HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SIM_ConAnchorObjRegion.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  * NAME: SIM_ConAnchorObjRegion.h ( SIM Library, C++)
7  *
8  * COMMENTS:
9  * This anchor represents a region in space that surrounds goal object.
10  * This can be used to constrain a Solid Object or a Hybrid Object
11  * to a deforming region in space.
12  * In the future, the support for this may be extended to
13  * the Wire Object and Cloth Object as well.
14  */
15 
16 #ifndef __SIM_ConAnchorObjRegion__
17 #define __SIM_ConAnchorObjRegion__
18 
19 #include "SIM_API.h"
20 #include "SIM_ConAnchor.h"
21 
22 #include <UT/UT_Vector4.h>
23 
24 #include <SYS/SYS_Types.h>
25 #include <SYS/SYS_Inline.h>
26 
28 
29 //
30 // PrimitiveSubsimplex identifies a subsimplex of a primitive.
31 // This works only for a specific subset of primitive types:
32 // particle system, polyline (open polygon), polygon (closed polygon)
33 // and tetrahedron.
34 // PrimitiveSubsimplex is a helper struct that is used to define
35 // the various connector (sub-anchor) types below
36 //
38 {
39 public:
41 
42  // Default construct an invalid object
45  mySubindex( -1 )
46  {
47  UT_ASSERT( !isValid() );
48  }
49 
51  const GA_Index primitive_index,
52  const PrimitiveSubindex subindex
53  ) :
54  myPrimitiveIndex( primitive_index ),
55  mySubindex( subindex )
56  {
57  UT_ASSERT( primitive_index != GA_INVALID_INDEX );
58  UT_ASSERT( subindex >= 0 );
59  UT_ASSERT( isValid() );
60  }
61 
63  {
64  return ( myPrimitiveIndex != GA_INVALID_INDEX );
65  }
66 
67  // Index to primitive of type:
68  // particles, polylines, polygons, tetrahedrons
70 
71  // For particles, triangles and polylines, the subindex identifies
72  // a subsimplex of the above primitive
74 };
75 
76 //
77 // ConnectorRealPrimitiveSubsimplex is a connector (sub-anchor) for
78 // a real sub-primitive of an anchor's object geometry.
79 //
81 {
82 public:
85 
86  // Default construct "invalid" location
88  myPrimitiveSubsimplex(), // invalid
89  myBary( 0, 0, 0, 0 )
90  {
91  UT_ASSERT( !isValid() );
92  }
93 
94  // Construct valid location from a point index, a primitive index and bary coords
96  const PrimitiveSubsimplex subprimitive,
97  const Bary& bary
98  ) :
99  myPrimitiveSubsimplex( subprimitive ),
100  myBary( bary )
101  {
102  UT_ASSERT( subprimitive.isValid() );
103  UT_ASSERT( isValid() );
104  }
105 
108 
110  {
112  }
113 
115 
116  // Barycentric coordinates relative to myPrimitiveSubsimplex,
117  // padded with zero values at the end for subprimitives
118  // that have fewer than four vertices (e.g., triangles on a polygon prim)
120 };
121 
122 //
123 // ConnectorRealPoint is a connector (sub-anchor) for
124 // a real point of an anchor's object geometry.
125 //
127 {
128 public:
129  // Default construct "invalid" point
132  {
133  UT_ASSERT( !isValid() );
134  }
135 
137  const GA_Index point_index
138  ) :
139  myPointIndex( point_index )
140  {
141  UT_ASSERT( point_index != GA_INVALID_INDEX );
142  UT_ASSERT( isValid() );
143  }
144 
146  {
147  return ( myPointIndex != GA_INVALID_INDEX );
148  }
149 
152 
154 };
155 
156 //
157 // ConnectorVirtualPoint is a connector (sub-anchor) for
158 // a virtual vertex that is defined relative to an anchor's object geometry.
159 // This virtual vertex is represented using barycentric coordinates
160 // relative to a real sub-primitive of the anchor geometry.
161 //
163 {
164 public:
167 
168  // Default construct "invalid" location
170  myPrimitiveSubsimplex(), // invalid
171  myBary( 0, 0, 0, 0 )
172  {
173  UT_ASSERT( !isValid() );
174  }
175 
176  // Construct valid location from a point index,
177  // a primitive index and bary coords
179  const PrimitiveSubsimplex subprimitive,
180  const Bary& bary
181  ) :
182  myPrimitiveSubsimplex( subprimitive ),
183  myBary( bary )
184  {
185  UT_ASSERT( subprimitive.isValid() );
186  UT_ASSERT( isValid() );
187  }
188 
191 
193  {
195  }
196 
198 
199  // Barycentric coordinates relative to simplex defined by myPrimitiveSubsimplex
200  // with zero at the end for simplices.
201  // that have fewer than four vertices (e.g., triangles on a polygon prim)
203 };
204 
205 //
206 // RealInterface is an ordered array of connectors
207 // at real subprimitives and real points.
208 // A region constraint connects these connectors to corresponding connectors
209 // on the other anchor.
210 // Connections are implied between connectors of matching types
211 // that have the same index in the real and virtual interface.
212 //
213 // This information is precomputed on constraint initialization and stored in
214 // SIM_ConAnchorObjRegion so that the information can be re-used
215 // for an entire simulation.
216 //
218 {
219 public:
221  using ConnectorsRealPrimitiveSubsimplex = std::vector< SIM_ConAnchorObjRegionConnectorRealPrimitiveSubsimplex >;
222 
224  using ConnectorsRealPoint = std::vector< ConnectorRealPoint >;
225 
226  //TODO: use move semantics to pass in here:
228  const ConnectorsRealPoint& connectors_at_rpoint_for_vpoint
229  ) :
230  myConnectorsAtRealPointForVirtualPoint( connectors_at_rpoint_for_vpoint )
231  {
232  }
233 
235 
236  //TODO: ConnectorsRealPrimitiveSubsimplex myConnectorsAtRealPrimitiveSubsimplexForVirtualPoint
238 
239 private:
240  // Disallow
242 };
243 
244 //
245 // VirtualInterface is an ordered array of connectors
246 // at virtual points (defined relative to real primitives in terms of
247 // barycentric coordinates).
248 // A region constraint connects these connectors to corresponding connectors
249 // on the other anchor.
250 // Connections are implied between connectors of matching types
251 // that have the same index in the real and virtual interface.
252 //
253 // This information is precomputed on constraint initialization and stored in
254 // SIM_ConAnchorObjRegion so that the information can be re-used
255 // for an entire simulation.
256 //
258 {
259 public:
261  using ConnectorsVirtualPoint = std::vector< ConnectorVirtualPoint >;
262 
263  //TODO: use move semantics to pass in here:
265  const ConnectorsVirtualPoint& connectors_at_vpoint_for_rpoint
266  ) :
267  myConnectorsAtVirtualPointForRealPoint( connectors_at_vpoint_for_rpoint )
268  {
269  }
270 
272 
273  // TODO: ConnectorsVirtualPoint myConnectorsAtVirtualPointForRealPrimitiveSubsimplex;
275 
276 private:
278  // Return a reference to the set of virtual point connectors of
279 };
280 
281 #define SIM_NAME_REGION_REGISTRATION_ATTRIBUTE "registrationattribute"
282 #define SIM_NAME_REGION_ALLOW_PARTIAL_OVERLAP "allowpartialoverlap"
283 #define SIM_NAME_REGION_ENABLE_MATCHING "enablematching"
284 #define SIM_NAME_REGION_PART_ID_ATTRIBUTE "identifierattribute"
285 
286 #define SIM_NAME_REGION_ENABLE_MULTIPLIERS "enablemultipliers"
287 #define SIM_NAME_REGION_STRENGTH_ATTRIBUTE "strengthattribute"
288 #define SIM_NAME_REGION_DAMPING_ATTRIBUTE "dampingattribute"
289 
291 {
292 public:
295 
298 
299  GETSET_DATA_FUNCS_S( SIM_NAME_OBJECT, ObjectName );
300 
301  // Use a custom registration attribute
303 
305 
306  // Support region matching using a primitive integer attribute
309 
310  // Support local scaling of stiffness using
314 
315  // Initialize the anchor by transferring ownership of
316  // the real and virtual interfaces
317  void initializeInterfaces(
318  RealInterfaceUCP& real_interface,
319  VirtualInterfaceUCP& virtual_interface
320  );
321 
322  // Return a non-owning pointer to the real interface that's held
323  // by this anchor; return nullptr when not available
324  // (do not delete this pointer)
325  const RealInterface* realInterface() const;
326 
327  // Return a non-owning pointer to the virtual interface that's held
328  // by this anchor; return nullptr when not available
329  // (do not delete this pointer)
330  const VirtualInterface* virtualInterface() const;
331 
332 protected:
333  explicit SIM_ConAnchorObjRegion( const SIM_DataFactory *f );
334  virtual ~SIM_ConAnchorObjRegion();
335 
336  bool getNeedsInitSubclass() const;
337 
338  virtual void initAnchorSubclass( const SIM_Object *object );
339 
340  virtual bool getObjectSpecificationSubclass( UT_String &str ) const;
341 
343  const SIM_Options& options,
344  const GU_DetailHandle& gdh,
345  const SIM_Relationship& rel,
346  const SIM_Time& t
347  ) const;
348 
349  virtual void makeEqualSubclass( const SIM_Data* source );
350 
351  //TODO:
352  //virtual void saveSubclass(std::ostream &os) const;
353  //virtual bool loadSubclass(UT_IStream &is);
354 
355 private:
356  RealInterfaceUCP myRealInterface;
357  VirtualInterfaceUCP myVirtualInterface;
358 
359  static const SIM_DopDescription *getDopDescription();
360 
364  "Anchor: Object Region",
365  getDopDescription());
366 };
367 
368 #endif
369 
#define SIM_NAME_REGION_PART_ID_ATTRIBUTE
virtual void makeEqualSubclass(const SIM_Data *source)
#define SIM_NAME_REGION_ENABLE_MULTIPLIERS
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
SIM_ConAnchorObjRegionConnectorVirtualPoint & operator=(const SIM_ConAnchorObjRegionConnectorVirtualPoint &)=default
#define SIM_NAME_REGION_ENABLE_MATCHING
virtual bool getObjectSpecificationSubclass(UT_String &str) const
Implements the real functionality of getObjectSpecification.
#define GETSET_DATA_FUNCS_B(DataName, FuncName)
SIM_ConAnchorObjRegionConnectorRealPrimitiveSubsimplex(const PrimitiveSubsimplex subprimitive, const Bary &bary)
#define GETSET_DATA_FUNCS_S(DataName, FuncName)
virtual void buildAnchorGuideGeometrySubclass(const SIM_Options &options, const GU_DetailHandle &gdh, const SIM_Relationship &rel, const SIM_Time &t) const
Default implementation does nothing.
virtual void initAnchorSubclass(const SIM_Object *object)
const ConnectorsVirtualPoint myConnectorsAtVirtualPointForRealPoint
#define SIM_NAME_REGION_REGISTRATION_ATTRIBUTE
SIM_ConAnchorObjRegionConnectorRealPoint(const GA_Index point_index)
#define DECLARE_DATAFACTORY(DataClass, SuperClass, Description, DopParms)
Definition: SIM_DataUtils.h:58
GLfloat f
Definition: glcorearb.h:1925
const ConnectorsRealPoint myConnectorsAtRealPointForVirtualPoint
#define UT_ASSERT(ZZ)
Definition: UT_Assert.h:102
int64 exint
Definition: SYS_Types.h:109
#define SIM_NAME_REGION_DAMPING_ATTRIBUTE
#define SYS_FORCE_INLINE
Definition: SYS_Inline.h:45
GLsizei GLsizei GLchar * source
Definition: glcorearb.h:802
virtual bool getNeedsInitSubclass() const
SIM_ConAnchorObjRegionVirtualInterface(const ConnectorsVirtualPoint &connectors_at_vpoint_for_rpoint)
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
Definition: GA_Types.h:611
SIM_ConAnchorObjRegionConnectorVirtualPoint(const PrimitiveSubsimplex subprimitive, const Bary &bary)
SIM_ConAnchorObjRegionPrimitiveSubsimplex(const GA_Index primitive_index, const PrimitiveSubindex subindex)
std::vector< SIM_ConAnchorObjRegionConnectorRealPrimitiveSubsimplex > ConnectorsRealPrimitiveSubsimplex
std::vector< ConnectorVirtualPoint > ConnectorsVirtualPoint
SIM_ConAnchorObjRegionConnectorRealPrimitiveSubsimplex & operator=(const SIM_ConAnchorObjRegionConnectorRealPrimitiveSubsimplex &)=default
#define SIM_NAME_OBJECT
Definition: SIM_Names.h:224
std::vector< ConnectorRealPoint > ConnectorsRealPoint
#define SIM_NAME_REGION_STRENGTH_ATTRIBUTE
#define SIM_API
Definition: SIM_API.h:10
#define GA_INVALID_INDEX
Definition: GA_Types.h:653
#define SIM_NAME_REGION_ALLOW_PARTIAL_OVERLAP
SIM_ConAnchorObjRegionConnectorRealPoint & operator=(const SIM_ConAnchorObjRegionConnectorRealPoint &)=default
SIM_ConAnchorObjRegionRealInterface(const ConnectorsRealPoint &connectors_at_rpoint_for_vpoint)