/usr/include/gmsh/Cell.h is in libgmsh-dev 3.0.6+dfsg1-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | // Gmsh - Copyright (C) 1997-2017 C. Geuzaine, J.-F. Remacle
//
// See the LICENSE.txt file for license information. Please report all
// bugs and problems to the public mailing list <gmsh@onelab.info>.
//
// Contributed by Matti Pellikka <matti.pellikka@gmail.com>.
#ifndef _CELL_H_
#define _CELL_H_
#include <map>
#include <vector>
#include "MElement.h"
class Cell;
class Less_Cell {
public:
bool operator()(const Cell* c1, const Cell* c2) const;
};
// Class to save cell boundary orientation information
class BdInfo {
private:
signed char _ori[2];
public:
BdInfo(int ori) { _ori[0] = ori; _ori[1] = 0; }
int get() const { return _ori[0]; }
void reset() { _ori[0] = _ori[1]; }
void init() { _ori[1] = _ori[0]; }
void set(int ori) { _ori[0] = ori; }
int geto() const { return _ori[1]; }
};
// Class representing an elementary cell of a cell complex.
class Cell {
protected:
static int _globalNum;
int _num;
char _domain;
// whether this cell a combinded cell of elementary cells
bool _combined;
// for some algorithms to omit this cell
bool _immune;
// list of cells on the boundary and on the coboundary of this cell
std::map<Cell*, BdInfo, Less_Cell> _bd;
std::map<Cell*, BdInfo, Less_Cell> _cbd;
Cell() {}
private:
char _dim;
std::vector<MVertex*> _v;
// sorted vertices of this cell (used for ordering of the cells)
std::vector<char> _si;
inline bool _sortVertexIndices();
public:
static std::pair<Cell*, bool> createCell(MElement* element, int domain);
static std::pair<Cell*, bool> createCell(Cell* parent, int i);
Cell(MElement* element, int domain);
Cell(Cell* parent, int i);
virtual ~Cell(){}
int getDomain() const { return _domain; }
void setDomain(int domain) { _domain = domain; }
int getNum() const { return _num; }
void setNum(int num) { _num = num; };
int getTypeMSH() const;
virtual int getDim() const { return _dim; }
bool inSubdomain() const { return _domain ? true : false; }
void getMeshVertices(std::vector<MVertex*>& v) const { v = _v; }
void setImmune(bool immune) { _immune = immune; };
bool getImmune() const { return _immune; };
int getNumSortedVertices() const { return _si.size(); }
inline int getSortedVertex(int vertex) const;
int getNumVertices() const { return _v.size(); }
MVertex* getMeshVertex(int vertex) const { return _v.at(vertex); }
void findBdElement(int i, std::vector<MVertex*>& vertices) const;
int getNumBdElements() const;
int findBdCellOrientation(Cell* cell, int i) const;
void increaseGlobalNum() { _globalNum++; }
// save/restore the original boundary information of the cell
void saveCellBoundary();
void restoreCellBoundary();
// true if this cell has given vertex
virtual bool hasVertex(int vertex) const;
// (co)boundary cell iterator
typedef std::map<Cell*, BdInfo, Less_Cell>::iterator biter;
// iterators to (first/last (co)boundary cells of this cell
// (orig: to original (co)boundary cells of this cell)
biter firstBoundary(bool orig=false);
biter lastBoundary();
biter firstCoboundary(bool orig=false);
biter lastCoboundary();
int getBoundarySize(bool orig=false);
int getCoboundarySize(bool orig=false);
// get the (orig: original) cell boundary
void getBoundary(std::map<Cell*, short int, Less_Cell>& boundary,
bool orig=false);
void getCoboundary(std::map<Cell*, short int, Less_Cell>& coboundary,
bool orig=false);
// add (co)boundary cell
// (other: reciprocally also add this cell from the other cell's (co)boundary)
void addBoundaryCell(int orientation, Cell* cell, bool other);
void addCoboundaryCell(int orientation, Cell* cell, bool other);
// remove (co)boundary cell
// (other: reciprocally also revove this cell from the other cell's (co)boundary)
void removeBoundaryCell(Cell* cell, bool other);
void removeCoboundaryCell(Cell* cell, bool other);
// true if has given cell on (orig: original) (co)boundary
bool hasBoundary(Cell* cell, bool orig=false);
bool hasCoboundary(Cell* cell, bool orig=false);
// print cell debug info
virtual void printCell();
virtual void printBoundary();
virtual void printCoboundary();
// tools for combined cells
bool isCombined() const { return _combined; }
typedef std::map<Cell*, int, Less_Cell>::iterator citer;
virtual void getCells(std::map<Cell*, int, Less_Cell>& cells) {
cells.clear();
cells[this] = 1;
}
virtual int getNumCells() const { return 1; }
bool operator==(const Cell& c2) const {
return (this->getNum() == c2.getNum());
}
};
// A cell that is a combination of cells of same dimension
class CombinedCell : public Cell{
private:
// list of cells this cell is a combination of
std::map< Cell*, int, Less_Cell > _cells;
public:
CombinedCell(Cell* c1, Cell* c2, bool orMatch, bool co=false);
CombinedCell(std::vector<Cell*>& cells);
~CombinedCell() {}
int getDim() const { return _cells.begin()->first->getDim(); }
void getCells(std::map< Cell*, int, Less_Cell >& cells) { cells = _cells; }
int getNumCells() const {return _cells.size();}
bool hasVertex(int vertex) const;
bool operator==(const Cell& c2) const {
return (this->getNum() == c2.getNum());
}
};
#endif
|