예제 #1
0
        //--------------------------------------------------------------------------------------------------

        void _OnFaceSelected(SelectSubshapeAction selectAction)
        {
            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 &&
                    brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Cylinder &&
                    brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Cone)
                {
                    StatusText = "Selected face is not a plane, cylinder or cone type surface.";
                    selectAction.Reset();
                    return;
                }

                selectAction.Stop();

                _TargetFace      = face;
                _Phase           = Phase.BaseEdgeOrVertex;
                _SubshapesOfFace = new List <TopoDS_Shape>();
                var edges = face.Edges().Where(
                    edge =>
                {
                    var analysis = new ShapeAnalysis_Edge();
                    return(!analysis.IsSeam(edge, face));
                }).ToList();
                _SubshapesOfFace.AddRange(edges);

                var vertices = face.Vertices().Where(
                    vertex =>
                {
                    var vertexEdges = edges.Where(edge => edge.Vertices().ContainsSame(vertex));
                    return(vertexEdges.Count() > 1);
                });
                _SubshapesOfFace.AddRange(vertices);

                var newAction = new SelectSubshapeAction(this, _SubshapesOfFace);
                if (!WorkspaceController.StartToolAction(newAction))
                {
                    Stop();
                    return;
                }
                newAction.Previewed += _OnActionPreview;
                newAction.Finished  += _OnActionFinished;

                StatusText = "Select base edge or vertex to define direction of taper.";
                WorkspaceController.HudManager?.SetCursor(Cursors.SelectEdge);
            }
        }
예제 #2
0
        /// <summary>
        ///   Returns 1 if the point is outside te face and -1 is inside or on the face.
        /// </summary>
        /// <param name = "point"></param>
        /// <returns></returns>
        private int GetDirection(gpPnt point)
        {
            var direction = 1;

            if (_selectedNodes[0].ShapeType == TopAbsShapeEnum.TopAbs_FACE)
            {
                var face       = TopoDS.Face(_selectedNodes[0].Node.Get <TopoDsShapeInterpreter>().Shape);
                var classifier = new IntToolsContext();
                if (classifier.IsValidPointForFace(point, face, Precision.Confusion))
                {
                    direction = -1;
                }
            }
            return(direction);
        }
예제 #3
0
        public static TopoDSShape ExtractSubShape(
            TopoDSShape originalShape,
            int facePosition,
            TopAbsShapeEnum shapeType)
        {
            if (originalShape == null)
            {
                return(null);
            }
            // Find the face
            var baseEx = new TopExpExplorer();

            baseEx.Init(originalShape, shapeType, TopAbsShapeEnum.TopAbs_SHAPE);

            while (baseEx.More && (facePosition != 1))
            {
                baseEx.Next();
                facePosition--;
            }
            //if (!baseEx.More())
            //    return null;
            TopoDSShape shape = null;

            switch (shapeType)
            {
            case TopAbsShapeEnum.TopAbs_VERTEX:
                shape = TopoDS.Vertex(baseEx.Current);
                break;

            case TopAbsShapeEnum.TopAbs_EDGE:
                shape = TopoDS.Edge(baseEx.Current);
                break;

            case TopAbsShapeEnum.TopAbs_WIRE:
                shape = TopoDS.Wire(baseEx.Current);
                break;

            case TopAbsShapeEnum.TopAbs_FACE:
                shape = TopoDS.Face(baseEx.Current);
                break;

            case TopAbsShapeEnum.TopAbs_SOLID:
            case TopAbsShapeEnum.TopAbs_COMPOUND:
                return(originalShape);
            }
            return(shape);
        }
예제 #4
0
        public override bool Execute()
        {
            var draftedShape = Dependency[0].ReferedShape;
            var draftedFace  = TopoDS.Face(Dependency[0].ReferenceData.TargetShape());

            var draftReferenceShape = Dependency[1].ReferenceData.TargetShape();

            Ensure.IsTrue(draftReferenceShape.ShapeType == TopAbsShapeEnum.TopAbs_FACE);
            var draftReferenceFace = TopoDS.Face(draftReferenceShape);
            var draftDirection     = GeomUtils.ExtractDirection(draftReferenceFace).Reversed;

            var angle = Dependency[3].Real;

            if (Math.Abs(angle) < Precision.Angular)
            {
                return(false);
            }

            var neutralPlaneNormal = Dependency[2].Axis3D.GpAxis;
            var neutralPlane       = new gpPln(neutralPlaneNormal.Location, neutralPlaneNormal.Direction);

            var draft = new BRepOffsetAPIDraftAngle(draftedShape);

            var draftSuceeded = BuildFaceDraft(draft, draftedFace, draftDirection, angle, neutralPlane);

            if (!draftSuceeded)
            {
                return(false);
            }

            draft.Build();
            if (!draft.IsDone)
            {
                return(false);
            }
            if (draft.Status != DraftErrorStatus.Draft_NoError)
            {
                return(false);
            }
            var refNode = Dependency[0].Reference;

            NodeUtils.Hide(refNode);

            Shape = draft.Shape;

            return(true);
        }
        //--------------------------------------------------------------------------------------------------

        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);
                selectAction.Stop();
                Stop();
                finished = true;
                var faceRef = _TargetShape.GetSubshapeReference(_TargetShape.GetTransformedBRep(), face);
                if (faceRef == null)
                {
                    Messages.Error("A subshape reference could not be produced for this face.");
                    return;
                }

                if (_Mode == ToolMode.CreateNew)
                {
                    // Create new
                    var extrude = Extrude.Create(_TargetBody, faceRef);
                    if (extrude != null)
                    {
                        InteractiveContext.Current.UndoHandler.Commit();
                        InteractiveContext.Current.WorkspaceController.Selection.SelectEntity(_TargetBody);
                    }
                }
                else if (_Mode == ToolMode.ReselectFace)
                {
                    // Reselected face
                    _ExtrudeToChange.Face = faceRef;
                    _ExtrudeToChange.Invalidate();
                    InteractiveContext.Current.UndoHandler.Commit();
                }
            }

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

            WorkspaceController.Invalidate();
        }
예제 #6
0
        //--------------------------------------------------------------------------------------------------

        void _SelectFaceAction_OnFinished(ToolAction toolaction)
        {
            Debug.Assert(toolaction == _SelectFaceAction);

            if (_SelectFaceAction.SelectedSubshapeType == SubshapeTypes.Face)
            {
                var face        = TopoDS.Face(_SelectFaceAction.SelectedSubshape);
                var brepAdaptor = new BRepAdaptor_Surface(face, true);
                if (brepAdaptor.GetGeomType() != GeomAbs_SurfaceType.GeomAbs_Plane)
                {
                    StatusText = "Selected face is not a plane type surface.";
                    _SelectFaceAction.Reset();
                    return;
                }

                var subshapeReference = _Body.Shape.GetSubshapeReference(_ShapeForFaceSelection.GetTransformedBRep(), _SelectFaceAction.SelectedSubshape);

                if (subshapeReference != null)
                {
                    if (_Component == null)
                    {
                        _CreateComponent();
                    }
                    _Component.ReferenceFace = subshapeReference;
                    InteractiveContext.Current.UndoHandler.Commit();
                }
                else
                {
                    Messages.Error("A subshape reference could not be produced for this subshape.");
                }
            }

            ToggleFaceSelection();

            if (_Component != null)
            {
                _InitInteractions();
            }
            else
            {
                Stop();
            }
        }
예제 #7
0
        public static bool IsPlanarFace(TopoDSShape shape)
        {
            TopoDSFace face;

            try
            {
                if ((shape.IsNull) || (shape.ShapeType != TopAbsShapeEnum.TopAbs_FACE))
                {
                    return(false);
                }
                face = TopoDS.Face(shape);
            }
            catch
            {
                return(false);
            }
            var aFaceElementAdaptor = new BRepAdaptorSurface(face, true);
            var surfaceType         = aFaceElementAdaptor.GetType;

            return(surfaceType == GeomAbsSurfaceType.GeomAbs_Plane);
        }
예제 #8
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Property List

        void _InitProperties()
        {
            if (_Properties != null)
            {
                return;
            }

            _Properties = new List <BRepTopologyTreeProperty>();
            try
            {
                _AddDefaultProperties();

                switch (BrepShape.ShapeType())
                {
                case TopAbs_ShapeEnum.TopAbs_SHELL:
                    _AddShellProperties(BrepShape as TopoDS_Shell ?? TopoDS.Shell(BrepShape));
                    break;

                case TopAbs_ShapeEnum.TopAbs_FACE:
                    _AddFaceProperties(BrepShape as TopoDS_Face ?? TopoDS.Face(BrepShape));
                    break;

                case TopAbs_ShapeEnum.TopAbs_WIRE:
                    _AddWireProperties(BrepShape as TopoDS_Wire ?? TopoDS.Wire(BrepShape));
                    break;

                case TopAbs_ShapeEnum.TopAbs_EDGE:
                    _AddEdgeProperties(BrepShape as TopoDS_Edge ?? TopoDS.Edge(BrepShape));
                    break;

                case TopAbs_ShapeEnum.TopAbs_VERTEX:
                    _AddVertexProperties(BrepShape as TopoDS_Vertex ?? TopoDS.Vertex(BrepShape));
                    break;
                }
            }
            catch (Exception e)
            {
                Messages.Exception($"Error getting properties for B-Rep shape {Name}", e);
            }
        }
예제 #9
0
        public override bool Execute()
        {
            // Get the extrusion referenece shape, height and extrusion type
            var offsetShape  = Dependency[0].ReferedShape;
            var offsetLength = Dependency[1].Real;

            // Don't allow 0 offset
            if (Math.Abs(offsetLength) < Precision.Confusion)
            {
                return(false);
            }

            //TopoDSShape resultShape = NodeUtils.GenerateWireOffset(offsetShapes, offsetLength);
            // ! Currently only offset on 2D closed shapes of type Face can be made
            if (offsetShape.ShapeType != TopAbsShapeEnum.TopAbs_FACE)
            {
                return(false);
            }

            var face        = TopoDS.Face(offsetShape);
            var resultShape = GeomUtils.GenerateFaceOffset(face, offsetLength);

            if ((resultShape == null) || (resultShape.IsNull))
            {
                return(false);
            }

            var wire       = TopoDS.Wire(resultShape);
            var offsetFace = new BRepBuilderAPIMakeFace(wire, false).Face;

            if (offsetFace.IsNull)
            {
                return(false);
            }

            // Set the result in the NamedShapeInterpreter and make the shape visible
            Shape = offsetFace;

            return(true);
        }
예제 #10
0
        //--------------------------------------------------------------------------------------------------

        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.";
                }

                finished = true;
            }

            if (finished)
            {
                var subshapeReference = _TargetShape.GetSubshapeReference(_TargetShape.GetTransformedBRep(), selectAction.SelectedSubshape);
                selectAction.Stop();
                Stop();

                if (subshapeReference == null)
                {
                    Messages.Error("A subshape reference could not be produced for this subshape.");
                    return;
                }

                _SelectedFunc.Invoke(subshapeReference);
            }
            else
            {
                selectAction.Reset();
            }

            WorkspaceController.Invalidate();
        }
예제 #11
0
        //--------------------------------------------------------------------------------------------------

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

            Debug.Assert(selectAction != null);

            if (selectAction.SelectedEntity is DatumPlane datumPlane)
            {
                _Plane   = new Pln(datumPlane.GetCoordinateSystem());
                finished = true;
            }
            else 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
                {
                    FaceAlgo.GetCenteredPlaneFromFace(face, out _Plane);
                    finished = true;
                }
            }

            if (finished)
            {
                selectAction.Stop();
                Stop();
                CreateSketch();
            }
            else
            {
                selectAction.Reset();
            }

            WorkspaceController.Invalidate();
        }
        //--------------------------------------------------------------------------------------------------

        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();
        }
예제 #13
0
        /// <summary>
        ///   Applies fillet on the edges of a Face generated from a wire.
        /// </summary>
        private static TopoDSFace ApplyFilletOnFace(IList <SceneSelectedEntity> filletNodes, double radius,
                                                    int filletChamferType)
        {
            // This method processes only fillet2D and chamfer2D operations
            if ((filletChamferType != (int)FilletChamferTypes.SimpleFillet2D) &&
                (filletChamferType != (int)FilletChamferTypes.SimpleChamfer2D))
            {
                return(null);
            }

            // There should be at least two edges to apply fillet on them
            if (filletNodes.Count < 2)
            {
                return(null);
            }

            // Check that the list contains only edges
            foreach (var node in filletNodes)
            {
                if (node.ShapeType != TopAbsShapeEnum.TopAbs_EDGE)
                {
                    return(null);
                }
            }

            try
            {
                var fillet = new BRepFilletAPIMakeFillet2d();
                // Initialize a fillet with the parent face of the edges
                var face = TopoDS.Face(filletNodes[0].Node.Get <TopoDsShapeInterpreter>().Shape);
                fillet.Init(face);

                // Fillet the common vertexes
                SceneSelectedEntity previousNode = null;
                foreach (var node in filletNodes)
                {
                    if (previousNode != null)
                    {
                        AddFaceFilletVertex(face, filletChamferType, radius, previousNode, node, fillet);
                    }
                    previousNode = node;
                }
                // Add also the last and first edges if they have a common node in the case there are more than 2 edges
                if ((previousNode != null) && (filletNodes.Count > 2))
                {
                    AddFaceFilletVertex(face, filletChamferType, radius, previousNode, filletNodes[0], fillet);
                }

                // Test if the operation succeeded
                if (fillet.Status != ChFi2dConstructionError.ChFi2d_IsDone)
                {
                    return(null);
                }

                var shape = fillet.Shape;
                if ((shape == null) || (shape.IsNull))
                {
                    return(null);
                }

                return(shape.ShapeType == TopAbsShapeEnum.TopAbs_FACE ? TopoDS.Face(shape) : null);
            }
            catch (Exception ex)
            {
                Log.Info("Apply Fillet2D error: " + ex.Message);
            }

            return(null);
        }
예제 #14
0
        //--------------------------------------------------------------------------------------------------

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

            Debug.Assert(selectAction != null);

            SubshapeReference subshapeRef = null;

            switch (_TargetShape.ShapeType)
            {
            case ShapeType.Sketch:
                if (selectAction.SelectedSubshapeType == SubshapeTypes.Edge)
                {
                    subshapeRef = _TargetShape.GetSubshapeReference(_TargetShape.GetTransformedBRep(), TopoDS.Edge(selectAction.SelectedSubshape));
                }
                break;

            case ShapeType.Solid:
                if (selectAction.SelectedSubshapeType == SubshapeTypes.Face)
                {
                    subshapeRef = _TargetShape.GetSubshapeReference(_TargetShape.GetTransformedBRep(), TopoDS.Face(selectAction.SelectedSubshape));
                }
                break;

            default:
                return;
            }

            if (subshapeRef != null)
            {
                selectAction.Stop();
                Stop();

                if (_Mode == ToolMode.CreateNew)
                {
                    var mirror = Mirror.Create(_TargetBody, subshapeRef);
                    if (mirror != null)
                    {
                        InteractiveContext.Current.UndoHandler.Commit();
                        //InteractiveContext.Current.WorkspaceController.Selection.SelectEntity(_TargetBody);
                    }
                }
                else if (_Mode == ToolMode.Reselect)
                {
                    // Reselected face or edge
                    _ModifierToChange.ReferenceShape = subshapeRef;
                    _ModifierToChange.Invalidate();
                    InteractiveContext.Current.UndoHandler.Commit();
                }
            }
            else
            {
                selectAction.Reset();
            }

            WorkspaceController.Invalidate();
        }
예제 #15
0
        //--------------------------------------------------------------------------------------------------

        public static TopoDS_Face ToFace(this TopoDS_Shape shape)
        {
            return(shape == null ? null : TopoDS.Face(shape));
        }
        //--------------------------------------------------------------------------------------------------

        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();
                    Stop();
                    finished = true;
                    var faceRef = _TargetShape.GetSubshapeReference(_TargetBrep, face);
                    if (faceRef == null)
                    {
                        Messages.Error("A subshape reference could not be produced for this face.");
                        return;
                    }

                    if (_Mode == ToolMode.CreateNew)
                    {
                        // Create new
                        var sketch = new Sketch
                        {
                            Body = _TargetBody,
                        };

                        var imprint = Imprint.Create(_TargetBody, faceRef, sketch);
                        if (imprint != null)
                        {
                            imprint.Mode = _ImprintMode;
                            InteractiveContext.Current.UndoHandler.Commit();
                            InteractiveContext.Current.WorkspaceController.Selection.SelectEntity(_TargetBody);
                            WorkspaceController.StartTool(new SketchEditorTool(sketch));
                        }
                    }
                    else if (_Mode == ToolMode.ReselectFace)
                    {
                        // Reselected face
                        _ImprintToChange.Face = faceRef;
                        _ImprintToChange.Invalidate();
                        InteractiveContext.Current.UndoHandler.Commit();
                    }
                }
            }

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

            WorkspaceController.Invalidate();
        }
예제 #17
0
        private static TopoDSShape ApplyFillet(double thickness, TopoDSShape body, int edgeNumber, int operationType)
        {
            try
            {
                // Create fillet
                var aEdgeExplorer = new TopExpExplorer(body, TopAbsShapeEnum.TopAbs_EDGE,
                                                       TopAbsShapeEnum.TopAbs_SHAPE);

                var         number = 1;
                TopoDSShape shape  = null;
                while (aEdgeExplorer.More)
                {
                    if ((edgeNumber == 0) || (edgeNumber == number))
                    {
                        var anEdge = TopoDS.Edge(aEdgeExplorer.Current);

                        if (operationType == (int)FilletChamferTypes.SimpleFillet)
                        {
                            var fillet = new BRepFilletAPIMakeFillet(body, ChFi3dFilletShape.ChFi3d_Rational);
                            // Add edge to fillet algorithm
                            fillet.Add(thickness, anEdge);
                            // Check if valid contour
                            try
                            {
                                if (fillet.StripeStatus(fillet.Contour(anEdge)) != ChFiDSErrorStatus.ChFiDS_Ok)
                                {
                                    return(null);
                                }
                            }
                            catch (Exception)
                            {
                                Log.Info("Exception on applying fillet");
                            }
                            shape = fillet.Shape;
                        }
                        else
                        {
                            var chamfer = new BRepFilletAPIMakeChamfer(body);
                            var aMap    = new TopToolsIndexedDataMapOfShapeListOfShape(1);
                            TopExp.MapShapesAndAncestors(body, TopAbsShapeEnum.TopAbs_EDGE, TopAbsShapeEnum.TopAbs_FACE,
                                                         aMap);
                            // Locate an ancestor face
                            for (var i = 1; i < aMap.Extent; i++)
                            {
                                var localEdge = TopoDS.Edge(aMap.FindKey(i));
                                if (!anEdge.IsSame(localEdge))
                                {
                                    continue;
                                }
                                // We found an ancestor face
                                var face = TopoDS.Face(aMap.FindFromIndex(i).First);
                                // Add the edge and face on the chmafer algorithm
                                chamfer.Add(thickness, thickness, anEdge, face);
                            }
                            shape = chamfer.Shape;
                        }
                    }

                    aEdgeExplorer.Next();
                    number++;
                }

                // Check the shape validity

                if ((shape == null) || (shape.IsNull))
                {
                    return(null);
                }

                return(shape);
            }
            catch (Exception ex)
            {
                Log.Info("Apply fillet error: " + ex.Message);
            }
            return(null);
        }
예제 #18
0
        //--------------------------------------------------------------------------------------------------

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

            Debug.Assert(selectAction != null);

            if (selectAction.SelectedEntity is DatumPlane plane)
            {
                WorkspaceController.Workspace.WorkingPlane = new Pln(plane.GetCoordinateSystem());
                finished = true;
            }
            else
            {
                switch (selectAction.SelectedSubshapeType)
                {
                case 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
                    {
                        double centerU   = brepAdaptor.FirstUParameter() + (brepAdaptor.LastUParameter() - brepAdaptor.FirstUParameter()) / 2;
                        double centerV   = brepAdaptor.FirstVParameter() + (brepAdaptor.LastVParameter() - brepAdaptor.FirstVParameter()) / 2;
                        var    centerPnt = brepAdaptor.Value(centerU, centerV);

                        WorkspaceController.Workspace.WorkingPlane = new Pln(centerPnt, brepAdaptor.Plane().Axis.Direction);
                        finished = true;
                    }

                    break;
                }

                case SubshapeTypes.Edge:
                {
                    var    edge = TopoDS.Edge(selectAction.SelectedSubshape);
                    double firstParam = 0, lastParam = 0;
                    var    curve = BRep_Tool.Curve(edge, ref firstParam, ref lastParam);
                    if (curve != null)
                    {
                        var midpoint = curve.Value(firstParam + (lastParam - firstParam) / 2);

                        WorkspaceController.Workspace.WorkingPlane = new Pln(midpoint, WorkspaceController.Workspace.WorkingPlane.Axis.Direction);
                        finished = true;
                    }

                    break;
                }

                case SubshapeTypes.Vertex:
                {
                    var vertex = TopoDS.Vertex(selectAction.SelectedSubshape);
                    WorkspaceController.Workspace.WorkingPlane = new Pln(BRep_Tool.Pnt(vertex), WorkspaceController.Workspace.WorkingPlane.Axis.Direction);
                    finished = true;
                    break;
                }
                }
            }

            if (finished)
            {
                selectAction.Stop();
                Stop();
            }
            else
            {
                selectAction.Reset();
            }

            WorkspaceController.Invalidate();
        }