VMTK
Loading...
Searching...
No Matches
vtkvmtkPolyDataAreaWeightedUmbrellaStencil.cxx
Go to the documentation of this file.
1/*=========================================================================
2
3 Program: VMTK
4 Module: $RCSfile: vtkvmtkPolyDataAreaWeightedUmbrellaStencil.cxx,v $
5 Language: C++
6 Date: $Date: 2006/04/06 16:46:44 $
7 Version: $Revision: 1.2 $
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
23#include "vtkvmtkMath.h"
24#include "vtkMath.h"
25#include "vtkObjectFactory.h"
26
27
29
34
36{
37 this->Superclass::Build();
38
39 for (vtkIdType i=0; i<this->NPoints; i++)
40 {
41 this->Weights[i] = 1.0/double(this->NPoints);
42 }
43
44 vtkPolyData* pdata = vtkPolyData::SafeDownCast(this->DataSet);
45
46 int j;
47 for (j=0; j<this->NPoints; j++)
48 {
49 this->Weights[j] = 0.0;
50 }
51
52 double point[3], point1[3], point2[3];
53// double vector[3], vector1[3], vector2[3];
54// double dot = 0.0;
55
56 pdata->GetPoint(this->DataSetPointId,point);
57
58// for (j=0; j<this->NPoints; j++)
59// {
60// pdata->GetPoint(this->PointIds[j],point1);
61// pdata->GetPoint(this->PointIds[(j+1)%this->NPoints],point2);
62// vector[0] = point2[0] - point1[0];
63// vector[1] = point2[1] - point1[1];
64// vector[2] = point2[2] - point1[2];
65// vector1[0] = point1[0] - point[0];
66// vector1[1] = point1[1] - point[1];
67// vector1[2] = point1[2] - point[2];
68// vector2[0] = point2[0] - point[0];
69// vector2[1] = point2[1] - point[1];
70// vector2[2] = point2[2] - point[2];
71// vtkMath::Normalize(vector);
72// vtkMath::Normalize(vector1);
73// vtkMath::Normalize(vector2);
74// dot = vtkMath::Dot(vector,vector1);
75// this->Weights[j] += vtkMath::Distance2BetweenPoints(point,point1) * dot * sqrt(1.0 - dot*dot) / 2.0;
76// if (!(this->IsBoundary || j==this->NPoints-1))
77// {
78// dot = vtkMath::Dot(vector,vector2);
79// this->Weights[(j+1)%this->NPoints] += vtkMath::Distance2BetweenPoints(point,point2) * dot * sqrt(1.0 - dot*dot) / 2.0;
80// }
81 for (j=0; j<this->NPoints; j++)
82 {
83 pdata->GetPoint(this->PointIds[j],point1);
84 pdata->GetPoint(this->PointIds[(j+1)%this->NPoints],point2);
85 double area = vtkvmtkMath::TriangleArea(point,point1,point2);
86 if (!(this->IsBoundary || j==this->NPoints-1))
87 {
88 this->Weights[j] += area;
89 this->Weights[(j+1)%this->NPoints] += area;
90 }
91 }
92
93 this->CenterWeight[0] = 0.0;
94 for (j=0; j<this->NPoints; j++)
95 {
96 this->CenterWeight[0] += this->Weights[j];
97 }
98
99 this->Area = this->CenterWeight[0];
100
101 this->ScaleWithArea();
102
103 this->ChangeWeightSign();
104}
105
static double TriangleArea(double point0[3], double point1[3], double point2[3])
Apply umbrella (laplacian) weighting to the neighborhood connections of a surface.
double * CenterWeight
vtkStandardNewMacro(vtkvmtkPolyDataAreaWeightedUmbrellaStencil)