HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros 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  /// This is used to determine which side of my parent I am on.
60  virtual UT_Vector3 getCenter() const;
61 
62  /// Count number of slices from myself and my children.
63  int countSlices() const;
64  static int countSlices(const SIM_ConstDataArray &slices);
65 
66  /// The nth entry of this list stores how to search for the nth
67  /// slice.
68  void buildSliceSearch(SIM_SliceSearchTable &table) const;
69  static void buildSliceSearch(SIM_SliceSearchTable &table,
70  SIM_ConstDataArray &slices);
71 
72  static fpreal computeSliceDist(const SIM_SliceSearchList &list,
73  const UT_Vector3 &pos);
74  /// This is different than a computeSliceDist < 0 because
75  /// we need to ensure that we are consistent with <= against
76  /// a zero result...
77  static bool isInsideSlice(const SIM_SliceSearchList &list,
78  const UT_Vector3 &pos);
79 
80  /// This returns true only if the bounding box is fully contained
81  /// in the slice. Assumes convex slices.
82  static bool isInsideSlice(const SIM_SliceSearchList &list,
83  const UT_BoundingBox &bbox);
84 
85 protected:
86  explicit SIM_Slice(const SIM_DataFactory *factory);
87  virtual ~SIM_Slice();
88 
89  /// Returns whether we are inside this slice or not.
90  /// true is inside. This corresponds to a negative slice
91  /// boundary distance but is overrideable for efficiency.
92  /// Default implementation just compares the distance with 0.
93  virtual bool isInsideSliceSubclass(const UT_Vector3 &pos) const;
94 
95  /// Returns the distance to the slice's boundary. If the point
96  /// is inside the slice this is a negative distance, else positive.
97  /// This is what must be overridden to make the slice do something
98  /// interesting
99  virtual fpreal getSliceBoundaryDistSubclass(const UT_Vector3 &pos) const = 0;
100 
101  /// This is used to determine which side of my parent I am on.
102  virtual UT_Vector3 getCenterSubclass() const = 0;
103 
104 private:
107 };
108 
109 #endif
110 
#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:263
#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