Пример #1
0
def glue_model_surfaces(brep, brep1):
    builder = model.BRepBuilder(brep)
    corner_mapping, line_mapping, surface_mapping = _brep_mapping(brep, brep1)
    for corner in brep1.corners():
        if not corner_mapping.has_mapping_input(corner.id()):
            corner_id = _create_corner(brep, builder, corner.mesh().point(0))
            corner_mapping.map(corner.id(), corner_id)
    for line in brep1.lines():
        if not line_mapping.has_mapping_input(line.id()):
            line_corners = brep1.boundary_corners(line)
            line_id = _create_line(brep, builder,
                                   corner_mapping.in2out(line_corners[0].id()),
                                   corner_mapping.in2out(line_corners[1].id()))
            line_mapping.map(line.id(), line_id)
    for surface in brep1.surfaces():
        if not surface_mapping.has_mapping_input(surface.id()):
            mapped_corners = []
            for v in range(surface.mesh().nb_vertices()):
                corner_id = _corner_from_surface_vertex(brep1, surface, v)
                mapped_corners.append(corner_mapping.in2out(corner_id))
            mapped_lines = []
            for surface_line in brep1.boundary_lines(surface):
                mapped_lines.append(line_mapping.in2out(surface_line.id()))
            surface_id = _create_surface(brep, builder, mapped_corners,
                                         mapped_lines)
            surface_mapping.map(surface.id(), surface_id)
    block_mapping = basic.BijectiveMappinguuid()
    for block in brep1.blocks():
        mapped_surfaces = []
        for block_surface in brep1.boundary_surfaces(block):
            mapped_surfaces.append(surface_mapping.in2out(block_surface.id()))
        block_id = _create_block(brep, builder, mapped_surfaces)
        block_mapping.map(block.id(), block_id)
Пример #2
0
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")
Пример #3
0
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
Пример #4
0
    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)
    add_internal_corner_relations(brep, builder, corner_uuids, surface_uuids,