changed: gcc8 base update
[opensg.git] / Source / System / Dynamics / Skeleton / OSGBaseSkeletonJointBase.cpp
blobff48f485ee1c5b143de0107d17e1150d5f57dbc7
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 BaseSkeletonJoint!
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 "OSGSkeleton.h" // Skeleton Class
67 #include "OSGBaseSkeletonJointBase.h"
68 #include "OSGBaseSkeletonJoint.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::BaseSkeletonJoint
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var Skeleton * BaseSkeletonJointBase::_sfSkeleton
87 Parent skeleton.
90 /*! \var Int16 BaseSkeletonJointBase::_sfJointId
91 Id of the joint in the skeleton, used to assign vertices to joints.
92 The joints in a skeleton must have a unique jointId and they should
93 form an interval (no holes) [0, N].
97 /***************************************************************************\
98 * FieldType/FieldTrait Instantiation *
99 \***************************************************************************/
101 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
102 PointerType FieldTraits<BaseSkeletonJoint *, nsOSG>::_type(
103 "BaseSkeletonJointPtr",
104 "GroupPtr",
105 BaseSkeletonJoint::getClassType(),
106 nsOSG);
107 #endif
109 OSG_FIELDTRAITS_GETTYPE_NS(BaseSkeletonJoint *, nsOSG)
111 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
112 BaseSkeletonJoint *,
113 nsOSG)
115 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
116 BaseSkeletonJoint *,
117 nsOSG)
119 DataType &FieldTraits< BaseSkeletonJoint *, nsOSG + 1 >::getType(void)
121 return FieldTraits<BaseSkeletonJoint *, nsOSG>::getType();
125 OSG_EXPORT_PTR_SFIELD(ChildPointerSField,
126 BaseSkeletonJoint *,
127 UnrecordedRefCountPolicy,
128 nsOSG + 1)
131 OSG_EXPORT_PTR_MFIELD(ChildPointerMField,
132 BaseSkeletonJoint *,
133 UnrecordedRefCountPolicy,
134 nsOSG + 1)
137 DataType &FieldTraits<BaseSkeletonJoint *, nsOSG + 2 >::getType(void)
139 return FieldTraits<BaseSkeletonJoint *, nsOSG>::getType();
143 OSG_SFIELDTYPE_INST(ParentPointerSField,
144 BaseSkeletonJoint *,
145 NoRefCountPolicy,
146 nsOSG + 2);
148 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerSField,
149 BaseSkeletonJoint *,
150 NoRefCountPolicy,
151 nsOSG + 2)
154 OSG_MFIELDTYPE_INST(ParentPointerMField,
155 BaseSkeletonJoint *,
156 NoRefCountPolicy,
159 OSG_FIELD_DLLEXPORT_DEF3(ParentPointerMField,
160 BaseSkeletonJoint *,
161 NoRefCountPolicy,
165 /***************************************************************************\
166 * Field Description *
167 \***************************************************************************/
169 void BaseSkeletonJointBase::classDescInserter(TypeObject &oType)
171 FieldDescriptionBase *pDesc = NULL;
174 pDesc = new SFParentSkeletonPtr::Description(
175 SFParentSkeletonPtr::getClassType(),
176 "skeleton",
177 "Parent skeleton.\n",
178 SkeletonFieldId, SkeletonFieldMask,
179 true,
180 (Field::SFDefaultFlags | Field::FStdAccess),
181 static_cast <FieldEditMethodSig>(&BaseSkeletonJoint::invalidEditField),
182 static_cast <FieldGetMethodSig >(&BaseSkeletonJoint::invalidGetField));
184 oType.addInitialDesc(pDesc);
186 pDesc = new SFInt16::Description(
187 SFInt16::getClassType(),
188 "jointId",
189 "Id of the joint in the skeleton, used to assign vertices to joints.\n"
190 "The joints in a skeleton must have a unique jointId and they should\n"
191 "form an interval (no holes) [0, N].\n",
192 JointIdFieldId, JointIdFieldMask,
193 false,
194 (Field::SFDefaultFlags | Field::FStdAccess),
195 static_cast<FieldEditMethodSig>(&BaseSkeletonJoint::editHandleJointId),
196 static_cast<FieldGetMethodSig >(&BaseSkeletonJoint::getHandleJointId));
198 oType.addInitialDesc(pDesc);
202 BaseSkeletonJointBase::TypeObject BaseSkeletonJointBase::_type(
203 BaseSkeletonJointBase::getClassname(),
204 Inherited::getClassname(),
205 "NULL",
206 nsOSG, //Namespace
207 NULL,
208 reinterpret_cast<InitContainerF>(&BaseSkeletonJoint::initMethod),
209 reinterpret_cast<ExitContainerF>(&BaseSkeletonJoint::exitMethod),
210 reinterpret_cast<InitalInsertDescFunc>(
211 reinterpret_cast<void *>(&BaseSkeletonJoint::classDescInserter)),
212 false,
214 "<?xml version=\"1.0\"?>\n"
215 "\n"
216 "<FieldContainer\n"
217 " name=\"BaseSkeletonJoint\"\n"
218 " parent=\"Group\"\n"
219 " library=\"Dynamics\"\n"
220 " pointerfieldtypes=\"both\"\n"
221 " structure=\"abstract\"\n"
222 " systemcomponent=\"true\"\n"
223 " parentsystemcomponent=\"true\"\n"
224 " decoratable=\"false\"\n"
225 " isNodeCore=\"false\"\n"
226 " childFields=\"both\"\n"
227 " parentFields=\"both\"\n"
228 ">\n"
229 " <Field\n"
230 " name=\"skeleton\"\n"
231 " type=\"Skeleton\"\n"
232 " category=\"parentpointer\"\n"
233 " cardinality=\"single\"\n"
234 " defaultValue=\"NULL\"\n"
235 " visibility=\"internal\"\n"
236 " access=\"none\"\n"
237 " >\n"
238 " Parent skeleton.\n"
239 " </Field>\n"
240 "\n"
241 " <Field\n"
242 " name=\"jointId\"\n"
243 " type=\"Int16\"\n"
244 " category=\"data\"\n"
245 " cardinality=\"single\"\n"
246 " defaultValue=\"BaseSkeletonJoint::INVALID_JOINT_ID\"\n"
247 " visibility=\"external\"\n"
248 " access=\"public\"\n"
249 " >\n"
250 " Id of the joint in the skeleton, used to assign vertices to joints.\n"
251 " The joints in a skeleton must have a unique jointId and they should\n"
252 " form an interval (no holes) [0, N].\n"
253 " </Field>\n"
254 "</FieldContainer>\n",
258 /*------------------------------ get -----------------------------------*/
260 FieldContainerType &BaseSkeletonJointBase::getType(void)
262 return _type;
265 const FieldContainerType &BaseSkeletonJointBase::getType(void) const
267 return _type;
270 UInt32 BaseSkeletonJointBase::getContainerSize(void) const
272 return sizeof(BaseSkeletonJoint);
275 /*------------------------- decorator get ------------------------------*/
279 SFInt16 *BaseSkeletonJointBase::editSFJointId(void)
281 editSField(JointIdFieldMask);
283 return &_sfJointId;
286 const SFInt16 *BaseSkeletonJointBase::getSFJointId(void) const
288 return &_sfJointId;
296 /*------------------------------ access -----------------------------------*/
298 SizeT BaseSkeletonJointBase::getBinSize(ConstFieldMaskArg whichField)
300 SizeT returnValue = Inherited::getBinSize(whichField);
302 if(FieldBits::NoField != (SkeletonFieldMask & whichField))
304 returnValue += _sfSkeleton.getBinSize();
306 if(FieldBits::NoField != (JointIdFieldMask & whichField))
308 returnValue += _sfJointId.getBinSize();
311 return returnValue;
314 void BaseSkeletonJointBase::copyToBin(BinaryDataHandler &pMem,
315 ConstFieldMaskArg whichField)
317 Inherited::copyToBin(pMem, whichField);
319 if(FieldBits::NoField != (SkeletonFieldMask & whichField))
321 _sfSkeleton.copyToBin(pMem);
323 if(FieldBits::NoField != (JointIdFieldMask & whichField))
325 _sfJointId.copyToBin(pMem);
329 void BaseSkeletonJointBase::copyFromBin(BinaryDataHandler &pMem,
330 ConstFieldMaskArg whichField)
332 Inherited::copyFromBin(pMem, whichField);
334 if(FieldBits::NoField != (SkeletonFieldMask & whichField))
336 editSField(SkeletonFieldMask);
337 _sfSkeleton.copyFromBin(pMem);
339 if(FieldBits::NoField != (JointIdFieldMask & whichField))
341 editSField(JointIdFieldMask);
342 _sfJointId.copyFromBin(pMem);
349 /*------------------------- constructors ----------------------------------*/
351 BaseSkeletonJointBase::BaseSkeletonJointBase(void) :
352 Inherited(),
353 _sfSkeleton (NULL),
354 _sfJointId (Int16(BaseSkeletonJoint::INVALID_JOINT_ID))
358 BaseSkeletonJointBase::BaseSkeletonJointBase(const BaseSkeletonJointBase &source) :
359 Inherited(source),
360 _sfSkeleton (NULL),
361 _sfJointId (source._sfJointId )
366 /*-------------------------- destructors ----------------------------------*/
368 BaseSkeletonJointBase::~BaseSkeletonJointBase(void)
371 /*-------------------------------------------------------------------------*/
372 /* Parent linking */
374 bool BaseSkeletonJointBase::linkParent(
375 FieldContainer * const pParent,
376 UInt16 const childFieldId,
377 UInt16 const parentFieldId )
379 if(parentFieldId == SkeletonFieldId)
381 Skeleton * pTypedParent =
382 dynamic_cast< Skeleton * >(pParent);
384 if(pTypedParent != NULL)
386 FieldContainer *pOldParent =
387 _sfSkeleton.getValue ();
389 UInt16 oldChildFieldId =
390 _sfSkeleton.getParentFieldPos();
392 if(pOldParent != NULL)
394 pOldParent->unlinkChild(this, oldChildFieldId);
397 editSField(SkeletonFieldMask);
399 _sfSkeleton.setValue(static_cast<Skeleton *>(pParent), childFieldId);
401 return true;
404 return false;
407 return Inherited::linkParent(pParent, childFieldId, parentFieldId);
410 bool BaseSkeletonJointBase::unlinkParent(
411 FieldContainer * const pParent,
412 UInt16 const parentFieldId)
414 if(parentFieldId == SkeletonFieldId)
416 Skeleton * pTypedParent =
417 dynamic_cast< Skeleton * >(pParent);
419 if(pTypedParent != NULL)
421 if(_sfSkeleton.getValue() == pTypedParent)
423 editSField(SkeletonFieldMask);
425 _sfSkeleton.setValue(NULL, 0xFFFF);
427 return true;
430 SWARNING << "Child ([" << this
431 << "] id [" << this->getId()
432 << "] type [" << this->getType().getCName()
433 << "] parentFieldId [" << parentFieldId
434 << "]) - Parent ([" << pParent
435 << "] id [" << pParent->getId()
436 << "] type [" << pParent->getType().getCName()
437 << "]): link inconsistent!"
438 << std::endl;
440 return false;
443 return false;
446 return Inherited::unlinkParent(pParent, parentFieldId);
451 GetFieldHandlePtr BaseSkeletonJointBase::getHandleSkeleton (void) const
453 SFParentSkeletonPtr::GetHandlePtr returnValue;
455 return returnValue;
458 EditFieldHandlePtr BaseSkeletonJointBase::editHandleSkeleton (void)
460 EditFieldHandlePtr returnValue;
462 return returnValue;
465 GetFieldHandlePtr BaseSkeletonJointBase::getHandleJointId (void) const
467 SFInt16::GetHandlePtr returnValue(
468 new SFInt16::GetHandle(
469 &_sfJointId,
470 this->getType().getFieldDesc(JointIdFieldId),
471 const_cast<BaseSkeletonJointBase *>(this)));
473 return returnValue;
476 EditFieldHandlePtr BaseSkeletonJointBase::editHandleJointId (void)
478 SFInt16::EditHandlePtr returnValue(
479 new SFInt16::EditHandle(
480 &_sfJointId,
481 this->getType().getFieldDesc(JointIdFieldId),
482 this));
485 editSField(JointIdFieldMask);
487 return returnValue;
491 #ifdef OSG_MT_CPTR_ASPECT
492 void BaseSkeletonJointBase::execSyncV( FieldContainer &oFrom,
493 ConstFieldMaskArg whichField,
494 AspectOffsetStore &oOffsets,
495 ConstFieldMaskArg syncMode,
496 const UInt32 uiSyncInfo)
498 BaseSkeletonJoint *pThis = static_cast<BaseSkeletonJoint *>(this);
500 pThis->execSync(static_cast<BaseSkeletonJoint *>(&oFrom),
501 whichField,
502 oOffsets,
503 syncMode,
504 uiSyncInfo);
506 #endif
510 void BaseSkeletonJointBase::resolveLinks(void)
512 Inherited::resolveLinks();
518 OSG_END_NAMESPACE