changed: gcc8 base update
[opensg.git] / Source / System / Dynamics / Skeleton / OSGSkinningAlgorithmBase.cpp
blobdb8d7f8afd007d9b2115321449ef6bb45d7a4fc4
1 /*---------------------------------------------------------------------------*\
2 * OpenSG *
3 * *
4 * *
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
6 * *
7 * www.opensg.org *
8 * *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
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 /*****************************************************************************\
40 *****************************************************************************
41 ** **
42 ** This file is automatically generated. **
43 ** **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
46 ** **
47 ** Do not change this file, changes should be done in the derived **
48 ** class SkinningAlgorithm!
49 ** **
50 *****************************************************************************
51 \*****************************************************************************/
53 #include <cstdlib>
54 #include <cstdio>
56 #ifdef WIN32
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
59 #endif
61 #include "OSGConfig.h"
65 #include "OSGSkinnedGeometry.h" // Skin Class
66 #include "OSGSkeleton.h" // Skeleton Class
68 #include "OSGSkinningAlgorithmBase.h"
69 #include "OSGSkinningAlgorithm.h"
71 #include <boost/bind.hpp>
73 OSG_BEGIN_NAMESPACE
75 /***************************************************************************\
76 * Description *
77 \***************************************************************************/
79 /*! \class OSG::SkinningAlgorithm
83 /***************************************************************************\
84 * Field Documentation *
85 \***************************************************************************/
87 /*! \var SkinnedGeometry * SkinningAlgorithmBase::_sfSkin
91 /*! \var Skeleton * SkinningAlgorithmBase::_sfSkeleton
96 /***************************************************************************\
97 * FieldType/FieldTrait Instantiation *
98 \***************************************************************************/
100 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
101 PointerType FieldTraits<SkinningAlgorithm *, nsOSG>::_type(
102 "SkinningAlgorithmPtr",
103 "AlgorithmPtr",
104 SkinningAlgorithm::getClassType(),
105 nsOSG);
106 #endif
108 OSG_FIELDTRAITS_GETTYPE_NS(SkinningAlgorithm *, nsOSG)
110 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
111 SkinningAlgorithm *,
112 nsOSG)
114 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
115 SkinningAlgorithm *,
116 nsOSG)
118 DataType &FieldTraits< SkinningAlgorithm *, nsOSG + 1 >::getType(void)
120 return FieldTraits<SkinningAlgorithm *, nsOSG>::getType();
124 OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
125 SkinningAlgorithm *,
126 UnrecordedRefCountPolicy,
127 nsOSG + 1)
130 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
131 SkinningAlgorithm *,
132 UnrecordedRefCountPolicy,
133 nsOSG + 1)
136 /***************************************************************************\
137 * Field Description *
138 \***************************************************************************/
140 void SkinningAlgorithmBase::classDescInserter(TypeObject &oType)
142 FieldDescriptionBase *pDesc = NULL;
145 pDesc = new SFParentSkinnedGeometryPtr::Description(
146 SFParentSkinnedGeometryPtr::getClassType(),
147 "skin",
149 SkinFieldId, SkinFieldMask,
150 false,
151 (Field::SFDefaultFlags | Field::FStdAccess),
152 static_cast <FieldEditMethodSig>(&SkinningAlgorithm::invalidEditField),
153 static_cast <FieldGetMethodSig >(&SkinningAlgorithm::invalidGetField));
155 oType.addInitialDesc(pDesc);
157 pDesc = new SFUnrecSkeletonPtr::Description(
158 SFUnrecSkeletonPtr::getClassType(),
159 "skeleton",
161 SkeletonFieldId, SkeletonFieldMask,
162 false,
163 (Field::SFDefaultFlags | Field::FStdAccess),
164 static_cast<FieldEditMethodSig>(&SkinningAlgorithm::editHandleSkeleton),
165 static_cast<FieldGetMethodSig >(&SkinningAlgorithm::getHandleSkeleton));
167 oType.addInitialDesc(pDesc);
171 SkinningAlgorithmBase::TypeObject SkinningAlgorithmBase::_type(
172 SkinningAlgorithmBase::getClassname(),
173 Inherited::getClassname(),
174 "NULL",
175 nsOSG, //Namespace
176 NULL,
177 reinterpret_cast<InitContainerF>(&SkinningAlgorithm::initMethod),
178 reinterpret_cast<ExitContainerF>(&SkinningAlgorithm::exitMethod),
179 reinterpret_cast<InitalInsertDescFunc>(
180 reinterpret_cast<void *>(&SkinningAlgorithm::classDescInserter)),
181 false,
183 "<?xml version=\"1.0\"?>\n"
184 "\n"
185 "<FieldContainer\n"
186 " name=\"SkinningAlgorithm\"\n"
187 " parent=\"Algorithm\"\n"
188 " library=\"Dynamics\"\n"
189 " pointerfieldtypes=\"both\"\n"
190 " structure=\"abstract\"\n"
191 " systemcomponent=\"true\"\n"
192 " parentsystemcomponent=\"true\"\n"
193 " decoratable=\"false\"\n"
194 " childFields=\"both\"\n"
195 " parentFields=\"none\"\n"
196 ">\n"
197 " <Field\n"
198 " name=\"skin\"\n"
199 " type=\"SkinnedGeometry\"\n"
200 " category=\"parentpointer\"\n"
201 " cardinality=\"single\"\n"
202 " visibility=\"external\"\n"
203 " access=\"none\"\n"
204 " defaultValue=\"NULL\"\n"
205 " >\n"
206 " </Field>\n"
207 "\n"
208 " <Field\n"
209 " name=\"skeleton\"\n"
210 " type=\"Skeleton\"\n"
211 " category=\"pointer\"\n"
212 " cardinality=\"single\"\n"
213 " visibility=\"external\"\n"
214 " access=\"public\"\n"
215 " defaultValue=\"NULL\"\n"
216 " >\n"
217 " </Field>\n"
218 "\n"
219 "</FieldContainer>\n",
223 /*------------------------------ get -----------------------------------*/
225 FieldContainerType &SkinningAlgorithmBase::getType(void)
227 return _type;
230 const FieldContainerType &SkinningAlgorithmBase::getType(void) const
232 return _type;
235 UInt32 SkinningAlgorithmBase::getContainerSize(void) const
237 return sizeof(SkinningAlgorithm);
240 /*------------------------- decorator get ------------------------------*/
244 //! Get the SkinningAlgorithm::_sfSkeleton field.
245 const SFUnrecSkeletonPtr *SkinningAlgorithmBase::getSFSkeleton(void) const
247 return &_sfSkeleton;
250 SFUnrecSkeletonPtr *SkinningAlgorithmBase::editSFSkeleton (void)
252 editSField(SkeletonFieldMask);
254 return &_sfSkeleton;
257 //! Get the value of the SkinningAlgorithm::_sfSkeleton field.
258 Skeleton * SkinningAlgorithmBase::getSkeleton(void) const
260 return _sfSkeleton.getValue();
263 //! Set the value of the SkinningAlgorithm::_sfSkeleton field.
264 void SkinningAlgorithmBase::setSkeleton(Skeleton * const value)
266 editSField(SkeletonFieldMask);
268 _sfSkeleton.setValue(value);
276 /*------------------------------ access -----------------------------------*/
278 SizeT SkinningAlgorithmBase::getBinSize(ConstFieldMaskArg whichField)
280 SizeT returnValue = Inherited::getBinSize(whichField);
282 if(FieldBits::NoField != (SkinFieldMask & whichField))
284 returnValue += _sfSkin.getBinSize();
286 if(FieldBits::NoField != (SkeletonFieldMask & whichField))
288 returnValue += _sfSkeleton.getBinSize();
291 return returnValue;
294 void SkinningAlgorithmBase::copyToBin(BinaryDataHandler &pMem,
295 ConstFieldMaskArg whichField)
297 Inherited::copyToBin(pMem, whichField);
299 if(FieldBits::NoField != (SkinFieldMask & whichField))
301 _sfSkin.copyToBin(pMem);
303 if(FieldBits::NoField != (SkeletonFieldMask & whichField))
305 _sfSkeleton.copyToBin(pMem);
309 void SkinningAlgorithmBase::copyFromBin(BinaryDataHandler &pMem,
310 ConstFieldMaskArg whichField)
312 Inherited::copyFromBin(pMem, whichField);
314 if(FieldBits::NoField != (SkinFieldMask & whichField))
316 editSField(SkinFieldMask);
317 _sfSkin.copyFromBin(pMem);
319 if(FieldBits::NoField != (SkeletonFieldMask & whichField))
321 editSField(SkeletonFieldMask);
322 _sfSkeleton.copyFromBin(pMem);
329 /*------------------------- constructors ----------------------------------*/
331 SkinningAlgorithmBase::SkinningAlgorithmBase(void) :
332 Inherited(),
333 _sfSkin (NULL),
334 _sfSkeleton (NULL)
338 SkinningAlgorithmBase::SkinningAlgorithmBase(const SkinningAlgorithmBase &source) :
339 Inherited(source),
340 _sfSkin (NULL),
341 _sfSkeleton (NULL)
346 /*-------------------------- destructors ----------------------------------*/
348 SkinningAlgorithmBase::~SkinningAlgorithmBase(void)
351 /*-------------------------------------------------------------------------*/
352 /* Parent linking */
354 bool SkinningAlgorithmBase::linkParent(
355 FieldContainer * const pParent,
356 UInt16 const childFieldId,
357 UInt16 const parentFieldId )
359 if(parentFieldId == SkinFieldId)
361 SkinnedGeometry * pTypedParent =
362 dynamic_cast< SkinnedGeometry * >(pParent);
364 if(pTypedParent != NULL)
366 FieldContainer *pOldParent =
367 _sfSkin.getValue ();
369 UInt16 oldChildFieldId =
370 _sfSkin.getParentFieldPos();
372 if(pOldParent != NULL)
374 pOldParent->unlinkChild(this, oldChildFieldId);
377 editSField(SkinFieldMask);
379 _sfSkin.setValue(static_cast<SkinnedGeometry *>(pParent), childFieldId);
381 return true;
384 return false;
387 return Inherited::linkParent(pParent, childFieldId, parentFieldId);
390 bool SkinningAlgorithmBase::unlinkParent(
391 FieldContainer * const pParent,
392 UInt16 const parentFieldId)
394 if(parentFieldId == SkinFieldId)
396 SkinnedGeometry * pTypedParent =
397 dynamic_cast< SkinnedGeometry * >(pParent);
399 if(pTypedParent != NULL)
401 if(_sfSkin.getValue() == pTypedParent)
403 editSField(SkinFieldMask);
405 _sfSkin.setValue(NULL, 0xFFFF);
407 return true;
410 SWARNING << "Child ([" << this
411 << "] id [" << this->getId()
412 << "] type [" << this->getType().getCName()
413 << "] parentFieldId [" << parentFieldId
414 << "]) - Parent ([" << pParent
415 << "] id [" << pParent->getId()
416 << "] type [" << pParent->getType().getCName()
417 << "]): link inconsistent!"
418 << std::endl;
420 return false;
423 return false;
426 return Inherited::unlinkParent(pParent, parentFieldId);
430 void SkinningAlgorithmBase::onCreate(const SkinningAlgorithm *source)
432 Inherited::onCreate(source);
434 if(source != NULL)
436 SkinningAlgorithm *pThis = static_cast<SkinningAlgorithm *>(this);
438 pThis->setSkeleton(source->getSkeleton());
442 GetFieldHandlePtr SkinningAlgorithmBase::getHandleSkin (void) const
444 SFParentSkinnedGeometryPtr::GetHandlePtr returnValue;
446 return returnValue;
449 EditFieldHandlePtr SkinningAlgorithmBase::editHandleSkin (void)
451 EditFieldHandlePtr returnValue;
453 return returnValue;
456 GetFieldHandlePtr SkinningAlgorithmBase::getHandleSkeleton (void) const
458 SFUnrecSkeletonPtr::GetHandlePtr returnValue(
459 new SFUnrecSkeletonPtr::GetHandle(
460 &_sfSkeleton,
461 this->getType().getFieldDesc(SkeletonFieldId),
462 const_cast<SkinningAlgorithmBase *>(this)));
464 return returnValue;
467 EditFieldHandlePtr SkinningAlgorithmBase::editHandleSkeleton (void)
469 SFUnrecSkeletonPtr::EditHandlePtr returnValue(
470 new SFUnrecSkeletonPtr::EditHandle(
471 &_sfSkeleton,
472 this->getType().getFieldDesc(SkeletonFieldId),
473 this));
475 returnValue->setSetMethod(
476 boost::bind(&SkinningAlgorithm::setSkeleton,
477 static_cast<SkinningAlgorithm *>(this), _1));
479 editSField(SkeletonFieldMask);
481 return returnValue;
485 #ifdef OSG_MT_CPTR_ASPECT
486 void SkinningAlgorithmBase::execSyncV( FieldContainer &oFrom,
487 ConstFieldMaskArg whichField,
488 AspectOffsetStore &oOffsets,
489 ConstFieldMaskArg syncMode,
490 const UInt32 uiSyncInfo)
492 SkinningAlgorithm *pThis = static_cast<SkinningAlgorithm *>(this);
494 pThis->execSync(static_cast<SkinningAlgorithm *>(&oFrom),
495 whichField,
496 oOffsets,
497 syncMode,
498 uiSyncInfo);
500 #endif
504 void SkinningAlgorithmBase::resolveLinks(void)
506 Inherited::resolveLinks();
508 static_cast<SkinningAlgorithm *>(this)->setSkeleton(NULL);
514 OSG_END_NAMESPACE