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