//--------------------------------------------------------------------------------------------------

        public override bool Start()
        {
            if (!_Flags.HasFlag(Flags.ForceManualSelect) &&
                UnfoldSheet.CanFindStartFace(_TargetBody.GetBRep()))
            {
                // Auto mode for start face can be used
                var unfoldSheet = UnfoldSheet.Create(_TargetBody);
                if (unfoldSheet != null)
                {
                    ((Tool)this).Stop();
                    InteractiveContext.Current.UndoHandler.Commit();
                    InteractiveContext.Current.WorkspaceController.Selection.SelectEntity(_TargetBody);
                    WorkspaceController.Invalidate();
                    return(false);
                }
            }

            var toolAction = new SelectSubshapeAction(this, SubshapeTypes.Face, _TargetBody, new FaceSelectionFilter(FaceSelectionFilter.FaceType.Plane));

            if (!WorkspaceController.StartToolAction(toolAction))
            {
                return(false);
            }
            toolAction.Finished += _OnActionFinished;

            StatusText = "Select start face for unfolding.";
            WorkspaceController.HudManager?.SetCursor(Cursors.SelectFace);
            return(true);
        }
        public void NoRadius()
        {
            var source = TestData.GetBodyFromBRep(Path.Combine(_BasePath, @"..\FlangeSheet\NoRadius.brep"));

            Assume.That(source, Is.Not.Null);

            var unfold = UnfoldSheet.Create(source);

            Assume.That(unfold, Is.Not.Null);

            Assert.That(unfold.Make(Shape.MakeFlags.DebugOutput));
            Assert.That(ModelCompare.CompareShape(unfold, Path.Combine(_BasePath, "NoRadius")));
        }
        public void SimpleMultiple()
        {
            var source = TestData.GetBodyFromBRep(Path.Combine(_BasePath, "SimpleMultiple_Source.brep"));

            Assume.That(source, Is.Not.Null);

            var unfold = UnfoldSheet.Create(source);

            Assume.That(unfold, Is.Not.Null);

            Assert.That(unfold.Make(Shape.MakeFlags.DebugOutput));
            Assert.That(ModelCompare.CompareShape(unfold, Path.Combine(_BasePath, "SimpleMultiple")));
        }
        public void AnotherStartFace()
        {
            var source = TestData.GetBodyFromBRep(Path.Combine(_BasePath, "NoFlange_Source.brep"));

            Assume.That(source, Is.Not.Null);

            var unfold = UnfoldSheet.Create(source, source.Shape.GetSubshapeReference(SubshapeType.Face, 3)); // Also try with 2

            Assume.That(unfold, Is.Not.Null);

            Assert.That(unfold.Make(Shape.MakeFlags.DebugOutput));
            Assert.That(ModelCompare.CompareShape(unfold, Path.Combine(_BasePath, "AnotherStartFace")));
        }
        //--------------------------------------------------------------------------------------------------

        void _OnActionFinished(ToolAction toolAction)
        {
            bool finished     = false;
            var  selectAction = toolAction as SelectSubshapeAction;

            Debug.Assert(selectAction != null);

            if (selectAction.SelectedSubshapeType == SubshapeTypes.Face)
            {
                var face        = TopoDS.Face(selectAction.SelectedSubshape);
                var brepAdaptor = new BRepAdaptor_Surface(face, true);
                if (brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Plane)
                {
                    StatusText = "Selected face is not a plane type surface.";
                }
                else
                {
                    selectAction.Stop();
                    ((Tool)this).Stop();
                    finished = true;

                    // We have found a plane
                    var startFaceRef = _TargetBody.Shape.GetSubshapeReference(_TargetBody.GetTransformedBRep(), face);
                    var unfoldSheet  = UnfoldSheet.Create(_TargetBody, startFaceRef);
                    if (unfoldSheet != null)
                    {
                        InteractiveContext.Current.UndoHandler.Commit();
                        InteractiveContext.Current.WorkspaceController.Selection.SelectEntity(_TargetBody);
                    }
                }
            }

            if (!finished)
            {
                selectAction.Reset();
            }

            WorkspaceController.Invalidate();
        }
Esempio n. 6
0
        //--------------------------------------------------------------------------------------------------

        public override void Initialize(BaseObject instance)
        {
            UnfoldSheet = instance as UnfoldSheet;

            InitializeComponent();
        }