def run_test_brep(): brep = model.BRep() test_dir = os.path.dirname(__file__) data_dir = os.path.abspath(os.path.join(test_dir, "../../../../tests/data")) model.load_brep(brep, os.path.join(data_dir, "test_v5.og_brep")) model.convert_brep_surface_meshes_into_triangulated_surfaces(brep) model.convert_brep_block_meshes_into_tetrahedral_solids(brep) file_io = "test_triangulated_surfaces." + brep.native_extension() model.save_brep(brep, file_io) brep2 = model.BRep() model.load_brep(brep2, file_io)
def test_clone(brep): brep2 = model.BRep() builder = model.BRepBuilder(brep2) builder.copy(brep) if brep2.nb_corners() != 6: raise ValueError("[Test] BRep should have 6 corners") if brep2.nb_lines() != 9: raise ValueError("[Test] BRep should have 9 lines") if brep2.nb_surfaces() != 5: raise ValueError("[Test] BRep should have 5 surfaces") if brep2.nb_blocks() != 1: raise ValueError("[Test] BRep should have 1 block") if brep2.nb_model_boundaries() != 3: raise ValueError("[Test] BRep should have 3 model boundaries")
def create_cube(x_min, y_min, z_min, x_max, y_max, z_max): cube = model.BRep() builder = model.BRepBuilder(cube) point0 = geometry.Point3D([x_min, y_min, z_min]) point1 = geometry.Point3D([x_max, y_min, z_min]) point2 = geometry.Point3D([x_min, y_max, z_min]) point3 = geometry.Point3D([x_max, y_max, z_min]) point4 = geometry.Point3D([x_min, y_min, z_max]) point5 = geometry.Point3D([x_max, y_min, z_max]) point6 = geometry.Point3D([x_min, y_max, z_max]) point7 = geometry.Point3D([x_max, y_max, z_max]) corner0 = _create_corner(cube, builder, point0) corner1 = _create_corner(cube, builder, point1) corner2 = _create_corner(cube, builder, point2) corner3 = _create_corner(cube, builder, point3) corner4 = _create_corner(cube, builder, point4) corner5 = _create_corner(cube, builder, point5) corner6 = _create_corner(cube, builder, point6) corner7 = _create_corner(cube, builder, point7) line0 = _create_line(cube, builder, corner0, corner1) line1 = _create_line(cube, builder, corner1, corner3) line2 = _create_line(cube, builder, corner3, corner2) line3 = _create_line(cube, builder, corner2, corner0) line4 = _create_line(cube, builder, corner4, corner5) line5 = _create_line(cube, builder, corner5, corner7) line6 = _create_line(cube, builder, corner7, corner6) line7 = _create_line(cube, builder, corner6, corner4) line8 = _create_line(cube, builder, corner0, corner4) line9 = _create_line(cube, builder, corner1, corner5) line10 = _create_line(cube, builder, corner2, corner6) line11 = _create_line(cube, builder, corner3, corner7) bottom = _create_surface(cube, builder, [corner0, corner1, corner3, corner2], [line0, line1, line2, line3]) top = _create_surface(cube, builder, [corner4, corner5, corner7, corner6], [line4, line5, line6, line7]) front = _create_surface(cube, builder, [corner0, corner1, corner5, corner4], [line0, line9, line4, line8]) back = _create_surface(cube, builder, [corner2, corner3, corner7, corner6], [line2, line11, line6, line10]) left = _create_surface(cube, builder, [corner0, corner4, corner6, corner2], [line8, line7, line10, line3]) right = _create_surface(cube, builder, [corner1, corner5, corner7, corner3], [line9, line5, line11, line1]) block = _create_block(cube, builder, [bottom, top, front, back, left, right]) return cube
builder = model.BRepBuilder(brep2) builder.copy(brep) if brep2.nb_corners() != 6: raise ValueError("[Test] BRep should have 6 corners") if brep2.nb_lines() != 9: raise ValueError("[Test] BRep should have 9 lines") if brep2.nb_surfaces() != 5: raise ValueError("[Test] BRep should have 5 surfaces") if brep2.nb_blocks() != 1: raise ValueError("[Test] BRep should have 1 block") if brep2.nb_model_boundaries() != 3: raise ValueError("[Test] BRep should have 3 model boundaries") if __name__ == '__main__': brep = model.BRep() builder = model.BRepBuilder(brep) # This BRep represents a prism corner_uuids = add_corners(brep, builder) line_uuids = add_lines(brep, builder) surface_uuids = add_surfaces(brep, builder) block_uuids = add_blocks(brep, builder) model_boundary_uuids = add_model_boundaries(brep, builder) add_corner_line_boundary_relation(brep, builder, corner_uuids, line_uuids) add_line_surface_boundary_relation(brep, builder, line_uuids, surface_uuids) add_surface_block_relation(brep, builder, surface_uuids, block_uuids) add_surfaces_in_model_boundaries(brep, builder, surface_uuids, model_boundary_uuids)