Go to the documentation of this file.
18 #ifndef viskores_cont_CellSetSingleType_h
19 #define viskores_cont_CellSetSingleType_h
47 template <
typename ConnectivityStorageTag = VISKORES_DEFAULT_CONNECTIVITY_STORAGE_TAG>
48 class VISKORES_ALWAYS_EXPORT CellSetSingleType
50 typename viskores::cont::ArrayHandleConstant<viskores::UInt8>::StorageTag,
51 ConnectivityStorageTag,
52 typename viskores::cont::ArrayHandleCounting<viskores::Id>::StorageTag
58 ConnectivityStorageTag,
65 , ExpectedNumberOfCellsAdded(-1)
67 , NumberOfPointsPerCell(0)
74 , ExpectedNumberOfCellsAdded(-1)
75 , CellShapeAsId(src.CellShapeAsId)
76 , NumberOfPointsPerCell(src.NumberOfPointsPerCell)
83 , ExpectedNumberOfCellsAdded(-1)
84 , CellShapeAsId(src.CellShapeAsId)
85 , NumberOfPointsPerCell(src.NumberOfPointsPerCell)
93 this->Superclass::operator=(src);
102 this->Superclass::operator=(std::forward<Superclass>(src));
103 this->CellShapeAsId = src.CellShapeAsId;
104 this->NumberOfPointsPerCell = src.NumberOfPointsPerCell;
118 this->Data->CellPointIds.Connectivity.Allocate(connectivityMaxLen);
120 this->Data->NumberOfCellsAdded = 0;
121 this->Data->ConnectivityAdded = 0;
122 this->ExpectedNumberOfCellsAdded = numCells;
128 template <
typename IdVecType>
131 const IdVecType& ids)
135 "CellSetSingleType::AddCell requires viskores::Id for indices.");
137 if (Traits::GetNumberOfComponents(ids) < numVertices)
140 "Not enough indices given to CellSetSingleType::AddCell.");
143 if (this->Data->ConnectivityAdded + numVertices >
144 this->Data->CellPointIds.Connectivity.GetNumberOfValues())
147 "Connectivity increased past estimated maximum connectivity.");
156 this->CellShapeAsId = shapeId;
157 this->CheckNumberOfPointsPerCell(numVertices);
158 this->NumberOfPointsPerCell = numVertices;
162 if (shapeId != this->GetCellShape(0))
166 if (numVertices != this->NumberOfPointsPerCell)
169 "Inconsistent number of points in cells for CellSetSingleType.");
172 auto conn = this->Data->CellPointIds.Connectivity.WritePortal();
175 conn.Set(this->Data->ConnectivityAdded + iVert, Traits::GetComponent(ids, iVert));
177 this->Data->NumberOfCellsAdded++;
178 this->Data->ConnectivityAdded += numVertices;
184 this->Data->NumberOfPoints = numPoints;
185 this->Data->CellPointIds.Connectivity.Allocate(this->Data->ConnectivityAdded,
190 this->Data->CellPointIds.Shapes =
195 this->Data->CellPointIds.ElementsValid =
true;
197 if (this->ExpectedNumberOfCellsAdded != this->GetNumberOfCells())
202 this->Data->NumberOfCellsAdded = -1;
203 this->Data->ConnectivityAdded = -1;
204 this->ExpectedNumberOfCellsAdded = -1;
217 this->Data->NumberOfPoints = numPoints;
218 this->CellShapeAsId = shapeId;
219 this->CheckNumberOfPointsPerCell(numberOfPointsPerCell);
229 this->Data->CellPointIds.Connectivity = connectivity;
231 this->Data->CellPointIds.ElementsValid =
true;
250 return std::make_shared<CellSetSingleType>();
262 this->Superclass::DeepCopy(other);
263 this->CellShapeAsId = other->CellShapeAsId;
264 this->NumberOfPointsPerCell = other->NumberOfPointsPerCell;
269 out <<
" CellSetSingleType: Type=" << this->CellShapeAsId << std::endl;
270 out <<
" CellPointIds:" << std::endl;
271 this->Data->CellPointIds.PrintSummary(out);
272 out <<
" PointCellIds:" << std::endl;
273 this->Data->PointCellIds.PrintSummary(out);
277 template <
typename CellShapeTag>
288 template <
typename CellShapeTag>
300 switch (this->CellShapeAsId)
324 template <
typename ConnectivityST>
325 struct SerializableTypeString<
viskores::cont::CellSetSingleType<ConnectivityST>>
329 static std::string name =
"CS_Single<" +
330 SerializableTypeString<viskores::cont::ArrayHandle<viskores::Id, ConnectivityST>>
::Get() +
342 template <
typename ConnectivityST>
343 struct Serialization<
viskores::cont::CellSetSingleType<ConnectivityST>>
349 static VISKORES_CONT void save(BinaryBuffer& bb,
const Type& cs)
351 viskoresdiy::save(bb, cs.GetNumberOfPoints());
352 viskoresdiy::save(bb, cs.GetCellShape(0));
353 viskoresdiy::save(bb, cs.GetNumberOfPointsInCell(0));
354 viskoresdiy::save(bb,
371 cs.Fill(numberOfPoints, shape, count, connectivity);
378 #endif //viskores_cont_CellSetSingleType_h
void CheckNumberOfPointsPerCell(CellShapeTag, viskores::CellTraitsTagSizeFixed, viskores::IdComponent numVertices) const
Definition: CellSetSingleType.h:278
T load(const U &u, viskores::Id v)
Definition: FetchTagArrayDirectIn.h:44
CellSetSingleType()
Definition: CellSetSingleType.h:63
viskores::Id ExpectedNumberOfCellsAdded
Definition: CellSetSingleType.h:309
viskores::IdComponent NumberOfPointsPerCell
Definition: CellSetSingleType.h:311
A tag used to identify the cell elements in a topology.
Definition: TopologyElementTag.h:32
void DeepCopy(const CellSet *src) override
Definition: CellSetSingleType.h:254
This class is thrown when Viskores encounters data of a type that is incompatible with the current op...
Definition: ErrorBadType.h:33
viskores::UInt8 GetCellShape(viskores::Id) const override
Definition: CellSetSingleType.h:241
Thisclass & operator=(const Thisclass &src)
Definition: CellSetSingleType.h:91
#define viskoresNotUsed(parameter_name)
Simple macro to identify a parameter as unused.
Definition: ExportMacros.h:136
#define viskoresGenericCellShapeMacro(call)
A macro used in a switch statement to determine cell shape.
Definition: CellShape.h:257
viskores::Id GetCellShapeAsId() const
Definition: CellSetSingleType.h:237
Manages an array-worth of data.
Definition: ArrayHandle.h:313
viskores::Int32 IdComponent
Base type to use to index small lists.
Definition: Types.h:202
viskores::cont::ArrayHandleConstant< T > make_ArrayHandleConstant(T value, viskores::Id numberOfValues)
make_ArrayHandleConstant is convenience function to generate an ArrayHandleImplicit.
Definition: ArrayHandleConstant.h:105
CellSetSingleType(Thisclass &&src) noexcept
Definition: CellSetSingleType.h:81
Definition: Particle.h:373
void AddCell(viskores::UInt8 shapeId, viskores::IdComponent numVertices, const IdVecType &ids)
Add a cell.
Definition: CellSetSingleType.h:129
~CellSetSingleType() override
Definition: CellSetSingleType.h:108
typename Superclass::StorageTag StorageTag
Definition: ArrayHandleConstant.h:85
CellSetSingleType(const Thisclass &src)
Definition: CellSetSingleType.h:72
A tag used to identify the point elements in a topology.
Definition: TopologyElementTag.h:42
Definition: CellShape.h:155
viskores::Int64 Id
Base type to use to index arrays.
Definition: Types.h:235
viskores::cont::ArrayHandleCounting< CountingValueType > make_ArrayHandleCounting(CountingValueType start, CountingValueType step, viskores::Id length)
A convenience function for creating an ArrayHandleCounting.
Definition: ArrayHandleCounting.h:165
#define VISKORES_CONT
Definition: ExportMacros.h:65
Groups connected points that have the same field value.
Definition: Atomic.h:27
Traits that can be queried to treat any type as a Vec.
Definition: VecTraits.h:69
Defines an irregular collection of cells.
Definition: CastAndCall.h:44
viskores::Id GetNumberOfValues() const
Returns the number of entries in the array.
Definition: ArrayHandle.h:482
Information about a cell based on its tag.
Definition: CellTraits.h:54
#define VISKORES_ASSERT(condition)
Definition: Assert.h:51
@ CELL_SHAPE_EMPTY
Placeholder for empty or invalid cells.
Definition: CellShape.h:45
void CheckNumberOfPointsPerCell(viskores::IdComponent numVertices) const
Definition: CellSetSingleType.h:298
std::shared_ptr< CellSet > NewInstance() const override
Definition: CellSetSingleType.h:248
#define VISKORES_DEPRECATED_SUPPRESS_END
Definition: Deprecated.h:132
void PrintSummary(std::ostream &out) const override
Definition: CellSetSingleType.h:267
#define VISKORES_STATIC_ASSERT_MSG(condition, message)
Definition: StaticAssert.h:26
viskores::Id CellShapeAsId
Definition: CellSetSingleType.h:310
uint8_t UInt8
Base type to use for 8-bit unsigned integer numbers.
Definition: Types.h:177
This class is thrown when a Viskores function or method encounters an invalid value that inhibits pro...
Definition: ErrorBadValue.h:33
typename Superclass::StorageTag StorageTag
Definition: ArrayHandleCounting.h:147
void PrepareToAddCells(viskores::Id numCells, viskores::Id connectivityMaxLen)
Start adding cells one at a time.
Definition: CellSetSingleType.h:114
void Fill(viskores::Id numPoints, viskores::UInt8 shapeId, viskores::IdComponent numberOfPointsPerCell, const viskores::cont::ArrayHandle< viskores::Id, ConnectivityStorageTag > &connectivity)
Set all the cells of the mesh.
Definition: CellSetSingleType.h:211
An explicit cell set with all cells of the same shape.
Definition: CastAndCall.h:42
auto Get(const viskores::Tuple< Ts... > &tuple)
Retrieve the object from a viskores::Tuple at the given index.
Definition: Tuple.h:89
void CompleteAddingCells(viskores::Id numPoints)
Finish adding cells one at a time.
Definition: CellSetSingleType.h:182
Defines the topological structure of the data in a DataSet.
Definition: CellSet.h:36
void CheckNumberOfPointsPerCell(CellShapeTag, viskores::CellTraitsTagSizeVariable, viskores::IdComponent) const
Definition: CellSetSingleType.h:289
Thisclass & operator=(Thisclass &&src) noexcept
Definition: CellSetSingleType.h:100
#define VISKORES_DEPRECATED_SUPPRESS_BEGIN
Definition: Deprecated.h:131