Shapeworks Studio  2.1
Shape analysis software suite
List of all members | Public Member Functions | Public Attributes | Protected Member Functions
FEMeshSmoothingModifier Class Reference

#include <FEMeshSmoothingModifier.h>

Public Member Functions

 FEMeshSmoothingModifier ()
 Constructor.
 
FEMeshApply (FEMesh *pm)
 Apply the smoothing modifier. More...
 

Public Attributes

double m_threshold1
 
double m_threshold2
 
double m_iteration
 
int m_method
 

Protected Member Functions

double area_triangle (vec3d r[3])
 
double distance (vec3d x, vec3d y)
 
double random ()
 
void Laplacian_Smoothing (FEMesh *pm, vector< int > hashmap)
 
void Laplacian_Smoothing2 (FEMesh *pm, vector< int > hashmap)
 
void Taubin_Smoothing (FEMesh *pm, vector< int > hashmap)
 
void Crease_Enhancing_Diffusion (FEMesh *pm, vector< int > hashmap)
 
void Add_Noise (FEMesh *pm, vector< int > hashmap)
 

Detailed Description

This class implements a modifier that coarses a plygonal mesh using an approximated centroidal voronoi diagram.

Definition at line 9 of file FEMeshSmoothingModifier.h.

Member Function Documentation

FEMesh * FEMeshSmoothingModifier::Apply ( FEMesh pm)

Apply the smoothing modifier.

Create the decimate mesh.

Todo:
This implementation will only work with closed surfaces.

Definition at line 25 of file FEMeshSmoothingModifier.cpp.

26 {
27  if (pm == NULL) {
28  throw std::runtime_error("FEMesher failed.");
29  }
30  // make sure this is a triangle mesh
31  if (pm->IsType(FE_TRI3) == false) {
32  throw std::runtime_error("FEMesher failed.");
33  }
34 
35  // make a copy of this mesh
36  FEMesh* pnew = new FEMesh(*pm);
37 
38  //marking the edge nodes.
39  vector<int> hashmap;
40  hashmap.reserve(pm->Nodes());
41  for (int i = 0 ; i< pm->Nodes();i++)
42  hashmap.push_back(0);
43  for (int i =0;i<pm->Edges();++i)
44  {
45  FEEdge& ed = pm->Edge(i);
46  hashmap[ed.n[0]] = -1;
47  hashmap[ed.n[1]] = -1;
48  }
49  switch(m_method)
50  {
51  case 0:
52  Laplacian_Smoothing(pnew,hashmap);
53  break;
54  case 1:
55  Laplacian_Smoothing2(pnew,hashmap);
56  break;
57  case 2:
58  Taubin_Smoothing(pnew,hashmap);
59  break;
60  case 3:
61  Crease_Enhancing_Diffusion(pnew,hashmap);
62  break;
63  case 4:
64  Add_Noise(pnew,hashmap);
65  break;
66  default:
67  break;
68  }
69  FEAutoMesher mesher;
70  mesher.BuildMesh(pnew);
71  return pnew;
72 }
int n[MAX_NODES]
edge nodes
Definition: FEElement.h:92
Definition: FEMesh.h:57
bool IsType(int ntype)
check the type of the mesh
Definition: FECoreMesh.cpp:17

The documentation for this class was generated from the following files: