Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

X3DShapeNode.cpp

Go to the documentation of this file.
00001 #include "X3DShapeNode.h"
00002 #include "ShapeNodes.h"
00003 
00004 #include <iostream>
00005 
00006 using namespace X3DTK;
00007 using namespace std;
00008 
00009 X3DShapeNode::X3DShapeNode()
00010 : X3DChildNode(), geometry_(0), appearance_(0)
00011 {
00012   defineTagName("X3DShapeNode", "Shape");
00013 }
00014 
00015 X3DShapeNode::X3DShapeNode(const X3DGeometryNode *geometry,  const X3DAppearanceNode *appearance)
00016 : X3DChildNode(), geometry_((SFNode)geometry), appearance_((SFNode)appearance)
00017 {
00018   defineTagName("X3DShapeNode", "Shape");
00019 }
00020 
00021 X3DShapeNode::X3DShapeNode(const X3DShapeNode &N)
00022 : X3DChildNode(N), geometry_(N.geometry_), appearance_(N.appearance_)
00023 {
00024   defineTagName("X3DShapeNode", "Shape");
00025 }
00026 
00027 SFNode X3DShapeNode::clone() const
00028 {
00029   return 0;
00030 }
00031 
00032 X3DShapeNode::~X3DShapeNode()
00033 {
00034 }
00035 
00036 void X3DShapeNode::setGeometry(const X3DGeometryNode *geometry)
00037 {
00038   removeLink(this, geometry_);
00039   geometry_ = (SFNode)geometry;
00040   addLink(this, geometry_);
00041 }
00042 
00043 void X3DShapeNode::setAppearance(const X3DAppearanceNode *appearance)
00044 {
00045   removeLink(this, appearance_);
00046   appearance_ = (SFNode)appearance;
00047   addLink(this, appearance_);
00048 }
00049 
00050 bool X3DShapeNode::addChild(const SFNode &N)
00051 {
00052   if (dynamic_cast<X3DGeometryNode *>(N) != 0)
00053   {
00054     if (geometry_ != 0)
00055       return false;
00056       
00057     setGeometry(static_cast<X3DGeometryNode *>(N));
00058     return true;
00059   }
00060   
00061   if (dynamic_cast<X3DAppearanceNode *>(N) != 0)
00062   {
00063     if (appearance_ != 0)
00064       return false;
00065       
00066     setAppearance(static_cast<X3DAppearanceNode *>(N));
00067     return true;    
00068   }
00069   
00070   return false;
00071 }
00072 
00073 bool X3DShapeNode::setChild(const SFNode &N)
00074 {
00075   if (dynamic_cast<X3DGeometryNode *>(N) != 0)
00076   {
00077     setGeometry(static_cast<X3DGeometryNode *>(N));
00078     return true;
00079   }
00080   
00081   if (dynamic_cast<X3DAppearanceNode *>(N) != 0)
00082   {
00083     setAppearance(static_cast<X3DAppearanceNode *>(N));
00084     return true;    
00085   }
00086   
00087   return false;
00088 }
00089 
00090 bool X3DShapeNode::removeChild(const SFNode &N)
00091 {
00092   if (geometry_ == N)
00093   {
00094     setGeometry(0);
00095     return true;
00096   } 
00097    
00098   if (appearance_ == N)
00099   {
00100     setAppearance(0);
00101     return true;
00102   } 
00103   
00104   return false;
00105 }
00106 
00107 void X3DShapeNode::removeScenesToChildren(const MFScene &sceneList)
00108 {
00109   removeScenes(geometry_, sceneList);
00110   removeScenes(appearance_, sceneList);
00111 }
00112 
00113 void X3DShapeNode::addScenesToChildren(const MFScene &sceneList)
00114 {
00115   addScenes(geometry_, sceneList);
00116   addScenes(appearance_, sceneList);
00117 }

Generated on Wed May 14 10:03:12 2003 for X3DToolKit by doxygen1.3