Free Electron
SpatialTreeBase.h
Go to the documentation of this file.
1 /* Copyright (C) 2003-2021 Free Electron Organization
2  Any use of this software requires a license. If a valid license
3  was not distributed with this file, visit freeelectron.org. */
4 
5 /** @file */
6 
7 #ifndef __surface_SpatialTreeBase_h__
8 #define __surface_SpatialTreeBase_h__
9 
10 namespace fe
11 {
12 namespace ext
13 {
14 
15 /**************************************************************************//**
16  @brief Triangular storage using a simple array
17 
18  @ingroup surface
19 *//***************************************************************************/
20 class FE_DL_EXPORT SpatialTreeBase: virtual public SpatialTreeI
21 {
22  public:
23 
24  class Hit:
25  public SpatialTreeI::Hit,
26  public CastableAs<Hit>
27  {
28  public:
29  Hit(void)
30  { reset(); }
31 
32  void reset(void)
33  {
34  m_face= -1;
35  m_triangleIndex= -1;
36  m_pointIndex= -1;
37  m_primitiveIndex= -1;
38  m_partitionIndex= -1;
39  m_distance= -1.0;
40  set(m_intersection);
41  set(m_direction);
42  set(m_barycenter);
43  set(m_uv);
44  set(m_color,1.0,1.0,1.0);
45  set(m_du);
46  set(m_dv);
47  m_pPointIndex[0]=0;
48  m_pPointIndex[1]=0;
49  m_pPointIndex[2]=0;
50  set(m_pVertex[0]);
51  set(m_pVertex[1]);
52  set(m_pVertex[2]);
53  set(m_pNormal[0]);
54  set(m_pNormal[1]);
55  set(m_pNormal[2]);
56  }
57 
58  virtual
59  const SpatialVector& intersection(void) const
60  { return m_intersection; }
61  virtual
62  const SpatialVector& direction(void) const
63  { return m_direction; }
64  virtual Real distance(void) const
65  { return m_distance; }
66  virtual I32 face(void) const
67  { return m_face; }
68  virtual I32 triangleIndex(void) const
69  { return m_triangleIndex; }
70  virtual I32 primitiveIndex(void) const
71  { return m_primitiveIndex; }
72  virtual I32 partitionIndex(void) const
73  { return m_partitionIndex; }
74  virtual
75  const SpatialBary& barycenter(void) const
76  { return m_barycenter; }
77  virtual
78  const Vector2& uv(void) const
79  { return m_uv; }
80  virtual
81  const SpatialVector& du(void) const
82  { return m_du; }
83  virtual
84  const SpatialVector& dv(void) const
85  { return m_dv; }
86  virtual
87  const Color& color(void) const
88  { return m_color; }
89  virtual
90  const I32* pointIndex(void) const
91  { return m_pPointIndex; }
92  virtual
93  const SpatialVector* vertex(void) const
94  { return m_pVertex; }
95  virtual
96  const SpatialVector* normal(void) const
97  { return m_pNormal; }
98 
99  void copy(const sp<Hit>& a_rspOther)
100  {
101  m_intersection=a_rspOther->intersection();
102  m_direction=a_rspOther->direction();
103  m_distance=a_rspOther->distance();
104  m_face=a_rspOther->face();
105  m_triangleIndex=a_rspOther->triangleIndex();
106  m_primitiveIndex=
107  a_rspOther->primitiveIndex();
108  m_partitionIndex=
109  a_rspOther->partitionIndex();
110  m_barycenter=a_rspOther->barycenter();
111  m_uv=a_rspOther->uv();
112  m_du=a_rspOther->du();
113  m_dv=a_rspOther->dv();
114  m_color=a_rspOther->color();
115  m_pPointIndex[0]=
116  a_rspOther->pointIndex()[0];
117  m_pPointIndex[1]=
118  a_rspOther->pointIndex()[1];
119  m_pPointIndex[2]=
120  a_rspOther->pointIndex()[2];
121  m_pVertex[0]=a_rspOther->vertex()[0];
122  m_pVertex[1]=a_rspOther->vertex()[1];
123  m_pVertex[2]=a_rspOther->vertex()[2];
124  m_pNormal[0]=a_rspOther->normal()[0];
125  m_pNormal[1]=a_rspOther->normal()[1];
126  m_pNormal[2]=a_rspOther->normal()[2];
127  }
128 
129  SpatialVector m_intersection;
130  SpatialVector m_direction;
131  Real m_distance;
132  I32 m_face;
133  I32 m_triangleIndex;
134  I32 m_pointIndex;
135  I32 m_primitiveIndex;
136  I32 m_partitionIndex;
137  SpatialBary m_barycenter;
138  Vector2 m_uv;
139  SpatialVector m_du;
140  SpatialVector m_dv;
141  Color m_color;
142  I32 m_pPointIndex[3];
143  SpatialVector m_pVertex[3];
144  SpatialVector m_pNormal[3];
145  };
146 
147  SpatialTreeBase(void);
148 virtual ~SpatialTreeBase(void);
149 
150 virtual void setAccuracy(SurfaceI::Accuracy a_accuracy)
151  { m_accuracy=a_accuracy; }
152 
153 virtual void draw(sp<DrawI>,const fe::Color*) const {}
154 
155  protected:
156 
157  SurfaceI::Accuracy m_accuracy;
158 };
159 
160 } /* namespace ext */
161 } /* namespace fe */
162 
163 #endif /* __surface_SpatialTreeBase_h__ */
kernel
Definition: namespace.dox:3
Special vector for color (RGBA)
Definition: Color.h:21
Triangular storage using a simple array.
Definition: SpatialTreeBase.h:20
Triangular storage interface.
Definition: SpatialTreeI.h:20
Intrusive Smart Pointer.
Definition: src/core/ptr.h:53
Per-class participation non-RTTI fallback dynamic casting mechanism.
Definition: Castable.h:192