Open Inventor Release 2023.2.3
 
Loading...
Searching...
No Matches
PbGrid3D.h
Go to the documentation of this file.
1/*=======================================================================
2 *** THE CONTENT OF THIS WORK IS PROPRIETARY TO FEI S.A.S, (FEI S.A.S.), ***
3 *** AND IS DISTRIBUTED UNDER A LICENSE AGREEMENT. ***
4 *** ***
5 *** REPRODUCTION, DISCLOSURE, OR USE, IN WHOLE OR IN PART, OTHER THAN AS ***
6 *** SPECIFIED IN THE LICENSE ARE NOT TO BE UNDERTAKEN EXCEPT WITH PRIOR ***
7 *** WRITTEN AUTHORIZATION OF FEI S.A.S. ***
8 *** ***
9 *** RESTRICTED RIGHTS LEGEND ***
10 *** USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT OF THE CONTENT OF THIS ***
11 *** WORK OR RELATED DOCUMENTATION IS SUBJECT TO RESTRICTIONS AS SET FORTH IN ***
12 *** SUBPARAGRAPH (C)(1) OF THE COMMERCIAL COMPUTER SOFTWARE RESTRICTED RIGHT ***
13 *** CLAUSE AT FAR 52.227-19 OR SUBPARAGRAPH (C)(1)(II) OF THE RIGHTS IN ***
14 *** TECHNICAL DATA AND COMPUTER SOFTWARE CLAUSE AT DFARS 52.227-7013. ***
15 *** ***
16 *** COPYRIGHT (C) 1996-2020 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24#ifndef _PB_GRID3D_
25#define _PB_GRID3D_
26
28
44class PbGrid3D : public PbMesh3D {
45
46
47 public:
48
52 PbGrid3D(SbBool is_data_duplicate=TRUE) : PbMesh3D(is_data_duplicate) {};
53
57 PbGrid3D(const PbGrid3D &mesh);
58
63
67 PbGrid3D& operator=(const PbGrid3D &mesh) ;
68
74 void setGeometry(int num_x, int num_y, int num_z, const float *x, const float *y, const float *z);
75
81 void getGeometry(int &num_x, int &num_y, int &num_z, const float* &x, const float* &y, const float* &z) const;
82
86 virtual SbVec3f getNodeCoord(int nod_index) const=0;
87
91 virtual SbVec3f getNodeCoord(int i, int j, int k) const=0;
92
96 void getDim(int &num_x, int &num_y, int &num_z) const { num_x = numX; num_y = numY; num_z = numZ;};
97
101 virtual void getNodeOwnerCellsInd(int nod_index, PbArrayOfInt &owner_cells) const;
102
107 virtual void getAdjacentCellsIndByNode(int cell_index, PbArrayOfInt &adjacent_cells) const;
108
113 virtual void getAdjacentCellsIndByFacet(int cell_index, PbArrayOfInt &adjacent_cells) const;
114
118 void getNodeIndices(int nod_index, int &i, int &j, int &k) const;
119
123 void getCellIndices(int cell_index, int &i, int &j, int &k) const;
124
125 /*----------------------------------------------------------------------------*/
126 private:
127 void meshSkin(PoMeshSkin *_PoMeshSkin) const;
128
129 virtual int evaluateSkinFacesNum() const {
130 return 2*((numZ-1)*(numY-1) + (numZ-1)*(numX-1) + (numX-1)*(numY-1));
131 }
132
133 int * getCellNodeIds(int i, int j, int k) const;
134 int * getCellNodeIds(int cell_index) const;
135
136 void print(FILE *fp) const;
137
138 private:
139 virtual void grid3DSkin(PoMeshSkin *_PoMeshSkin) const = 0;
140
141 PbGrid3D(int num_x, int num_y, int num_z, SbBool isDataDuplicate=TRUE) ;
142 void setDim(int num_x, int num_y, int num_z);
143 virtual void setXYZGeometry(int num_x, int num_y, int num_z, const float *x, const float *y, const float *z)=0;
144 virtual void getXYZGeometry(const float* &x, const float* &y, const float* &z) const=0;
145 int numX,numY,numZ;
146
147 // node ids of the mutable private cell
148 // each time the getCell or getTopoCell is called, m_cellNodeIds is updated
149 mutable int m_cellNodeIds[8];
150
151 private:
152 void copy(const PbGrid3D &mesh) ;
153 void destroy();
154} ;
155
156/*---------------------------------------------------------------------------*/
157
158// calculate indices i,j,k that verify nod_index = (i*numY + j)*numZ + k
159inline void
160PbGrid3D::getNodeIndices(int nod_index, int &i, int &j, int &k) const
161{
162 int tmp;
163 k = nod_index % numZ;
164 tmp = (nod_index-k) / numZ; // tmp = i*numY + j
165 j = tmp % numY;
166 i = (tmp-j) / numY;
167}
168
169// calculate indices i,j,k that verify cell_index = (i*(numY-1) + j)*(numZ-1) + k
170inline void
171PbGrid3D::getCellIndices(int cell_index, int &i, int &j, int &k) const
172{
173 int ny=numY-1, nz=numZ-1;
174 int tmp;
175 k = cell_index % nz;
176 tmp = (cell_index-k) / nz; // tmp = i*ny + j
177 j = tmp % ny;
178 i = (tmp-j) / ny;
179}
180
181// set dimensions of the grid
182inline void
183PbGrid3D::setDim(int num_x, int num_y, int num_z)
184{
185 numX = num_x;
186 numY = num_y;
187 numZ = num_z;
188 numMeshNodes = numX * numY * numZ;
189 m_numMeshCells = (numX-1) * (numY-1) * (numZ-1);
190 updateTopologyId();
191}
192
193inline int *
194PbGrid3D::getCellNodeIds(int cell_index) const
195{
196 int i, j, k;
197 getCellIndices(cell_index, i, j, k);
198 return getCellNodeIds(i,j,k);
199}
200
201#define NSI_(i,j,k) numZ*((j)+(i)*numY) + (k)
202inline int *
203PbGrid3D::getCellNodeIds(int i, int j, int k) const
204{
205 m_cellNodeIds[4] = (m_cellNodeIds[0] = NSI_(i ,j ,k )) + 1;
206 m_cellNodeIds[5] = (m_cellNodeIds[1] = NSI_(i+1,j ,k )) + 1;
207 m_cellNodeIds[6] = (m_cellNodeIds[2] = NSI_(i+1,j+1,k )) + 1;
208 m_cellNodeIds[7] = (m_cellNodeIds[3] = NSI_(i ,j+1,k )) + 1;
209 return m_cellNodeIds;
210}
211
212#endif /* _PB_GRID3D_ */
213
214
215
216
217
218
219
#define NSI_(i, j, k)
Definition PbGrid3D.h:201
#define TRUE
Possible value of SbBool.
Definition SbBase.h:77
DTEXT Dynamic array of int .
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Defines an abstract grid...
Definition PbGrid3D.h:44
virtual void getNodeOwnerCellsInd(int nod_index, PbArrayOfInt &owner_cells) const
Gets the list of index of cells that own the node "nod_index".
void setGeometry(int num_x, int num_y, int num_z, const float *x, const float *y, const float *z)
Defines a volume mesh geometry.
void getNodeIndices(int nod_index, int &i, int &j, int &k) const
Calculates indices i,j,k that verify (i*num_y + j)*num_z + k.
Definition PbGrid3D.h:160
virtual SbVec3f getNodeCoord(int nod_index) const =0
Gets the coordinates of a node defined by its index.
void getCellIndices(int cell_index, int &i, int &j, int &k) const
Calculates indices i,j,k that verify cell_index = (i*(num_y-1) + j)*(num_z-1) + k.
Definition PbGrid3D.h:171
virtual SbVec3f getNodeCoord(int i, int j, int k) const =0
Gets the coordinates of a node defined by its i,j,k indices on the grid.
PbGrid3D & operator=(const PbGrid3D &mesh)
Assignment operator.
PbGrid3D(SbBool is_data_duplicate=TRUE)
Constructor.
Definition PbGrid3D.h:52
PbGrid3D(const PbGrid3D &mesh)
Copy constructor.
virtual void getAdjacentCellsIndByNode(int cell_index, PbArrayOfInt &adjacent_cells) const
Gets the list of index of cells that are adjacent (by a node) to cell_index.
~PbGrid3D()
Destructor.
virtual void getAdjacentCellsIndByFacet(int cell_index, PbArrayOfInt &adjacent_cells) const
Gets the list of index of cells that are adjacent (by a facet) to cell_index.
void getDim(int &num_x, int &num_y, int &num_z) const
Gets the dimensions num_x, num_y, num_z of the grid.
Definition PbGrid3D.h:96
void getGeometry(int &num_x, int &num_y, int &num_z, const float *&x, const float *&y, const float *&z) const
Gets the mesh geometry.
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Defines an abstract volu...
Definition PbMesh3D.h:51
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Representation of the me...
Definition PoMeshSkin.h:61
3D vector class.
Definition SbVec.h:932
int SbBool
Boolean type.
Definition SbBase.h:87