changed: gcc8 base update
[opensg.git] / Source / System / NodeCores / Drawables / Geometry / Instancing / OSGGeoInstancerBase.cpp
blob3b640fde786eae842607b8389bce5c8abc55616e
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 GeoInstancer!
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 "OSGGeometry.h" // BaseGeometry Class
67 #include "OSGGeoInstancerBase.h"
68 #include "OSGGeoInstancer.h"
70 #include <boost/bind.hpp>
72 OSG_BEGIN_NAMESPACE
74 /***************************************************************************\
75 * Description *
76 \***************************************************************************/
78 /*! \class OSG::GeoInstancer
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var UInt32 GeoInstancerBase::_sfNumInstances
90 /*! \var Geometry * GeoInstancerBase::_sfBaseGeometry
95 /***************************************************************************\
96 * FieldType/FieldTrait Instantiation *
97 \***************************************************************************/
99 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
100 PointerType FieldTraits<GeoInstancer *, nsOSG>::_type(
101 "GeoInstancerPtr",
102 "MaterialDrawablePtr",
103 GeoInstancer::getClassType(),
104 nsOSG);
105 #endif
107 OSG_FIELDTRAITS_GETTYPE_NS(GeoInstancer *, nsOSG)
109 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField,
110 GeoInstancer *,
111 nsOSG)
113 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField,
114 GeoInstancer *,
115 nsOSG)
117 /***************************************************************************\
118 * Field Description *
119 \***************************************************************************/
121 void GeoInstancerBase::classDescInserter(TypeObject &oType)
123 FieldDescriptionBase *pDesc = NULL;
126 pDesc = new SFUInt32::Description(
127 SFUInt32::getClassType(),
128 "numInstances",
130 NumInstancesFieldId, NumInstancesFieldMask,
131 false,
132 (Field::SFDefaultFlags | Field::FStdAccess),
133 static_cast<FieldEditMethodSig>(&GeoInstancer::editHandleNumInstances),
134 static_cast<FieldGetMethodSig >(&GeoInstancer::getHandleNumInstances));
136 oType.addInitialDesc(pDesc);
138 pDesc = new SFUnrecChildGeometryPtr::Description(
139 SFUnrecChildGeometryPtr::getClassType(),
140 "baseGeometry",
142 BaseGeometryFieldId, BaseGeometryFieldMask,
143 false,
144 (Field::SFDefaultFlags | Field::FStdAccess),
145 static_cast<FieldEditMethodSig>(&GeoInstancer::editHandleBaseGeometry),
146 static_cast<FieldGetMethodSig >(&GeoInstancer::getHandleBaseGeometry));
148 oType.addInitialDesc(pDesc);
152 GeoInstancerBase::TypeObject GeoInstancerBase::_type(
153 GeoInstancerBase::getClassname(),
154 Inherited::getClassname(),
155 "NULL",
156 nsOSG, //Namespace
157 reinterpret_cast<PrototypeCreateF>(&GeoInstancerBase::createEmptyLocal),
158 reinterpret_cast<InitContainerF>(&GeoInstancer::initMethod),
159 reinterpret_cast<ExitContainerF>(&GeoInstancer::exitMethod),
160 reinterpret_cast<InitalInsertDescFunc>(
161 reinterpret_cast<void *>(&GeoInstancer::classDescInserter)),
162 false,
164 "<?xml version=\"1.0\"?>\n"
165 "\n"
166 "<FieldContainer\n"
167 " name=\"GeoInstancer\"\n"
168 " parent=\"MaterialDrawable\"\n"
169 " library=\"Drawable\"\n"
170 " pointerfieldtypes=\"both\"\n"
171 " structure=\"concrete\"\n"
172 " systemcomponent=\"true\"\n"
173 " parentsystemcomponent=\"true\"\n"
174 " decoratable=\"false\"\n"
175 " docGroupBase=\"GrpDrawablesGeometry\"\n"
176 " >\n"
177 " <Field\n"
178 " name=\"numInstances\"\n"
179 " type=\"UInt32\"\n"
180 " cardinality=\"single\"\n"
181 " visibility=\"external\"\n"
182 " defaultValue=\"1\"\n"
183 " access=\"public\"\n"
184 " >\n"
185 " </Field>\n"
186 " <Field\n"
187 " name=\"baseGeometry\"\n"
188 " type=\"Geometry\"\n"
189 " category=\"childpointer\"\n"
190 " cardinality=\"single\"\n"
191 " visibility=\"external\"\n"
192 " defaultValue=\"NULL\"\n"
193 " access=\"public\"\n"
194 " linkParentField=\"Parents\"\n"
195 " >\n"
196 " </Field>\n"
197 "</FieldContainer>\n",
201 /*------------------------------ get -----------------------------------*/
203 FieldContainerType &GeoInstancerBase::getType(void)
205 return _type;
208 const FieldContainerType &GeoInstancerBase::getType(void) const
210 return _type;
213 UInt32 GeoInstancerBase::getContainerSize(void) const
215 return sizeof(GeoInstancer);
218 /*------------------------- decorator get ------------------------------*/
221 SFUInt32 *GeoInstancerBase::editSFNumInstances(void)
223 editSField(NumInstancesFieldMask);
225 return &_sfNumInstances;
228 const SFUInt32 *GeoInstancerBase::getSFNumInstances(void) const
230 return &_sfNumInstances;
234 //! Get the GeoInstancer::_sfBaseGeometry field.
235 const SFUnrecChildGeometryPtr *GeoInstancerBase::getSFBaseGeometry(void) const
237 return &_sfBaseGeometry;
240 SFUnrecChildGeometryPtr *GeoInstancerBase::editSFBaseGeometry (void)
242 editSField(BaseGeometryFieldMask);
244 return &_sfBaseGeometry;
247 //! Get the value of the GeoInstancer::_sfBaseGeometry field.
248 Geometry * GeoInstancerBase::getBaseGeometry(void) const
250 return _sfBaseGeometry.getValue();
253 //! Set the value of the GeoInstancer::_sfBaseGeometry field.
254 void GeoInstancerBase::setBaseGeometry(Geometry * const value)
256 editSField(BaseGeometryFieldMask);
258 _sfBaseGeometry.setValue(value);
266 /*------------------------------ access -----------------------------------*/
268 SizeT GeoInstancerBase::getBinSize(ConstFieldMaskArg whichField)
270 SizeT returnValue = Inherited::getBinSize(whichField);
272 if(FieldBits::NoField != (NumInstancesFieldMask & whichField))
274 returnValue += _sfNumInstances.getBinSize();
276 if(FieldBits::NoField != (BaseGeometryFieldMask & whichField))
278 returnValue += _sfBaseGeometry.getBinSize();
281 return returnValue;
284 void GeoInstancerBase::copyToBin(BinaryDataHandler &pMem,
285 ConstFieldMaskArg whichField)
287 Inherited::copyToBin(pMem, whichField);
289 if(FieldBits::NoField != (NumInstancesFieldMask & whichField))
291 _sfNumInstances.copyToBin(pMem);
293 if(FieldBits::NoField != (BaseGeometryFieldMask & whichField))
295 _sfBaseGeometry.copyToBin(pMem);
299 void GeoInstancerBase::copyFromBin(BinaryDataHandler &pMem,
300 ConstFieldMaskArg whichField)
302 Inherited::copyFromBin(pMem, whichField);
304 if(FieldBits::NoField != (NumInstancesFieldMask & whichField))
306 editSField(NumInstancesFieldMask);
307 _sfNumInstances.copyFromBin(pMem);
309 if(FieldBits::NoField != (BaseGeometryFieldMask & whichField))
311 editSField(BaseGeometryFieldMask);
312 _sfBaseGeometry.copyFromBin(pMem);
316 //! create a new instance of the class
317 GeoInstancerTransitPtr GeoInstancerBase::createLocal(BitVector bFlags)
319 GeoInstancerTransitPtr fc;
321 if(getClassType().getPrototype() != NULL)
323 FieldContainerTransitPtr tmpPtr =
324 getClassType().getPrototype()-> shallowCopyLocal(bFlags);
326 fc = dynamic_pointer_cast<GeoInstancer>(tmpPtr);
329 return fc;
332 //! create a new instance of the class, copy the container flags
333 GeoInstancerTransitPtr GeoInstancerBase::createDependent(BitVector bFlags)
335 GeoInstancerTransitPtr fc;
337 if(getClassType().getPrototype() != NULL)
339 FieldContainerTransitPtr tmpPtr =
340 getClassType().getPrototype()-> shallowCopyDependent(bFlags);
342 fc = dynamic_pointer_cast<GeoInstancer>(tmpPtr);
345 return fc;
348 //! create a new instance of the class
349 GeoInstancerTransitPtr GeoInstancerBase::create(void)
351 GeoInstancerTransitPtr fc;
353 if(getClassType().getPrototype() != NULL)
355 FieldContainerTransitPtr tmpPtr =
356 getClassType().getPrototype()-> shallowCopy();
358 fc = dynamic_pointer_cast<GeoInstancer>(tmpPtr);
361 return fc;
364 GeoInstancer *GeoInstancerBase::createEmptyLocal(BitVector bFlags)
366 GeoInstancer *returnValue;
368 newPtr<GeoInstancer>(returnValue, bFlags);
370 returnValue->_pFieldFlags->_bNamespaceMask &= ~bFlags;
372 return returnValue;
375 //! create an empty new instance of the class, do not copy the prototype
376 GeoInstancer *GeoInstancerBase::createEmpty(void)
378 GeoInstancer *returnValue;
380 newPtr<GeoInstancer>(returnValue, Thread::getCurrentLocalFlags());
382 returnValue->_pFieldFlags->_bNamespaceMask &=
383 ~Thread::getCurrentLocalFlags();
385 return returnValue;
389 FieldContainerTransitPtr GeoInstancerBase::shallowCopyLocal(
390 BitVector bFlags) const
392 GeoInstancer *tmpPtr;
394 newPtr(tmpPtr, dynamic_cast<const GeoInstancer *>(this), bFlags);
396 FieldContainerTransitPtr returnValue(tmpPtr);
398 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~bFlags;
400 return returnValue;
403 FieldContainerTransitPtr GeoInstancerBase::shallowCopyDependent(
404 BitVector bFlags) const
406 GeoInstancer *tmpPtr;
408 newPtr(tmpPtr, dynamic_cast<const GeoInstancer *>(this), ~bFlags);
410 FieldContainerTransitPtr returnValue(tmpPtr);
412 tmpPtr->_pFieldFlags->_bNamespaceMask = bFlags;
414 return returnValue;
417 FieldContainerTransitPtr GeoInstancerBase::shallowCopy(void) const
419 GeoInstancer *tmpPtr;
421 newPtr(tmpPtr,
422 dynamic_cast<const GeoInstancer *>(this),
423 Thread::getCurrentLocalFlags());
425 tmpPtr->_pFieldFlags->_bNamespaceMask &= ~Thread::getCurrentLocalFlags();
427 FieldContainerTransitPtr returnValue(tmpPtr);
429 return returnValue;
435 /*------------------------- constructors ----------------------------------*/
437 GeoInstancerBase::GeoInstancerBase(void) :
438 Inherited(),
439 _sfNumInstances (UInt32(1)),
440 _sfBaseGeometry (this,
441 BaseGeometryFieldId,
442 Geometry::ParentsFieldId)
446 GeoInstancerBase::GeoInstancerBase(const GeoInstancerBase &source) :
447 Inherited(source),
448 _sfNumInstances (source._sfNumInstances ),
449 _sfBaseGeometry (this,
450 BaseGeometryFieldId,
451 Geometry::ParentsFieldId)
456 /*-------------------------- destructors ----------------------------------*/
458 GeoInstancerBase::~GeoInstancerBase(void)
462 /*-------------------------------------------------------------------------*/
463 /* Child linking */
465 bool GeoInstancerBase::unlinkChild(
466 FieldContainer * const pChild,
467 UInt16 const childFieldId)
469 if(childFieldId == BaseGeometryFieldId)
471 Geometry * pTypedChild =
472 dynamic_cast<Geometry *>(pChild);
474 if(pTypedChild != NULL)
476 if(_sfBaseGeometry.getValue() == pTypedChild)
478 editSField(BaseGeometryFieldMask);
480 _sfBaseGeometry.setValue(NULL);
482 return true;
485 SWARNING << "Parent ([" << this
486 << "] id [" << this->getId()
487 << "] type [" << this->getType().getCName()
488 << "] childFieldId [" << childFieldId
489 << "]) - Child ([" << pChild
490 << "] id [" << pChild->getId()
491 << "] type [" << pChild->getType().getCName()
492 << "]): link inconsistent!"
493 << std::endl;
495 return false;
498 return false;
502 return Inherited::unlinkChild(pChild, childFieldId);
505 void GeoInstancerBase::onCreate(const GeoInstancer *source)
507 Inherited::onCreate(source);
509 if(source != NULL)
511 GeoInstancer *pThis = static_cast<GeoInstancer *>(this);
513 pThis->setBaseGeometry(source->getBaseGeometry());
517 GetFieldHandlePtr GeoInstancerBase::getHandleNumInstances (void) const
519 SFUInt32::GetHandlePtr returnValue(
520 new SFUInt32::GetHandle(
521 &_sfNumInstances,
522 this->getType().getFieldDesc(NumInstancesFieldId),
523 const_cast<GeoInstancerBase *>(this)));
525 return returnValue;
528 EditFieldHandlePtr GeoInstancerBase::editHandleNumInstances (void)
530 SFUInt32::EditHandlePtr returnValue(
531 new SFUInt32::EditHandle(
532 &_sfNumInstances,
533 this->getType().getFieldDesc(NumInstancesFieldId),
534 this));
537 editSField(NumInstancesFieldMask);
539 return returnValue;
542 GetFieldHandlePtr GeoInstancerBase::getHandleBaseGeometry (void) const
544 SFUnrecChildGeometryPtr::GetHandlePtr returnValue(
545 new SFUnrecChildGeometryPtr::GetHandle(
546 &_sfBaseGeometry,
547 this->getType().getFieldDesc(BaseGeometryFieldId),
548 const_cast<GeoInstancerBase *>(this)));
550 return returnValue;
553 EditFieldHandlePtr GeoInstancerBase::editHandleBaseGeometry (void)
555 SFUnrecChildGeometryPtr::EditHandlePtr returnValue(
556 new SFUnrecChildGeometryPtr::EditHandle(
557 &_sfBaseGeometry,
558 this->getType().getFieldDesc(BaseGeometryFieldId),
559 this));
561 returnValue->setSetMethod(
562 boost::bind(&GeoInstancer::setBaseGeometry,
563 static_cast<GeoInstancer *>(this), _1));
565 editSField(BaseGeometryFieldMask);
567 return returnValue;
571 #ifdef OSG_MT_CPTR_ASPECT
572 void GeoInstancerBase::execSyncV( FieldContainer &oFrom,
573 ConstFieldMaskArg whichField,
574 AspectOffsetStore &oOffsets,
575 ConstFieldMaskArg syncMode,
576 const UInt32 uiSyncInfo)
578 GeoInstancer *pThis = static_cast<GeoInstancer *>(this);
580 pThis->execSync(static_cast<GeoInstancer *>(&oFrom),
581 whichField,
582 oOffsets,
583 syncMode,
584 uiSyncInfo);
586 #endif
589 #ifdef OSG_MT_CPTR_ASPECT
590 FieldContainer *GeoInstancerBase::createAspectCopy(
591 const FieldContainer *pRefAspect) const
593 GeoInstancer *returnValue;
595 newAspectCopy(returnValue,
596 dynamic_cast<const GeoInstancer *>(pRefAspect),
597 dynamic_cast<const GeoInstancer *>(this));
599 return returnValue;
601 #endif
603 void GeoInstancerBase::resolveLinks(void)
605 Inherited::resolveLinks();
607 static_cast<GeoInstancer *>(this)->setBaseGeometry(NULL);
613 OSG_END_NAMESPACE