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


Python Wrappers类代码示例

本文整理汇总了Python中Wrappers的典型用法代码示例。如果您正苦于以下问题:Python Wrappers类的具体用法?Python Wrappers怎么用?Python Wrappers使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Wrappers类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testSplitWire1

def testSplitWire1():
	"""
		Test split wire function. there are two main cases:
		wires with intersection on different edges,
		and a wire with a single edge split in many places
	"""
		
	#case 1: a single edge with lots of intersections along its length
	e  = Wrappers.edgeFromTwoPoints( gp.gp_Pnt(0,0,0),gp.gp_Pnt(5,0,0));
	w = Wrappers.wireFromEdges([e]);
	
	#out of order on purpose
	p1 = PointOnAnEdge(e,1.0,gp.gp_Pnt(1.0,0,0));
	p3 = PointOnAnEdge(e,3.0,gp.gp_Pnt(3.0,0,0));
	p2 = PointOnAnEdge(e,2.0,gp.gp_Pnt(2.0,0,0));	
	p4 = PointOnAnEdge(e,4.0,gp.gp_Pnt(4.0,0,0));
	ee = splitWire(w,[p1,p3,p2,p4] );

	assert len(ee) ==  2;
	length = 0;
	for e in ee:
		ew = Wrappers.Edge(e);
		length += ew.distanceBetweenEnds();
		TestDisplay.display.showShape(e);

	assert length == 2.0;
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:26,代码来源:edgegraph3__old.py

示例2: copyToZ

    def copyToZ(self, z):
        "makes a copy of this slice, transformed to the specified z height"
        theCopy = Slice()
        theCopy.zLevel = z
        theCopy.zHeight = self.zHeight
        theCopy.sliceHeight = self.sliceHeight
        theCopy.fillWidth = self.fillWidth
        theCopy.hatchDir = self.hatchDir
        theCopy.checkSum = self.checkSum

        # make transformation
        p1 = gp.gp_Pnt(0, 0, 0)
        p2 = gp.gp_Pnt(0, 0, z)
        xform = gp.gp_Trsf()
        xform.SetTranslation(p1, p2)
        bt = BRepBuilderAPI.BRepBuilderAPI_Transform(xform)

        # copy all of the faces
        for f in hSeqIterator(self.faces):
            bt.Perform(f, True)
            theCopy.addFace(Wrappers.cast(bt.Shape()))

            # copy all of the fillWires
        for w in hSeqIterator(self.fillWires):
            bt.Perform(w, True)
            # TestDisplay.display.showShape(bt.Shape() );
            theCopy.fillWires.Append(Wrappers.cast(bt.Shape()))

            # copy all of the fillEdges
        for e in hSeqIterator(self.fillEdges):
            bt.Perform(e, True)
            # TestDisplay.display.showShape(bt.Shape() );
            theCopy.fillEdges.Append(Wrappers.cast(bt.Shape()))

        return theCopy
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:35,代码来源:OccSliceLib.py

示例3: testSplitWire2

def testSplitWire2():
	"intersections on different edges. one edge completely inside"
	
	e1 = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(0,0,0),gp.gp_Pnt(2,0,0));
	e2 = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(2,0,0),gp.gp_Pnt(5,0,0));
	e3 = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(5,0,0),gp.gp_Pnt(6,0,0));
	
	
	#trick here. after building a wire, the edges change identity.
	#evidently, BRepBuilder_MakeWire makes copies of the underliying edges.
	
	w = Wrappers.wireFromEdges([e1,e2,e3]);
	ee = Wrappers.Wire(w).edgesAsList();
	print "Original Edges: %d %d %d " % ( hashE(ee[0]),hashE(ee[1]),hashE(ee[2]));
	p1 = PointOnAnEdge(ee[0],1.0,gp.gp_Pnt(1.0,0,0));
	p2 = PointOnAnEdge(ee[2],0.5,gp.gp_Pnt(5.0,0,0));
	
	
	ee = splitWire(w,[p2,p1]);
	
	assert len(ee) == 3;
	
	length = 0;
	for e in ee:
		ew = Wrappers.Edge(e);
		length += ew.distanceBetweenEnds();
		TestDisplay.display.showShape(e);
	print "length=%0.3f" % length;
	assert length == 4.5;
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:29,代码来源:edgegraph3__old.py

示例4: scanlinesFromBoundingBox

def scanlinesFromBoundingBox(boundingBox,interval):
	(xMin,yMin,zMin,xMax,yMax,zMax) = boundingBox;
	print boundingBox;
	edges = [];
	for y in Wrappers.frange6(yMin,yMax,interval):
		e = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(xMin,y,0),gp.gp_Pnt(xMax,y,0));
		#TestDisplay.display.showShape(e);
		edges.append((y,Wrappers.wireFromEdges([e])));
	return edges;
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:9,代码来源:pixMapFromWire.py

示例5: makeHeartWire

def makeHeartWire():
	"make a heart wire"
	e1 = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(0,0,0), gp.gp_Pnt(4.0,4.0,0));
	circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(2,4,0),gp.gp().DZ()),2);
	e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle, gp.gp_Pnt(4,4,0),gp.gp_Pnt(0,4,0)).Edge();
	circle = gp.gp_Circ(gp.gp_Ax2(gp.gp_Pnt(-2,4,0),gp.gp().DZ()),2);
	e3 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(circle, gp.gp_Pnt(0,4,0),gp.gp_Pnt(-4,4,0)).Edge();
	e4 = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(-4,4,0), gp.gp_Pnt(0,0,0));
	return Wrappers.wireFromEdges([e1,e2,e3,e4]);
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:9,代码来源:pixMapFromWire.py

示例6: squareWire

def squareWire(centerPt,w ):
	"makes a square wire with center at the desired point"
	w2 = w/2.0;
	p1 = gp.gp_Pnt(centerPt.X() - w2,centerPt.Y() -w2 , centerPt.Z() )
	p2 = gp.gp_Pnt(centerPt.X() - w2,centerPt.Y() +w2, centerPt.Z() )
	p3 = gp.gp_Pnt(centerPt.X() + w2,centerPt.Y() +w2, centerPt.Z() )
	p4 = gp.gp_Pnt(centerPt.X() + w2,centerPt.Y() -w2, centerPt.Z() )
	e1 = Wrappers.edgeFromTwoPoints(p1,p4);
	e2 = Wrappers.edgeFromTwoPoints(p4,p3);
	e3 = Wrappers.edgeFromTwoPoints(p3,p2);
	e4 = Wrappers.edgeFromTwoPoints(p2,p1);
	return Wrappers.wireFromEdges([e1,e2,e3,e4] );
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:12,代码来源:solidoffset.py

示例7: makeHexArray

	def makeHexArray(self,bottomLeftCenter, countX, countY ):
		"""
			makes an array of hexagons
			bottomLeftCenter is the center of the top left hex, as a three-element tuple
			countX is the number of hexes in the x direction
			countY is the number of hexes in the y direction
			returns a list of wires representing a hexagon fill pattern
		"""
		pattern = self.makePeriodic(bottomLeftCenter);
		wireBuilder = BRepBuilderAPI.BRepBuilderAPI_MakeWire(pattern);

		#make horizontal array
		tsf = gp.gp_Trsf();
		pDist = 2.0 * self.cartesianSpacing()[0];
		tsf.SetTranslation(gp.gp_Pnt(0,0,0),gp.gp_Pnt(pDist ,0,0));
		tx = BRepBuilderAPI.BRepBuilderAPI_Transform(tsf);
		currentShape = pattern;
		for i in range(1,int((countX/2)+1)):
			tx.Perform(currentShape,False);
			currentShape = tx.Shape();
			#display.DisplayShape(currentShape);
			wireBuilder.Add(Wrappers.cast(currentShape));

		#create an array by alternately offsetting one cell right and 
		#moving down
		topHalf = wireBuilder.Wire();		
		#topHalf= approximatedWire(topHalf);
		
		wires=[];
		wires.append(topHalf);
		dY = self.cartesianSpacing()[1]/2.0;
		dX = self.cartesianSpacing()[0];
		
		####TODO// performance note.  This method takes about 31ms to compute 1000x1000 hex.
		# pretty good, except that nearly 50% of the time is spent in makeTransform!!!
		# a much better method would be to use the same transform object somehow
		for i in range(1,int(countY*2)):
			if i % 2 == 0:
				t = makeTransform(0,dY*i,0);
			else:
				t = makeTransform(dX,dY*i,0);
			t.Perform(topHalf,False);
			w = Wrappers.cast(t.Shape());
			
			#approximate the wire
			#wires.append ( approximatedWire(w));
			wires.append( w);
		
		#display.DisplayShape(wires);
		return wires;
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:50,代码来源:hexagonlib.py

示例8: testWirePixmap2

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,代码行数:30,代码来源:pixMapFromWire.py

示例9: addWire

	def addWire(self,wire,type):
		"add all the edges of a wire. They will be connected together."
		"type is the node type for each edge"
		
		#for finding an edge node
		wr = Wrappers.Wire(wire);
		self.edgeSeq = wr.edgesAsSequence();
		firstNode = None;
		lastNode = None;
		last = None;
		for i in range(1,self.edgeSeq.Length()+1):

			edge = Wrappers.cast(self.edgeSeq.Value(i));
			te = Wrappers.Edge(edge);			
			newnode = EdgeNode(te,type);
			self.addNode(newnode);
			
			if last:
				self.linkPrev( newnode,last);
				self.linkNext(last,newnode );
				
			last = newnode;

			if i == 1:
				firstNode = newnode;
			if i == self.edgeSeq.Length():
				lastNode = newnode;

		#link last and first edge if the wire is closed
		if wire.Closed():
			self.linkPrev( firstNode,lastNode);
			self.linkNext( lastNode,firstNode);			
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:32,代码来源:edgegraph2.py

示例10: displayPixelGrid

def displayPixelGrid(pixelGrid):
	"show all the points in a pixel grid"
	l = [];
	for k in pixelGrid.keys():
		l.append(Wrappers.make_vertex(gp.gp_Pnt(k[0],k[1],0.00)));
		
	display.DisplayShape(l);
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:7,代码来源:OccSliceLib2.py

示例11: divideEdge

	def divideEdge(self,edge,param):
		"""
			split the edge at the provided parameter,
			creating two new edge nodes.
			update internal structures accordingly.
		"""
		original = self.findEdge(edge,param);
		
		if original == None:
			raise ValueError,"Could not find edge having parameter %0.3f" % (param);
			
		#param must be between the bounds on the original edge
		assert param >= original.p1 and param <= original.p2;
		
		#compute nodes on either end.
		n1 = tP(original.firstPoint);
		n2 = tP(original.lastPoint);
		
		#add new node and edges
		n3 = tP( Wrappers.pointAtParameter(edge,param));
		newNode1 = EdgeSegment(edge,original.p1,param,original.type);
		newNode2 = EdgeSegment(edge,param,original.p2, original.type );

		
		self.addEdgeSegment(newNode1);
		self.addEdgeSegment(newNode2);
		
		#delete the original
		self.removeEdge(original);
				
		return [newNode1,newNode2];
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:31,代码来源:edgegraph3__old.py

示例12: makeFillEdges2d

def makeFillEdges2d(xMin, yMin, xMax, yMax, spacing):
    "make straight hatch lines."
    edges = []
    for y in Wrappers.frange6(yMin, yMax, spacing):
        e = edgeFromTwoPoints((xMin, y), (xMax, y))
        # TestDisplay.display.showShape(e);
        edges.append(e)
    return edges
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:8,代码来源:test2dStuff.py

示例13: addBoundaryWire

	def addBoundaryWire(self,wire):
		#for finding an edge node
		wr = Wrappers.Wire(wire);
		eS = wr.edgesAsSequence();

		for i in range(1,eS.Length()+1):
			e = Wrappers.cast(eS.Value(i));
			self.addSingleBoundaryEdge(e);	
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:8,代码来源:edgegraph4.py

示例14: buildGraph

	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,代码行数:17,代码来源:edgegraph4.py

示例15: displayGraph

def displayGraph(graph):
	"display an networkx graph"
	"this is just a hack-- the tuples are in integer coordinates, and this will be terribly slow"
	
	for e in graph.edges_iter():
		try:
			TestDisplay.display.showShape(Wrappers.edgeFromTwoPoints(pnt(e[0]),pnt(e[1])));
		except:
			pass;
开发者ID:adam-urbanczyk,项目名称:emcfab,代码行数:9,代码来源:pixMapFromWire.py


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