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
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057 #ifndef _VTKVRML_H_
00058 #define _VTKVRML_H_
00059
00060 #define DEFAULTINCREMENT 100
00061
00062 template <class T>
00063 class VectorType
00064 {
00065 protected:
00066 T *Data;
00067 int Allocated;
00068 int Used;
00069 public:
00070 VectorType()
00071 { \
00072 Allocated=DEFAULTINCREMENT;
00073 Data=new T[Allocated];
00074 Used=0;
00075 }
00076 ~VectorType(void)
00077 {
00078 delete[] Data;
00079 }
00080 void Reserve(int newSize);
00081 void Demand(int newSize)
00082 {
00083 Reserve(newSize);
00084 Used=newSize;
00085 }
00086 int Count(void) const
00087 {
00088 return Used;
00089 }
00090 T& Get(int index) const
00091 {
00092 if (index > Used)
00093 return Data[Used-1];
00094 return Data[index];
00095 }
00096 T& operator[](int index)
00097 {
00098 if (index > Used)
00099 Demand(index);
00100 return Data[index];
00101 }
00102 operator T*() const
00103 {
00104 return Data;
00105 }
00106 VectorType<T>& operator+=(T datum)
00107 {
00108 Reserve(Used+1);
00109 Data[Used]=datum;
00110 Used++;
00111 return *this;
00112 }
00113 void Push(T datum)
00114 {
00115 Reserve(Used+1);
00116 Data[Used]=datum;
00117 Used++;
00118 }
00119 T& Pop()
00120 {
00121 Used--;
00122 return Data[Used];
00123 }
00124 T& Top()
00125 {
00126 return Data[Used-1];
00127 }
00128 };
00129
00130 template <class T>
00131 void VectorType<T>::Reserve(int newSize)
00132 {
00133 T *temp;
00134 int oldSize;
00135 if(newSize >= Allocated)
00136 {
00137 oldSize=Allocated;
00138 Allocated=newSize+DEFAULTINCREMENT;
00139 temp=Data;
00140 Data=new T[Allocated];
00141 if(Data==(T *)'\0')
00142 {
00143 return;
00144 }
00145 memcpy((void*)Data, (void*)temp, oldSize*sizeof(T));
00146 delete[] temp;
00147 }
00148 }
00149
00150 static const char standardNodes[][2042] = {
00151 "#VRML V2.0 utf8 \n\
00152 # \n\
00153 # ************************************************** \n\
00154 # * VRML 2.0 Parser \n\
00155 # * Copyright (C) 1996 Silicon Graphics, Inc. \n\
00156 # * \n\
00157 # * Author(s) : Gavin Bell \n\
00158 # * Daniel Woods (first port) \n\
00159 # ************************************************** \n\
00160 # \n\
00161 # Definitions for all of the nodes built-in to the spec. \n\
00162 # Taken almost directly from the VRML 2.0 final spec: \n\
00163 \n\
00164 PROTO Anchor [ \n\
00165 eventIn MFNode addChildren \n\
00166 eventIn MFNode removeChildren \n\
00167 exposedField MFNode children [] \n\
00168 exposedField SFString description \"\" \n\
00169 exposedField MFString parameter [] \n\
00170 exposedField MFString url [] \n\
00171 field SFVec3f bboxCenter 0.0 0.0 0.0 \n\
00172 field SFVec3f bboxSize -1.0 -1.0 -1.0 \n\
00173 ] { } \n\
00174 \n\
00175 PROTO Appearance [ \n\
00176 exposedField SFNode material NULL \n\
00177 exposedField SFNode texture NULL \n\
00178 exposedField SFNode textureTransform NULL \n\
00179 ] { } \n\
00180 \n\
00181 PROTO AudioClip [ \n\
00182 exposedField SFString description \"\" \n\
00183 exposedField SFBool loop FALSE \n\
00184 exposedField SFFloat pitch 1.0 \n\
00185 exposedField SFTime startTime 0 \n\
00186 exposedField SFTime stopTime 0 \n\
00187 exposedField MFString url [] \n\
00188 eventOut SFTime duration_changed \n\
00189 eventOut SFBool isActive \n\
00190 ] { } \n\
00191 \n\
00192 PROTO Background [ \n\
00193 eventIn SFBool set_bind \n\
00194 exposedField MFFloat groundAngle [] \n\
00195 exposedField MFColor groundColor [] \n\
00196 exposedField MFString backUrl [] \n\
00197 exposedField MFString bottomUrl [] \n\
00198 exposedField MFString frontUrl [] \n\
00199 exposedField MFString leftUrl [] \n\
00200 exposedField MFString rightUrl [] \n\
00201 exposedField MFString topUrl [] \n\
00202 exposedField MFFloat skyAngle [] \n\
00203 exposedField MFColor skyColor [ 0 0 0 ] \n\
00204 eventOut SFBool isBound \n\
00205 ] { }",
00206 "PROTO Billboard [ \n\
00207 eventIn MFNode addChildren \n\
00208 eventIn MFNode removeChildren \n\
00209 exposedField SFVec3f axisOfRotation 0 1 0 \n\
00210 exposedField MFNode children [] \n\
00211 field SFVec3f bboxCenter 0 0 0 \n\
00212 field SFVec3f bboxSize -1 -1 -1 \n\
00213 ] { } \n\
00214 \n\
00215 PROTO Box [ \n\
00216 field SFVec3f size 2 2 2 \n\
00217 ] { } \n\
00218 \n\
00219 PROTO Collision [ \n\
00220 eventIn MFNode addChildren \n\
00221 eventIn MFNode removeChildren \n\
00222 exposedField MFNode children [] \n\
00223 exposedField SFBool collide TRUE \n\
00224 field SFVec3f bboxCenter 0 0 0 \n\
00225 field SFVec3f bboxSize -1 -1 -1 \n\
00226 field SFNode proxy NULL \n\
00227 eventOut SFTime collideTime \n\
00228 ] { } \n\
00229 \n\
00230 PROTO Color [ \n\
00231 exposedField MFColor color [] \n\
00232 ] { } \n\
00233 \n\
00234 PROTO ColorInterpolator [ \n\
00235 eventIn SFFloat set_fraction \n\
00236 exposedField MFFloat key [] \n\
00237 exposedField MFColor keyValue [] \n\
00238 eventOut SFColor value_changed \n\
00239 ] { } \n\
00240 \n\
00241 PROTO Cone [ \n\
00242 field SFFloat bottomRadius 1 \n\
00243 field SFFloat height 2 \n\
00244 field SFBool side TRUE \n\
00245 field SFBool bottom TRUE \n\
00246 ] { } \n\
00247 \n\
00248 PROTO Coordinate [ \n\
00249 exposedField MFVec3f point [] \n\
00250 ] { } \n\
00251 \n\
00252 PROTO CoordinateInterpolator [ \n\
00253 eventIn SFFloat set_fraction \n\
00254 exposedField MFFloat key [] \n\
00255 exposedField MFVec3f keyValue [] \n\
00256 eventOut MFVec3f value_changed \n\
00257 ] { } \n\
00258 \n\
00259 PROTO Cylinder [ \n\
00260 field SFBool bottom TRUE \n\
00261 field SFFloat height 2 \n\
00262 field SFFloat radius 1 \n\
00263 field SFBool side TRUE \n\
00264 field SFBool top TRUE \n\
00265 ] { } \n\
00266 \n\
00267 PROTO CylinderSensor [ \n\
00268 exposedField SFBool autoOffset TRUE \n\
00269 exposedField SFFloat diskAngle 0.262 \n\
00270 exposedField SFBool enabled TRUE \n\
00271 exposedField SFFloat maxAngle -1 \n\
00272 exposedField SFFloat minAngle 0 \n\
00273 exposedField SFFloat offset 0 \n\
00274 eventOut SFBool isActive \n\
00275 eventOut SFRotation rotation_changed \n\
00276 eventOut SFVec3f trackPoint_changed \n\
00277 ] { }",
00278 "PROTO DirectionalLight [ \n\
00279 exposedField SFFloat ambientIntensity 0 \n\
00280 exposedField SFColor color 1 1 1 \n\
00281 exposedField SFVec3f direction 0 0 -1 \n\
00282 exposedField SFFloat intensity 1 \n\
00283 exposedField SFBool on TRUE \n\
00284 ] { } \n\
00285 \n\
00286 PROTO ElevationGrid [ \n\
00287 eventIn MFFloat set_height \n\
00288 exposedField SFNode color NULL \n\
00289 exposedField SFNode normal NULL \n\
00290 exposedField SFNode texCoord NULL \n\
00291 field SFBool ccw TRUE \n\
00292 field SFBool colorPerVertex TRUE \n\
00293 field SFFloat creaseAngle 0 \n\
00294 field MFFloat height [] \n\
00295 field SFBool normalPerVertex TRUE \n\
00296 field SFBool solid TRUE \n\
00297 field SFInt32 xDimension 0 \n\
00298 field SFFloat xSpacing 0.0 \n\
00299 field SFInt32 zDimension 0 \n\
00300 field SFFloat zSpacing 0.0 \n\
00301 \n\
00302 ] { } \n\
00303 \n\
00304 PROTO Extrusion [ \n\
00305 eventIn MFVec2f set_crossSection \n\
00306 eventIn MFRotation set_orientation \n\
00307 eventIn MFVec2f set_scale \n\
00308 eventIn MFVec3f set_spine \n\
00309 field SFBool beginCap TRUE \n\
00310 field SFBool ccw TRUE \n\
00311 field SFBool convex TRUE \n\
00312 field SFFloat creaseAngle 0 \n\
00313 field MFVec2f crossSection [ 1 1, 1 -1, -1 -1, -1 1, 1 1 ] \n\
00314 field SFBool endCap TRUE \n\
00315 field MFRotation orientation 0 0 1 0 \n\
00316 field MFVec2f scale 1 1 \n\
00317 field SFBool solid TRUE \n\
00318 field MFVec3f spine [ 0 0 0, 0 1 0 ] \n\
00319 ] { } \n\
00320 \n\
00321 PROTO Fog [ \n\
00322 exposedField SFColor color 1 1 1 \n\
00323 exposedField SFString fogType \"LINEAR\" \n\
00324 exposedField SFFloat visibilityRange 0 \n\
00325 eventIn SFBool set_bind \n\
00326 eventOut SFBool isBound \n\
00327 ] { }",
00328 "PROTO FontStyle [ \n\
00329 field SFString family \"SERIF\" \n\
00330 field SFBool horizontal TRUE \n\
00331 field MFString justify \"BEGIN\" \n\
00332 field SFString language \"\" \n\
00333 field SFBool leftToRight TRUE \n\
00334 field SFFloat size 1.0 \n\
00335 field SFFloat spacing 1.0 \n\
00336 field SFString style \"PLAIN\" \n\
00337 field SFBool topToBottom TRUE \n\
00338 ] { } \n\
00339 \n\
00340 PROTO Group [ \n\
00341 eventIn MFNode addChildren \n\
00342 eventIn MFNode removeChildren \n\
00343 exposedField MFNode children [] \n\
00344 field SFVec3f bboxCenter 0 0 0 \n\
00345 field SFVec3f bboxSize -1 -1 -1 \n\
00346 ] { } \n\
00347 \n\
00348 PROTO ImageTexture [ \n\
00349 exposedField MFString url [] \n\
00350 field SFBool repeatS TRUE \n\
00351 field SFBool repeatT TRUE \n\
00352 ] { } \n\
00353 \n\
00354 PROTO IndexedFaceSet [ \n\
00355 eventIn MFInt32 set_colorIndex \n\
00356 eventIn MFInt32 set_coordIndex \n\
00357 eventIn MFInt32 set_normalIndex \n\
00358 eventIn MFInt32 set_texCoordIndex \n\
00359 exposedField SFNode color NULL \n\
00360 exposedField SFNode coord NULL \n\
00361 exposedField SFNode normal NULL \n\
00362 exposedField SFNode texCoord NULL \n\
00363 field SFBool ccw TRUE \n\
00364 field MFInt32 colorIndex [] \n\
00365 field SFBool colorPerVertex TRUE \n\
00366 field SFBool convex TRUE \n\
00367 field MFInt32 coordIndex [] \n\
00368 field SFFloat creaseAngle 0 \n\
00369 field MFInt32 normalIndex [] \n\
00370 field SFBool normalPerVertex TRUE \n\
00371 field SFBool solid TRUE \n\
00372 field MFInt32 texCoordIndex [] \n\
00373 ] { } \n\
00374 \n\
00375 PROTO IndexedLineSet [ \n\
00376 eventIn MFInt32 set_colorIndex \n\
00377 eventIn MFInt32 set_coordIndex \n\
00378 exposedField SFNode color NULL \n\
00379 exposedField SFNode coord NULL \n\
00380 field MFInt32 colorIndex [] \n\
00381 field SFBool colorPerVertex TRUE \n\
00382 field MFInt32 coordIndex [] \n\
00383 ] { }",
00384 "PROTO Inline [ \n\
00385 exposedField MFString url [] \n\
00386 field SFVec3f bboxCenter 0 0 0 \n\
00387 field SFVec3f bboxSize -1 -1 -1 \n\
00388 ] { } \n\
00389 PROTO LOD [ \n\
00390 exposedField MFNode level [] \n\
00391 field SFVec3f center 0 0 0 \n\
00392 field MFFloat range [] \n\
00393 ] { } \n\
00394 \n\
00395 PROTO Material [ \n\
00396 exposedField SFFloat ambientIntensity 0.2 \n\
00397 exposedField SFColor diffuseColor 0.8 0.8 0.8 \n\
00398 exposedField SFColor emissiveColor 0 0 0 \n\
00399 exposedField SFFloat shininess 0.2 \n\
00400 exposedField SFColor specularColor 0 0 0 \n\
00401 exposedField SFFloat transparency 0 \n\
00402 ] { } \n\
00403 \n\
00404 PROTO MovieTexture [ \n\
00405 exposedField SFBool loop FALSE \n\
00406 exposedField SFFloat speed 1 \n\
00407 exposedField SFTime startTime 0 \n\
00408 exposedField SFTime stopTime 0 \n\
00409 exposedField MFString url [] \n\
00410 field SFBool repeatS TRUE \n\
00411 field SFBool repeatT TRUE \n\
00412 eventOut SFFloat duration_changed \n\
00413 eventOut SFBool isActive \n\
00414 ] { } \n\
00415 \n\
00416 PROTO NavigationInfo [ \n\
00417 eventIn SFBool set_bind \n\
00418 exposedField MFFloat avatarSize [ 0.25, 1.6, 0.75 ] \n\
00419 exposedField SFBool headlight TRUE \n\
00420 exposedField SFFloat speed 1.0 \n\
00421 exposedField MFString type \"WALK\" \n\
00422 exposedField SFFloat visibilityLimit 0.0 \n\
00423 eventOut SFBool isBound \n\
00424 ] { } \n\
00425 \n\
00426 PROTO Normal [ \n\
00427 exposedField MFVec3f vector [] \n\
00428 ] { } \n\
00429 \n\
00430 PROTO NormalInterpolator [ \n\
00431 eventIn SFFloat set_fraction \n\
00432 exposedField MFFloat key [] \n\
00433 exposedField MFVec3f keyValue [] \n\
00434 eventOut MFVec3f value_changed \n\
00435 ] { } \n\
00436 \n\
00437 PROTO OrientationInterpolator [ \n\
00438 eventIn SFFloat set_fraction \n\
00439 exposedField MFFloat key [] \n\
00440 exposedField MFRotation keyValue [] \n\
00441 eventOut SFRotation value_changed \n\
00442 ] { } \n\
00443 \n\
00444 PROTO PixelTexture [ \n\
00445 exposedField SFImage image 0 0 0 \n\
00446 field SFBool repeatS TRUE \n\
00447 field SFBool repeatT TRUE \n\
00448 ] { }",
00449 "PROTO PlaneSensor [ \n\
00450 exposedField SFBool autoOffset TRUE \n\
00451 exposedField SFBool enabled TRUE \n\
00452 exposedField SFVec2f maxPosition -1 -1 \n\
00453 exposedField SFVec2f minPosition 0 0 \n\
00454 exposedField SFVec3f offset 0 0 0 \n\
00455 eventOut SFBool isActive \n\
00456 eventOut SFVec3f trackPoint_changed \n\
00457 eventOut SFVec3f translation_changed \n\
00458 ] { } \n\
00459 \n\
00460 PROTO PointLight [ \n\
00461 exposedField SFFloat ambientIntensity 0 \n\
00462 exposedField SFVec3f attenuation 1 0 0 \n\
00463 exposedField SFColor color 1 1 1 \n\
00464 exposedField SFFloat intensity 1 \n\
00465 exposedField SFVec3f location 0 0 0 \n\
00466 exposedField SFBool on TRUE \n\
00467 exposedField SFFloat radius 100 \n\
00468 ] { } \n\
00469 \n\
00470 PROTO PointSet [ \n\
00471 exposedField SFNode color NULL \n\
00472 exposedField SFNode coord NULL \n\
00473 ] { } \n\
00474 \n\
00475 PROTO PositionInterpolator [ \n\
00476 eventIn SFFloat set_fraction \n\
00477 exposedField MFFloat key [] \n\
00478 exposedField MFVec3f keyValue [] \n\
00479 eventOut SFVec3f value_changed \n\
00480 ] { } \n\
00481 \n\
00482 PROTO ProximitySensor [ \n\
00483 exposedField SFVec3f center 0 0 0 \n\
00484 exposedField SFVec3f size 0 0 0 \n\
00485 exposedField SFBool enabled TRUE \n\
00486 eventOut SFBool isActive \n\
00487 eventOut SFVec3f position_changed \n\
00488 eventOut SFRotation orientation_changed \n\
00489 eventOut SFTime enterTime \n\
00490 eventOut SFTime exitTime \n\
00491 ] { }",
00492 "PROTO ScalarInterpolator [ \n\
00493 eventIn SFFloat set_fraction \n\
00494 exposedField MFFloat key [] \n\
00495 exposedField MFFloat keyValue [] \n\
00496 eventOut SFFloat value_changed \n\
00497 ] { } \n\
00498 \n\
00499 PROTO Script [ \n\
00500 exposedField MFString url [ ] \n\
00501 field SFBool directOutput FALSE \n\
00502 field SFBool mustEvaluate FALSE \n\
00503 ] { } \n\
00504 \n\
00505 PROTO Shape [ \n\
00506 field SFNode appearance NULL \n\
00507 field SFNode geometry NULL \n\
00508 ] { } \n\
00509 \n\
00510 PROTO Sound [ \n\
00511 exposedField SFVec3f direction 0 0 1 \n\
00512 exposedField SFFloat intensity 1 \n\
00513 exposedField SFVec3f location 0 0 0 \n\
00514 exposedField SFFloat maxBack 10 \n\
00515 exposedField SFFloat maxFront 10 \n\
00516 exposedField SFFloat minBack 1 \n\
00517 exposedField SFFloat minFront 1 \n\
00518 exposedField SFFloat priority 0 \n\
00519 exposedField SFNode source NULL \n\
00520 field SFBool spatialize TRUE \n\
00521 ] { } \n\
00522 \n\
00523 PROTO Sphere [ \n\
00524 field SFFloat radius 1 \n\
00525 ] { } \n\
00526 \n\
00527 PROTO SphereSensor [ \n\
00528 exposedField SFBool autoOffset TRUE \n\
00529 exposedField SFBool enabled TRUE \n\
00530 exposedField SFRotation offset 0 1 0 0 \n\
00531 eventOut SFBool isActive \n\
00532 eventOut SFRotation rotation_changed \n\
00533 eventOut SFVec3f trackPoint_changed \n\
00534 ] { } \n\
00535 \n\
00536 PROTO SpotLight [ \n\
00537 exposedField SFFloat ambientIntensity 0 \n\
00538 exposedField SFVec3f attenuation 1 0 0 \n\
00539 exposedField SFFloat beamWidth 1.570796 \n\
00540 exposedField SFColor color 1 1 1 \n\
00541 exposedField SFFloat cutOffAngle 0.785398 \n\
00542 exposedField SFVec3f direction 0 0 -1 \n\
00543 exposedField SFFloat intensity 1 \n\
00544 exposedField SFVec3f location 0 0 0 \n\
00545 exposedField SFBool on TRUE \n\
00546 exposedField SFFloat radius 100 \n\
00547 ] { } \n\
00548 \n\
00549 PROTO Switch [ \n\
00550 exposedField MFNode choice [] \n\
00551 exposedField SFInt32 whichChoice -1 \n\
00552 ] { } \n\
00553 \n\
00554 PROTO Text [ \n\
00555 exposedField MFString string [] \n\
00556 field SFNode fontStyle NULL \n\
00557 field MFFloat length [] \n\
00558 field SFFloat maxExtent 0.0 \n\
00559 ] { }",
00560 "PROTO TextureCoordinate [ \n\
00561 exposedField MFVec2f point [] \n\
00562 ] { } \n\
00563 PROTO TextureTransform [ \n\
00564 exposedField SFVec2f center 0 0 \n\
00565 exposedField SFFloat rotation 0 \n\
00566 exposedField SFVec2f scale 1 1 \n\
00567 exposedField SFVec2f translation 0 0 \n\
00568 ] { } \n\
00569 \n\
00570 PROTO TimeSensor [ \n\
00571 exposedField SFTime cycleInterval 1 \n\
00572 exposedField SFBool enabled TRUE \n\
00573 exposedField SFBool loop FALSE \n\
00574 exposedField SFTime startTime 0 \n\
00575 exposedField SFTime stopTime 0 \n\
00576 eventOut SFTime cycleTime \n\
00577 eventOut SFFloat fraction_changed \n\
00578 eventOut SFBool isActive \n\
00579 eventOut SFTime time \n\
00580 ] { } \n\
00581 \n\
00582 PROTO TouchSensor [ \n\
00583 exposedField SFBool enabled TRUE \n\
00584 eventOut SFVec3f hitNormal_changed \n\
00585 eventOut SFVec3f hitPoint_changed \n\
00586 eventOut SFVec2f hitTexCoord_changed \n\
00587 eventOut SFBool isActive \n\
00588 eventOut SFBool isOver \n\
00589 eventOut SFTime touchTime \n\
00590 ] { } \n\
00591 \n\
00592 PROTO Transform [ \n\
00593 eventIn MFNode addChildren \n\
00594 eventIn MFNode removeChildren \n\
00595 exposedField SFVec3f center 0 0 0 \n\
00596 exposedField MFNode children [] \n\
00597 exposedField SFRotation rotation 0 0 1 0 \n\
00598 exposedField SFVec3f scale 1 1 1 \n\
00599 exposedField SFRotation scaleOrientation 0 0 1 0 \n\
00600 exposedField SFVec3f translation 0 0 0 \n\
00601 field SFVec3f bboxCenter 0 0 0 \n\
00602 field SFVec3f bboxSize -1 -1 -1 \n\
00603 ] { } \n\
00604 \n\
00605 PROTO Viewpoint [ \n\
00606 eventIn SFBool set_bind \n\
00607 exposedField SFFloat fieldOfView 0.785398 \n\
00608 exposedField SFBool jump TRUE \n\
00609 exposedField SFRotation orientation 0 0 1 0 \n\
00610 exposedField SFVec3f position 0 0 10 \n\
00611 field SFString description \"\" \n\
00612 eventOut SFTime bindTime \n\
00613 eventOut SFBool isBound \n\
00614 ] { }",
00615 "PROTO VisibilitySensor [ \n\
00616 exposedField SFVec3f center 0 0 0 \n\
00617 exposedField SFBool enabled TRUE \n\
00618 exposedField SFVec3f size 0 0 0 \n\
00619 eventOut SFTime enterTime \n\
00620 eventOut SFTime exitTime \n\
00621 eventOut SFBool isActive \n\
00622 ] { } \n\
00623 \n\
00624 PROTO WorldInfo [ \n\
00625 field MFString info [] \n\
00626 field SFString title \"\" \n\
00627 ] { }",""
00628 };
00629 #endif