HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DOP_FullPathData.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: DOP_FullPathData.h ( SOP Library, C++)
7  *
8  * COMMENTS:
9  */
10 
11 #ifndef __DOP_FullPathData_h__
12 #define __DOP_FullPathData_h__
13 
14 #include "DOP_API.h"
15 #include <UT/UT_Array.h>
16 #include <UT/UT_String.h>
17 #include <OP/OP_Node.h>
18 #include <GU/GU_DetailHandle.h>
19 #include "DOP_Engine.h"
20 
21 class UT_WorkBuffer;
22 class UT_StringArray;
24 class SIM_Data;
25 class SIM_Object;
27 class SIM_SDF;
28 class OP_Context;
29 class OP_GlobContext;
30 class DOP_Parent;
32 
34 {
35 public:
37  {
38  myNode = 0;
39  myParent = 0;
40  myRootData = 0;
41  myData = 0;
42  myDataName = "";
43  myGlobalTime = 0;
44  }
46  {
47  *this = src;
48  }
50  {
51  }
52 
53  static const SIM_Position *getBestPosition(const SIM_RootData *rootdata,
54  const SIM_Data *data,
55  const char *dataname)
56  {
57  const SIM_Position *position = 0;
58  const SIM_Object *obj;
59 
60  // Get our root data as a SIM_Object.
61  obj = SIM_DATA_CASTCONST(rootdata, SIM_Object);
62 
63  // Get the transform from the SIM_Position data.
64  if (data)
65  position = SIM_DATA_CASTCONST(data, SIM_Position);
66 
67  // If it's an object, get the "Position" data.
68  if (!position && obj && obj == data)
69  position = obj->getPosition();
70 
71  // Check if we can get a position from the
72  // data directly.
73  if (!position && obj)
74  position = obj->getPositionForGeometry(dataname);
75 
76  // If it's an SDF, check the parent's position.
77  if (!position && obj && SIM_DATA_CASTCONST(data, SIM_SDF))
78  {
79  UT_String geopath, sdfname;
80  UT_StringWrap(dataname).splitPath(geopath, sdfname);
81  position = obj->getPositionForGeometry(geopath);
82  }
83 
84  return position;
85  }
86 
88  {
89  return getBestPosition(myRootData, myData, myDataName);
90  }
91 
92  static GU_ConstDetailHandle getBestGeometry(UT_DMatrix4 &xform,
93  const SIM_RootData *rootdata,
94  const SIM_Data *data,
95  const char *dataname,
96  fpreal simtime);
97 
98  GU_ConstDetailHandle getBestGeometry(UT_DMatrix4 &xform) const;
99 
100  bool operator==(const DOP_FullPathData &cmp) const
101  {
102  return ((myNode == cmp.myNode) &&
103  (myParent == cmp.myParent) &&
104  (myRootData == cmp.myRootData) &&
105  (myData == cmp.myData) &&
106  (myDataName == cmp.myDataName));
107  }
108 
110  {
111  myNode = src.myNode;
112  myParent = src.myParent;
113  myRootData = src.myRootData;
114  myData = src.myData;
115  myDataName.harden(src.myDataName);
116 
117  return *this;
118  }
119 
120  void clear()
121  {
122  myNode = 0;
123  myParent = 0;
124  myRootData = 0;
125  myData = 0;
126  myDataName = "";
127  }
128 
132  const SIM_Data *myData;
134 
135  // Not simulation time.
137 };
138 
139 class DOP_API DOP_FullPathDataArray : public UT_Array<DOP_FullPathData>
140 {
141 public:
143  virtual ~DOP_FullPathDataArray();
144 
145  void buildFromPaths(const UT_StringArray &paths);
146  void getObjectArray(SIM_ConstObjectArray &objects) const;
147  void getObjectString(UT_WorkBuffer &buffer) const;
148 };
149 
150 DOP_API bool DOPfindDataFromPath(const char *path,
151  DOP_FullPathData &fulldata,
152  fpreal time, OP_Node *relativetonode = 0,
153  bool dopparentisenough = false);
154 /// Version of DOPfindDataFromPath() that uses the provided SIM_Engine instead
155 /// of searching for a DOP node at the beginning of the path.
156 DOP_API bool DOPfindDataFromPath(const char *path,
157  DOP_FullPathData &fulldata,
158  const SIM_Engine &engine,
159  const SIM_Time &sim_time,
160  bool interpolate_data);
161 DOP_API bool DOPfindAllDataFromPath(const char *path,
162  DOP_FullPathDataArray &fulldata,
163  fpreal time, OP_Node *relativetonode = 0,
164  bool dopparentisenough = false);
165 /// Version of DOPfindAllDataFromPath() that uses the provided SIM_Engine
166 /// instead of searching for a DOP node at the beginning of the path.
167 DOP_API bool DOPfindAllDataFromPath(const char *path,
168  DOP_FullPathDataArray &fulldata,
169  const SIM_Engine &engine,
170  const SIM_Time &sim_time,
171  bool interpolate_data);
172 DOP_API void DOPglobPathAndFindAllData(const char *path,
173  DOP_FullPathDataArray &fulldata,
174  OP_NodeList &nodatadopnets,
175  fpreal time, OP_Node *relativetonode = 0,
176  OP_GlobContext *context = 0,
177  OP_Node *errorsink = 0);
178 
179 /// If the dopparent is currently simulating it is not possible to
180 /// reset its time. Similarly, if the desired time is within the last
181 /// timestep, we can't interpolate since the actual 'current' value
182 /// of the object is stored at the end time.
183 /// Returned from this is the new time to use for accesses.
184 /// In case of unsimulated networks, it is the same as
185 /// dopparent->setDOPTime(time); return time;
187 
188 /// The following functions are the only ones which are thread-safe for
189 /// accessing DOP data
190 // @{
191 
192 /// Thread-safe method to find the owner node of a DOP data path
194  const char *path,
195  fpreal time, OP_Node *relativetonode = 0,
196  bool dopparentisenough = false);
197 
198 /// Thread-safe method to world transform of the a DOP data path, optionally
199 /// returning the geometry if there is any (and gdh is non-NULL). If given
200 /// an interested_node, then we will add an extra input on it to the path.
202  UT_DMatrix4 &xform,
204  bool &timedep,
205  const char *path,
206  OP_Context &context,
207  OP_Node *relativetonode = 0,
208  bool dopparentisenough = false,
209  OP_Node *interested_node = 0);
210 
211 // @}
212 
213 #endif
214 
#define SIM_DATA_CASTCONST(Data, DataClass)
Definition: SIM_Utils.h:34
DOP_FullPathData(const DOP_FullPathData &src)
DOP_API bool DOPgetWorldTransformFromDataPath(UT_DMatrix4 &xform, GU_ConstDetailHandle *gdh, bool &timedep, const char *path, OP_Context &context, OP_Node *relativetonode=0, bool dopparentisenough=false, OP_Node *interested_node=0)
GT_API const UT_StringHolder time
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
GLenum src
Definition: glcorearb.h:1793
IMATH_HOSTDEVICE constexpr int cmp(T a, T b) IMATH_NOEXCEPT
Definition: ImathFun.h:84
const SIM_Position * getPositionForGeometry(const char *geo) const
Definition: core.h:760
#define DOP_API
Definition: DOP_API.h:10
This class holds a signed distance function representing a GU_Detail.
Definition: SIM_SDF.h:27
GLhandleARB obj
Definition: glew.h:6266
DOP_API OP_Node * DOPgetNodeFromDataPath(const char *path, fpreal time, OP_Node *relativetonode=0, bool dopparentisenough=false)
Thread-safe method to find the owner node of a DOP data path.
DOP_API bool DOPfindDataFromPath(const char *path, DOP_FullPathData &fulldata, fpreal time, OP_Node *relativetonode=0, bool dopparentisenough=false)
static const SIM_Position * getBestPosition(const SIM_RootData *rootdata, const SIM_Data *data, const char *dataname)
Holds pointers to a number of const SIM_Object objects.
const SIM_Position * getPosition() const
const SIM_RootData * myRootData
fpreal64 fpreal
Definition: SYS_Types.h:277
bool operator==(const DOP_FullPathData &cmp) const
DOP_API void DOPglobPathAndFindAllData(const char *path, DOP_FullPathDataArray &fulldata, OP_NodeList &nodatadopnets, fpreal time, OP_Node *relativetonode=0, OP_GlobContext *context=0, OP_Node *errorsink=0)
DOP_API bool DOPfindAllDataFromPath(const char *path, DOP_FullPathDataArray &fulldata, fpreal time, OP_Node *relativetonode=0, bool dopparentisenough=false)
void splitPath(UT_String &dir_name, UT_String &file_name) const
DOP_Parent * myParent
DOP_API SIM_Time DOPsetBestTime(DOP_Parent *dopparent, SIM_Time time)
const SIM_Position * getBestPosition() const
Definition: format.h:895
const DOP_FullPathData & operator=(const DOP_FullPathData &src)
GLenum const void * paths
Definition: glew.h:13872
const SIM_Data * myData