本文整理匯總了Python中Wrappers.pairwise方法的典型用法代碼示例。如果您正苦於以下問題:Python Wrappers.pairwise方法的具體用法?Python Wrappers.pairwise怎麽用?Python Wrappers.pairwise使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Wrappers
的用法示例。
在下文中一共展示了Wrappers.pairwise方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: testWirePixmap2
# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import pairwise [as 別名]
def testWirePixmap2(face):
"""
tests drawing a wire while adjusting sharp borders
"""
PIXEL = 0.01 ;
DEFLECTION = PIXEL / 4.0;
#get bounding box
(xMin,yMin,zMin,xMax,yMax,zMax) = boundingBox([face]);
g = nx.Graph();
#adjust boundaries a bit
BUFFER=PIXEL*5;
#make pixmap
pixmap = pixmaptest.pixmap((xMin-BUFFER,yMin-BUFFER),(xMax+BUFFER,yMax+BUFFER),PIXEL);
ow = brt.OuterWire(face);
boundary = tuplesFromWire(ow,DEFLECTION);
for et in Wrappers.pairwise(boundary):
p1 = et[0];
p2 = et[1];
g.add_edge(p1,p2);
i1 = pixmap.index(p1);
i2 = pixmap.index(p2);
#print i1,i2,p1,p2
pixmap.drawLine(p1,p2,1,2);
pixmap.saveImage("c:\\temp\\thickboundary.jpg");
示例2: buildGraph
# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import pairwise [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)});
示例3: testHugePixmap
# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import pairwise [as 別名]
def testHugePixmap(face):
"""
tests drawing a wire while adjusting sharp borders
"""
PIXEL = 0.005 ;
DEFLECTION = PIXEL / 2.0;
#get bounding box
(xMin,yMin,zMin,xMax,yMax,zMax) = boundingBox([face]);
g = nx.Graph();
#adjust boundaries a bit
BUFFER=PIXEL*5;
#make pixmap
pixmap = pixmaptest.pixmap((xMin-BUFFER,yMin-BUFFER),(xMax+BUFFER,yMax+BUFFER),PIXEL);
ow = brt.OuterWire(face);
boundary = tuplesFromWire(ow,DEFLECTION);
for et in Wrappers.pairwise(boundary):
p1 = et[0];
p2 = et[1];
g.add_edge(p1,p2);
i1 = pixmap.index(p1);
i2 = pixmap.index(p2);
#print i1,i2,p1,p2
pixmap.drawLine(p1,p2,1,2);
#now, lets see how long it takes to find the intersection of a line by painting on the pixmap
q = time.clock();
p1 = ( -4.0,2.0 )
p2 = ( 4.0, 2.0 )
results = pixmap.drawLine2(p1,p2 )
print results
print "Found Intersections in %0.3f seconds" % ( time.clock() - q );
#how fast is it to determine if a point is on the face?
q = time.clock()
p1 = ( -0.5,2.0)
for i in range(1,1000):
pixmap.get(p1)
print "Tested 1000 points in %0.3f seconds" % ( time.clock() - q );
pixmap.saveImage( "c:\\temp\scanline.jpg" );
示例4: testWirePixmap
# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import pairwise [as 別名]
def testWirePixmap(face):
"""
tests drawing a wire while adjusting sharp borders
"""
PIXEL = 0.01 ;
DEFLECTION = PIXEL / 4.0;
#get bounding box
(xMin,yMin,zMin,xMax,yMax,zMax) = boundingBox([face]);
g = nx.Graph();
#adjust boundaries a bit
BUFFER=PIXEL*5;
#make pixmap
pixmap = pixmaptest.pixmap((xMin-BUFFER,yMin-BUFFER),(xMax+BUFFER,yMax+BUFFER),PIXEL);
ow = brt.OuterWire(face);
boundary = tuplesFromWire(ow,DEFLECTION);
for et in Wrappers.pairwise(boundary):
p1 = et[0];
p2 = et[1];
g.add_edge(p1,p2);
i1 = pixmap.index(p1);
i2 = pixmap.index(p2);
#print i1,i2,p1,p2
lines = bres.piecewise_bresenham_line(pixmap.p,i1,i2);
#add to the graph. this is tricky. we want to add the original locations
#to the graph if nothing changed, but we want to add the new locations
#to the graph is something did change or new points were added
for l in lines:
#print "adding edge."
g.add_edge(l[0],l[1]);
return g;
示例5: drawWire
# 需要導入模塊: import Wrappers [as 別名]
# 或者: from Wrappers import pairwise [as 別名]
def drawWire( tupleList, pixmap, fillColor=1 ):
"draws a wire onto an image"
for et in Wrappers.pairwise(tupleList):
pixmap.drawLine(et[0],et[1],fillColor);