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_REGULARCARTESIANGRID2D_
00025 #define _PB_REGULARCARTESIANGRID2D_
00026
00027 #include <MeshViz/3Ddata/PbGrid2D.h>
00028
00029 class PiContouring;
00030 class PoMeshLines;
00031 class PoMeshFilled;
00032 class PoMeshSides;
00033 class PbPixelCell;
00034 class PbQuadrangleCell;
00035
00057 class PbRegularCartesianGrid2D : public PbGrid2D {
00058
00059
00060 public:
00061
00065 PbRegularCartesianGrid2D(SbBool isDataDuplicate=TRUE) ;
00066
00070 PbRegularCartesianGrid2D(const PbRegularCartesianGrid2D &mesh);
00071
00076 PbRegularCartesianGrid2D(int num_x,int num_y, float x_min,float y_min, float x_max,float y_max, SbBool isDataDuplicate=TRUE) ;
00077
00082 PbRegularCartesianGrid2D(int num_x,int num_y, float x_min,float y_min, float x_max,float y_max, const float *z,
00083 SbBool isDataDuplicate=TRUE) ;
00084
00088 PbRegularCartesianGrid2D(int num_x,int num_y,
00089 const PbRegularCartesianGrid2D &other_mesh);
00090
00094 ~PbRegularCartesianGrid2D() ;
00095
00099 PbRegularCartesianGrid2D& operator=(const PbRegularCartesianGrid2D &mesh) ;
00100
00104 friend int operator ==(const PbRegularCartesianGrid2D &m1, const PbRegularCartesianGrid2D &m2);
00105
00109 friend int operator !=(const PbRegularCartesianGrid2D &m1, const PbRegularCartesianGrid2D &m2)
00110 { return !(m1 == m2); }
00111
00115 void setGeometry(int num_x,int num_y, float x_min,float y_min, float x_max,float y_max);
00116
00120 void setGeometry(int num_x,int num_y, float x_min,float y_min, float x_max,float y_max, const float *z);
00121
00126 void getGeometry(int &num_x,int &num_y, float &x_min,float &y_min, float &x_max,float &y_max) const;
00127
00133 void getGeometry(int &num_x,int &num_y, float &x_min,float &y_min, float &x_max,float &y_max, const float *&z) const;
00134
00135 virtual const PbCell* findContainingCell(const SbVec3f &point, float tolerance, SbVec3f &pcoord, const PbCell *adjacent_cell) const;
00136
00150 virtual const PbCell* findContainingCell(const SbVec3f &point, float tolerance, SbVec3f &pcoord) const;
00151
00158 virtual const PbCell *getCell(int cell_index) const;
00159
00163 virtual SbVec3f getNodeCoord(int nod_index) const;
00164
00168 virtual SbVec3f getNodeCoord(int i, int j) const;
00169
00173 virtual float getArea() const;
00174
00175
00176 private:
00177 void meshLines(PoMeshLines *_PoMeshLines) const;
00178 void meshFilled(PoMeshFilled *_PoMeshFilled) const;
00179 void meshSides(PoMeshSides *_PoMeshSides) const;
00180 void meshContouring(PiContouring *_PiContouring, const float *z) const;
00181 void mesh2DVec(PoMesh2DVec *mesh_vec) const ;
00182 void getLimits(PoMesh2D *_PoMesh2D, Ppoint_list_list3 &limit) const;
00183
00184 void getNodesCoord(const float *z, SoMFVec3f &vertices) const;
00185 virtual SbBool hasSidesNormals() const;
00186 virtual void getSidesNormals(SbVec3f *&normals,
00187 const PbArrayOfInt &limitSizes) const;
00188
00189 void print(FILE *fp) const;
00190 void printInfo() const {print(stdout);};
00191
00192 private:
00193 void constructXYGeometry(float x_min,float y_min, float x_max,float y_max, SbBool is_data_duplicate);
00194 void setXYGeometry(int numX, int numY, const float *x, const float *y);
00195 void getXYGeometry(const float* &x, const float* &y) const;
00196
00197 private:
00198 float m_x[2], m_y[2];
00199 float m_xmin, m_xmax, m_dx;
00200 float m_ymin, m_ymax, m_dy;
00201
00202 void updateBoundingBox() const;
00203 void copy(const PbRegularCartesianGrid2D &mesh) ;
00204 void destroy();
00205
00206 mutable PbPixelCell *m_pixel;
00207 mutable PbQuadrangleCell *m_quadrangle;
00208 } ;
00209
00210
00211
00212 inline void
00213 PbRegularCartesianGrid2D::getGeometry(int &num_x,int &num_y, float &x_min,float &y_min, float &x_max,float &y_max) const
00214 {
00215 num_x = numX; x_min = m_xmin; x_max = m_xmax;
00216 num_y = numY; y_min = m_ymin; y_max = m_ymax;
00217 }
00218
00219 inline void
00220 PbRegularCartesianGrid2D::getGeometry(int &num_x,int &num_y, float &x_min,float &y_min, float &x_max,float &y_max, const float *&zn) const
00221 {
00222 num_x = numX; x_min = m_xmin; x_max = m_xmax;
00223 num_y = numY; y_min = m_ymin; y_max = m_ymax;
00224 zn = m_zCoord;
00225 }
00226
00227 #endif
00228
00229
00230
00231
00232
00233
00234
00235