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_ConAnchor_h__ 00015 #define __SIM_ConAnchor_h__ 00016 00017 #include "SIM_API.h" 00018 #include "SIM_DataUtils.h" 00019 #include "SIM_OptionsUser.h" 00020 00021 class SIM_Object; 00022 class SIM_Relationship; 00023 00024 /// Definition of the relationship between a constraint and an anchor 00025 /// (typically part of a SIM_Object). 00026 /// 00027 /// It knows 00028 /// 1) which object the anchor is associated with (may be none) 00029 /// 2) which part of that object (e.g., point, primitive, etc.) 00030 /// 3) the position, orientation and linear/angular velocities of the 00031 /// anchor 00032 class SIM_API SIM_ConAnchor : public SIM_Data, 00033 public SIM_OptionsUser 00034 { 00035 public: 00036 /// Get the object pointer stored by setReferencedObject(). This is 00037 /// the object that defines this anchor, if there is one. The object 00038 /// is interpolated to the specified simulation time so that the 00039 /// returned anchor values are properly interpolated. 00040 const SIM_Object *getReferencedObject(const SIM_Time &time) const; 00041 00042 /// Returns true if the anchor has to be initialized before it is used. 00043 /// Initialization involves calling initAnchor() on the anchor, passing 00044 /// in the object we are attached to, so the anchor can customize itself 00045 /// to a particular object. This function calls getNeedsInitSubclass(). 00046 bool getNeedsInit() const; 00047 /// This function performs any initialization that may be required 00048 /// to make a constraint specific to a particular object. For example, 00049 /// in spatial constraints, this function may convert a world space 00050 /// position parameter to an object space position. This function 00051 /// calls initAnchorSubclass(). 00052 void initAnchor(const SIM_Object *object); 00053 /// This function will return true if this anchor class requires an 00054 /// object specification otherwise it returns false. The returned string 00055 /// value can be used in an object filter expression. 00056 bool getObjectSpecification(UT_String &str) const; 00057 /// This function is responsible for calling the initAnchor function 00058 /// which initialize this anchor based on the owner relationship. 00059 void initConstraint(const SIM_Relationship *rel); 00060 00061 /// Slight variation on buildGuideGeometry. It's just like 00062 /// buildGuideGeometry, but it will be called by the constraint using 00063 /// the anchor, and will add some extra options about the status of 00064 /// that constraint. 00065 void buildAnchorGuideGeometry(const SIM_Options &options, 00066 const GU_DetailHandle &gdh, 00067 const SIM_Relationship &rel, 00068 const SIM_Time &t) const; 00069 00070 protected: 00071 explicit SIM_ConAnchor(const SIM_DataFactory *factory); 00072 virtual ~SIM_ConAnchor(); 00073 00074 /// Sets the object that this anchor is defined by. Calling this 00075 /// function is the responsibility of the subclasses that are defined 00076 /// by objects. This function is generally called from 00077 /// initAnchorSubclass(). 00078 void setReferencedObject(const SIM_Object *object); 00079 00080 /// Returns true if the anchor needs to have initAnchor() called. The 00081 /// default implementation returns false. 00082 virtual bool getNeedsInitSubclass() const; 00083 /// Initializes the anchor for use by a solver. The default implementation 00084 /// does nothing. 00085 virtual void initAnchorSubclass(const SIM_Object *object); 00086 /// Implements the real functionality of getObjectSpecification. 00087 virtual bool getObjectSpecificationSubclass(UT_String &str) const; 00088 /// Implements the real functionality of initConstraint. The default 00089 /// implementation calls initAnchor on the object from the relationship 00090 /// that we are interested in. 00091 virtual void initConstraintSubclass(const SIM_Relationship *rel); 00092 00093 /// Default implementation does nothing. 00094 virtual void buildAnchorGuideGeometrySubclass( 00095 const SIM_Options &options, 00096 const GU_DetailHandle &gdh, 00097 const SIM_Relationship &rel, 00098 const SIM_Time &t) const; 00099 00100 private: 00101 const SIM_Object *myReferencedObject; 00102 SIM_Time myReferencedObjectTime; 00103 00104 DECLARE_STANDARD_GETCASTTOTYPE(); 00105 DECLARE_CLASSNAME(SIM_ConAnchor, SIM_Data); 00106 }; 00107 00108 #endif
1.5.9