def testDivideWire():
	w = TestDisplay.makeCircleWire();
	#w = TestDisplay.makeSquareWire();
	#w = TestDisplay.makeReversedWire();
	
	wr = Wrappers.Wire(w);
	
	eg = EdgeGraph();
	eg.addWire(w,'BOUND');
	print eg.edges
	
	#the big test-- split one of the edges
	e = eg.firstNode().edge;

	[newEdge1,newEdge2] = eg.divideEdge(e,2.5);
	print eg.edges
	e2 = newEdge2.edge;
	[newEdge3,newEdge4] = eg.divideEdge(e2,0.2333 );

	for en in eg.allEdgesRandomOrder():
		time.sleep(.1);
		e = en.newEdge();
		TestDisplay.display.showShape( TestDisplay.makeEdgeIndicator(e) );
		TestDisplay.display.showShape(e );	
Exemple #2
0
def testDivideWire():
	w = TestDisplay.makeCircleWire();
	#w = TestDisplay.makeSquareWire();
	#w = TestDisplay.makeReversedWire();
	
	wr = Wrappers.Wire(w);
	
	eg = EdgeGraph();
	eg.addWire(w,'BOUND');
	print eg.edges
	
	#the big test-- split one of the edges
	e = eg.firstNode().edge;

	[newEdge1,newEdge2] = eg.divideEdge(e,2.5);
	print eg.edges
	e2 = newEdge2.edge;
	[newEdge3,newEdge4] = eg.divideEdge(e2,0.2333 );

	for en in eg.allEdgesRandomOrder():
		time.sleep(.1);
		e = en.newEdge();
		TestDisplay.display.showShape( TestDisplay.makeEdgeIndicator(e) );
		TestDisplay.display.showShape(e );	
Exemple #3
0
    startNode = graph.firstNode()
    yield startNode
    nD = startNode.next
    while len(nD) > 0:
        nextNode = nD.values()[0]
        if nextNode == startNode:
            return
        yield nextNode
        nD = nextNode.next

    return


if __name__ == '__main__':
    print "Basic Wrappers and Utilities Module"
    w = TestDisplay.makeCircleWire()
    w = TestDisplay.makeSquareWire()
    w = TestDisplay.makeReversedWire()

    eg = EdgeGraph()
    eg.addWire(w, 'BOUND')

    #the big test-- split one of the edges
    e = eg.firstNode().edge
    newNode = eg.divideEdge(e, 2.5)

    e2 = newNode.edge
    newNode2 = eg.divideEdge(e2, 0.2333)

    for en in followForwardGenerator(eg):
        time.sleep(1)
		if refVal != None and theVal != None:			
			#if  abs(refVal - theVal) <= self.options.machineResolution:
			if abs(refVal - theVal ) <= 0.000001:
				return None;
		
		return theVal;

	def comment(self,txt):
		return self.options.commentFormat  % txt;
		
if __name__=='__main__':

	###Logging Configuration
	logging.basicConfig(level=logging.WARN,
						format='%(asctime)s [%(funcName)s] %(levelname)s %(message)s',
						stream=sys.stdout)	
						
	w1 = TestDisplay.makeSquareWire();
	w2 = TestDisplay.makeCircleWire();
	w3 = TestDisplay.makeReversedWire();
	TestDisplay.display.showShape([w1,w2,w3]);
	o = SlicerConfig.GcodeOptions();
	o.setDefaults();
	o.computeExtraAxis=False;
	ge = GcodeExporter(o );
	#ge.useArcs = False;
	for line in ge.gcode([w1,w2,w3]):
		print line,;

		
	TestDisplay.display.run();
Exemple #5
0
        for edge in self.edges2():
            ew = Edge(edge)
            s.append(str(ew))
        return "\n".join(s)

    def discretePoints(self, deflection):
        "discrete points for all of a wire"
        for e in self.edges():
            for m in Edge(e).discretePoints(deflection):
                yield m


if __name__ == '__main__':
    print "Basic Wrappers and Utilities Module"

    w = TestDisplay.makeSquareWire()

    el = EdgeLinkedList(w)

    #TestDisplay.display.showShape(w);
    #TestDisplay.display.showShape(el.first().edge);
    #TestDisplay.display.showShape(el.last().edge);

    #for e in el.nodesForward():
    #	TestDisplay.display.showShape(e.edge);

    for e in el.nodesBackward():
        TestDisplay.display.showShape(e.edge)

    TestDisplay.display.run()
Exemple #6
0
        if nextNode == startNode:
            return
        yield nextNode
        nD = nextNode.next

    return


def tP(point):
    "return a tuple for a point"
    return (point.X(), point.Y(), point.Z())


if __name__ == '__main__':
    print "Basic Wrappers and Utilities Module"
    w = TestDisplay.makeCircleWire()
    w = TestDisplay.makeSquareWire()
    #w = TestDisplay.makeReversedWire();

    wr = Wrappers.Wire(w)

    g = networkx.Graph()

    for e in wr.edges():
        ew = Wrappers.Edge(e)
        g.add_edge(tP(ew.firstPoint), tP(ew.lastPoint), {'ew': ew})
        TestDisplay.display.showShape(e)

    #print g.nodes();
    #print g.edges();
    print g.get_edge_data((5.0, 0.0, 0.0), (5.0, 5.0, 0.0))
Exemple #7
0
            #if  abs(refVal - theVal) <= self.options.machineResolution:
            if abs(refVal - theVal) <= 0.000001:
                return None

        return theVal

    def comment(self, txt):
        return self.options.commentFormat % txt


if __name__ == '__main__':

    ###Logging Configuration
    logging.basicConfig(
        level=logging.WARN,
        format='%(asctime)s [%(funcName)s] %(levelname)s %(message)s',
        stream=sys.stdout)

    w1 = TestDisplay.makeSquareWire()
    w2 = TestDisplay.makeCircleWire()
    w3 = TestDisplay.makeReversedWire()
    TestDisplay.display.showShape([w1, w2, w3])
    o = SlicerConfig.GcodeOptions()
    o.setDefaults()
    o.computeExtraAxis = False
    ge = GcodeExporter(o)
    #ge.useArcs = False;
    for line in ge.gcode([w1, w2, w3]):
        print line,

    TestDisplay.display.run()
Exemple #8
0
		for edge in self.edges2():
			ew = Edge(edge);
			s.append( str(ew) );
		return "\n".join(s);
		
		
	def discretePoints(self,deflection):
		"discrete points for all of a wire"
		for e in self.edges():
			for m in Edge(e).discretePoints(deflection):
				yield m;
		
if __name__=='__main__':
	print "Basic Wrappers and Utilities Module"

	w = TestDisplay.makeSquareWire();
	
	el = EdgeLinkedList(w);

	#TestDisplay.display.showShape(w);
	#TestDisplay.display.showShape(el.first().edge);
	#TestDisplay.display.showShape(el.last().edge);
	
	#for e in el.nodesForward():
	#	TestDisplay.display.showShape(e.edge);
	
	for e in el.nodesBackward():
		TestDisplay.display.showShape(e.edge);
		
	TestDisplay.display.run();
	
from OCC import TopoDS
from OCC import TColStd

import Wrappers
import TestDisplay

def listFromArray( stdArray ):
	results= []
	for i in range(stdArray.Lower(),stdArray.Upper() ):
		results.append(stdArray.Value(i));
	return results;

if __name__=='__main__':
	
	#make test wire, which has two edges
	[testWire,circleEdge,lineEdge] = TestDisplay.makeKeyHoleWire();
	testWire2 = TestDisplay.makeSquareWire();
	
	if testWire2.Closed():
		print "testWire2 is closed";
	else:
		print "testWire2 is not closed.";
	TOLERANCE = 0.00001;
	curve  = BRepAdaptor.BRepAdaptor_CompCurve (testWire);
	
	print "CompCurve is parameterized between %0.5f and %0.5f " % (  curve.FirstParameter(), curve.LastParameter() );
	print "%d Continuity" % curve.Continuity();
	print "%d Intervals(C0)" % curve.NbIntervals(0);
	print "%d Intervals(C1)" % curve.NbIntervals(1);
	print "%d Intervals(C2)" % curve.NbIntervals(2);
	print "%d Intervals(C3)" % curve.NbIntervals(3);
Exemple #10
0
		if nextNode == startNode:
			return;
		yield nextNode;
		nD = nextNode.next;

	return;


def tP(point):
	"return a tuple for a point"
	return (point.X(), point.Y(), point.Z() );


if __name__=='__main__':
	print "Basic Wrappers and Utilities Module"
	w = TestDisplay.makeCircleWire();
	w = TestDisplay.makeSquareWire();
	#w = TestDisplay.makeReversedWire();
	
	wr = Wrappers.Wire(w);

	g = networkx.Graph();
	
	for e in wr.edges():
		ew = Wrappers.Edge(e);
		g.add_edge(tP(ew.firstPoint),tP(ew.lastPoint),{'ew':ew});
		TestDisplay.display.showShape(e);
	
	#print g.nodes();
	#print g.edges();
	print g.get_edge_data((5.0,0.0,0.0),(5.0,5.0,0.0));
Exemple #11
0
    # DrawTo 3,2.2
    assert testMoves([edge1, edge2, edge3]) == 3, "There should be Thee Moves"
    print "[OK]"

    print "Disconnected Edges"
    #the correct answer is:
    #  MoveTo 0,0
    #  Lineto 1,1
    #  MoveTo 2,2
    #  LineTo 3,2.2
    assert testMoves([edge1, edge3]) == 4, "Should be four moves"
    print "[OK]"

    print "Arcs And Lines"
    wire = makeTestWire()
    #the correct answer is:
    #  Moveto 40,50
    #  ArcTo  50,40 with center 40,40, ccw direction
    #  LineTo 80,40
    assert testMoves([wire]) == 3, "Should be 3 moves?"
    print "[OK]"

    print "Arcs and Lines-- No Arcs"
    # should MoveTo 40,50
    # draw to 50,40 in a lot of little moves
    # draw to 80,40 in one move
    assert testMoves([wire], False) > 10, "Should be lots of moves"

    print "Square Wire"
    assert testMoves([TestDisplay.makeSquareWire()], False) > 3
Exemple #12
0
import Wrappers
import TestDisplay


def listFromArray(stdArray):
    results = []
    for i in range(stdArray.Lower(), stdArray.Upper()):
        results.append(stdArray.Value(i))
    return results


if __name__ == '__main__':

    #make test wire, which has two edges
    [testWire, circleEdge, lineEdge] = TestDisplay.makeKeyHoleWire()
    testWire2 = TestDisplay.makeSquareWire()

    if testWire2.Closed():
        print "testWire2 is closed"
    else:
        print "testWire2 is not closed."
    TOLERANCE = 0.00001
    curve = BRepAdaptor.BRepAdaptor_CompCurve(testWire)

    print "CompCurve is parameterized between %0.5f and %0.5f " % (
        curve.FirstParameter(), curve.LastParameter())
    print "%d Continuity" % curve.Continuity()
    print "%d Intervals(C0)" % curve.NbIntervals(0)
    print "%d Intervals(C1)" % curve.NbIntervals(1)
    print "%d Intervals(C2)" % curve.NbIntervals(2)
Exemple #13
0
	# DrawTo 3,2.2
	assert testMoves([edge1,edge2,edge3]) == 3,"There should be Thee Moves"
	print "[OK]"
	
	print "Disconnected Edges"
	#the correct answer is:
	#  MoveTo 0,0
	#  Lineto 1,1
	#  MoveTo 2,2
	#  LineTo 3,2.2
	assert testMoves([edge1,edge3]) == 4,"Should be four moves"
	print "[OK]"
	
	print "Arcs And Lines"
	wire = makeTestWire();
	#the correct answer is:
	#  Moveto 40,50
	#  ArcTo  50,40 with center 40,40, ccw direction
	#  LineTo 80,40
	assert testMoves([wire]) == 3,"Should be 3 moves?"
	print "[OK]"
	
	print "Arcs and Lines-- No Arcs"
	# should MoveTo 40,50
	# draw to 50,40 in a lot of little moves
	# draw to 80,40 in one move
	assert testMoves([wire],False) > 10,"Should be lots of moves"
	
	print "Square Wire"
	assert testMoves([TestDisplay.makeSquareWire()],False) > 3;
	
Exemple #14
0
	nD = startNode.next;
	while  len(nD) > 0:
		nextNode = nD.values()[0];
		if nextNode == startNode:
			return;
		yield nextNode;
		nD = nextNode.next;

	return;


	

if __name__=='__main__':
	print "Basic Wrappers and Utilities Module"
	w = TestDisplay.makeCircleWire();
	w = TestDisplay.makeSquareWire();
	w = TestDisplay.makeReversedWire();
	
	eg = EdgeGraph();
	eg.addWire(w,'BOUND');

	#the big test-- split one of the edges
	e = eg.firstNode().edge;
	newNode = eg.divideEdge(e,2.5);

	e2 = newNode.edge;
	newNode2 = eg.divideEdge(e2,0.2333 );
	
	for en in followForwardGenerator(eg):
		time.sleep(1);