当前位置: 首页>>代码示例>>C#>>正文


C# RectangleDouble.Inflate方法代码示例

本文整理汇总了C#中MatterHackers.Agg.RectangleDouble.Inflate方法的典型用法代码示例。如果您正苦于以下问题:C# RectangleDouble.Inflate方法的具体用法?C# RectangleDouble.Inflate怎么用?C# RectangleDouble.Inflate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MatterHackers.Agg.RectangleDouble的用法示例。


在下文中一共展示了RectangleDouble.Inflate方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ScaleMeshToView

		private void ScaleMeshToView(List<MeshGroup> loadedMeshGroups)
		{
			if (loadedMeshGroups != null)
			{
				AxisAlignedBoundingBox meshBounds = GetAxisAlignedBoundingBox(loadedMeshGroups);

				bool done = false;
				double scallFraction = .1;
				RectangleDouble goalBounds = new RectangleDouble(0, 0, size.x, size.y);
				goalBounds.Inflate(-10);
				while (!done)
				{
					RectangleDouble partScreenBounds = GetScreenBounds(meshBounds);

					if (!NeedsToBeSmaller(partScreenBounds, goalBounds))
					{
						trackballTumbleWidget.TrackBallController.Scale *= (1 + scallFraction);
						partScreenBounds = GetScreenBounds(meshBounds);

						// If it crossed over the goal reduct the amount we are adjusting by.
						if (NeedsToBeSmaller(partScreenBounds, goalBounds))
						{
							scallFraction /= 2;
						}
					}
					else
					{
						trackballTumbleWidget.TrackBallController.Scale *= (1 - scallFraction);
						partScreenBounds = GetScreenBounds(meshBounds);

						// If it crossed over the goal reduct the amount we are adjusting by.
						if (!NeedsToBeSmaller(partScreenBounds, goalBounds))
						{
							scallFraction /= 2;
							if (scallFraction < .001)
							{
								done = true;
							}
						}
					}
				}
			}
		}
开发者ID:CodeMangler,项目名称:MatterControl,代码行数:43,代码来源:ThumbnailTracer.cs

示例2: SavingFunction

        public void SavingFunction()
        {
            currentlySaving = true;
            countThatHaveBeenSaved = 0;
            // first create images for all the parts
            foreach (FileNameAndPresentationName stlFileNames in stlFilesToPrint)
            {
                Mesh loadedMesh = StlProcessing.Load(stlFileNames.fileName);
                if (loadedMesh != null)
                {
                    AxisAlignedBoundingBox aabb = loadedMesh.GetAxisAlignedBoundingBox();
                    RectangleDouble bounds2D = new RectangleDouble(aabb.minXYZ.x, aabb.minXYZ.y, aabb.maxXYZ.x, aabb.maxXYZ.y);
                    double widthInMM = bounds2D.Width + PartMarginMM * 2;
                    double textSpaceMM = 5;
                    double heightMM = textSpaceMM + bounds2D.Height + PartMarginMM * 2;

                    TypeFacePrinter typeFacePrinter = new TypeFacePrinter(stlFileNames.presentationName, 28, Vector2.Zero, Justification.Center, Baseline.BoundsCenter);
                    double sizeOfNameX = typeFacePrinter.GetSize().x + PartMarginPixels * 2;
                    Vector2 sizeOfRender = new Vector2(widthInMM * PixelPerMM, heightMM * PixelPerMM);

                    ImageBuffer imageOfPart = new ImageBuffer((int)(Math.Max(sizeOfNameX, sizeOfRender.x)), (int)(sizeOfRender.y), 32, new BlenderBGRA());
                    typeFacePrinter.Origin = new Vector2(imageOfPart.Width / 2, (textSpaceMM / 2) * PixelPerMM);

                    Graphics2D partGraphics2D = imageOfPart.NewGraphics2D();

                    RectangleDouble rectBounds = new RectangleDouble(0, 0, imageOfPart.Width, imageOfPart.Height);
                    double strokeWidth = .5 * PixelPerMM;
                    rectBounds.Inflate(-strokeWidth / 2);
                    RoundedRect rect = new RoundedRect(rectBounds, PartMarginMM * PixelPerMM);
                    partGraphics2D.Render(rect, RGBA_Bytes.LightGray);
                    Stroke rectOutline = new Stroke(rect, strokeWidth);
                    partGraphics2D.Render(rectOutline, RGBA_Bytes.DarkGray);

                    PolygonMesh.Rendering.OrthographicZProjection.DrawTo(partGraphics2D, loadedMesh, new Vector2(-bounds2D.Left + PartMarginMM, -bounds2D.Bottom + textSpaceMM + PartMarginMM), PixelPerMM, RGBA_Bytes.Black);
                    partGraphics2D.Render(typeFacePrinter, RGBA_Bytes.Black);

                    partImagesToPrint.Add(new PartImage(imageOfPart));
                }
                countThatHaveBeenSaved++;
                if (UpdateRemainingItems != null)
                {
                    UpdateRemainingItems(this, new StringEventArgs(Path.GetFileName(stlFileNames.presentationName)));
                }
            }

            partImagesToPrint.Sort(BiggestToLittlestImages);

            PdfDocument document = new PdfDocument();
            document.Info.Title = "MatterHackers Parts Sheet";
            document.Info.Author = "MatterHackers Inc.";
            document.Info.Subject = "This is a list of the parts that are in a queue from MatterControl.";
            document.Info.Keywords = "MatterControl, STL, 3D Printing";

            int nextPartToPrintIndex = 0;
            int plateNumber = 1;
            bool done = false;
            while (!done && nextPartToPrintIndex < partImagesToPrint.Count)
            {
                PdfPage pdfPage = document.AddPage();
                CreateOnePage(plateNumber++, ref nextPartToPrintIndex, pdfPage);
            }
			try
			{
                // save the final document
            	document.Save(pathAndFileToSaveTo);
                // Now try and open the document. This will lanch whatever PDF viewer is on the system and ask it 
                // to show the file (at least on Windows).
            	Process.Start(pathAndFileToSaveTo);
			}
			catch (Exception)
            {
			}

            OnDoneSaving();
            currentlySaving = false;
        }
开发者ID:klewisjohnson,项目名称:MatterControl,代码行数:76,代码来源:PartsSheetCreator.cs

示例3: CreateBase

		private void CreateBase(List<MeshGroup> meshesList, List<Matrix4X4> meshTransforms, List<PlatingMeshGroupData> platingDataList)
		{
			if (meshesList.Count > 0)
			{
				AxisAlignedBoundingBox bounds = meshesList[0].GetAxisAlignedBoundingBox(meshTransforms[0]);
				for (int i = 1; i < meshesList.Count; i++)
				{
					bounds = AxisAlignedBoundingBox.Union(bounds, meshesList[i].GetAxisAlignedBoundingBox(meshTransforms[i]));
				}

				double roundingScale = 20;
				RectangleDouble baseRect = new RectangleDouble(bounds.minXYZ.x, bounds.minXYZ.y, bounds.maxXYZ.x, bounds.maxXYZ.y);
				baseRect.Inflate(2);
				baseRect *= roundingScale;
				RoundedRect baseRoundedRect = new RoundedRect(baseRect, 1 * roundingScale);

				Mesh baseMeshResult = VertexSourceToMesh.Extrude(baseRoundedRect, unscaledBaseHeight / 2 * roundingScale * sizeScrollBar.Value * heightScrollBar.Value);

				baseMeshResult.Transform(Matrix4X4.CreateScale(1 / roundingScale));

				meshesList.Add(new MeshGroup(baseMeshResult));
				platingDataList.Add(new PlatingMeshGroupData());
				meshTransforms.Add(Matrix4X4.CreateTranslation(0, 0, 0));
				PlatingHelper.CreateITraceableForMeshGroup(platingDataList, meshesList, meshesList.Count - 1, null);
			}
		}
开发者ID:tellingmachine,项目名称:MatterControl,代码行数:26,代码来源:View3DBrailleBuilder.cs


注:本文中的MatterHackers.Agg.RectangleDouble.Inflate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。