changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Drawables / Particles / OSGParticleBSP.h
blob650b34b2a153f3c45abd1d4ca50367e274a132c4
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
10 * *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
13 * License *
14 * *
15 * This library is free software; you can redistribute it and/or modify it *
16 * under the terms of the GNU Library General Public License as published *
17 * by the Free Software Foundation, version 2. *
18 * *
19 * This library is distributed in the hope that it will be useful, but *
20 * WITHOUT ANY WARRANTY; without even the implied warranty of *
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
22 * Library General Public License for more details. *
23 * *
24 * You should have received a copy of the GNU Library General Public *
25 * License along with this library; if not, write to the Free Software *
26 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. *
27 * *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
30 * Changes *
31 * *
32 * *
33 * *
34 * *
35 * *
36 * *
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGPARTICLEBSP_H_
40 #define _OSGPARTICLEBSP_H_
41 #ifdef __sgi
42 #pragma once
43 #endif
45 #include "OSGConfig.h"
47 #include "OSGParticlesFields.h"
49 #include "OSGTypedGeoVectorProperty.h"
51 OSG_BEGIN_NAMESPACE
53 class ParticleBSPTree;
55 /*! \brief Particle BSP Tree Node
56 \ingroup GrpDrawablesParticlesHelpers
57 \nohierarchy
60 class OSG_DRAWABLE_DLLMAPPING ParticleBSPNode
62 /*========================== PUBLIC =================================*/
64 public:
66 enum Axis
68 X = 0,
69 Y,
70 Z,
71 Leaf
74 /*---------------------------------------------------------------------*/
75 /*! \name Constructors */
76 /*! \{ */
78 ParticleBSPNode(void);
79 ParticleBSPNode(const ParticleBSPNode &source);
81 ParticleBSPNode(UInt32 value);
82 ParticleBSPNode(UInt8 axis,
83 Real32 splitvalue);
85 /*! \} */
86 /*---------------------------------------------------------------------*/
87 /*! \name Destructors */
88 /*! \{ */
90 ~ParticleBSPNode(void);
92 /*! \} */
93 /*---------------------------------------------------------------------*/
94 /*! \name Access */
95 /*! \{ */
97 bool isLeaf (void ) const;
98 Int32 getValue (void ) const;
99 Real32 getSplitValue(void ) const;
100 UInt8 getAxis (void ) const;
102 void setValue (Int32 value );
103 void setSplit (UInt8 axis,
104 Real32 splitvalue);
106 /*! \} */
107 /*---------------------------------------------------------------------*/
108 /*! \name Output */
109 /*! \{ */
111 void dump( UInt32 uiIndent = 0,
112 const BitVector bvFlags = 0) const;
114 /*! \} */
115 /*========================= PROTECTED ===============================*/
117 protected:
119 /*========================== PRIVATE ================================*/
121 private:
123 UInt8 _axis;
125 union
127 Int32 _value;
128 Real32 _splitvalue;
132 /*! \brief Particle BSP Tree
133 \ingroup GrpDrawablesParticlesHelpers
134 \nohierarchy
137 class OSG_DRAWABLE_DLLMAPPING ParticleBSPTree
139 /*========================== PUBLIC =================================*/
141 public:
143 /*---------------------------------------------------------------------*/
144 /*! \name Constructors */
145 /*! \{ */
147 ParticleBSPTree(void);
149 /*! \} */
150 /*---------------------------------------------------------------------*/
151 /*! \name Destructors */
152 /*! \{ */
154 virtual ~ParticleBSPTree(void);
156 /*! \} */
157 /*---------------------------------------------------------------------*/
158 /*! \name Creation / Deletion */
159 /*! \{ */
161 bool created(void) const;
163 void build (Particles *core);
165 void destroy(void);
167 /*! \} */
168 /*---------------------------------------------------------------------*/
169 /*! \name Traversal */
170 /*! \{ */
172 Int32 *traverse(const Pnt3f &refPoint,
173 UInt32 &length,
174 Int32 *order = NULL) const;
176 Int32 *traverse(const Vec3f &refVec,
177 UInt32 &length,
178 Int32 *order = NULL) const;
180 /*! \} */
181 /*---------------------------------------------------------------------*/
182 /*! \name Input / Output */
183 /*! \{ */
185 virtual void dump( UInt32 uiIndent = 0,
186 const BitVector bvFlags = 0) const;
188 void putToString(std::string &outVal) const;
190 bool getFromString(const Char8 *&inVal);
192 /*! \} */
193 /*---------------------------------------------------------------------*/
194 /*! \name Input / Output */
195 /*! \{ */
197 SizeT getBinSize (void ) const;
199 void copyToBin (BinaryDataHandler &pMem) const;
200 void copyFromBin(BinaryDataHandler &pMem);
202 /*! \} */
203 /*---------------------------------------------------------------------*/
204 /*! \name Input / Output */
205 /*! \{ */
207 bool operator ==(const ParticleBSPTree &source) const;
209 /*! \} */
210 /*========================= PROTECTED ===============================*/
212 protected:
214 /*---------------------------------------------------------------------*/
215 /*! \name Node Traversal */
216 /*! \{ */
218 UInt32 doTraverse(const Pnt3f &refPoint,
219 UInt32 index,
220 UInt32 length,
221 Int32 *order ) const;
223 UInt32 doTraverse(const Vec3f &refVec,
224 UInt32 index,
225 UInt32 length,
226 Int32 *order ) const;
228 /*! \} */
229 /*---------------------------------------------------------------------*/
230 /*! \name Creation Tools */
231 /*! \{ */
233 UInt32 doBuild(std::vector<Int32>::iterator begin,
234 std::vector<Int32>::iterator end,
235 UInt32 nodeindex,
236 GeoVectorProperty *pos );
238 /*! \} */
239 /*========================== PRIVATE ================================*/
241 private:
243 std::vector<ParticleBSPNode> _tree;
247 /*! \ingroup GrpDrawablesParticlesFieldTraits
248 \ingroup GrpLibOSGDrawables
251 template <>
252 struct FieldTraits<ParticleBSPTree> :
253 public FieldTraitsTemplateBase<ParticleBSPTree>
255 private:
257 static DataType _type;
259 public:
261 typedef FieldTraits<ParticleBSPTree> Self;
263 enum { Convertible = 0x00 };
265 static OSG_DRAWABLE_DLLMAPPING
266 DataType &getType (void);
268 static const Char8 *getSName (void) { return "SFParticleBSPTree"; }
269 static const Char8 *getMName (void) { return "MFParticleBSPTree"; }
271 static ParticleBSPTree getDefault (void) { return ParticleBSPTree(); }
274 static bool getFromString( ParticleBSPTree &outVal,
275 const Char8 *&inVal)
277 return outVal.getFromString(inVal);
280 static void putToString (const ParticleBSPTree &inVal,
281 std::string &outVal)
283 inVal.putToString(outVal);
287 static SizeT getBinSize(const ParticleBSPTree &oObject)
289 return oObject.getBinSize();
292 static void copyToBin( BinaryDataHandler &pMem,
293 const ParticleBSPTree &oObject)
295 oObject.copyToBin(pMem);
298 static void copyFromBin(BinaryDataHandler &pMem,
299 ParticleBSPTree &oObject)
301 oObject.copyFromBin(pMem);
306 #ifndef DOXYGEN_SHOULD_SKIP_THIS
307 /*! \ingroup GrpDrawablesParticlesFieldSFields */
308 typedef SField<ParticleBSPTree> SFParticleBSPTree;
309 #else
310 /*! \ingroup GrpDrawablesParticlesFieldSFields \ingroup GrpLibOSGDrawables */
311 struct SFParticleBSPTree : public SField<ParticleBSPTree> {};
312 #endif
315 OSG_END_NAMESPACE
317 #include "OSGParticleBSP.inl"
319 #endif /* _OSGPARTICLES_H_ */