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

Cylinder.cpp

Go to the documentation of this file.
00001 #include "Cylinder.h"
00002 
00003 using namespace X3DTK;
00004 
00005 Cylinder::Cylinder()
00006 : X3DGeometry3DNode(), bottom_(true), radius_(1.0f), height_(2.0f), side_(true), top_(true)  
00007 {
00008   defineTagName("Cylinder", "Geometry3D");
00009 }
00010 
00011 Cylinder::Cylinder(SFBool bottom, SFFloat radius, SFFloat height, SFBool side, SFBool top)
00012 : X3DGeometry3DNode(), bottom_(bottom), radius_(radius), height_(height), side_(side), top_(top)
00013 {
00014   defineTagName("Cylinder", "Geometry3D");
00015 }
00016 
00017 Cylinder::Cylinder(const Cylinder &C)
00018 : X3DGeometry3DNode(C), bottom_(C.bottom_), radius_(C.radius_), height_(C.height_), side_(C.side_), top_(C.top_)
00019 {
00020   defineTagName("Cylinder", "Geometry3D");
00021 }
00022 
00023 SFNode Cylinder::clone() const
00024 {
00025   return new Cylinder(*this);
00026 }
00027 
00028 Cylinder::~Cylinder()
00029 {
00030 }
00031 
00032 void Cylinder::setBottom(SFBool bottom)
00033 {
00034   bottom_ = bottom;
00035 }
00036 
00037 void Cylinder::setRadius(SFFloat radius)
00038 {
00039   radius_ = radius;
00040 }
00041 
00042 void Cylinder::setHeight(SFFloat height)
00043 {
00044   height_ = height;
00045 }
00046 
00047 void Cylinder::setSide(SFBool side)
00048 {
00049   side_ = side;
00050 }
00051 
00052 void Cylinder::setTop(SFBool top)
00053 {
00054   top_ = top;
00055 }
00056 
00057 void Cylinder::loadAttributes(const X3DFileElement *element)
00058 {
00059   int index;
00060   index = element->getIndexAttribute("bottom");
00061   if (index != -1)
00062     bottom_ = (element->getAttribute(index).upper() == "TRUE");
00063   
00064   index = element->getIndexAttribute("radius");
00065   if (index != -1)
00066     radius_ = element->getAttribute(index).toFloat(); 
00067 
00068   index = element->getIndexAttribute("height");
00069   if (index != -1)
00070     height_ = element->getAttribute(index).toFloat(); 
00071   
00072   index = element->getIndexAttribute("side");
00073   if (index != -1)
00074     side_ = (element->getAttribute(index).upper() == "TRUE"); 
00075   
00076   index = element->getIndexAttribute("top");
00077   if (index != -1)
00078     top_ = (element->getAttribute(index).upper() == "TRUE"); 
00079 }
00080 
00081 SFString Cylinder::writeAttributes() const
00082 {
00083   SFString attr;
00084   if (!bottom_)
00085     attr += " bottom=\"FALSE\"";
00086   if (radius_ != 1.0f)  
00087     attr += " radius=\"" + toSFString(radius_) + "\"";
00088   if (height_ != 2.0f)  
00089     attr += " height=\"" + toSFString(height_) + "\"";
00090   if (!side_)  
00091     attr += " side=\"FALSE\"";
00092   if (!top_)    
00093     attr += " top=\"FALSE\"";
00094       
00095   return attr;
00096 }

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