7 #ifndef __SIM_ConstraintNetworkIteratorImpl_h__
8 #define __SIM_ConstraintNetworkIteratorImpl_h__
13 namespace SIM_ConstraintNetwork
16 const_iterator::skipInvalid()
18 while (!myPrimIterator.
atEnd())
20 myPrimOffset = *myPrimIterator;
22 myConstraintDataIndex = myConstraintNameRef.
getIndex(myPrimOffset);
26 if ((myConstraintDataIndex >= 0
27 && myValidConstraintData.
getBitFast(myConstraintDataIndex))
28 && !(mySkipBroken && myBrokenGroup
29 && myBrokenGroup->
contains(myPrimOffset)))
33 if (vertices.
size() == 2)
49 myConstraintIndex = 0;
58 return !myGdp || myPrimIterator.
atEnd();
79 return myBrokenGroup && myBrokenGroup->
contains(myPrimOffset);
87 if (!myConstraintTypeRef.
isValid())
95 return myConstraintTypes[idx];
101 return anchor1 ? myPtBOffset : myPtAOffset;
116 return myConstraintDataIndex;
122 myConstraintDataIndex = constraint_idx;
123 myPrimOffset = primoff;
129 return myConstraintData[myConstraintDataIndex];
132 template <
typename T>
137 get(attribute_name, *myGdp, myCachedAttributes,
value);
141 template <
typename T>
147 myConstraintDataOptions[myConstraintDataIndex];
150 getOption(options, attribute_name, value);
154 template <
typename T>
160 attribute_name, *myGdp, myCachedAttributes, value);
163 template <
typename T>
167 AttribCache &cache, T &
value)
const
170 auto it = cache.find(attribute_name);
171 if (it != cache.end())
178 value =
h.get(myPrimOffset);
190 cache.emplace(attribute_name, attrib);
197 value =
h.get(myPrimOffset);
206 template <
typename T>
210 AttribCache &cache, T &value)
const
215 value = getDataOption<T>(attribute_name);
221 AttribCache &cache,
fpreal &value)
const
223 value = getDataOption<fpreal>(attribute_name);
227 value *= attrib_value;
233 const CachedObjectData *
data = getCachedData(anchor1);
237 data->getGdp()->pointIndex(off);
243 return myNumDOFsRef.
isValid() ? myNumDOFsRef.
get(getPointOffset(anchor1)) :
250 return myDOFVectorRef.
isValid() ?
251 myDOFVectorRef.
get(getPointOffset(anchor1)) :
258 return myNameRef.
isValid() ? myNameRef.
get(getPointOffset(anchor1)) :
263 GenericAnchorAccessor::getAnchorId(
bool anchor1)
const
265 return myAnchorIdRef.
isValid() ?
266 GA_Index(myAnchorIdRef.
get(getPointOffset(anchor1))) :
271 GenericAnchorAccessor::getInitialAnchorOrientation(
bool anchor1)
const
274 return myOrientRef.
get(getPointOffset(anchor1));
275 else if (myRotationRef.
isValid())
301 const CachedObjectData *
data = getCachedData(anchor1);
315 else if (getAnchorId(anchor1) == -1)
323 GenericAnchorAccessor::getAnchorNameIndex(
bool anchor1)
const
325 return myNameRef.
isValid() ? myNameRef.
getIndex(getPointOffset(anchor1)) :
329 inline const GenericAnchorAccessor::CachedObjectData *
330 GenericAnchorAccessor::getCachedData(
bool anchor1)
const
332 const CachedObjectData *
data =
nullptr;
334 if (str_idx >= 0 && str_idx < myCachedData.
entries())
335 data = myCachedData(str_idx).get();
SIM_API const UT_StringHolder anchor_type
Definition of a geometry attribute.
PositionType
How the position of the anchor is interpreted.
bool getBitFast(exint index) const
GA_Offset getAnchorPointOffset(bool anchor1) const
int getAnchorNumConDOFs(bool anchor1) const
GLsizei const GLfloat * value
UT_Vector3T< float > UT_Vector3
bool getPrimitiveAttribute(const UT_StringRef &attribute_name, T &value) const
SYS_FORCE_INLINE bool isValid() const
SYS_FORCE_INLINE const HOLDER & get(GA_Offset off, int comp=0) const
Get the string at the given offset.
UT_Vector3 getAnchorDOFVector(bool anchor1) const
SYS_FORCE_INLINE INDEXTYPE getIndex(GA_Offset off, int comp=0) const
Get the string index at the given offset.
ConstraintType getConstraintType() const
Returns whether the constraint affects position / rotation / all.
const SIM_Data * getConstraintData() const
void degToRad()
conversion between degrees and radians
#define GA_INVALID_OFFSET
void advance(exint constraint_idx, GA_Offset primoff)
Update the current constraint data type index and primitive offset.
SYS_FORCE_INLINE GA_Index primitiveIndex(GA_Offset offset) const
Given a primitive's data offset, return its index.
static const UT_StringHolder theEmptyString
SYS_FORCE_INLINE GA_OffsetListRef getPrimitiveVertexList(GA_Offset primoff) const
const UT_StringHolder & getAnchorName(bool anchor1) const
GLdouble GLdouble GLint GLint order
SIM_API const UT_StringHolder rotation
exint getConstraintDataIndex() const
Returns the index of the current constraint data type.
#define GA_INVALID_STRING_INDEX
SYS_FORCE_INLINE T get(GA_Offset off, int comp=0) const
SYS_FORCE_INLINE GA_Offset vertexPoint(GA_Offset vertex) const
Given a vertex, return the point it references.
GA_Index getPrimIndex() const
The primitive index.
GA_Size GA_Index
Define the strictness of GA_Offset/GA_Index.
bool contains(const GA_Primitive *prim) const
SYS_FORCE_INLINE const GA_Attribute * findPrimitiveAttribute(GA_AttributeScope s, const UT_StringRef &name) const
SYS_FORCE_INLINE bool isValid() const
exint entries() const
Alias of size(). size() is preferred.
SYS_FORCE_INLINE GA_Index pointIndex(GA_Offset offset) const
Given a point's data offset, return its index.
GLfloat GLfloat GLfloat GLfloat h
ConstraintType
The type of a constraint (linear, angular, or both).
UT_QuaternionT< fpreal32 > UT_Quaternion
PositionType getAnchorPositionType(bool anchor1) const
GA_Index getAnchorPointIndex(bool anchor1) const
T getDataOption(const UT_StringRef &attribute_name) const
Retrieve a value from the attached subdata for the constraint.
GA_BlobIndex GA_StringIndexType
GA_Index getPointNumber(bool anchor1) const
The point number for this anchor in the constraint network geometry.
T get(const UT_StringRef &attribute_name) const
GA_Offset getPointOffset(bool anchor1) const
The point offset for this anchor in the constraint network geometry.
SYS_FORCE_INLINE FromType size() const
Returns the number of used elements in the list (always <= capacity())