00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _PB_REGULARCARTESIANGRID3D_
00025 #define _PB_REGULARCARTESIANGRID3D_
00026
00027 #include <MeshViz/3Ddata/PbGrid3D.h>
00028
00029 class PbVoxelCell;
00050 class PbRegularCartesianGrid3D : public PbGrid3D {
00051
00052 public:
00053
00057 PbRegularCartesianGrid3D(SbBool isDataDuplicate=TRUE);
00058
00062 PbRegularCartesianGrid3D(const PbRegularCartesianGrid3D &mesh);
00063
00068 PbRegularCartesianGrid3D(int num_x, int num_y, int num_z,
00069 float x_min, float y_min, float z_min,
00070 float x_max, float y_max, float z_max,
00071 SbBool isDataDuplicate = TRUE);
00072
00076 ~PbRegularCartesianGrid3D();
00077
00081 PbRegularCartesianGrid3D& operator=(const PbRegularCartesianGrid3D &mesh);
00082
00086 friend int operator ==(const PbRegularCartesianGrid3D &m1,
00087 const PbRegularCartesianGrid3D &m2);
00088
00092 friend int operator !=(const PbRegularCartesianGrid3D &m1,
00093 const PbRegularCartesianGrid3D &m2)
00094 { return !(m1 == m2); }
00095
00099 void setGeometry(int num_x, int num_y, int num_z,
00100 float x_min, float y_min, float z_min,
00101 float x_max, float y_max, float z_max);
00102
00107 void getGeometry(int &num_x, int &num_y, int &num_z,
00108 float &x_min, float &y_min, float &z_min,
00109 float &x_max, float &y_max, float &z_max) const;
00110
00111 virtual const PbCell* findContainingCell(const SbVec3f &point,
00112 float tolerance,
00113 SbVec3f &pcoord,
00114 const PbCell *adjacent_cell) const;
00115
00129 virtual const PbCell* findContainingCell(const SbVec3f &point,
00130 float tolerance,
00131 SbVec3f &pcoord) const;
00132
00139 virtual const PbCell *getCell(int cell_index) const;
00140
00144 virtual SbVec3f getNodeCoord(int nod_index) const;
00145
00149 virtual SbVec3f getNodeCoord(int i, int j, int k) const
00150 { return SbVec3f(m_xmin+i*m_dx, m_ymin+j*m_dy, m_zmin+k*m_dz); };
00151
00155 virtual float getVolume() const
00156 { return fabs((m_xmax-m_xmin)*(m_ymax-m_ymin)*(m_zmax-m_zmin)); }
00157
00167 void setCoordinates(const float *xnod, const float *ynod, const float *znod);
00168
00178 void getCoordinates(const float* &xnod, const float* &ynod, const float* &znod,
00179 int &size_xnod, int &size_ynod, int &size_znod) const {
00180 xnod = m_x;
00181 ynod = m_y;
00182 znod = m_z;
00183 size_xnod = size_ynod = size_znod = 2;
00184 }
00185
00186
00187 private:
00188 void setBounds(float x_min, float y_min, float z_min,
00189 float x_max, float y_max, float z_max);
00190
00191 float getLongestEdgeLength();
00192
00193
00194 void meshCrossSection(PoMeshCrossSection *cross_section) const;
00195 void meshCrossContour(PoMeshCrossContour *cross_contour) const;
00196 void meshSkeleton(PoMeshSkeleton *skeleton,
00197 const float *nod_values,
00198 float *x_cont,
00199 float *y_cont,
00200 float *z_cont) const;
00201 void mesh3DVec(PoMesh3DVec *mesh_vec) const;
00202 SbBool isCrossSectionOptimal() const { return TRUE; }
00203
00204 void print(FILE *fp) const;
00205
00206
00207 virtual const PbCell *getTopoCell(int cell_index) const;
00208
00209 private:
00210 void constructXYGeometry(float x_min, float y_min,
00211 float x_max, float y_max,
00212 SbBool is_data_duplicate);
00213 void setXYZGeometry(int num_x, int num_y, int num_z,
00214 const float *x, const float *y, const float *z);
00215 void getXYZGeometry(const float* &x, const float* &y, const float* &z) const;
00216 virtual void grid3DSkin(PoMeshSkin *_PoMeshSkin) const;
00217
00218 private:
00219 float m_x[2], m_y[2], m_z[2];
00220 float m_xmin, m_xmax, m_dx;
00221 float m_ymin, m_ymax, m_dy;
00222 float m_zmin, m_zmax, m_dz;
00223
00224 void updateBoundingBox() const;
00225 void copy(const PbRegularCartesianGrid3D &mesh);
00226 void destroy();
00227
00228 mutable PbVoxelCell *m_voxel;
00229 };
00230
00231
00232
00233 inline void
00234 PbRegularCartesianGrid3D::getGeometry(int &num_x, int &num_y, int &num_z,
00235 float &x_min, float &y_min, float &z_min,
00236 float &x_max, float &y_max, float &z_max) const
00237 {
00238 num_x = numX; x_min = m_xmin; x_max = m_xmax;
00239 num_y = numY; y_min = m_ymin; y_max = m_ymax;
00240 num_z = numZ; z_min = m_zmin; z_max = m_zmax;
00241 }
00242
00243 #endif
00244
00245
00246
00247
00248
00249
00250
00251