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 * Side Effects Software Inc. 00008 * 123 Front Street West, Suite 1401 00009 * Toronto, Ontario 00010 * Canada M5J 2M2 00011 * 416-504-9876 00012 */ 00013 00014 #ifndef __SIM_Geometry_h__ 00015 #define __SIM_Geometry_h__ 00016 00017 #include "SIM_API.h" 00018 #include <GU/GU_DetailHandle.h> 00019 #include "SIM_OptionsUser.h" 00020 #include "SIM_DataUtils.h" 00021 00022 class UT_DMatrix4; 00023 class UT_IStream; 00024 00025 /// This is the definitions for the SIM_Geometry interface. It also 00026 /// provides a default implementation that returns an empty geometry and 00027 /// an identity transform. It also has the facility to hold its own 00028 /// geometry and transform as internal data. If set, these are saved and 00029 /// loaded automatically. But there is no way for anyone except subclasses 00030 /// to set these internal data. Thus they are really just a convenience 00031 /// when writing SIM_Geometry subcalsses. 00032 class SIM_API SIM_Geometry : public SIM_Data, 00033 public SIM_OptionsUser 00034 { 00035 public: 00036 /// Accesses the relative path to the position data associated with 00037 /// this geometry. 00038 GETSET_DATA_FUNCS_S(SIM_NAME_POSITIONPATH, PositionPath); 00039 00040 /// Method for accessing the geometry. If we have some internal 00041 /// geometry data, we return that. Otherwise this function calls 00042 /// getGeometrySubclass(). 00043 GU_ConstDetailHandle getGeometry() const; 00044 /// Get the geometry transform. If we have some internal transform 00045 /// data, we return that. Otherwise this function calls 00046 /// getTransformSubclass(). 00047 void getTransform(UT_DMatrix4 &xform) const; 00048 00049 protected: 00050 explicit SIM_Geometry(const SIM_DataFactory *factory); 00051 virtual ~SIM_Geometry(); 00052 00053 /// Set initial values on all the geometry attributes. 00054 virtual void initializeSubclass(); 00055 /// Makes this geometry equal to some other SIM_Geometry. 00056 virtual void makeEqualSubclass(const SIM_Data *source); 00057 /// Saves our attributes, and our internal data if it has been set. 00058 virtual void saveSubclass(ostream &os) const; 00059 /// Loads our attributes and internal data if it was set when we saved. 00060 virtual bool loadSubclass(UT_IStream &is); 00061 /// Creates a query object specifically for geometry data to access 00062 /// the transforms associated with geometry data. 00063 virtual SIM_Query *createQueryObjectSubclass() const; 00064 /// Create an interpolation between two other SIM_Geometry subclasses. 00065 /// This is one place where the internal data gets used automatically. 00066 /// Since the source data may be of any subclass, the only way to 00067 /// safely and correctly interpolate between two SIM_Geometry subclasses 00068 /// is to copy one of the source geometry and transform to our internal 00069 /// data, and then do a blend towards the second source data. 00070 virtual void interpolateSubclass(const SIM_Data *source1, 00071 const SIM_Data *source2, 00072 fpreal interp); 00073 virtual int64 getMemorySizeSubclass() const; 00074 00075 /// This function is called by getGeometry() to return the actual 00076 /// geometry data. The default implementation returns an empty geometry. 00077 virtual GU_ConstDetailHandle getGeometrySubclass() const; 00078 /// This function is called by getTransform() to return the actual 00079 /// transform data. The default implementation returns an identity matrix. 00080 virtual void getTransformSubclass(UT_DMatrix4 &xform) const; 00081 00082 /// Set our internal geometry data. If some internal data already exists, 00083 /// it is deleted. The pointer passed in becomes controlled by the 00084 /// SIM_Geometry so must not be deleted by external code. A null pointer 00085 /// can be passed in to clear our internal geometry data. 00086 void setOwnGeometry(GU_Detail *gdp); 00087 /// Set our internal geometry data from an existing GU_DetailHandle. 00088 /// If some internal data already exists, it is deleted. 00089 void setOwnGeometry(const GU_DetailHandle &gdh); 00090 /// Returns a const pointer to our internal geometry data, if it is set. 00091 GU_ConstDetailHandle getOwnGeometry() const; 00092 /// Returns a pointer to our internal geometry data, if it is set. 00093 GU_DetailHandle getOwnGeometry(); 00094 /// Set our internal transform data. If some internal data already exists, 00095 /// it is deleted. The pointer passed in becomes controlled by the 00096 /// SIM_Geometry so must not be deleted by external code. A null pointer 00097 /// can be passed in to clear our internal transform data. 00098 void setOwnTransform(UT_DMatrix4 *xform); 00099 /// Returns a const pointer to our internal transform data, if it is set. 00100 const UT_DMatrix4 *getOwnTransform() const; 00101 /// Returns a pointer to our internal transform data, if it is set. 00102 UT_DMatrix4 *getOwnTransform(); 00103 00104 private: 00105 GU_DetailHandle myOwnGeometry; 00106 UT_DMatrix4 *myOwnTransform; 00107 00108 DECLARE_STANDARD_GETCASTTOTYPE(); 00109 DECLARE_CLASSNAME(SIM_Geometry, SIM_Data); 00110 }; 00111 00112 #endif 00113
1.5.9