fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / System / NodeCores / Groups / Base / OSGGroup.cpp
blobc3a5636317e253b245faae92db11ef6c7d876821
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 #include <cstdlib>
40 #include <cstdio>
42 #include "OSGConfig.h"
44 #include "OSGRenderAction.h"
45 #include "OSGIntersectAction.h"
47 #include "OSGGroup.h"
49 OSG_USING_NAMESPACE
51 // Documentation for this class is emited in the
52 // OSGGroupBase.cpp file.
53 // To modify it, please change the .fcd file (OSGGroup.fcd) and
54 // regenerate the base file.
56 /*-------------------------------------------------------------------------*/
57 /* Sync */
59 void Group::changed(ConstFieldMaskArg whichField,
60 UInt32 origin,
61 BitVector details)
63 Inherited::changed(whichField, origin, details);
66 /*-------------------------------------------------------------------------*/
67 /* Dump */
69 void Group::dump( UInt32 uiIndent,
70 const BitVector bvFlags) const
72 Inherited::dump(uiIndent, bvFlags);
75 /*-------------------------------------------------------------------------*/
76 /* Constructors */
78 Group::Group(void) :
79 Inherited()
83 Group::Group(const Group &source) :
84 Inherited(source)
88 /*-------------------------------------------------------------------------*/
89 /* Destructor */
91 Group::~Group(void)
95 /*-------------------------------------------------------------------------*/
96 /* Render */
98 Action::ResultE Group::renderEnter(Action *action)
100 RenderAction *ra = dynamic_cast<RenderAction *>(action);
102 if(ra->pushVisibility() == true)
104 if(ra->selectVisibles() == 0)
106 ra->popVisibility();
107 return Action::Skip;
111 return Action::Continue;
114 Action::ResultE Group::renderLeave(Action *action)
116 RenderAction *ra = dynamic_cast<RenderAction *>(action);
118 ra->popVisibility();
120 return Action::Continue;
123 /*-------------------------------------------------------------------------*/
124 /* Intersect */
126 Action::ResultE Group::intersectEnter(Action *action)
128 IntersectAction *ia = dynamic_cast<IntersectAction *>(action);
129 const BoxVolume &bv = ia->getActNode()->getVolume();
131 if(bv.isValid() && ! bv.intersect(ia->getLine()))
133 return Action::Skip; //bv missed -> can not hit children
136 return Action::Continue;
139 /*-------------------------------------------------------------------------*/
140 /* Init */
142 void Group::initMethod(InitPhase ePhase)
144 Inherited::initMethod(ePhase);
147 if(ePhase == TypeObject::SystemPost)
149 RenderAction::registerEnterDefault(
150 Group::getClassType(),
151 reinterpret_cast<Action::Callback>(&Group::renderEnter));
153 RenderAction::registerLeaveDefault(
154 Group::getClassType(),
155 reinterpret_cast<Action::Callback>(&Group::renderLeave));
157 IntersectAction::registerEnterDefault(
158 getClassType(),
159 reinterpret_cast<Action::Callback>(&Group::intersectEnter));