Version: 8.3.0
SMDS_Downward.hxx
Go to the documentation of this file.
1 // Copyright (C) 2010-2016 CEA/DEN, EDF R&D, 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 
32 typedef struct
33 {
34  int nodeIds[8];
35  int nbNodes;
36  unsigned char vtkType;
37 } ElemByNodesType; // TODO resize for polyhedrons
38 
39 typedef struct
40 {
41  ElemByNodesType elems[6];
42  int nbElems;
43 } ListElemByNodesType; // TODO resize for polyhedrons
44 
46 {
47 public:
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 {
69  friend class SMDS_UnstructuredGrid;
70  friend class SMDS_Down2D;
71  friend class SMDS_Down3D;
72 public:
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  }
86  int getMaxId()
87  {
88  return _maxId;
89  }
90  static int getCellDimension(unsigned char cellType);
91 protected:
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 
103  int _maxId;
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 {
114  friend class SMDS_UnstructuredGrid;
115 public:
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); }
121 protected:
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 {
145  friend class SMDS_UnstructuredGrid;
146  friend class SMDS_Down1D;
147 public:
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);
152 protected:
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 
168  std::vector<int> _upCellIds;
169  std::vector<unsigned char> _upCellTypes;
170  std::vector<int> _tempNodes;
171  int _nbNodes;
172 };
173 
175 {
176  friend class SMDS_UnstructuredGrid;
177 public:
178  virtual int getNumberOfUpCells(int cellId);
179  virtual const int* getUpCells(int cellId);
180  virtual const unsigned char* getUpTypes(int cellId);
181  virtual void getNodeIds(int cellId, std::set<int>& nodeSet);
182 protected:
183  SMDS_Down3D(SMDS_UnstructuredGrid *grid, int nbDownCells);
184  ~SMDS_Down3D();
185  virtual void allocate(int nbElems);
186  virtual void compactStorage();
187  virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes) = 0;
188  int FindFaceByNodes(int cellId, ElemByNodesType& faceByNodes);
189 };
190 
192 {
193  friend class SMDS_UnstructuredGrid;
194 public:
195 protected:
197  ~SMDS_DownEdge();
198 };
199 
201 {
202  friend class SMDS_UnstructuredGrid;
203 public:
204 protected:
207 };
208 
210 {
211  friend class SMDS_UnstructuredGrid;
212 public:
213 protected:
216  virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
217  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
218 };
219 
221 {
222  friend class SMDS_UnstructuredGrid;
223 public:
224 protected:
227  virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
228  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
229 };
230 
232 {
233  friend class SMDS_UnstructuredGrid;
234 public:
235 protected:
238  virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
239  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
240 };
241 
243 {
244  friend class SMDS_UnstructuredGrid;
245 public:
246 protected:
249  virtual void computeEdgesWithNodes(int cellId, ListElemByNodesType& edgesWithNodes);
250  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
251 };
252 
253 //class SMDS_DownPolygon: public SMDS_Down2D
254 //{
255 //public:
256 // SMDS_DownPolygon(SMDS_UnstructuredGrid *grid);
257 // ~SMDS_DownPolygon();
258 //protected:
259 //};
260 
261 //class SMDS_DownQuadPolygon: public SMDS_Down2D
262 //{
263 //public:
264 // SMDS_DownQuadPolygon(SMDS_UnstructuredGrid *grid);
265 // ~SMDS_DownQuadPolygon();
266 //protected:
267 //};
268 
270 {
271  friend class SMDS_UnstructuredGrid;
272 public:
273  virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
274 protected:
276  ~SMDS_DownTetra();
277  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
278  virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
279 };
280 
282 {
283  friend class SMDS_UnstructuredGrid;
284 public:
285  virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
286 protected:
289  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
290  virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
291 };
292 
294 {
295  friend class SMDS_UnstructuredGrid;
296 public:
297  virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
298 protected:
300  ~SMDS_DownPyramid();
301  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
302  virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
303 };
304 
306 {
307  friend class SMDS_UnstructuredGrid;
308 public:
309  virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
310 protected:
313  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
314  virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
315 };
316 
318 {
319  friend class SMDS_UnstructuredGrid;
320 public:
321  virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
322 protected:
324  ~SMDS_DownPenta();
325  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
326  virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
327 };
328 
330 {
331  friend class SMDS_UnstructuredGrid;
332 public:
333  virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
334 protected:
337  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
338  virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
339 };
340 
342 {
343  friend class SMDS_UnstructuredGrid;
344 public:
345  virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
346 protected:
348  ~SMDS_DownHexa();
349  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
350  virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
351 };
352 
354 {
355  friend class SMDS_UnstructuredGrid;
356 public:
357  virtual void getOrderedNodesOfFace(int cellId, std::vector<vtkIdType>& orderedNodes);
358 protected:
361  virtual void addDownCell(int cellId, int lowCellId, unsigned char aType);
362  virtual void computeFacesWithNodes(int cellId, ListElemByNodesType& facesWithNodes);
363 };
364 
365 //class SMDS_DownPolyhedra: public SMDS_Down3D
366 //{
367 //public:
368 // SMDS_DownPolyhedra(SMDS_UnstructuredGrid *grid);
369 // ~SMDS_DownPolyhedra();
370 //protected:
371 //};
372 
373 //class SMDS_DownQuadPolyhedra: public SMDS_Down3D
374 //{
375 //public:
376 // SMDS_DownQuadPolyhedra(SMDS_UnstructuredGrid *grid);
377 // ~SMDS_DownQuadPolyhedra();
378 //protected:
379 //};
380 
381 #endif /* SMDS_DOWNWARD_HXX_ */