def __make_edge(a, b): try: return BRepBuilderAPI_MakeEdge(to_Pnt(a), to_Pnt(b)).Edge() except: raise Exception(f"Cannot make edge segment from points {a}, {b}")
def _segment(a, b) -> Shape: a, b = points((a, b)) return Shape(BRepBuilderAPI_MakeEdge(to_Pnt(a), to_Pnt(b)).Edge())
def project_point_on_curve(pnt, crv): algo = GeomAPI_ProjectPointOnCurve(to_Pnt(pnt), crv.Curve()) return point3(algo.NearestPoint())
def _circle_arc(p1, p2, p3): aArcOfCircle = GC_MakeArcOfCircle(to_Pnt(p1), to_Pnt(p2), to_Pnt(p3)) return Shape(BRepBuilderAPI_MakeEdge(aArcOfCircle.Value()).Edge())
def set_center(self, pnt, redraw=True): self._display.View.Camera().SetCenter(to_Pnt(pnt)) self.set_orient1() if redraw: self.redraw()
def opencascade_array1_of_pnt(arr): ret = TColgp_Array1OfPnt(1, len(arr)) for i in range(len(arr)): ret.SetValue(i + 1, to_Pnt(arr[i])) return ret
def opencascade_array2_of_pnt(arr): ret = TColgp_Array2OfPnt(1, len(arr), 1, len(arr[0])) for r in range(len(arr)): for c in range(len(arr[0])): ret.SetValue(r + 1, c + 1, to_Pnt(arr[r][c])) return ret
def set_points(self, p1, p2): self.p1 = point3(p1) self.p2 = point3(p2) p1 = Geom_CartesianPoint(to_Pnt(self.p1)) p2 = Geom_CartesianPoint(to_Pnt(self.p2)) self.ais_object.SetPoints(p1, p2)
def make_ais(self): p1 = Geom_CartesianPoint(to_Pnt(self.p1)) p2 = Geom_CartesianPoint(to_Pnt(self.p2)) return AIS_Line(p1, p2)