//-------------------------------------------------------------------------------------------------- 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 _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_", "")); } }
//-------------------------------------------------------------------------------------------------- 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_", "")); } }