Ejemplo n.º 1
0
    def getWires(self):
        q = time.clock()
        en = self.graphBuilder.walkEdges()

        #print "Walked Edges-- %d total paths, %0.3f sec" % (len(en), ( time.clock() - q ) );
        wires = []
        for path in en:
            wb = OCCUtil.WireBuilder()
            for edge in Util.pairwise(path):
                #each pair is a set of nodes that form an edge in the graph. We need to ge the OCC edges from each
                for occEdge in self.graphBuilder.getEdges(edge[0], edge[1]):
                    wb.add(OCCUtil.cast(occEdge))
                wires.append(wb.wire())
        return wires
Ejemplo n.º 2
0
    def build(self):
        topoWire = Topo(self.wire)

        #compute closest point on the wire
        brp = BRepExtrema.BRepExtrema_DistShapeShape()
        brp.LoadS1(OCCUtil.make_vertex(self.startPoint))
        brp.LoadS2(self.wire)

        result = brp.Perform()
        p1 = brp.PointOnShape2(1)
        wb = OCCUtil.WireBuilder()
        closestParam = None
        if brp.SupportTypeShape2(1) == BRepExtrema.BRepExtrema_IsOnEdge:
            #closest point is a point along an edge
            interSectingEdge = OCCUtil.cast(brp.SupportOnShape2(1))
            closestParam = brp.ParOnEdgeS2(1)
        else:
            #closest point is a point on a vertex, here we'll shorten one edge
            #in this case closest point is a vertex, so we dont have a param on an edge
            vertex = OCCUtil.cast(brp.SupportOnShape2(1))
            edges = []
            for e in topoWire.edges_from_vertex(vertex):
                edges.append(e)

                interSectingEdge = edges[0]

        #compute parameter along one curve
        #break the edge into two new edges. account for a split distance between them.
        ej = EdgeJoin(interSectingEdge, self.startPoint, self.trackWidth,
                      closestParam)

        #add lead-in edges
        for e in ej.connectingEdges:
            wb.add(e)

        #now add all of the other edges in the wire except the original one that we split
        for e in topoWire.edges():
            if not e.IsSame(interSectingEdge):
                wb.add(e)

        for e in ej.otherEdges:
            wb.add(e)

        return wb.wire()
Ejemplo n.º 3
0
    def buildWire(self):

        #simply do the work of the trimming and construction.
        wB = OCCUtil.WireBuilder()
        wire = self.jointRequest.wire
        tw = Topo(wire)
        edgeToTrim = self.pointOnEdge.edge

        #shorten the selected edge
        #TODO: maybe simplify this to return pointOnEdge?
        (self.trimmedEdge, self.trimmedPoint,
         self.trimmedVec) = OCCUtil.shortenEdge(edgeToTrim,
                                                self.pointOnEdge.point,
                                                self.trimDistance)

        wB.add(self.trimmedEdge)
        #add the edges we didnt touch
        for e in tw.edges():
            if not e.IsSame(edgeToTrim):
                wB.add(e)
        self.wire = wB.wire()