HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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 DOP_API bool DOPfindAllDataFromPath(const char *path,
155  DOP_FullPathDataArray &fulldata,
156  fpreal time, OP_Node *relativetonode = 0,
157  bool dopparentisenough = false);
158 DOP_API void DOPglobPathAndFindAllData(const char *path,
159  DOP_FullPathDataArray &fulldata,
160  OP_NodeList &nodatadopnets,
161  fpreal time, OP_Node *relativetonode = 0,
162  OP_GlobContext *context = 0);
163 
164 /// If the dopparent is currently simulating it is not possible to
165 /// reset its time. Similarly, if the desired time is within the last
166 /// timestep, we can't interpolate since the actual 'current' value
167 /// of the object is stored at the end time.
168 /// Returned from this is the new time to use for accesses.
169 /// In case of unsimulated networks, it is the same as
170 /// dopparent->setDOPTime(time); return time;
172 
173 /// The following functions are the only ones which are thread-safe for
174 /// accessing DOP data
175 // @{
176 
177 /// Thread-safe method to find the owner node of a DOP data path
179  const char *path,
180  fpreal time, OP_Node *relativetonode = 0,
181  bool dopparentisenough = false);
182 
183 /// Thread-safe method to world transform of the a DOP data path, optionally
184 /// returning the geometry if there is any (and gdh is non-NULL). If given
185 /// an interested_node, then we will add an extra input on it to the path.
187  UT_DMatrix4 &xform,
189  bool &timedep,
190  const char *path,
191  OP_Context &context,
192  OP_Node *relativetonode = 0,
193  bool dopparentisenough = false,
194  OP_Node *interested_node = 0);
195 
196 // @}
197 
198 #endif
199 
DOP_API void DOPglobPathAndFindAllData(const char *path, DOP_FullPathDataArray &fulldata, OP_NodeList &nodatadopnets, fpreal time, OP_Node *relativetonode=0, OP_GlobContext *context=0)
#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)
GLsizei const GLchar *const * path
Definition: glcorearb.h:3340
GLuint buffer
Definition: glcorearb.h:659
const SIM_Position * getPositionForGeometry(const char *geo) const
#define DOP_API
Definition: DOP_API.h:10
This class holds a signed distance function representing a GU_Detail.
Definition: SIM_SDF.h:27
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)
GLboolean * data
Definition: glcorearb.h:130
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.
int cmp(T a, T b)
Definition: ImathFun.h:119
double fpreal
Definition: SYS_Types.h:263
const SIM_Position * getPosition() const
const SIM_RootData * myRootData
bool operator==(const DOP_FullPathData &cmp) const
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
const DOP_FullPathData & operator=(const DOP_FullPathData &src)
const SIM_Data * myData
GLenum src
Definition: glcorearb.h:1792