HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_ConAnchor.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  */
7 
8 #ifndef __SIM_ConAnchor_h__
9 #define __SIM_ConAnchor_h__
10 
11 #include "SIM_API.h"
12 #include "SIM_DataUtils.h"
13 #include "SIM_OptionsUser.h"
14 
15 class SIM_Object;
16 class SIM_Relationship;
17 
18 /// Definition of the relationship between a constraint and an anchor
19 /// (typically part of a SIM_Object).
20 ///
21 /// It knows
22 /// 1) which object the anchor is associated with (may be none)
23 /// 2) which part of that object (e.g., point, primitive, etc.)
24 /// 3) the position, orientation and linear/angular velocities of the
25 /// anchor
27  public SIM_OptionsUser
28 {
29 public:
30  /// Get the object pointer stored by setReferencedObject(). This is
31  /// the object that defines this anchor, if there is one. The object
32  /// is interpolated to the specified simulation time so that the
33  /// returned anchor values are properly interpolated.
34  const SIM_Object *getReferencedObject(const SIM_Time &time) const;
35 
36  /// Returns true if the anchor has to be initialized before it is used.
37  /// Initialization involves calling initAnchor() on the anchor, passing
38  /// in the object we are attached to, so the anchor can customize itself
39  /// to a particular object. This function calls getNeedsInitSubclass().
40  bool getNeedsInit() const;
41  /// This function performs any initialization that may be required
42  /// to make a constraint specific to a particular object. For example,
43  /// in spatial constraints, this function may convert a world space
44  /// position parameter to an object space position. This function
45  /// calls initAnchorSubclass().
46  void initAnchor(const SIM_Object *object);
47  /// This function will return true if this anchor class requires an
48  /// object specification otherwise it returns false. The returned string
49  /// value can be used in an object filter expression.
50  bool getObjectSpecification(UT_String &str) const;
51  /// This function is responsible for calling the initAnchor function
52  /// which initialize this anchor based on the owner relationship.
53  void initConstraint(const SIM_Relationship *rel);
54 
55  /// Slight variation on buildGuideGeometry. It's just like
56  /// buildGuideGeometry, but it will be called by the constraint using
57  /// the anchor, and will add some extra options about the status of
58  /// that constraint.
59  void buildAnchorGuideGeometry(const SIM_Options &options,
60  const GU_DetailHandle &gdh,
61  const SIM_Relationship &rel,
62  const SIM_Time &t) const;
63 
64 protected:
65  explicit SIM_ConAnchor(const SIM_DataFactory *factory);
66  ~SIM_ConAnchor() override;
67 
68  /// Sets the object that this anchor is defined by. Calling this
69  /// function is the responsibility of the subclasses that are defined
70  /// by objects. This function is generally called from
71  /// initAnchorSubclass().
72  void setReferencedObject(const SIM_Object *object);
73 
74  /// Returns true if the anchor needs to have initAnchor() called. The
75  /// default implementation returns false.
76  virtual bool getNeedsInitSubclass() const;
77  /// Initializes the anchor for use by a solver. The default implementation
78  /// does nothing.
79  virtual void initAnchorSubclass(const SIM_Object *object);
80  /// Implements the real functionality of getObjectSpecification.
81  virtual bool getObjectSpecificationSubclass(UT_String &str) const;
82  /// Implements the real functionality of initConstraint. The default
83  /// implementation calls initAnchor on the object from the relationship
84  /// that we are interested in.
85  virtual void initConstraintSubclass(const SIM_Relationship *rel);
86 
87  /// Default implementation does nothing.
88  virtual void buildAnchorGuideGeometrySubclass(
89  const SIM_Options &options,
90  const GU_DetailHandle &gdh,
91  const SIM_Relationship &rel,
92  const SIM_Time &t) const;
93 
94 private:
95  const SIM_Object *myReferencedObject;
96  SIM_Time myReferencedObjectTime;
97 
100 };
101 
102 #endif
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:50
#define DECLARE_CLASSNAME(DataClass, SuperClass)
Definition: SIM_DataUtils.h:20
GT_API const UT_StringHolder time
GLdouble t
Definition: glad.h:2397
#define SIM_API
Definition: SIM_API.h:12