1 /*=========================================================================
2
3 Program: Visualization Toolkit
4 Module: otherCellPosition.cxx
5
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7 All rights reserved.
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
13
14 =========================================================================*/
15
16 // .NAME
17 // .SECTION Description
18 // this program tests the Cell Position and Location Boundary methods for each cell type
19
20 #include "vtkDebugLeaks.h"
21 #include "vtkHexahedron.h"
22 #include "vtkIdList.h"
23 #include "vtkLine.h"
24 #include "vtkPixel.h"
25 #include "vtkPoints.h"
26 #include "vtkPolyLine.h"
27 #include "vtkPolyVertex.h"
28 #include "vtkPolygon.h"
29 #include "vtkQuad.h"
30 #include "vtkTetra.h"
31 #include "vtkTriangle.h"
32 #include "vtkTriangleStrip.h"
33 #include "vtkVertex.h"
34 #include "vtkVoxel.h"
35 #include "vtkWedge.h"
36 #include "vtkPentagonalPrism.h"
37 #include "vtkHexagonalPrism.h"
38
39 #include <vtksys/ios/sstream>
40
TestOCP(ostream & strm)41 int TestOCP(ostream& strm)
42 {
43 // actual test
44 vtkIdList *ids = vtkIdList::New();
45 int j;
46 int n;
47 double dist2;
48 int subId;
49
50 strm << "Test vtkCell::EvaluatePosition Start" << endl;
51
52 //Vertex
53 vtkVertex *vertex = vtkVertex::New();
54 double vertexCoords[3], vertexWeights[2];
55 double vertexPoint[2][3] = {{10.0, 20.0, 30.0}, {0, 0, 0}};
56 double vertexClosest[3];
57
58 vertex->GetPointIds()->SetId(0,0);
59 vertex->GetPoints()->SetPoint (0, 10.0, 20.0, 30.0);
60
61 n = sizeof(vertexPoint) / (3 * sizeof(double));
62 for (j = 0; j < n; j++)
63 {
64 vertex->EvaluatePosition (&vertexPoint[j][0], &vertexClosest[0], subId, &vertexCoords[0], dist2, &vertexWeights[0]);
65 strm << "vtkVertex (" << vertexPoint[j][0] << ", " << vertexPoint[j][1] << ", " << vertexPoint[j][2] << ")" << endl;
66 strm << "\tclosest: " << vertexClosest[0] << ", " << vertexClosest[1] << ", " << vertexClosest[2] << endl;
67 strm << "\tcoords: " << vertexCoords[0] << endl;
68 strm << "\tweights: " << vertexWeights[0] << endl;
69 strm << "\tsubid: " << subId << endl;
70 strm << "\tdist2: " << dist2 << endl;
71 strm << endl;
72 }
73
74 //Poly Vertex
75 vtkPolyVertex *polyVertex = vtkPolyVertex::New();
76 double polyVertexCoords[1], polyVertexWeights[2];
77 double polyVertexPoint[3][3] = {{10.0, 20.0, 30.0}, {30.0, 20.0, 10.0}, {0, 0, 0}};
78 double polyVertexClosest[3];
79
80 polyVertex->GetPointIds()->SetNumberOfIds(2);
81 polyVertex->GetPointIds()->SetId(0,0);
82 polyVertex->GetPointIds()->SetId(1,1);
83
84 polyVertex->GetPoints()->SetNumberOfPoints(2);
85 polyVertex->GetPoints()->SetPoint (0, 10.0, 20.0, 30.0);
86 polyVertex->GetPoints()->SetPoint (1, 30.0, 20.0, 10.0);
87
88 n = sizeof(polyVertexPoint) / (3 * sizeof(double));
89 for (j = 0; j < n; j++)
90 {
91 polyVertex->EvaluatePosition (&polyVertexPoint[j][0], &polyVertexClosest[0], subId, &polyVertexCoords[0], dist2, &polyVertexWeights[0]);
92 strm << "vtkPolyVertex (" << polyVertexPoint[j][0] << ", " << polyVertexPoint[j][1] << ", " << polyVertexPoint[j][2] << ")" << endl;
93 strm << "\tclosest: " << polyVertexClosest[0] << ", " << polyVertexClosest[1] << ", " << polyVertexClosest[2] << endl;
94 strm << "\tcoords: " << polyVertexCoords[0] << endl;
95 strm << "\tweights: " << polyVertexWeights[0] << endl;
96 strm << "\tsubid: " << subId << endl;
97 strm << "\tdist2: " << dist2 << endl;
98 strm << endl;
99 }
100
101 //Line
102 vtkLine *line = vtkLine::New();
103 double lineCoords[3], lineWeights[2];
104 double linePoint[3][3] = {{10.0, 20.0, 30.0}, {30.0, 20.0, 10.0}, {0, 0, 0}};
105 double lineClosest[3];
106
107 line->GetPointIds()->SetId(0,0);
108 line->GetPointIds()->SetId(1,1);
109 line->GetPoints()->SetPoint (0, 10.0, 20.0, 30.0);
110 line->GetPoints()->SetPoint (1, 30.0, 20.0, 10.0);
111
112 n = sizeof(linePoint) / (3 * sizeof(double));
113 for (j = 0; j < n; j++)
114 {
115 line->EvaluatePosition (&linePoint[j][0], &lineClosest[0], subId, &lineCoords[0], dist2, &lineWeights[0]);
116 strm << "vtkLine (" << linePoint[j][0] << ", " << linePoint[j][1] << ", " << linePoint[j][2] << ")" << endl;
117 strm << "\tclosest: " << lineClosest[0] << ", " << lineClosest[1] << ", " << lineClosest[2] << endl;
118 strm << "\tcoords: " << lineCoords[0] << endl;
119 strm << "\tweights: " << lineWeights[0] << endl;
120 strm << "\tsubid: " << subId << endl;
121 strm << "\tdist2: " << dist2 << endl;
122 strm << endl;
123 }
124
125 //Poly Line
126 vtkPolyLine *polyLine = vtkPolyLine::New();
127 double polyLineCoords[3], polyLineWeights[3];
128 double polyLinePoint[4][3] = {{10.0, 20.0, 30.0}, {10.0, 30.0, 30.0}, {10.0, 30.0, 40.0}, {0, 0, 0}};
129 double polyLineClosest[3];
130
131 polyLine->GetPointIds()->SetNumberOfIds(3);
132 polyLine->GetPointIds()->SetId(0,0);
133 polyLine->GetPointIds()->SetId(1,1);
134 polyLine->GetPointIds()->SetId(2,2);
135
136 polyLine->GetPoints()->SetNumberOfPoints(3);
137 polyLine->GetPoints()->SetPoint (0, 10.0, 20.0, 30.0);
138 polyLine->GetPoints()->SetPoint (1, 10.0, 30.0, 30.0);
139 polyLine->GetPoints()->SetPoint (2, 10.0, 30.0, 40.0);
140
141 n = sizeof(polyLinePoint) / (3 * sizeof(double));
142 for (j = 0; j < n; j++)
143 {
144 polyLine->EvaluatePosition (&polyLinePoint[j][0], &polyLineClosest[0], subId, &polyLineCoords[0], dist2, &polyLineWeights[0]);
145 strm << "vtkPolyLine (" << polyLinePoint[j][0] << ", " << polyLinePoint[j][1] << ", " << polyLinePoint[j][2] << ")" << endl;
146 strm << "\tclosest: " << polyLineClosest[0] << ", " << polyLineClosest[1] << ", " << polyLineClosest[2] << endl;
147 strm << "\tcoords: " << polyLineCoords[0] << endl;
148 strm << "\tweights: " << polyLineWeights[0] << endl;
149 strm << "\tsubid: " << subId << endl;
150 strm << "\tdist2: " << dist2 << endl;
151 strm << endl;
152 }
153
154 //Triangle
155 vtkTriangle *triangle = vtkTriangle::New();
156 double triangleCoords[3], triangleWeights[3], trianglePosition[3];
157 double trianglePoint[4][3] = {{10.0, 10.0, 10.0}, {12.0, 10.0, 10.0}, {11.0, 12.0, 12.0}, {11, 11, 11}};
158 double triangleClosest[3];
159
160 triangle->GetPointIds()->SetId(0,0);
161 triangle->GetPointIds()->SetId(1,1);
162 triangle->GetPointIds()->SetId(2,2);
163
164 triangle->GetPoints()->SetPoint (0, 10.0, 10.0, 10.0);
165 triangle->GetPoints()->SetPoint (1, 12.0, 10.0, 10.0);
166 triangle->GetPoints()->SetPoint (2, 11.0, 12.0, 12.0);
167
168 n = sizeof(trianglePoint) / (3 * sizeof(double));
169 for (j = 0; j < n; j++)
170 {
171 triangle->EvaluatePosition (&trianglePoint[j][0], &triangleClosest[0], subId, &triangleCoords[0], dist2, &triangleWeights[0]);
172 strm << "vtkTriangle (" << trianglePoint[j][0] << ", " << trianglePoint[j][1] << ", " << trianglePoint[j][2] << ")" << endl;
173 strm << "\tclosest: " << triangleClosest[0] << ", " << triangleClosest[1] << ", " << triangleClosest[2] << endl;
174 strm << "\tcoords: " << triangleCoords[0] << ", " << triangleCoords[1] << ", " << triangleCoords[2] << endl;
175 strm << "\tweights: " << triangleWeights[0] << ", " << triangleWeights[1] << ", " << triangleWeights[2] << endl;
176 strm << "\tsubid: " << subId << endl;
177 strm << "\tdist2: " << dist2 << endl;
178 triangle->EvaluateLocation (subId, triangleCoords, trianglePosition, triangleWeights);
179 strm << "\tposition: " << trianglePosition[0] << ", " << trianglePosition[1] << ", " << trianglePosition[2] << endl;
180 strm << endl;
181 }
182
183 //Triangle Strip
184 vtkTriangleStrip *triangleStrip = vtkTriangleStrip::New();
185 double triangleStripCoords[3], triangleStripWeights[4], triangleStripPosition[3];
186 double triangleStripPoint[5][3] = {{10.0, 10.0, 10.0}, {12.0, 10.0, 10.0}, {11.0, 12.0, 10.0}, {13, 10, 10}, {11, 11, 10}};
187 double triangleStripClosest[3];
188
189 triangleStrip->GetPointIds()->SetNumberOfIds(4);
190 triangleStrip->GetPointIds()->SetId(0,0);
191 triangleStrip->GetPointIds()->SetId(1,1);
192 triangleStrip->GetPointIds()->SetId(2,2);
193 triangleStrip->GetPointIds()->SetId(3,3);
194
195 triangleStrip->GetPoints()->SetNumberOfPoints(4);
196 triangleStrip->GetPoints()->SetPoint (0, 10.0, 10.0, 10.0);
197 triangleStrip->GetPoints()->SetPoint (1, 12.0, 10.0, 10.0);
198 triangleStrip->GetPoints()->SetPoint (2, 11.0, 12.0, 10.0);
199 triangleStrip->GetPoints()->SetPoint (3, 13.0, 10.0, 10.0);
200
201 n = sizeof(triangleStripPoint) / (3 * sizeof(double));
202 for (j = 0; j < n; j++)
203 {
204 triangleStrip->EvaluatePosition (&triangleStripPoint[j][0], &triangleStripClosest[0], subId, &triangleStripCoords[0], dist2, &triangleStripWeights[0]);
205 strm << "vtkTriangleStrip (" << triangleStripPoint[j][0] << ", " << triangleStripPoint[j][1] << ", " << triangleStripPoint[j][2] << ")" << endl;
206 strm << "\tclosest: " << triangleStripClosest[0] << ", " << triangleStripClosest[1] << ", " << triangleStripClosest[2] << endl;
207 strm << "\tcoords: " << triangleStripCoords[0] << ", " << triangleStripCoords[1] << ", " << triangleStripCoords[2] << endl;
208 strm << "\tweights: " << triangleStripWeights[0] << ", " << triangleStripWeights[1] << ", " << triangleStripWeights[2] << endl;
209 strm << "\tsubid: " << subId << endl;
210 strm << "\tdist2: " << dist2 << endl;
211 triangleStrip->EvaluateLocation (subId, triangleStripCoords, triangleStripPosition, triangleStripWeights);
212 strm << "\tposition: " << triangleStripPosition[0] << ", " << triangleStripPosition[1] << ", " << triangleStripPosition[2] << endl;
213 strm << endl;
214 }
215
216 //Quad
217 vtkQuad *quad = vtkQuad::New();
218 double quadCoords[2], quadWeights[4], quadPosition[3];
219 double quadPoint[5][3] = {{10.0, 10.0, 10.0}, {12.0, 10.0, 10.0}, {12.0, 12.0, 10.0}, {10, 12, 10}, {11, 11, 10.1}};
220 double quadClosest[3];
221
222 quad->GetPointIds()->SetId(0,0);
223 quad->GetPointIds()->SetId(1,1);
224 quad->GetPointIds()->SetId(2,2);
225 quad->GetPointIds()->SetId(3,3);
226
227 quad->GetPoints()->SetPoint (0, 10.0, 10.0, 10.0);
228 quad->GetPoints()->SetPoint (1, 12.0, 10.0, 10.0);
229 quad->GetPoints()->SetPoint (2, 12.0, 12.0, 10.0);
230 quad->GetPoints()->SetPoint (3, 10.0, 12.0, 10.0);
231
232 n = sizeof(quadPoint) / (3 * sizeof(double));
233 for (j = 0; j < n; j++)
234 {
235 quad->EvaluatePosition (&quadPoint[j][0], &quadClosest[0], subId, &quadCoords[0], dist2, &quadWeights[0]);
236 strm << "vtkQuad (" << quadPoint[j][0] << ", " << quadPoint[j][1] << ", " << quadPoint[j][2] << ")" << endl;
237 strm << "\tclosest: " << quadClosest[0] << ", " << quadClosest[1] << ", " << quadClosest[2] << endl;
238 strm << "\tcoords: " << quadCoords[0] << ", " << quadCoords[1] << endl;
239 strm << "\tweights: " << quadWeights[0] << ", " << quadWeights[1] << ", " << quadWeights[2] << ", " << quadWeights[3] << endl;
240 strm << "\tsubid: " << subId << endl;
241 strm << "\tdist2: " << dist2 << endl;
242 quad->EvaluateLocation (subId, quadCoords, quadPosition, quadWeights);
243 strm << "\tposition: " << quadPosition[0] << ", " << quadPosition[1] << ", " << quadPosition[2] << endl;
244 strm << endl;
245 }
246
247 //Pixel
248 vtkPixel *pixel = vtkPixel::New();
249 double pixelCoords[3], pixelWeights[4], pixelPosition[3];
250 double pixelPoint[5][3] = {{10.0, 10.0, 10.0}, {12.0, 10.0, 10.0}, {12.0, 12.0, 10.0}, {10, 12, 10}, {11, 11, 10.1}};
251 double pixelClosest[3];
252
253 pixel->GetPointIds()->SetId(0,0);
254 pixel->GetPointIds()->SetId(1,1);
255 pixel->GetPointIds()->SetId(2,3);
256 pixel->GetPointIds()->SetId(3,2);
257
258 pixel->GetPoints()->SetPoint (0, 10.0, 10.0, 10.0);
259 pixel->GetPoints()->SetPoint (1, 12.0, 10.0, 10.0);
260 pixel->GetPoints()->SetPoint (3, 12.0, 12.0, 10.0);
261 pixel->GetPoints()->SetPoint (2, 10.0, 12.0, 10.0);
262
263 n = sizeof(pixelPoint) / (3 * sizeof(double));
264 for (j = 0; j < n; j++)
265 {
266 pixel->EvaluatePosition (&pixelPoint[j][0], &pixelClosest[0], subId, &pixelCoords[0], dist2, &pixelWeights[0]);
267 strm << "vtkPixel (" << pixelPoint[j][0] << ", " << pixelPoint[j][1] << ", " << pixelPoint[j][2] << ")" << endl;
268 strm << "\tclosest: " << pixelClosest[0] << ", " << pixelClosest[1] << ", " << pixelClosest[2] << endl;
269 strm << "\tcoords: " << pixelCoords[0] << ", " << pixelCoords[1] << endl;
270 strm << "\tweights: " << pixelWeights[0] << ", " << pixelWeights[1] << ", " << pixelWeights[2] << ", " << pixelWeights[3] << endl;
271 strm << "\tsubid: " << subId << endl;
272 strm << "\tdist2: " << dist2 << endl;
273 pixel->EvaluateLocation (subId, pixelCoords, pixelPosition, pixelWeights);
274 strm << "\tposition: " << pixelPosition[0] << ", " << pixelPosition[1] << ", " << pixelPosition[2] << endl;
275 strm << endl;
276 }
277
278 //Polygon
279 vtkPolygon *polygon = vtkPolygon::New();
280 double polygonCoords[2], polygonWeights[4], polygonPosition[3];
281 double polygonPoint[5][3] = {{0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0, 1, 0}, {.5, .5, 0}};
282 double polygonClosest[3];
283
284 polygon->GetPointIds()->SetNumberOfIds(4);
285 polygon->GetPointIds()->SetId(0,0);
286 polygon->GetPointIds()->SetId(1,1);
287 polygon->GetPointIds()->SetId(2,2);
288 polygon->GetPointIds()->SetId(3,3);
289
290 polygon->GetPoints()->SetNumberOfPoints(4);
291 polygon->GetPoints()->SetPoint(0, 0.0, 0.0, 0.0);
292 polygon->GetPoints()->SetPoint(1, 1.0, 0.0, 0.0);
293 polygon->GetPoints()->SetPoint(2, 1.0, 1.0, 0.0);
294 polygon->GetPoints()->SetPoint(3, 0.0, 1.0, 0.0);
295
296 n = sizeof(polygonPoint) / (3 * sizeof(double));
297 for (j = 0; j < n; j++)
298 {
299 polygon->EvaluatePosition (&polygonPoint[j][0], &polygonClosest[0], subId, &polygonCoords[0], dist2, &polygonWeights[0]);
300 strm << "vtkPolygon (" << polygonPoint[j][0] << ", " << polygonPoint[j][1] << ", " << polygonPoint[j][2] << ")" << endl;
301 strm << "\tclosest: " << polygonClosest[0] << ", " << polygonClosest[1] << ", " << polygonClosest[2] << endl;
302 strm << "\tcoords: " << polygonCoords[0] << ", " << polygonCoords[1] << endl;
303 strm << "\tweights: " << polygonWeights[0] << ", " << polygonWeights[1] << ", " << polygonWeights[2] << ", " << polygonWeights[3] << endl;
304 strm << "\tsubid: " << subId << endl;
305 strm << "\tdist2: " << dist2 << endl;
306 polygon->EvaluateLocation (subId, polygonCoords, polygonPosition, polygonWeights);
307 strm << "\tposition: " << polygonPosition[0] << ", " << polygonPosition[1] << ", " << polygonPosition[2] << endl;
308 strm << endl;
309 }
310
311 //Tetra
312 vtkTetra *tetra = vtkTetra::New();
313 double tetraCoords[3], tetraWeights[4], tetraPosition[3];
314 double tetraPoint[5][3] = {{10, 10, 10}, {12, 10, 10}, {11, 12, 10}, {11, 11, 12}, {11, 11, 11}};
315 double tetraClosest[3];
316
317 tetra->GetPointIds()->SetNumberOfIds(4);
318 tetra->GetPointIds()->SetId(0,0);
319 tetra->GetPointIds()->SetId(1,1);
320 tetra->GetPointIds()->SetId(2,2);
321 tetra->GetPointIds()->SetId(3,3);
322 tetra->GetPoints()->SetPoint(0, 10.0, 10.0, 10.0);
323 tetra->GetPoints()->SetPoint(1, 12.0, 10.0, 10.0);
324 tetra->GetPoints()->SetPoint(2, 11.0, 12.0, 10.0);
325 tetra->GetPoints()->SetPoint(3, 11.0, 11.0, 12.0);
326
327 n = sizeof(tetraPoint) / (3 * sizeof(double));
328 for (j = 0; j < n; j++)
329 {
330 tetra->EvaluatePosition (&tetraPoint[j][0], &tetraClosest[0], subId, &tetraCoords[0], dist2, &tetraWeights[0]);
331 strm << "vtkTetra (" << tetraPoint[j][0] << ", " << tetraPoint[j][1] << ", " << tetraPoint[j][2] << ")" << endl;
332 strm << "\tclosest: " << tetraClosest[0] << ", " << tetraClosest[1] << ", " << tetraClosest[2] << endl;
333 strm << "\tcoords: " << tetraCoords[0] << ", " << tetraCoords[1] << ", " << tetraCoords[2] << endl;
334 strm << "\tweights: " << tetraWeights[0] << ", " << tetraWeights[1] << ", " << tetraWeights[2] << ", " << tetraWeights[3] << endl;
335 strm << "\tsubid: " << subId << endl;
336 strm << "\tdist2: " << dist2 << endl;
337 tetra->EvaluateLocation (subId, tetraCoords, tetraPosition, tetraWeights);
338 strm << "\tposition: " << tetraPosition[0] << ", " << tetraPosition[1] << ", " << tetraPosition[2] << endl;
339 strm << endl;
340 }
341
342 //Voxel
343 vtkVoxel *voxel = vtkVoxel::New();
344 double voxelCoords[3], voxelWeights[8], voxelPosition[3];
345 double voxelPoint[9][3] = {{10, 10, 10}, {12, 10, 10}, {12, 12, 10}, {10, 12, 10},
346 {10, 10, 12}, {12, 10, 12}, {12, 12, 12}, {10, 12, 12},
347 {11, 11, 11}};
348 double voxelClosest[3];
349
350 voxel->GetPointIds()->SetNumberOfIds(8);
351 voxel->GetPointIds()->SetId(0,0);
352 voxel->GetPointIds()->SetId(1,1);
353 voxel->GetPointIds()->SetId(2,3);
354 voxel->GetPointIds()->SetId(3,2);
355 voxel->GetPointIds()->SetId(4,4);
356 voxel->GetPointIds()->SetId(5,5);
357 voxel->GetPointIds()->SetId(6,7);
358 voxel->GetPointIds()->SetId(7,6);
359
360 voxel->GetPoints()->SetPoint(0, 10, 10, 10);
361 voxel->GetPoints()->SetPoint(1, 12, 10, 10);
362 voxel->GetPoints()->SetPoint(3, 12, 12, 10);
363 voxel->GetPoints()->SetPoint(2, 10, 12, 10);
364 voxel->GetPoints()->SetPoint(4, 10, 10, 12);
365 voxel->GetPoints()->SetPoint(5, 12, 10, 12);
366 voxel->GetPoints()->SetPoint(7, 12, 12, 12);
367 voxel->GetPoints()->SetPoint(6, 10, 12, 12);
368
369 n = sizeof(voxelPoint) / (3 * sizeof(double));
370 for (j = 0; j < n; j++)
371 {
372 voxel->EvaluatePosition (&voxelPoint[j][0], &voxelClosest[0], subId, &voxelCoords[0], dist2, &voxelWeights[0]);
373 strm << "vtkVoxel (" << voxelPoint[j][0] << ", " << voxelPoint[j][1] << ", " << voxelPoint[j][2] << ")" << endl;
374 strm << "\tclosest: " << voxelClosest[0] << ", " << voxelClosest[1] << ", " << voxelClosest[2] << endl;
375 strm << "\tcoords: " << voxelCoords[0] << ", " << voxelCoords[1] << ", " << voxelCoords[2] << endl;
376 strm << "\tweights: " << voxelWeights[0] << ", " << voxelWeights[1] << ", " << voxelWeights[2] << ", " << voxelWeights[3] << endl;
377 strm << "\tsubid: " << subId << endl;
378 strm << "\tdist2: " << dist2 << endl;
379 voxel->EvaluateLocation (subId, voxelCoords, voxelPosition, voxelWeights);
380 strm << "\tposition: " << voxelPosition[0] << ", " << voxelPosition[1] << ", " << voxelPosition[2] << endl;
381 strm << endl;
382 }
383
384 //Wedge
385 vtkWedge *wedge = vtkWedge::New();
386 double wedgeCoords[3], wedgeWeights[8], wedgePosition[3];
387 double wedgePoint[9][3] = {{10, 10, 10}, {12, 10, 10}, {11, 12, 10}, {10, 10, 12},
388 {12, 10, 12}, {11, 12, 12}, {11, 11, 11}};
389 double wedgeClosest[3];
390
391 wedge->GetPointIds()->SetNumberOfIds(6);
392 wedge->GetPointIds()->SetId(0,0);
393 wedge->GetPointIds()->SetId(1,1);
394 wedge->GetPointIds()->SetId(2,2);
395 wedge->GetPointIds()->SetId(3,3);
396 wedge->GetPointIds()->SetId(4,4);
397 wedge->GetPointIds()->SetId(5,5);
398
399 wedge->GetPoints()->SetPoint(0, 10, 10, 10);
400 wedge->GetPoints()->SetPoint(1, 12, 10, 10);
401 wedge->GetPoints()->SetPoint(2, 11, 12, 10);
402 wedge->GetPoints()->SetPoint(3, 10, 10, 12);
403 wedge->GetPoints()->SetPoint(4, 12, 10, 12);
404 wedge->GetPoints()->SetPoint(5, 11, 12, 12);
405
406 n = sizeof(wedgePoint) / (3 * sizeof(double));
407 for (j = 0; j < n; j++)
408 {
409 wedge->EvaluatePosition (&wedgePoint[j][0], &wedgeClosest[0], subId, &wedgeCoords[0], dist2, &wedgeWeights[0]);
410 strm << "vtkWedge (" << wedgePoint[j][0] << ", " << wedgePoint[j][1] << ", " << wedgePoint[j][2] << ")" << endl;
411 strm << "\tclosest: " << wedgeClosest[0] << ", " << wedgeClosest[1] << ", " << wedgeClosest[2] << endl;
412 strm << "\tcoords: " << wedgeCoords[0] << ", " << wedgeCoords[1] << ", " << wedgeCoords[2] << endl;
413 strm << "\tweights: " << wedgeWeights[0] << ", " << wedgeWeights[1] << ", " << wedgeWeights[2] << ", " << wedgeWeights[3] << endl;
414 strm << "\tsubid: " << subId << endl;
415 strm << "\tdist2: " << dist2 << endl;
416 wedge->EvaluateLocation (subId, wedgeCoords, wedgePosition, wedgeWeights);
417 strm << "\tposition: " << wedgePosition[0] << ", " << wedgePosition[1] << ", " << wedgePosition[2] << endl;
418 strm << endl;
419 }
420
421 //Hexahedron
422 vtkHexahedron *hexahedron = vtkHexahedron::New();
423 double hexahedronCoords[3], hexahedronWeights[8], hexahedronPosition[3];
424 double hexahedronPoint[9][3] = {{10, 10, 10}, {12, 10, 10}, {12, 12, 10}, {10, 12, 10},
425 {10, 10, 12}, {12, 10, 12}, {12, 12, 12}, {10, 12, 12},
426 {11, 11, 11}};
427 double hexahedronClosest[3];
428
429 hexahedron->GetPointIds()->SetNumberOfIds(8);
430 hexahedron->GetPointIds()->SetId(0,0);
431 hexahedron->GetPointIds()->SetId(1,1);
432 hexahedron->GetPointIds()->SetId(2,2);
433 hexahedron->GetPointIds()->SetId(3,3);
434 hexahedron->GetPointIds()->SetId(4,4);
435 hexahedron->GetPointIds()->SetId(5,5);
436 hexahedron->GetPointIds()->SetId(6,6);
437 hexahedron->GetPointIds()->SetId(7,7);
438
439 hexahedron->GetPoints()->SetPoint(0, 10, 10, 10);
440 hexahedron->GetPoints()->SetPoint(1, 12, 10, 10);
441 hexahedron->GetPoints()->SetPoint(2, 12, 12, 10);
442 hexahedron->GetPoints()->SetPoint(3, 10, 12, 10);
443 hexahedron->GetPoints()->SetPoint(4, 10, 10, 12);
444 hexahedron->GetPoints()->SetPoint(5, 12, 10, 12);
445 hexahedron->GetPoints()->SetPoint(6, 12, 12, 12);
446 hexahedron->GetPoints()->SetPoint(7, 10, 12, 12);
447
448 n = sizeof(hexahedronPoint) / (3 * sizeof(double));
449 for (j = 0; j < n; j++)
450 {
451 hexahedron->EvaluatePosition (&hexahedronPoint[j][0], &hexahedronClosest[0], subId, &hexahedronCoords[0], dist2, &hexahedronWeights[0]);
452 strm << "vtkHexahedron (" << hexahedronPoint[j][0] << ", " << hexahedronPoint[j][1] << ", " << hexahedronPoint[j][2] << ")" << endl;
453 strm << "\tclosest: " << hexahedronClosest[0] << ", " << hexahedronClosest[1] << ", " << hexahedronClosest[2] << endl;
454 strm << "\tcoords: " << hexahedronCoords[0] << ", " << hexahedronCoords[1] << ", " << hexahedronCoords[2] << endl;
455 strm << "\tweights: " << hexahedronWeights[0] << ", " << hexahedronWeights[1] << ", " << hexahedronWeights[2] << ", " << hexahedronWeights[3] << endl;
456 strm << "\tsubid: " << subId << endl;
457 strm << "\tdist2: " << dist2 << endl;
458 hexahedron->EvaluateLocation (subId, hexahedronCoords, hexahedronPosition, hexahedronWeights);
459 strm << "\tposition: " << hexahedronPosition[0] << ", " << hexahedronPosition[1] << ", " << hexahedronPosition[2] << endl;
460 strm << endl;
461 }
462
463 //Pentagonal Prism
464 vtkPentagonalPrism *penta = vtkPentagonalPrism::New();
465 double pentaCoords[3], pentaWeights[10], pentaPosition[3];
466 double pentaPoint[11][3] = {{11, 10, 10}, {13, 10, 10}, {14, 12, 10}, {12, 14, 10},
467 {10, 12, 10}, {11, 10, 14}, {13, 10, 14}, {14, 12, 14},
468 {12, 14, 14}, {10, 12, 14}, {12, 12, 12}};
469 double pentaClosest[3];
470
471 penta->GetPointIds()->SetNumberOfIds(10);
472 penta->GetPointIds()->SetId(0,0);
473 penta->GetPointIds()->SetId(1,1);
474 penta->GetPointIds()->SetId(2,2);
475 penta->GetPointIds()->SetId(3,3);
476 penta->GetPointIds()->SetId(4,4);
477 penta->GetPointIds()->SetId(5,5);
478 penta->GetPointIds()->SetId(6,6);
479 penta->GetPointIds()->SetId(7,7);
480 penta->GetPointIds()->SetId(8,8);
481 penta->GetPointIds()->SetId(9,9);
482
483 penta->GetPoints()->SetPoint(0, 11, 10, 10);
484 penta->GetPoints()->SetPoint(1, 13, 10, 10);
485 penta->GetPoints()->SetPoint(2, 14, 12, 10);
486 penta->GetPoints()->SetPoint(3, 12, 14, 10);
487 penta->GetPoints()->SetPoint(4, 10, 12, 10);
488 penta->GetPoints()->SetPoint(5, 11, 10, 14);
489 penta->GetPoints()->SetPoint(6, 13, 10, 14);
490 penta->GetPoints()->SetPoint(7, 14, 12, 14);
491 penta->GetPoints()->SetPoint(8, 12, 14, 14);
492 penta->GetPoints()->SetPoint(9, 10, 12, 14);
493
494 n = sizeof(pentaPoint) / (3 * sizeof(double));
495 for (j = 0; j < n; j++)
496 {
497 penta->EvaluatePosition (&pentaPoint[j][0], &pentaClosest[0], subId, &pentaCoords[0], dist2, &pentaWeights[0]);
498 strm << "vtkPentagonalPrism (" << pentaPoint[j][0] << ", " << pentaPoint[j][1] << ", " << pentaPoint[j][2] << ")" << endl;
499 strm << "\tclosest: " << pentaClosest[0] << ", " << pentaClosest[1] << ", " << pentaClosest[2] << endl;
500 strm << "\tcoords: " << pentaCoords[0] << ", " << pentaCoords[1] << ", " << pentaCoords[2] << endl;
501 strm << "\tweights: " << pentaWeights[0] << ", " << pentaWeights[1] << ", " << pentaWeights[2] << ", " << pentaWeights[3] << endl;
502 strm << "\tsubid: " << subId << endl;
503 strm << "\tdist2: " << dist2 << endl;
504 penta->EvaluateLocation (subId, pentaCoords, pentaPosition, pentaWeights);
505 strm << "\tposition: " << pentaPosition[0] << ", " << pentaPosition[1] << ", " << pentaPosition[2] << endl;
506 strm << endl;
507 }
508
509 //Hexagonal Prism
510 vtkHexagonalPrism *hexa = vtkHexagonalPrism::New();
511 double hexaCoords[3], hexaWeights[12], hexaPosition[3];
512 double hexaPoint[13][3] = {{11, 10, 10}, {13, 10, 10}, {14, 12, 10}, {13, 14, 10},
513 {11, 14, 10}, {10, 12, 10}, {11, 10, 14}, {13, 10, 14},
514 {14, 12, 14}, {13, 14, 14}, {11, 14, 14}, {10, 12, 14},
515 {12, 12, 12}};
516 double hexaClosest[3];
517
518 hexa->GetPointIds()->SetNumberOfIds(12);
519 hexa->GetPointIds()->SetId(0,0);
520 hexa->GetPointIds()->SetId(1,1);
521 hexa->GetPointIds()->SetId(2,2);
522 hexa->GetPointIds()->SetId(3,3);
523 hexa->GetPointIds()->SetId(4,4);
524 hexa->GetPointIds()->SetId(5,5);
525 hexa->GetPointIds()->SetId(6,6);
526 hexa->GetPointIds()->SetId(7,7);
527 hexa->GetPointIds()->SetId(8,8);
528 hexa->GetPointIds()->SetId(9,9);
529 hexa->GetPointIds()->SetId(10,10);
530 hexa->GetPointIds()->SetId(11,11);
531
532 hexa->GetPoints()->SetPoint(0, 11, 10, 10);
533 hexa->GetPoints()->SetPoint(1, 13, 10, 10);
534 hexa->GetPoints()->SetPoint(2, 14, 12, 10);
535 hexa->GetPoints()->SetPoint(3, 13, 14, 10);
536 hexa->GetPoints()->SetPoint(4, 11, 14, 10);
537 hexa->GetPoints()->SetPoint(5, 10, 12, 10);
538 hexa->GetPoints()->SetPoint(6, 11, 10, 14);
539 hexa->GetPoints()->SetPoint(7, 13, 10, 14);
540 hexa->GetPoints()->SetPoint(8, 14, 12, 14);
541 hexa->GetPoints()->SetPoint(9, 13, 14, 14);
542 hexa->GetPoints()->SetPoint(10, 11, 14, 14);
543 hexa->GetPoints()->SetPoint(11, 10, 12, 14);
544
545 n = sizeof(hexaPoint) / (3 * sizeof(double));
546 for (j = 0; j < n; j++)
547 {
548 hexa->EvaluatePosition (&hexaPoint[j][0], &hexaClosest[0], subId, &hexaCoords[0], dist2, &hexaWeights[0]);
549 strm << "vtkHexagonalPrism (" << hexaPoint[j][0] << ", " << hexaPoint[j][1] << ", " << hexaPoint[j][2] << ")" << endl;
550 strm << "\tclosest: " << hexaClosest[0] << ", " << hexaClosest[1] << ", " << hexaClosest[2] << endl;
551 strm << "\tcoords: " << hexaCoords[0] << ", " << hexaCoords[1] << ", " << hexaCoords[2] << endl;
552 strm << "\tweights: " << hexaWeights[0] << ", " << hexaWeights[1] << ", " << hexaWeights[2] << ", " << hexaWeights[3] << endl;
553 strm << "\tsubid: " << subId << endl;
554 strm << "\tdist2: " << dist2 << endl;
555 hexa->EvaluateLocation (subId, hexaCoords, hexaPosition, hexaWeights);
556 strm << "\tposition: " << hexaPosition[0] << ", " << hexaPosition[1] << ", " << hexaPosition[2] << endl;
557 strm << endl;
558 }
559
560 ids->Delete();
561 vertex->Delete();
562 polyVertex->Delete();
563 line->Delete();
564 polyLine->Delete();
565 triangle->Delete();
566 triangleStrip->Delete();
567 quad->Delete();
568 pixel->Delete();
569 polygon->Delete();
570 tetra->Delete();
571 voxel->Delete();
572 wedge->Delete();
573 hexahedron->Delete();
574 penta->Delete();
575 hexa->Delete();
576
577 strm << "Test vtkCell::CellPosition Complete" << endl;
578 return 0;
579 }
580
otherCellPosition(int,char * [])581 int otherCellPosition(int, char *[])
582 {
583 vtksys_ios::ostringstream vtkmsg_with_warning_C4701;
584 return TestOCP(vtkmsg_with_warning_C4701);
585 }
586