00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef _OSG_BASEFIELDDATATYPE_H_
00040 #define _OSG_BASEFIELDDATATYPE_H_
00041
00042 #include <OSGFieldDataType.h>
00043 #include <OSGTime.h>
00044 #include <OSGColor.h>
00045 #include <OSGDynamicVolume.h>
00046 #include <OSGSphereVolume.h>
00047 #include <OSGBoxVolume.h>
00048 #include <OSGPlane.h>
00049 #include <OSGGL.h>
00050
00051 #include <string>
00052
00053 OSG_BEGIN_NAMESPACE
00054
00055 #if !defined(OSG_DO_DOC) || (OSG_DOC_LEVEL >= 3)
00056
00057 #ifdef OSG_DOC_FILES_IN_MODULE
00058
00062 #endif
00063
00064
00067 #if !defined(OSG_DOC_DEV_TRAITS)
00068
00069 #endif
00070
00071 template <>
00072 struct OSG_BASE_DLLMAPPING FieldDataTraits<Color3f> :
00073 public FieldTraitsRecurseBase<Color3f>
00074 {
00075 static DataType _type;
00076
00077 enum { StringConvertable = ToStringConvertable |
00078 FromStringConvertable };
00079
00080 static DataType &getType (void) { return _type; }
00081
00082 static const Char8 *getSName (void) { return "SFColor3f"; }
00083
00084 static const Char8 *getMName (void) { return "MFColor3f"; }
00085
00086 static const Color3f getDefault (void) { return Color3f(); }
00087
00088 static bool getFromString( Color3f &outVal,
00089 const Char8 *&inVal)
00090 {
00091 outVal.setValue(inVal);
00092
00093 return true;
00094 }
00095
00096 static void putToString (const Color3f &inVal,
00097 std::string &outStr)
00098 {
00099 typedef TypeTraits<Color3f::ValueType> TypeTrait;
00100
00101 outStr.assign(TypeTrait::putToString(inVal.red() ));
00102 outStr.append(" ");
00103 outStr.append(TypeTrait::putToString(inVal.green()));
00104 outStr.append(" ");
00105 outStr.append(TypeTrait::putToString(inVal.blue() ));
00106 }
00107
00108 static UInt32 getBinSize (const Color3f &)
00109 {
00110 return sizeof(Real32) * 3;
00111 }
00112
00113 static UInt32 getBinSize (const Color3f *,
00114 UInt32 uiNumObjects)
00115 {
00116 return sizeof(Real32)* 3 * uiNumObjects;
00117 }
00118
00119 static void copyToBin ( BinaryDataHandler &pMem,
00120 const Color3f &oObject)
00121 {
00122 pMem.putValues(&oObject[0], 3);
00123 }
00124
00125 static void copyFromBin( BinaryDataHandler &pMem,
00126 Color3f &oObject)
00127 {
00128 pMem.getValues(&oObject[0], 3);
00129 }
00130
00131 static void copyToBin( BinaryDataHandler &pMem,
00132 const Color3f *pObjectStore,
00133 UInt32 uiNumObjects)
00134 {
00135 pMem.putValues(&pObjectStore[0][0], uiNumObjects*3);
00136 }
00137
00138 static void copyFromBin( BinaryDataHandler &pMem,
00139 Color3f *pObjectStore,
00140 UInt32 uiNumObjects)
00141 {
00142 pMem.getValues(&pObjectStore[0][0], uiNumObjects*3);
00143 }
00144
00145
00146 };
00147
00148 #if !defined(OSG_DOC_DEV_TRAITS)
00149
00151 #endif
00152
00155 #if !defined(OSG_DOC_DEV_TRAITS)
00156
00157 #endif
00158
00159 template <>
00160 struct OSG_BASE_DLLMAPPING FieldDataTraits<Color4f> :
00161 public FieldTraitsRecurseBase<Color4f>
00162 {
00163 static DataType _type;
00164
00165 enum { StringConvertable = ToStringConvertable |
00166 FromStringConvertable };
00167
00168 static DataType &getType (void) { return _type; }
00169
00170 static const Char8 *getSName (void) { return "SFColor4f"; }
00171
00172 static const Char8 *getMName (void) { return "MFColor4f"; }
00173
00174 static Color4f getDefault (void){ return Color4f(); }
00175
00176 static bool getFromString( Color4f &outVal,
00177 const Char8 *&inVal)
00178 {
00179 outVal.setValue(inVal);
00180
00181 return true;
00182 }
00183
00184 static void putToString (const Color4f &inVal,
00185 std::string &outStr)
00186 {
00187 typedef TypeTraits<Color4f::ValueType> TypeTrait;
00188
00189 outStr.assign(TypeTrait::putToString(inVal.red() ));
00190 outStr.append(" ");
00191 outStr.append(TypeTrait::putToString(inVal.green()));
00192 outStr.append(" ");
00193 outStr.append(TypeTrait::putToString(inVal.blue() ));
00194 outStr.append(" ");
00195 outStr.append(TypeTrait::putToString(inVal.alpha()));
00196 }
00197
00198 static UInt32 getBinSize (const Color4f &)
00199 {
00200 return sizeof(Real32) * 4;
00201 }
00202
00203 static UInt32 getBinSize (const Color4f *,
00204 UInt32 uiNumObjects)
00205 {
00206 return sizeof(Real32) * 4 * uiNumObjects;
00207 }
00208
00209 static void copyToBin ( BinaryDataHandler &pMem,
00210 const Color4f &oObject)
00211 {
00212 pMem.putValues(&oObject[0], 4);
00213 }
00214
00215
00216 static void copyFromBin( BinaryDataHandler &pMem,
00217 Color4f &oObject)
00218 {
00219 pMem.getValues(&oObject[0], 4);
00220 }
00221
00222
00223 static void copyToBin( BinaryDataHandler &pMem,
00224 const Color4f *pObjectStore,
00225 UInt32 uiNumObjects)
00226 {
00227 pMem.putValues(&pObjectStore[0][0], uiNumObjects*4);
00228 }
00229
00230 static void copyFromBin( BinaryDataHandler &pMem,
00231 Color4f *pObjectStore,
00232 UInt32 uiNumObjects)
00233 {
00234 pMem.getValues(&pObjectStore[0][0], uiNumObjects*4);
00235 }
00236
00237
00238
00239 };
00240
00241 #if !defined(OSG_DOC_DEV_TRAITS)
00242
00244 #endif
00245
00248 #if !defined(OSG_DOC_DEV_TRAITS)
00249
00250 #endif
00251
00252 template <>
00253 struct OSG_BASE_DLLMAPPING FieldDataTraits<Color3ub> :
00254 public FieldTraitsRecurseBase<Color3ub>
00255 {
00256 static DataType _type;
00257
00258 enum { StringConvertable = ToStringConvertable |
00259 FromStringConvertable };
00260
00261 static DataType &getType (void) { return _type; }
00262
00263 static const Char8 *getSName (void) { return "SFColor3ub"; }
00264 static const Char8 *getMName (void) { return "MFColor3ub"; }
00265
00266 static Color3ub getDefault (void) { return Color3ub(); }
00267
00268 static bool getFromString( Color3ub &outVal,
00269 const Char8 *&inVal)
00270 {
00271 outVal.setValue(inVal);
00272
00273 return true;
00274 }
00275
00276 static void putToString (const Color3ub &inVal,
00277 std::string &outStr)
00278 {
00279 typedef TypeTraits<Color3ub::ValueType> TypeTrait;
00280
00281 outStr.assign(TypeTrait::putToString(inVal.red() ));
00282 outStr.append(" ");
00283 outStr.append(TypeTrait::putToString(inVal.green()));
00284 outStr.append(" ");
00285 outStr.append(TypeTrait::putToString(inVal.blue() ));
00286 }
00287
00288 static UInt32 getBinSize (const Color3ub &)
00289 {
00290 return sizeof(UInt8) * 3;
00291 }
00292
00293 static UInt32 getBinSize (const Color3ub *,
00294 UInt32 uiNumObjects)
00295 {
00296 return sizeof(UInt8)* 3 * uiNumObjects;
00297 }
00298
00299 static void copyToBin ( BinaryDataHandler &pMem,
00300 const Color3ub &oObject)
00301 {
00302 pMem.putValues(&oObject[0], 3);
00303 }
00304
00305
00306 static void copyFromBin( BinaryDataHandler &pMem,
00307 Color3ub &oObject)
00308 {
00309 pMem.getValues(&oObject[0], 3);
00310 }
00311
00312 static void copyToBin( BinaryDataHandler &pMem,
00313 const Color3ub *pObjectStore,
00314 UInt32 uiNumObjects)
00315 {
00316 pMem.putValues(&pObjectStore[0][0], uiNumObjects*3);
00317 }
00318
00319 static void copyFromBin( BinaryDataHandler &pMem,
00320 Color3ub *pObjectStore,
00321 UInt32 uiNumObjects)
00322 {
00323 pMem.getValues(&pObjectStore[0][0], uiNumObjects*3);
00324 }
00325 };
00326
00327 #if !defined(OSG_DOC_DEV_TRAITS)
00328
00330 #endif
00331
00334 #if !defined(OSG_DOC_DEV_TRAITS)
00335
00336 #endif
00337
00338 template <>
00339 struct OSG_BASE_DLLMAPPING FieldDataTraits<Color4ub> :
00340 public FieldTraitsRecurseBase<Color4ub>
00341 {
00342 static DataType _type;
00343
00344 enum { StringConvertable = ToStringConvertable |
00345 FromStringConvertable };
00346
00347 static DataType &getType (void) { return _type; }
00348
00349 static const Char8 *getSName (void) { return "SFColor4ub"; }
00350
00351 static const Char8 *getMName (void) { return "MFColor4ub"; }
00352
00353 static Color4ub getDefault (void) { return Color4ub(); }
00354
00355 static bool getFromString( Color4ub &outVal,
00356 const Char8 *&inVal)
00357 {
00358 outVal.setValue(inVal);
00359
00360 return true;
00361 }
00362
00363 static void putToString (const Color4ub &inVal,
00364 std::string &outStr)
00365 {
00366 typedef TypeTraits<Color4ub::ValueType> TypeTrait;
00367
00368 outStr.assign(TypeTrait::putToString(inVal.red() ));
00369 outStr.append(" ");
00370 outStr.append(TypeTrait::putToString(inVal.green()));
00371 outStr.append(" ");
00372 outStr.append(TypeTrait::putToString(inVal.blue() ));
00373 outStr.append(" ");
00374 outStr.append(TypeTrait::putToString(inVal.alpha()));
00375 }
00376
00377 static UInt32 getBinSize (const Color4ub &)
00378 {
00379 return sizeof(UInt8) * 4;
00380 }
00381
00382 static UInt32 getBinSize (const Color4ub *,
00383 UInt32 uiNumObjects)
00384 {
00385 return sizeof(UInt8) * 4 * uiNumObjects;
00386 }
00387
00388 static void copyToBin ( BinaryDataHandler &pMem,
00389 const Color4ub &oObject)
00390 {
00391 pMem.putValues(&oObject[0], 4);
00392 }
00393
00394
00395 static void copyFromBin( BinaryDataHandler &pMem,
00396 Color4ub &oObject)
00397 {
00398 pMem.getValues(&oObject[0], 4);
00399 }
00400
00401
00402 static void copyToBin( BinaryDataHandler &pMem,
00403 const Color4ub *pObjectStore,
00404 UInt32 uiNumObjects)
00405 {
00406 pMem.putValues(&pObjectStore[0][0], uiNumObjects*4);
00407 }
00408
00409 static void copyFromBin( BinaryDataHandler &pMem,
00410 Color4ub *pObjectStore,
00411 UInt32 uiNumObjects)
00412 {
00413 pMem.getValues(&pObjectStore[0][0], uiNumObjects*4);
00414 }
00415
00416
00417
00418
00419 };
00420
00421 #if !defined(OSG_DOC_DEV_TRAITS)
00422
00424 #endif
00425
00428 #if !defined(OSG_DOC_DEV_TRAITS)
00429
00430 #endif
00431
00432 template <>
00433 struct OSG_BASE_DLLMAPPING FieldDataTraits<std::string> :
00434 public FieldTraitsRecurseBase<std::string>
00435 {
00436 static DataType _type;
00437
00438 enum { StringConvertable = ToStringConvertable |
00439 FromStringConvertable };
00440
00441 static DataType &getType (void) { return _type; }
00442
00443 static const Char8 *getSName (void) { return "SFString"; }
00444
00445 static const Char8 *getMName (void) { return "MFString"; }
00446
00447 static std::string getDefault (void) { return std::string(); }
00448
00449 static bool getFromString( std::string &target,
00450 const Char8 *&source)
00451 {
00452 target.assign(source);
00453
00454 if(source != NULL)
00455 {
00456 source += strlen(source);
00457 }
00458
00459 return true;
00460 }
00461
00462 static void putToString(const std::string &inVal,
00463 std::string &outStr)
00464 {
00465 outStr.assign("\"");
00466 outStr.append(inVal);
00467 outStr.append("\"");
00468 }
00469
00470
00471 static UInt32 getBinSize (const std::string &oObject)
00472 {
00473 return oObject.length() + 1 + sizeof(UInt32);
00474 }
00475
00476 static UInt32 getBinSize (const std::string *pObjectStore,
00477 UInt32 uiNumObjects)
00478 {
00479 UInt32 size=0;
00480
00481 for(UInt32 i = 0; i < uiNumObjects; ++i)
00482 {
00483 size += getBinSize(pObjectStore[i]);
00484 }
00485
00486 return size;
00487 }
00488
00489
00490 static void copyToBin( BinaryDataHandler &pMem,
00491 const std::string &oObject)
00492 {
00493 pMem.putValue(oObject);
00494 }
00495
00496 static void copyToBin( BinaryDataHandler &pMem,
00497 const std::string *pObjectStore,
00498 UInt32 uiNumObjects)
00499 {
00500 for(UInt32 i=0; i < uiNumObjects; ++i)
00501 {
00502 copyToBin(pMem, pObjectStore[i]);
00503 }
00504 }
00505
00506 static void copyFromBin( BinaryDataHandler &pMem,
00507 std::string &oObject)
00508 {
00509 pMem.getValue(oObject);
00510 }
00511
00512 static void copyFromBin( BinaryDataHandler &pMem,
00513 std::string *pObjectStore,
00514 UInt32 uiNumObjects)
00515 {
00516 for(UInt32 i = 0; i < uiNumObjects; ++i)
00517 {
00518 copyFromBin(pMem, pObjectStore[i]);
00519 }
00520 }
00521 };
00522
00523 #if !defined(OSG_DOC_DEV_TRAITS)
00524
00526 #endif
00527
00530 #if !defined(OSG_DOC_DEV_TRAITS)
00531
00532 #endif
00533
00534 template <>
00535 struct OSG_BASE_DLLMAPPING FieldDataTraits1<Time> :
00536 public FieldTraitsRecurseBase<Time>
00537 {
00538 static DataType _type;
00539
00540 enum { StringConvertable = ToStringConvertable |
00541 FromStringConvertable };
00542
00543 static DataType &getType (void) { return _type; }
00544
00545 static const Char8 *getSName (void) { return "SFTime"; }
00546
00547 static const Char8 *getMName (void) { return "MFTime"; }
00548
00549 static Time getDefault (void) { return Time(); }
00550
00551 static bool getFromString( Time &outVal,
00552 const Char8 *&inVal)
00553 {
00554 outVal = TypeTraits<Time>::getFromString(inVal);
00555
00556 return true;
00557 }
00558
00559 static void putToString(const Time &inVal,
00560 std::string &outStr)
00561 {
00562 outStr.assign(TypeTraits<Time>::putToString(inVal));
00563 }
00564
00565 static UInt32 getBinSize (const Time &)
00566 {
00567 return sizeof(Time);
00568 }
00569
00570 static UInt32 getBinSize (const Time *,
00571 UInt32 uiNumObjects)
00572 {
00573 return sizeof(Time)*uiNumObjects;
00574 }
00575
00576 static void copyToBin( BinaryDataHandler &pMem,
00577 const Time &oObject)
00578 {
00579 pMem.putValue(oObject);
00580 }
00581
00582 static void copyFromBin(BinaryDataHandler &pMem,
00583 Time &oObject)
00584 {
00585 pMem.getValue(oObject);
00586 }
00587
00588 static void copyToBin( BinaryDataHandler &pMem,
00589 const Time *pObjectStore,
00590 UInt32 uiNumObjects)
00591 {
00592 pMem.putValues(&pObjectStore[0], uiNumObjects);
00593 }
00594
00595 static void copyFromBin( BinaryDataHandler &pMem,
00596 Time *pObjectStore,
00597 UInt32 uiNumObjects)
00598 {
00599 pMem.getValues(&pObjectStore[0], uiNumObjects);
00600 }
00601 };
00602
00603 #if !defined(OSG_DOC_DEV_TRAITS)
00604
00606 #endif
00607
00610 #if !defined(OSG_DOC_DEV_TRAITS)
00611
00612 #endif
00613
00614 template <>
00615 struct OSG_BASE_DLLMAPPING FieldDataTraits<DynamicVolume> :
00616 public FieldTraitsRecurseBase<DynamicVolume>
00617 {
00618 static DataType _type;
00619
00620 enum { StringConvertable = ToStringConvertable |
00621 FromStringConvertable };
00622
00623 static DataType &getType (void) { return _type; }
00624
00625 static const Char8 *getSName (void) { return "SFDynamicVolume"; }
00626
00627 static const Char8 *getMName (void) { return "MFDynamicVolume"; }
00628
00629 static const DynamicVolume getDefault (void) { return DynamicVolume(); }
00630
00631 static bool getFromString( DynamicVolume &outVal,
00632 const Char8 *&inVal)
00633 {
00634 Real32 valStore[ 6];
00635 Char8 str [256];
00636
00637 UInt32 length = strlen(inVal);
00638 Char8 *c = str;
00639
00640 if(length > 256)
00641 {
00642 std::cerr << "FieldDataTraits<DynamicVolume>::getFromString(): "
00643 << "Input too long" << std::endl;
00644
00645 return false;
00646 }
00647
00648 strncpy(str, inVal, length);
00649
00650 while(*c != '\0')
00651 {
00652 if(*c == '[')
00653 *c = ' ';
00654 if(*c == ']')
00655 *c = ' ';
00656 if(*c == ',')
00657 *c = ' ';
00658
00659 c++;
00660 }
00661
00662 Int16 count = sscanf(str, "%f %f %f %f %f %f",
00663 &valStore[0], &valStore[1], &valStore[2],
00664 &valStore[3], &valStore[4], &valStore[5]);
00665
00666 if(count == 4)
00667 {
00668 outVal.setVolumeType(DynamicVolume::SPHERE_VOLUME);
00669
00670 SphereVolume *pSVol =
00671 dynamic_cast<SphereVolume *>(&(outVal.getInstance()));
00672
00673 pSVol->setCenter(Pnt3f(valStore[0], valStore[1], valStore[2]));
00674 pSVol->setRadius(valStore[3]);
00675
00676 outVal.instanceChanged();
00677
00678 return true;
00679 }
00680 else if(count == 6)
00681 {
00682 outVal.setVolumeType(DynamicVolume::BOX_VOLUME);
00683
00684 BoxVolume *pBVol =
00685 dynamic_cast<BoxVolume *>(&(outVal.getInstance()));
00686
00687 pBVol->setBounds(valStore[0], valStore[1], valStore[2],
00688 valStore[3], valStore[4], valStore[5]);
00689
00690 outVal.instanceChanged();
00691
00692 return true;
00693 }
00694 else
00695 {
00696 outVal.setVolumeType(DynamicVolume::BOX_VOLUME);
00697
00698 BoxVolume *pBVol =
00699 dynamic_cast<BoxVolume *>(&(outVal.getInstance()));
00700
00701 pBVol->setBounds(0.,0.,0., 0.,0.,0.);
00702
00703 outVal.instanceChanged();
00704
00705 return false;
00706 }
00707 }
00708
00709 static void putToString(const DynamicVolume &inVal,
00710 std::string &outStr)
00711 {
00712 Pnt3f min, max;
00713 outStr.erase();
00714
00715 switch(inVal.getType())
00716 {
00717
00718 case DynamicVolume::BOX_VOLUME:
00719
00720 typedef TypeTraits<Pnt3f::ValueType> TypeTrait;
00721
00722 inVal.getBounds(min, max);
00723 outStr.append(TypeTrait::putToString(min.getValues()[0]));
00724 outStr.append(" ");
00725 outStr.append(TypeTrait::putToString(min.getValues()[1]));
00726 outStr.append(" ");
00727 outStr.append(TypeTrait::putToString(min.getValues()[2]));
00728 outStr.append(" ");
00729 outStr.append(TypeTrait::putToString(max.getValues()[0]));
00730 outStr.append(" ");
00731 outStr.append(TypeTrait::putToString(max.getValues()[1]));
00732 outStr.append(" ");
00733 outStr.append(TypeTrait::putToString(max.getValues()[2]));
00734 break;
00735
00736
00737 case DynamicVolume::SPHERE_VOLUME:
00738
00739 typedef TypeTraits<Pnt3f::ValueType> TypeTrait;
00740
00741 const SphereVolume &sVol =
00742 dynamic_cast<const SphereVolume&>(inVal.getInstance());
00743
00744 outStr.append(TypeTrait::putToString(sVol.getCenter()[0]));
00745 outStr.append(" ");
00746 outStr.append(TypeTrait::putToString(sVol.getCenter()[1]));
00747 outStr.append(" ");
00748 outStr.append(TypeTrait::putToString(sVol.getCenter()[1]));
00749 outStr.append(" ");
00750 outStr.append(TypeTraits<
00751 Real32>::putToString(sVol.getRadius()));
00752 break;
00753 }
00754 }
00755
00756 static UInt32 getBinSize(const DynamicVolume &oObject)
00757 {
00758 UInt32 type = oObject.getType();
00759 UInt32 size = sizeof(DynamicVolume::Type) + sizeof(UInt16);
00760
00761 switch(type)
00762 {
00763 case DynamicVolume::BOX_VOLUME :
00764 size += sizeof(Pnt3f) + sizeof(Pnt3f);
00765 break;
00766
00767 case DynamicVolume::SPHERE_VOLUME :
00768 size += sizeof(Pnt3f) + sizeof(Real32);
00769 break;
00770
00771 default :
00772 SWARNING << "Unknown volume type in getBinSize" << std::endl;
00773 }
00774
00775 return size;
00776 }
00777
00778 static UInt32 getBinSize(const DynamicVolume *pObjectStore,
00779 UInt32 uiNumObjects)
00780 {
00781 UInt32 size = 0;
00782
00783 for(UInt32 i = 0; i < uiNumObjects; ++i)
00784 {
00785 size += getBinSize(pObjectStore[i]);
00786 }
00787
00788 return size;
00789 }
00790
00791 static void copyToBin( BinaryDataHandler &pMem,
00792 const DynamicVolume &oObject)
00793 {
00794 UInt32 type = (UInt32)(oObject.getType());
00795
00796 pMem.putValue(type);
00797
00798 switch(type)
00799 {
00800 case DynamicVolume::BOX_VOLUME :
00801 {
00802 const BoxVolume *pBVol =
00803 dynamic_cast<const BoxVolume *>(
00804 &(oObject.getInstance()));
00805
00806 UInt16 state = pBVol->getState();
00807
00808 pMem.putValue(state);
00809
00810 pMem.putValues(&(pBVol->getMin()[0]), 3);
00811 pMem.putValues(&(pBVol->getMax()[0]), 3);
00812
00813 break;
00814 }
00815 case DynamicVolume::SPHERE_VOLUME :
00816 {
00817 const SphereVolume *pSVol =
00818 dynamic_cast<const SphereVolume *>(
00819 &(oObject.getInstance()));
00820
00821 Real32 radius = pSVol->getRadius();
00822
00823 UInt16 state = pSVol->getState();
00824
00825 pMem.putValue(state);
00826
00827 pMem.putValues(&(pSVol->getCenter()[0]), 3);
00828 pMem.putValue (radius);
00829
00830 break;
00831 }
00832
00833 default:
00834 SWARNING << "Unknown volume type in copyToBin" << std::endl;
00835 }
00836 }
00837
00838 static void copyToBin( BinaryDataHandler &pMem,
00839 const DynamicVolume *pObjectStore,
00840 UInt32 uiNumObjects)
00841 {
00842 for(UInt32 i = 0; i < uiNumObjects; ++i)
00843 {
00844 copyToBin(pMem, pObjectStore[i]);
00845 }
00846 }
00847
00848 static void copyFromBin(BinaryDataHandler &pMem,
00849 DynamicVolume &oObject)
00850 {
00851 UInt32 type;
00852
00853 pMem.getValue(type);
00854 DynamicVolume::Type volumeType=
00855 static_cast<DynamicVolume::Type>(type);
00856 oObject.setVolumeType(volumeType);
00857
00858 switch(type)
00859 {
00860 case DynamicVolume::BOX_VOLUME :
00861 {
00862 BoxVolume *pBVol =
00863 dynamic_cast<BoxVolume *>(&(oObject.getInstance()));
00864
00865 Pnt3f min,max;
00866 UInt16 state;
00867
00868 pMem.getValue (state );
00869 pMem.getValues(&(min[0]), 3);
00870 pMem.getValues(&(max[0]), 3);
00871
00872 pBVol->setState (state );
00873 pBVol->setBounds(min, max);
00874
00875 break;
00876 }
00877 case DynamicVolume::SPHERE_VOLUME :
00878 {
00879 SphereVolume *pSVol =
00880 dynamic_cast<SphereVolume *>(&(oObject.getInstance()));
00881
00882 Pnt3f center;
00883 Real32 radius;
00884 UInt16 state;
00885
00886 pMem.getValue(state);
00887 pMem.getValues(&(center[0]), 3);
00888 pMem.getValue (radius);
00889
00890 pSVol->setState (state );
00891 pSVol->setCenter(center);
00892 pSVol->setRadius(radius);
00893
00894 break;
00895 }
00896
00897 default:
00898 SWARNING << "Unknown volume type in copyFronBin" << std::endl;
00899 }
00900 }
00901
00902 static void copyFromBin(BinaryDataHandler &pMem,
00903 DynamicVolume *pObjectStore,
00904 UInt32 uiNumObjects)
00905 {
00906 for(UInt32 i = 0; i < uiNumObjects; ++i)
00907 {
00908 copyFromBin(pMem, pObjectStore[i]);
00909 }
00910 }
00911 };
00912
00913 #if !defined(OSG_DOC_DEV_TRAITS)
00914
00916 #endif
00917
00920 #if !defined(OSG_DOC_DEV_TRAITS)
00921
00922 #endif
00923
00924 template <>
00925 struct OSG_BASE_DLLMAPPING FieldDataTraits1<BitVector> :
00926 public FieldTraitsRecurseBase<BitVector>
00927 {
00928 static DataType _type;
00929
00930 enum { StringConvertable = 0x00 };
00931
00932 static DataType &getType (void) { return _type; }
00933
00934 static const Char8 *getSName(void) { return "SFBitVector"; }
00935
00936 static const Char8 *getMName(void) { return "MFBitVector"; }
00937
00938 static BitVector getDefault(void) { return BitVector(); }
00939
00940 static UInt32 getBinSize(const BitVector &)
00941 {
00942 return sizeof(BitVector);
00943 }
00944
00945 static UInt32 getBinSize (const BitVector *,
00946 UInt32 uiNumObjects)
00947 {
00948 return sizeof(BitVector)*uiNumObjects;
00949 }
00950
00951 static void copyToBin ( BinaryDataHandler &pMem,
00952 const BitVector &oObject)
00953 {
00954 BitVector value=oObject;
00955 pMem.putValue(value);
00956 }
00957
00958 static void copyToBin( BinaryDataHandler &pMem,
00959 const BitVector *pObjectStore,
00960 UInt32 uiNumObjects)
00961 {
00962 for(UInt32 i = 0; i < uiNumObjects; ++i)
00963 {
00964 copyToBin(pMem, pObjectStore[i]);
00965 }
00966 }
00967
00968 static void copyFromBin( BinaryDataHandler &pMem,
00969 BitVector &oObject)
00970 {
00971 BitVector value;
00972 pMem.getValue(value);
00973 oObject=value;
00974 }
00975
00976 static void copyFromBin(BinaryDataHandler &pMem,
00977 BitVector *pObjectStore,
00978 UInt32 uiNumObjects)
00979 {
00980 for(UInt32 i = 0; i < uiNumObjects; ++i)
00981 {
00982 copyFromBin(pMem, pObjectStore[i]);
00983 }
00984 }
00985
00986 };
00987
00988 #if !defined(OSG_DOC_DEV_TRAITS)
00989
00991 #endif
00992
00995 #if !defined(OSG_DOC_DEV_TRAITS)
00996
00997 #endif
00998
00999 template <>
01000 struct OSG_BASE_DLLMAPPING FieldDataTraits1<GLenum> :
01001 public FieldTraitsRecurseBase<GLenum>
01002 {
01003 static DataType _type;
01004 typedef FieldDataTraits1<GLenum> Self;
01005
01006 enum { StringConvertable = Self::ToStringConvertable |
01007 Self::FromStringConvertable };
01008
01009 static DataType &getType (void) { return _type; }
01010
01011 static Char8 *getSName (void) { return "SFGLenum"; }
01012 static Char8 *getMName (void) { return "MFGLenum"; }
01013
01014 static GLenum getDefault (void) { return 0; }
01015
01016 static bool getFromString( GLenum &outVal,
01017 const Char8 *&inVal)
01018 {
01019 outVal = TypeTraits<GLenum>::getFromString(inVal);
01020
01021 return false;
01022 }
01023
01024 static void putToString (const GLenum &inVal,
01025 std::string &outStr)
01026 {
01027 outStr.assign(TypeTraits<GLenum>::putToString(inVal));
01028 }
01029
01030 static UInt32 getBinSize (const GLenum &)
01031 {
01032 return sizeof(UInt32);
01033 }
01034
01035 static UInt32 getBinSize (const GLenum *,
01036 UInt32 uiNumObjects)
01037 {
01038 return sizeof(UInt32)*uiNumObjects;
01039 }
01040
01041 static void copyToBin ( BinaryDataHandler &pMem,
01042 const GLenum &oObject)
01043 {
01044 pMem.putValue ((UInt32)oObject);
01045 }
01046
01047 static void copyToBin( BinaryDataHandler &pMem,
01048 const GLenum *pObjectStore,
01049 UInt32 uiNumObjects)
01050 {
01051 for(UInt32 i = 0; i < uiNumObjects; ++i)
01052 {
01053 copyToBin(pMem, pObjectStore[i]);
01054 }
01055 }
01056
01057 static void copyFromBin( BinaryDataHandler &pMem,
01058 GLenum &oObject)
01059 {
01060 UInt32 val;
01061 pMem.getValue (val);
01062 oObject = val;
01063 }
01064
01065 static void copyFromBin(BinaryDataHandler &pMem,
01066 GLenum *pObjectStore,
01067 UInt32 uiNumObjects)
01068 {
01069 for(UInt32 i = 0; i < uiNumObjects; ++i)
01070 {
01071 copyFromBin(pMem, pObjectStore[i]);
01072 }
01073 }
01074 };
01075
01076 #if !defined(OSG_DOC_DEV_TRAITS)
01077
01079 #endif
01080
01083 #if !defined(OSG_DOC_DEV_TRAITS)
01084
01085 #endif
01086
01087 template <>
01088 struct OSG_BASE_DLLMAPPING FieldDataTraits<Plane> :
01089 public FieldTraitsRecurseBase<Plane>
01090 {
01091 static DataType _type;
01092
01093 enum { StringConvertable = ToStringConvertable |
01094 FromStringConvertable };
01095
01096 static DataType &getType (void) { return _type; }
01097
01098 static const Char8 *getSName (void) { return "SFPlane"; }
01099
01