def add_blocks(model, builder): nb = 1 uuids = [] for i in range(nb): uuids.append(builder.add_block()) builder.set_block_name(uuids[-1], "block" + str(len(uuids))) temp_block = model.block(builder.add_block()) builder.remove_block(temp_block) if model.nb_blocks() != nb: raise ValueError("[Test] BRep should have 1 blocks") if model.block(uuids[0]).name() != "block1": raise ValueError("[Test] Wrong Block name") return uuids
def add_internal_line_relations(model, builder, line_uuids, surface_uuids, block_uuids): for line_id in line_uuids: builder.add_line_surface_internal_relationship( model.line(line_id), model.surface(surface_uuids[0])) builder.add_line_block_internal_relationship( model.line(line_id), model.block(block_uuids[0])) for line_id in line_uuids: for embedding in model.embedding_surfaces_of_line(model.line(line_id)): if surface_uuids[0].string() != embedding.id().string(): raise ValueError( "[Test] All Line embedded surfaces should be Surfaces") if model.nb_internal_lines_of_surface(embedding) != len( line_uuids): raise ValueError("[Test] Surface should embed all Lines") for embedding in model.embedding_blocks_of_line(model.line(line_id)): if block_uuids[0].string() != embedding.id().string(): raise ValueError( "[Test] All Lines embedded blocks should be Blocks") if model.nb_internal_lines_of_block(embedding) != len(line_uuids): raise ValueError("[Test] Block should embed all Lines") if model.nb_embeddings(line_id) != 2: raise ValueError( "[Test] All Surfaces should be embedded to 1 Block and 1 Surface" ) if model.nb_embedding_surfaces_of_line(model.line(line_id)) != 1: raise ValueError( "[Test] All Surfaces should be embedded to 1 Surface") if model.nb_embedding_blocks_of_line(model.line(line_id)) != 1: raise ValueError( "[Test] All Surfaces should be embedded to 1 Block")
def test_boundary_ranges(model, corner_uuids, line_uuids, surface_uuids, block_uuids): line_boundary_count = 0 for line_boundary in model.boundary_corners(model.line(line_uuids[0])): line_boundary_count += 1 if line_boundary.id().string() != corner_uuids[0].string( ) and line_boundary.id().string() != corner_uuids[1].string(): raise ValueError( "[Test] BoundaryCornerRange iteration result is not correct") if not model.is_line_boundary(line_boundary, model.line( line_uuids[0])): raise ValueError("[Test] Corner should be boundary of Line") if line_boundary_count != 2: raise ValueError( "[Test] BoundaryCornerRange should iterates on 2 Corners") surface_boundary_count = 0 for surface_boundary in model.boundary_lines( model.surface(surface_uuids[0])): surface_boundary_count += 1 if surface_boundary.id().string() != line_uuids[0].string( ) and surface_boundary.id().string() != line_uuids[1].string( ) and surface_boundary.id().string() != line_uuids[2].string(): raise ValueError( "[Test] BoundaryLineRange iteration result is not correct") if not model.is_surface_boundary(surface_boundary, model.surface(surface_uuids[0])): raise ValueError("[Test] Line should be boundary of Surface") if surface_boundary_count != 3: raise ValueError("[Test] BoundaryLineRange should iterates on 3 Lines") block_boundary_count = 0 for block_boundary in model.boundary_surfaces(model.block(block_uuids[0])): block_boundary_count += 1 if block_boundary.id().string() != surface_uuids[0].string( ) and block_boundary.id().string() != surface_uuids[1].string( ) and block_boundary.id().string() != surface_uuids[2].string( ) and block_boundary.id().string() != surface_uuids[3].string( ) and block_boundary.id().string() != surface_uuids[4].string(): raise ValueError( "[Test] BoundarySurfaceRange iteration result is not correct") if not model.is_block_boundary(block_boundary, model.block(block_uuids[0])): raise ValueError("[Test] Surface should be boundary of Block") if block_boundary_count != 5: raise ValueError( "[Test] BoundarySurfaceRange should iterates on 5 Surfaces")
def add_surface_block_relation(model, builder, surface_uuids, block_uuids): for surface_id in surface_uuids: builder.add_surface_block_boundary_relationship( model.surface(surface_id), model.block(block_uuids[0])) for surface_id in surface_uuids: for incidence in model.incident_blocks(model.surface(surface_id)): if block_uuids[0].string() != incidence.id().string(): raise ValueError( "[Test] All Surfaces incidences should be Blocks") if model.nb_incidences(surface_id) != 1: raise ValueError( "[Test] All Surfaces should be connected to 1 Block") if model.nb_boundaries(block_uuids[0]) != len(surface_uuids): raise ValueError( "[Test] The Block should be connected to all Surfaces")
def add_internal_surface_relations(model, builder, surface_uuids, block_uuids): for surface_id in surface_uuids: builder.add_surface_block_internal_relationship( model.surface(surface_id), model.block(block_uuids[0])) for surface_id in surface_uuids: for embedding in model.embedding_blocks_of_surface( model.surface(surface_id)): if model.nb_internal_surfaces_of_block(embedding) != len( surface_uuids): raise ValueError("[Test] Block should embed all Surfaces") if block_uuids[0].string() != embedding.id().string(): raise ValueError( "[Test] All Surfaces embeddings should be Blocks") if model.nb_embeddings(surface_id) != 1: raise ValueError( "[Test] All Surfaces should be embedded to 1 Block") if model.nb_embedding_blocks_of_surface( model.surface(surface_id)) != 1: raise ValueError( "[Test] All Surfaces should be embedded to 1 Block")