Example #1
0
    def calcdne(self):
        """Method for calculating surface Dirichlet normal energy and populating instance variables."""
        # creation of dictionary of vertex keys and face values     
        self._get_vert_tri_dict()
        
        # optional implicit smooth of mesh
        if self.dosmooth == 1:
            self.Mesh = pcopy(self.Mesh)
            self.Mesh.vertices = implicitfair.smooth(self.Mesh.vertices, self.Mesh.faces, int(self.smoothit), float(self.smoothstep), self.vert_tri_dict)
            if self.Mesh.vertices == "!":
                print "Cholesky error"
                return "!"    

        # creation of array of vertices per edge
        self._get_edge_verts()
        # list of boundary faces
        self._get_boundary_faces()
        
        # arrays of normalized face normals and vertex normals approximated from adjacent faces
        self.vnormal, self.fnormal = normcore.computenormal(self.Mesh.vertices, self.Mesh.faces, self.Mesh.triverts, self.vert_tri_dict)
        # array of e(p) and face area for polygons across mesh
        
        self._energize_surface()
        
        self._sumdne()
Example #2
0
 def implicit_fair_mesh(self, iterations, step):
     self.get_vert_tri_dict()
     faired_vertices = implicitfair.smooth(self.vertices, self.faces, iterations, step, self.vert_tri_dict)
     self.vertices = faired_vertices
     self.mesh[0] = faired_vertices
     
     for i in range(len(self.triverts)):
         self.triverts[i] = self.vertices[self.faces[i]]
         
     self.mesh[1] = self.triverts
    def test_mesh_smooth(self):
        varray = array([[0.0, 0.0, 0.0],
                        [2.0, 0.0, 0.0],
                        [0.0, 2.0, 0.0],
                        [2.0, 2.0, 0.0],
                        [1.0, 1.0, 2.0]])
        farray = array([[0, 1, 2],
                        [1, 3, 2],
                        [0, 1, 4],
                        [1, 3, 4],
                        [2, 0, 4],
                        [3, 2, 4]])
        
        vfarray = {0: [0, 2, 4], 1: [0, 1, 2, 3], 2: [0, 1, 4, 5], 3: [1, 3, 5], 4: [2, 3, 4, 5]}

        solution_smoothed_vertices = array([[ 0.68411383,  0.68411383,  0.26803399],
                                            [ 1.31588617,  0.68411383,  0.26803399],
                                            [ 0.68411383,  1.31588617,  0.26803399],
                                            [ 1.31588617,  1.31588617,  0.26803399],
                                            [ 1.        ,  1.        ,  0.92786405]])
        
        test_smoothed_vertices = implicitfair.smooth(varray, farray, 3, 0.1, vfarray)
        
        self.assertTrue(allclose(test_smoothed_vertices, solution_smoothed_vertices), msg = "Reference pyramid mesh not smoothed as expected.")