|
36 | 36 |
|
37 | 37 | # collection of pints (used for spline construction) |
38 | 38 | from OCP.TColgp import TColgp_HArray1OfPnt |
39 | | -from OCP.BRepAdaptor import BRepAdaptor_Curve, BRepAdaptor_Surface |
| 39 | +from OCP.BRepAdaptor import BRepAdaptor_Curve, BRepAdaptor_Surface, BRepAdaptor_HCurve |
40 | 40 | from OCP.BRepBuilderAPI import ( |
41 | 41 | BRepBuilderAPI_MakeVertex, |
42 | 42 | BRepBuilderAPI_MakeEdge, |
|
168 | 168 | from OCP.ShapeAnalysis import ShapeAnalysis_FreeBounds |
169 | 169 | from OCP.TopTools import TopTools_HSequenceOfShape |
170 | 170 |
|
| 171 | +from OCP.GCPnts import GCPnts_AbscissaPoint |
| 172 | + |
| 173 | +from OCP.GeomFill import ( |
| 174 | + GeomFill_Frenet, |
| 175 | + GeomFill_CorrectedFrenet, |
| 176 | + GeomFill_CorrectedFrenet, |
| 177 | + GeomFill_DiscreteTrihedron, |
| 178 | + GeomFill_ConstantBiNormal, |
| 179 | + GeomFill_DraftTrihedron, |
| 180 | + GeomFill_TrihedronLaw, |
| 181 | +) |
171 | 182 | from math import pi, sqrt |
172 | 183 | import warnings |
173 | 184 |
|
@@ -1070,13 +1081,69 @@ def makeTangentArc(cls: Type["Edge"], v1: Vector, v2: Vector, v3: Vector) -> "Ed |
1070 | 1081 | @classmethod |
1071 | 1082 | def makeLine(cls: Type["Edge"], v1: Vector, v2: Vector) -> "Edge": |
1072 | 1083 | """ |
1073 | | - Create a line between two points |
1074 | | - :param v1: Vector that represents the first point |
1075 | | - :param v2: Vector that represents the second point |
1076 | | - :return: A linear edge between the two provided points |
| 1084 | + Create a line between two points |
| 1085 | + :param v1: Vector that represents the first point |
| 1086 | + :param v2: Vector that represents the second point |
| 1087 | + :return: A linear edge between the two provided points |
1077 | 1088 | """ |
1078 | 1089 | return cls(BRepBuilderAPI_MakeEdge(v1.toPnt(), v2.toPnt()).Edge()) |
1079 | 1090 |
|
| 1091 | + def locationAt( |
| 1092 | + self, |
| 1093 | + d: float, |
| 1094 | + mode: Literal["length", "parameter"] = "length", |
| 1095 | + frame: Literal["frenet", "corrected"] = "frenet", |
| 1096 | + ) -> Location: |
| 1097 | + """Generate location along the curve |
| 1098 | + :param d: distance or parameter value |
| 1099 | + :param mode: position calculation mode (default: length) |
| 1100 | + :param frame: moving frame calculation method (default: frenet) |
| 1101 | + :return: A Location object representing local coordinate system at the specified distance. |
| 1102 | + """ |
| 1103 | + |
| 1104 | + curve = BRepAdaptor_Curve(self.wrapped) |
| 1105 | + |
| 1106 | + if mode == "length": |
| 1107 | + l = GCPnts_AbscissaPoint.Length_s(curve) |
| 1108 | + param = GCPnts_AbscissaPoint(curve, l * d, 0).Parameter() |
| 1109 | + else: |
| 1110 | + param = d |
| 1111 | + |
| 1112 | + law: GeomFill_TrihedronLaw |
| 1113 | + if frame == "frenet": |
| 1114 | + law = GeomFill_Frenet() |
| 1115 | + else: |
| 1116 | + law = GeomFill_CorrectedFrenet() |
| 1117 | + |
| 1118 | + law.SetCurve(BRepAdaptor_HCurve(curve)) |
| 1119 | + |
| 1120 | + tangent, normal, binormal = gp_Vec(), gp_Vec(), gp_Vec() |
| 1121 | + |
| 1122 | + law.D0(param, tangent, normal, binormal) |
| 1123 | + pnt = curve.Value(param) |
| 1124 | + |
| 1125 | + T = gp_Trsf() |
| 1126 | + T.SetTransformation( |
| 1127 | + gp_Ax3(pnt, gp_Dir(tangent.XYZ()), gp_Dir(normal.XYZ())), gp_Ax3() |
| 1128 | + ) |
| 1129 | + |
| 1130 | + return Location(TopLoc_Location(T)) |
| 1131 | + |
| 1132 | + def locations( |
| 1133 | + self, |
| 1134 | + ds: Iterable[float], |
| 1135 | + mode: Literal["length", "parameter"] = "length", |
| 1136 | + frame: Literal["frenet", "corrected"] = "frenet", |
| 1137 | + ) -> List[Location]: |
| 1138 | + """Generate location along the curve |
| 1139 | + :param ds: distance or parameter values |
| 1140 | + :param mode: position calculation mode (default: length) |
| 1141 | + :param frame: moving frame calculation method (default: frenet) |
| 1142 | + :return: A list of Location objects representing local coordinate systems at the specified distances. |
| 1143 | + """ |
| 1144 | + |
| 1145 | + return [self.locationAt(d, mode, frame) for d in ds] |
| 1146 | + |
1080 | 1147 |
|
1081 | 1148 | class Wire(Shape, Mixin1D): |
1082 | 1149 | """ |
|
0 commit comments