当前位置: 首页>>代码示例>>Python>>正文


Python Wrappers.pairwise方法代码示例

本文整理汇总了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");
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:32,代码来源:pixMapFromWire.py

示例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)});
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:19,代码来源:edgegraph4.py

示例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" );
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:46,代码来源:pixMapFromWire.py

示例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;
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:39,代码来源:pixMapFromWire.py

示例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);	
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:6,代码来源:pixMapFromWire.py


注:本文中的Wrappers.pairwise方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。