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