Ejemplo n.º 1
0
    def pln_on_face(self, face=TopoDS_Face()):
        face_adaptor = BRepAdaptor_Surface(face)
        face_trf = face_adaptor.Trsf()
        face_pln = face_adaptor.Plane()
        #face_dir = face_adaptor.Direction()

        face_umin = face_adaptor.FirstUParameter()
        face_vmin = face_adaptor.FirstVParameter()
        face_umax = face_adaptor.LastUParameter()
        face_vmax = face_adaptor.LastVParameter()
        face_u = (face_umax + face_umin) / 2
        face_v = (face_vmax + face_vmin) / 2
        face_pnt = face_adaptor.Value(face_u, face_v)

        return face_pln
Ejemplo n.º 2
0
    def sample_interior(face_mesh):
        vertices, _, _, face = face_mesh

        additional_vertices = []

        surface = BRepAdaptor_Surface(face)
        FU = surface.FirstUParameter()
        LU = surface.LastUParameter()
        FV = surface.FirstVParameter()
        LV = surface.LastVParameter()

        U_LENGTH = LU - FU
        V_LENGTH = LV - FV

        if INTERIOR_SAMPLING_METHOD == INTERIOR_GRID:
            for u_index in range(1, GRID_U_SAMPLES + 1):
                for v_index in range(1, GRID_V_SAMPLES + 1):
                    u_offset = U_OFFSET_FACTOR / (GRID_U_SAMPLES + 1)
                    v_offset = V_OFFSET_FACTOR / (GRID_V_SAMPLES + 1)
                    u = FU + ((u_index /
                               (GRID_U_SAMPLES + 1)) + u_offset) * U_LENGTH
                    v = FV + ((v_index /
                               (GRID_V_SAMPLES + 1)) + v_offset) * V_LENGTH

                    sv_add = SuperVertex(u=u, v=v, same_as=vertices[0])
                    sv_add.project_to_XYZ()
                    additional_vertices.append(sv_add)
        elif INTERIOR_SAMPLING_METHOD == INTERIOR_RANDOM:
            for i in range(RANDOM_SAMPLES):
                rand0 = random.randint(
                    1, RANDOM_RESOLUTION - 1) / RANDOM_RESOLUTION
                rand1 = random.randint(
                    1, RANDOM_RESOLUTION - 1) / RANDOM_RESOLUTION
                u = FU + rand0 * U_LENGTH
                v = FV + rand1 * V_LENGTH

                sv_add = SuperVertex(u=u, v=v, same_as=vertices[0])
                sv_add.project_to_XYZ()
                additional_vertices.append(sv_add)
        else:
            raise Exception(
                'sample_interior() error - INTERIOR_SAMPLING_METHOD unknown')

        return additional_vertices