VMTK
Loading...
Searching...
No Matches
vtkvmtkPolyDataManifoldStencil.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkPolyDataManifoldStencil.cxx,v $
5 Language: C++
6 Date: $Date: 2005/11/15 17:39:25 $
7 Version: $Revision: 1.4 $
8
9 Copyright (c) Luca Antiga, David Steinman. All rights reserved.
10 See LICENSE file for details.
11
12 Portions of this code are covered under the VTK copyright.
13 See VTKCopyright.txt or http://www.kitware.com/VTKCopyright.htm
14 for details.
15
16 This software is distributed WITHOUT ANY WARRANTY; without even
17 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
18 PURPOSE. See the above copyright notices for more information.
19
20=========================================================================*/
21
25
26#include "vtkObjectFactory.h"
27#include "vtkIdList.h"
28#include "vtkCell.h"
29#include "vtkvmtkMath.h"
30#include "vtkMath.h"
31
32
33
40
42 {
43 double point[3], point1[3], point2[3];
44 vtkIdType j, numberOfTriangles;
45
46 if (this->DataSet==NULL)
47 {
48 vtkErrorMacro(<<"No DataSet specified.");
49 return;
50 }
51
52 this->DataSet->GetPoint(this->DataSetPointId,point);
53 this->Area = 0.0;
54
55 if (!this->IsBoundary)
56 {
57 numberOfTriangles = this->NPoints;
58 }
59 else
60 {
61 numberOfTriangles = this->NPoints-1;
62 }
63
64 for (j=0; j<numberOfTriangles; j++)
65 {
66 this->DataSet->GetPoint(this->PointIds[j],point1);
67 this->DataSet->GetPoint(this->PointIds[(j+1)%this->NPoints],point2);
68
69 this->Area += vtkvmtkMath::TriangleArea(point2,point,point1);
70 }
71 }
72
74 {
75 double scale;
76
77 if (this->Area<VTK_VMTK_DOUBLE_TOL)
78 {
79 scale = 2.0*VTK_VMTK_LARGE_DOUBLE;
80 }
81 else
82 {
83 scale = 1.0 / (this->Area * factor);
84 }
85
86 this->ScaleWeights(scale);
87 }
88
89
91 {
92 if (this->PointIds && this->Weights && !this->ReallocateOnBuild)
93 {
94 return;
95 }
96
97 vtkIdType i;
98 vtkvmtkPolyDataManifoldNeighborhood *manifoldNeighborhood;
99
100 if (this->UseExtendedNeighborhood)
101 {
103 }
104 else
105 {
106 manifoldNeighborhood = vtkvmtkPolyDataManifoldNeighborhood::New();
107 }
108 manifoldNeighborhood->SetDataSet(this->DataSet);
109 manifoldNeighborhood->SetDataSetPointId(this->DataSetPointId);
110 manifoldNeighborhood->Build();
111
112 this->NPoints = manifoldNeighborhood->GetNumberOfPoints();
113 if (this->PointIds!=NULL)
114 {
115 delete[] this->PointIds;
116 this->PointIds = NULL;
117 }
118 this->PointIds = new vtkIdType[this->NPoints];
119 memcpy(this->PointIds,manifoldNeighborhood->GetPointer(0),this->NPoints*sizeof(vtkIdType));
120
121 this->IsBoundary = manifoldNeighborhood->GetIsBoundary();
122
123 if (this->Weights!=NULL)
124 {
125 delete[] this->Weights;
126 this->Weights = NULL;
127 }
128 this->Weights = new double[this->NumberOfComponents*this->NPoints];
129 for (i=0; i<this->NumberOfComponents*this->NPoints; i++)
130 {
131 this->Weights[i] = 0.0;
132 }
133 this->CenterWeight = new double[this->NumberOfComponents];
134 for (i=0; i<this->NumberOfComponents; i++)
135 {
136 this->CenterWeight[i] = 0.0;
137 }
138
139 manifoldNeighborhood->Delete();
140 }
141
virtual void SetDataSetPointId(vtkIdType)
void SetDataSet(vtkDataSet *dataSet)
static double TriangleArea(double point0[3], double point1[3], double point2[3])
vtkIdType * GetPointer(vtkIdType i)
virtual bool GetIsBoundary()
static vtkvmtkPolyDataManifoldExtendedNeighborhood * New()
Apply a neighborhood to the points of a manifold surface.
static vtkvmtkPolyDataManifoldNeighborhood * New()
void DeepCopy(vtkvmtkPolyDataManifoldStencil *src)
virtual void DeepCopy(vtkvmtkItem *src) override
vtkIdType NumberOfComponents
double * CenterWeight
void ScaleWeights(double factor)
#define VTK_VMTK_DOUBLE_TOL
#define VTK_VMTK_LARGE_DOUBLE