Esempio n. 1
0
    def to_wire(self, stroking_interval=5.0):
        """convert IfcTransitionSegment2D to OCC wire

        :param stroking_interval: maximum curve length between points to be calculated
        :type stroking_interval: float
        :return: OCC wire containing interpolated points
        """
        points = list()

        L = self.SegmentLength
        R = self.EndRadius
        ccw = self.IsStartRadiusCCW
        trans_type = self.TransitionCurveType.name

        num_intervals = math.ceil(L / stroking_interval)
        interval_dist = L / num_intervals
        lpt = 0.0  # length along the curve at the point to be calculated

        for _ in range(num_intervals):
            points.append(self._calc_transition_curve_point(lpt, L, R, ccw, trans_type))
            lpt += interval_dist

        edges = list()
        for i in range(len(points) - 1):
            edges.append(BRepBuilderAPI_MakeEdge2d(points[i], points[i + 1]))

        wire = BRepBuilderAPI_MakeWire()
        for e in edges:
            wire.Add(e.Edge())
        # return wire
        return points
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()
Esempio n. 3
0
 def display_path(lay, col):
     wire = BRepBuilderAPI_MakeWire()
     for i in range(1, len(lay)):
         if lay[i - 1][0].Distance(lay[i][0]) < 50:
             ray = BRepBuilderAPI_MakeEdge(lay[i - 1][0], lay[i][0]).Edge()
             wire.Add(ray)
     display.DisplayShape(wire.Wire(), color=col, update=False)
Esempio n. 4
0
def thicken_spline(event=None):
    # Creation of points for the spine
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(1, 4, 0))
    array.SetValue(2, gp_Pnt(2, 2, 0))
    array.SetValue(3, gp_Pnt(3, 3, 0))
    array.SetValue(4, gp_Pnt(4, 3, 0))
    array.SetValue(5, gp_Pnt(5, 5, 0))

    # Creation of a Bezier Curve as the spine
    bz_curv = Geom_BezierCurve(array)
    bz_curv_edge = BRepBuilderAPI_MakeEdge(bz_curv).Edge()
    bz_curv_wire = BRepBuilderAPI_MakeWire(bz_curv_edge).Wire()
    display.DisplayShape(bz_curv_wire)

    # Creation of profile to sweep along the spine
    circle = gp_Circ(gp_ZOX(), 1)
    circle.SetLocation(array[0])
    circle_edge = BRepBuilderAPI_MakeEdge(circle).Edge()
    circle_wire = BRepBuilderAPI_MakeWire(circle_edge).Wire()

    # Creation of the law to dictate the evolution of the profile
    brep1 = BRepOffsetAPI_MakePipeShell(bz_curv_wire)
    law_f = Law_Linear()
    law_f.Set(0, 0.5, 1, 1)
    brep1.SetLaw(circle_wire, law_f, False, True)
    return brep1.Shape()
Esempio n. 5
0
def extrude_polyline2d(polyline, frame, height):
    pol3d = polyline.to_frame(frame)
    lines = []
    yb_point = Point([frame[0][i] for i in range(3)])
    yb_vec = Vector([frame[1][0][i] for i in range(3)]).unit()
    print '*************'
    print yb_vec
    orig = gp_Pnt(frame[0][0], frame[0][1], frame[0][2])
    vec = gp_Dir(yb_vec[0], yb_vec[1], yb_vec[2])
    plane = gp_Pln(orig, vec)

    for i, p in enumerate(pol3d[:-1]):
        print p
        print 'zob'
        gp0 = gp_Pnt(p[0], p[1], p[2])
        gp1 = gp_Pnt(pol3d[i + 1][0], pol3d[i + 1][1], pol3d[i + 1][2])
        lines.append(BRepBuilderAPI_MakeEdge(gp0, gp1).Edge())

    wire = BRepBuilderAPI_MakeWire(lines[0])

    for l in lines[1:]:
        wire.Add(l)

    face = BRepBuilderAPI_MakeFace(wire.Wire())
    print 'normal'
    print[vec.X(), vec.Y(), vec.Z()]
    extrude = BRepPrimAPI_MakePrism(
        face.Shape(),
        gp_Vec(height * vec.X(), height * vec.Y(), height * vec.Z())).Shape()
    return extrude
Esempio n. 6
0
def main():

    vertices = [gp_Pnt(p[0], p[1], p[2]) for p in mesh['vertices']]
    oFaces = []

    builder = BRep_Builder()
    shell = TopoDS_Shell()
    builder.MakeShell(shell)

    for face in mesh['faces']:
        edges = []
        face.reverse()
        for i in range(len(face)):
            cur = face[i]
            nxt = face[(i + 1) % len(face)]
            segment = GC_MakeSegment(vertices[cur], vertices[nxt])
            edges.append(BRepBuilderAPI_MakeEdge(segment.Value()))

        wire = BRepBuilderAPI_MakeWire()
        for edge in edges:
            wire.Add(edge.Edge())

        oFace = BRepBuilderAPI_MakeFace(wire.Wire())
        builder.Add(shell, oFace.Shape())
    write_stl_file(shell, "./cube_binding.stl")
Esempio n. 7
0
def make_revolved_cylinder(pnt, height, revolve_angle, rotation, wall_thick):
    """
    This method demonstrates how to create a revolved shape from a drawn closed edge.
    It currently creates a hollow cylinder

    adapted from algotopia.com's opencascade_basic tutorial:
    http://www.algotopia.com/contents/opencascade/opencascade_basic

    :param pnt:
    :param height:
    :param revolve_angle:
    :param rotation:
    :param wall_thick:
    :type pnt: dict
    :type height: float
    :type revolve_angle: float
    :type rotation: float
    :type wall_thick: float
    """
    from OCC.Core.BRepBuilderAPI import (
        BRepBuilderAPI_MakeEdge,
        BRepBuilderAPI_MakeFace,
        BRepBuilderAPI_MakeWire,
    )
    from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeRevol
    from OCC.Core.gp import gp_Ax1, gp_Dir, gp_Pnt

    face_inner_radius = pnt["X"] + (17.0 - wall_thick / 2) * 1000
    face_outer_radius = pnt["X"] + (17.0 + wall_thick / 2) * 1000

    # point to create an edge from
    edg_points = [
        gp_Pnt(face_inner_radius, pnt["Y"], pnt["Z"]),
        gp_Pnt(face_inner_radius, pnt["Y"], pnt["Z"] + height),
        gp_Pnt(face_outer_radius, pnt["Y"], pnt["Z"] + height),
        gp_Pnt(face_outer_radius, pnt["Y"], pnt["Z"]),
        gp_Pnt(face_inner_radius, pnt["Y"], pnt["Z"]),
    ]

    # aggregate edges in wire
    hexwire = BRepBuilderAPI_MakeWire()

    for i in range(len(edg_points) - 1):
        hexedge = BRepBuilderAPI_MakeEdge(edg_points[i],
                                          edg_points[i + 1]).Edge()
        hexwire.Add(hexedge)

    hexwire_wire = hexwire.Wire()
    # face from wire
    hexface = BRepBuilderAPI_MakeFace(hexwire_wire).Face()
    revolve_axis = gp_Ax1(gp_Pnt(pnt["X"], pnt["Y"], pnt["Z"]),
                          gp_Dir(0, 0, 1))
    # create revolved shape
    revolved_shape_ = BRepPrimAPI_MakeRevol(hexface, revolve_axis,
                                            np.radians(
                                                float(revolve_angle))).Shape()
    revolved_shape_ = rotate_shp_3_axis(revolved_shape_, revolve_axis,
                                        rotation)

    return revolved_shape_
Esempio n. 8
0
def face_polygon(pnts):
    wire_maker = BRepBuilderAPI_MakeWire()
    verts = [BRepBuilderAPI_MakeVertex(as_occ(pnt, gp_Pnt)).Vertex() for pnt in pnts]
    for i in range(len(verts)):
        j = (i + 1) % len(verts)
        wire_maker.Add(BRepBuilderAPI_MakeEdge(verts[i], verts[j]).Edge())
        
    return BRepBuilderAPI_MakeFace(wire_maker.Wire()).Face() 
Esempio n. 9
0
def _make_wire(arr):
    mk = BRepBuilderAPI_MakeWire()

    for ptr in arr:
        if (ptr.Shape().ShapeType() == TopAbs_WIRE):
            mk.Add(ptr.Wire())
        elif (ptr.Shape().ShapeType() == TopAbs_EDGE):
            mk.Add(ptr.Edge())

    return Shape(mk.Wire())
Esempio n. 10
0
def __make_wire(lst):
    mk = BRepBuilderAPI_MakeWire()

    for ptr in lst:
        if ptr.Shape().ShapeType() == TopAbs_WIRE:
            mk.Add(ptr.Wire())
        elif ptr.Shape().ShapeType() == TopAbs_EDGE:
            mk.Add(ptr.Edge())

    return mk.Wire()
Esempio n. 11
0
def wire_from_polyline(pol3d):
    lines = []
    for i, p in enumerate(pol3d[:-1]):
        gp0 = gp_Pnt(p[0], p[1], p[2])
        gp1 = gp_Pnt(pol3d[i + 1][0], pol3d[i + 1][1], pol3d[i + 1][2])
        lines.append(BRepBuilderAPI_MakeEdge(gp0, gp1).Edge())
    wire = BRepBuilderAPI_MakeWire(lines[0])

    for l in lines[1:]:
        wire.Add(l)
    return wire
 def generate_planar_slices(nozz_dia, sur_nozz_dia):
     xmin, ymin, zmin, xmax, ymax, zmax = get_boundingbox(part_shape)
     print(xmax - xmin, ",", ymax - ymin, ",", zmax - zmin)
     wires = []
     slices = []
     contours = []
     for z in numpy.arange(zmin+(nozz_dia/2)+(sur_nozz_dia/2), \
      zmax-(nozz_dia/2)-(sur_nozz_dia/2), nozz_dia):
         plane = gp_Pln(gp_Pnt(0., 0., z), gp_Dir(0., 0., 1.))
         slices.append(Slicing.plane_shape_intersection(plane, part_shape))
     for s in range(0, len(slices)):
         wire = []
         wires.append([])
         while len(slices[s]) != 0:
             for i in range(0, len(slices[s])):
                 if len(wire) == 0:
                     wire.append(slices[s][i])
                     slices[s].remove(slices[s][i])
                     break
                 elif Slicing.do_edges_connect(slices[s][i], wire[-1]):
                     wire.append(slices[s][i])
                     slices[s].remove(slices[s][i])
                     break
             if Slicing.do_edges_connect(wire[0], wire[-1]):
                 if len(wire) > 2:
                     wires[s].append(wire)
                     wire = []
                 elif len(wire) == 2 and Slicing.do_edges_loop(
                         wire[0], wire[-1]):
                     wires[s].append(wire)
                     wire = []
     for k in range(0, len(wires)):
         contours.append([])
         for l in range(0, len(wires[k])):
             make_wire = BRepBuilderAPI_MakeWire()
             for edge in wires[k][l]:
                 make_wire.Add(edge)
             try:
                 made_wire = make_wire.Wire()
                 contours[k].append(made_wire)
             except:
                 print("Skipped a contour!")
                 continue
     contour_faces = []
     for contour in contours:
         if len(contour) == 1:
             contour_faces.append(
                 BRepBuilderAPI_MakeFace(contour[0]).Face())
         else:
             contour_faces.extend(Slicing.get_layer_faces(contour))
     # for l in range(0,len(contour_faces)):
     #   display.DisplayShape(contour_faces[l], color=colour[l%5],\
     #   	transparency=0.95, update=True)
     return contour_faces
Esempio n. 13
0
def face_polyline3d(pol3d):
    from OCC.Core.TopoDS import topods
    lines = []
    for i, p in enumerate(pol3d[:-1]):
        gp0 = gp_Pnt(p[0], p[1], p[2])
        gp1 = gp_Pnt(pol3d[i + 1][0], pol3d[i + 1][1], pol3d[i + 1][2])
        lines.append(BRepBuilderAPI_MakeEdge(gp0, gp1).Edge())
    wire = BRepBuilderAPI_MakeWire(lines[0])
    for l in lines[1:]:
        wire.Add(l)
    face = BRepBuilderAPI_MakeFace(wire.Wire())
    return face
Esempio n. 14
0
 def makeWire(self):
     """Generate a wire from the edges in self.edgeList."""
     wireBldr = BRepBuilderAPI_MakeWire()
     occ_seq = TopTools_ListOfShape()
     for edge in self.edgeList:
         occ_seq.Append(edge)
     wireBldr.Add(occ_seq)
     if wireBldr.IsDone():
         self.wire = wireBldr.Wire()
         status = True
     else:
         status = False
     return status
def pipe():
    # the bspline path, must be a wire
    array2 = TColgp_Array1OfPnt(1, 3)
    array2.SetValue(1, gp_Pnt(0, 0, 0))
    array2.SetValue(2, gp_Pnt(0, 1, 2))
    array2.SetValue(3, gp_Pnt(0, 2, 3))
    bspline2 = GeomAPI_PointsToBSpline(array2).Curve()
    path_edge = BRepBuilderAPI_MakeEdge(bspline2).Edge()
    path_wire = BRepBuilderAPI_MakeWire(path_edge).Wire()

    # the bspline profile. Profile mist be a wire
    array = TColgp_Array1OfPnt(1, 5)
    array.SetValue(1, gp_Pnt(0, 0, 0))
    array.SetValue(2, gp_Pnt(1, 2, 0))
    array.SetValue(3, gp_Pnt(2, 3, 0))
    array.SetValue(4, gp_Pnt(4, 3, 0))
    array.SetValue(5, gp_Pnt(5, 5, 0))
    bspline = GeomAPI_PointsToBSpline(array).Curve()
    profile_edge = BRepBuilderAPI_MakeEdge(bspline).Edge()

    # pipe
    pipe = BRepOffsetAPI_MakePipe(path_wire, profile_edge).Shape()

    display.DisplayShape(profile_edge, update=False)
    display.DisplayShape(path_wire, update=False)
    display.DisplayShape(pipe, update=True)
Esempio n. 16
0
File: blade.py Progetto: o4fr/BladeX
    def _generate_tip(self, maxDeg):
        """
        Private method to generate the surface that closing the blade tip.

        :param int maxDeg: Define the maximal U degree of generated surface
        """
        self._import_occ_libs()

        generator = BRepOffsetAPI_ThruSections(False, False, 1e-10)
        generator.SetMaxDegree(maxDeg)
        # npoints_up == npoints_down
        npoints = len(self.blade_coordinates_down[-1][0])
        vertices_1 = TColgp_HArray1OfPnt(1, npoints)
        vertices_2 = TColgp_HArray1OfPnt(1, npoints)
        for j in range(npoints):
            vertices_1.SetValue(
                j + 1,
                gp_Pnt(1000 * self.blade_coordinates_down[-1][0][j],
                       1000 * self.blade_coordinates_down[-1][1][j],
                       1000 * self.blade_coordinates_down[-1][2][j]))

            vertices_2.SetValue(
                j + 1,
                gp_Pnt(1000 * self.blade_coordinates_up[-1][0][j],
                       1000 * self.blade_coordinates_up[-1][1][j],
                       1000 * self.blade_coordinates_up[-1][2][j]))

        # Initializes an algorithm for constructing a constrained
        # BSpline curve passing through the points of the blade last
        # section, with tolerance = 1e-9
        bspline_1 = GeomAPI_Interpolate(vertices_1, False, 1e-9)
        bspline_1.Perform()

        bspline_2 = GeomAPI_Interpolate(vertices_2, False, 1e-9)
        bspline_2.Perform()

        edge_1 = BRepBuilderAPI_MakeEdge(bspline_1.Curve()).Edge()
        edge_2 = BRepBuilderAPI_MakeEdge(bspline_2.Curve()).Edge()

        # Add BSpline wire to the generator constructor
        generator.AddWire(BRepBuilderAPI_MakeWire(edge_1).Wire())
        generator.AddWire(BRepBuilderAPI_MakeWire(edge_2).Wire())
        # Returns the shape built by the shape construction algorithm
        generator.Build()
        # Returns the Face generated by each edge of the first section
        self.generated_tip = generator.GeneratedFace(edge_1)
Esempio n. 17
0
 def __init__(self, center: numpy.array, normal: numpy.array,
              radius: float):
     super().__init__()
     self.wire = TopoDS_Wire
     gpCenter = OccPoint(center)
     gpVec = OccVector(normal)
     mkcircle = GC_MakeCircle(gpCenter.Value(), gpVec.Value(), radius)
     if not mkcircle.IsDone():
         OCCWrapper.OccError('OccCircle', mkcircle)
     else:
         mkwire = BRepBuilderAPI_MakeWire(mkcircle.Value())
         if not mkwire.IsDone():
             OCCWrapper.OccError('OccCircle', mkwire)
         else:
             self.done = True
             self.w = mkwire.Wire()
     return
Esempio n. 18
0
 def makeSqProfile(self, size):
     # points and segments need to be in CW sequence to get W pointing along Z
     p1 = gp_Pnt(-size, size, 0).Transformed(self.Trsf)
     p2 = gp_Pnt(size, size, 0).Transformed(self.Trsf)
     p3 = gp_Pnt(size, -size, 0).Transformed(self.Trsf)
     p4 = gp_Pnt(-size, -size, 0).Transformed(self.Trsf)
     seg1 = GC_MakeSegment(p1, p2).Value()
     seg2 = GC_MakeSegment(p2, p3).Value()
     seg3 = GC_MakeSegment(p3, p4).Value()
     seg4 = GC_MakeSegment(p4, p1).Value()
     e1 = BRepBuilderAPI_MakeEdge(seg1).Edge()
     e2 = BRepBuilderAPI_MakeEdge(seg2).Edge()
     e3 = BRepBuilderAPI_MakeEdge(seg3).Edge()
     e4 = BRepBuilderAPI_MakeEdge(seg4).Edge()
     aWire_mkr = BRepBuilderAPI_MakeWire(e1, e2, e3, e4)
     myWireProfile = aWire_mkr.Wire()
     return myWireProfile  # TopoDS_Wire
Esempio n. 19
0
def makeHalfWire(event=None):
    global aWire
    aWire = BRepBuilderAPI_MakeWire(aEdge1.Edge(), aEdge2.Edge(),
                                    aEdge3.Edge()).Wire()
    display.EraseAll()
    display.DisplayColoredShape(aWire, 'BLUE')
    display.Repaint()
    win.statusBar().showMessage('Make Half Wire complete')
 def display_path(lay, col, nozz_dia=0):
     wire = BRepBuilderAPI_MakeWire()
     for i in range(1, len(lay)):
         ray = BRepBuilderAPI_MakeEdge(lay[i - 1][0], lay[i][0]).Edge()
         if i == len(lay) - 1:
             display.DisplayShape(ray, color=col, update=True)
         else:
             display.DisplayShape(ray, color=col, update=False)
Esempio n. 21
0
def makeWholeWire():
    global myWireProfile
    xAxis = gp_OX()
    # Set up the mirror
    aTrsf = gp_Trsf()
    aTrsf.SetMirror(xAxis)
    # Apply the mirror transform
    aBRepTrsf = BRepBuilderAPI_Transform(aWire, aTrsf)
    # Convert mirrored shape to a wire
    aMirroredShape = aBRepTrsf.Shape()
    aMirroredWire = topods_Wire(aMirroredShape)
    # Combine the two wires
    mkWire = BRepBuilderAPI_MakeWire()
    mkWire.Add(aWire)
    mkWire.Add(aMirroredWire)
    myWireProfile = mkWire.Wire()
    return myWireProfile
Esempio n. 22
0
def make_wire(*args):
    # if we get an iterable, than add all edges to wire builder
    if isinstance(args[0], list) or isinstance(args[0], tuple):
        wire = BRepBuilderAPI_MakeWire()
        for i in args[0]:
            wire.Add(i)
        wire.Build()
        return wire.Wire()
    wire = BRepBuilderAPI_MakeWire(*args)
    return wire.Wire()
Esempio n. 23
0
def make_wire(*args):
    # if we get an iterable, than add all edges to wire builder
    if isinstance(args[0], list) or isinstance(args[0], tuple):
        wire = BRepBuilderAPI_MakeWire()
        for i in args[0]:
            wire.Add(i)
        wire.Build()
        return wire.Wire()

    wire = BRepBuilderAPI_MakeWire(*args)
    wire.Build()
    with assert_isdone(wire, 'failed to produce wire'):
        result = wire.Wire()
        return result
def boundary_curve_from_2_points(p1, p2):
    # first create an edge
    e0 = BRepBuilderAPI_MakeEdge(p1, p2).Edge()
    w0 = BRepBuilderAPI_MakeWire(e0).Wire()
    # boundary for filling
    adap = BRepAdaptor_CompCurve(w0)
    p0_h = BRepAdaptor_HCompCurve(adap)
    boundary = GeomFill_SimpleBound(p0_h.GetHandle(), 1e-6, 1e-6)
    return boundary.GetHandle()
Esempio n. 25
0
 def __init__(self, p1: numpy.array, p2: numpy.array, p3: numpy.array):
     # p1, p2, p3: Three points on a circle. Cannot be colinear
     super().__init__()
     self.wire = TopoDS_Wire
     gp1 = OccPoint(p1)
     gp2 = OccPoint(p2)
     gp3 = OccPoint(p3)
     mkcircle = GC_MakeCircle(gp1.Value(), gp3.Value(), gp2.Value())
     if not mkcircle.IsDone():
         OCCWrapper.OccError(type(self), mkcircle)
     else:
         mkwire = BRepBuilderAPI_MakeWire(mkcircle.Value())
         if not mkwire.IsDone():
             OCCWrapper.OccError(type(self), mkwire)
         else:
             self.done = True
             self.wire = mkwire.Wire()
     return
Esempio n. 26
0
 def makeSqProfile(self, size):
     # points and segments need to be in CW sequence to get W pointing along Z
     p1 = gp_Pnt2d(-size, size)
     p2 = gp_Pnt2d(size, size)
     p3 = gp_Pnt2d(size, -size)
     p4 = gp_Pnt2d(-size, -size)
     seg1 = GCE2d_MakeSegment(p1, p2)
     seg2 = GCE2d_MakeSegment(p2, p3)
     seg3 = GCE2d_MakeSegment(p3, p4)
     seg4 = GCE2d_MakeSegment(p4, p1)
     e1 = BRepBuilderAPI_MakeEdge(seg1.Value(), self.plane)
     e2 = BRepBuilderAPI_MakeEdge(seg2.Value(), self.plane)
     e3 = BRepBuilderAPI_MakeEdge(seg3.Value(), self.plane)
     e4 = BRepBuilderAPI_MakeEdge(seg4.Value(), self.plane)
     aWire = BRepBuilderAPI_MakeWire(e1.Edge(), e2.Edge(), e3.Edge(),
                                     e4.Edge())
     myWireProfile = aWire.Wire()
     return myWireProfile  # TopoDS_Wire
Esempio n. 27
0
def make_wire(*args):
    # if we get an iterable, than add all edges to wire builder
    if isinstance(args[0], (list, tuple)):
        wire = BRepBuilderAPI_MakeWire()
        for i in args[0]:
            wire.Add(i)
        wire.Build()
        return wire.Wire()
    wire = BRepBuilderAPI_MakeWire(*args)
    assert_isdone(wire, "failed to produce wire")
    return wire.Wire()
Esempio n. 28
0
def makeWholeWire(event=None):
    global myWireProfile
    xAxis = gp_OX()
    # Set up the mirror
    aTrsf = gp_Trsf()
    aTrsf.SetMirror(xAxis)
    # Apply the mirror transform
    aBRepTrsf = BRepBuilderAPI_Transform(aWire, aTrsf)
    # Convert mirrored shape to a wire
    aMirroredShape = aBRepTrsf.Shape()
    aMirroredWire = topods_Wire(aMirroredShape)
    # Combine the two wires
    mkWire = BRepBuilderAPI_MakeWire()
    mkWire.Add(aWire)
    mkWire.Add(aMirroredWire)
    myWireProfile = mkWire.Wire()
    display.DisplayColoredShape(myWireProfile, 'BLUE')
    display.Repaint()
    win.statusBar().showMessage('Make whole wire complete')
Esempio n. 29
0
    def _renderWireObj(self, aWire, aWireRadius):
        startPoint, tangentDir = _getWireStartPointAndTangentDir(aWire)
        profileCircle = GC_MakeCircle(startPoint, tangentDir,
                                      aWireRadius).Value()
        profileEdge = BRepBuilderAPI_MakeEdge(profileCircle).Edge()
        profileWire = BRepBuilderAPI_MakeWire(profileEdge).Wire()

        shape = BRepOffsetAPI_MakePipe(aWire, profileWire).Shape()

        self._renderShapeObj(shape)
Esempio n. 30
0
def _polysegment(pnts, closed=False) -> Shape:
    if len(pnts) <= 1:
        raise Exception("Need at least two points for polysegment")

    mkWire = BRepBuilderAPI_MakeWire()

    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}")

    for i in range(len(pnts) - 1):
        mkWire.Add(__make_edge(pnts[i], pnts[i + 1]))

    if (closed):
        mkWire.Add(__make_edge(pnts[len(pnts) - 1], pnts[0]))

    return Shape(mkWire.Wire())