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 KDTreeIntersectProxyAttachment!
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" // Geometry Class
67 #include "OSGKDTreeIntersectProxyAttachmentBase.h"
68 #include "OSGKDTreeIntersectProxyAttachment.h"
70 #include <boost/bind.hpp>
74 /***************************************************************************\
76 \***************************************************************************/
78 /*! \class OSG::KDTreeIntersectProxyAttachment
82 /***************************************************************************\
83 * Field Documentation *
84 \***************************************************************************/
86 /*! \var Geometry * KDTreeIntersectProxyAttachmentBase::_sfGeometry
87 Geometry proxied by this attachment.
90 /*! \var Int32 KDTreeIntersectProxyAttachmentBase::_sfMaxDepth
91 Maximal depth of IntersectKDTree, auto determined if negative.
94 /*! \var IntersectKDTreeNode KDTreeIntersectProxyAttachmentBase::_mfTreeNodes
95 Stores the nodes of the IntersectKDTree.
98 /*! \var UInt32 KDTreeIntersectProxyAttachmentBase::_mfTriIndices
99 Stores triangle indices referenced from leaf nodes of the IntersectKDTree.
103 /***************************************************************************\
104 * FieldType/FieldTrait Instantiation *
105 \***************************************************************************/
107 #if !defined(OSG_DO_DOC) || defined(OSG_DOC_DEV)
108 PointerType FieldTraits
<KDTreeIntersectProxyAttachment
*, nsOSG
>::_type(
109 "KDTreeIntersectProxyAttachmentPtr",
110 "IntersectProxyAttachmentPtr",
111 KDTreeIntersectProxyAttachment::getClassType(),
115 OSG_FIELDTRAITS_GETTYPE_NS(KDTreeIntersectProxyAttachment
*, nsOSG
)
117 OSG_EXPORT_PTR_SFIELD_FULL(PointerSField
,
118 KDTreeIntersectProxyAttachment
*,
121 OSG_EXPORT_PTR_MFIELD_FULL(PointerMField
,
122 KDTreeIntersectProxyAttachment
*,
125 /***************************************************************************\
126 * Field Description *
127 \***************************************************************************/
129 void KDTreeIntersectProxyAttachmentBase::classDescInserter(TypeObject
&oType
)
131 FieldDescriptionBase
*pDesc
= NULL
;
134 pDesc
= new SFUnrecGeometryPtr::Description(
135 SFUnrecGeometryPtr::getClassType(),
137 "Geometry proxied by this attachment.\n",
138 GeometryFieldId
, GeometryFieldMask
,
140 (Field::SFDefaultFlags
| Field::FStdAccess
),
141 static_cast<FieldEditMethodSig
>(&KDTreeIntersectProxyAttachment::editHandleGeometry
),
142 static_cast<FieldGetMethodSig
>(&KDTreeIntersectProxyAttachment::getHandleGeometry
));
144 oType
.addInitialDesc(pDesc
);
146 pDesc
= new SFInt32::Description(
147 SFInt32::getClassType(),
149 "Maximal depth of IntersectKDTree, auto determined if negative.\n",
150 MaxDepthFieldId
, MaxDepthFieldMask
,
152 (Field::SFDefaultFlags
| Field::FStdAccess
),
153 static_cast<FieldEditMethodSig
>(&KDTreeIntersectProxyAttachment::editHandleMaxDepth
),
154 static_cast<FieldGetMethodSig
>(&KDTreeIntersectProxyAttachment::getHandleMaxDepth
));
156 oType
.addInitialDesc(pDesc
);
158 pDesc
= new MFIntersectKDTreeNode::Description(
159 MFIntersectKDTreeNode::getClassType(),
161 "Stores the nodes of the IntersectKDTree.\n",
162 TreeNodesFieldId
, TreeNodesFieldMask
,
164 (Field::MFDefaultFlags
| Field::FStdAccess
),
165 static_cast<FieldEditMethodSig
>(&KDTreeIntersectProxyAttachment::editHandleTreeNodes
),
166 static_cast<FieldGetMethodSig
>(&KDTreeIntersectProxyAttachment::getHandleTreeNodes
));
168 oType
.addInitialDesc(pDesc
);
170 pDesc
= new MFUInt32::Description(
171 MFUInt32::getClassType(),
173 "Stores triangle indices referenced from leaf nodes of the IntersectKDTree.\n",
174 TriIndicesFieldId
, TriIndicesFieldMask
,
176 (Field::MFDefaultFlags
| Field::FStdAccess
),
177 static_cast<FieldEditMethodSig
>(&KDTreeIntersectProxyAttachment::editHandleTriIndices
),
178 static_cast<FieldGetMethodSig
>(&KDTreeIntersectProxyAttachment::getHandleTriIndices
));
180 oType
.addInitialDesc(pDesc
);
184 KDTreeIntersectProxyAttachmentBase::TypeObject
KDTreeIntersectProxyAttachmentBase::_type(
185 KDTreeIntersectProxyAttachmentBase::getClassname(),
186 Inherited::getClassname(),
187 "IntersectProxyAttachment",
189 reinterpret_cast<PrototypeCreateF
>(&KDTreeIntersectProxyAttachmentBase::createEmptyLocal
),
190 reinterpret_cast<InitContainerF
>(&KDTreeIntersectProxyAttachment::initMethod
),
191 reinterpret_cast<ExitContainerF
>(&KDTreeIntersectProxyAttachment::exitMethod
),
192 reinterpret_cast<InitalInsertDescFunc
>(
193 reinterpret_cast<void *>(&KDTreeIntersectProxyAttachment::classDescInserter
)),
196 "<?xml version=\"1.0\"?>\n"
199 " name=\"KDTreeIntersectProxyAttachment\"\n"
200 " parent=\"IntersectProxyAttachment\"\n"
201 " group=\"IntersectProxyAttachment\"\n"
202 " library=\"Drawable\"\n"
203 " pointerfieldtypes=\"both\"\n"
204 " structure=\"concrete\"\n"
205 " systemcomponent=\"true\"\n"
206 " parentsystemcomponent=\"true\"\n"
207 " docGroupBase=\"GrpDrawablesGeometry\"\n"
210 " name=\"geometry\"\n"
211 " type=\"Geometry\"\n"
212 " category=\"pointer\"\n"
213 " cardinality=\"single\"\n"
214 " visibility=\"external\"\n"
215 " access=\"public\"\n"
217 " Geometry proxied by this attachment.\n"
220 " name=\"maxDepth\"\n"
222 " category=\"data\"\n"
223 " cardinality=\"single\"\n"
224 " visibility=\"external\"\n"
225 " access=\"public\"\n"
226 " defaultValue=\"-1\"\n"
228 " Maximal depth of IntersectKDTree, auto determined if negative.\n"
231 " name=\"treeNodes\"\n"
232 " type=\"IntersectKDTreeNode\"\n"
233 " category=\"data\"\n"
234 " cardinality=\"multi\"\n"
235 " visibility=\"external\"\n"
236 " access=\"protected\"\n"
238 " Stores the nodes of the IntersectKDTree.\n"
241 " name=\"triIndices\"\n"
243 " category=\"data\"\n"
244 " cardinality=\"multi\"\n"
245 " visibility=\"external\"\n"
246 " access=\"protected\"\n"
248 " Stores triangle indices referenced from leaf nodes of the IntersectKDTree.\n"
250 "</FieldContainer>\n",
254 /*------------------------------ get -----------------------------------*/
256 FieldContainerType
&KDTreeIntersectProxyAttachmentBase::getType(void)
261 const FieldContainerType
&KDTreeIntersectProxyAttachmentBase::getType(void) const
266 UInt32
KDTreeIntersectProxyAttachmentBase::getContainerSize(void) const
268 return sizeof(KDTreeIntersectProxyAttachment
);
271 /*------------------------- decorator get ------------------------------*/
274 //! Get the KDTreeIntersectProxyAttachment::_sfGeometry field.
275 const SFUnrecGeometryPtr
*KDTreeIntersectProxyAttachmentBase::getSFGeometry(void) const
280 SFUnrecGeometryPtr
*KDTreeIntersectProxyAttachmentBase::editSFGeometry (void)
282 editSField(GeometryFieldMask
);
287 //! Get the value of the KDTreeIntersectProxyAttachment::_sfGeometry field.
288 Geometry
* KDTreeIntersectProxyAttachmentBase::getGeometry(void) const
290 return _sfGeometry
.getValue();
293 //! Set the value of the KDTreeIntersectProxyAttachment::_sfGeometry field.
294 void KDTreeIntersectProxyAttachmentBase::setGeometry(Geometry
* const value
)
296 editSField(GeometryFieldMask
);
298 _sfGeometry
.setValue(value
);
302 SFInt32
*KDTreeIntersectProxyAttachmentBase::editSFMaxDepth(void)
304 editSField(MaxDepthFieldMask
);
309 const SFInt32
*KDTreeIntersectProxyAttachmentBase::getSFMaxDepth(void) const
315 MFIntersectKDTreeNode
*KDTreeIntersectProxyAttachmentBase::editMFTreeNodes(void)
317 editMField(TreeNodesFieldMask
, _mfTreeNodes
);
319 return &_mfTreeNodes
;
322 const MFIntersectKDTreeNode
*KDTreeIntersectProxyAttachmentBase::getMFTreeNodes(void) const
324 return &_mfTreeNodes
;
328 MFUInt32
*KDTreeIntersectProxyAttachmentBase::editMFTriIndices(void)
330 editMField(TriIndicesFieldMask
, _mfTriIndices
);
332 return &_mfTriIndices
;
335 const MFUInt32
*KDTreeIntersectProxyAttachmentBase::getMFTriIndices(void) const
337 return &_mfTriIndices
;
345 /*------------------------------ access -----------------------------------*/
347 SizeT
KDTreeIntersectProxyAttachmentBase::getBinSize(ConstFieldMaskArg whichField
)
349 SizeT returnValue
= Inherited::getBinSize(whichField
);
351 if(FieldBits::NoField
!= (GeometryFieldMask
& whichField
))
353 returnValue
+= _sfGeometry
.getBinSize();
355 if(FieldBits::NoField
!= (MaxDepthFieldMask
& whichField
))
357 returnValue
+= _sfMaxDepth
.getBinSize();
359 if(FieldBits::NoField
!= (TreeNodesFieldMask
& whichField
))
361 returnValue
+= _mfTreeNodes
.getBinSize();
363 if(FieldBits::NoField
!= (TriIndicesFieldMask
& whichField
))
365 returnValue
+= _mfTriIndices
.getBinSize();
371 void KDTreeIntersectProxyAttachmentBase::copyToBin(BinaryDataHandler
&pMem
,
372 ConstFieldMaskArg whichField
)
374 Inherited::copyToBin(pMem
, whichField
);
376 if(FieldBits::NoField
!= (GeometryFieldMask
& whichField
))
378 _sfGeometry
.copyToBin(pMem
);
380 if(FieldBits::NoField
!= (MaxDepthFieldMask
& whichField
))
382 _sfMaxDepth
.copyToBin(pMem
);
384 if(FieldBits::NoField
!= (TreeNodesFieldMask
& whichField
))
386 _mfTreeNodes
.copyToBin(pMem
);
388 if(FieldBits::NoField
!= (TriIndicesFieldMask
& whichField
))
390 _mfTriIndices
.copyToBin(pMem
);
394 void KDTreeIntersectProxyAttachmentBase::copyFromBin(BinaryDataHandler
&pMem
,
395 ConstFieldMaskArg whichField
)
397 Inherited::copyFromBin(pMem
, whichField
);
399 if(FieldBits::NoField
!= (GeometryFieldMask
& whichField
))
401 editSField(GeometryFieldMask
);
402 _sfGeometry
.copyFromBin(pMem
);
404 if(FieldBits::NoField
!= (MaxDepthFieldMask
& whichField
))
406 editSField(MaxDepthFieldMask
);
407 _sfMaxDepth
.copyFromBin(pMem
);
409 if(FieldBits::NoField
!= (TreeNodesFieldMask
& whichField
))
411 editMField(TreeNodesFieldMask
, _mfTreeNodes
);
412 _mfTreeNodes
.copyFromBin(pMem
);
414 if(FieldBits::NoField
!= (TriIndicesFieldMask
& whichField
))
416 editMField(TriIndicesFieldMask
, _mfTriIndices
);
417 _mfTriIndices
.copyFromBin(pMem
);
421 //! create a new instance of the class
422 KDTreeIntersectProxyAttachmentTransitPtr
KDTreeIntersectProxyAttachmentBase::createLocal(BitVector bFlags
)
424 KDTreeIntersectProxyAttachmentTransitPtr fc
;
426 if(getClassType().getPrototype() != NULL
)
428 FieldContainerTransitPtr tmpPtr
=
429 getClassType().getPrototype()-> shallowCopyLocal(bFlags
);
431 fc
= dynamic_pointer_cast
<KDTreeIntersectProxyAttachment
>(tmpPtr
);
437 //! create a new instance of the class, copy the container flags
438 KDTreeIntersectProxyAttachmentTransitPtr
KDTreeIntersectProxyAttachmentBase::createDependent(BitVector bFlags
)
440 KDTreeIntersectProxyAttachmentTransitPtr fc
;
442 if(getClassType().getPrototype() != NULL
)
444 FieldContainerTransitPtr tmpPtr
=
445 getClassType().getPrototype()-> shallowCopyDependent(bFlags
);
447 fc
= dynamic_pointer_cast
<KDTreeIntersectProxyAttachment
>(tmpPtr
);
453 //! create a new instance of the class
454 KDTreeIntersectProxyAttachmentTransitPtr
KDTreeIntersectProxyAttachmentBase::create(void)
456 KDTreeIntersectProxyAttachmentTransitPtr fc
;
458 if(getClassType().getPrototype() != NULL
)
460 FieldContainerTransitPtr tmpPtr
=
461 getClassType().getPrototype()-> shallowCopy();
463 fc
= dynamic_pointer_cast
<KDTreeIntersectProxyAttachment
>(tmpPtr
);
469 KDTreeIntersectProxyAttachment
*KDTreeIntersectProxyAttachmentBase::createEmptyLocal(BitVector bFlags
)
471 KDTreeIntersectProxyAttachment
*returnValue
;
473 newPtr
<KDTreeIntersectProxyAttachment
>(returnValue
, bFlags
);
475 returnValue
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
480 //! create an empty new instance of the class, do not copy the prototype
481 KDTreeIntersectProxyAttachment
*KDTreeIntersectProxyAttachmentBase::createEmpty(void)
483 KDTreeIntersectProxyAttachment
*returnValue
;
485 newPtr
<KDTreeIntersectProxyAttachment
>(returnValue
, Thread::getCurrentLocalFlags());
487 returnValue
->_pFieldFlags
->_bNamespaceMask
&=
488 ~Thread::getCurrentLocalFlags();
494 FieldContainerTransitPtr
KDTreeIntersectProxyAttachmentBase::shallowCopyLocal(
495 BitVector bFlags
) const
497 KDTreeIntersectProxyAttachment
*tmpPtr
;
499 newPtr(tmpPtr
, dynamic_cast<const KDTreeIntersectProxyAttachment
*>(this), bFlags
);
501 FieldContainerTransitPtr
returnValue(tmpPtr
);
503 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~bFlags
;
508 FieldContainerTransitPtr
KDTreeIntersectProxyAttachmentBase::shallowCopyDependent(
509 BitVector bFlags
) const
511 KDTreeIntersectProxyAttachment
*tmpPtr
;
513 newPtr(tmpPtr
, dynamic_cast<const KDTreeIntersectProxyAttachment
*>(this), ~bFlags
);
515 FieldContainerTransitPtr
returnValue(tmpPtr
);
517 tmpPtr
->_pFieldFlags
->_bNamespaceMask
= bFlags
;
522 FieldContainerTransitPtr
KDTreeIntersectProxyAttachmentBase::shallowCopy(void) const
524 KDTreeIntersectProxyAttachment
*tmpPtr
;
527 dynamic_cast<const KDTreeIntersectProxyAttachment
*>(this),
528 Thread::getCurrentLocalFlags());
530 tmpPtr
->_pFieldFlags
->_bNamespaceMask
&= ~Thread::getCurrentLocalFlags();
532 FieldContainerTransitPtr
returnValue(tmpPtr
);
540 /*------------------------- constructors ----------------------------------*/
542 KDTreeIntersectProxyAttachmentBase::KDTreeIntersectProxyAttachmentBase(void) :
545 _sfMaxDepth (Int32(-1)),
551 KDTreeIntersectProxyAttachmentBase::KDTreeIntersectProxyAttachmentBase(const KDTreeIntersectProxyAttachmentBase
&source
) :
554 _sfMaxDepth (source
._sfMaxDepth
),
555 _mfTreeNodes (source
._mfTreeNodes
),
556 _mfTriIndices (source
._mfTriIndices
)
561 /*-------------------------- destructors ----------------------------------*/
563 KDTreeIntersectProxyAttachmentBase::~KDTreeIntersectProxyAttachmentBase(void)
567 void KDTreeIntersectProxyAttachmentBase::onCreate(const KDTreeIntersectProxyAttachment
*source
)
569 Inherited::onCreate(source
);
573 KDTreeIntersectProxyAttachment
*pThis
= static_cast<KDTreeIntersectProxyAttachment
*>(this);
575 pThis
->setGeometry(source
->getGeometry());
579 GetFieldHandlePtr
KDTreeIntersectProxyAttachmentBase::getHandleGeometry (void) const
581 SFUnrecGeometryPtr::GetHandlePtr
returnValue(
582 new SFUnrecGeometryPtr::GetHandle(
584 this->getType().getFieldDesc(GeometryFieldId
),
585 const_cast<KDTreeIntersectProxyAttachmentBase
*>(this)));
590 EditFieldHandlePtr
KDTreeIntersectProxyAttachmentBase::editHandleGeometry (void)
592 SFUnrecGeometryPtr::EditHandlePtr
returnValue(
593 new SFUnrecGeometryPtr::EditHandle(
595 this->getType().getFieldDesc(GeometryFieldId
),
598 returnValue
->setSetMethod(
599 boost::bind(&KDTreeIntersectProxyAttachment::setGeometry
,
600 static_cast<KDTreeIntersectProxyAttachment
*>(this), _1
));
602 editSField(GeometryFieldMask
);
607 GetFieldHandlePtr
KDTreeIntersectProxyAttachmentBase::getHandleMaxDepth (void) const
609 SFInt32::GetHandlePtr
returnValue(
610 new SFInt32::GetHandle(
612 this->getType().getFieldDesc(MaxDepthFieldId
),
613 const_cast<KDTreeIntersectProxyAttachmentBase
*>(this)));
618 EditFieldHandlePtr
KDTreeIntersectProxyAttachmentBase::editHandleMaxDepth (void)
620 SFInt32::EditHandlePtr
returnValue(
621 new SFInt32::EditHandle(
623 this->getType().getFieldDesc(MaxDepthFieldId
),
627 editSField(MaxDepthFieldMask
);
632 GetFieldHandlePtr
KDTreeIntersectProxyAttachmentBase::getHandleTreeNodes (void) const
634 MFIntersectKDTreeNode::GetHandlePtr
returnValue(
635 new MFIntersectKDTreeNode::GetHandle(
637 this->getType().getFieldDesc(TreeNodesFieldId
),
638 const_cast<KDTreeIntersectProxyAttachmentBase
*>(this)));
643 EditFieldHandlePtr
KDTreeIntersectProxyAttachmentBase::editHandleTreeNodes (void)
645 MFIntersectKDTreeNode::EditHandlePtr
returnValue(
646 new MFIntersectKDTreeNode::EditHandle(
648 this->getType().getFieldDesc(TreeNodesFieldId
),
652 editMField(TreeNodesFieldMask
, _mfTreeNodes
);
657 GetFieldHandlePtr
KDTreeIntersectProxyAttachmentBase::getHandleTriIndices (void) const
659 MFUInt32::GetHandlePtr
returnValue(
660 new MFUInt32::GetHandle(
662 this->getType().getFieldDesc(TriIndicesFieldId
),
663 const_cast<KDTreeIntersectProxyAttachmentBase
*>(this)));
668 EditFieldHandlePtr
KDTreeIntersectProxyAttachmentBase::editHandleTriIndices (void)
670 MFUInt32::EditHandlePtr
returnValue(
671 new MFUInt32::EditHandle(
673 this->getType().getFieldDesc(TriIndicesFieldId
),
677 editMField(TriIndicesFieldMask
, _mfTriIndices
);
683 #ifdef OSG_MT_CPTR_ASPECT
684 void KDTreeIntersectProxyAttachmentBase::execSyncV( FieldContainer
&oFrom
,
685 ConstFieldMaskArg whichField
,
686 AspectOffsetStore
&oOffsets
,
687 ConstFieldMaskArg syncMode
,
688 const UInt32 uiSyncInfo
)
690 KDTreeIntersectProxyAttachment
*pThis
= static_cast<KDTreeIntersectProxyAttachment
*>(this);
692 pThis
->execSync(static_cast<KDTreeIntersectProxyAttachment
*>(&oFrom
),
701 #ifdef OSG_MT_CPTR_ASPECT
702 FieldContainer
*KDTreeIntersectProxyAttachmentBase::createAspectCopy(
703 const FieldContainer
*pRefAspect
) const
705 KDTreeIntersectProxyAttachment
*returnValue
;
707 newAspectCopy(returnValue
,
708 dynamic_cast<const KDTreeIntersectProxyAttachment
*>(pRefAspect
),
709 dynamic_cast<const KDTreeIntersectProxyAttachment
*>(this));
715 void KDTreeIntersectProxyAttachmentBase::resolveLinks(void)
717 Inherited::resolveLinks();
719 static_cast<KDTreeIntersectProxyAttachment
*>(this)->setGeometry(NULL
);
721 #ifdef OSG_MT_CPTR_ASPECT
722 AspectOffsetStore oOffsets
;
724 _pAspectStore
->fillOffsetArray(oOffsets
, this);
727 #ifdef OSG_MT_CPTR_ASPECT
728 _mfTreeNodes
.terminateShare(Thread::getCurrentAspect(),
731 #ifdef OSG_MT_CPTR_ASPECT
732 _mfTriIndices
.terminateShare(Thread::getCurrentAspect(),