TTK
Loading...
Searching...
No Matches
CellArray_legacy.h
Go to the documentation of this file.
1
16
17#ifndef _CELLARRAY_H
18#define _CELLARRAY_H
19
20#include <DataTypes.h>
21
22#include <vector>
23
24#ifndef TTK_ENABLE_KAMIKAZE
25#include <iostream>
26#endif
27
28namespace ttk {
29
30 // This is not a Debug class as we want to keep it as light as possible
31 class CellArray {
32 public:
33 CellArray(const LongSimplexId *cellArray,
34 const LongSimplexId nbCells,
35 const unsigned char dimension)
36 : cellArray_{cellArray}, nbCells_{nbCells}, dimension_{dimension} {
37 }
38
39 virtual ~CellArray() {
40 if(ownerShip_) {
41 delete[] cellArray_;
42 }
43 }
44
46 void setOwnership(const bool o) {
47 ownerShip_ = o;
48 }
49
51 inline unsigned char getDimension() const {
52 return dimension_;
53 }
54
56 inline LongSimplexId getNbCells() const {
57 return nbCells_;
58 }
59
63 inline SimplexId getCellVertexNumber(const LongSimplexId cellId) const {
64#ifndef TTK_ENABLE_KAMIKAZE
65 if(cellId >= this->nbCells_) {
66 std::cerr << "TTK: access to cell " << cellId << " on "
67 << this->nbCells_ << std::endl;
68 }
69#endif
70 // WARNING: ASSUME Regular Mesh here
71 return this->dimension_ + 1;
72 }
79 const SimplexId localVertId) const {
80 const SimplexId locNbVert = this->getCellVertexNumber(cellId);
81#ifndef TTK_ENABLE_KAMIKAZE
82 if(localVertId >= locNbVert) {
83 std::cerr << "TTK: access to local vert " << localVertId << " on "
84 << locNbVert << std::endl;
85 }
86#endif
87 // Assume VTK < 9 layout and uniform mesh (only one type of cells)
88 return this->cellArray_[(locNbVert + 1) * cellId + 1 + localVertId];
89 }
90
91 static void TranslateToFlatLayout(std::vector<LongSimplexId> &connectivity,
92 std::vector<LongSimplexId> &offset,
93 LongSimplexId *&singleArray);
94
95 protected:
98 const unsigned char dimension_;
99 bool ownerShip_ = false;
100 };
101} // namespace ttk
102
103#endif
CellArray generic array of cells
LongSimplexId getCellVertex(const LongSimplexId cellId, const SimplexId localVertId) const
const LongSimplexId * cellArray_
const unsigned char dimension_
LongSimplexId getNbCells() const
Get the number of cells in the array.
CellArray(const LongSimplexId *cellArray, const LongSimplexId nbCells, const unsigned char dimension)
const LongSimplexId nbCells_
SimplexId getCellVertexNumber(const LongSimplexId cellId) const
static void TranslateToFlatLayout(std::vector< LongSimplexId > &connectivity, std::vector< LongSimplexId > &offset, LongSimplexId *&singleArray)
unsigned char getDimension() const
Retrieve the dimension.
void setOwnership(const bool o)
Deal with data ownership.
The Topology ToolKit.
long long int LongSimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:15
int SimplexId
Identifier type for simplices of any dimension.
Definition DataTypes.h:22