Exemplo n.º 1
0
def _surface_mapping(brep0, brep1, line_mapping):
    surface_mapping = basic.BijectiveMappinguuid()
    for surface0 in brep0.surfaces():
        surface_lines0 = brep0.boundary_lines(surface0)
        found = True
        for surface_line0 in surface_lines0:
            if not line_mapping.has_mapping_output(surface_line0.id()):
                found = False
                break
        if not found:
            continue
        for surface1 in brep1.surfaces():
            done = True
            for line1 in brep1.boundary_lines(surface1):
                found = False
                for surface_line0 in surface_lines0:
                    if line_mapping.out2in(surface_line0.id()).string(
                    ) == line1.id().string():
                        found = True
                        break
                if not found:
                    done = False
                    break
            if done:
                surface_mapping.map(surface1.id(), surface0.id())
                break
    return surface_mapping
Exemplo n.º 2
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)
Exemplo n.º 3
0
def _corner_mapping(brep0, brep1):
    corner_mapping = basic.BijectiveMappinguuid()
    for corner0 in brep0.corners():
        for corner1 in brep1.corners():
            if corner0.mesh().point(0).inexact_equal(corner1.mesh().point(0),
                                                     1e-8):
                corner_mapping.map(corner1.id(), corner0.id())
                break
    return corner_mapping
Exemplo n.º 4
0
def _line_mapping(brep0, brep1, corner_mapping):
    line_mapping = basic.BijectiveMappinguuid()
    for line0 in brep0.lines():
        line_corners0 = brep0.boundary_corners(line0)
        if not corner_mapping.has_mapping_output(line_corners0[0].id(
        )) or not corner_mapping.has_mapping_output(line_corners0[1].id()):
            continue
        for line1 in brep1.lines():
            found = True
            for corner1 in brep1.boundary_corners(line1):
                if corner_mapping.out2in(line_corners0[0].id()).string(
                ) != corner1.id().string() and corner_mapping.out2in(
                        line_corners0[1].id()).string() != corner1.id().string(
                        ):
                    found = False
                    break
            if found:
                line_mapping.map(line1.id(), line0.id())
                break
    return line_mapping