TTK
Loading...
Searching...
No Matches
CellArray_new.h
Go to the documentation of this file.
1
20
21#ifndef _CELLARRAY_H
22#define _CELLARRAY_H
23
24#include <DataTypes.h>
25
26#include <vector>
27
28#ifndef TTK_ENABLE_KAMIKAZE
29#include <iostream>
30#endif
31
32namespace ttk {
33 // This is not a Debug class as we want to keep it as light as possible
34 class CellArray {
35 public:
36 CellArray(const LongSimplexId *connectivity,
37 const LongSimplexId *offset,
38 const LongSimplexId nbCells)
39 : connectivity_{connectivity}, offset_{offset}, nbCells_{nbCells} {
40 }
41
42 virtual ~CellArray() {
43 if(ownerShip_) {
44 delete[] connectivity_;
45 delete[] offset_;
46 }
47 }
48
50 void setOwnership(const bool o) {
51 ownerShip_ = o;
52 }
53
55 inline LongSimplexId getNbCells() const {
56 return nbCells_;
57 }
58
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 // Connectivity size is nbCell + 1 for last cell
71 return this->offset_[cellId + 1] - this->offset_[cellId];
72 }
79 const SimplexId localVertId) const {
80#ifndef TTK_ENABLE_KAMIKAZE
81 const SimplexId locNbVert = this->getCellVertexNumber(cellId);
82 if(localVertId >= locNbVert) {
83 std::cerr << "TTK: access to local vert " << localVertId << " on "
84 << locNbVert << std::endl;
85 }
86#endif
87 return connectivity_[offset_[cellId] + localVertId];
88 }
89
90 protected:
94 bool ownerShip_ = false;
95 };
96} // namespace ttk
97
98#endif
LongSimplexId getCellVertex(const LongSimplexId cellId, const SimplexId localVertId) const
const LongSimplexId * connectivity_
virtual ~CellArray()
LongSimplexId getNbCells() const
Get the number of cells in the array.
const LongSimplexId * offset_
const LongSimplexId nbCells_
SimplexId getCellVertexNumber(const LongSimplexId cellId) const
CellArray(const LongSimplexId *connectivity, const LongSimplexId *offset, const LongSimplexId nbCells)
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