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

IndexedFaceSet.cpp

Go to the documentation of this file.
00001 #include "IndexedFaceSet.h"
00002 
00003 #include <iostream>
00004 
00005 using namespace X3DTK;
00006 using namespace std;
00007 
00008 IndexedFaceSet::IndexedFaceSet()
00009 : X3DComposedGeometryNode(), convex_(true), creaseAngle_(0.0f)
00010 {
00011   defineTagName("IndexedFaceSet", "Geometry3D");
00012 }
00013 
00014 IndexedFaceSet::IndexedFaceSet(const X3DColorNode *color, const X3DCoordinateNode *coord, const X3DNormalNode *normal, const X3DTextureCoordinateNode *texCoord, SFBool ccw, const MFInt32 &colorIndex, SFBool colorPerVertex, SFBool convex, const MFInt32 &coordIndex, SFFloat creaseAngle, const MFInt32 &normalIndex, SFBool normalPerVertex, SFBool solid, const MFInt32 &texCoordIndex) 
00015 : X3DComposedGeometryNode(color, coord, normal, texCoord, ccw, colorPerVertex, normalPerVertex, solid),
00016 colorIndex_(colorIndex), convex_(convex), coordIndex_(coordIndex), creaseAngle_(creaseAngle), normalIndex_(normalIndex), texCoordIndex_(texCoordIndex)
00017 {
00018   defineTagName("IndexedFaceSet", "Geometry3D");
00019 }
00020            
00021 IndexedFaceSet::IndexedFaceSet(const IndexedFaceSet &I)
00022 : X3DComposedGeometryNode(I),
00023 colorIndex_(I.colorIndex_), convex_(I.convex_), coordIndex_(I.coordIndex_), creaseAngle_(I.creaseAngle_), normalIndex_(I.normalIndex_), texCoordIndex_(I.texCoordIndex_)
00024 {
00025   defineTagName("IndexedFaceSet", "Geometry3D");
00026 }
00027 
00028 SFNode IndexedFaceSet::clone() const
00029 {
00030   return new IndexedFaceSet(*this);
00031 }
00032 
00033 IndexedFaceSet::~IndexedFaceSet()
00034 {
00035 }
00036   
00037 void IndexedFaceSet::setColorIndex(const MFInt32 &colorIndex)
00038 {
00039   colorIndex_ = colorIndex;
00040 }
00041 
00042 void IndexedFaceSet::setConvex(SFBool convex)
00043 {
00044   convex_ = convex;
00045 }
00046 
00047 void IndexedFaceSet::setCoordIndex(const MFInt32 &coordIndex)
00048 {
00049   coordIndex_ = coordIndex;
00050 }
00051 
00052 void IndexedFaceSet::setCreaseAngle(SFFloat creaseAngle)
00053 {
00054   creaseAngle_ = creaseAngle;
00055 }
00056 
00057 void IndexedFaceSet::setNormalIndex(const MFInt32 &normalIndex)
00058 {
00059   normalIndex_ = normalIndex;
00060 }
00061 
00062 void IndexedFaceSet::setTexCoordIndex(const MFInt32 &texCoordIndex)  
00063 {
00064   texCoordIndex_ = texCoordIndex;
00065 }
00066 
00067 void IndexedFaceSet::loadAttributes(const X3DFileElement *element)
00068 {
00069   X3DComposedGeometryNode::loadAttributes(element);
00070  
00071   int index;
00072   index = element->getIndexAttribute("colorIndex");
00073   if (index != -1)
00074     colorIndex_ = MFInt32(element->getAttribute(index));
00075   
00076   index = element->getIndexAttribute("convex");  
00077   if (index != -1)
00078     convex_ = (element->getAttribute(index).upper() == "TRUE");
00079 
00080   index = element->getIndexAttribute("coordIndex");
00081   if (index != -1)
00082     coordIndex_ = MFInt32(element->getAttribute(index));
00083 
00084   index = element->getIndexAttribute("creaseAngle");
00085   if (index != -1)
00086     creaseAngle_ = element->getAttribute(index).toFloat(); 
00087   
00088   index = element->getIndexAttribute("normalIndex");
00089   if (index != -1)
00090     normalIndex_ = MFInt32(element->getAttribute(index));
00091 
00092   index = element->getIndexAttribute("texCoordIndex");
00093   if (index != -1)
00094     texCoordIndex_ = MFInt32(element->getAttribute(index));
00095 }
00096 
00097 SFString IndexedFaceSet::writeAttributes() const
00098 {
00099   SFString attr;
00100   attr = X3DComposedGeometryNode::writeAttributes();
00101   
00102   if (!colorIndex_.empty()) 
00103     attr += " colorIndex=\"" + toSFString(colorIndex_) + "\"";
00104   if (!convex_)  
00105     attr += " convex=\"FALSE\"";
00106   if (!coordIndex_.empty())  
00107     attr += " coordIndex=\"" + toSFString(coordIndex_) + "\"";
00108   if (creaseAngle_ != 0.0f)
00109     attr += " creaseAngle=\"" + toSFString(creaseAngle_) + "\"";
00110   if (!normalIndex_.empty())  
00111     attr += " normalIndex=\"" + toSFString(normalIndex_) + "\"";
00112   if (!texCoordIndex_.empty())  
00113     attr += " texCoordIndex=\"" + toSFString(texCoordIndex_) + "\"";
00114   
00115   return attr;
00116 }

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