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

#include <FECVDDecimationModifier.h>

Public Member Functions

 FECVDDecimationModifier ()
 Constructor.
 
FEMeshApply (FEMesh *pm)
 Apply the decimation modifier. More...
 

Public Attributes

double m_pct
 percentage of target number of clusters/vertices
 
bool m_bcvd
 
double m_sel_pct
 
double m_gradient
 

Detailed Description

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

Definition at line 10 of file FECVDDecimationModifier.h.

Member Function Documentation

FEMesh * FECVDDecimationModifier::Apply ( FEMesh pm)

Apply the decimation modifier.

Create the decimate mesh.

Todo:
This implementation will only work with closed surfaces.

Definition at line 32 of file FECVDDecimationModifier.cpp.

33 {
34  // make sure this is a triangle mesh
35  if (pm->IsType(FE_TRI3) == false)
36  {
37  return 0;
38  }
39 
40  // do the initialization
41  if (Initialize(pm) == false) return 0;
42 
43  // Minimize energy
44  if (Minimize(pm) == false) return 0;
45 
46  // create the new mesh
47  // we can create either the clustered mesh or the final decimated mesh
48  FEMesh* pnew = 0;
49  if (m_bcvd)
50  {
51  // partition mesh based on cluster assingments
52  pnew = CalculateCVD(pm);
53  }
54  else
55  {
56  // triangulate the decimation
57  pnew = Triangulate2(pm);
58 
59  // make sure we have a mesh
60  if (pnew == 0) return 0;
61 
62  // next, we use the auto-mesher to reconstruct all faces, edges and nodes
63  FEAutoMesher mesher;
64  mesher.BuildMesh(pnew);
65 
66  //interpolating shell thickness
67  InterpolateShellThickness(pnew);
68 
69  // TODO: I noticed that this algorithm can create duplicate elements. I'm not sure yet if
70  // this is a bug or if there is something fishy about this algorithm. In any case,
71  // for now I will explicitly check for duplicate elements and remove duplicates. Even
72  // this may not fix all problems, since sometimes duplicate elements can have different
73  // winding.
74  // remove duplicate elements
75  pnew->RemoveDuplicateElements();
76  mesher.BuildMesh(pnew);
77 
78  // TODO: Another problem I found is that some elements become non-manifold, meaning that
79  // one or two edges don't have any neighbors. If the origianl mesh is closed, then
80  // the decimated mesh must be closed as well. (Off course, this assumes that the original
81  // mesh is closed. Perhaps I can find another criteria for non-manifold).
82  pnew->RemoveNonManifoldElements();
83  mesher.BuildMesh(pnew);
84 
85  // TODO: Some elements can be wound in the wrong direction. So, we try to find those elements
86  // and invert them.
87  pnew->FixElementWinding();
88  mesher.BuildMesh(pnew);
89 
90  // TODO: These operations can create holes in the mesh. therefore we fill all holes.
91  FEFillHole fill;
92  fill.FillAllHoles(pnew);
93  }
94 
95  // All done!
96  return pnew;
97 }
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: