VMTK
vtkvmtkPolyDataSurfaceRemeshing.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: VMTK
4  Module: $RCSfile: vtkvmtkPolyDataSurfaceRemeshing.h,v $
5  Language: C++
6 
7  Copyright (c) Luca Antiga, David Steinman. All rights reserved.
8  See LICENSE file for details.
9 
10  Portions of this code are covered under the VTK copyright.
11  See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
12  for details.
13 
14  This software is distributed WITHOUT ANY WARRANTY; without even
15  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
16  PURPOSE. See the above copyright notices for more information.
17 
18 =========================================================================*/
28 #ifndef __vtkvmtkPolyDataSurfaceRemeshing_h
29 #define __vtkvmtkPolyDataSurfaceRemeshing_h
30 
31 #include "vtkObject.h"
32 #include "vtkPolyDataAlgorithm.h"
33 #include "vtkvmtkWin32Header.h"
34 #include "vtkIdList.h"
35 
36 class vtkCellLocator;
37 class vtkIntArray;
38 
39 class VTK_VMTK_DIFFERENTIAL_GEOMETRY_EXPORT vtkvmtkPolyDataSurfaceRemeshing : public vtkPolyDataAlgorithm
40 {
41 public:
42 
43  static vtkvmtkPolyDataSurfaceRemeshing *New();
44  vtkTypeMacro(vtkvmtkPolyDataSurfaceRemeshing,vtkPolyDataAlgorithm);
45  void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
46 
47  vtkSetMacro(AspectRatioThreshold,double);
48  vtkGetMacro(AspectRatioThreshold,double);
49 
50  vtkSetMacro(InternalAngleTolerance,double);
51  vtkGetMacro(InternalAngleTolerance,double);
52 
53  vtkSetMacro(NormalAngleTolerance,double);
54  vtkGetMacro(NormalAngleTolerance,double);
55 
56  vtkSetMacro(CollapseAngleThreshold,double);
57  vtkGetMacro(CollapseAngleThreshold,double);
58 
59  vtkSetMacro(Relaxation,double);
60  vtkGetMacro(Relaxation,double);
61 
62  vtkSetMacro(TargetArea,double);
63  vtkGetMacro(TargetArea,double);
64 
65  vtkSetMacro(TargetAreaFactor,double);
66  vtkGetMacro(TargetAreaFactor,double);
67 
68  vtkSetMacro(TriangleSplitFactor,double);
69  vtkGetMacro(TriangleSplitFactor,double);
70 
71  vtkSetMacro(MinAreaFactor,double);
72  vtkGetMacro(MinAreaFactor,double);
73 
74  vtkSetMacro(MaxArea,double);
75  vtkGetMacro(MaxArea,double);
76 
77  vtkSetMacro(MinArea,double);
78  vtkGetMacro(MinArea,double);
79 
80  vtkSetMacro(NumberOfIterations,int);
81  vtkGetMacro(NumberOfIterations,int);
82 
83  vtkSetMacro(NumberOfConnectivityOptimizationIterations,int);
84  vtkGetMacro(NumberOfConnectivityOptimizationIterations,int);
85 
86  vtkSetStringMacro(TargetAreaArrayName);
87  vtkGetStringMacro(TargetAreaArrayName);
88 
89  vtkSetMacro(ElementSizeMode,int);
90  vtkGetMacro(ElementSizeMode,int);
92  { this->SetElementSizeMode(TARGET_AREA); }
94  { this->SetElementSizeMode(TARGET_AREA_ARRAY); }
95 
96  vtkSetMacro(PreserveBoundaryEdges,int);
97  vtkGetMacro(PreserveBoundaryEdges,int);
98  vtkBooleanMacro(PreserveBoundaryEdges,int);
99 
100  vtkSetStringMacro(CellEntityIdsArrayName);
101  vtkGetStringMacro(CellEntityIdsArrayName);
102 
103  vtkSetObjectMacro(ExcludedEntityIds,vtkIdList);
104  vtkGetObjectMacro(ExcludedEntityIds,vtkIdList);
105 
106  //BTX
107  enum {
108  SUCCESS = 0,
116  TRIANGLE_LOCKED
117  };
118 
119  enum {
121  DO_NOTHING
122  };
123 
124  enum {
126  TARGET_AREA_ARRAY
127  };
128 
129  enum {
131  RELOCATE_FAILURE
132  };
133 
134  enum {
137  NO_NEIGHBORS
138  };
139  //ETX
140 
141 protected:
144 
145  virtual int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
146 
147  void BuildEntityBoundary(vtkPolyData* input, vtkPolyData* entityBoundary);
148 
149  int EdgeFlipConnectivityOptimizationIteration();
150  int EdgeFlipIteration();
151  int EdgeCollapseIteration();
152  int TriangleSplitIteration();
153  int EdgeSplitIteration();
154  int PointRelocationIteration(bool projectToSurface=true);
155 
156  int TestFlipEdgeValidity(vtkIdType pt1, vtkIdType pt2, vtkIdType cell1, vtkIdType cell2, vtkIdType pt3, vtkIdType pt4);
157  int TestConnectivityFlipEdge(vtkIdType pt1, vtkIdType pt2);
158  int TestDelaunayFlipEdge(vtkIdType pt1, vtkIdType pt2);
159  int TestAspectRatioCollapseEdge(vtkIdType cellId, vtkIdType& pt1, vtkIdType& pt2);
160  int TestTriangleSplit(vtkIdType cellId);
161  int TestAreaSplitEdge(vtkIdType cellId, vtkIdType& pt1, vtkIdType& pt2);
162 
163  int IsElementExcluded(vtkIdType cellId);
164  int GetEdgeCellsAndOppositeEdge(vtkIdType pt1, vtkIdType pt2, vtkIdType& cell1, vtkIdType& cell2, vtkIdType& pt3, vtkIdType& pt4);
165 
166  int SplitEdge(vtkIdType pt1, vtkIdType pt2);
167  int CollapseEdge(vtkIdType pt1, vtkIdType pt2);
168  int FlipEdge(vtkIdType pt1, vtkIdType pt2);
169 
170  int SplitTriangle(vtkIdType cellId);
171  int CollapseTriangle(vtkIdType cellId);
172 
173  int RelocatePoint(vtkIdType pointId, bool projectToSurface);
174 
175  int IsPointOnBoundary(vtkIdType pointId);
176  int IsPointOnEntityBoundary(vtkIdType pointId);
177 
178  int GetNumberOfBoundaryEdges(vtkIdType cellId);
179 
180  double ComputeTriangleTargetArea(vtkIdType cellId);
181 
182  int FindOneRingNeighbors(vtkIdType pointId, vtkIdList* neighborIds);
183 
184  vtkPolyData* Mesh;
185  vtkPolyData* InputBoundary;
186  vtkPolyData* InputEntityBoundary;
187  vtkCellLocator* Locator;
188  vtkCellLocator* BoundaryLocator;
189  vtkCellLocator* EntityBoundaryLocator;
190  vtkIntArray* CellEntityIdsArray;
191  vtkDataArray* TargetAreaArray;
192  vtkIdList* ExcludedEntityIds;
193 
198  double Relaxation;
201 
203 
205  double TargetArea;
207  double MaxArea;
208  double MinArea;
212 
214 
215 private:
217  void operator=(const vtkvmtkPolyDataSurfaceRemeshing&); // Not implemented.
218 };
219 
220 #endif
221 
remesh a surface using quality triangles.