Blob.h

Go to the documentation of this file.
00001 /**<!-------------------------------------------------------------------->
00002    @class  Blob
00003    @author Travis Fischer (fisch0920@gmail.com)
00004    @author Matthew Jacobs (jacobs.mh@gmail.com)
00005    @date   Spring 2008
00006    
00007    @brief
00008       Blobby isosurface composed of a set of MetaObjects, all of which 
00009    combine to form a scalar field whose contour at this blob's threshold 
00010    value defines the surface. Upon initialization (Blob::init), the implicit 
00011    surface is polygonized into triangles using a variant of the well-known 
00012    Marching Cubes algorithm.
00013       A MetaObject exerts a positive or negative 'charge' in a scalar field, 
00014    whose isocontours (level sets) define blobby surfaces with different 
00015    threshold values corresponding to the contour level.  MetaObjects positively
00016    or negatively affect their neighboring MetaObjects depending on their 
00017    'strength' and 'negative' attributes.
00018    
00019    @param
00020       threshold - specifies the particular isocontour boundary which will 
00021    define the surface of this blobby shape (defaults to BLOB_THRESHOLD_DEFAULT)
00022    
00023    @see also MetaObject
00024    <!-------------------------------------------------------------------->**/
00025 
00026 #ifndef BLOB_H_
00027 #define BLOB_H_
00028 
00029 #include <shapes/MetaObject.h>
00030 #include <shapes/Transformable.h>
00031 
00032 #define BLOB_THRESHOLD_DEFAULT (0.17) 
00033 
00034 DECLARE_STL_TYPEDEF(std::vector<MetaObject*>, MetaObjectList);
00035 
00036 class Mesh;
00037 
00038 class Blob : public MetaObject, public Transformable {
00039    public:
00040       ///@name Constructors
00041       //@{-----------------------------------------------------------------
00042       
00043       inline Blob(real_t threshold = BLOB_THRESHOLD_DEFAULT)
00044          : MetaObject(), Transformable(), 
00045            m_mesh(NULL), m_threshold(threshold)
00046       { }
00047       
00048       inline Blob(const MetaObjectList &metaObjects, 
00049                   real_t threshold = BLOB_THRESHOLD_DEFAULT)
00050          : MetaObject(), Transformable(), 
00051            m_metaObjects(metaObjects), 
00052            m_mesh(NULL), m_threshold(threshold)
00053       { }
00054       
00055       virtual ~Blob();
00056       
00057       
00058       //@}-----------------------------------------------------------------
00059       ///@name Core functionality
00060       //@{-----------------------------------------------------------------
00061       
00062       virtual void init();
00063       virtual void preview();
00064       
00065       virtual real_t getIntersection(const Ray &ray, SurfacePoint &pt);
00066       
00067       virtual bool   intersects(const Ray &ray, real_t tMax = INFINITY);
00068       
00069       /**
00070        * @returns the aggregate charge at the given point
00071        * 
00072        * @note
00073        *    If the given point is outside of this Blob's AABB, evaluate is 
00074        * assumed to return zero
00075        */
00076       virtual real_t evaluate(const Point3 &pt) const;
00077       
00078       
00079       //@}-----------------------------------------------------------------
00080       ///@name Accessors / Mutators
00081       //@{-----------------------------------------------------------------
00082       
00083       /**
00084        * @returns the threshold spcifying the boundary of this blobby surface
00085        */
00086       inline real_t getThreshold() const {
00087          return m_threshold;
00088       }
00089       
00090       /**
00091        * @brief
00092        *    sets the threshold spcifying the boundary of this blobby surface
00093        */
00094       inline void setThreshold(real_t threshold) {
00095          m_threshold = threshold;
00096       }
00097       
00098       /**
00099        * @returns the underlying mesh generated from marching cubes
00100        */
00101       inline Mesh *getMesh() {
00102          return m_mesh;
00103       }
00104       
00105       /**
00106        * @brief
00107        *    adds the given MetaObject to this blob
00108        */
00109       inline void push_back(MetaObject *meta) {
00110          ASSERT(meta);
00111          
00112          m_metaObjects.push_back(meta);
00113       }
00114       
00115       inline MetaObjectList &getMetaObjects() {
00116          return m_metaObjects;
00117       }
00118       
00119       virtual AABB getAABB() const;
00120       
00121       
00122       //@}-----------------------------------------------------------------
00123       
00124    protected:
00125       virtual void _getUV(SurfacePoint &pt) const;
00126       virtual void _getGeometricNormal(SurfacePoint &pt) const;
00127       
00128    protected:
00129       MetaObjectList m_metaObjects;
00130       Mesh          *m_mesh;
00131       
00132       real_t         m_threshold;
00133 };
00134 
00135 #endif // BLOB_H_
00136 

Generated on 28 Feb 2009 for Milton by doxygen 1.5.6