Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members

# ScalarGridT.hh

    00001
    00002 //=============================================================================
    00003 //
    00004 //  CLASS ScalarGridT
    00005 //
    00006 //=============================================================================
    00007
    00008
    00009 #ifndef ISOEX_SCALARGRIDT_HH
    00010 #define ISOEX_SCALARGRIDT_HH
    00011
    00012
    00013 //== INCLUDES =================================================================
    00014
    00015 #include <OpenMesh/Core/IO/BinaryHelper.hh>
    00016 #include <OpenMesh/Core/Math/VectorT.hh>
    00017 #include <IsoEx/Grids/RegularGrid.hh>
    00018 #include <IsoEx/Implicits/Implicit.hh>
    00019 #include <vector>
    00020 #include <iostream>
    00021
    00022 //== NAMESPACES ===============================================================
    00023
    00024 namespace IsoEx {
    00025
    00026 //== CLASS DEFINITION =========================================================
    00027
    00028
    00035 template <typename Scalar>
    00036 class ScalarGridT : public RegularGrid
    00037 {
    00038 public:
    00039
    00040   //typedef _Scalar Scalar;
    00041   typedef std::vector<Scalar>  Values;
    00042
    00043
    00045   ScalarGridT(const OpenMesh::Vec3f&  _origin = OpenMesh::Vec3f(0,0,0),
    00046               const OpenMesh::Vec3f&  _x_axis = OpenMesh::Vec3f(1,0,0),
    00047               const OpenMesh::Vec3f&  _y_axis = OpenMesh::Vec3f(0,1,0),
    00048               const OpenMesh::Vec3f&  _z_axis = OpenMesh::Vec3f(0,0,1),
    00049               unsigned int            _x_res  = 10,
    00050               unsigned int            _y_res  = 10,
    00051               unsigned int            _z_res  = 10)
    00052     : RegularGrid(_origin, _x_axis, _y_axis, _z_axis, _x_res, _y_res, _z_res),
    00053       values_(_x_res*_y_res*_z_res, 0)
    00054   {}
    00055
    00057   virtual ~ScalarGridT() {}
    00058
    00059
    00060
    00061   virtual float scalar_distance(PointIdx _pidx) const {
    00062     return values_[_pidx];
    00063   }
    00064
    00065   virtual bool is_inside(PointIdx _pidx) const {
    00066     return values_[_pidx] < 0.0;
    00067   }
    00068
    00069   virtual bool directed_distance(const OpenMesh::Vec3f&  _p0,
    00070                                  const OpenMesh::Vec3f&  _p1,
    00071                                  OpenMesh::Vec3f&        _point,
    00072                                  OpenMesh::Vec3f&        _normal,
    00073                                  float&                  _distance) const {
    00074     return false;
    00075   }
    00076
    00077   void sample(const Implicit& _implicit);
    00078
    00079
    00080   virtual bool read(const char* _filename);
    00081   virtual bool write(const char* _filename);
    00082   virtual bool read(FILE* _in);
    00083   virtual bool write(FILE* _out);
    00084
    00085
    00086   Scalar& operator()(unsigned int x, unsigned int y, unsigned int z) {
    00087     return values_[x + y*x_resolution() + z*x_resolution()*y_resolution()];
    00088   }
    00089
    00090   Scalar operator()(unsigned int x, unsigned int y, unsigned int z) const {
    00091     return values_[x + y*x_resolution() + z*x_resolution()*y_resolution()];
    00092   }
    00093
    00094   Scalar& value(unsigned int x, unsigned int y, unsigned int z) {
    00095     return (*this)(x, y, z);
    00096   }
    00097
    00098   Scalar value(unsigned int x, unsigned int y, unsigned int z) const {
    00099     return (*this)(x, y, z);
    00100   }
    00101
    00102   void resize() {values_ = Values(n_points(), 0);};  // changed
    00103
    00104
    00105 private:
    00106
    00107   Values  values_;
    00108 };
    00109
    00110
    00111 //=============================================================================
    00112 } // namespace IsoEx
    00113 //=============================================================================
    00114 #if defined(INCLUDE_TEMPLATES) && !defined(ISOEX_SCALARGRIDT_C)
    00115 #define ISOEX_SCALARGRIDT_TEMPLATES
    00116 #include "ScalarGridT.cc"
    00117 #endif
    00118 //=============================================================================
    00119 #endif // ISOEX_SCALARGRIDT_HH defined
    00120 //=============================================================================
    00121