1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2002 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, jbehr@zgdv.de *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 #ifndef _OSGPARTICLEBSP_H_
40 #define _OSGPARTICLEBSP_H_
45 #include "OSGConfig.h"
47 #include "OSGParticlesFields.h"
49 #include "OSGTypedGeoVectorProperty.h"
53 class ParticleBSPTree
;
55 /*! \brief Particle BSP Tree Node
56 \ingroup GrpDrawablesParticlesHelpers
60 class OSG_DRAWABLE_DLLMAPPING ParticleBSPNode
62 /*========================== PUBLIC =================================*/
74 /*---------------------------------------------------------------------*/
75 /*! \name Constructors */
78 ParticleBSPNode(void);
79 ParticleBSPNode(const ParticleBSPNode
&source
);
81 ParticleBSPNode(UInt32 value
);
82 ParticleBSPNode(UInt8 axis
,
86 /*---------------------------------------------------------------------*/
87 /*! \name Destructors */
90 ~ParticleBSPNode(void);
93 /*---------------------------------------------------------------------*/
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
,
107 /*---------------------------------------------------------------------*/
111 void dump( UInt32 uiIndent
= 0,
112 const BitVector bvFlags
= 0) const;
115 /*========================= PROTECTED ===============================*/
119 /*========================== PRIVATE ================================*/
132 /*! \brief Particle BSP Tree
133 \ingroup GrpDrawablesParticlesHelpers
137 class OSG_DRAWABLE_DLLMAPPING ParticleBSPTree
139 /*========================== PUBLIC =================================*/
143 /*---------------------------------------------------------------------*/
144 /*! \name Constructors */
147 ParticleBSPTree(void);
150 /*---------------------------------------------------------------------*/
151 /*! \name Destructors */
154 virtual ~ParticleBSPTree(void);
157 /*---------------------------------------------------------------------*/
158 /*! \name Creation / Deletion */
161 bool created(void) const;
163 void build (Particles
*core
);
168 /*---------------------------------------------------------------------*/
169 /*! \name Traversal */
172 Int32
*traverse(const Pnt3f
&refPoint
,
174 Int32
*order
= NULL
) const;
176 Int32
*traverse(const Vec3f
&refVec
,
178 Int32
*order
= NULL
) const;
181 /*---------------------------------------------------------------------*/
182 /*! \name Input / Output */
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
);
193 /*---------------------------------------------------------------------*/
194 /*! \name Input / Output */
197 SizeT
getBinSize (void ) const;
199 void copyToBin (BinaryDataHandler
&pMem
) const;
200 void copyFromBin(BinaryDataHandler
&pMem
);
203 /*---------------------------------------------------------------------*/
204 /*! \name Input / Output */
207 bool operator ==(const ParticleBSPTree
&source
) const;
210 /*========================= PROTECTED ===============================*/
214 /*---------------------------------------------------------------------*/
215 /*! \name Node Traversal */
218 UInt32
doTraverse(const Pnt3f
&refPoint
,
221 Int32
*order
) const;
223 UInt32
doTraverse(const Vec3f
&refVec
,
226 Int32
*order
) const;
229 /*---------------------------------------------------------------------*/
230 /*! \name Creation Tools */
233 UInt32
doBuild(std::vector
<Int32
>::iterator begin
,
234 std::vector
<Int32
>::iterator end
,
236 GeoVectorProperty
*pos
);
239 /*========================== PRIVATE ================================*/
243 std::vector
<ParticleBSPNode
> _tree
;
247 /*! \ingroup GrpDrawablesParticlesFieldTraits
248 \ingroup GrpLibOSGDrawables
252 struct FieldTraits
<ParticleBSPTree
> :
253 public FieldTraitsTemplateBase
<ParticleBSPTree
>
257 static DataType _type
;
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,
277 return outVal.getFromString(inVal);
280 static void putToString (const ParticleBSPTree &inVal,
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
;
310 /*! \ingroup GrpDrawablesParticlesFieldSFields \ingroup GrpLibOSGDrawables */
311 struct SFParticleBSPTree
: public SField
<ParticleBSPTree
> {};
317 #include "OSGParticleBSP.inl"
319 #endif /* _OSGPARTICLES_H_ */