00001 #include "GLCreatorGeometry3DVisitor.h" 00002 #include "Box.h" 00003 #include "Cone.h" 00004 #include "Cylinder.h" 00005 #include "IndexedFaceSet.h" 00006 #include "Sphere.h" 00007 #include "GLBox.h" 00008 #include "GLCone.h" 00009 #include "GLCylinder.h" 00010 #include "GLIndexedFaceSet.h" 00011 #include "GLSphere.h" 00012 00013 #include <iostream> 00014 00015 using namespace X3DTK; 00016 using namespace std; 00017 00018 GLCreatorGeometry3DVisitor::GLCreatorGeometry3DVisitor() 00019 : Geometry3DVisitor() 00020 { 00021 // Enter functions. 00022 defineNewEnterFunction<GLCreatorGeometry3DVisitor, Box>(&GLCreatorGeometry3DVisitor::enterBox); 00023 defineNewEnterFunction<GLCreatorGeometry3DVisitor, Cone>(&GLCreatorGeometry3DVisitor::enterCone); 00024 defineNewEnterFunction<GLCreatorGeometry3DVisitor, Cylinder>(&GLCreatorGeometry3DVisitor::enterCylinder); 00025 defineNewEnterFunction<GLCreatorGeometry3DVisitor, IndexedFaceSet>(&GLCreatorGeometry3DVisitor::enterIndexedFaceSet); 00026 defineNewEnterFunction<GLCreatorGeometry3DVisitor, Sphere>(&GLCreatorGeometry3DVisitor::enterSphere); 00027 00028 // GlobalVariables assignation. 00029 globalVariables = GVManager::getInstanceOf<GLCreatorGlobalVariables>(); 00030 } 00031 00032 GLCreatorGeometry3DVisitor::~GLCreatorGeometry3DVisitor() 00033 { 00034 } 00035 00036 void GLCreatorGeometry3DVisitor::enterBox(Box *B) const 00037 { 00038 GLBox *GB = new GLBox(); 00039 GB->setLink(B); 00040 globalVariables->getTop()->addChild(GB); 00041 globalVariables->pushNode(GB); 00042 } 00043 00044 void GLCreatorGeometry3DVisitor::enterCone(Cone *C) const 00045 { 00046 GLCone *GC = new GLCone(); 00047 GC->setLink(C); 00048 globalVariables->getTop()->addChild(GC); 00049 globalVariables->pushNode(GC); 00050 } 00051 00052 void GLCreatorGeometry3DVisitor::enterCylinder(Cylinder *C) const 00053 { 00054 GLCylinder *GC = new GLCylinder(); 00055 GC->setLink(C); 00056 globalVariables->getTop()->addChild(GC); 00057 globalVariables->pushNode(GC); 00058 } 00059 00060 void GLCreatorGeometry3DVisitor::enterIndexedFaceSet(IndexedFaceSet *I) const 00061 { 00062 GLIndexedFaceSet *GI = new GLIndexedFaceSet(); 00063 GI->setLink(I); 00064 globalVariables->getTop()->addChild(GI); 00065 globalVariables->pushNode(GI); 00066 } 00067 00068 void GLCreatorGeometry3DVisitor::enterSphere(Sphere *S) const 00069 { 00070 GLSphere *GS = new GLSphere(); 00071 GS->setLink(S); 00072 globalVariables->getTop()->addChild(GS); 00073 globalVariables->pushNode(GS); 00074 }