Geometry.h

Go to the documentation of this file.
00001 /* $Id: Geometry.h,v 1.5 2002/11/05 14:31:15 anonymous Exp $ */
00002 
00003 #ifndef __GEOMETRY_H
00004 #define __GEOMETRY_H
00005 
00006 #include <esg/Definitions.h>
00007 #include <esg/ESGObject.h>
00008 #include <esg/mesh/Mesh.h>
00009 #include <esg/PointEnv.h>
00010 
00011 
00012 namespace esg {
00013 
00018 class OGSCENE_EXPORT Geometry : public ESGObject {
00019 public:
00020         static const float EPS; 
00021         
00022 protected:
00023         bool _insideOut; // whether to invert normals
00024 
00025 protected:
00026     virtual Mesh* _mesh                 (int /*density*/) const = 0;
00027     virtual void  _duplicate_attributes (const Geometry& src);
00028     
00029     // Geometric transformations
00030     virtual void _rotateX   (float /* angle */)                            = 0;
00031     virtual void _rotateY   (float /* angle */)                            = 0;
00032     virtual void _rotateZ   (float /* angle */)                            = 0;
00033     virtual void _rotate    (float /* angle */, const Vector3& /* axis */) = 0;
00034     virtual void _rotate    (const Matrix3&)                               = 0;
00035     virtual void _translate (float /* x */, float /* y */, float /* z */)  = 0;
00036     virtual void _transform (const Matrix4&)                               = 0;
00037     virtual void _scale     (float /* scale */)                            = 0;
00038             void _translate (const Vector3& v) { _translate(v.x, v.y, v.z); }
00039 
00040 public:
00044         Geometry() : _insideOut(false) {}
00045 
00049         virtual ~Geometry() {}
00050 
00056         void insideOut (bool b) { _insideOut = b; } // invert facet normals
00057 
00069         virtual void rayIntersection (PointEnv*      pPE,
00070                                       int            mask,
00071                                       const Vector3& origin,
00072                                       const Vector3& direction,
00073                                       float          maxD = MAXFLOAT) = 0;
00074 
00083         virtual bool mapToUV (const Vector3& v, Vector2& uv) = 0;
00084 
00093         virtual void randomSample (int mask, PointEnv& pe, double* pdf) = 0;
00094 
00104         virtual bool randomDirection (const Vector3& pov,
00105                                       Vector3&       dir,
00106                                       double*        pdf) = 0;
00107 
00114         virtual Interval extent (const Vector3& direction) const = 0;
00115 
00124         Interval extent (float x, float y, float z) const {
00125             return extent(Vector3(x,y,z));
00126         }
00127         
00131         virtual Vector3 centroid (void) const = 0;
00132 
00139         virtual double radius (const Vector3& centroid) const = 0;
00140 
00148         virtual double radius (void) const { return radius(centroid()); }
00149 
00155         Geometry* clone (void) const { return clone(NULL);}
00156 
00163         virtual Geometry* clone (const Matrix4* pTrMat) const = 0;
00164 
00173         virtual bool separation (Geometry& geom, Vector3*  pDir) = 0;
00174 
00186         virtual double distance (const Geometry& geom, Vector3* pDir) = 0;
00187 
00194         virtual void dump (const char* intent, const char* tab) = 0;
00195 
00202         Mesh* mesh (int density = 0) const;
00203 
00204         
00205         
00206 
00207 
00208 
00209 
00210     // debuging:
00211     virtual void __debug() {
00212         fprintf(stderr,"Geometry: No debug info\n");
00213     }
00214 };
00215 
00216 }; // namespace
00217 
00218 #endif // __GEOMETRY_H

Generated on Wed Jun 28 12:24:28 2006 for esg by  doxygen 1.4.6