Open Inventor Release 2024.2.1
 
Loading...
Searching...
No Matches
PbGrid2D.h
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-2014 BY FEI S.A.S, ***
17 *** BORDEAUX, FRANCE ***
18 *** ALL RIGHTS RESERVED ***
19**=======================================================================*/
20/*=======================================================================
21** Author : VSG (MMM YYYY)
22**=======================================================================*/
23
24#ifndef _PB_GRID2D_
25#define _PB_GRID2D_
26
27#include <MeshViz/3Ddata/PbMesh2D.h>
43class PbGrid2D : public PbMesh2D {
44
45
46 public:
47
51 PbGrid2D(SbBool is_data_duplicate=TRUE) : PbMesh2D(is_data_duplicate) {};
52
56 PbGrid2D(const PbGrid2D &mesh);
57
62
66 PbGrid2D& operator=(const PbGrid2D &mesh) ;
67
73 void setGeometry(int num_x, int num_y, const float *x, const float *y);
74
81 void setGeometry(int num_x, int num_y, const float *x, const float *y, const float *z);
82
88 void getGeometry(int &num_x, int &num_y, const float* &x, const float* &y) const;
89
96 void getGeometry(int &num_x, int &num_y, const float* &x, const float* &y, const float* &z) const;
97
101 virtual SbVec3f getNodeCoord(int nod_index) const=0;
102
106 virtual SbVec3f getNodeCoord(int i, int j) const=0;
107
111 void getDim(int &num_x, int &num_y) const { num_x = numX; num_y = numY;};
112
116 virtual void getNodeOwnerCellsInd(int nod_index, PbArrayOfInt &owner_cells) const;
117
122 virtual void getAdjacentCellsIndByNode(int cell_index, PbArrayOfInt &adjacent_cells) const;
123
128 virtual void getAdjacentCellsIndByFacet(int cell_index, PbArrayOfInt &adjacent_cells) const;
129
133 void getNodeIndices(int nod_index, int &i, int &j) const;
134
138 void getCellIndices(int cell_index, int &i, int &j) const;
139 private:
140 int * getCellNodeIds(int i, int j) const;
141 int * getCellNodeIds(int cell_index) const;
142 virtual SbVec3f getFirstCellNormal() const;
143
144 void print(FILE *fp) const;
145 virtual void getLimitIndices(PbArrayOfInt &nodesIndex, PbArrayOfInt &limitSizes) const;
146
147 private:
148 virtual void updateCellBoundingBox() const;
149 PbGrid2D(int num_x, int num_y, SbBool isDataDuplicate=TRUE) ;
150 PbGrid2D(int num_x, int num_y, const float *z, SbBool isDataDuplicate=TRUE) ;
151 void setDim(int num_x, int num_y);
152 virtual void setXYGeometry(int num_x, int num_y, const float *x, const float *y)=0;
153 virtual void getXYGeometry(const float* &x, const float* &y) const=0;
154 void setZCoordMatrix(int num_x, int num_y, const float *z);
155 int numX,numY;
156 float **z;
157
158 // node ids of the mutable private cell
159 // each time the getCell or getTopoCell is called, m_cellNodeIds is updated
160 mutable int m_cellNodeIds[4];
161
162 private:
163
164 void copy(const PbGrid2D &mesh) ;
165 void destroy();
166} ;
167
168/*---------------------------------------------------------------------------*/
169
170// calculate indices i,j that verify nod_index = i*numY + j
171inline void
172PbGrid2D::getNodeIndices(int nod_index, int &i, int &j) const
173{
174 j = nod_index % numY;
175 i = (nod_index-j) / numY;
176}
177
178// calculate indices i,j that verify cell_index = i*(numY-1) + j
179inline void
180PbGrid2D::getCellIndices(int cell_index, int &i, int &j) const
181{
182 j = cell_index % (numY-1);
183 i = (cell_index-j) / (numY-1);
184}
185
186// set dimensions of the grid
187inline void
188PbGrid2D::setDim(int num_x, int num_y)
189{
190 numX = num_x;
191 numY = num_y;
192 numMeshNodes = numX * numY;
193 if (num_x > 1 && num_y > 1)
194 m_numMeshCells = (numX-1) * (numY-1);
195 else
196 // setDim can be used with (0,0) as argt !
197 m_numMeshCells = 0;
198}
199
200inline int *
201PbGrid2D::getCellNodeIds(int cell_index) const
202{
203 int i, j;
204 getCellIndices(cell_index, i, j);
205 return getCellNodeIds(i,j);
206}
207
208inline int *
209PbGrid2D::getCellNodeIds(int i, int j) const
210{
211 m_cellNodeIds[0] = i*numY+j;
212 m_cellNodeIds[1] = (i+1)*numY+j;
213 m_cellNodeIds[2] = (i+1)*numY+j+1;
214 m_cellNodeIds[3] = i*numY+j+1;
215 return m_cellNodeIds;
216}
217
218#endif /* _PB_GRID2D_ */
219
220
221
222
223
224
225
DTEXT Dynamic array of int .
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Defines an abstract grid...
Definition PbGrid2D.h:43
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.
PbGrid2D(SbBool is_data_duplicate=TRUE)
Constructor.
Definition PbGrid2D.h:51
PbGrid2D(const PbGrid2D &mesh)
Copy constructor.
void setGeometry(int num_x, int num_y, const float *x, const float *y)
Defines a 2D surface mesh geometry.
~PbGrid2D()
Destructor.
void getCellIndices(int cell_index, int &i, int &j) const
Calculates indices i,j that verify cell_index = i*(num_y-1) + j.
Definition PbGrid2D.h:180
virtual void getAdjacentCellsIndByFacet(int cell_index, PbArrayOfInt &adjacent_cells) const
Gets the list of index of cells that are adjacent (by an edge) to cell_index.
void getDim(int &num_x, int &num_y) const
Gets the dimensions num_x, num_y of the grid.
Definition PbGrid2D.h:111
virtual void getNodeOwnerCellsInd(int nod_index, PbArrayOfInt &owner_cells) const
Gets the list of index of cells that own the node "nod_index".
virtual SbVec3f getNodeCoord(int i, int j) const =0
Gets the coordinates of a node defined by its i,j indices on the grid.
virtual SbVec3f getNodeCoord(int nod_index) const =0
Gets the coordinates of a node defined by its index.
void setGeometry(int num_x, int num_y, const float *x, const float *y, const float *z)
Defines a 3D surface mesh geometry.
PbGrid2D & operator=(const PbGrid2D &mesh)
Assignment operator.
void getGeometry(int &num_x, int &num_y, const float *&x, const float *&y, const float *&z) const
Gets the mesh 3D geometry.
void getGeometry(int &num_x, int &num_y, const float *&x, const float *&y) const
Gets the mesh 2D geometry.
void getNodeIndices(int nod_index, int &i, int &j) const
Calculates indices i,j that verify nod_index = i*num_y + j.
Definition PbGrid2D.h:172
<a href="IconLegend.html"><img src="extMV.gif" alt="MeshViz" border="0"></a> Defines an abstract surf...
Definition PbMesh2D.h:54
3D vector class.
Definition SbVec.h:932
int SbBool
Boolean type.
Definition SbBase.h:87