VTK  9.7.20261116
ResolveHangingNodesTestUtilities.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2// SPDX-License-Identifier: BSD-3-Clause
3// Helpers of the tests of vtkResolveHangingNodes: the partitions of a mesh, the merge of the
4// partitions of an output, the checks shared by all the outputs, and mock filters.
5#ifndef ResolveHangingNodesTestUtilities_h
6#define ResolveHangingNodesTestUtilities_h
7
8#include "vtkAppendFilter.h"
9#include "vtkCellArray.h"
10#include "vtkCellData.h"
11#include "vtkCellType.h"
12#include "vtkCellValidator.h"
13#include "vtkCompositeDataSet.h"
14#include "vtkDataSet.h"
15#include "vtkDoubleArray.h"
16#include "vtkFeatureEdges.h"
17#include "vtkGeometryFilter.h"
18#include "vtkIdList.h"
19#include "vtkIdTypeArray.h"
20#include "vtkImageData.h"
21#include "vtkIntArray.h"
22#include "vtkMath.h"
23#include "vtkNew.h"
24#include "vtkObjectFactory.h"
27#include "vtkPointData.h"
28#include "vtkPointSet.h"
29#include "vtkPoints.h"
30#include "vtkPolyData.h"
32#include "vtkPolygon.h"
34#include "vtkSmartPointer.h"
35#include "vtkUnstructuredGrid.h"
36
37#include <array>
38#include <cmath>
39#include <iostream>
40#include <map>
41#include <numeric>
42#include <string>
43#include <vector>
44
45// The functions are inline, so that a test that does not use one gets no warning.
46namespace
47{
48constexpr double EPSILON = 1e-6;
49
50// A mesh: its area (2D) or volume (3D), the length (2D) or area (3D) of its boundary, and its
51// number of input cells.
52struct Domain
53{
54 double Measure;
55 double BoundaryMeasure;
56 vtkIdType NumberOfCells;
57};
58
59// The 2D 3-level mesh, over the domain [0,8] x [0,4] rotated by 30 degrees around the z axis.
60constexpr Domain THREE_LEVEL_DOMAIN = { 32.0, 24.0, 8 };
61
62// The 2D 3-level mesh is split in 2 partitions (see Split): the cells 0-3 (levels 0 and 1), and
63// the cells 4-7 (level 2). The hanging point (4,2) of cell 0 is in its partition, and the hanging
64// points (7,2) and (6,3) of the cells 2 and 3 are in the other one.
65constexpr vtkIdType THREE_LEVEL_SPLIT = 4;
66
67inline std::array<double, 3> Rotate(double x, double y)
68{
69 const double c = std::cos(vtkMath::Pi() / 6.0);
70 const double s = std::sin(vtkMath::Pi() / 6.0);
71 return { c * x - s * y, s * x + c * y, 0.0 };
72}
73
74// 2D 3-level mesh over the domain [0,8] x [0,4]:
75// - Cell 0, level 0: [0,4] x [0,4] (area 16). Its edge x = 4 has the hanging point (4,2).
76// - Cells 1-3, level 1: [4,6] x [0,2], [6,8] x [0,2], [4,6] x [2,4] (area 4). The edge y = 2 of
77// cell 2 has the hanging point (7,2), and the edge x = 6 of cell 3 has the hanging point (6,3).
78// - Cells 4-7, level 2: [6,8] x [2,4] subdivided 2 x 2 (area 1).
79// Cell data "CellIds" holds the cell id, and point data "Values" holds x + 10 y, after the point
80// global ids "GlobalIds" if `withGlobalIds` is true.
81inline vtkSmartPointer<vtkPolyData> CreateThreeLevelMesh(bool withGlobalIds = false)
82{
84 points->SetDataType(VTK_DOUBLE);
86 values->SetName("Values");
87 vtkNew<vtkIdTypeArray> globalIds;
88 globalIds->SetName("GlobalIds");
89 auto add = [&](double x, double y)
90 {
91 values->InsertNextValue(x + 10.0 * y);
92 globalIds->InsertNextValue(points->GetNumberOfPoints());
93 return points->InsertNextPoint(Rotate(x, y).data());
94 };
95 const vtkIdType p00 = add(0, 0), p40 = add(4, 0), p44 = add(4, 4), p04 = add(0, 4);
96 const vtkIdType p80 = add(8, 0), p84 = add(8, 4), p42 = add(4, 2), p60 = add(6, 0),
97 p62 = add(6, 2), p64 = add(6, 4), p82 = add(8, 2);
98 const vtkIdType p72 = add(7, 2), p83 = add(8, 3), p74 = add(7, 4), p63 = add(6, 3),
99 p73 = add(7, 3);
100
102 auto quad = [&](vtkIdType a, vtkIdType b, vtkIdType c, vtkIdType d)
103 {
104 const vtkIdType q[4] = { a, b, c, d };
105 polys->InsertNextCell(4, q);
106 };
107 quad(p00, p40, p44, p04);
108 quad(p40, p60, p62, p42);
109 quad(p60, p80, p82, p62);
110 quad(p42, p62, p64, p44);
111 quad(p62, p72, p73, p63);
112 quad(p72, p82, p83, p73);
113 quad(p63, p73, p74, p64);
114 quad(p73, p83, p84, p74);
115
117 pd->SetPoints(points);
118 pd->SetPolys(polys);
119 if (withGlobalIds)
120 {
121 pd->GetPointData()->SetGlobalIds(globalIds);
122 }
123 pd->GetPointData()->AddArray(values);
125 cellIds->SetName("CellIds");
126 for (vtkIdType i = 0; i < 8; ++i)
127 {
128 cellIds->InsertNextValue(i);
129 }
130 pd->GetCellData()->AddArray(cellIds);
131 return pd;
132}
133
134// The domain of the 3D 2-level mesh: [0,4] x [0,4] x [0,2].
135constexpr Domain TWO_LEVEL_DOMAIN = { 32.0, 64.0, 11 };
136
137// The 3D 2-level mesh is split in 2 partitions (see Split): the coarse cells A, B and C, and the
138// fine cells D, so that all the hanging points are in the other partition.
139constexpr vtkIdType TWO_LEVEL_SPLIT = 3;
140
141// Builds an unstructured grid of axis-aligned hexahedra given by their min corner and size. Cell
142// data "CellIds" holds the cell id, and point data "Values" holds x + 10 y + 100 z, after the point
143// global ids "GlobalIds" if they are requested.
144class HexMeshBuilder
145{
146public:
147 HexMeshBuilder()
148 {
149 this->Points->SetDataType(VTK_DOUBLE);
150 this->Values->SetName("Values");
151 }
152
153 void AddHex(int x, int y, int z, int size)
154 {
155 const vtkIdType ids[8] = {
156 this->Point(x, y, z),
157 this->Point(x + size, y, z),
158 this->Point(x + size, y + size, z),
159 this->Point(x, y + size, z),
160 this->Point(x, y, z + size),
161 this->Point(x + size, y, z + size),
162 this->Point(x + size, y + size, z + size),
163 this->Point(x, y + size, z + size),
164 };
165 this->Hexes.emplace_back(ids, ids + 8);
166 }
167
168 vtkIdType Point(int x, int y, int z)
169 {
170 auto it = this->PointIds.find({ x, y, z });
171 if (it != this->PointIds.end())
172 {
173 return it->second;
174 }
175 this->Values->InsertNextValue(x + 10.0 * y + 100.0 * z);
176 const vtkIdType id = this->Points->InsertNextPoint(x, y, z);
177 this->PointIds[{ x, y, z }] = id;
178 return id;
179 }
180
181 vtkSmartPointer<vtkUnstructuredGrid> Build(bool withGlobalIds = false)
182 {
184 ug->AllocateExact(static_cast<vtkIdType>(this->Hexes.size()), 8);
185 vtkNew<vtkIdTypeArray> cellIds;
186 cellIds->SetName("CellIds");
187 for (const auto& hex : this->Hexes)
188 {
189 cellIds->InsertNextValue(ug->InsertNextCell(VTK_HEXAHEDRON, 8, hex.data()));
190 }
191 ug->SetPoints(this->Points);
192 if (withGlobalIds)
193 {
194 vtkNew<vtkIdTypeArray> globalIds;
195 globalIds->SetName("GlobalIds");
196 globalIds->SetNumberOfValues(this->Points->GetNumberOfPoints());
197 std::iota(globalIds->GetPointer(0), globalIds->GetPointer(0) + globalIds->GetNumberOfValues(),
198 static_cast<vtkIdType>(0));
199 ug->GetPointData()->SetGlobalIds(globalIds);
200 }
201 ug->GetPointData()->AddArray(this->Values);
202 ug->GetCellData()->AddArray(cellIds);
203 return ug;
204 }
205
206private:
207 vtkNew<vtkPoints> Points;
208 vtkNew<vtkDoubleArray> Values;
209 std::map<std::array<int, 3>, vtkIdType> PointIds;
210 std::vector<std::vector<vtkIdType>> Hexes;
211};
212
213// 3D 2-level mesh over the domain [0,4] x [0,4] x [0,2]:
214// - Cell 0 (A), level 0: [0,2] x [0,2] x [0,2]. Its face x = 2 borders the fine block D.
215// - Cell 1 (B), level 0: [0,2] x [2,4] x [0,2]. It touches D only along the edge x = 2, y = 2:
216// its faces are all shared with A and C or on the boundary of the domain, so the hanging point
217// (2,2,1) on that edge is only found through A and C.
218// - Cell 2 (C), level 0: [2,4] x [2,4] x [0,2]. Its face y = 2 borders D.
219// - Cells 3-10 (D), level 1: [2,4] x [0,2] x [0,2] subdivided 2 x 2 x 2, cell 3 + i + 2 j + 4 k
220// being [2+i,3+i] x [j,j+1] x [k,k+1].
221inline vtkSmartPointer<vtkUnstructuredGrid> CreateTwoLevelMesh()
222{
223 HexMeshBuilder builder;
224 builder.AddHex(0, 0, 0, 2);
225 builder.AddHex(0, 2, 0, 2);
226 builder.AddHex(2, 2, 0, 2);
227 for (int k = 0; k < 2; ++k)
228 {
229 for (int j = 0; j < 2; ++j)
230 {
231 for (int i = 0; i < 2; ++i)
232 {
233 builder.AddHex(2 + i, j, k, 1);
234 }
235 }
236 }
237 return builder.Build();
238}
239
240// A block of level `level` of a vtkNonOverlappingAMR: a vtkImageData of `numCells` cells (0 along z
241// in 2D) of size `spacing`, from `origin`. Cell data "CellIds" holds the cell ids from
242// `firstCellId`, and point data "Values" holds x + 10 y + 100 z, and "Levels" the level.
243inline vtkSmartPointer<vtkImageData> CreateBlock(int level, const std::array<double, 3>& origin,
244 const std::array<int, 3>& numCells, double spacing, vtkIdType firstCellId)
245{
247 block->SetOrigin(origin.data());
248 block->SetSpacing(spacing, spacing, spacing);
249 block->SetDimensions(numCells[0] + 1, numCells[1] + 1, numCells[2] + 1);
251 values->SetName("Values");
252 vtkNew<vtkIntArray> levels;
253 levels->SetName("Levels");
254 for (vtkIdType i = 0; i < block->GetNumberOfPoints(); ++i)
255 {
256 const double* p = block->GetPoint(i);
257 values->InsertNextValue(p[0] + 10.0 * p[1] + 100.0 * p[2]);
258 levels->InsertNextValue(level);
259 }
260 block->GetPointData()->AddArray(values);
261 block->GetPointData()->AddArray(levels);
263 cellIds->SetName("CellIds");
264 for (vtkIdType i = 0; i < block->GetNumberOfCells(); ++i)
265 {
266 cellIds->InsertNextValue(firstCellId + i);
267 }
268 block->GetCellData()->AddArray(cellIds);
269 return block;
270}
271
272inline vtkSmartPointer<vtkUnstructuredGrid> ToUnstructuredGrid(vtkPolyData* pd)
273{
275 converter->SetInputData(pd);
276 converter->Update();
277 return converter->GetOutput();
278}
279
280// Total length (2D) or area (3D) of the edges or faces used by a single cell. It is the boundary
281// measure of the domain if and only if the mesh is conforming: a remaining hanging node leaves both
282// sides of an interface unmatched.
283template <int Dim>
284inline double BoundaryMeasure(vtkDataSet* ds)
285{
287 geometry->SetInputData(ds);
288 geometry->Update();
289 vtkSmartPointer<vtkPolyData> boundary = geometry->GetOutput();
290 if constexpr (Dim == 2)
291 {
293 edges->SetInputData(boundary);
294 edges->BoundaryEdgesOn();
295 edges->FeatureEdgesOff();
296 edges->NonManifoldEdgesOff();
297 edges->ManifoldEdgesOff();
298 edges->Update();
299 boundary = edges->GetOutput();
300 }
301 double measure = 0.0;
303 for (vtkIdType c = 0; c < boundary->GetNumberOfCells(); ++c)
304 {
305 boundary->GetCellPoints(c, ids);
306 if constexpr (Dim == 2)
307 {
308 double p0[3], p1[3];
309 boundary->GetPoint(ids->GetId(0), p0);
310 boundary->GetPoint(ids->GetId(1), p1);
311 measure += std::sqrt(vtkMath::Distance2BetweenPoints(p0, p1));
312 }
313 else
314 {
315 double normal[3];
316 measure += vtkPolygon::ComputeArea(
317 boundary->GetPoints(), ids->GetNumberOfIds(), ids->GetPointer(0), normal);
318 }
319 }
320 return measure;
321}
322
323// The cells `cellIds` of `mesh`, in this order, with the points they use and the point and cell
324// data, global ids included, in a dataset of the type of `mesh`, whose cells are polygons if it is
325// a vtkPolyData.
326inline vtkSmartPointer<vtkPointSet> ExtractCells(
327 vtkPointSet* mesh, const std::vector<vtkIdType>& cellIds)
328{
330 points->SetDataType(mesh->GetPoints()->GetDataType());
331 auto part = vtk::TakeSmartPointer(mesh->NewInstance());
332 vtkPointData* pointData = part->GetPointData();
333 pointData->CopyGlobalIdsOn();
334 pointData->CopyAllocate(mesh->GetPointData());
335 vtkCellData* cellData = part->GetCellData();
336 cellData->CopyAllocate(mesh->GetCellData());
338 std::vector<int> types;
339 std::map<vtkIdType, vtkIdType> pointIds;
341 for (vtkIdType i = 0; i < static_cast<vtkIdType>(cellIds.size()); ++i)
342 {
343 const vtkIdType c = cellIds[i];
344 mesh->GetCellPoints(c, ids);
345 for (vtkIdType j = 0; j < ids->GetNumberOfIds(); ++j)
346 {
347 const auto [it, isNew] = pointIds.emplace(ids->GetId(j), points->GetNumberOfPoints());
348 if (isNew)
349 {
350 points->InsertNextPoint(mesh->GetPoint(ids->GetId(j)));
351 pointData->CopyData(mesh->GetPointData(), ids->GetId(j), it->second);
352 }
353 ids->SetId(j, it->second);
354 }
355 cells->InsertNextCell(ids);
356 types.push_back(mesh->GetCellType(c));
357 cellData->CopyData(mesh->GetCellData(), c, i);
358 }
359 part->SetPoints(points);
360 if (auto polyData = vtkPolyData::SafeDownCast(part))
361 {
362 polyData->SetPolys(cells);
363 }
364 else
365 {
366 vtkUnstructuredGrid::SafeDownCast(part)->SetCells(types.data(), cells);
367 }
368 return part;
369}
370
371// The cells [begin, end) of `mesh`, see above.
372inline vtkSmartPointer<vtkPointSet> ExtractCells(vtkPointSet* mesh, vtkIdType begin, vtkIdType end)
373{
374 std::vector<vtkIdType> cellIds(end - begin);
375 std::iota(cellIds.begin(), cellIds.end(), begin);
376 return ExtractCells(mesh, cellIds);
377}
378
379// `mesh` in 2 partitions, its first `numCellsOfFirst` cells and the others, of the single
380// vtkPartitionedDataSet of a vtkPartitionedDataSetCollection, so that they are resolved together.
382 vtkPointSet* mesh, vtkIdType numCellsOfFirst)
383{
385 partitions->SetPartition(0, ExtractCells(mesh, 0, numCellsOfFirst));
386 partitions->SetPartition(1, ExtractCells(mesh, numCellsOfFirst, mesh->GetNumberOfCells()));
388 collection->SetPartitionedDataSet(0, partitions);
389 return collection;
390}
391
392// The partitions of `output` in one mesh, with the points they share merged.
394{
396 append->MergePointsOn();
397 for (vtkDataSet* partition : vtkCompositeDataSet::GetDataSets(output))
398 {
399 append->AddInputData(partition);
400 }
401 append->Update();
402 return append->GetOutput();
403}
404
405// Checks shared by all the outputs of a mesh of `domain`, once their partitions are merged. The
406// cell data "CellIds" of the input holds the cell ids, and the point data "Values" is passed.
407template <int Dim>
408inline bool CheckOutput(const std::string& name, vtkUnstructuredGrid* output, bool decompose,
409 vtkIdType expectedPoints, vtkIdType expectedCells, const Domain& domain)
410{
411 if (output->GetNumberOfPoints() != expectedPoints || output->GetNumberOfCells() != expectedCells)
412 {
413 std::cerr << name << ": expected " << expectedPoints << " points and " << expectedCells
414 << " cells, got " << output->GetNumberOfPoints() << " and "
415 << output->GetNumberOfCells() << "\n";
416 return false;
417 }
418
419 // The output is conforming.
420 const double boundaryMeasure = BoundaryMeasure<Dim>(output);
421 if (std::abs(boundaryMeasure - domain.BoundaryMeasure) > EPSILON)
422 {
423 std::cerr << name << ": the boundary " << (Dim == 2 ? "length" : "area") << " is "
424 << boundaryMeasure << " instead of " << domain.BoundaryMeasure
425 << ", the output is not conforming\n";
426 return false;
427 }
428
429 // Cell types: polygons or polyhedra with hanging points, or triangles and quads in 2D, and
430 // tetrahedra and pyramids in 3D.
431 for (vtkIdType c = 0; c < output->GetNumberOfCells(); ++c)
432 {
433 const int type = output->GetCellType(c);
434 const bool isValidType = Dim == 2
435 ? type == VTK_QUAD || type == (decompose ? VTK_TRIANGLE : VTK_POLYGON)
436 : type == VTK_HEXAHEDRON ||
437 (decompose ? (type == VTK_TETRA || type == VTK_PYRAMID) : type == VTK_POLYHEDRON);
438 if (!isValidType)
439 {
440 std::cerr << name << ": unexpected type " << type << " for cell " << c << "\n";
441 return false;
442 }
443 }
444
445 // 3D: the cells are valid, in particular the tetrahedra and pyramids are not inverted.
446 if (Dim == 3)
447 {
448 vtkNew<vtkCellValidator> validator;
449 validator->SetInputData(output);
450 validator->Update();
451 vtkDataArray* states =
452 vtkDataSet::SafeDownCast(validator->GetOutput())->GetCellData()->GetArray("ValidityState");
453 for (vtkIdType c = 0; c < output->GetNumberOfCells(); ++c)
454 {
455 if (states->GetTuple1(c) != static_cast<short>(vtkCellValidator::State::Valid))
456 {
457 std::cerr << name << ": cell " << c << " of type " << output->GetCellType(c)
458 << " is not valid (state " << states->GetTuple1(c) << ")\n";
459 return false;
460 }
461 }
462 }
463
464 // The cells (or sub-cells) of every input cell are in input order and copy its cell data.
465 vtkDataArray* cellIds = output->GetCellData()->GetArray("CellIds");
466 if (!cellIds || cellIds->GetTuple1(0) != 0 ||
467 cellIds->GetTuple1(expectedCells - 1) != domain.NumberOfCells - 1)
468 {
469 std::cerr << name << ": cell data was not copied\n";
470 return false;
471 }
472 for (vtkIdType c = 1; c < expectedCells; ++c)
473 {
474 const double step = cellIds->GetTuple1(c) - cellIds->GetTuple1(c - 1);
475 if (step != 0 && step != 1)
476 {
477 std::cerr << name << ": cells are not in input order\n";
478 return false;
479 }
480 }
481
482 // The inverse measures are positive and cover the domain.
483 const char* inverseMeasureName = Dim == 2 ? "InverseArea" : "InverseVolume";
484 vtkDataArray* inverseMeasure = output->GetCellData()->GetArray(inverseMeasureName);
485 if (!inverseMeasure ||
486 output->GetCellData()->GetArray(Dim == 2 ? "InverseVolume" : "InverseArea"))
487 {
488 std::cerr << name << ": expected the " << inverseMeasureName << " cell data array only\n";
489 return false;
490 }
491 double measure = 0.0;
492 for (vtkIdType c = 0; c < output->GetNumberOfCells(); ++c)
493 {
494 if (inverseMeasure->GetTuple1(c) <= 0.0)
495 {
496 std::cerr << name << ": wrong " << inverseMeasureName << " for cell " << c << "\n";
497 return false;
498 }
499 measure += 1.0 / inverseMeasure->GetTuple1(c);
500 }
501 if (std::abs(measure - domain.Measure) > EPSILON)
502 {
503 std::cerr << name << ": the cells cover " << (Dim == 2 ? "an area" : "a volume") << " of "
504 << measure << " instead of " << domain.Measure << "\n";
505 return false;
506 }
507
508 // Point data is passed.
509 if (!output->GetPointData()->GetArray("Values"))
510 {
511 std::cerr << name << ": point data was not passed\n";
512 return false;
513 }
514 return true;
515}
516
517inline vtkIdType FindPoint(vtkDataSet* ds, const std::array<double, 3>& p)
518{
519 for (vtkIdType i = 0; i < ds->GetNumberOfPoints(); ++i)
520 {
521 if (vtkMath::Distance2BetweenPoints(p.data(), ds->GetPoint(i)) < EPSILON)
522 {
523 return i;
524 }
525 }
526 return -1;
527}
528
529// Mock subclass providing points of other processes without an MPI controller, in addition to the
530// points of the other local partitions.
531class vtkRemotePointsTestFilter : public vtkResolveHangingNodes
532{
533public:
534 static vtkRemotePointsTestFilter* New() { VTK_STANDARD_NEW_BODY(vtkRemotePointsTestFilter); }
535 vtkTypeMacro(vtkRemotePointsTestFilter, vtkResolveHangingNodes);
536
537 vtkSmartPointer<vtkPolyData> Remote;
538
539protected:
540 bool UseRemotePoints() override { return true; }
541 std::vector<vtkSmartPointer<vtkPolyData>> GetRemotePoints(
542 const std::vector<vtkPolyData*>& boundaries,
543 const std::vector<int>& partitionedDataSetIds) override
544 {
545 std::vector<vtkSmartPointer<vtkPolyData>> remotePoints =
546 this->Superclass::GetRemotePoints(boundaries, partitionedDataSetIds);
547 for (std::size_t p = 0; p < boundaries.size(); ++p)
548 {
549 remotePoints[p] =
550 this->MergeReceivedPoints({ { 0, remotePoints[p] }, { 1, this->Remote } }, boundaries[p]);
551 }
552 return remotePoints;
553 }
554};
555
556// Mock subclass recording the partitionedDataSetIds of the blocks of a vtkNonOverlappingAMR, their
557// levels, and checking that a block only receives the points of the blocks of the other levels,
558// whose point data "Levels" holds their level.
559class vtkLevelsTestFilter : public vtkResolveHangingNodes
560{
561public:
562 static vtkLevelsTestFilter* New() { VTK_STANDARD_NEW_BODY(vtkLevelsTestFilter); }
563 vtkTypeMacro(vtkLevelsTestFilter, vtkResolveHangingNodes);
564
565 std::vector<int> PartitionedDataSetIds;
566 bool ReceivedOnlyOtherLevels = true;
567
568protected:
569 std::vector<vtkSmartPointer<vtkPolyData>> GetRemotePoints(
570 const std::vector<vtkPolyData*>& boundaries,
571 const std::vector<int>& partitionedDataSetIds) override
572 {
573 this->PartitionedDataSetIds = partitionedDataSetIds;
574 std::vector<vtkSmartPointer<vtkPolyData>> remotePoints =
575 this->Superclass::GetRemotePoints(boundaries, partitionedDataSetIds);
576 for (std::size_t p = 0; p < remotePoints.size(); ++p)
577 {
578 vtkDataArray* levels =
579 remotePoints[p] ? remotePoints[p]->GetPointData()->GetArray("Levels") : nullptr;
580 for (vtkIdType i = 0; levels && i < levels->GetNumberOfTuples(); ++i)
581 {
582 if (levels->GetTuple1(i) == partitionedDataSetIds[p])
583 {
584 this->ReceivedOnlyOtherLevels = false;
585 }
586 }
587 }
588 return remotePoints;
589 }
590};
591} // namespace
592
593#endif
vtkIdType GetNumberOfTuples() const
Get the number of complete tuples (a component group) in the array.
represent and manipulate cell attribute data
static std::vector< DataSetT * > GetDataSets(vtkDataObject *dobj, bool preserveNull=false)
Extract datasets from the given data object.
double GetTuple1(vtkIdType tupleIdx)
These methods are included as convenience for the wrappers.
general representation of visualization data
void CopyData(vtkDataSetAttributes *fromPd, vtkIdType fromId, vtkIdType toId)
Copy the attribute data from one id to another.
void CopyAllocate(vtkDataSetAttributes *pd, vtkIdType sze=0, vtkIdType ext=1000)
Allocates point data for point-by-point (or cell-by-cell) copy operation.
abstract class to specify dataset behavior
Definition vtkDataSet.h:165
vtkPointData * GetPointData()
Return a pointer to this dataset's point data.
Definition vtkDataSet.h:443
static vtkDataSet * SafeDownCast(vtkObjectBase *o)
virtual vtkIdType GetNumberOfPoints()=0
Determine the number of points composing the dataset.
virtual double * GetPoint(vtkIdType ptId)=0
Get point coordinates with ptId such that: 0 <= ptId < NumberOfPoints.
vtkCellData * GetCellData()
Return a pointer to this dataset's cell data.
Definition vtkDataSet.h:437
vtkDataArray * GetArray(int i)
Not recommended for use.
static ReturnTypeT Distance2BetweenPoints(const TupleRangeT1 &p1, const TupleRangeT2 &p2)
Compute distance squared between two points p1 and p2.
Definition vtkMath.h:2096
static constexpr double Pi()
A mathematical constant.
Definition vtkMath.h:227
Allocate and hold a VTK object.
Definition vtkNew.h:168
T * GetPointer() const noexcept
Get a raw pointer to the contained object.
Definition vtkNew.h:257
represent and manipulate point attribute data
concrete class for storing a set of points
Definition vtkPointSet.h:98
void GetCellPoints(vtkIdType, vtkIdList *idList) override
This method resets parameter idList, as there is no cell in a vtkPointSet.
vtkPointSet * NewInstance() const
Standard methods for type information and printing.
vtkPoints * GetPoints() override
Specify point array to define point coordinates.
vtkIdType GetNumberOfCells() override
This method always returns 0, as there are no cells in a vtkPointSet.
vtkIdType GetNumberOfPoints() override
See vtkDataSet for additional information.
void GetPoint(vtkIdType ptId, double x[3]) override
See vtkDataSet for additional information.
int GetCellType(vtkIdType) override
This method always returns VTK_EMPTY_CELL, as there is no cell in a vtkPointSet.
virtual int GetDataType() const
Return the underlying data type.
concrete dataset represents vertices, lines, polygons, and triangle strips
static vtkPolyData * SafeDownCast(vtkObjectBase *o)
double ComputeArea()
Compute the area of a polygon.
make a 2D or 3D multi-resolution mesh conforming by inserting hanging points
virtual std::vector< vtkSmartPointer< vtkPolyData > > GetRemotePoints(const std::vector< vtkPolyData * > &boundaries, const std::vector< int > &partitionedDataSetIds)
Called with the true boundary of every local partition: the edges (2D) or faces (3D) without neighbor...
Hold a reference to a vtkObjectBase instance.
static vtkSmartPointer< T > New()
Create an instance of a VTK object.
dataset represents arbitrary combinations of all possible cell types
static vtkUnstructuredGrid * SafeDownCast(vtkObjectBase *o)
Standard methods for type information and printing.
void SetCells(int type, vtkCellArray *cells)
Provide cell information to define the dataset with a single type.
vtkIdType GetNumberOfCells() override
Standard vtkDataSet methods; see vtkDataSet.h for documentation.
int GetCellType(vtkIdType cellId) override
Get the type of the cell with the given cellId.
const std::string pointIds
const std::string pointData
@ points
Definition vtkX3D.h:447
@ type
Definition vtkX3D.h:517
@ name
Definition vtkX3D.h:220
@ data
Definition vtkX3D.h:316
vtkSmartPointer< T > TakeSmartPointer(T *obj)
Construct a vtkSmartPointer<T> containing obj.
std::pair< boost::graph_traits< vtkGraph * >::edge_iterator, boost::graph_traits< vtkGraph * >::edge_iterator > edges(vtkGraph *g)
@ VTK_PYRAMID
Definition vtkCellType.h:51
@ VTK_TRIANGLE
Definition vtkCellType.h:42
@ VTK_POLYGON
Definition vtkCellType.h:44
@ VTK_POLYHEDRON
Definition vtkCellType.h:80
@ VTK_TETRA
Definition vtkCellType.h:47
@ VTK_HEXAHEDRON
Definition vtkCellType.h:49
@ VTK_QUAD
Definition vtkCellType.h:46
#define vtkDataArray
#define VTK_STANDARD_NEW_BODY(thisClass)
int vtkIdType
Definition vtkType.h:366
#define VTK_DOUBLE
Definition vtkType.h:44