示例#1
0
def splitPerfTest():
	"make a long wire of lots of edges"
	"""
		performance of the wire split routine is surprisingly bad!
		
	"""
	
	WIDTH=0.1
	edges = [];

		
	
	#trick here. after building a wire, the edges change identity.
	#evidently, BRepBuilder_MakeWire makes copies of the underliying edges.
	h = hexagonlib.Hexagon(2.0,0 );
	wirelist = h.makeHexForBoundingBox((0,0,0), (100,100,0));
	w = wirelist[0];
	ee = Wrappers.Wire(w).edgesAsList();
	TestDisplay.display.showShape(w);
	#compute two intersections
	e1 = Wrappers.Edge(ee[5]);
	e2 = Wrappers.Edge(ee[55]);
	e1p = (e1.lastParameter - e1.firstParameter )/ 2;
	e2p = (e2.lastParameter - e2.firstParameter )/ 2;
	p1 = PointOnAnEdge(e1.edge,e1p ,e1.pointAtParameter(e1p));
	p2 = PointOnAnEdge(e2.edge,e2p ,e2.pointAtParameter(e2p));
	TestDisplay.display.showShape( Wrappers.make_vertex(p1.point));
	TestDisplay.display.showShape( Wrappers.make_vertex(p2.point));
	#cProfile.runctx('for i in range(1,20): ee=splitWire(w,[p2,p1])', globals(), locals(), filename="slicer.prof")
	#p = pstats.Stats('slicer.prof')
	#p.sort_stats('cum')
	#p.print_stats(.98);		

	t = Wrappers.Timer();
	ee = [];
	for i in range(1,1000):
		ee = splitWire(w,[p2,p1]);
		assert len(ee) == 1;
	
	print "Elapsed for 1000splits:",t.finishedString();
示例#2
0
def splitPerfTest():
	"make a long wire of lots of edges"
	"""
		performance of the wire split routine is surprisingly bad!
		
	"""
	
	WIDTH=0.1
	edges = [];
	for i in range(1,50):
		e = Wrappers.edgeFromTwoPoints(gp.gp_Pnt(i*WIDTH,0,0),gp.gp_Pnt((i+1)*WIDTH,0,0))
		TestDisplay.display.showShape(e);
		edges.append(e);
		
	
	#trick here. after building a wire, the edges change identity.
	#evidently, BRepBuilder_MakeWire makes copies of the underliying edges.
	
	w = Wrappers.wireFromEdges(edges);
	ee = Wrappers.Wire(w).edgesAsList();
	
	#compute two intersections
	e1 = Wrappers.Edge(ee[5]);
	e2 = Wrappers.Edge(ee[30]);
	e1p = (e1.lastParameter - e1.firstParameter )/ 2;
	e2p = (e2.lastParameter - e2.firstParameter )/ 2;
	p1 = PointOnAnEdge(e1.edge,e1p ,e1.pointAtParameter(e1p));
	p2 = PointOnAnEdge(e2.edge,e2p ,e2.pointAtParameter(e2p));
	
	#cProfile.runctx('for i in range(1,100): ee=splitWire(w,[p2,p1])', globals(), locals(), filename="slicer.prof")
	#p = pstats.Stats('slicer.prof')
	#p.sort_stats('time')
	#p.print_stats(.98);		

	t = Wrappers.Timer();
	for i in range(1,100):
		ee = splitWire(w,[p2,p1]);
	print "Elapsed for 100 splits:",t.finishedString();
示例#3
0
    print "******************************"
    print " HatchLib Unit Tests...."
    print "******************************"
    #w = TestDisplay.makeSquareWire(); #box around 0,0 <--> 5,5
    #w2=TestDisplay.makeCircleWire(); #circle centered at 2,2, radius 1
    #h = Hatcher([w,w2],0.0,( 0,0,5.0,5.0) );
    gc.disable()
    w = makeHeartWire()
    w2 = makeCircleWire()
    h = Hatcher([w, w2], 0.0, (-6, 0, 10.0, 10.0))

    #display.DisplayShape(w);
    #display.DisplayShape(w2);

    #runProfiled('h.hatch()',0.9);
    t = Wrappers.Timer()
    h.hatch()
    g = h.graphBuilder.graph
    #debugGraph(g)
    #h.hatch2();
    print "Hatching Finished", t.finishedString()
    #print "There are %d fill edges" % len(h.graph.fillEdges)

    if False:
        for e in g.edges_iter(data=True):
            displayEdgeFromGraph(e[2])

    if False:
        for e in h.graphBuilder.fillEdges:
            edge = g.get_edge_data(e[0], e[1])
            displayEdgeFromGraph(edge, True)