def fill_surface(): n_sided = BRepFill_Filling() n_sided.SetResolParam(4, 30, 5, True) # Sets the parameters used for resolution. # The default values of these parameters have been chosen for a good ratio quality/performance. # # Degree: it is the order of energy criterion to minimize for computing the deformation of the surface. # The default value is 3. # The recommanded value is i+2 # where i is the maximum order of the constraints. # # NbPtsOnCur: it is the average number of points for discretisation of the edges. # # NbIter: it is the maximum number of iterations of the process. # For each iteration the number of discretisation points is increased. # # Anisotropie: n_sided.SetConstrParam() # Sets the values of Tolerances used to control the constraint. # Tol2d: # Tol3d: # it is the maximum distance allowed between the support surface and the constraints # TolAng: it is the maximum angle allowed between the normal of the surface and the constraints # TolCurv: it is the maximum difference of curvature allowed between the surface and the constraint p0 = gp_Pnt(-20, -20, 0) p1 = gp_Pnt(+20, -20, 10) p2 = gp_Pnt(+20, +20, 0) p3 = gp_Pnt(-20, +20, 0) p4 = gp_Pnt(-10, -10, +5) p5 = gp_Pnt(-10, +10, -5) p6 = gp_Pnt(+10, -10, -10) p7 = gp_Pnt(+10, +10, +10) p8 = gp_Pnt(-15, -15, +2) p9 = gp_Pnt(-15, +15, -15) p10 = gp_Pnt(+15, -15, -2) p11 = gp_Pnt(+15, +15, +50) n_sided.Add(make_edge(p0, p1), GeomAbs_C0) n_sided.Add(make_edge(p1, p2), GeomAbs_C0) n_sided.Add(make_edge(p2, p3), GeomAbs_C0) n_sided.Add(make_edge(p3, p0), GeomAbs_C0) n_sided.Add(p4) n_sided.Add(p5) n_sided.Add(p6) n_sided.Add(p7) n_sided.Add(p8) n_sided.Add(p9) n_sided.Add(p10) n_sided.Add(p11) n_sided.Build() write_step_file(n_sided.Face(), "./tmp/FillSurf.stp") return n_sided.Face()
def make_EllipWire(self, rxy=[1.0, 1.0], shft=0.0, skin=None, axs=gp_Ax3()): rx, ry = rxy if rx > ry: major_radi = rx minor_radi = ry axis = gp_Ax2() axis.SetXDirection(axis.XDirection()) else: major_radi = ry minor_radi = rx axis = gp_Ax2() axis.SetXDirection(axis.YDirection()) axis.Rotate(axis.Axis(), np.deg2rad(shft)) elip = make_edge(gp_Elips(axis, major_radi, minor_radi)) poly = make_wire(elip) poly.Location(set_loc(gp_Ax3(), axs)) if skin == None: return poly else: n_sided = BRepFill_Filling() for e in Topo(poly).edges(): n_sided.Add(e, GeomAbs_C0) n_sided.Build() face = n_sided.Face() if skin == 0: return face else: solid = BRepOffset_MakeOffset(face, skin, 1.0E-5, BRepOffset_Skin, False, True, GeomAbs_Arc, True, True) return solid.Shape()
def __init__(self, axs=gp_Ax3()): self.rot = axs self.axs = gp_Ax3(self.rot.Ax2()) self.rim = make_edge(gp_Circ(self.axs.Ax2(), 100)) self.pln = dispocc.make_plane_axs(self.axs) self.surf = make_plane(self.axs.Location(), dir_to_vec(self.axs.Direction()), -500, 500, -500, 500)
def trim(self, lbound, ubound): ''' trim the curve @param lbound: @param ubound: ''' a, b = sorted([lbound, ubound]) tr = Geom_TrimmedCurve(self.adaptor.Curve().Curve(), a, b).GetHandle() return Edge(make_edge(tr))
def trim(self, lbound, ubound): ''' trim the curve @param lbound: @param ubound: ''' a, b = sorted([lbound, ubound]) tr = Geom_TrimmedCurve(self.adaptor.Curve().Curve(), a, b).GetHandle() return Edge(make_edge(tr))
def make_Ellip(self, rxy=[1.0, 1.0], shft=0.0, axs=gp_Ax3()): rx, ry = rxy if rx > ry: major_radi = rx minor_radi = ry axis = axs.Ax2() axis.SetXDirection(axs.XDirection()) else: major_radi = ry minor_radi = rx axis = axs.Ax2() axis.SetXDirection(axs.YDirection()) axis.Rotate(axs.Axis(), np.deg2rad(shft)) elip = make_edge(gp_Elips(axis, major_radi, minor_radi)) poly = make_wire(elip) return poly
def line_from_axs(axs=gp_Ax3(), length=100): return make_edge(axs.Location(), pnt_from_axs(axs, length))
def line_from_axs(axs=gp_Ax3(), length=100): vec = point_to_vector(axs.Location()) + \ dir_to_vec(axs.Direction()) * length return make_edge(axs.Location(), vector_to_point(vec))
def make_edges(pts): edg = [] for i in range(len(pts) - 1): i0, i1 = i, i + 1 edg.append(make_edge(pts[i0], pts[i1])) return make_wire(edg)
def set_wire(pts): edge = [] for i in range(len(pts)): i0, i1 = i, (i + 1) % len(pts) edge.append(make_edge(pts[i0], pts[i1])) return make_wire(edge)
def check_ground(self): if len(self.pts) > 2: ray = make_edge(self.pts[-2], self.pts[-1]) h_line = BRep_Tool.Curve(ray) h_surf = BRep_Tool.Surface(self.grd) print(GeomAPI_IntCS(h_line, h_surf))