Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

CondenseTraverser.h

Go to the documentation of this file.
00001 // Copyright NVIDIA Corporation 2002-2004
00002 // TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
00003 // *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
00004 // OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY
00005 // AND FITNESS FOR A PARTICULAR PURPOSE.  IN NO EVENT SHALL NVIDIA OR ITS SUPPLIERS
00006 // BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR CONSEQUENTIAL DAMAGES
00007 // WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
00008 // BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR ANY OTHER PECUNIARY LOSS)
00009 // ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF NVIDIA HAS
00010 // BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES 
00011 
00012 #pragma once
00013 
00015 #pragma push_macro("free")
00016 #undef free
00017 #include <valarray>
00018 #pragma pop_macro("free")
00019 
00020 #include <set>
00021 
00022 #include "nvsgcommon.h"
00023 
00024 #include "nvsg/nvsg.h"
00025 #include "nvtraverser/Traverser.h"
00026 
00027 namespace nvtraverser
00028 {  
00029 
00031 
00032   class CondenseTraverser : public Traverser
00033   {
00034   public:
00036     NVSG_API CondenseTraverser(void);
00037 
00039 
00040     NVSG_API void  setEpsilon( 
00041       float epsilon                 
00042       );
00043 
00044   protected:
00046     NVSG_API virtual ~CondenseTraverser(void);
00047 
00049 
00050     NVSG_API virtual void  doApply( const nvsg::ViewState *pViewState    
00051       , const nvsg::Scene *pScene            
00052       );
00053 
00055     NVSG_API virtual void handleGeoNode( const nvsg::GeoNode *p   
00056       );
00057 
00058   private:
00059     bool    areSimilar( const std::valarray<float> &v0, const std::valarray<float> &v1, float eps );
00060     void    condense( const nvsg::Quads *p );
00061     void    condense( const nvsg::Triangles *p );
00062     size_t  hash( const std::valarray<float> &vertex, const std::valarray<float> &base, float scale, size_t numVertices );
00063     void    postRemapping( const nvsg::GeoSet *p, std::vector<std::valarray<float> > &valuesOut );
00064     void    prepareRemapping( const nvsg::GeoSet *p, std::vector<std::valarray<float> > &valuesIn );
00065     bool    remap( const nvsg::IndexSet &iIn, const std::vector<std::valarray<float> > &vIn,
00066       nvsg::IndexSet &iOut, std::vector<std::valarray<float> > &vOut, float epsilon );
00067 
00068   private:
00069     float m_epsilon;
00070     float m_tolerance;
00071     std::set<const nvsg::Quads *>     m_quads;
00072     std::set<const nvsg::Triangles *> m_triangles;
00073   };
00074 
00075   inline  void  CondenseTraverser::setEpsilon( float epsilon )
00076   {
00077     m_epsilon = fabsf( epsilon );
00078   }
00079 }

Generated on Tue Mar 1 13:19:19 2005 for NVSGSDK by NVIDIA