Example #1
0
    def test_sgrp_90plus(self):
        line_coords = array.array('d', [0, 0, -1, 0, -1, 0.01])
        line_indices = array.array('I', [0, 1, 2, 0])
        g = pstalgo.CreateSegmentGraph(line_coords, line_indices, None)
        self.doTest(g, 2, 100, False, [0, 1], [0, 1])
        self.doTest(g, 2, 180, False, [0, 0], [0, 0])
        self.doTest(g, 2, 100, True, [0, 1], [0, 1])
        self.doTest(g, 2, 180, True, [0, 0], [0, 0])
        pstalgo.FreeSegmentGraph(g)

        line_coords = array.array('d', [0, 0, -1, 0, -1, 0.01, 1, 1])
        line_indices = array.array('I', [0, 1, 2, 0, 0, 3])
        g = pstalgo.CreateSegmentGraph(line_coords, line_indices, None)
        self.doTest(g, 3, 90, False, [0, 1, 0], [0, 1, 0])
        pstalgo.FreeSegmentGraph(g)
Example #2
0
 def test_createsegmentgraph(self):
     line_coords = array.array('d', [0, 0, 1, 0])
     line_indices = array.array('I', [0, 1])
     segment_graph_handle = pstalgo.CreateSegmentGraph(
         line_coords, line_indices, None)
     self.assertIsNotNone(segment_graph_handle)
     pstalgo.FreeSegmentGraph(segment_graph_handle)
Example #3
0
def CreateCrosshairSegmentGraph():
	#  ___
	# |_|_|
	# |_|_|
	#
	line_coords = array.array('d', [-1, -1, 0, -1, 1, -1, 1, 0, 1, 1, 0, 1, -1, 1, -1, 0, 0, 0])
	line_indices = array.array('I', [0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 0, 3, 8, 8, 7, 1, 8, 8, 5])
	graph_handle = pstalgo.CreateSegmentGraph(line_coords, line_indices, None)
	return graph_handle
Example #4
0
 def create_split_graph2(self):
     # _/\_ where bottom path is shorter
     #  \/
     line_coords = array.array('d',
                               [-2, 0, -1, 0, 0, 0.1, 0, 0, 1, 0, 2, 0])
     line_indices = array.array('I', [0, 1, 1, 2, 2, 4, 1, 3, 3, 4, 4, 5])
     graph_handle = pstalgo.CreateSegmentGraph(line_coords, line_indices,
                                               None)
     self.assertIsNotNone(graph_handle)
     return graph_handle
Example #5
0
def CreateSegmentChainGraph(line_count, line_length):
	line_coords = []	
	for x in range(line_count+1): 
		line_coords.append(x*line_length)
		line_coords.append(0)
	line_indices = []	
	for i in range(line_count): 
		line_indices.append(i)
		line_indices.append(i+1)
	line_coords = array.array('d', line_coords)
	line_indices = array.array('I', line_indices)
	graph_handle = pstalgo.CreateSegmentGraph(line_coords, line_indices, None)
	return graph_handle
Example #6
0
 def create_chain_graph(self, line_count, line_length=1):
     # --...--
     line_coords = []
     for x in range(line_count + 1):
         line_coords.append(x * line_length)
         line_coords.append(0)
     line_indices = []
     for i in range(line_count):
         line_indices.append(i)
         line_indices.append(i + 1)
     line_coords = array.array('d', line_coords)
     line_indices = array.array('I', line_indices)
     graph_handle = pstalgo.CreateSegmentGraph(line_coords, line_indices,
                                               None)
     self.assertIsNotNone(graph_handle)
     return graph_handle
Example #7
0
def CreateSegmentSquareGraph(line_length):
	line_coords = array.array('d', [0, 0, line_length, 0, line_length, line_length, 0, line_length])
	line_indices = array.array('I', [0, 1, 1, 2, 2, 3, 3, 0])
	graph_handle = pstalgo.CreateSegmentGraph(line_coords, line_indices, None)
	return graph_handle