1 /*---------------------------------------------------------------------------*\
5 * Copyright (C) 2000-2013 by the OpenSG Forum *
9 * contact: dirk@opensg.org, gerrit.voss@vossg.org, carsten_neumann@gmx.net *
11 \*---------------------------------------------------------------------------*/
12 /*---------------------------------------------------------------------------*\
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. *
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. *
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. *
28 \*---------------------------------------------------------------------------*/
29 /*---------------------------------------------------------------------------*\
37 \*---------------------------------------------------------------------------*/
39 /*****************************************************************************\
40 *****************************************************************************
42 ** This file is automatically generated. **
44 ** Any changes made to this file WILL be lost when it is **
45 ** regenerated, which can become necessary at any time. **
47 ** Do not change this file, changes should be done in the derived **
48 ** class GeoInstancer!
50 *****************************************************************************
51 \*****************************************************************************/
57 #pragma warning(disable: 4355) // turn off 'this' : used in base member initializer list warning
58 #pragma warning(disable: 4290) // disable exception specification warning
61 #include "OSGConfig.h"
65 #include "OSGGeometry.h" // BaseGeometry Class
67 #include "OSGGeoInstancerBase.h"
68 #include "OSGGeoInstancer.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
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(
102 "MaterialDrawablePtr",
103 GeoInstancer::getClassType(),
107 OSG_FIELDTRAITS_GETTYPE_NS(GeoInstancer
*, nsOSG
)
109 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
113 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
117 /***************************************************************************\
118 * Field Description *
119 \***************************************************************************/
121 void GeoInstancerBase::classDescInserter(TypeObject
&oType
)
123 FieldDescriptionBase
*pDesc
= NULL
;
126 pDesc
= new SFUInt32::Description(
127 SFUInt32::getClassType(),
130 NumInstancesFieldId
, NumInstancesFieldMask
,
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(),
142 BaseGeometryFieldId
, BaseGeometryFieldMask
,
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(),
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
)),
164 "<?xml version=\"1.0\"?>\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"
178 " name=\"numInstances\"\n"
180 " cardinality=\"single\"\n"
181 " visibility=\"external\"\n"
182 " defaultValue=\"1\"\n"
183 " access=\"public\"\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"
197 "</FieldContainer>\n",
201 /*------------------------------ get -----------------------------------*/
203 FieldContainerType
&GeoInstancerBase::getType(void)
208 const FieldContainerType
&GeoInstancerBase::getType(void) const
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();
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
);
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
);
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
);
364 GeoInstancer
*GeoInstancerBase::createEmptyLocal(BitVector bFlags
)
366 GeoInstancer
*returnValue
;
368 newPtr
<GeoInstancer
>(returnValue
, bFlags
);
370 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
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();
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
;
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
;
417 FieldContainerTransitPtr
GeoInstancerBase::shallowCopy(void) const
419 GeoInstancer
*tmpPtr
;
422 dynamic_cast<const GeoInstancer
*>(this),
423 Thread::getCurrentLocalFlags());
425 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
427 FieldContainerTransitPtr
returnValue(tmpPtr
);
435 /*------------------------- constructors ----------------------------------*/
437 GeoInstancerBase::GeoInstancerBase(void) :
439 _sfNumInstances (UInt32(1)),
440 _sfBaseGeometry (this,
442 Geometry::ParentsFieldId
)
446 GeoInstancerBase::GeoInstancerBase(const GeoInstancerBase
&source
) :
448 _sfNumInstances (source
._sfNumInstances
),
449 _sfBaseGeometry (this,
451 Geometry::ParentsFieldId
)
456 /*-------------------------- destructors ----------------------------------*/
458 GeoInstancerBase::~GeoInstancerBase(void)
462 /*-------------------------------------------------------------------------*/
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
);
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!"
502 return Inherited::unlinkChild(pChild
, childFieldId
);
505 void GeoInstancerBase::onCreate(const GeoInstancer
*source
)
507 Inherited::onCreate(source
);
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(
522 this->getType().getFieldDesc(NumInstancesFieldId
),
523 const_cast<GeoInstancerBase
*>(this)));
528 EditFieldHandlePtr
GeoInstancerBase::editHandleNumInstances (void)
530 SFUInt32::EditHandlePtr
returnValue(
531 new SFUInt32::EditHandle(
533 this->getType().getFieldDesc(NumInstancesFieldId
),
537 editSField(NumInstancesFieldMask
);
542 GetFieldHandlePtr
GeoInstancerBase::getHandleBaseGeometry (void) const
544 SFUnrecChildGeometryPtr::GetHandlePtr
returnValue(
545 new SFUnrecChildGeometryPtr::GetHandle(
547 this->getType().getFieldDesc(BaseGeometryFieldId
),
548 const_cast<GeoInstancerBase
*>(this)));
553 EditFieldHandlePtr
GeoInstancerBase::editHandleBaseGeometry (void)
555 SFUnrecChildGeometryPtr::EditHandlePtr
returnValue(
556 new SFUnrecChildGeometryPtr::EditHandle(
558 this->getType().getFieldDesc(BaseGeometryFieldId
),
561 returnValue
->setSetMethod(
562 boost::bind(&GeoInstancer::setBaseGeometry
,
563 static_cast<GeoInstancer
*>(this), _1
));
565 editSField(BaseGeometryFieldMask
);
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
),
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));
603 void GeoInstancerBase::resolveLinks(void)
605 Inherited::resolveLinks();
607 static_cast<GeoInstancer
*>(this)->setBaseGeometry(NULL
);