Exemplo n.º 1
0
        void Unfold(Body body, Face startFace, bool isDetectingCollisions, bool isCreatingDashes, double breakAngle, double dashSize)
        {
            DateTime startTime = DateTime.Now;

            FlatPattern flatPattern = new FlatPattern(body, startFace, isDetectingCollisions, isCreatingDashes, breakAngle, dashSize, Resources.FlatPatternText);

            DateTime calcTime     = DateTime.Now;
            double   calcDuration = (calcTime - startTime).TotalSeconds;

            flatPattern.Render();
            double drawDuration = (DateTime.Now - calcTime).TotalSeconds;

            int n = 0;

            foreach (FlatBody flatBody in flatPattern.FlatBodies)
            {
                foreach (FlatFace flatFace in flatBody.FlatFaces)
                {
                    foreach (FlatLoop flatLoop in flatFace.Loops)
                    {
                        n++;
                    }
                }
            }

            string output =
                String.Format("Unfolded {0:D} faces in {1:F} s. ({2:F} fps.) \n", n, Math.Round(calcDuration, 2), Math.Round((double)n / calcDuration, 2)) +
                String.Format("Modeled {0:F} seconds. ({1:F} fps.)", Math.Round(drawDuration, 2), Math.Round((double)n / drawDuration, 2))
            ;

            Application.ReportStatus(output, StatusMessageType.Information, null);
        }
Exemplo n.º 2
0
        protected override void OnExecute(Command command, ExecutionContext context, System.Drawing.Rectangle buttonRect)
        {
            //isDetectingCollisions = Booleans[Resources.DetectCollisionsText].Value;
            //isCreatingDashes = Booleans[Resources.CreateDashesText].Value;

            Part part = Window.ActiveWindow.Scene as Part;

            if (part == null)
            {
                return;
            }

            Layer curveLayer = NoteHelper.CreateOrGetLayer(Window.ActiveWindow.Document, Resources.FlatMediumEngravingLayerName, System.Drawing.Color.Green);
            Layer planeLayer = NoteHelper.CreateOrGetLayer(part.Document, Resources.AnnotationPlanesLayerName, Color.Gray);

            planeLayer.SetVisible(null, false);
            foreach (Component component in part.Components)
            {
                Body body = component.Content.Bodies.First().Master.Shape.Copy();
                body.Transform(component.Content.TransformToMaster.Inverse);
                Face startFace = body.Faces.First();

                string      name        = component.Content.Master.Name;
                FlatPattern flatPattern = new FlatPattern(body, startFace, isDetectingCollisions, false, 0, 0, name);
                flatPattern.Render();

                DatumPlane datumPlane = DatumPlane.Create(flatPattern.FlatPart, Resources.AnnotationPlaneName, flatPattern.PaperPlane);
                datumPlane.Layer = planeLayer;
                PointUV center = flatPattern.PaperPlane.ProjectPoint(flatPattern.GetBoundingBox(Matrix.Identity).Center).Param;
                Note    note   = Note.Create(datumPlane, center, TextPoint.Center, 0.01, name);
                note.Layer = NoteHelper.CreateOrGetLayer(part.Document, Resources.AnnotationLayerName, System.Drawing.Color.DarkViolet);

                foreach (FlatBody flatBody in flatPattern.FlatBodies)
                {
                    foreach (FlatFace flatFace in flatBody.FlatFaces)
                    {
                        foreach (ITrimmedCurve iTrimmedCurve in part.Curves.Select(c => c.Shape).Where(c => c.AreEndPointsOnFace(flatFace.SourceFace)))
                        {
                            var designCurve = DesignCurve.Create(flatBody.FlatPart, iTrimmedCurve);
                            designCurve.Transform(flatFace.Transform);
                            designCurve.Layer = curveLayer;
                        }
                    }
                }
            }
        }