當前位置: 首頁>>代碼示例>>Python>>正文


Python Wrappers.trimmedEdge方法代碼示例

本文整理匯總了Python中Wrappers.trimmedEdge方法的典型用法代碼示例。如果您正苦於以下問題:Python Wrappers.trimmedEdge方法的具體用法?Python Wrappers.trimmedEdge怎麽用?Python Wrappers.trimmedEdge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Wrappers的用法示例。


在下文中一共展示了Wrappers.trimmedEdge方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: buildGraph

# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import trimmedEdge [as 別名]
	def buildGraph(self):
		g = self.graph;
		
		#add fill edge nodes first
		for e in self.fillEdges:
			g.add_edge(e[0], e[1], {"type":'FILL', "edgeList":e[2]});
					
		#add boundary nodes. 
		for (edge, pointList ) in self.boundaryEdges.iteritems():
			#sort the points by parameter
			sortedPoints = sorted(pointList,key = lambda p: p.param );
			
			for (poe1,poe2) in Wrappers.pairwise(sortedPoints):
				#dont add if there is already an edge
				if not g.has_edge(poe1.node,poe2.node):
					#here we need to trim each edge to limit it to the desired parameters
					g.add_edge(poe1.node,poe2.node,{"type":"BOUND", "edge": Wrappers.trimmedEdge(edge,poe1.param,poe2.param)});
開發者ID:adam-urbanczyk,項目名稱:emcfab,代碼行數:19,代碼來源:edgegraph4.py

示例2: newEdge

# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import trimmedEdge [as 別名]
	def newEdge(self):
		"make a new edge between specified parameters"
		return Wrappers.trimmedEdge(self.edge,self.p1, self.p2);
開發者ID:adam-urbanczyk,項目名稱:emcfab,代碼行數:5,代碼來源:edgegraph3__old.py

示例3: splitWire

# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import trimmedEdge [as 別名]
def splitWire(wire, ipoints):
	"""
		ipoints is a list of intersection points.
		returns a list of wires inside the intersection point
		
		BASELINE PERFORMANCE: 11 ms per call for splitwiretest
	"""
	
	#load original wire
	#we make an important assumption that the wire is organized from
	#left to right or from right to left, and starts outside the boundaries.
	#this allows the scanline algorithm to define which segments are 'inside'
	#wr = Wrappers.Wire(wire);
	
	
	
	#assume edges are in ascending x order also
	#very interesting OCC weird thing: topexp is much faster than wireexplorer
	topexp = TopExp.TopExp_Explorer();
	topexp.Init(wire,TopAbs.TopAbs_EDGE);


	#sort intersection points by ascending X location
	ix = sorted(ipoints,key = lambda p: p.point.X() );
	
	inside = False;		
	edges = []; #a list of edges for the current wire.	

	iEdge = 0;
	iIntersection=0;
	
	#TODO: handle odd number of intersections
	
	#the last parameter on the current edge.
	#it is either the first parameter on the current edge,
	#or the last intersection point on the edge.
	currentEdge = Wrappers.cast(topexp.Current());
	currentEdgeBounds = brepTool.Range(currentEdge);
	startParam = currentEdgeBounds[0];
	#print "handling %d intersections" % len(ix)
	while iIntersection < len(ix) and ( topexp.More()  ) :
		currentIntersection = ix[iIntersection];

		if hashE(currentEdge) == currentIntersection.hash:
						
			#current edge matches intersection point
			if inside:
				#transition to outside: add this part edge
				currentEdgeBounds = brepTool.Range(currentEdge);
				newEdge = Wrappers.trimmedEdge(currentEdge,startParam,currentIntersection.param);
				#TestDisplay.display.showShape(newEdge);
				edges.append(newEdge);
							
			#move to next point, store last intersection
			iIntersection += 1;
			startParam = currentIntersection.param;			
			inside = not inside;
			
		else:
			#edges do not match		
			if inside:
				currentEdgeBounds = brepTool.Range(currentEdge);
				if startParam == currentEdgeBounds[0]:
					edges.append(currentEdge);
				else:
					newEdge = Wrappers.trimmedEdge(currentEdge,startParam, currentEdgeBounds[1] );
					
					edges.append(newEdge);
			
			#move to next edge
			topexp.Next();
			currentEdge = Wrappers.cast(topexp.Current());
			startParam = currentEdgeBounds[0];			
	#print "returning %d edges" % len(edges)
	return edges;	
開發者ID:adam-urbanczyk,項目名稱:emcfab,代碼行數:77,代碼來源:edgegraph3__old.py

示例4: splitWire

# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import trimmedEdge [as 別名]
def splitWire(wire, ipoints):
	"""
		ipoints is a list of intersection points.
	"""
	
	#load original wire
	#we make an important assumption that the wire is organized from
	#left to right or from right to left, and starts outside the boundaries.
	#this allows the scanline algorithm to define which segments are 'inside'
	wr = Wrappers.Wire(wire);
	
	#assume edges are in ascending x order also
	eS = wr.edgesAsList();	
	

	#sort intersection points by ascending X location
	ix = sorted(ipoints,key = lambda p: p.point.X() );
	
	inside = False;		
	edges = []; #a list of edges for the current wire.	
	iEdge = 0;
	iIntersection=0;
	
	#TODO: handle odd number of intersections
	
	#the last parameter on the current edge.
	#it is either the first parameter on the current edge,
	#or the last intersection point on the edge.
	currentEdge = eS[iEdge];
	currentEdgeBounds = brepTool.Range(currentEdge);
	startParam = currentEdgeBounds[0];
	
	while iIntersection < len(ix) and ( iEdge < len(eS)  ) :
		currentIntersection = ix[iIntersection];

		if hashE(currentEdge) == hashE(currentIntersection.edge):
						
			#current edge matches intersection point
			if inside:
				#transition to outside: add this part edge
				currentEdgeBounds = brepTool.Range(currentEdge);
				newEdge = Wrappers.trimmedEdge(currentEdge,startParam,currentIntersection.param);
				edges.append(newEdge);
							
			#move to next point, store last intersection
			iIntersection += 1;
			startParam = currentIntersection.param;			
			inside = not inside;
			
		else:
			#edges do not match		
			if inside:
				currentEdgeBounds = brepTool.Range(currentEdge);
				if startParam == currentEdgeBounds[0]:
					edges.append(currentEdge);
				else:
					newEdge = Wrappers.trimmedEdge(currentEdge,startParam, currentEdgeBounds[1] );

					edges.append(newEdge);
			
			#move to next edge
			iEdge += 1;
			currentEdge = eS[iEdge];
			startParam = currentEdgeBounds[0];			

	return edges;
開發者ID:adam-urbanczyk,項目名稱:emcfab,代碼行數:68,代碼來源:edgegraph3_b.py

示例5: splitWire

# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import trimmedEdge [as 別名]
def splitWire(wire, ipoints):
    """
		ipoints is a list of intersection points.
		returns a list of wires inside the intersection point
		
		this method must also work for a 'wire' consisting of a single
		edge. more than one intersection point can be on each edge, 
		but all of the ipoints are expected to be on edges in the provided wire.
		BASELINE PERFORMANCE: 11 ms per call for splitwiretest
		
		returns a list of lists.
		each element in the top list is a chain of connected edges.
			each element in that list is an edge ( or part of an edge )
			
		so, for example, suppose you compute a wire that has 100 edges, and there are 4 intersection points.
		in this case, there will be two elements returned, and each element would contain a list of edges
		between the two segments.
		---E1---+---E2---+-X-E3---+---E4--X--+---E5---
		will return [  [E1,E2], [ E3,E4 ] ]
		
	"""
    topexp = TopExp.TopExp_Explorer()
    topexp.Init(wire, TopAbs.TopAbs_EDGE)

    # sort intersection points by ascending X location
    ix = sorted(ipoints, key=lambda p: p.point.X())

    edgeList = []

    assert (len(ipoints) % 2) == 0

    for i in range(0, len(ipoints), 2):
        # process intersection points in pairs
        # TODO: this could be done more cleanly with a pairwise iterator
        currentIntersection = ix[i]
        nextIntersection = ix[i + 1]

        # if they are on the same edge, simply add a trimmed edge.
        # in this case,
        if currentIntersection.hash == nextIntersection.hash:
            edgeList.append(
                [Wrappers.trimmedEdge(currentIntersection.edge, currentIntersection.param, nextIntersection.param)]
            )
        else:
            # intersections are not on the same edge.
            # add the fraction of the first edge
            (bp, ep) = brepTool.Range(currentIntersection.edge)
            edges = []
            # print "adding piece of start edge."
            edges.append(Wrappers.trimmedEdge(currentIntersection.edge, currentIntersection.param, ep))

            # pick up whole edges between the first intersection and the next one
            # loop till current edge is same as current intersection
            while topexp.Current().__hash__() != currentIntersection.hash:
                topexp.Next()

                # advance to next edge
            topexp.Next()

            # add edges till current edge is same as next intersection
            # most of the performance suckage is happening here, with gc associated with these
            # edge objects.  If that gets fixed, we'll get a huge speed boost. about 33% of total time is saved.
            while topexp.Current().__hash__() != nextIntersection.hash:
                edge = Wrappers.cast(topexp.Current())
                edges.append(edge)
                # print "adding middle edge"
                topexp.Next()

                # add the last edge
            (bp, ep) = brepTool.Range(nextIntersection.edge)
            edges.append(Wrappers.trimmedEdge(nextIntersection.edge, bp, nextIntersection.param))
            # print "adding last piece of edge"
            edgeList.append(edges)
    return edgeList
開發者ID:adam-urbanczyk,項目名稱:emcfab,代碼行數:76,代碼來源:edgegraph3.py


注:本文中的Wrappers.trimmedEdge方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。