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

TriangleSet.cpp

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

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