Version: 9.16.0
SMDS_Downward.hxx
Go to the documentation of this file.
1// Copyright (C) 2010-2026 CEA, EDF, OPEN CASCADE
2//
3// This library is free software; you can redistribute it and/or
4// modify it under the terms of the GNU Lesser General Public
5// License as published by the Free Software Foundation; either
6// version 2.1 of the License, or (at your option) any later version.
7//
8// This library is distributed in the hope that it will be useful,
9// but WITHOUT ANY WARRANTY; without even the implied warranty of
10// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11// Lesser General Public License for more details.
12//
13// You should have received a copy of the GNU Lesser General Public
14// License along with this library; if not, write to the Free Software
15// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16//
17// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18//
19
20// File: SMDS_Downward.hxx
21// Created: Jun 3, 2010
22// Author: prascle
23
24#ifndef SMDS_DOWNWARD_HXX_
25#define SMDS_DOWNWARD_HXX_
26
28
29#include <vector>
30#include <set>
31
32typedef struct
33{
34 int nodeIds[8];
36 unsigned char vtkType;
37} ElemByNodesType; // TODO resize for polyhedrons
38
39typedef struct
40{
41 ElemByNodesType elems[6];
43} ListElemByNodesType; // TODO resize for polyhedrons
44
46{
47public:
48 DownIdType(int a, unsigned char b) :
49 cellId(a), cellType(b)
50 {
51 }
52 int cellId;
53 unsigned char cellType;
54};
55
57{
58 bool operator ()(const DownIdType e1, const DownIdType e2) const
59 {
60 if (e1.cellId == e2.cellId)
61 return (e1.cellType < e2.cellType);
62 else
63 return (e1.cellId < e2.cellId);
64 }
65};
66
68{
70 friend class SMDS_Down2D;
71 friend class SMDS_Down3D;
72public:
73 virtual int getNumberOfDownCells(int cellId);
74 virtual const int* getDownCells(int cellId);
75 virtual const unsigned char* getDownTypes(int cellId);
76 virtual int getNumberOfUpCells(int cellId) = 0;
77 virtual const int* getUpCells(int cellId) = 0;
78 virtual const unsigned char* getUpTypes(int cellId) = 0;
79 virtual void getNodeIds(int cellId, std::set<int>& nodeSet) = 0;
80 virtual int getNodes(int /*cellId*/, int* /*nodevec*/) {return 0; }
81 virtual void getOrderedNodesOfFace(int /*cellId*/, std::vector<vtkIdType>& /*orderedNodes*/) {};
82 int getVtkCellId(int cellId)
83 {
84 return _vtkCellIds[cellId];
85 }
87 {
88 return _maxId;
89 }
90 static int getCellDimension(unsigned char cellType);
91protected:
92 SMDS_Downward(SMDS_UnstructuredGrid *grid, int nbDownCells);
93 virtual ~SMDS_Downward();
94 int addCell(int vtkId = -1);
95 virtual void initCell(int cellId);
96 virtual void allocate(int nbElems) = 0;
97 virtual void compactStorage() = 0;
98 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
99 virtual void addUpCell(int cellId, int upCellId, unsigned char aType);
100 virtual int getNodeSet(int cellId, int* nodeSet);
101
105 std::vector<int> _cellIds;
106 std::vector<int> _vtkCellIds;
107 std::vector<unsigned char> _cellTypes;
108
109 static std::vector<int> _cellDimension;
110};
111
113{
115public:
116 virtual int getNumberOfUpCells(int cellId);
117 virtual const int* getUpCells(int cellId);
118 virtual const unsigned char* getUpTypes(int cellId);
119 virtual void getNodeIds(int cellId, std::set<int>& nodeSet);
120 virtual int getNodes(int cellId, int* nodevec) { return getNodeSet(cellId, nodevec); }
121protected:
122 SMDS_Down1D(SMDS_UnstructuredGrid *grid, int nbDownCells);
123 ~SMDS_Down1D();
124 virtual void initCell(int cellId);
125 virtual void allocate(int nbElems);
126 virtual void compactStorage();
127 virtual void addUpCell(int cellId, int upCellId, unsigned char aType);
128 virtual int getNodeSet(int cellId, int* nodeSet);
129 void setNodes(int cellId, int vtkId);
130 void setNodes(int cellId, const int* nodeIds);
131 int computeVtkCells(int cellId, std::vector<int>& vtkIds);
132 int computeVtkCells(int* pts, std::vector<int>& vtkIds);
133 int computeFaces(int cellId, int* vtkIds, int nbcells, int* downFaces, unsigned char* downTypes);
134 int computeFaces(int* pts, int* vtkIds, int nbcells, int* downFaces, unsigned char* downTypes);
135
136 std::vector<std::vector<int> > _upCellIdsVector;
137 std::vector<std::vector<unsigned char> > _upCellTypesVector;
138 std::vector<int> _upCellIds;
139 std::vector<unsigned char> _upCellTypes;
140 std::vector<int> _upCellIndex;
141};
142
144{
146 friend class SMDS_Down1D;
147public:
148 virtual int getNumberOfUpCells(int cellId);
149 virtual const int* getUpCells(int cellId);
150 virtual const unsigned char* getUpTypes(int cellId);
151 virtual void getNodeIds(int cellId, std::set<int>& nodeSet);
152protected:
153 SMDS_Down2D(SMDS_UnstructuredGrid *grid, int nbDownCells);
154 ~SMDS_Down2D();
155 virtual void allocate(int nbElems);
156 virtual void compactStorage();
157 virtual void addUpCell(int cellId, int upCellId, unsigned char aType);
158 virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& facesWithNodes) = 0;
159 virtual int getNodeSet(int cellId, int* nodeSet);
160 int computeVolumeIds(int cellId, int* ids);
161 int computeVolumeIds(ElemByNodesType& faceByNodes, int* ids);
162 int computeVolumeIdsFromNodesFace(int* nodes, int nbNodes, int* ids);
163 void setTempNodes(int cellId, int vtkId);
164 void setTempNodes(int cellId, ElemByNodesType& faceByNodes);
165 bool isInFace(int cellId, int *pts, int npts);
166 int FindEdgeByNodes(int cellId, ElemByNodesType& edgeByNodes);
167 int FindEdgeByNodesSet(int cellId, int* nodeSetToFind, int vtkEdgeType);
168
169 std::vector<int> _upCellIds;
170 std::vector<unsigned char> _upCellTypes;
171 std::vector<int> _tempNodes;
173};
174
176{
178public:
179 virtual int getNumberOfUpCells(int cellId);
180 virtual const int* getUpCells(int cellId);
181 virtual const unsigned char* getUpTypes(int cellId);
182 virtual void getNodeIds(int cellId, std::set<int>& nodeSet);
183protected:
184 SMDS_Down3D(SMDS_UnstructuredGrid *grid, int nbDownCells);
185 ~SMDS_Down3D();
186 virtual void allocate(int nbElems);
187 virtual void compactStorage();
188 virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes) = 0;
189 int FindFaceByNodes(int cellId, ElemByNodesType& faceByNodes);
190};
191
193{
195public:
196protected:
199};
200
202{
204public:
205protected:
208};
209
211{
213public:
214protected:
217 virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
218 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
219};
220
222{
224public:
225protected:
228 virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
229 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
230};
231
233{
235public:
236protected:
239 virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
240 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
241};
242
244{
246public:
247protected:
250 virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
251 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
252};
253
254//class SMDS_DownPolygon: public SMDS_Down2D
255//{
256//public:
257// SMDS_DownPolygon(SMDS_UnstructuredGrid *grid);
258// ~SMDS_DownPolygon();
259//protected:
260//};
261
262//class SMDS_DownQuadPolygon: public SMDS_Down2D
263//{
264//public:
265// SMDS_DownQuadPolygon(SMDS_UnstructuredGrid *grid);
266// ~SMDS_DownQuadPolygon();
267//protected:
268//};
269
271{
273public:
274 virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
275protected:
278 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
279 virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
280};
281
283{
285public:
286 virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
287protected:
290 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
291 virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
292};
293
295{
297public:
298 virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
299protected:
302 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
303 virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
304};
305
307{
309public:
310 virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
311protected:
314 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
315 virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
316};
317
319{
321public:
322 virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
323protected:
326 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
327 virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
328};
329
331{
333public:
334 virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
335protected:
338 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
339 virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
340};
341
343{
345public:
346 virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
347protected:
350 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
351 virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
352};
353
355{
357public:
358 virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
359protected:
362 virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
363 virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
364};
365
366//class SMDS_DownPolyhedra: public SMDS_Down3D
367//{
368//public:
369// SMDS_DownPolyhedra(SMDS_UnstructuredGrid *grid);
370// ~SMDS_DownPolyhedra();
371//protected:
372//};
373
374//class SMDS_DownQuadPolyhedra: public SMDS_Down3D
375//{
376//public:
377// SMDS_DownQuadPolyhedra(SMDS_UnstructuredGrid *grid);
378// ~SMDS_DownQuadPolyhedra();
379//protected:
380//};
381
382#endif /* SMDS_DOWNWARD_HXX_ */
#define SMDS_EXPORT
Definition: SMESH_SMDS.hxx:37
Definition: SMDS_Downward.hxx:46
DownIdType(int a, unsigned char b)
Definition: SMDS_Downward.hxx:48
unsigned char cellType
Definition: SMDS_Downward.hxx:53
int cellId
Definition: SMDS_Downward.hxx:52
Definition: SMDS_Downward.hxx:113
std::vector< std::vector< unsigned char > > _upCellTypesVector
the number of faces sharing an edge is not known
Definition: SMDS_Downward.hxx:137
virtual void allocate(int nbElems)
Resize the downward connectivity storage vector if needed.
Definition: SMDS_Downward.cxx:220
std::vector< std::vector< int > > _upCellIdsVector
the number of faces sharing an edge is not known
Definition: SMDS_Downward.hxx:136
virtual const unsigned char * getUpTypes(int cellId)
Definition: SMDS_Downward.cxx:286
virtual void compactStorage()
Definition: SMDS_Downward.cxx:231
virtual void addUpCell(int cellId, int upCellId, unsigned char aType)
Id's are downward connectivity id's.
Definition: SMDS_Downward.cxx:259
std::vector< int > _upCellIndex
compacted storage after connectivity calculation
Definition: SMDS_Downward.hxx:140
virtual int getNodes(int cellId, int *nodevec)
Definition: SMDS_Downward.hxx:120
virtual void getNodeIds(int cellId, std::set< int > &nodeSet)
Definition: SMDS_Downward.cxx:292
std::vector< int > _upCellIds
compacted storage after connectivity calculation
Definition: SMDS_Downward.hxx:138
virtual const int * getUpCells(int cellId)
Definition: SMDS_Downward.cxx:280
virtual int getNodeSet(int cellId, int *nodeSet)
Definition: SMDS_Downward.cxx:298
std::vector< unsigned char > _upCellTypes
compacted storage after connectivity calculation
Definition: SMDS_Downward.hxx:139
virtual int getNumberOfUpCells(int cellId)
Definition: SMDS_Downward.cxx:274
Definition: SMDS_Downward.hxx:144
int _nbNodes
number of nodes in a face
Definition: SMDS_Downward.hxx:172
std::vector< unsigned char > _upCellTypes
2 volume types per face
Definition: SMDS_Downward.hxx:170
std::vector< int > _tempNodes
temporary storage of nodes, until downward connectivity completion
Definition: SMDS_Downward.hxx:171
virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType &facesWithNodes)=0
std::vector< int > _upCellIds
2 volumes max.
Definition: SMDS_Downward.hxx:169
Definition: SMDS_Downward.hxx:176
virtual void computeFacesWithNodes(int cellId, ListElemByNodesType &facesWithNodes)=0
Definition: SMDS_Downward.hxx:193
Definition: SMDS_Downward.hxx:343
Definition: SMDS_Downward.hxx:319
Definition: SMDS_Downward.hxx:295
Definition: SMDS_Downward.hxx:202
Definition: SMDS_Downward.hxx:355
Definition: SMDS_Downward.hxx:331
Definition: SMDS_Downward.hxx:307
Definition: SMDS_Downward.hxx:244
Definition: SMDS_Downward.hxx:283
Definition: SMDS_Downward.hxx:222
Definition: SMDS_Downward.hxx:233
Definition: SMDS_Downward.hxx:271
Definition: SMDS_Downward.hxx:211
Definition: SMDS_Downward.hxx:68
virtual int getNumberOfDownCells(int cellId)
Get the number of downward entities associated to a cell (always the same for a given vtk type of cel...
Definition: SMDS_Downward.cxx:135
static int getCellDimension(unsigned char cellType)
get the dimension of a cell (1,2,3 for 1D, 2D 3D) given the vtk cell type
Definition: SMDS_Downward.cxx:45
virtual int getNumberOfUpCells(int cellId)=0
std::vector< int > _vtkCellIds
growing size: size = _maxId, either vtkId or -1
Definition: SMDS_Downward.hxx:106
std::vector< unsigned char > _cellTypes
fixed size: the same vector for all cells of a derived class
Definition: SMDS_Downward.hxx:107
int getVtkCellId(int cellId)
Definition: SMDS_Downward.hxx:82
SMDS_UnstructuredGrid * _grid
Definition: SMDS_Downward.hxx:102
virtual const int * getDownCells(int cellId)
get a pointer on the downward entities id's associated to a cell.
Definition: SMDS_Downward.cxx:146
virtual ~SMDS_Downward()
Definition: SMDS_Downward.cxx:91
virtual void initCell(int cellId)
generic method do nothing.
Definition: SMDS_Downward.cxx:126
virtual void allocate(int nbElems)=0
static std::vector< int > _cellDimension
conversion table: type --> dimension
Definition: SMDS_Downward.hxx:109
int addCell(int vtkId=-1)
Give or create an entry for downward connectivity structure relative to a cell.
Definition: SMDS_Downward.cxx:102
SMDS_Downward(SMDS_UnstructuredGrid *grid, int nbDownCells)
Generic constructor for all the downward connectivity structures (one per vtk cell type).
Definition: SMDS_Downward.cxx:81
virtual int getNodes(int, int *)
Definition: SMDS_Downward.hxx:80
virtual void addUpCell(int cellId, int upCellId, unsigned char aType)
Id's are downward connectivity id's.
Definition: SMDS_Downward.cxx:180
std::vector< int > _cellIds
growing size: all the down cell id's, size = _maxId * _nbDownCells
Definition: SMDS_Downward.hxx:105
virtual void getNodeIds(int cellId, std::set< int > &nodeSet)=0
int getMaxId()
Definition: SMDS_Downward.hxx:86
virtual const unsigned char * getUpTypes(int cellId)=0
int _nbDownCells
the same number for all cells of a derived class
Definition: SMDS_Downward.hxx:104
virtual const unsigned char * getDownTypes(int cellId)
get a list of vtk cell types associated to downward entities of a given cell, in the same order than ...
Definition: SMDS_Downward.cxx:158
friend class SMDS_Down2D
Definition: SMDS_Downward.hxx:70
virtual void getOrderedNodesOfFace(int, std::vector< vtkIdType > &)
Definition: SMDS_Downward.hxx:81
virtual void compactStorage()=0
virtual const int * getUpCells(int cellId)=0
int _maxId
Definition: SMDS_Downward.hxx:103
virtual void addDownCell(int cellId, int lowCellId, unsigned char aType)
Id's are downward connectivity id's.
Definition: SMDS_Downward.cxx:169
virtual int getNodeSet(int cellId, int *nodeSet)
Definition: SMDS_Downward.cxx:185
This class extends vtkUnstructuredGrid to deal with downward connectivity.
Definition: SMDS_UnstructuredGrid.hxx:108
int getOrderedNodesOfFace(int vtkVolId, int &dim, std::vector< vtkIdType > &orderedNodes)
reorder the nodes of a face
Definition: SMDS_UnstructuredGrid.cxx:1048
Definition: SMDS_Downward.hxx:57
bool operator()(const DownIdType e1, const DownIdType e2) const
Definition: SMDS_Downward.hxx:58
Definition: SMDS_Downward.hxx:33
unsigned char vtkType
Definition: SMDS_Downward.hxx:36
int nbNodes
Definition: SMDS_Downward.hxx:35
Definition: SMDS_Downward.hxx:40
int nbElems
Definition: SMDS_Downward.hxx:42