Go to the documentation of this file.
10 #ifndef vtk_m_cont_CellSetSingleType_h
11 #define vtk_m_cont_CellSetSingleType_h
39 template <
typename ConnectivityStorageTag = VTKM_DEFAULT_CONNECTIVITY_STORAGE_TAG>
42 typename vtkm::cont::ArrayHandleConstant<vtkm::UInt8>::StorageTag,
43 ConnectivityStorageTag,
44 typename vtkm::cont::ArrayHandleCounting<vtkm::Id>::StorageTag
50 ConnectivityStorageTag,
57 , ExpectedNumberOfCellsAdded(-1)
59 , NumberOfPointsPerCell(0)
66 , ExpectedNumberOfCellsAdded(-1)
67 , CellShapeAsId(src.CellShapeAsId)
68 , NumberOfPointsPerCell(src.NumberOfPointsPerCell)
75 , ExpectedNumberOfCellsAdded(-1)
76 , CellShapeAsId(src.CellShapeAsId)
77 , NumberOfPointsPerCell(src.NumberOfPointsPerCell)
85 this->Superclass::operator=(src);
94 this->Superclass::operator=(std::forward<Superclass>(src));
95 this->CellShapeAsId = src.CellShapeAsId;
96 this->NumberOfPointsPerCell = src.NumberOfPointsPerCell;
110 this->Data->CellPointIds.Connectivity.Allocate(connectivityMaxLen);
112 this->Data->NumberOfCellsAdded = 0;
113 this->Data->ConnectivityAdded = 0;
114 this->ExpectedNumberOfCellsAdded = numCells;
120 template <
typename IdVecType>
125 "CellSetSingleType::AddCell requires vtkm::Id for indices.");
127 if (Traits::GetNumberOfComponents(ids) < numVertices)
132 if (this->Data->ConnectivityAdded + numVertices >
133 this->Data->CellPointIds.Connectivity.GetNumberOfValues())
136 "Connectivity increased past estimated maximum connectivity.");
145 this->CellShapeAsId = shapeId;
146 this->CheckNumberOfPointsPerCell(numVertices);
147 this->NumberOfPointsPerCell = numVertices;
151 if (shapeId != this->GetCellShape(0))
155 if (numVertices != this->NumberOfPointsPerCell)
158 "Inconsistent number of points in cells for CellSetSingleType.");
161 auto conn = this->Data->CellPointIds.Connectivity.WritePortal();
164 conn.Set(this->Data->ConnectivityAdded + iVert, Traits::GetComponent(ids, iVert));
166 this->Data->NumberOfCellsAdded++;
167 this->Data->ConnectivityAdded += numVertices;
173 this->Data->NumberOfPoints = numPoints;
174 this->Data->CellPointIds.Connectivity.Allocate(this->Data->ConnectivityAdded,
177 vtkm::Id numCells = this->Data->NumberOfCellsAdded;
179 this->Data->CellPointIds.Shapes =
184 this->Data->CellPointIds.ElementsValid =
true;
186 if (this->ExpectedNumberOfCellsAdded != this->GetNumberOfCells())
191 this->Data->NumberOfCellsAdded = -1;
192 this->Data->ConnectivityAdded = -1;
193 this->ExpectedNumberOfCellsAdded = -1;
205 this->Data->NumberOfPoints = numPoints;
206 this->CellShapeAsId = shapeId;
207 this->CheckNumberOfPointsPerCell(numberOfPointsPerCell);
217 this->Data->CellPointIds.Connectivity = connectivity;
219 this->Data->CellPointIds.ElementsValid =
true;
231 return static_cast<vtkm::UInt8>(this->CellShapeAsId);
238 return std::make_shared<CellSetSingleType>();
250 this->Superclass::DeepCopy(other);
251 this->CellShapeAsId = other->CellShapeAsId;
252 this->NumberOfPointsPerCell = other->NumberOfPointsPerCell;
257 out <<
" CellSetSingleType: Type=" << this->CellShapeAsId << std::endl;
258 out <<
" CellPointIds:" << std::endl;
259 this->Data->CellPointIds.PrintSummary(out);
260 out <<
" PointCellIds:" << std::endl;
261 this->Data->PointCellIds.PrintSummary(out);
265 template <
typename CellShapeTag>
276 template <
typename CellShapeTag>
288 switch (this->CellShapeAsId)
312 template <
typename ConnectivityST>
313 struct SerializableTypeString<
vtkm::cont::CellSetSingleType<ConnectivityST>>
317 static std::string name =
"CS_Single<" +
318 SerializableTypeString<vtkm::cont::ArrayHandle<vtkm::Id, ConnectivityST>>
::Get() +
"_ST>";
329 template <
typename ConnectivityST>
330 struct Serialization<
vtkm::cont::CellSetSingleType<ConnectivityST>>
336 static VTKM_CONT void save(BinaryBuffer& bb,
const Type& cs)
338 vtkmdiy::save(bb, cs.GetNumberOfPoints());
339 vtkmdiy::save(bb, cs.GetCellShape(0));
340 vtkmdiy::save(bb, cs.GetNumberOfPointsInCell(0));
357 cs.Fill(numberOfPoints, shape, count, connectivity);
364 #endif //vtk_m_cont_CellSetSingleType_h
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:34
Manages an array-worth of data.
Definition: ArrayHandle.h:300
void Fill(vtkm::Id numPoints, vtkm::UInt8 shapeId, vtkm::IdComponent numberOfPointsPerCell, const vtkm::cont::ArrayHandle< vtkm::Id, ConnectivityStorageTag > &connectivity)
Set all the cells of the mesh.
Definition: CellSetSingleType.h:200
T load(const U &u, vtkm::Id v)
Definition: FetchTagArrayDirectIn.h:36
Groups connected points that have the same field value.
Definition: Atomic.h:19
CellSetSingleType()
Definition: CellSetSingleType.h:55
auto Get(const vtkm::Tuple< Ts... > &tuple)
Retrieve the object from a vtkm::Tuple at the given index.
Definition: Tuple.h:81
#define VTKM_ASSERT(condition)
Definition: Assert.h:43
vtkm::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:194
void DeepCopy(const CellSet *src) override
Definition: CellSetSingleType.h:242
vtkm::Id CellShapeAsId
Definition: CellSetSingleType.h:298
CellSetSingleType(Thisclass &&src) noexcept
Definition: CellSetSingleType.h:73
An explicit cell set with all cells of the same shape.
Definition: CastAndCall.h:34
vtkm::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:468
vtkm::cont::ArrayHandleConstant< T > make_ArrayHandleConstant(T value, vtkm::Id numberOfValues)
make_ArrayHandleConstant is convenience function to generate an ArrayHandleImplicit.
Definition: ArrayHandleConstant.h:95
void CompleteAddingCells(vtkm::Id numPoints)
Finish adding cells one at a time.
Definition: CellSetSingleType.h:171
@ CELL_SHAPE_EMPTY
Placeholder for empty or invalid cells.
Definition: CellShape.h:37
vtkm::UInt8 GetCellShape(vtkm::Id) const override
Definition: CellSetSingleType.h:229
This class is thrown when VTK-m encounters data of a type that is incompatible with the current opera...
Definition: ErrorBadType.h:25
vtkm::cont::ArrayHandleCounting< CountingValueType > make_ArrayHandleCounting(CountingValueType start, CountingValueType step, vtkm::Id length)
A convenience function for creating an ArrayHandleCounting.
Definition: ArrayHandleCounting.h:154
Definition: Particle.h:351
#define VTKM_DEPRECATED_SUPPRESS_END
Definition: Deprecated.h:123
void AddCell(vtkm::UInt8 shapeId, vtkm::IdComponent numVertices, const IdVecType &ids)
Add a cell.
Definition: CellSetSingleType.h:121
#define vtkmGenericCellShapeMacro(call)
A macro used in a switch statement to determine cell shape.
Definition: CellShape.h:250
vtkm::Id ExpectedNumberOfCellsAdded
Definition: CellSetSingleType.h:297
void CheckNumberOfPointsPerCell(CellShapeTag, vtkm::CellTraitsTagSizeVariable, vtkm::IdComponent) const
Definition: CellSetSingleType.h:277
void CheckNumberOfPointsPerCell(CellShapeTag, vtkm::CellTraitsTagSizeFixed, vtkm::IdComponent numVertices) const
Definition: CellSetSingleType.h:266
vtkm::Id GetCellShapeAsId() const
Definition: CellSetSingleType.h:225
#define VTKM_STATIC_ASSERT_MSG(condition, message)
Definition: StaticAssert.h:18
void PrintSummary(std::ostream &out) const override
Definition: CellSetSingleType.h:255
~CellSetSingleType() override
Definition: CellSetSingleType.h:100
vtkm::IdComponent NumberOfPointsPerCell
Definition: CellSetSingleType.h:299
#define VTKM_CONT
Definition: ExportMacros.h:57
vtkm::Int64 Id
Base type to use to index arrays.
Definition: Types.h:227
Defines the topological structure of the data in a DataSet.
Definition: CellSet.h:28
void PrepareToAddCells(vtkm::Id numCells, vtkm::Id connectivityMaxLen)
Start adding cells one at a time.
Definition: CellSetSingleType.h:106
Definition: CellShape.h:147
Thisclass & operator=(const Thisclass &src)
Definition: CellSetSingleType.h:83
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:169
#define vtkmNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:128
#define VTKM_DEPRECATED_SUPPRESS_BEGIN
Definition: Deprecated.h:122
void CheckNumberOfPointsPerCell(vtkm::IdComponent numVertices) const
Definition: CellSetSingleType.h:286
This class is thrown when a VTKm function or method encounters an invalid value that inhibits progres...
Definition: ErrorBadValue.h:25
Defines an irregular collection of cells.
Definition: CastAndCall.h:36
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:24
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:61
Thisclass & operator=(Thisclass &&src) noexcept
Definition: CellSetSingleType.h:92
#define VTKM_ALWAYS_EXPORT
Definition: ExportMacros.h:89
CellSetSingleType(const Thisclass &src)
Definition: CellSetSingleType.h:64
typename Superclass::StorageTag StorageTag
Definition: ArrayHandleCounting.h:136
std::shared_ptr< CellSet > NewInstance() const override
Definition: CellSetSingleType.h:236
Information about a cell based on its tag.
Definition: CellTraits.h:46