Esempio n. 1
0
 def test_make_island_from_a_cube_with_cuts(self):
     jMesh = mesh.make_cube_mesh()
     viewer = mesh.MeshDisplayer(jMesh)
     viewer.displayEdgesIdx()
     cuts = [8, 0, 4, 10, 3, 11, 5]
     jMesh.set_cuts(cuts)
     viewer.display_edges(cuts)
     viewer.displayFacesIdx()
     self.islandMaker = make.IslandMaker(None, jMesh, 0)
     meshLoc = make.MeshLoc(face=1, edge=4)
     start_frame = trans.Frame.create_frame_from_tuples(
         (10, 0, 0), (1, 0, 0), (0, 1, 0))
     start_frame.show()
     island, visited_faces = self.islandMaker.make_island(
         meshLoc, start_frame)
     island.draw_all()
     correct_points = [
         geom.Point3d(15, 0, 0),  #0    
         geom.Point3d(10, 0, 0),  #1
         geom.Point3d(15, 5, 0),  #2 
         geom.Point3d(10, 5, 0),  #3 
         geom.Point3d(15, 10, 0),  #4
         geom.Point3d(10, 10, 0),  #5
         geom.Point3d(15, 15, 0),  #6
         geom.Point3d(10, 15, 0),  #7
         geom.Point3d(20, 10, 0),  #8
         geom.Point3d(20, 15, 0),  #9
         geom.Point3d(15, 20, 0),  #10
         geom.Point3d(10, 20, 0),  #11
         geom.Point3d(5, 15, 0),  #12
         geom.Point3d(5, 10, 0)  #13 ]
     ]
     island.has_same_points(correct_points)
     self.assertSetEqual(set(visited_faces), set(range(6)))
Esempio n. 2
0
 def test_get_mapped_point(self):
     fakeMesh = StubbedMesh()
     self.islandMaker.island = StubbedIsland()
     self.islandMaker.myMesh = fakeMesh
     point = fakeMesh.get_point()
     rs.AddPoint(point)
     meshLoc = make.MeshLoc(0, 1)
     islandLoc = make.IslandLoc(0, 0)
     mapped_point = self.islandMaker.get_mapped_point(
         point, meshLoc, islandLoc)
     rs.AddPoint(mapped_point)
     correct_point = geom.Point3d(-4.0, -4.0, 0.0)
     self.assertTrue(mapped_point.Equals(correct_point))
Esempio n. 3
0
 def test_layout_first_two_points(self):
     meshLoc = make.MeshLoc(face=0, edge=1)
     start_frame = trans.Frame.create_frame_from_tuples(
         (0, -10, 0), (1, 0, 0), (0, 1, 0))
     start_frame.show()
     self.islandMaker.spawn_island()
     self.islandMaker.layout_first_two_points(meshLoc, start_frame)
     pnt1_correct = geom.Point3d(0, -10, 0)
     pnt0_correct = geom.Point3d(5, -10, 0)
     self.islandMaker.island.draw_all()
     self.assertTrue(
         self.islandMaker.island.flatVerts[0].hasSamePoint(pnt0_correct))
     self.assertTrue(
         self.islandMaker.island.flatVerts[1].hasSamePoint(pnt1_correct))
Esempio n. 4
0
 def test_make_island(self):
     meshLoc = make.MeshLoc(face=0, edge=1)
     start_frame = trans.Frame.create_frame_from_tuples(
         (10, 0, 0), (1, 0, 0), (0, 1, 0))
     start_frame.show()
     self.islandMaker.make_island_no_cuts(meshLoc, start_frame)
     self.islandMaker.island.draw_all()
     island = self.islandMaker.island
     pnt0_correct = geom.Point3d(15, 0, 0)
     pnt1_correct = geom.Point3d(10, 0, 0)
     pnt2_correct = geom.Point3d(10, 5, 0)
     pnt3_correct = geom.Point3d(15, 5, 0)
     self.assertTrue(island.flatVerts[0].hasSamePoint(pnt0_correct))
     self.assertTrue(island.flatVerts[1].hasSamePoint(pnt1_correct))
     self.assertTrue(island.flatVerts[2].hasSamePoint(pnt2_correct))
     self.assertTrue(island.flatVerts[3].hasSamePoint(pnt3_correct))
Esempio n. 5
0
    def _test_make_island_cone(self):
        meshFile = "/TestMeshes/cone"
        myMesh = mesh.Mesh(meshLoad.load_mesh(meshFile))
        displayer = mesh.MeshDisplayer(myMesh)
        displayer.display_all_elements()
        face = 0
        edge = myMesh.getFaceEdges(face)[0]
        island_idx = 0
        self.islandMaker = make.IslandMaker(None, myMesh, island_idx)

        meshLoc = make.MeshLoc(face, edge)
        start_frame = trans.Frame.create_frame_from_tuples(
            (20, 0, 0), (1, 0, 0), (0, 1, 0))
        start_frame.show()
        island, visited_faces = self.islandMaker.make_island(
            meshLoc, start_frame)
        island.draw_all()
Esempio n. 6
0
 def test_unfolds_a_segment_of_cube(self):
     jMesh = mesh.make_cube_mesh()
     viewer = mesh.MeshDisplayer(jMesh)
     viewer.displayEdgesIdx()
     cuts = [3, 4, 10, 11, 6, 5]
     jMesh.set_cuts(cuts)
     viewer.display_edges(cuts)
     self.islandMaker = make.IslandMaker(None, jMesh, 0)
     meshLoc = make.MeshLoc(face=1, edge=4)
     island, visited_faces = self.islandMaker.make_island(meshLoc)
     island.draw_all()
     correct_points = [
         geom.Point3d(5, 0, 0),
         geom.Point3d(0, 0, 0),
         geom.Point3d(5, 5, 0),
         geom.Point3d(0, 5, 0),
         geom.Point3d(5, 10, 0),
         geom.Point3d(0, 10, 0)
     ]
     island.has_same_points(correct_points)
     self.assertEqual([1, 5], visited_faces)
Esempio n. 7
0
 def _get_meshLoc_next_to_cut_or_naked(self):
     canditate_faces = self.myMesh.get_set_of_face_idxs().difference(
         self.processed_faces)
     edge, face = self.myMesh.get_naked_or_cut_edge_from_candidate_faces(
         canditate_faces)
     return islandMaker.MeshLoc(face, edge)
Esempio n. 8
0
 def test_meshLoc_must_be_on_a_cutEdge_or_nakedEdge(self):
     meshLoc = make.MeshLoc(face=0, edge=2)
     cuts = [0]
     self.myMesh.set_cuts(cuts)
     self.assertRaises(AssertionError, self.islandMaker.make_island,
                       meshLoc)