RenderMan API  23.0
ImplicitField.h
Go to the documentation of this file.
1 /*
2 # ------------------------------------------------------------------------------
3 #
4 # Copyright (c) 1986-2019 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 
38 #ifndef IMPLICITFIELD_H
39 #define IMPLICITFIELD_H
40 
41 #include <cstddef> // for NULL
42 #include <vector> // for vector
43 #include "prmanapi.h" // for PRMANEXPORT
44 #include "ri.h" // for RtPoint, RtBound, etc
45 #include "RixInterfaces.h"
46 
47 #define IMPLICIT_VER 7
48 
50 {
51 private:
52  /* inhibit copying */
54  ImplicitVertexValue& operator=(const ImplicitVertexValue&);
55 
56 public:
58  virtual ~ImplicitVertexValue() {}
59 
66  virtual void GetVertexValue(float* result, const RtPoint p) = 0;
67 
75  virtual void GetVertexValueFiltered(
76  float* result,
77  const RtPoint p,
78  const RtPoint dPdu,
79  const RtPoint dPdv,
80  const RtPoint dPdw)
81  {
82  PIXAR_ARGUSED(dPdu);
83  PIXAR_ARGUSED(dPdv);
84  PIXAR_ARGUSED(dPdw);
85 
86  GetVertexValue(result, p);
87  }
88 
97  virtual void GetVertexValueMultiple(
98  int neval,
99  float* result,
100  int resultstride,
101  const RtPoint* p)
102  {
103  for (int i = 0; i < neval; ++i)
104  {
105  GetVertexValue(result, *p++);
106  result += resultstride;
107  }
108  }
109 
119  int neval,
120  float* result,
121  int resultstride,
122  const RtPoint* p,
123  const RtPoint* dPdu,
124  const RtPoint* dPdv,
125  const RtPoint* dPdw)
126  {
127  for (int i = 0; i < neval; ++i)
128  {
129  GetVertexValueFiltered(result, *p++, *dPdu++, *dPdv++, *dPdw++);
130  result += resultstride;
131  }
132  }
133 
143  int neval,
144  float* result,
145  int resultstride,
146  const RtPoint* p,
147  const float* time)
148  {
149  PIXAR_ARGUSED(time);
150 
151  GetVertexValueMultiple(neval, result, resultstride, p);
152  }
153 
163  int neval,
164  float* result,
165  int resultstride,
166  const RtPoint* p,
167  const RtPoint* dPdu,
168  const RtPoint* dPdv,
169  const RtPoint* dPdw,
170  const float* time)
171  {
172  PIXAR_ARGUSED(time);
173 
174  GetVertexValueMultipleFiltered(neval, result, resultstride, p,
175  dPdu, dPdv, dPdw);
176  }
177 
182  virtual size_t MemoryUsage()
183  {
184  return 0;
185  }
186 };
187 
189 {
190 public:
196 
197 private:
198  /* inhibit copying */
200  ImplicitField& operator=(const ImplicitField&);
201 
202 public:
204  virtual ~ImplicitField() {}
205 
208  virtual float Eval(const RtPoint p) = 0;
209 
213  virtual float EvalFiltered(
214  const RtPoint p,
215  const RtPoint dPdu,
216  const RtPoint dPdv,
217  const RtPoint dPdw)
218  {
219  PIXAR_ARGUSED(dPdu);
220  PIXAR_ARGUSED(dPdv);
221  PIXAR_ARGUSED(dPdw);
222 
223  return Eval(p);
224  }
225 
230  virtual void EvalMultiple(
231  int neval,
232  float* result,
233  int resultstride,
234  const RtPoint* p)
235  {
236  for (int i = 0; i < neval; ++i)
237  {
238  *result = Eval(*p++);
239  result += resultstride;
240  }
241  }
242 
247  virtual void EvalMultipleFiltered(
248  int neval,
249  float* result,
250  int resultstride,
251  const RtPoint* p,
252  const RtPoint* dPdu,
253  const RtPoint* dPdv,
254  const RtPoint* dPdw)
255  {
256  PIXAR_ARGUSED(dPdu);
257  PIXAR_ARGUSED(dPdv);
258  PIXAR_ARGUSED(dPdw);
259 
260  EvalMultiple(neval, result, resultstride, p);
261  }
262 
265  virtual void GradientEval(RtPoint result, const RtPoint p) = 0;
266 
269  virtual void GradientEvalFiltered(
270  RtPoint result,
271  const RtPoint p,
272  const RtPoint dPdu,
273  const RtPoint dPdv,
274  const RtPoint dPdw)
275  {
276  PIXAR_ARGUSED(dPdu);
277  PIXAR_ARGUSED(dPdv);
278  PIXAR_ARGUSED(dPdw);
279 
280  GradientEval(result, p);
281  }
282 
286  virtual void GradientEvalMultiple(
287  int neval,
288  RtPoint* result,
289  const RtPoint* p)
290  {
291  for (int i = 0; i < neval; ++i)
292  {
293  GradientEval(*result++, *p++);
294  }
295  }
296 
301  int neval,
302  RtPoint* result,
303  const RtPoint* p,
304  const RtPoint* dPdu,
305  const RtPoint* dPdv,
306  const RtPoint* dPdw)
307  {
308  PIXAR_ARGUSED(dPdu);
309  PIXAR_ARGUSED(dPdv);
310  PIXAR_ARGUSED(dPdw);
311 
312  GradientEvalMultiple(neval, result, p);
313  }
314 
324  virtual void Range(
325  RtInterval result,
326  const RtPoint corners[8],
327  const RtVolumeHandle h)
328  {
329  PIXAR_ARGUSED(corners);
330  PIXAR_ARGUSED(h);
331 
332  result[0] = -1e30f;
333  result[1] = 1e30f;
334  }
335 
337  virtual bool ShouldSplit() { return false; }
338 
344  virtual void Split(std::vector<ImplicitField*>& children)
345  {
346  PIXAR_ARGUSED(children);
347  }
348 
353  virtual void Motion(RtPoint result, const RtPoint p)
354  {
355  PIXAR_ARGUSED(p);
356 
357  result[0] = 0.0f;
358  result[1] = 0.0f;
359  result[2] = 0.0f;
360  }
361 
366  virtual void MotionFiltered(
367  RtPoint result,
368  const RtPoint p,
369  const RtPoint dPdu,
370  const RtPoint dPdv,
371  const RtPoint dPdw)
372  {
373  PIXAR_ARGUSED(dPdu);
374  PIXAR_ARGUSED(dPdv);
375  PIXAR_ARGUSED(dPdw);
376 
377  Motion(result, p);
378  }
379 
382  virtual void MotionMultiple(int neval, RtPoint* result, const RtPoint* p)
383  {
384  for (int i = 0; i < neval; ++i)
385  {
386  Motion(*result++, *p++);
387  }
388  }
389 
393  int neval,
394  RtPoint* result,
395  const RtPoint* p,
396  const RtPoint* dPdu,
397  const RtPoint* dPdv,
398  const RtPoint* dPdw)
399  {
400  PIXAR_ARGUSED(dPdu);
401  PIXAR_ARGUSED(dPdv);
402  PIXAR_ARGUSED(dPdw);
403 
404  MotionMultiple(neval, result, p);
405  }
406 
412  virtual void BoxMotion(RtBound result, const RtBound b)
413  {
414  for (int i = 0; i < 6; i++)
415  {
416  result[i] = b[i];
417  }
418  }
419 
433  virtual void VolumeCompleted(const RtVolumeHandle h)
434  {
435  PIXAR_ARGUSED(h);
436  }
437 
449  const RtUString name,
450  int nvalue)
451  {
452  PIXAR_ARGUSED(name);
453  PIXAR_ARGUSED(nvalue);
454 
455  return 0;
456  }
457 
462  virtual float MinimumVoxelSize(
463  const RtPoint corners[8])
464  {
465  PIXAR_ARGUSED(corners);
466 
467  return 0.0f;
468  }
469 
475  virtual void HullCorners(RtPoint** corners, int* ncorners)
476  {
477  *corners = NULL;
478  *ncorners = 0;
479  }
480 
491  virtual void HullCornersMotion(
492  RtPoint* corners,
493  int ncorners,
494  RtPoint** motioncorners,
495  int* nmotioncorners)
496  {
497  PIXAR_ARGUSED(corners);
498  PIXAR_ARGUSED(ncorners);
499 
500  *motioncorners = NULL;
501  *nmotioncorners = 0;
502  }
503 
507  virtual size_t MemoryUsage()
508  {
509  return 0;
510  }
511 };
512 
513 #define FIELDCREATE \
514  extern "C" const PRMANEXPORT int ImplicitFieldVersion = IMPLICIT_VER; \
515  extern "C" PRMANEXPORT ImplicitField* ImplicitFieldNew( \
516  int nfloat, const float* float0, const float* float1, \
517  int nstring, const RtString* string)
518 
519 #define FIELDCREATE_ARGUSED \
520  PIXAR_ARGUSED(nfloat); \
521  PIXAR_ARGUSED(float0); \
522  PIXAR_ARGUSED(float1); \
523  PIXAR_ARGUSED(nstring); \
524  PIXAR_ARGUSED(string);
525 
526 #endif
virtual void Range(RtInterval result, const RtPoint corners[8], const RtVolumeHandle h)
virtual ImplicitVertexValue * CreateVertexValue(const RtUString name, int nvalue)
virtual void MotionFiltered(RtPoint result, const RtPoint p, const RtPoint dPdu, const RtPoint dPdv, const RtPoint dPdw)
virtual ~ImplicitField()
virtual void EvalMultipleFiltered(int neval, float *result, int resultstride, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw)
virtual ~ImplicitVertexValue()
Definition: ImplicitField.h:58
float RtPoint[3]
Definition: ri.h:58
virtual void GetVertexValueMultipleTemporalFiltered(int neval, float *result, int resultstride, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw, const float *time)
virtual void GetVertexValueMultiple(int neval, float *result, int resultstride, const RtPoint *p)
Definition: ImplicitField.h:97
float RtBound[6]
Definition: ri.h:64
virtual void GetVertexValueMultipleFiltered(int neval, float *result, int resultstride, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw)
virtual void Split(std::vector< ImplicitField *> &children)
virtual void GradientEvalFiltered(RtPoint result, const RtPoint p, const RtPoint dPdu, const RtPoint dPdv, const RtPoint dPdw)
virtual void GradientEvalMultipleFiltered(int neval, RtPoint *result, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw)
virtual size_t MemoryUsage()
virtual void HullCorners(RtPoint **corners, int *ncorners)
virtual void GetVertexValueFiltered(float *result, const RtPoint p, const RtPoint dPdu, const RtPoint dPdv, const RtPoint dPdw)
Definition: ImplicitField.h:75
virtual bool ShouldSplit()
Returns true if the DSO requires splitting into children DSOs.
virtual float MinimumVoxelSize(const RtPoint corners[8])
float RtInterval[2]
Definition: ri.h:65
virtual void EvalMultiple(int neval, float *result, int resultstride, const RtPoint *p)
pxrcore::UString RtUString
virtual float EvalFiltered(const RtPoint p, const RtPoint dPdu, const RtPoint dPdv, const RtPoint dPdw)
virtual void GetVertexValueMultipleTemporal(int neval, float *result, int resultstride, const RtPoint *p, const float *time)
virtual void MotionMultiple(int neval, RtPoint *result, const RtPoint *p)
virtual size_t MemoryUsage()
virtual void GradientEvalMultiple(int neval, RtPoint *result, const RtPoint *p)
virtual void BoxMotion(RtBound result, const RtBound b)
RtPointer RtVolumeHandle
Definition: ri.h:82
virtual void MotionMultipleFiltered(int neval, RtPoint *result, const RtPoint *p, const RtPoint *dPdu, const RtPoint *dPdv, const RtPoint *dPdw)
virtual void Motion(RtPoint result, const RtPoint p)
virtual void HullCornersMotion(RtPoint *corners, int ncorners, RtPoint **motioncorners, int *nmotioncorners)
virtual void GetVertexValue(float *result, const RtPoint p)=0
virtual void VolumeCompleted(const RtVolumeHandle h)
#define PIXAR_ARGUSED(x)
Definition: prmanapi.h:171