def make_prism(profile, vec): ''' makes a finite prism ''' pri = BRepPrimAPI_MakePrism(profile, vec, True) with assert_isdone(pri, 'failed building prism'): pri.Build() return pri.Shape()
def update_shape(self, change=None): d = self.declaration if d.shape: shape = coerce_shape(d.shape) copy = True else: shape = self.get_shape().shape copy = False if d.infinite: args = (shape, d.direction.proxy, True, copy, d.canonize) else: args = (shape, gp_Vec(*d.vector), copy, d.canonize) prism = BRepPrimAPI_MakePrism(*args) self.shape = prism.Shape()
def brep_feat_rib(event=None): mkw = BRepBuilderAPI_MakeWire() mkw.Add( BRepBuilderAPI_MakeEdge(gp_Pnt(0., 0., 0.), gp_Pnt(200., 0., 0.)).Edge()) mkw.Add( BRepBuilderAPI_MakeEdge(gp_Pnt(200., 0., 0.), gp_Pnt(200., 0., 50.)).Edge()) mkw.Add( BRepBuilderAPI_MakeEdge(gp_Pnt(200., 0., 50.), gp_Pnt(50., 0., 50.)).Edge()) mkw.Add( BRepBuilderAPI_MakeEdge(gp_Pnt(50., 0., 50.), gp_Pnt(50., 0., 200.)).Edge()) mkw.Add( BRepBuilderAPI_MakeEdge(gp_Pnt(50., 0., 200.), gp_Pnt(0., 0., 200.)).Edge()) mkw.Add( BRepBuilderAPI_MakeEdge(gp_Pnt(0., 0., 200.), gp_Pnt(0., 0., 0.)).Edge()) S = BRepPrimAPI_MakePrism( BRepBuilderAPI_MakeFace(mkw.Wire()).Face(), gp_Vec(gp_Pnt(0., 0., 0.), gp_Pnt(0., 100., 0.))) display.EraseAll() # display.DisplayShape(S.Shape()) W = BRepBuilderAPI_MakeWire( BRepBuilderAPI_MakeEdge(gp_Pnt(50., 45., 100.), gp_Pnt(100., 45., 50.)).Edge()) aplane = Geom_Plane(0., 1., 0., -45.) aform = BRepFeat_MakeLinearForm(S.Shape(), W.Wire(), aplane, gp_Vec(0., 10., 0.), gp_Vec(0., 0., 0.), 1, True) aform.Perform() display.DisplayShape(aform.Shape()) display.FitAll()
def build_tooth(): base_center = gp_Pnt2d(pitch_circle_radius + (tooth_radius - roller_radius), 0) base_circle = gp_Circ2d(gp_Ax2d(base_center, gp_Dir2d()), tooth_radius) trimmed_base = GCE2d_MakeArcOfCircle(base_circle, M_PI - (roller_contact_angle / 2.), M_PI).Value() trimmed_base.Reverse() # just a trick p0 = trimmed_base.StartPoint() p1 = trimmed_base.EndPoint() # Determine the center of the profile circle x_distance = cos(roller_contact_angle / 2.) * (profile_radius + tooth_radius) y_distance = sin(roller_contact_angle / 2.) * (profile_radius + tooth_radius) profile_center = gp_Pnt2d(pitch_circle_radius - x_distance, y_distance) # Construct the profile circle gp_Circ2d profile_circle = gp_Circ2d(gp_Ax2d(profile_center, gp_Dir2d()), profile_center.Distance(p1)) geom_profile_circle = GCE2d_MakeCircle(profile_circle).Value() # Construct the outer circle gp_Circ2d outer_circle = gp_Circ2d(gp_Ax2d(gp_Pnt2d(0, 0), gp_Dir2d()), top_radius) geom_outer_circle = GCE2d_MakeCircle(outer_circle).Value() inter = Geom2dAPI_InterCurveCurve(geom_profile_circle, geom_outer_circle) num_points = inter.NbPoints() assert isinstance(p1, gp_Pnt2d) if num_points == 2: if p1.Distance(inter.Point(1)) < p1.Distance(inter.Point(2)): p2 = inter.Point(1) else: p2 = inter.Point(2) elif num_points == 1: p2 = inter.Point(1) else: sys.exit(-1) # Trim the profile circle and mirror trimmed_profile = GCE2d_MakeArcOfCircle(profile_circle, p1, p2).Value() # Calculate the outermost point p3 = gp_Pnt2d(cos(tooth_angle / 2.) * top_radius, sin(tooth_angle / 2.) * top_radius) # and use it to create the third arc trimmed_outer = GCE2d_MakeArcOfCircle(outer_circle, p2, p3).Value() # Mirror and reverse the three arcs mirror_axis = gp_Ax2d(gp_Origin2d(), gp_DX2d().Rotated(tooth_angle / 2.)) mirror_base = Geom2d_TrimmedCurve.DownCast(trimmed_base.Copy()) mirror_profile = Geom2d_TrimmedCurve.DownCast(trimmed_profile.Copy()) mirror_outer = Geom2d_TrimmedCurve.DownCast(trimmed_outer.Copy()) mirror_base.Mirror(mirror_axis) mirror_profile.Mirror(mirror_axis) mirror_outer.Mirror(mirror_axis) mirror_base.Reverse() mirror_profile.Reverse() mirror_outer.Reverse() # Replace the two outer arcs with a single one outer_start = trimmed_outer.StartPoint() outer_mid = trimmed_outer.EndPoint() outer_end = mirror_outer.EndPoint() outer_arc = GCE2d_MakeArcOfCircle(outer_start, outer_mid, outer_end).Value() # Create an arc for the inside of the wedge inner_circle = gp_Circ2d(gp_Ax2d(gp_Pnt2d(0, 0), gp_Dir2d()), top_radius - roller_diameter) inner_start = gp_Pnt2d(top_radius - roller_diameter, 0) inner_arc = GCE2d_MakeArcOfCircle(inner_circle, inner_start, tooth_angle).Value() inner_arc.Reverse() # Convert the 2D arcs and two extra lines to 3D edges plane = gp_Pln(gp_Origin(), gp_DZ()) arc1 = BRepBuilderAPI_MakeEdge(geomapi_To3d(trimmed_base, plane)).Edge() arc2 = BRepBuilderAPI_MakeEdge(geomapi_To3d(trimmed_profile, plane)).Edge() arc3 = BRepBuilderAPI_MakeEdge(geomapi_To3d(outer_arc, plane)).Edge() arc4 = BRepBuilderAPI_MakeEdge(geomapi_To3d(mirror_profile, plane)).Edge() arc5 = BRepBuilderAPI_MakeEdge(geomapi_To3d(mirror_base, plane)).Edge() p4 = mirror_base.EndPoint() p5 = inner_arc.StartPoint() lin1 = BRepBuilderAPI_MakeEdge(gp_Pnt(p4.X(), p4.Y(), 0), gp_Pnt(p5.X(), p5.Y(), 0)).Edge() arc6 = BRepBuilderAPI_MakeEdge(geomapi_To3d(inner_arc, plane)).Edge() p6 = inner_arc.EndPoint() lin2 = BRepBuilderAPI_MakeEdge(gp_Pnt(p6.X(), p6.Y(), 0), gp_Pnt(p0.X(), p0.Y(), 0)).Edge() wire = BRepBuilderAPI_MakeWire(arc1) wire.Add(arc2) wire.Add(arc3) wire.Add(arc4) wire.Add(arc5) wire.Add(lin1) wire.Add(arc6) wire.Add(lin2) face = BRepBuilderAPI_MakeFace(wire.Wire()) wedge = BRepPrimAPI_MakePrism(face.Shape(), gp_Vec(0.0, 0.0, thickness)) return wedge.Shape()
# Combine the two constituent wires mkWire = BRepBuilderAPI_MakeWire() mkWire.Add(aWire.Wire()) mkWire.Add(aMirroredWire) myWireProfile = mkWire.Wire() # The face that we'll sweep to make the prism myFaceProfile = BRepBuilderAPI_MakeFace(myWireProfile) # We want to sweep the face along the Z axis to the height aPrismVec = gp_Vec(0, 0, height) myBody = BRepPrimAPI_MakePrism(myFaceProfile.Face(), aPrismVec) # Add fillets to all edges through the explorer mkFillet = BRepFilletAPI_MakeFillet(myBody.Shape()) anEdgeExplorer = TopExp_Explorer(myBody.Shape(), TopAbs_EDGE) while anEdgeExplorer.More(): anEdge = topods.Edge(anEdgeExplorer.Current()) mkFillet.Add(thickness / 12.0, anEdge) anEdgeExplorer.Next() myBody = mkFillet # Create the neck of the bottle neckLocation = gp_Pnt(0, 0, height) neckAxis = gp_DZ() neckAx2 = gp_Ax2(neckLocation, neckAxis)
def __init__(self, shape, v): v = CheckGeom.to_vector(v) builder = BRepPrimAPI_MakePrism(shape.object, v) self._shape = Shape.wrap(builder.Shape()) self._s1 = Shape.wrap(builder.FirstShape()) self._s2 = Shape.wrap(builder.LastShape())
def __init__(self, face, v): v = CheckGeom.to_vector(v) builder = BRepPrimAPI_MakePrism(face.object, v) self._solid = Solid(builder.Shape()) self._f1 = Face(builder.FirstShape()) self._f2 = Face(builder.LastShape())
def __init__(self, wire, v): v = CheckGeom.to_vector(v) builder = BRepPrimAPI_MakePrism(wire.object, v) self._shell = Shell(builder.Shape()) self._w1 = Wire(builder.FirstShape()) self._w2 = Wire(builder.LastShape())
def __init__(self, edge, v): v = CheckGeom.to_vector(v) builder = BRepPrimAPI_MakePrism(edge.object, v) self._f = Face(builder.Shape()) self._e1 = Edge(builder.FirstShape()) self._e2 = Edge(builder.LastShape())
def __init__(self, vertex, v): v = CheckGeom.to_vector(v) builder = BRepPrimAPI_MakePrism(vertex.object, v) self._e = Edge(builder.Shape()) self._v1 = Vertex(builder.FirstShape()) self._v2 = Vertex(builder.LastShape())