def __init__(self): self.data = [] self.curHilightedObj = None self.ProjectOnCurve = Geom2dAPI_ProjectPointOnCurve() self.curCoordinateSystem = gp_Ax3(gp.XOY()) self.FirstEdge = TopoDS_Edge() self.SecondEdge = TopoDS_Edge() self.curPnt2d = gp.Origin2d() self.objectPnt2d = gp.Origin2d() self.bestPnt2d = gp.Origin2d() self.findbestPnt2d = False self.firstDisplay = True self.myGeom_Point = Geom_CartesianPoint(gp.Origin()) self.myAIS_Point = AIS_Point(self.myGeom_Point) self.myAIS_Point.SetColor(Quantity_Color(Quantity_NOC_YELLOW)) self.myAIS_Point.SetWidth(5.0) self.myAIS_Point.SetMarker(Aspect_TOM_O_POINT) self.minimumSnapDistance = MINIMUMSNAP self.minDistance = 0 self.curDistance = 0 self.curGeom2d_Point = Geom2d_CartesianPoint(self.curPnt2d) self.myPlane = Geom_Plane(self.curCoordinateSystem)
def __init__(self, edge: TopoDS_Edge) -> None: # following constructor creates an empty TopoDS_Edge super(InheritEdge, self).__init__() # we need to copy the base shape using the following three # lines t.assertTrue(self.IsNull()) self.TShape(edge.TShape()) self.Location(edge.Location()) self.Orientation(edge.Orientation()) t.assertFalse(self.IsNull())
def __init__(self): super(Sketch_CommandBSpline, self).__init__("BSplineCurve.") self.IndexCounter = 1 self.myDegree = SKETCH_DEGREE self.tempPnt2d = gp.Origin2d() self.myFirstgp_Pnt = gp.Origin() self.tempPnt = gp.Origin() self.curEdge = TopoDS_Edge() self.myBSplineCurveAction = BSplineCurveAction.Nothing self.Poles2d = [gp.Origin2d()] * 2 self.Poles = [gp.Origin()] * 2 self.Multi, self.Knots = setQuasiUniformKnots(len(self.Poles), self.myDegree) curgp_Array1CurvePoles2d = point_list_to_TColgp_Array1OfPnt2d( self.Poles2d) curgp_Array1CurveMulti = int_list_to_TColStd_Array1OfInteger( self.Multi) curgp_Array1CurveKnots = float_list_to_TColStd_Array1OfReal(self.Knots) self.myGeom2d_BSplineCurve = Geom2d_BSplineCurve( curgp_Array1CurvePoles2d, curgp_Array1CurveKnots, curgp_Array1CurveMulti, self.myDegree) curgp_Array1CurvePoles = point_list_to_TColgp_Array1OfPnt(self.Poles) self.myGeom_BSplineCurve = Geom_BSplineCurve(curgp_Array1CurvePoles, curgp_Array1CurveKnots, curgp_Array1CurveMulti, self.myDegree) self.myRubberAIS_Shape = AIS_Shape(self.curEdge)
def __init__(self): super(Sketch_CommandBezierCurve, self).__init__("BezierCurve.") self.IndexCounter = 1 self.tempPnt2d = gp.Origin2d() self.myFirstgp_Pnt = gp.Origin() self.tempPnt = gp.Origin() self.curEdge = TopoDS_Edge() self.myBezierCurveAction = BezierCurveAction.Nothing curgp_Array1CurvePoles2d = TColgp_Array1OfPnt2d(1, 2) curgp_Array1CurvePoles2d.SetValue(1, gp.Origin2d()) curgp_Array1CurvePoles2d.SetValue(2, gp.Origin2d()) self.myGeom2d_BezierCurve = Geom2d_BezierCurve( curgp_Array1CurvePoles2d) curgp_Array1CurvePoles = TColgp_Array1OfPnt(1, 2) curgp_Array1CurvePoles.SetValue(1, gp.Origin()) curgp_Array1CurvePoles.SetValue(2, gp.Origin()) self.myGeom_BezierCurve = Geom_BezierCurve(curgp_Array1CurvePoles) self.myRubberAIS_Shape = AIS_Shape(self.curEdge)
def discretize_edge(a_topods_edge: TopoDS_Edge, deflection=0.2, algorithm="QuasiUniformDeflection"): """Take a TopoDS_Edge and returns a list of points The more deflection is small, the more the discretization is precise, i.e. the more points you get in the returned points algorithm: to choose in ["UniformAbscissa", "QuasiUniformDeflection"] """ if not is_edge(a_topods_edge): raise AssertionError( "You must provide a TopoDS_Edge to the discretize_edge function.") if a_topods_edge.IsNull(): print( "Warning : TopoDS_Edge is null. discretize_edge will return an empty list of points." ) return [] curve_adaptator = BRepAdaptor_Curve(a_topods_edge) first = curve_adaptator.FirstParameter() last = curve_adaptator.LastParameter() if algorithm == "QuasiUniformDeflection": discretizer = GCPnts_QuasiUniformDeflection() elif algorithm == "UniformAbscissa": discretizer = GCPnts_UniformAbscissa() elif algorithm == "UniformDeflection": discretizer = GCPnts_UniformDeflection() else: raise AssertionError("Unknown algorithm") discretizer.Initialize(curve_adaptator, deflection, first, last) if not discretizer.IsDone(): raise AssertionError("Discretizer not done.") if not discretizer.NbPoints() > 0: raise AssertionError("Discretizer nb points not > 0.") points = [] for i in range(1, discretizer.NbPoints() + 1): p = curve_adaptator.Value(discretizer.Parameter(i)) points.append(p.Coord()) return points
def prop_edge(self, edge=TopoDS_Edge()): edge_adaptor = BRepAdaptor_Curve(edge) edge_line = edge_adaptor.Line() return edge_line