RenderManAPI  24.0
ImplicitField.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 2020 Pixar. All rights reserved.
5 #
6 # The information in this file (the "Software") is provided for the exclusive
7 # use of the software licensees of Pixar ("Licensees"). Licensees have the
8 # right to incorporate the Software into other products for use by other
9 # authorized software licensees of Pixar, without fee. Except as expressly
10 # permitted herein, the Software may not be disclosed to third parties, copied
11 # or duplicated in any form, in whole or in part, without the prior written
12 # permission of Pixar.
13 #
14 # The copyright notices in the Software and this entire statement, including the
15 # above license grant, this restriction and the following disclaimer, must be
16 # included in all copies of the Software, in whole or in part, and all permitted
17 # derivative works of the Software, unless such copies or derivative works are
18 # solely in the form of machine-executable object code generated by a source
19 # language processor.
20 #
21 # PIXAR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
22 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL PIXAR BE
23 # LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
24 # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
25 # OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
26 # CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. IN NO CASE WILL
27 # PIXAR'S TOTAL LIABILITY FOR ALL DAMAGES ARISING OUT OF OR IN CONNECTION WITH
28 # THE USE OR PERFORMANCE OF THIS SOFTWARE EXCEED $50.
29 #
30 # Pixar
31 # 1200 Park Ave
32 # Emeryville CA 94608
33 #
34 # ------------------------------------------------------------------------------
35 */
36 
37 #ifndef IMPLICITFIELD_H
38 #define IMPLICITFIELD_H
39 
40 #include <cstddef> // for NULL
41 #include <vector> // for vector
42 #include "prmanapi.h" // for PRMANEXPORT
43 #include "ri.h" // for RtPoint, RtBound, etc
44 #include "RixInterfaces.h"
45 
46 #define IMPLICIT_VER 7
47 
49 {
50 private:
51  /* inhibit copying */
53  ImplicitVertexValue& operator=(const ImplicitVertexValue&);
54 
55 public:
57  virtual ~ImplicitVertexValue() {}
58 
65  virtual void GetVertexValue(float* result, const RtPoint p) = 0;
66 
74  virtual void GetVertexValueFiltered(
75  float* result,
76  const RtPoint p,
77  const RtPoint dPdu,
78  const RtPoint dPdv,
79  const RtPoint dPdw)
80  {
81  PIXAR_ARGUSED(dPdu);
82  PIXAR_ARGUSED(dPdv);
83  PIXAR_ARGUSED(dPdw);
84 
85  GetVertexValue(result, p);
86  }
87 
96  virtual void GetVertexValueMultiple(
97  int neval,
98  float* result,
99  int resultstride,
100  const RtPoint* p)
101  {
102  for (int i = 0; i < neval; ++i)
103  {
104  GetVertexValue(result, *p++);
105  result += resultstride;
106  }
107  }
108 
118  int neval,
119  float* result,
120  int resultstride,
121  const RtPoint* p,
122  const RtPoint* dPdu,
123  const RtPoint* dPdv,
124  const RtPoint* dPdw)
125  {
126  for (int i = 0; i < neval; ++i)
127  {
128  GetVertexValueFiltered(result, *p++, *dPdu++, *dPdv++, *dPdw++);
129  result += resultstride;
130  }
131  }
132 
142  int neval,
143  float* result,
144  int resultstride,
145  const RtPoint* p,
146  const float* time)
147  {
148  PIXAR_ARGUSED(time);
149 
150  GetVertexValueMultiple(neval, result, resultstride, p);
151  }
152 
162  int neval,
163  float* result,
164  int resultstride,
165  const RtPoint* p,
166  const RtPoint* dPdu,
167  const RtPoint* dPdv,
168  const RtPoint* dPdw,
169  const float* time)
170  {
171  PIXAR_ARGUSED(time);
172 
173  GetVertexValueMultipleFiltered(neval, result, resultstride, p,
174  dPdu, dPdv, dPdw);
175  }
176 
181  virtual size_t MemoryUsage()
182  {
183  return 0;
184  }
185 };
186 
188 {
189 public:
195 
196 private:
197  /* inhibit copying */
199  ImplicitField& operator=(const ImplicitField&);
200 
201 public:
203  virtual ~ImplicitField() {}
204 
207  virtual float Eval(const RtPoint p) = 0;
208 
212  virtual float EvalFiltered(
213  const RtPoint p,
214  const RtPoint dPdu,
215  const RtPoint dPdv,
216  const RtPoint dPdw)
217  {
218  PIXAR_ARGUSED(dPdu);
219  PIXAR_ARGUSED(dPdv);
220  PIXAR_ARGUSED(dPdw);
221 
222  return Eval(p);
223  }
224 
229  virtual void EvalMultiple(
230  int neval,
231  float* result,
232  int resultstride,
233  const RtPoint* p)
234  {
235  for (int i = 0; i < neval; ++i)
236  {
237  *result = Eval(*p++);
238  result += resultstride;
239  }
240  }
241 
246  virtual void EvalMultipleFiltered(
247  int neval,
248  float* result,
249  int resultstride,
250  const RtPoint* p,
251  const RtPoint* dPdu,
252  const RtPoint* dPdv,
253  const RtPoint* dPdw)
254  {
255  PIXAR_ARGUSED(dPdu);
256  PIXAR_ARGUSED(dPdv);
257  PIXAR_ARGUSED(dPdw);
258 
259  EvalMultiple(neval, result, resultstride, p);
260  }
261 
264  virtual void GradientEval(RtPoint result, const RtPoint p) = 0;
265 
268  virtual void GradientEvalFiltered(
269  RtPoint result,
270  const RtPoint p,
271  const RtPoint dPdu,
272  const RtPoint dPdv,
273  const RtPoint dPdw)
274  {
275  PIXAR_ARGUSED(dPdu);
276  PIXAR_ARGUSED(dPdv);
277  PIXAR_ARGUSED(dPdw);
278 
279  GradientEval(result, p);
280  }
281 
285  virtual void GradientEvalMultiple(
286  int neval,
287  RtPoint* result,
288  const RtPoint* p)
289  {
290  for (int i = 0; i < neval; ++i)
291  {
292  GradientEval(*result++, *p++);
293  }
294  }
295 
300  int neval,
301  RtPoint* result,
302  const RtPoint* p,
303  const RtPoint* dPdu,
304  const RtPoint* dPdv,
305  const RtPoint* dPdw)
306  {
307  PIXAR_ARGUSED(dPdu);
308  PIXAR_ARGUSED(dPdv);
309  PIXAR_ARGUSED(dPdw);
310 
311  GradientEvalMultiple(neval, result, p);
312  }
313 
323  virtual void Range(
324  RtInterval result,
325  const RtPoint corners[8],
326  const RtVolumeHandle h)
327  {
328  PIXAR_ARGUSED(corners);
329  PIXAR_ARGUSED(h);
330 
331  result[0] = -1e30f;
332  result[1] = 1e30f;
333  }
334 
336  virtual bool ShouldSplit() { return false; }
337 
343  virtual void Split(std::vector<ImplicitField*>& children)
344  {
345  PIXAR_ARGUSED(children);
346  }
347 
352  virtual void Motion(RtPoint result, const RtPoint p)
353  {
354  PIXAR_ARGUSED(p);
355 
356  result[0] = 0.0f;
357  result[1] = 0.0f;
358  result[2] = 0.0f;
359  }
360 
365  virtual void MotionFiltered(
366  RtPoint result,
367  const RtPoint p,
368  const RtPoint dPdu,
369  const RtPoint dPdv,
370  const RtPoint dPdw)
371  {
372  PIXAR_ARGUSED(dPdu);
373  PIXAR_ARGUSED(dPdv);
374  PIXAR_ARGUSED(dPdw);
375 
376  Motion(result, p);
377  }
378 
381  virtual void MotionMultiple(int neval, RtPoint* result, const RtPoint* p)
382  {
383  for (int i = 0; i < neval; ++i)
384  {
385  Motion(*result++, *p++);
386  }
387  }
388 
392  int neval,
393  RtPoint* result,
394  const RtPoint* p,
395  const RtPoint* dPdu,
396  const RtPoint* dPdv,
397  const RtPoint* dPdw)
398  {
399  PIXAR_ARGUSED(dPdu);
400  PIXAR_ARGUSED(dPdv);
401  PIXAR_ARGUSED(dPdw);
402 
403  MotionMultiple(neval, result, p);
404  }
405 
411  virtual void BoxMotion(RtBound result, const RtBound b)
412  {
413  for (int i = 0; i < 6; i++)
414  {
415  result[i] = b[i];
416  }
417  }
418 
432  virtual void VolumeCompleted(const RtVolumeHandle h)
433  {
434  PIXAR_ARGUSED(h);
435  }
436 
448  const RtUString name,
449  int nvalue)
450  {
451  PIXAR_ARGUSED(name);
452  PIXAR_ARGUSED(nvalue);
453 
454  return 0;
455  }
456 
461  virtual float MinimumVoxelSize(
462  const RtPoint corners[8])
463  {
464  PIXAR_ARGUSED(corners);
465 
466  return 0.0f;
467  }
468 
474  virtual void HullCorners(RtPoint** corners, int* ncorners)
475  {
476  *corners = NULL;
477  *ncorners = 0;
478  }
479 
490  virtual void HullCornersMotion(
491  RtPoint* corners,
492  int ncorners,
493  RtPoint** motioncorners,
494  int* nmotioncorners)
495  {
496  PIXAR_ARGUSED(corners);
497  PIXAR_ARGUSED(ncorners);
498 
499  *motioncorners = NULL;
500  *nmotioncorners = 0;
501  }
502 
506  virtual size_t MemoryUsage()
507  {
508  return 0;
509  }
510 };
511 
512 #define FIELDCREATE \
513  extern "C" const PRMANEXPORT int ImplicitFieldVersion = IMPLICIT_VER; \
514  extern "C" PRMANEXPORT ImplicitField* ImplicitFieldNew( \
515  int nfloat, const float* float0, const float* float1, \
516  int nstring, const RtString* string)
517 
518 #define FIELDCREATE_ARGUSED \
519  PIXAR_ARGUSED(nfloat); \
520  PIXAR_ARGUSED(float0); \
521  PIXAR_ARGUSED(float1); \
522  PIXAR_ARGUSED(nstring); \
523  PIXAR_ARGUSED(string);
524 
525 #endif
virtual void EvalMultiple(int neval, float *result, int resultstride, const RtPoint *p)
Calculates the neval field values at point p, in object coordinates, at shutter open time...
Definition: ImplicitField.h:229
virtual void GetVertexValue(float *result, const RtPoint p)=0
Stores in result the value of the named vertex variable associated with the call to CreateVertexValue...
virtual void MotionMultipleFiltered(int neval, RtPoint *result, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw)
Stores into result the filtered motion vectors representing the movement of the neval p values per un...
Definition: ImplicitField.h:391
virtual void GradientEval(RtPoint result, const RtPoint p)=0
Stores the field gradient at point p, in object coordinates calculated at shutter open time...
virtual void Motion(RtPoint result, const RtPoint p)
Stores into result how much the point p moves per unit time (i.e.
Definition: ImplicitField.h:352
ImplicitVertexValue()
Definition: ImplicitField.h:56
virtual void MotionFiltered(RtPoint result, const RtPoint p, const RtPoint dPdu, const RtPoint dPdv, const RtPoint dPdw)
Stores into result how much the point p moves per unit time (i.e.
Definition: ImplicitField.h:365
virtual void GradientEvalMultipleFiltered(int neval, RtPoint *result, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw)
Calculates the filtered field gradients at points p, in object coordinates calculated at shutter open...
Definition: ImplicitField.h:299
virtual void VolumeCompleted(const RtVolumeHandle h)
VolumeCompleted is a courtesy callback, hinting that PRMan has finished processing all points inside ...
Definition: ImplicitField.h:432
ImplicitField()
Definition: ImplicitField.h:202
virtual void GetVertexValueMultiple(int neval, float *result, int resultstride, const RtPoint *p)
Stores in result the values of the named vertex variable associated with the call to CreateVertexValu...
Definition: ImplicitField.h:96
float RtPoint[3]
Definition: ri.h:58
virtual void HullCornersMotion(RtPoint *corners, int ncorners, RtPoint **motioncorners, int *nmotioncorners)
Given corners of a shutter open convex hull, this routine must modify them to take into account any m...
Definition: ImplicitField.h:490
RtBound bbox
The bbox field must be filled in during initialization with a bounding box outside which the field va...
Definition: ImplicitField.h:194
virtual ~ImplicitVertexValue()
Definition: ImplicitField.h:57
virtual void GetVertexValueMultipleFiltered(int neval, float *result, int resultstride, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw)
Stores in result the filtered values of the named vertex variable associated with the call to CreateV...
Definition: ImplicitField.h:117
virtual float Eval(const RtPoint p)=0
Returns the field value at point p, in object coordinates, at shutter open time.
float RtBound[6]
Definition: ri.h:64
virtual void Range(RtInterval result, const RtPoint corners[8], const RtVolumeHandle h)
Stores into result the bounds of the field function values inside the region of object space with the...
Definition: ImplicitField.h:323
virtual ImplicitVertexValue * CreateVertexValue(const RtUString name, int nvalue)
CreateVertexValue informs the plugin of a vertex variable declaration, asking that the plugin provide...
Definition: ImplicitField.h:447
virtual void GradientEvalMultiple(int neval, RtPoint *result, const RtPoint *p)
Calculates the field gradients at points p, in object coordinates calculated at shutter open time...
Definition: ImplicitField.h:285
virtual void GradientEvalFiltered(RtPoint result, const RtPoint p, const RtPoint dPdu, const RtPoint dPdv, const RtPoint dPdw)
Stores the field gradient at point p, in object coordinates calculated at shutter open time...
Definition: ImplicitField.h:268
virtual void GetVertexValueMultipleTemporalFiltered(int neval, float *result, int resultstride, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw, const float *time)
Stores in result the time-dependent value of the named vertex variable associated with the call to Cr...
Definition: ImplicitField.h:161
virtual void MotionMultiple(int neval, RtPoint *result, const RtPoint *p)
Stores into result how much the neval points p move per unit time (i.e.
Definition: ImplicitField.h:381
virtual float MinimumVoxelSize(const RtPoint corners[8])
This callback allows the plugin to hint at the minimum size of a voxel in object space as a way of av...
Definition: ImplicitField.h:461
virtual float EvalFiltered(const RtPoint p, const RtPoint dPdu, const RtPoint dPdv, const RtPoint dPdw)
Returns the filtered field value over the region of space in object coordinates delineated by point p...
Definition: ImplicitField.h:212
Definition: ImplicitField.h:48
virtual void GetVertexValueMultipleTemporal(int neval, float *result, int resultstride, const RtPoint *p, const float *time)
Stores in result the time-dependent values of the named vertex variable associated with the call to C...
Definition: ImplicitField.h:141
virtual bool ShouldSplit()
Returns true if the DSO requires splitting into children DSOs.
Definition: ImplicitField.h:336
virtual void BoxMotion(RtBound result, const RtBound b)
Given a shutter open bounding box b, this routine must compute a corresponding bounding box taking in...
Definition: ImplicitField.h:411
float RtInterval[2]
Definition: ri.h:65
virtual void GetVertexValueFiltered(float *result, const RtPoint p, const RtPoint dPdu, const RtPoint dPdv, const RtPoint dPdw)
Stores in result the filtered value of the named vertex variable associated with the call to CreateVe...
Definition: ImplicitField.h:74
virtual void EvalMultipleFiltered(int neval, float *result, int resultstride, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw)
Calculates the neval filtered field values at point p, in object coordinates, at shutter open time...
Definition: ImplicitField.h:246
virtual size_t MemoryUsage()
Returns the memory consumption of the plugin.
Definition: ImplicitField.h:506
RtPointer RtVolumeHandle
Definition: ri.h:82
virtual void HullCorners(RtPoint **corners, int *ncorners)
Return corners of a convex hull outside which the field value is zero.
Definition: ImplicitField.h:474
Definition: ImplicitField.h:187
pxrcore::UString RtUString
Definition: RiTypesHelper.h:682
virtual size_t MemoryUsage()
Returns the memory consumption of the vertex value.
Definition: ImplicitField.h:181
virtual ~ImplicitField()
Definition: ImplicitField.h:203
#define PIXAR_ARGUSED(x)
Definition: prmanapi.h:170
virtual void Split(std::vector< ImplicitField *> &children)
Returns a list of children DSOs.
Definition: ImplicitField.h:343