Esempio n. 1
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()
Esempio 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();
Esempio 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()
Esempio n. 4
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()
Esempio n. 5
0
def makeExtrusionWire( shellWire, startPoint, trackWidth):
    
    topoWire = Topo(shellWire);
    #compute closest point on the wire
    brp = BRepExtrema.BRepExtrema_DistShapeShape();
    brp.LoadS1(OCCUtil.make_vertex(startPoint));
    brp.LoadS2(shellWire);
    
    result = brp.Perform();    
    p1 = brp.PointOnShape2(1);
    wb = WireBuilder();

    #make an edge from start point to located point.
    #wb.add ( OCCUtil.edgeFromTwoPoints(startPoint, p1 ) );
    dist = p1.Distance(p2)
    
    
    if brp.SupportTypeShape2(1) == BRepExtrema.BRepExtrema_IsOnEdge:
  
        #closest point is a point along an edge
        interSectingEdge = OCCUtil.cast(brp.SupportOnShape2(1));
        p = brp.ParOnEdgeS2(1);
    
        #compute parameter along one curve
        #break the edge into two new edges. account for a split distance between them.
        (e1,e2)= OCCUtil.splitEdge(interSectingEdge,p);
        
         
        wb.add(e1);
                
        #add second one shortened, on the end near the vertex
        wb.add ( OCCUtil.shortenEdge(e2,p1,trackWidth)); #hack, must find parameter closest to this end

        #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);

    else:
        #closest point is a point on a vertex, here we'll shorten one edge
        #
        vertex = OCCUtil.cast(brp.SupportOnShape2(1));        
        edges = [];
        for e in  topoWire.edges_from_vertex(vertex):
            edges.append(e);
            
        #shorten one, leave other intact
        #try to handle case where vertex is at end of a wire ( ie a non-closed wire )
        e1 = edges[0];
        wb.add( edges[0]);
        e2 = None;
        if len(edges) > 1:
            e2 = edges[1];            
            e3 = OCCUtil.shortenEdge(e2,p1,trackWidth); #hack-- find edges closest to this end
            #display.DisplayColoredShape(e3,'BLUE')
            wb.add ( e3); 
        
        for e in topoWire.edges():
            if e.IsSame(e1): continue;                
            if e2 and e.IsSame(e2): continue;            
            wb.add ( e );
            
    return wb.wire();