fixed: auto_ptr -> unique_ptr
[opensg.git] / Source / Contrib / ComputeBase / Base / OSGAlgorithmComputeElement.cpp
blob024b2d373bc4907d3a01b55106588a6cc979bcd5
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 <sstream>
43 #include <fstream>
45 #include "OSGConfig.h"
47 #include "OSGAction.h"
48 #include "OSGCamera.h"
49 #include "OSGRenderAction.h"
50 #include "OSGSceneFileHandler.h"
51 #include "OSGVolumeDraw.h"
53 #include "OSGAlgorithmComputeElement.h"
54 #include "OSGAlgorithmComputeElementData.h"
56 #include "OSGComputeAlgorithm.h"
58 #include "OSGFrameBufferObject.h"
59 #include "OSGFrameBufferAttachment.h"
61 #include "OSGMatrixUtility.h"
63 OSG_BEGIN_NAMESPACE
65 // Documentation for this class is emited in the
66 // OSGAlgorithmComputeElementBase.cpp file.
67 // To modify it, please change the .fcd file (OSGAlgorithmComputeElement.fcd)
68 // and regenerate the base file.
70 /*-------------------------------------------------------------------------*/
71 /* Sync */
73 void AlgorithmComputeElement::changed(ConstFieldMaskArg whichField,
74 UInt32 origin,
75 BitVector details)
77 Inherited::changed(whichField, origin, details);
80 /*-------------------------------------------------------------------------*/
81 /* Dump */
83 void
84 AlgorithmComputeElement::dump( UInt32 OSG_CHECK_ARG(uiIndent),
85 const BitVector OSG_CHECK_ARG(bvFlags )) const
87 SLOG << "Dump AlgorithmComputeElement NI" << std::endl;
90 /*-------------------------------------------------------------------------*/
91 /* Constructors */
93 AlgorithmComputeElement::AlgorithmComputeElement(void) :
94 Inherited()
98 AlgorithmComputeElement::AlgorithmComputeElement(
99 const AlgorithmComputeElement &source) :
101 Inherited(source)
105 /*-------------------------------------------------------------------------*/
106 /* Destructor */
108 AlgorithmComputeElement::~AlgorithmComputeElement(void)
112 /*-------------------------------------------------------------------------*/
113 /* loading */
115 Action::ResultE AlgorithmComputeElement::renderEnter(Action *action)
117 RenderAction *a = dynamic_cast<RenderAction *>(action);
118 ComputeAlgorithm *pAlgo = this->getAlgorithm();
120 if(pAlgo != NULL)
122 AlgorithmComputeElementData *pData =
123 a->getData<AlgorithmComputeElementData *>(_iDataSlotId);
125 if(pData == NULL)
127 AlgorithmComputeElementDataUnrecPtr pDataNew =
128 AlgorithmComputeElementData::create();
130 this->setData(pDataNew.get(), _iDataSlotId, a);
132 pData = pDataNew;
135 ComputeAlgorithmDrawTask *pTask = pData->getTask();
137 if(pTask == NULL)
139 pTask = new ComputeAlgorithmDrawTask(
140 pAlgo,
141 ComputeAlgorithmDrawTask::Algorithm);
143 pData->setTask(pTask);
147 a->getWindow()->queueTaskFromDrawer(pTask);
150 return Action::Continue;
153 Action::ResultE AlgorithmComputeElement::renderLeave(Action *a)
155 return Action::Continue;
159 /*-------------------------------------------------------------------------*/
160 /* Init */
162 void AlgorithmComputeElement::initMethod(InitPhase ePhase)
164 Inherited::initMethod(ePhase);
166 if(ePhase == TypeObject::SystemPost)
168 RenderAction::registerEnterDefault(
169 AlgorithmComputeElement::getClassType(),
170 reinterpret_cast<Action::Callback>(
171 &AlgorithmComputeElement::renderEnter));
173 RenderAction::registerLeaveDefault(
174 AlgorithmComputeElement::getClassType(),
175 reinterpret_cast<Action::Callback>(
176 &AlgorithmComputeElement::renderLeave));
180 OSG_END_NAMESPACE