VTK  9.7.20261102
vtkUnstructuredGridSides.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
99#ifndef vtkUnstructuredGridSides_h
100#define vtkUnstructuredGridSides_h
101
102#include "vtkCellGridSidesQuery.h" // For SideFlags and SummaryStrategy
103#include "vtkCommonDataModelModule.h" // For export macro
104#include "vtkDataSetAttributes.h" // For HIDDENCELL and REFINEDCELL
105#include "vtkKeys.h" // For DenseKeys and ReducedKeys
106#include "vtkObject.h"
107#include "vtkType.h" // For vtkIdType, VTK_ID_MAX and VTK_DOUBLE_MAX
108
109#include <cstdint> // For std::uint8_t
110#include <memory> // For std::unique_ptr
111
112VTK_ABI_NAMESPACE_BEGIN
113class vtkGenericCell;
114class vtkIdList;
116
117template <typename TId = vtkIdType, typename TSideId = vtkTypeInt8>
118class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGridSides : public vtkObject
119{
120public:
122 static SelfType* New();
124 void PrintSelf(ostream& os, vtkIndent indent) override;
125
131
136
138
142 virtual void SetDataSet(vtkUnstructuredGrid* dataSet);
143 vtkGetObjectMacro(DataSet, vtkUnstructuredGrid);
145
147
151 vtkSetMacro(PreserveRenderableInputs, bool);
152 vtkGetMacro(PreserveRenderableInputs, bool);
153 vtkBooleanMacro(PreserveRenderableInputs, bool);
155
157
160 vtkSetMacro(OmitSidesForRenderableInputs, bool);
161 vtkGetMacro(OmitSidesForRenderableInputs, bool);
162 vtkBooleanMacro(OmitSidesForRenderableInputs, bool);
164
166
171 vtkSetClampMacro(OutputDimensionControl, int, 0, SideFlags::AllSides);
172 vtkGetMacro(OutputDimensionControl, int);
174
176
179 vtkSetMacro(Strategy, SummaryStrategy);
180 void SetStrategyToWinding() { this->SetStrategy(SummaryStrategy::Winding); }
181 void SetStrategyToAnyOccurrence() { this->SetStrategy(SummaryStrategy::AnyOccurrence); }
182 void SetStrategyToBoundary() { this->SetStrategy(SummaryStrategy::Boundary); }
184 virtual void SetStrategy(int strategy)
185 {
186 this->SetStrategy(static_cast<SummaryStrategy>(strategy));
187 }
188 vtkGetMacro(Strategy, SummaryStrategy);
190
192
196 vtkSetMacro(PointClipping, bool);
197 vtkGetMacro(PointClipping, bool);
198 vtkBooleanMacro(PointClipping, bool);
200
202
206 vtkSetMacro(CellClipping, bool);
207 vtkGetMacro(CellClipping, bool);
208 vtkBooleanMacro(CellClipping, bool);
210
212
216 vtkSetMacro(ExtentClipping, bool);
217 vtkGetMacro(ExtentClipping, bool);
218 vtkBooleanMacro(ExtentClipping, bool);
220
222
226 vtkSetClampMacro(PointMinimum, vtkIdType, 0, VTK_ID_MAX);
227 vtkGetMacro(PointMinimum, vtkIdType);
228 vtkSetClampMacro(PointMaximum, vtkIdType, 0, VTK_ID_MAX);
229 vtkGetMacro(PointMaximum, vtkIdType);
231
233
237 vtkSetClampMacro(CellMinimum, vtkIdType, 0, VTK_ID_MAX);
238 vtkGetMacro(CellMinimum, vtkIdType);
239 vtkSetClampMacro(CellMaximum, vtkIdType, 0, VTK_ID_MAX);
240 vtkGetMacro(CellMaximum, vtkIdType);
242
244
248 vtkSetVector6Macro(Extent, double);
249 vtkGetVector6Macro(Extent, double);
251
253
257 vtkSetMacro(RemoveGhostInterfaces, bool);
258 vtkGetMacro(RemoveGhostInterfaces, bool);
259 vtkBooleanMacro(RemoveGhostInterfaces, bool);
261
263
268 vtkSetMacro(MaskedGhostTypes, unsigned char);
269 vtkGetMacro(MaskedGhostTypes, unsigned char);
271
273
281 vtkSetMacro(MatchSidePoints, bool);
282 vtkGetMacro(MatchSidePoints, bool);
283 vtkBooleanMacro(MatchSidePoints, bool);
285
289 enum class BuildMode : std::uint8_t
290 {
292 Scattered,
293 Reduced,
294 Grouped
295 };
296
303
311
321
325 BuildMode GetBuildMode() const { return this->Mode; }
326
330 void Reset();
331
335 vtkGetMacro(BuildTime, vtkMTimeType);
336
340 bool UsesGarbageCollector() const override { return true; }
341
342 //------------------------------------------------------------------------------
343 // The sides, after any build: by key, and by their index k in their key. BuildScatteredSides()
344 // and BuildReducedSides() have no getters of their own.
345 //------------------------------------------------------------------------------
346
351
359 TId GetNumberOfKeys() const;
360
365
371
376 const TId* GetCellIdsOfKey(TId keyId) const;
377
382 const TSideId* GetSideIdsOfKey(TId keyId) const;
383
385
389 TId GetCellIdOfSide(TId keyId, vtkIdType k) const;
390 TSideId GetSideIdOfSide(TId keyId, vtkIdType k) const;
391 int GetDimensionOfSide(TId keyId, vtkIdType k) const;
393
398 {
399 vtkIdType CellId; // the cell of the side
400 unsigned char CellType; // the cell type of its cell
401 int SideId; // its local index in its cell, -1 for a preserved cell
402 int SideType; // its cell type, e.g., VTK_QUADRATIC_QUAD for a face of a quadratic hex
403 int SideDimension; // its dimension, the one of its cell for a preserved cell
404 int SideSize; // its number of points
405 };
406
417 SideInformation GetSideInformation(TId keyId, vtkIdType k, vtkGenericCell* tempCell) const;
418
433 void GetSidePoints(TId keyId, vtkIdType k, vtkIdList* sidePtIds, unsigned char& cellType,
434 vtkIdList* tempCellPointIds, vtkGenericCell* tempCell) const;
435
436 //------------------------------------------------------------------------------
437 // The groups of equal sides, after BuildGroupedSides() only, none otherwise.
438 //------------------------------------------------------------------------------
439
441
450
452
460
462
468 const TId* GetCellIdsOfGroup(vtkIdType group) const;
469 const TSideId* GetSideIdsOfGroup(vtkIdType group) const;
471
477
478protected:
481
482 vtkTimeStamp BuildTime; // time at which the sides were built
483
485
486private:
488 void operator=(const vtkUnstructuredGridSides&) = delete;
489
490 // Find and scatter the sides, see BuildScatteredSides(), and reduce or group them as given by
491 // the mode.
492 void BuildSides(BuildMode mode);
493
494 // Where the sides of a key start in their arrays, which keep the kept sides of a key at the
495 // front of its sides, with gaps between the keys, unlike GetSideOffsetOfKey(): the last key, of
496 // the preserved cells, starts after all the found sides.
497 vtkIdType GetStorageOffsetOfKey(TId keyId) const;
498
499 // The steps of BuildSides(), defined in the .cxx file, nested so that they read the settings
500 // directly.
501 template <class OffsetsT, class ConnectivityT>
502 struct InputCells;
503 template <class InputCellsT>
504 struct SideMapper;
505 template <class InputCellsT, bool Faces>
506 struct MatchingFunctor;
507 struct PreservedCells;
508 struct BuildSidesWorker;
509
510 // The settings.
511 vtkUnstructuredGrid* DataSet = nullptr;
512 bool PreserveRenderableInputs = false;
513 bool OmitSidesForRenderableInputs = false;
514 int OutputDimensionControl = SideFlags::NextLowestDimension;
515 SummaryStrategy Strategy = SummaryStrategy::Boundary;
516 bool PointClipping = false;
517 bool CellClipping = false;
518 bool ExtentClipping = false;
519 vtkIdType PointMinimum = 0;
520 vtkIdType PointMaximum = VTK_ID_MAX;
521 vtkIdType CellMinimum = 0;
522 vtkIdType CellMaximum = VTK_ID_MAX;
525 bool RemoveGhostInterfaces = true;
526 unsigned char MaskedGhostTypes =
528 bool MatchSidePoints = true;
529
530 // The sides, scattered by their key, their smallest point id (ScatteredKeys), the number of kept
531 // sides at the front of the sides of every key once reduced (ReducedKeys), and the groups of
532 // equal sides and the number of groups of every key once grouped (Groups): their cell, local
533 // index and dimension, unless they all have the dimension SideDimension. The cell and local index
534 // of the preserved cells are after them. BuiltKeys, the keys of the built sides, which the
535 // getters read, is ScatteredKeys, or ReducedKeys once reduced.
536 using KeysType = vtk::keys::DenseKeys<TId>;
537 KeysType ScatteredKeys;
540 const KeysType* BuiltKeys = &this->ScatteredKeys;
541 BuildMode Mode = BuildMode::None;
542 std::unique_ptr<TId[]> CellIds;
543 std::unique_ptr<TSideId[]> SideIds;
544 std::unique_ptr<std::uint8_t[]> Dimensions;
545 std::uint8_t SideDimension = 0;
546
547 // The number of preserved cells, in the last key, in the order of their ids: they are not
548 // scattered, since they are not matched.
549 vtkIdType NumberOfPreservedCells = 0;
550};
551
552VTK_ABI_NAMESPACE_END
553#endif // vtkUnstructuredGridSides_h
554
555#if defined(VTK_UNSTRUCTURED_GRID_SIDES_INSTANTIATING)
556
557#define VTK_UNSTRUCTURED_GRID_SIDES_INSTANTIATE(TId, TSideId) \
558 VTK_ABI_NAMESPACE_BEGIN \
559 template class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGridSides<TId, TSideId>; \
560 VTK_ABI_NAMESPACE_END
561
562// MinGW GCC does not reliably export the inline member functions of vtkTemplateTypeMacro with
563// extern template, see vtkAOSDataArrayTemplate.h.
564#elif defined(VTK_USE_EXTERN_TEMPLATE) && !defined(__MINGW32__)
565
566#ifndef VTK_UNSTRUCTURED_GRID_SIDES_TEMPLATE_EXTERN
567#define VTK_UNSTRUCTURED_GRID_SIDES_TEMPLATE_EXTERN
568#ifdef _MSC_VER
569#pragma warning(push)
570// The following is needed when vtkUnstructuredGridSides is declared dllexport and is used from
571// another class in vtkCommonDataModel.
572#pragma warning(disable : 4910) // extern and dllexport incompatible
573#endif
574VTK_ABI_NAMESPACE_BEGIN
575extern template class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGridSides<vtkTypeInt32, vtkTypeInt8>;
576extern template class VTKCOMMONDATAMODEL_EXPORT
578extern template class VTKCOMMONDATAMODEL_EXPORT vtkUnstructuredGridSides<vtkTypeInt64, vtkTypeInt8>;
579extern template class VTKCOMMONDATAMODEL_EXPORT
581VTK_ABI_NAMESPACE_END
582#ifdef _MSC_VER
583#pragma warning(pop)
584#endif
585#endif // VTK_UNSTRUCTURED_GRID_SIDES_TEMPLATE_EXTERN
586
587#endif
588// VTK-HeaderTest-Exclude: vtkUnstructuredGridSides.h
SideFlags
An enum specifying which side(s) each responder should generate.
SummaryStrategy
An enum specifying the strategy by which input hashes are summarized into output Sides entries.
Detect and break reference loops.
provides thread-safe access to cells
list of point or cell ids
Definition vtkIdList.h:135
a simple class to control print indentation
Definition vtkIndent.h:108
record modification and/or execution time
the sides of the cells of a vtkUnstructuredGrid, matched without cell links
BuildMode
How the sides were built, see GetBuildMode().
bool UsesGarbageCollector() const override
The dataset is reported to the garbage collector, see ReportReferences().
vtkTemplateTypeMacro(SelfType, vtkObject)
vtkIdType GetNumberOfGroups() const
The groups of equal sides, ordered by key: their number, e.g., the number of distinct faces,...
TSideId GetSideIdOfSide(TId keyId, vtkIdType k) const
The cell, the local index in its cell, and the dimension of the side k of a key, 0 <= k < GetNumberOf...
TId GetNumberOfKeys() const
The number of keys: the number of points plus one if some sides are found, otherwise one,...
vtkIdType GetNumberOfSides() const
The number of sides: the kept sides after BuildReducedSides(), all the sides otherwise.
vtkCellGridSidesQuery::SummaryStrategy SummaryStrategy
vtkUnstructuredGridSides< TId, TSideId > SelfType
int GetDimensionOfGroup(vtkIdType group) const
The dimension of the sides of a group, 0 <= group < GetNumberOfGroups(), which all have the same one,...
virtual void SetDataSet(vtkUnstructuredGrid *dataSet)
The dataset whose sides are built, which is referenced.
void GetSidePoints(TId keyId, vtkIdType k, vtkIdList *sidePtIds, unsigned char &cellType, vtkIdList *tempCellPointIds, vtkGenericCell *tempCell) const
Get the point ids of the side k of a key, in the order of the side in its cell, from the cell arrays ...
const TId * GetCellIdsOfKey(TId keyId) const
The cells of the sides of a key, of GetNumberOfSidesOfKey() values, 0 <= keyId < GetNumberOfKeys().
void ReportReferences(vtkGarbageCollector *) override
virtual void SetStrategy(SummaryStrategy)
vtkIdType GetNumberOfSidesOfGroup(vtkIdType group) const
The number of sides of a group, 0 <= group < GetNumberOfGroups(), and its first side,...
~vtkUnstructuredGridSides() override
const TId * GetCellIdsOfGroup(vtkIdType group) const
The cells and the local indices in their cell of the sides of a group, of GetNumberOfSidesOfGroup() v...
vtkIdType GetGroupOffsetOfKey(TId keyId) const
The groups of equal sides, ordered by key: their number, e.g., the number of distinct faces,...
void PrintSelf(ostream &os, vtkIndent indent) override
Methods invoked by print to print information about the object including superclasses.
int GetDimensionOfSide(TId keyId, vtkIdType k) const
The cell, the local index in its cell, and the dimension of the side k of a key, 0 <= k < GetNumberOf...
SideInformation GetSideInformation(TId keyId, vtkIdType k, vtkGenericCell *tempCell) const
The information of the side k of a key, without reading its points: its type and size are given by vt...
const TSideId * GetSideIdsOfKey(TId keyId) const
The local indices of the sides of a key in their cell, of GetNumberOfSidesOfKey() values,...
static SelfType * New()
BuildMode GetBuildMode() const
How the sides were last built, None if they were not, e.g., after Reset().
vtkIdType GetSideOffsetOfGroup(vtkIdType group) const
The number of sides of a group, 0 <= group < GetNumberOfGroups(), and its first side,...
void SetStrategyToBoundary()
Which sides to keep, see BuildReducedSides().
void SetStrategyToWinding()
Which sides to keep, see BuildReducedSides().
void BuildScatteredSides()
Find the sides of the cells given by OutputDimensionControl, and scatter all of them by their key,...
vtkIdType GetNumberOfSidesOfKey(TId keyId) const
The number of sides of a key, as GetNumberOfSides(), 0 <= keyId < GetNumberOfKeys().
virtual void SetStrategy(int strategy)
This method exists for ParaView to set the strategy.
vtkIdType GetSideOffsetOfKey(TId keyId) const
The offset of a key, 0 <= keyId <= GetNumberOfKeys(): the number of sides of the keys before it,...
void Reset()
Release the memory, so that the sides are built again.
void SetStrategyToAnyOccurrence()
Which sides to keep, see BuildReducedSides().
void BuildReducedSides()
Same as BuildScatteredSides(), then match the sides of every key, and keep them as given by the summa...
void BuildGroupedSides()
Same as BuildScatteredSides(), then match the sides of every key, and keep all of them,...
TId GetCellIdOfSide(TId keyId, vtkIdType k) const
The cell, the local index in its cell, and the dimension of the side k of a key, 0 <= k < GetNumberOf...
const TSideId * GetSideIdsOfGroup(vtkIdType group) const
The cells and the local indices in their cell of the sides of a group, of GetNumberOfSidesOfGroup() v...
dataset represents arbitrary combinations of all possible cell types
The dense keys of the elements, returned by ScatterDense(): every key of the key range [GetMinKey(),...
Definition vtkKeys.h:205
The keys of the surviving elements of Reduce(), or of the groups of Group(): the keys of the scattere...
Definition vtkKeys.h:382
The information of a side, see GetSideInformation().
The result of Group(): the groups, and the keys of the groups, i.e., the groups of key id k are [Keys...
Definition vtkKeys.h:477
@ None
!< For HCURL
parallel scatter of elements by key, and operations on the elements of every key
int vtkIdType
Definition vtkType.h:363
#define VTK_ID_MAX
Definition vtkType.h:367
vtkTypeUInt32 vtkMTimeType
Definition vtkType.h:318
#define VTK_DOUBLE_MAX
Definition vtkType.h:202