Ejemplo n.º 1
0
    def repair(self, verbose=False, joincomp=False,
               remove_smallest_components=True):
        """Performs mesh repair using MeshFix's default repair
        process.

        Parameters
        ----------
        verbose : bool, optional
            Enables or disables debug printing.  Disabled by default.

        joincomp : bool, optional
            Attempts to join nearby open components.

        remove_smallest_components : bool, optional
            Remove all but the largest isolated component from the
            mesh before beginning the repair process.  Default True

        Notes
        -----
        Vertex and face arrays are updated inplace.  Access them with:
        meshfix.v
        meshfix.f
        """
        assert self.f.shape[1] == 3, 'Face array must contain three columns'
        assert self.f.ndim == 2, 'Face array must be 2D'
        self.v, self.f = _meshfix.clean_from_arrays(self.v, self.f,
                                                    verbose, joincomp,
                                                    remove_smallest_components)
Ejemplo n.º 2
0
    def fix_mesh(self, wiggle_vertices=False, verbose=False):
        """ Executes rudimentary fixing function from pymeshfix

        Good for closing holes

        :param wiggle_vertices: bool
            adds robustness for smaller components
        :param verbose: bool
        """
        if self.body_count > 1:
            tin = _meshfix.PyTMesh(verbose)
            # tin.LoadArray(self.vertices, self.faces)
            tin.load_array(self.vertices, self.faces)
            tin.remove_smallest_components()
            # tin.RemoveSmallestComponents()

            # Check if volume is 0 after isolated components have been removed
            # self.vertices, self.faces = tin.ReturnArrays()
            self.vertices, self.faces = tin.return_arrays()

            self.fix_normals()

        if self.volume == 0:
            return

        if wiggle_vertices:
            wiggle = np.random.randn(self.n_vertices * 3).reshape(-1, 3) * 10
            self.vertices += wiggle

        # self.vertices, self.faces = _meshfix.CleanFromVF(self.vertices,
        #                                                  self.faces,
        #                                                  verbose=verbose)
        self.vertices, self.faces = _meshfix.clean_from_arrays(
            self.vertices, self.faces, verbose=verbose)

        self.fix_normals()