//-------------------------------------------------------------------------------------------------- void _ExportEdges(List <TopoDS_Edge> edges, TopoDS_Face face) { // Order edges var order = new ShapeAnalysis_WireOrder(true, 0.0001); foreach (var edge in edges) { var first = BRep_Tool.Pnt(TopExp.FirstVertex(edge)); var last = BRep_Tool.Pnt(TopExp.LastVertex(edge)); if (edge.Orientation() == TopAbs_Orientation.TopAbs_FORWARD) { order.Add(first.Coord, last.Coord); } else { order.Add(last.Coord, first.Coord); } } order.Perform(true); if (order.IsDone()) { order.SetChains(0.0001); for (int chain = 1; chain <= order.NbChains(); chain++) { int startIndex = 0, endIndex = 0; order.Chain(chain, ref startIndex, ref endIndex); // Process ordered edges for (int i = startIndex; i <= endIndex; i++) { int orderIndex = order.Ordered(i); int originalIndex = Math.Abs(orderIndex) - 1; // order index is 1-based _ExportEdge(edges[originalIndex], orderIndex < 0, face); } // Add path to group ClosePath(); if (!CombineToPath) { FinalizePath(); } } } else { // Cannot sort, just pump out all edges foreach (var edge in edges) { _ExportEdge(edge, false, face); } // Add path to group if ((CurrentPath != null) && CurrentPath.Segments.Any()) { CurrentGroup.Children.Add(CurrentPath); } } }
//-------------------------------------------------------------------------------------------------- void _AddVertexProperties(TopoDS_Vertex vertex) { const string cat = "Vertex"; var pnt = BRep_Tool.Pnt(vertex); _AddProperty(cat, "Pnt", $"({pnt.X.ToRoundedString()}, {pnt.Y.ToRoundedString()}, {pnt.Z.ToRoundedString()})"); _AddProperty(cat, "Tolerance", $"{BRep_Tool.Tolerance(vertex)}"); }
//-------------------------------------------------------------------------------------------------- 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 { 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; } } else if (selectAction.SelectedSubshapeType == 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; } } else if (selectAction.SelectedSubshapeType == SubshapeTypes.Vertex) { var vertex = TopoDS.Vertex(selectAction.SelectedSubshape); WorkspaceController.Workspace.WorkingPlane = new Pln(BRep_Tool.Pnt(vertex), WorkspaceController.Workspace.WorkingPlane.Axis.Direction); finished = true; } if (finished) { selectAction.Stop(); Stop(); } else { selectAction.Reset(); } WorkspaceController.Invalidate(); }
//-------------------------------------------------------------------------------------------------- public static bool RenderEdges(IDrawingRenderer renderer, List <TopoDS_Edge> edges, TopoDS_Face face) { var res = true; // Order edges var order = new ShapeAnalysis_WireOrder(true, 0.0001); foreach (var edge in edges) { var first = BRep_Tool.Pnt(TopExp.FirstVertex(edge)); var last = BRep_Tool.Pnt(TopExp.LastVertex(edge)); if (edge.Orientation() == TopAbs_Orientation.TopAbs_FORWARD) { order.Add(first.Coord, last.Coord); } else { order.Add(last.Coord, first.Coord); } } order.Perform(true); if (order.IsDone()) { order.SetChains(0.0001); for (int chain = 1; chain <= order.NbChains(); chain++) { int startIndex = 0, endIndex = 0; order.Chain(chain, ref startIndex, ref endIndex); if (startIndex > endIndex) { continue; } // Process ordered edges renderer.BeginPathSegment(); for (int index = startIndex; index <= endIndex; index++) { int orderIndex = order.Ordered(index); int originalIndex = Math.Abs(orderIndex) - 1; // order index is 1-based res &= RenderEdge(renderer, edges[originalIndex], orderIndex < 0, face); } renderer.EndPathSegment(); } } else { // Cannot sort, just pump out all edges foreach (var edge in edges) { res &= RenderEdge(renderer, edge, false, face); } } return(res); }
//-------------------------------------------------------------------------------------------------- public static Geom_Curve Curve(this TopoDS_Edge edge, out double firstParam, out double lastParam) { firstParam = lastParam = 0; if (edge == null) { return(null); } return(BRep_Tool.Curve(edge, ref firstParam, ref lastParam)); }
public static gp_Dir ComputeNormal(this TopoDS_Face face) { double umin = 0, umax = 0, vmin = 0, vmax = 0; BRepTools.UVBounds(face, ref umin, ref umax, ref vmin, ref vmax); var surface = BRep_Tool.Surface(face); var props = new GeomLProp_SLProps(surface, umin, vmin, 1.0, 1e-1); return(props.Normal()); }
public static FaceIntersectionLineResult IntersectLine(this TopoDS_Face face, TopoDS_Face other, double tol) { var s1 = face.Surface(); var s2 = other.Surface(); var a = new GeomAPI_IntSS(s1, s2, tol); var C = a.Line(1); var edge = new BRepBuilderAPI_MakeEdge(C, C.FirstParameter(), C.LastParameter()); var v1 = edge.Vertex1(); var v2 = edge.Vertex2(); var i1 = BRep_Tool.Pnt(v1); var i2 = BRep_Tool.Pnt(v2); return(new FaceIntersectionLineResult(C, new Line3D(i1.ToVector3D(), i2.ToVector3D()))); }
//-------------------------------------------------------------------------------------------------- void _AddFaceProperties(TopoDS_Face face) { const string facecat = "Face"; const string surfcat = "Surface"; if (Shape != null) { var subshapeRef = Shape.GetSubshapeReference(_TopLevelShape, face); _AddProperty(facecat, "SubshapeRef", subshapeRef?.ToString() ?? "null"); } _AddProperty(facecat, "Tolerance", $"{BRep_Tool.Tolerance(face)}"); _AddProperty(facecat, "Nat.Restrict.", $"{(BRep_Tool.NaturalRestriction(face) ? "Yes" : "No")}"); var props = new GProp_GProps(); BRepGProp.SurfaceProperties(BrepShape, props); _AddProperty(facecat, "Area", $"{props.Mass()}"); var surface = BRep_Tool.Surface(face); if (surface != null) { _AddProperty(surfcat, "Class", surface.GetType().Name.Replace("Geom_", "")); double u1 = 0, u2 = 0, v1 = 0, v2 = 0; surface.Bounds(ref u1, ref u2, ref v1, ref v2); _AddProperty(surfcat, "Bounds U", $"({u1}, {u2})"); _AddProperty(surfcat, "Bounds V", $"({v1}, {v2})"); _AddProperty(surfcat, "Is Closed", $"U={(surface.IsUClosed() ? "Yes" : "No")} V={(surface.IsUClosed() ? "Yes" : "No")}"); if (surface.IsUPeriodic() || surface.IsVPeriodic()) { var s = ""; if (surface.IsUPeriodic()) { s += $"U={surface.UPeriod()} "; } if (surface.IsVPeriodic()) { s += $"V={surface.VPeriod()} "; } _AddProperty(surfcat, "Period", s); } _AddProperty(surfcat, "Continuity", surface.Continuity().ToString().Replace("GeomAbs_", "")); } }
//-------------------------------------------------------------------------------------------------- double _FindEdgeParam(TopoDS_Edge edge, SelectSubshapeAction selectAction) { // Calculate parameter on the edge double umin = 0, umax = 0; var curve = BRep_Tool.Curve(edge, ref umin, ref umax); var viewAxis = selectAction.LastMouseEventData.PickAxis; var extrema = new GeomAPI_ExtremaCurveCurve(curve, new Geom_Line(viewAxis)); if (extrema.NbExtrema() > 0) { double param1 = 0, param2 = 0; extrema.LowerDistanceParameters(ref param1, ref param2); return(param1); } else { return(Taper.CalculateBaseParameter(edge, 0.5)); } }
//-------------------------------------------------------------------------------------------------- public static bool RenderEdge(IDrawingRenderer renderer, TopoDS_Edge edge, bool reverse, TopoDS_Face face) { var res = true; reverse ^= edge.Orientation() == TopAbs_Orientation.TopAbs_REVERSED; double first = 0, last = 0; if (face != null) { var curve = BRep_Tool.CurveOnSurface(edge, new Geom_Plane(Ax3.XOY), new TopLoc_Location(), ref first, ref last); if (curve == null) { return(false); } res &= RenderCurve(renderer, curve, first, last, reverse); } else { if (!(edge.TShape() is BRep_TEdge tedge)) { return(res); } var curves = tedge.CurvesList(); if (reverse) { curves.Reverse(); } foreach (var curveOnSurface in curves.OfType <BRep_CurveOnSurface>()) { var curve = curveOnSurface.PCurve(); first = curveOnSurface.First(); last = curveOnSurface.Last(); res &= RenderCurve(renderer, curve, first, last, reverse); } } return(res); }
//-------------------------------------------------------------------------------------------------- void _ExportEdge(TopoDS_Edge edge, bool reverse, TopoDS_Face face) { reverse ^= edge.Orientation() == TopAbs_Orientation.TopAbs_REVERSED; double first = 0, last = 0; if (face != null) { var curve = BRep_Tool.CurveOnSurface(edge, new Geom_Plane(Ax3.XOY), new TopLoc_Location(), ref first, ref last); if (curve == null) { return; } AddCurve(curve, reverse, first, last); } else { var tedge = edge.TShape() as BRep_TEdge; if (tedge == null) { return; } var curves = tedge.CurvesList(); if (reverse) { curves.Reverse(); } foreach (var curveOnSurface in curves.Cast <BRep_CurveOnSurface>()) { var curve = curveOnSurface.PCurve(); first = curveOnSurface.First(); last = curveOnSurface.Last(); AddCurve(curve, reverse, first, last); } } }
//-------------------------------------------------------------------------------------------------- void _ExportLayer(VectorExportLayer layer) { _Document.Layers.Add(new DxfDomLayer(layer.Name, _Lineweights[layer.Type], layer.Type.ToString())); _CurrentLayer = layer.Name; foreach (var edge in layer.BRep.Edges()) { var tedge = edge.TShape() as BRep_TEdge; if (tedge == null) { return; } var curves = tedge.CurvesList(); foreach (var curve in curves) { Geom2d_Curve geomCurve; double first = 0; double last = 0; BRep_CurveOnSurface curveOnSurface = curve as BRep_CurveOnSurface; if (curveOnSurface != null) { geomCurve = curveOnSurface.PCurve(); first = curveOnSurface.First(); last = curveOnSurface.Last(); } else { geomCurve = BRep_Tool.CurveOnSurface(edge, new Geom_Plane(Ax3.XOY), new TopLoc_Location(), ref first, ref last); } if (geomCurve != null) { _AddCurve(geomCurve, first, last); } } } }
//-------------------------------------------------------------------------------------------------- public static bool ComputeAxisFromEdge(TopoDS_Face face, TopoDS_Edge edge, double parameter, out Ax1 axis) { axis = new Ax1(); // Get edge point and tangent var adaptorEdge = edge.Adaptor(); var edgeFirst = adaptorEdge.FirstParameter(); var edgeLast = adaptorEdge.LastParameter(); var centerParam = parameter.Clamp(edgeFirst, edgeLast); Pnt centerPoint = Pnt.Origin; Vec edgeTangent = Vec.Zero; adaptorEdge.D1(centerParam, ref centerPoint, ref edgeTangent); if (edge.Orientation() == TopAbs_Orientation.TopAbs_REVERSED) { edgeTangent.Reverse(); } // Get normal at point of edge double first = 0, last = 0; var curveOnSurface = BRep_Tool.CurveOnSurface(edge, face, ref first, ref last); if (curveOnSurface == null) { return(false); } var paramNormalized = (centerParam - edgeFirst) / (edgeLast - edgeFirst); var centerUV = curveOnSurface.Value(first + (last - first) * paramNormalized); Vec faceNormal = Vec.Zero; new BRepGProp_Face(face).Normal(centerUV.X, centerUV.Y, ref centerPoint, ref faceNormal); axis = new Ax1(centerPoint, faceNormal.ToDir().Crossed(edgeTangent.ToDir())); return(true); }
//-------------------------------------------------------------------------------------------------- public static bool ComputeAxisFromVertex(TopoDS_Face face, TopoDS_Vertex vertex, out Ax1 axis) { // Get normal at point of vertex var uv = BRep_Tool.Parameters(vertex, face); Pnt centerPoint = Pnt.Origin; Vec faceNormal = Vec.Zero; new BRepGProp_Face(face).Normal(uv.X, uv.Y, ref centerPoint, ref faceNormal); // Find edges var edges = face.Edges(false).Where(edge => edge.Vertices().ContainsSame(vertex)).ToList(); if (edges.Count != 2) { axis = new Ax1(); return(false); } // Calc direction bool order = false; // is false if face is on the left of edge1 var tangents = new Vec[2]; for (var edgeIndex = 0; edgeIndex < edges.Count; edgeIndex++) { var edge = edges[edgeIndex]; var edgeAdaptor = edge.Adaptor(); var parameter = BRep_Tool.Parameter(vertex, edge); Pnt unusedPoint = Pnt.Origin; Vec edgeTangent = Vec.Zero; edgeAdaptor.D1(parameter, ref unusedPoint, ref edgeTangent); var parameterReversed = parameter > (edgeAdaptor.FirstParameter() + edgeAdaptor.LastParameter()) * 0.5; if (parameterReversed) { edgeTangent.Reverse(); } if (edgeIndex == 0 && parameterReversed != (edge.Orientation() == TopAbs_Orientation.TopAbs_REVERSED)) { order = true; // face is on the right of edge1 } tangents[edgeIndex] = edgeTangent.Normalized(); } var direction = tangents[0].Added(tangents[1]); var angleBetweenTangents = tangents[0].AngleWithRef(tangents[1], faceNormal); if (order) { angleBetweenTangents *= -1.0; } if (angleBetweenTangents < 0) { // Concave vertex direction.Reverse(); } axis = new Ax1(centerPoint, direction.ToDir()); return(true); }
//-------------------------------------------------------------------------------------------------- void _AddEdgeProperties(TopoDS_Edge edge) { const string edgecat = "Edge"; const string curvecat = "Curve"; if (Shape != null) { var subshapeRef = Shape.GetSubshapeReference(_TopLevelShape, edge); _AddProperty(edgecat, "SubshapeRef", subshapeRef?.ToString() ?? "null"); } var flags = ""; if (BRep_Tool.Degenerated(edge)) { flags += "Degenerated "; } if (BRep_Tool.SameParameter(edge)) { flags += "SameParameter "; } if (BRep_Tool.SameRange(edge)) { flags += "SameRange "; } _AddProperty(edgecat, "Is Closed", $"{(BRep_Tool.IsClosed(edge) ? "Yes" : "No")}"); _AddProperty(edgecat, "Curve Type", $"{(BRep_Tool.IsGeometric(edge) ? "Geometric Curve" : "Curve on Surface")}"); var props = new GProp_GProps(); BRepGProp.LinearProperties(BrepShape, props); _AddProperty(edgecat, "Length", $"{props.Mass()}"); _AddProperty(edgecat, "Tolerance", $"{BRep_Tool.Tolerance(edge)}"); if (!flags.IsEmpty()) { _AddProperty(edgecat, "Flags", flags); } if (BRep_Tool.IsGeometric(edge)) { // 3D curve double first = 0, last = 0; var curve = BRep_Tool.Curve(edge, ref first, ref last); if (curve != null) { _AddProperty(edgecat, "Parameter", $"({first}, {last})"); _AddProperty(curvecat, "Class", curve.GetType().Name.Replace("Geom_", "")); _AddProperty(curvecat, "Is Closed", $"{(curve.IsClosed() ? "Yes" : "No")}"); if (curve.IsPeriodic()) { _AddProperty(curvecat, "Period", $"{curve.Period()}"); } _AddProperty(curvecat, "Continuity", curve.Continuity().ToString().Replace("GeomAbs_", "")); switch (curve) { case Geom_Line line: const string linecat = "Line"; var lineLoc = line.Position().Location; _AddProperty(linecat, "Location", $"({lineLoc.X.ToRoundedString()}, {lineLoc.Y.ToRoundedString()}, {lineLoc.Z.ToRoundedString()})"); var lineDir = line.Position().Direction; _AddProperty(linecat, "Direction", $"({lineDir.X.ToRoundedString()}, {lineDir.Y.ToRoundedString()}, {lineDir.Z.ToRoundedString()})"); break; case Geom_Circle circle: const string circlecat = "Circle"; _AddProperty(circlecat, "Radius", $"{circle.Radius().ToRoundedString()}"); var circleLoc = circle.Position().Location; _AddProperty(circlecat, "Location", $"({circleLoc.X.ToRoundedString()}, {circleLoc.Y.ToRoundedString()}, {circleLoc.Z.ToRoundedString()})"); var circleDir = circle.Position().Direction; _AddProperty(circlecat, "Direction", $"({circleDir.X.ToRoundedString()}, {circleDir.Y.ToRoundedString()}, {circleDir.Z.ToRoundedString()})"); var circleXDir = circle.Position().XDirection; _AddProperty(circlecat, "X-Direction", $"({circleXDir.X.ToRoundedString()}, {circleXDir.Y.ToRoundedString()}, {circleXDir.Z.ToRoundedString()})"); var circleYDir = circle.Position().YDirection; _AddProperty(circlecat, "Y-Direction", $"({circleYDir.X.ToRoundedString()}, {circleYDir.Y.ToRoundedString()}, {circleYDir.Z.ToRoundedString()})"); break; case Geom_Ellipse ellipse: const string ellipsecat = "Ellipse"; _AddProperty(ellipsecat, "Major Radius", $"{ellipse.MajorRadius().ToRoundedString()}"); _AddProperty(ellipsecat, "Minor Radius", $"{ellipse.MinorRadius().ToRoundedString()}"); _AddProperty(ellipsecat, "Eccentricity", $"{ellipse.Eccentricity().ToRoundedString()}"); _AddProperty(ellipsecat, "Focal", $"{ellipse.Focal().ToRoundedString()}"); var ellipseFocus = ellipse.Focus1(); _AddProperty(ellipsecat, "Focus 1", $"({ellipseFocus.X.ToRoundedString()}, {ellipseFocus.Y.ToRoundedString()}, {ellipseFocus.Z.ToRoundedString()})"); ellipseFocus = ellipse.Focus2(); _AddProperty(ellipsecat, "Focus 2", $"({ellipseFocus.X.ToRoundedString()}, {ellipseFocus.Y.ToRoundedString()}, {ellipseFocus.Z.ToRoundedString()})"); var ellipseLoc = ellipse.Position().Location; _AddProperty(ellipsecat, "Location", $"({ellipseLoc.X.ToRoundedString()}, {ellipseLoc.Y.ToRoundedString()}, {ellipseLoc.Z.ToRoundedString()})"); var ellipseDir = ellipse.Position().Direction; _AddProperty(ellipsecat, "Direction", $"({ellipseDir.X.ToRoundedString()}, {ellipseDir.Y.ToRoundedString()}, {ellipseDir.Z.ToRoundedString()})"); var ellipseXDir = ellipse.Position().XDirection; _AddProperty(ellipsecat, "X-Direction", $"({ellipseXDir.X.ToRoundedString()}, {ellipseXDir.Y.ToRoundedString()}, {ellipseXDir.Z.ToRoundedString()})"); var ellipseYDir = ellipse.Position().YDirection; _AddProperty(ellipsecat, "Y-Direction", $"({ellipseYDir.X.ToRoundedString()}, {ellipseYDir.Y.ToRoundedString()}, {ellipseYDir.Z.ToRoundedString()})"); break; case Geom_BezierCurve bezier: const string beziercat = "Bézier Curve"; _AddProperty(beziercat, "Degree", $"{bezier.Degree()}"); _AddProperty(beziercat, "Pole Count", $"{bezier.NbPoles()}"); _AddProperty(beziercat, "Is Rational", $"{(bezier.IsRational() ? "Yes" : "No")}"); break; case Geom_BSplineCurve bspline: const string bsplinecat = "B-Spline Curve"; _AddProperty(bsplinecat, "Degree", $"{bspline.Degree()}"); _AddProperty(bsplinecat, "Pole Count", $"{bspline.NbPoles()}"); _AddProperty(bsplinecat, "Knoe Count", $"{bspline.NbKnots()}"); _AddProperty(bsplinecat, "Knot Distrib.", bspline.KnotDistribution().ToString().Replace("GeomAbs_", "")); _AddProperty(bsplinecat, "Is Rational", $"{(bspline.IsRational() ? "Yes" : "No")}"); break; } } } else { // Curve on surface, currently not supported } // Get continuity information var(face1, face2) = EdgeAlgo.FindAdjacentFaces(_TopLevelShape, edge); if (face1 != null && face2 != null) { _AddProperty(edgecat, "Face Contin.", BRep_Tool.Continuity(edge, face1, face2).ToString().Replace("GeomAbs_", "")); } }
//-------------------------------------------------------------------------------------------------- void _AddWireProperties(TopoDS_Wire wire) { const string cat = "Wire"; _AddProperty(cat, "Free Vertices", $"{(BRep_Tool.IsClosed(wire) ? "Yes" : "No")}"); }
//-------------------------------------------------------------------------------------------------- void _AddShellProperties(TopoDS_Shell shell) { const string cat = "Shell"; _AddProperty(cat, "Free Edges", $"{(BRep_Tool.IsClosed(shell) ? "Yes" : "No")}"); }
//-------------------------------------------------------------------------------------------------- public SnapInfo Snap(MouseEventData mouseEvent) { if (!InteractiveContext.Current.EditorState.SnappingEnabled) { return(null); } SnapInfo info = null; if (mouseEvent.DetectedShapes.Count == 1) { var detectedShape = mouseEvent.DetectedShapes[0]; if (SupportedSnapModes.HasFlag(SnapMode.Vertex) && InteractiveContext.Current.EditorState.SnapToVertexSelected && (detectedShape.ShapeType() == TopAbs_ShapeEnum.TopAbs_VERTEX)) { // On Vertex var vertex = TopoDS.Vertex(detectedShape); info = new SnapInfo() { Point = BRep_Tool.Pnt(vertex), SnapMode = SnapMode.Vertex }; } else if (SupportedSnapModes.HasFlag(SnapMode.Edge) && InteractiveContext.Current.EditorState.SnapToEdgeSelected && (detectedShape.ShapeType() == TopAbs_ShapeEnum.TopAbs_EDGE)) { // On Edge var edge = TopoDS.Edge(detectedShape); double umin = 0, umax = 0; var curve = BRep_Tool.Curve(edge, ref umin, ref umax); if (curve != null) { var extrema = new GeomAPI_ExtremaCurveCurve(curve, new Geom_Line(_WorkspaceController.ActiveViewport.ViewAxis(Convert.ToInt32(mouseEvent.ScreenPoint.X), Convert.ToInt32(mouseEvent.ScreenPoint.Y)))); if (extrema.NbExtrema() >= 1) { Pnt p1 = new Pnt(); Pnt p2 = new Pnt(); if (extrema.TotalNearestPoints(ref p1, ref p2)) { info = new SnapInfo() { Point = p1, SnapMode = SnapMode.Edge }; } } } } } else if (mouseEvent.DetectedAisInteractives.Count == 1) { if (SupportedSnapModes.HasFlag(SnapMode.Vertex) && InteractiveContext.Current.EditorState.SnapToVertexSelected && (mouseEvent.DetectedAisInteractives[0] is AIS_Point aisPoint)) { // On Vertex info = new SnapInfo() { Point = aisPoint.Component().Pnt(), SnapMode = SnapMode.Vertex }; } } else if (SupportedSnapModes.HasFlag(SnapMode.Grid) && InteractiveContext.Current.EditorState.SnapToGridSelected && _WorkspaceController.Workspace.V3dViewer.Grid().IsActive()) { // On Grid info = new SnapInfo() { Point = _WorkspaceController.ActiveViewport.ProjectToGrid(Convert.ToInt32(mouseEvent.ScreenPoint.X), Convert.ToInt32(mouseEvent.ScreenPoint.Y)), SnapMode = SnapMode.Grid }; } if (info != null) { _WorkspaceController.CursorPosition = info.Point; } return(info); }
//-------------------------------------------------------------------------------------------------- public static Pnt Pnt(this TopoDS_Vertex vertex) { return(vertex == null ? new Pnt() : BRep_Tool.Pnt(vertex)); }
//-------------------------------------------------------------------------------------------------- public static Geom_Surface Surface(this TopoDS_Face face) { return(face == null ? null : BRep_Tool.Surface(face)); }