00001 #include "TriangleFanSet.h" 00002 00003 #include <iostream> 00004 00005 using namespace X3DTK; 00006 using namespace std; 00007 00008 TriangleFanSet::TriangleFanSet() 00009 : X3DComposedGeometryNode(), convex_(true), creaseAngle_(0.0f) 00010 { 00011 defineTagName("TriangleFanSet", "Rendering"); 00012 } 00013 00014 TriangleFanSet::TriangleFanSet(const X3DColorNode *color, const X3DCoordinateNode *coord, const X3DNormalNode *normal, const X3DTextureCoordinateNode *texCoord, SFBool ccw, SFBool colorPerVertex, SFBool convex, SFFloat creaseAngle, const MFInt32 &fanCount, SFBool normalPerVertex, SFBool solid) 00015 : X3DComposedGeometryNode(color, coord, normal, texCoord, ccw, colorPerVertex, normalPerVertex, solid), 00016 convex_(convex), creaseAngle_(creaseAngle), fanCount_(fanCount) 00017 { 00018 defineTagName("TriangleFanSet", "Rendering"); 00019 } 00020 00021 00022 TriangleFanSet::TriangleFanSet(const TriangleFanSet &T) 00023 : X3DComposedGeometryNode(T), convex_(T.convex_), creaseAngle_(T.creaseAngle_), fanCount_(T.fanCount_) 00024 { 00025 defineTagName("TriangleFanSet", "Rendering"); 00026 } 00027 00028 SFNode TriangleFanSet::clone() const 00029 { 00030 return new TriangleFanSet(*this); 00031 } 00032 00033 TriangleFanSet::~TriangleFanSet() 00034 { 00035 } 00036 00037 void TriangleFanSet::setConvex(SFBool convex) 00038 { 00039 convex_ = convex; 00040 } 00041 00042 void TriangleFanSet::setCreaseAngle(SFFloat creaseAngle) 00043 { 00044 creaseAngle_ = creaseAngle; 00045 } 00046 00047 void TriangleFanSet::setFanCount(const MFInt32 &fanCount) 00048 { 00049 fanCount_ = fanCount; 00050 } 00051 00052 void TriangleFanSet::loadAttributes(const X3DFileElement *element) 00053 { 00054 X3DComposedGeometryNode::loadAttributes(element); 00055 00056 int index; 00057 index = element->getIndexAttribute("convex"); 00058 if (index != -1) 00059 convex_ = (element->getAttribute(index).upper() == "TRUE"); 00060 00061 index = element->getIndexAttribute("creaseAngle"); 00062 if (index != -1) 00063 creaseAngle_ = element->getAttribute(index).toFloat(); 00064 00065 index = element->getIndexAttribute("fanCount"); 00066 if (index != -1) 00067 fanCount_ = MFInt32(element->getAttribute(index)); 00068 } 00069 00070 SFString TriangleFanSet::writeAttributes() const 00071 { 00072 SFString attr; 00073 attr = X3DComposedGeometryNode::writeAttributes(); 00074 00075 if (!convex_) 00076 attr += " convex=\"FALSE\""; 00077 if (creaseAngle_ != 0.0f) 00078 attr += " creaseAngle=\"" + toSFString(creaseAngle_) + "\""; 00079 if (!fanCount_.empty()) 00080 attr += " fanCount=\"" + toSFString(fanCount_) + "\""; 00081 00082 return attr; 00083 }