65{
66 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
67 vtkInformation *outInfo = outputVector->GetInformationObject(0);
68
69 vtkPolyData *input = vtkPolyData::SafeDownCast(
70 inInfo->Get(vtkDataObject::DATA_OBJECT()));
71 vtkPolyData *output = vtkPolyData::SafeDownCast(
72 outInfo->Get(vtkDataObject::DATA_OBJECT()));
73
75
76 int numberOfInputPoints = input->GetNumberOfPoints();
77 nb->SetNumberOfPoints(numberOfInputPoints);
78
79 double point[3];
80 real xpos[3];
81 int i;
82 for (i=0; i<numberOfInputPoints; i++)
83 {
84 input->GetPoint(i,point);
85 xpos[0] = static_cast<real>(point[0]);
86 xpos[1] = static_cast<real>(point[1]);
87 xpos[2] = static_cast<real>(point[2]);
88 nb->AddPoint(i,xpos[0],xpos[1],xpos[2]);
89 }
90
91 input->BuildCells();
92 int numberOfInputCells = input->GetNumberOfCells();
93 vtkIdType npts, *pts;
94 for (i=0; i<numberOfInputCells; i++)
95 {
96 if (input->GetCellType(i) != VTK_TRIANGLE)
97 {
98 continue;
99 }
100 input->GetCellPoints(i,npts,pts);
101 nb->AddTriangle(pts[0],pts[1],pts[2]);
102 }
103
104 try
105 {
106 nb->Run2D();
107 }
108 catch(Error *e)
109 {
110 e->Print(std::cerr);
111 }
112
113 nb->IterateOnOutput(false);
114
115 vtkPoints* outputPoints = vtkPoints::New();
116 vtkCellArray* outputCellArray = vtkCellArray::New();
117
118 while (nb->NextNode(xpos)!=-1)
119 {
120 point[0] = static_cast<double>(xpos[0]);
121 point[1] = static_cast<double>(xpos[1]);
122 point[2] = static_cast<double>(xpos[2]);
123 outputPoints->InsertNextPoint(point);
124 }
125
126 int icorn[3];
127 while (nb->NextCell(icorn))
128 {
129 outputCellArray->InsertNextCell(3,icorn);
130 }
131
132 output->SetPoints(outputPoints);
133 output->SetPolys(outputCellArray);
134
135 outputPoints->Delete();
136 outputCellArray->Delete();
137
138 delete nb;
139
140 return 1;
141}