HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SIM_Slice.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  */
7 
8 #ifndef __SIM_Slice_h__
9 #define __SIM_Slice_h__
10 
11 #include "SIM_API.h"
12 #include "SIM_DataUtils.h"
13 #include <UT/UT_Vector3.h>
14 #include <UT/UT_Array.h>
15 #include <UT/UT_VectorTypes.h>
16 
18 class SIM_Geometry;
19 class SIM_Position;
20 class SIM_Motion;
21 
22 class SIM_Slice;
23 
25 {
26 public:
28  {
29  mySlice = 0;
30  myInside = false;
31  }
32  SIM_SliceSearchEntry(const SIM_Slice *slice, bool isinside)
33  {
34  mySlice = slice;
35  myInside = isinside;
36  }
38  bool myInside;
39 };
40 
43 
44 /// This is the definition of the SIM_Slice interface. The only function that
45 /// needs to be overridden (besides any standard SIM_Data overrides) is the
46 /// getSliceBoundaryDistSubclass() functions.
47 class SIM_API SIM_Slice : public SIM_Data
48 {
49 public:
50  /// Returns whether we are inside this slice or not.
51  /// true is inside. This corresponds to a negative slice
52  /// boundary distance but is overrideable for efficiency.
53  bool isInsideSlice(const UT_Vector3 &pos) const;
54 
55  /// Returns the distance to the slice's boundary. If the point
56  /// is inside the slice this is a negative distance, else positive.
57  fpreal getSliceBoundaryDist(const UT_Vector3 &pos) const;
58 
59  /// Returns the minimal distance to the slice's boundary within
60  /// the bounding box. A negative result implies the slice and
61  /// bounding box overlap.
62  fpreal getMinSliceBoundaryDist(const UT_BoundingBox &bbox) const;
63  fpreal getMaxSliceBoundaryDist(const UT_BoundingBox &bbox) const;
64 
65  /// This is used to determine which side of my parent I am on.
66  virtual UT_Vector3 getCenter() const;
67 
68  /// Count number of slices from myself and my children.
69  int countSlices() const;
70  static int countSlices(const SIM_ConstDataArray &slices);
71 
72  /// The nth entry of this list stores how to search for the nth
73  /// slice.
74  void buildSliceSearch(SIM_SliceSearchTable &table) const;
75  static void buildSliceSearch(SIM_SliceSearchTable &table,
76  SIM_ConstDataArray &slices);
77 
78  static fpreal computeSliceDist(const SIM_SliceSearchList &list,
79  const UT_Vector3 &pos);
80  /// This is different than a computeSliceDist < 0 because
81  /// we need to ensure that we are consistent with <= against
82  /// a zero result...
83  static bool isInsideSlice(const SIM_SliceSearchList &list,
84  const UT_Vector3 &pos);
85 
86  /// This returns true only if the bounding box is fully contained
87  /// in the slice. Assumes convex slices.
88  static bool isInsideSlice(const SIM_SliceSearchList &list,
89  const UT_BoundingBox &bbox);
90 
91  /// Returns true if the bounding box at all intersects the slice.
92  static bool doesIntersectSlice(const SIM_SliceSearchList &list,
93  const UT_BoundingBox &bbox);
94 
95 protected:
96  explicit SIM_Slice(const SIM_DataFactory *factory);
97  virtual ~SIM_Slice();
98 
99  /// Returns whether we are inside this slice or not.
100  /// true is inside. This corresponds to a negative slice
101  /// boundary distance but is overrideable for efficiency.
102  /// Default implementation just compares the distance with 0.
103  virtual bool isInsideSliceSubclass(const UT_Vector3 &pos) const;
104 
105  /// Returns the distance to the slice's boundary. If the point
106  /// is inside the slice this is a negative distance, else positive.
107  /// This is what must be overridden to make the slice do something
108  /// interesting
109  virtual fpreal getSliceBoundaryDistSubclass(const UT_Vector3 &pos) const = 0;
110 
111  /// Returns the minimum value the slice attains inside the given bounding
112  /// box. A negative value implies the slice and bounding box overlap.
113  virtual fpreal getMinSliceBoundaryDistSubclass(const UT_BoundingBox &bbox) const = 0;
114  virtual fpreal getMaxSliceBoundaryDistSubclass(const UT_BoundingBox &bbox) const = 0;
115 
116  /// This is used to determine which side of my parent I am on.
117  virtual UT_Vector3 getCenterSubclass() const = 0;
118 
119 private:
122 };
123 
124 #endif
125 
#define DECLARE_STANDARD_GETCASTTOTYPE()
Definition: SIM_DataUtils.h:45
UT_Array< SIM_SliceSearchEntry > SIM_SliceSearchList
Definition: SIM_Slice.h:41
#define DECLARE_CLASSNAME(DataClass, SuperClass)
Definition: SIM_DataUtils.h:20
UT_Array< SIM_SliceSearchList > SIM_SliceSearchTable
Definition: SIM_Slice.h:42
bool myInside
Definition: SIM_Slice.h:38
This is the default implementation for standard motion data.
Definition: SIM_Motion.h:18
Definition: SIM_Slice.h:24
SIM_SliceSearchEntry()
Definition: SIM_Slice.h:27
double fpreal
Definition: SYS_Types.h:270
#define SIM_API
Definition: SIM_API.h:10
const SIM_Slice * mySlice
Definition: SIM_Slice.h:37
SIM_SliceSearchEntry(const SIM_Slice *slice, bool isinside)
Definition: SIM_Slice.h:32