00001 /* 00002 * PROPRIETARY INFORMATION. This software is proprietary to 00003 * Side Effects Software Inc., and is not to be reproduced, 00004 * transmitted, or disclosed in any way without written permission. 00005 * 00006 * Produced by: 00007 * Jeff Lait 00008 * Side Effects Software Inc 00009 * 477 Richmond Street West 00010 * Toronto, Ontario 00011 * Canada M5V 3E7 00012 * 416-504-9876 00013 * 00014 * NAME: RBD_SphereTree.h ( RBD Library, C++) 00015 * 00016 * COMMENTS: 00017 * This builds a tree of spheres producing bounding 00018 * information for a point cloud. 00019 */ 00020 00021 #ifndef __RBD_SphereTree_H__ 00022 #define __RBD_SphereTree_H__ 00023 00024 #include "RBD_API.h" 00025 #include <UT/UT_Vector2.h> 00026 #include <UT/UT_Vector3Array.h> 00027 00028 #include <SIM/SIM_DataUtils.h> 00029 #include <SIM/SIM_OptionsUser.h> 00030 00031 #include "RBD_Utils.h" 00032 00033 /// This is the base class for nodes inside sphere trees. 00034 class RBD_API RBD_SphereTreeNode 00035 { 00036 public: 00037 RBD_SphereTreeNode(); 00038 virtual ~RBD_SphereTreeNode(); 00039 00040 UT_Vector3 myCenter; 00041 fpreal myRadius; 00042 00043 RBD_SphereTreeNode *myChild[2]; 00044 }; 00045 00046 /// This is a node in the sphere tree. 00047 class RBD_API RBD_SpherePointTreeNode : public RBD_SphereTreeNode 00048 { 00049 public: 00050 RBD_SpherePointTreeNode(const UT_Vector3Array &pts); 00051 00052 virtual ~RBD_SpherePointTreeNode(); 00053 00054 int64 getMemoryUsage() const; 00055 00056 UT_Vector3Array myPoints; 00057 }; 00058 00059 /// This class provides a generic way of describing sphere trees 00060 /// of points, edges, or higher order things. 00061 class RBD_API RBD_SphereTree : public SIM_Data 00062 { 00063 public: 00064 // Return the untyped root of the tree. 00065 virtual const RBD_SphereTreeNode *getRoot() const = 0; 00066 00067 protected: 00068 explicit RBD_SphereTree(const SIM_DataFactory *factory); 00069 virtual ~RBD_SphereTree(); 00070 00071 DECLARE_STANDARD_GETCASTTOTYPE(); 00072 DECLARE_CLASSNAME(RBD_SphereTree, SIM_Data); 00073 }; 00074 00075 /// This class holds a point cloud of samples. 00076 /// It has a bounding sphere hierarchy to allow quick rejection 00077 /// when dealing with a SDF. 00078 class RBD_API RBD_SpherePointTree : public RBD_SphereTree, public SIM_OptionsUser 00079 { 00080 public: 00081 /// Get the Tree. 00082 virtual const RBD_SphereTreeNode *getRoot() const; 00083 00084 protected: 00085 // Determines if we convert to polygons or use raw points. 00086 GETSET_DATA_FUNCS_B(RBD_NAME_POLYCONVERT, PolyConvert); 00087 GETSET_DATA_FUNCS_B(RBD_NAME_TRIANGULATE, Triangulate); 00088 GETSET_DATA_FUNCS_V2(RBD_NAME_POLYLOD, PolyLOD); 00089 GETSET_DATA_FUNCS_B(RBD_NAME_ADDBARYCENTER, AddBaryCenter); 00090 00091 explicit RBD_SpherePointTree(const SIM_DataFactory *factory); 00092 virtual ~RBD_SpherePointTree(); 00093 00094 /// Overrides to properly implement this class as a SIM_Data. 00095 /// This object is meant to be updated from the object's geometry at 00096 /// each frame, so we only implement skeleton save, and load methods. 00097 virtual void initializeSubclass(); 00098 virtual int64 getMemorySizeSubclass() const; 00099 virtual bool getIsAlternateRepresentationSubclass() const; 00100 virtual void initAlternateRepresentationSubclass(const SIM_Data &); 00101 00102 private: 00103 static const SIM_DopDescription *getSpherePointTreeDopDescription(); 00104 00105 // This builds the sphere tree from the given set of points. 00106 void buildSpherePointTree(const UT_Vector3Array &pts); 00107 00108 RBD_SpherePointTreeNode *myRoot; 00109 00110 DECLARE_STANDARD_GETCASTTOTYPE(); 00111 DECLARE_DATAFACTORY(RBD_SpherePointTree, 00112 RBD_SphereTree, 00113 "Sphere Point Tree", 00114 getSpherePointTreeDopDescription()); 00115 }; 00116 00117 #endif
1.5.9