Exemple #1
0
 def test_iges_write_modified_tolerance(self):
     iges_handler = IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     outfilename = 'tests/test_datasets/test_pipe_out.iges'
     iges_handler.write(mesh_points, outfilename, 1e-3)
     self.assertEqual(iges_handler.outfile, outfilename)
     self.addCleanup(os.remove, outfilename)
Exemple #2
0
 def test_iges_write_shape_to_file_igs(self):
     ihp = BRepPrimAPI_MakeBox(1., 1., 1.).Shape()
     path = 'tests/test_datasets/x.igs'
     iges_handler = IgesHandler()
     iges_handler.write_shape_to_file(ihp, path)
     self.assertTrue(os.path.exists(path))
     self.addCleanup(os.remove, path)
Exemple #3
0
    def test_iges_write_comparison_igs(self):
        iges_handler = IgesHandler()
        mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.igs')
        mesh_points[0][0] = 2.2
        mesh_points[5][1] = 4.3
        mesh_points[9][2] = 0.5
        mesh_points[12][0] = 7.2
        mesh_points[16][1] = -1.2
        mesh_points[31][2] = -3.6

        outfilename = 'tests/test_datasets/test_pipe_out.igs'
        outfilename_expected = 'tests/test_datasets/test_pipe_out_true.igs'

        iges_handler.write(mesh_points, outfilename)

        mesh_points = iges_handler.parse(outfilename)
        mesh_points_expected = iges_handler.parse(outfilename_expected)
        np.testing.assert_array_almost_equal(mesh_points, mesh_points_expected)
        self.addCleanup(os.remove, outfilename)
Exemple #4
0
 def test_iges_parse_control_point_position_member(self):
     iges_handler = IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     self.assertListEqual(iges_handler._control_point_position,
                          [0, 6, 12, 18, 24, 28, 32])
Exemple #5
0
 def test_iges_parse_infile(self):
     iges_handler = IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     self.assertEqual(iges_handler.infile,
                      'tests/test_datasets/test_pipe.iges')
Exemple #6
0
 def test_iges_parse_failing_check_extension(self):
     iges_handler = IgesHandler()
     with self.assertRaises(ValueError):
         mesh_points = iges_handler.parse(
             'tests/test_datasets/test_pipe.vtk')
Exemple #7
0
 def test_iges_instantiation(self):
     iges_handler = IgesHandler()
Exemple #8
0
 def test_iges_write_failing_check_extension(self):
     iges_handler = IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     with self.assertRaises(ValueError):
         iges_handler.write(mesh_points,
                            'tests/test_datasets/test_square.stl')
Exemple #9
0
 def test_iges_parse_coords_5_igs(self):
     iges_handler = IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.igs')
     np.testing.assert_almost_equal(mesh_points[-1][2], 10000.0)
Exemple #10
0
 def test_iges_parse_failing_filename_type(self):
     iges_handler = IgesHandler()
     with self.assertRaises(TypeError):
         mesh_points = iges_handler.parse(5.2)
Exemple #11
0
 def test_iges_load_shape_from_file_raises_wrong_type(self):
     iges_handler = IgesHandler()
     with self.assertRaises(TypeError):
         iges_handler.load_shape_from_file(None)
Exemple #12
0
 def test_iges_ihow_failing_outfile_type(self):
     iges_handler = IgesHandler()
     with self.assertRaises(TypeError):
         iges_handler.show(ihow_file=1.1)
Exemple #13
0
 def test_iges_plot_failing_outfile_type(self):
     iges_handler = IgesHandler()
     with self.assertRaises(TypeError):
         iges_handler.plot(plot_file=3)
Exemple #14
0
 def test_iges_plot_save_fig(self):
     iges_handler = IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     iges_handler.plot(save_fig=True)
     self.assertTrue(os.path.isfile('tests/test_datasets/test_pipe.png'))
     self.addCleanup(os.remove, 'tests/test_datasets/test_pipe.png')
Exemple #15
0
 def test_iges_default_extension_member(self):
     iges_handler = IgesHandler()
     self.assertListEqual(iges_handler.extensions, ['.iges', '.igs'])
Exemple #16
0
 def test_iges_parse_shape_igs(self):
     iges_handler = IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.igs')
     self.assertTupleEqual(mesh_points.shape, (32, 3))
Exemple #17
0
 def test_iges_parse_coords_2(self):
     iges_handler = IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     np.testing.assert_almost_equal(mesh_points[8][1], 999.99999997448208)
Exemple #18
0
 def test_iges_load_shape_correct_igs(self):
     iges_handler = IgesHandler()
     shape = iges_handler.load_shape_from_file(
         'tests/test_datasets/test_pipe.igs')
     self.assertEqual(type(topods_Compound(shape)), TopoDS_Compound)
Exemple #19
0
 def test_iges_write_failing_filename_type(self):
     iges_handler = IgesHandler()
     mesh_points = iges_handler.parse('tests/test_datasets/test_pipe.iges')
     with self.assertRaises(TypeError):
         iges_handler.write(mesh_points, -2)
Exemple #20
0
 def test_iges_write_shape_to_file_raises_wrong_type(self):
     iges_handler = IgesHandler()
     with self.assertRaises(TypeError):
         iges_handler.write_shape_to_file(None, None)
Exemple #21
0
 def test_iges_write_failing_infile_instantiation(self):
     iges_handler = IgesHandler()
     mesh_points = np.zeros((20, 3))
     with self.assertRaises(RuntimeError):
         iges_handler.write(mesh_points,
                            'tests/test_datasets/test_pipe_out.iges')
Exemple #22
0
 def test_iges_write_shape_to_file_raises_wrong_extension(self):
     iges_handler = IgesHandler()
     with self.assertRaises(ValueError):
         iges_handler.load_shape_from_file('tests/test_datasets/x.stp')