diff --git a/CMakeLists.txt b/CMakeLists.txt index c14c02640..2a951d25a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,14 +28,14 @@ OPTION(USE_GRAPHICAL_BENCHMARK "Use Graphical Benchmark" ON) OPTION(BUILD_SHARED_LIBS "Use shared libraries" OFF) OPTION(USE_SOFT_BODY_MULTI_BODY_DYNAMICS_WORLD "Use btSoftMultiBodyDynamicsWorld" ON) -OPTION(BULLET2_USE_THREAD_LOCKS "Build Bullet 2 libraries with mutex locking around certain operations (required for multi-threading)" OFF) -IF (BULLET2_USE_THREAD_LOCKS) +OPTION(BULLET2_MULTITHREADING "Build Bullet 2 libraries with mutex locking around certain operations (required for multi-threading)" OFF) +IF (BULLET2_MULTITHREADING) OPTION(BULLET2_USE_OPEN_MP_MULTITHREADING "Build Bullet 2 with support for multi-threading with OpenMP (requires a compiler with OpenMP support)" OFF) OPTION(BULLET2_USE_TBB_MULTITHREADING "Build Bullet 2 with support for multi-threading with Intel Threading Building Blocks (requires the TBB library to be already installed)" OFF) IF (MSVC) OPTION(BULLET2_USE_PPL_MULTITHREADING "Build Bullet 2 with support for multi-threading with Microsoft Parallel Patterns Library (requires MSVC compiler)" OFF) ENDIF (MSVC) -ENDIF (BULLET2_USE_THREAD_LOCKS) +ENDIF (BULLET2_MULTITHREADING) IF(NOT WIN32) @@ -225,12 +225,15 @@ IF(USE_GRAPHICAL_BENCHMARK) ADD_DEFINITIONS( -DUSE_GRAPHICAL_BENCHMARK) ENDIF (USE_GRAPHICAL_BENCHMARK) -IF(BULLET2_USE_THREAD_LOCKS) +IF(BULLET2_MULTITHREADING) ADD_DEFINITIONS( -DBT_THREADSAFE=1 ) IF (NOT MSVC) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") ENDIF (NOT MSVC) -ENDIF (BULLET2_USE_THREAD_LOCKS) + IF (NOT WIN32) + LINK_LIBRARIES( pthread ) + ENDIF (NOT WIN32) +ENDIF (BULLET2_MULTITHREADING) IF (BULLET2_USE_OPEN_MP_MULTITHREADING) ADD_DEFINITIONS("-DBT_USE_OPENMP=1") diff --git a/Extras/BulletRobotics/CMakeLists.txt b/Extras/BulletRobotics/CMakeLists.txt index b2c4523b6..08595cbab 100644 --- a/Extras/BulletRobotics/CMakeLists.txt +++ b/Extras/BulletRobotics/CMakeLists.txt @@ -59,10 +59,7 @@ SET(BulletRobotics_SRCS ../../examples/Utils/b3ReferenceFrameHelper.hpp ../../examples/Utils/ChromeTraceUtil.cpp - ../../examples/ThirdPartyLibs/tinyxml/tinystr.cpp - ../../examples/ThirdPartyLibs/tinyxml/tinyxml.cpp - ../../examples/ThirdPartyLibs/tinyxml/tinyxmlerror.cpp - ../../examples/ThirdPartyLibs/tinyxml/tinyxmlparser.cpp + ../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp ../../examples/ThirdPartyLibs/Wavefront/tiny_obj_loader.h diff --git a/Extras/Serialize/BulletWorldImporter/btMultiBodyWorldImporter.h b/Extras/Serialize/BulletWorldImporter/btMultiBodyWorldImporter.h index eb47ecda2..002616e40 100644 --- a/Extras/Serialize/BulletWorldImporter/btMultiBodyWorldImporter.h +++ b/Extras/Serialize/BulletWorldImporter/btMultiBodyWorldImporter.h @@ -1,7 +1,7 @@ #ifndef BT_MULTIBODY_WORLD_IMPORTER_H #define BT_MULTIBODY_WORLD_IMPORTER_H -#include "../Extras/Serialize/BulletWorldImporter/btBulletWorldImporter.h" +#include "btBulletWorldImporter.h" class btMultiBodyWorldImporter : public btBulletWorldImporter { diff --git a/Extras/Serialize/BulletXmlWorldImporter/CMakeLists.txt b/Extras/Serialize/BulletXmlWorldImporter/CMakeLists.txt index 3a9606288..9fd125e44 100644 --- a/Extras/Serialize/BulletXmlWorldImporter/CMakeLists.txt +++ b/Extras/Serialize/BulletXmlWorldImporter/CMakeLists.txt @@ -2,6 +2,7 @@ INCLUDE_DIRECTORIES( ${BULLET_PHYSICS_SOURCE_DIR}/src ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletFileLoader ${BULLET_PHYSICS_SOURCE_DIR}/Extras/Serialize/BulletWorldImporter + ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/tinyxml2 ) ADD_LIBRARY( @@ -10,12 +11,7 @@ ADD_LIBRARY( btBulletXmlWorldImporter.h string_split.cpp string_split.h - tinyxml.cpp - tinyxml.h - tinystr.cpp - tinystr.h - tinyxmlerror.cpp - tinyxmlparser.cpp + ${BULLET_PHYSICS_SOURCE_DIR}/examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp ) SET_TARGET_PROPERTIES(BulletXmlWorldImporter PROPERTIES VERSION ${BULLET_VERSION}) diff --git a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp index e58dbc1f9..51a6f5c23 100644 --- a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp +++ b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.cpp @@ -14,9 +14,10 @@ subject to the following restrictions: */ #include "btBulletXmlWorldImporter.h" -#include "tinyxml.h" +#include "tinyxml2.h" #include "btBulletDynamicsCommon.h" #include "string_split.h" +using namespace tinyxml2; struct MyLocalCaster { @@ -43,12 +44,12 @@ btBulletXmlWorldImporter::~btBulletXmlWorldImporter() } #if 0 -static int get_double_attribute_by_name(const TiXmlElement* pElement, const char* attribName,double* value) +static int get_double_attribute_by_name(const XMLElement* pElement, const char* attribName,double* value) { if ( !pElement ) return 0; - const TiXmlAttribute* pAttrib=pElement->FirstAttribute(); + const XMLAttribute* pAttrib=pElement->FirstAttribute(); while (pAttrib) { if (pAttrib->Name()==attribName) @@ -60,16 +61,16 @@ static int get_double_attribute_by_name(const TiXmlElement* pElement, const char } #endif -static int get_int_attribute_by_name(const TiXmlElement* pElement, const char* attribName,int* value) +static int get_int_attribute_by_name(const XMLElement* pElement, const char* attribName,int* value) { if ( !pElement ) return 0; - const TiXmlAttribute* pAttrib=pElement->FirstAttribute(); + const XMLAttribute* pAttrib=pElement->FirstAttribute(); while (pAttrib) { if (!strcmp(pAttrib->Name(),attribName)) - if (pAttrib->QueryIntValue(value)==TIXML_SUCCESS) + if (pAttrib->QueryIntValue(value)==XML_SUCCESS) return 1; // if (pAttrib->QueryDoubleValue(&dval)==TIXML_SUCCESS) printf( " d=%1.1f", dval); pAttrib=pAttrib->Next(); @@ -84,7 +85,7 @@ void stringToFloatArray(const std::string& string, btAlignedObjectArray& bullet_utils::split( pieces, string, " "); for ( int i = 0; i < pieces.size(); ++i) { - assert(pieces[i]!=""); + btAssert(pieces[i]!=""); floats.push_back((float)atof(pieces[i].c_str())); } @@ -95,7 +96,7 @@ static btVector3FloatData TextToVector3Data(const char* txt) btAssert(txt); btAlignedObjectArray floats; stringToFloatArray(txt, floats); - assert(floats.size()==4); + btAssert(floats.size()==4); btVector3FloatData vec4; vec4.m_floats[0] = floats[0]; @@ -105,13 +106,13 @@ static btVector3FloatData TextToVector3Data(const char* txt) return vec4; } -void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,btAlignedObjectArray& vectors) +void btBulletXmlWorldImporter::deSerializeVector3FloatData(XMLNode* pParent,btAlignedObjectArray& vectors) { - TiXmlNode* flNode = pParent->FirstChild("m_floats"); + XMLNode* flNode = pParent->FirstChildElement("m_floats"); btAssert(flNode); - while (flNode && flNode->FirstChild()) + while (flNode && flNode->FirstChildElement()) { - TiXmlText* pText = flNode->FirstChild()->ToText(); + XMLText* pText = flNode->FirstChildElement()->ToText(); // printf("value = %s\n",pText->Value()); btVector3FloatData vec4 = TextToVector3Data(pText->Value()); vectors.push_back(vec4); @@ -122,20 +123,20 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt #define SET_INT_VALUE(xmlnode, targetdata, argname) \ - btAssert((xmlnode)->FirstChild(#argname) && (xmlnode)->FirstChild(#argname)->ToElement());\ - if ((xmlnode)->FirstChild(#argname) && (xmlnode)->FirstChild(#argname)->ToElement())\ - (targetdata)->argname= (int)atof(xmlnode->FirstChild(#argname)->ToElement()->GetText()); + btAssert((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement());\ + if ((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement())\ + (targetdata)->argname= (int)atof(xmlnode->FirstChildElement(#argname)->ToElement()->GetText()); #define SET_FLOAT_VALUE(xmlnode, targetdata, argname) \ - btAssert((xmlnode)->FirstChild(#argname) && (xmlnode)->FirstChild(#argname)->ToElement());\ - if ((xmlnode)->FirstChild(#argname) && (xmlnode)->FirstChild(#argname)->ToElement())\ - (targetdata)->argname= (float)atof(xmlnode->FirstChild(#argname)->ToElement()->GetText()); + btAssert((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement());\ + if ((xmlnode)->FirstChildElement(#argname) && (xmlnode)->FirstChildElement(#argname)->ToElement())\ + (targetdata)->argname= (float)atof(xmlnode->FirstChildElement(#argname)->ToElement()->GetText()); #define SET_POINTER_VALUE(xmlnode, targetdata, argname, pointertype) \ {\ - TiXmlNode* node = xmlnode->FirstChild(#argname);\ + XMLNode* node = xmlnode->FirstChildElement(#argname);\ btAssert(node);\ if (node)\ {\ @@ -148,11 +149,11 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt #define SET_VECTOR4_VALUE(xmlnode, targetdata, argname) \ {\ - TiXmlNode* flNode = xmlnode->FirstChild(#argname);\ + XMLNode* flNode = xmlnode->FirstChildElement(#argname);\ btAssert(flNode);\ - if (flNode && flNode->FirstChild())\ + if (flNode && flNode->FirstChildElement())\ {\ - const char* txt= flNode->FirstChild()->ToElement()->GetText();\ + const char* txt= flNode->FirstChildElement()->ToElement()->GetText();\ btVector3FloatData vec4 = TextToVector3Data(txt);\ (targetdata)->argname.m_floats[0] = vec4.m_floats[0];\ (targetdata)->argname.m_floats[1] = vec4.m_floats[1];\ @@ -164,22 +165,22 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt #define SET_MATRIX33_VALUE(n, targetdata, argname) \ {\ - TiXmlNode* xmlnode = n->FirstChild(#argname);\ + XMLNode* xmlnode = n->FirstChildElement(#argname);\ btAssert(xmlnode);\ if (xmlnode)\ {\ - TiXmlNode* eleNode = xmlnode->FirstChild("m_el");\ + XMLNode* eleNode = xmlnode->FirstChildElement("m_el");\ btAssert(eleNode);\ - if (eleNode&& eleNode->FirstChild())\ + if (eleNode&& eleNode->FirstChildElement())\ {\ - const char* txt= eleNode->FirstChild()->ToElement()->GetText();\ + const char* txt= eleNode->FirstChildElement()->ToElement()->GetText();\ btVector3FloatData vec4 = TextToVector3Data(txt);\ (targetdata)->argname.m_el[0].m_floats[0] = vec4.m_floats[0];\ (targetdata)->argname.m_el[0].m_floats[1] = vec4.m_floats[1];\ (targetdata)->argname.m_el[0].m_floats[2] = vec4.m_floats[2];\ (targetdata)->argname.m_el[0].m_floats[3] = vec4.m_floats[3];\ \ - TiXmlNode* n1 = eleNode->FirstChild()->NextSibling();\ + XMLNode* n1 = eleNode->FirstChildElement()->NextSibling();\ btAssert(n1);\ if (n1)\ {\ @@ -190,7 +191,7 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt (targetdata)->argname.m_el[1].m_floats[2] = vec4.m_floats[2];\ (targetdata)->argname.m_el[1].m_floats[3] = vec4.m_floats[3];\ \ - TiXmlNode* n2 = n1->NextSibling();\ + XMLNode* n2 = n1->NextSibling();\ btAssert(n2);\ if (n2)\ {\ @@ -208,7 +209,7 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt #define SET_TRANSFORM_VALUE(n, targetdata, argname) \ {\ - TiXmlNode* trNode = n->FirstChild(#argname);\ + XMLNode* trNode = n->FirstChildElement(#argname);\ btAssert(trNode);\ if (trNode)\ {\ @@ -218,7 +219,7 @@ void btBulletXmlWorldImporter::deSerializeVector3FloatData(TiXmlNode* pParent,bt }\ -void btBulletXmlWorldImporter::deSerializeCollisionShapeData(TiXmlNode* pParent, btCollisionShapeData* colShapeData) +void btBulletXmlWorldImporter::deSerializeCollisionShapeData(XMLNode* pParent, btCollisionShapeData* colShapeData) { SET_INT_VALUE(pParent,colShapeData,m_shapeType) colShapeData->m_name = 0; @@ -226,17 +227,17 @@ void btBulletXmlWorldImporter::deSerializeCollisionShapeData(TiXmlNode* pParent, -void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent) +void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(XMLNode* pParent) { MyLocalCaster cast; get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int); btConvexHullShapeData* convexHullData = (btConvexHullShapeData*)btAlignedAlloc(sizeof(btConvexHullShapeData), 16); - TiXmlNode* xmlConvexInt = pParent->FirstChild("m_convexInternalShapeData"); + XMLNode* xmlConvexInt = pParent->FirstChildElement("m_convexInternalShapeData"); btAssert(xmlConvexInt); - TiXmlNode* xmlColShape = xmlConvexInt ->FirstChild("m_collisionShapeData"); + XMLNode* xmlColShape = xmlConvexInt ->FirstChildElement("m_collisionShapeData"); btAssert(xmlColShape); deSerializeCollisionShapeData(xmlColShape,&convexHullData->m_convexInternalShapeData.m_collisionShapeData); @@ -249,7 +250,7 @@ void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent //#define SET_POINTER_VALUE(xmlnode, targetdata, argname, pointertype) { - TiXmlNode* node = pParent->FirstChild("m_unscaledPointsFloatPtr"); + XMLNode* node = pParent->FirstChildElement("m_unscaledPointsFloatPtr"); btAssert(node); if (node) { @@ -268,7 +269,7 @@ void btBulletXmlWorldImporter::deSerializeConvexHullShapeData(TiXmlNode* pParent m_pointerLookup.insert(cast.m_ptr,convexHullData); } -void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pParent) +void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(XMLNode* pParent) { MyLocalCaster cast; get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int); @@ -276,10 +277,10 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pPar int numChildren = 0; btAlignedObjectArray* compoundChildArrayPtr = new btAlignedObjectArray; { - TiXmlNode* transNode = pParent->FirstChild("m_transform"); - TiXmlNode* colShapeNode = pParent->FirstChild("m_childShape"); - TiXmlNode* marginNode = pParent->FirstChild("m_childMargin"); - TiXmlNode* childTypeNode = pParent->FirstChild("m_childShapeType"); + XMLNode* transNode = pParent->FirstChildElement("m_transform"); + XMLNode* colShapeNode = pParent->FirstChildElement("m_childShape"); + XMLNode* marginNode = pParent->FirstChildElement("m_childMargin"); + XMLNode* childTypeNode = pParent->FirstChildElement("m_childShapeType"); int i=0; while (transNode && colShapeNode && marginNode && childTypeNode) @@ -305,10 +306,10 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pPar compoundChildArrayPtr->at(i).m_childMargin = (float)atof(marginNode->ToElement()->GetText()); } - transNode = transNode->NextSibling("m_transform"); - colShapeNode = colShapeNode->NextSibling("m_childShape"); - marginNode = marginNode->NextSibling("m_childMargin"); - childTypeNode = childTypeNode->NextSibling("m_childShapeType"); + transNode = transNode->NextSiblingElement("m_transform"); + colShapeNode = colShapeNode->NextSiblingElement("m_childShape"); + marginNode = marginNode->NextSiblingElement("m_childMargin"); + childTypeNode = childTypeNode->NextSiblingElement("m_childShapeType"); i++; } @@ -326,24 +327,24 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeChildData(TiXmlNode* pPar } -void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent) +void btBulletXmlWorldImporter::deSerializeCompoundShapeData(XMLNode* pParent) { MyLocalCaster cast; get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int); btCompoundShapeData* compoundData = (btCompoundShapeData*) btAlignedAlloc(sizeof(btCompoundShapeData),16); - TiXmlNode* xmlColShape = pParent ->FirstChild("m_collisionShapeData"); + XMLNode* xmlColShape = pParent ->FirstChildElement("m_collisionShapeData"); btAssert(xmlColShape); deSerializeCollisionShapeData(xmlColShape,&compoundData->m_collisionShapeData); SET_INT_VALUE(pParent, compoundData,m_numChildShapes); - TiXmlNode* xmlShapeData = pParent->FirstChild("m_collisionShapeData"); + XMLNode* xmlShapeData = pParent->FirstChildElement("m_collisionShapeData"); btAssert(xmlShapeData ); { - TiXmlNode* node = pParent->FirstChild("m_childShapePtr");\ + XMLNode* node = pParent->FirstChildElement("m_childShapePtr");\ btAssert(node); while (node) { @@ -351,7 +352,7 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent) MyLocalCaster cast; cast.m_int = (int) atof(txt); compoundData->m_childShapePtr = (btCompoundShapeChildData*) cast.m_ptr; - node = node->NextSibling("m_childShapePtr"); + node = node->NextSiblingElement("m_childShapePtr"); } //SET_POINTER_VALUE(xmlColShape, *compoundData,m_childShapePtr,btCompoundShapeChildData*); @@ -363,14 +364,14 @@ void btBulletXmlWorldImporter::deSerializeCompoundShapeData(TiXmlNode* pParent) } -void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(TiXmlNode* pParent) +void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(XMLNode* pParent) { MyLocalCaster cast; get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int); btStaticPlaneShapeData* planeData = (btStaticPlaneShapeData*) btAlignedAlloc(sizeof(btStaticPlaneShapeData),16); - TiXmlNode* xmlShapeData = pParent->FirstChild("m_collisionShapeData"); + XMLNode* xmlShapeData = pParent->FirstChildElement("m_collisionShapeData"); btAssert(xmlShapeData ); deSerializeCollisionShapeData(xmlShapeData,&planeData->m_collisionShapeData); @@ -383,7 +384,7 @@ void btBulletXmlWorldImporter::deSerializeStaticPlaneShapeData(TiXmlNode* pParen } -void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(TiXmlNode* pParent) +void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(XMLNode* pParent) { btContactSolverInfo solverInfo; //btVector3 gravity(0,0,0); @@ -393,7 +394,7 @@ void btBulletXmlWorldImporter::deSerializeDynamicsWorldData(TiXmlNode* pParent) //gravity and world info } -void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(TiXmlNode* pParent) +void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(XMLNode* pParent) { MyLocalCaster cast; get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int); @@ -402,7 +403,7 @@ void btBulletXmlWorldImporter::deSerializeConvexInternalShapeData(TiXmlNode* pPa btConvexInternalShapeData* convexShape = (btConvexInternalShapeData*) btAlignedAlloc(sizeof(btConvexInternalShapeData),16); memset(convexShape,0,sizeof(btConvexInternalShapeData)); - TiXmlNode* xmlShapeData = pParent->FirstChild("m_collisionShapeData"); + XMLNode* xmlShapeData = pParent->FirstChildElement("m_collisionShapeData"); btAssert(xmlShapeData ); deSerializeCollisionShapeData(xmlShapeData,&convexShape->m_collisionShapeData); @@ -433,7 +434,7 @@ enum btTypedConstraintType */ -void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* pParent) +void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(XMLNode* pParent) { MyLocalCaster cast; get_int_attribute_by_name(pParent->ToElement(),"pointer",&cast.m_int); @@ -441,7 +442,7 @@ void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* p btGeneric6DofConstraintData2* dof6Data = (btGeneric6DofConstraintData2*)btAlignedAlloc(sizeof(btGeneric6DofConstraintData2),16); - TiXmlNode* n = pParent->FirstChild("m_typeConstraintData"); + XMLNode* n = pParent->FirstChildElement("m_typeConstraintData"); if (n) { SET_POINTER_VALUE(n,dof6Data->m_typeConstraintData,m_rbA,btRigidBodyData*); @@ -473,7 +474,7 @@ void btBulletXmlWorldImporter::deSerializeGeneric6DofConstraintData(TiXmlNode* p m_pointerLookup.insert(cast.m_ptr,dof6Data); } -void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(TiXmlNode* pParent) +void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(XMLNode* pParent) { MyLocalCaster cast; @@ -485,7 +486,7 @@ void btBulletXmlWorldImporter::deSerializeRigidBodyFloatData(TiXmlNode* pParent) btRigidBodyData* rbData = (btRigidBodyData*)btAlignedAlloc(sizeof(btRigidBodyData),16); - TiXmlNode* n = pParent->FirstChild("m_collisionObjectData"); + XMLNode* n = pParent->FirstChildElement("m_collisionObjectData"); if (n) { @@ -661,14 +662,14 @@ void btBulletXmlWorldImporter::fixupCollisionDataPointers(btCollisionShapeData* } -void btBulletXmlWorldImporter::auto_serialize_root_level_children(TiXmlNode* pParent) +void btBulletXmlWorldImporter::auto_serialize_root_level_children(XMLNode* pParent) { int numChildren = 0; btAssert(pParent); if (pParent) { - TiXmlNode*pChild; - for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling(), numChildren++) + XMLNode*pChild; + for ( pChild = pParent->FirstChildElement(); pChild != 0; pChild = pChild->NextSibling(), numChildren++) { // printf("child Name=%s\n", pChild->Value()); if (!strcmp(pChild->Value(),"btVector3FloatData")) @@ -848,15 +849,15 @@ void btBulletXmlWorldImporter::auto_serialize_root_level_children(TiXmlNode* pPa } } -void btBulletXmlWorldImporter::auto_serialize(TiXmlNode* pParent) +void btBulletXmlWorldImporter::auto_serialize(XMLNode* pParent) { -// TiXmlElement* root = pParent->FirstChildElement("bullet_physics"); +// XMLElement* root = pParent->FirstChildElement("bullet_physics"); if (pParent) { - TiXmlNode*pChild; - for ( pChild = pParent->FirstChild(); pChild != 0; pChild = pChild->NextSibling()) + XMLNode*pChild; + for ( pChild = pParent->FirstChildElement(); pChild != 0; pChild = pChild->NextSibling()) { - if (pChild->Type()==TiXmlNode::TINYXML_ELEMENT) + //if (pChild->Type()==XMLNode::TINYXML_ELEMENT) { // printf("root Name=%s\n", pChild->Value()); auto_serialize_root_level_children(pChild); @@ -873,13 +874,12 @@ void btBulletXmlWorldImporter::auto_serialize(TiXmlNode* pParent) bool btBulletXmlWorldImporter::loadFile(const char* fileName) { - TiXmlDocument doc(fileName); + XMLDocument doc; - bool loadOkay = doc.LoadFile(); - //dump_to_stdout(&doc,0); - - if (loadOkay) + XMLError loadOkay = doc.LoadFile(fileName); + + if (loadOkay==XML_SUCCESS) { if (get_int_attribute_by_name(doc.FirstChildElement()->ToElement(),"version", &m_fileVersion)) { diff --git a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.h b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.h index 99686c8a0..aabf2576a 100644 --- a/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.h +++ b/Extras/Serialize/BulletXmlWorldImporter/btBulletXmlWorldImporter.h @@ -19,7 +19,12 @@ subject to the following restrictions: #include "LinearMath/btScalar.h" class btDynamicsWorld; -class TiXmlNode; + +namespace tinyxml2 +{ + class XMLNode; +}; + struct btConvexInternalShapeData; struct btCollisionShapeData; #ifdef BT_USE_DOUBLE_PRECISION @@ -40,6 +45,8 @@ struct btCompoundShapeChildData; #include "LinearMath/btAlignedObjectArray.h" #include "btWorldImporter.h" + + class btBulletXmlWorldImporter : public btWorldImporter { @@ -52,28 +59,28 @@ protected: int m_fileVersion; bool m_fileOk; - void auto_serialize_root_level_children(TiXmlNode* pParent); - void auto_serialize(TiXmlNode* pParent); + void auto_serialize_root_level_children(tinyxml2::XMLNode* pParent); + void auto_serialize(tinyxml2::XMLNode* pParent); - void deSerializeVector3FloatData(TiXmlNode* pParent,btAlignedObjectArray& vectors); + void deSerializeVector3FloatData(tinyxml2::XMLNode* pParent,btAlignedObjectArray& vectors); void fixupCollisionDataPointers(btCollisionShapeData* shapeData); void fixupConstraintData(btTypedConstraintData2* tcd); //collision shapes data - void deSerializeCollisionShapeData(TiXmlNode* pParent,btCollisionShapeData* colShapeData); - void deSerializeConvexInternalShapeData(TiXmlNode* pParent); - void deSerializeStaticPlaneShapeData(TiXmlNode* pParent); - void deSerializeCompoundShapeData(TiXmlNode* pParent); - void deSerializeCompoundShapeChildData(TiXmlNode* pParent); - void deSerializeConvexHullShapeData(TiXmlNode* pParent); - void deSerializeDynamicsWorldData(TiXmlNode* parent); + void deSerializeCollisionShapeData(tinyxml2::XMLNode* pParent,btCollisionShapeData* colShapeData); + void deSerializeConvexInternalShapeData(tinyxml2::XMLNode* pParent); + void deSerializeStaticPlaneShapeData(tinyxml2::XMLNode* pParent); + void deSerializeCompoundShapeData(tinyxml2::XMLNode* pParent); + void deSerializeCompoundShapeChildData(tinyxml2::XMLNode* pParent); + void deSerializeConvexHullShapeData(tinyxml2::XMLNode* pParent); + void deSerializeDynamicsWorldData(tinyxml2::XMLNode* parent); ///bodies - void deSerializeRigidBodyFloatData(TiXmlNode* pParent); + void deSerializeRigidBodyFloatData(tinyxml2::XMLNode* pParent); ///constraints - void deSerializeGeneric6DofConstraintData(TiXmlNode* pParent); + void deSerializeGeneric6DofConstraintData(tinyxml2::XMLNode* pParent); public: btBulletXmlWorldImporter(btDynamicsWorld* world); diff --git a/Extras/Serialize/BulletXmlWorldImporter/premake4.lua b/Extras/Serialize/BulletXmlWorldImporter/premake4.lua index d940dfd8a..dded9cff4 100644 --- a/Extras/Serialize/BulletXmlWorldImporter/premake4.lua +++ b/Extras/Serialize/BulletXmlWorldImporter/premake4.lua @@ -5,10 +5,12 @@ includedirs { "../BulletWorldImporter", "../BulletFileLoader", - "../../../src" + "../../../src", + "../../../examples/ThirdPartyLibs/tinyxml2" } files { "**.cpp", - "**.h" + "**.h", + "../../../examples/ThirdPartyLibs/tinyxml2/tinyxml2.cpp", } diff --git a/Extras/Serialize/BulletXmlWorldImporter/tinystr.cpp b/Extras/Serialize/BulletXmlWorldImporter/tinystr.cpp deleted file mode 100644 index 066576820..000000000 --- a/Extras/Serialize/BulletXmlWorldImporter/tinystr.cpp +++ /dev/null @@ -1,111 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - - -#ifndef TIXML_USE_STL - -#include "tinystr.h" - -// Error value for find primitive -const TiXmlString::size_type TiXmlString::npos = static_cast< TiXmlString::size_type >(-1); - - -// Null rep. -TiXmlString::Rep TiXmlString::nullrep_ = { 0, 0, { '\0' } }; - - -void TiXmlString::reserve (size_type cap) -{ - if (cap > capacity()) - { - TiXmlString tmp; - tmp.init(length(), cap); - memcpy(tmp.start(), data(), length()); - swap(tmp); - } -} - - -TiXmlString& TiXmlString::assign(const char* str, size_type len) -{ - size_type cap = capacity(); - if (len > cap || cap > 3*(len + 8)) - { - TiXmlString tmp; - tmp.init(len); - memcpy(tmp.start(), str, len); - swap(tmp); - } - else - { - memmove(start(), str, len); - set_size(len); - } - return *this; -} - - -TiXmlString& TiXmlString::append(const char* str, size_type len) -{ - size_type newsize = length() + len; - if (newsize > capacity()) - { - reserve (newsize + capacity()); - } - memmove(finish(), str, len); - set_size(newsize); - return *this; -} - - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b) -{ - TiXmlString tmp; - tmp.reserve(a.length() + b.length()); - tmp += a; - tmp += b; - return tmp; -} - -TiXmlString operator + (const TiXmlString & a, const char* b) -{ - TiXmlString tmp; - TiXmlString::size_type b_len = static_cast( strlen(b) ); - tmp.reserve(a.length() + b_len); - tmp += a; - tmp.append(b, b_len); - return tmp; -} - -TiXmlString operator + (const char* a, const TiXmlString & b) -{ - TiXmlString tmp; - TiXmlString::size_type a_len = static_cast( strlen(a) ); - tmp.reserve(a_len + b.length()); - tmp.append(a, a_len); - tmp += b; - return tmp; -} - - -#endif // TIXML_USE_STL diff --git a/Extras/Serialize/BulletXmlWorldImporter/tinystr.h b/Extras/Serialize/BulletXmlWorldImporter/tinystr.h deleted file mode 100644 index 89cca3341..000000000 --- a/Extras/Serialize/BulletXmlWorldImporter/tinystr.h +++ /dev/null @@ -1,305 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - - -#ifndef TIXML_USE_STL - -#ifndef TIXML_STRING_INCLUDED -#define TIXML_STRING_INCLUDED - -#include -#include - -/* The support for explicit isn't that universal, and it isn't really - required - it is used to check that the TiXmlString class isn't incorrectly - used. Be nice to old compilers and macro it here: -*/ -#if defined(_MSC_VER) && (_MSC_VER >= 1200 ) - // Microsoft visual studio, version 6 and higher. - #define TIXML_EXPLICIT explicit -#elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - #define TIXML_EXPLICIT explicit -#else - #define TIXML_EXPLICIT -#endif - - -/* - TiXmlString is an emulation of a subset of the std::string template. - Its purpose is to allow compiling TinyXML on compilers with no or poor STL support. - Only the member functions relevant to the TinyXML project have been implemented. - The buffer allocation is made by a simplistic power of 2 like mechanism : if we increase - a string and there's no more room, we allocate a buffer twice as big as we need. -*/ -class TiXmlString -{ - public : - // The size type used - typedef size_t size_type; - - // Error value for find primitive - static const size_type npos; // = -1; - - - // TiXmlString empty constructor - TiXmlString () : rep_(&nullrep_) - { - } - - // TiXmlString copy constructor - TiXmlString ( const TiXmlString & copy) : rep_(0) - { - init(copy.length()); - memcpy(start(), copy.data(), length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * copy) : rep_(0) - { - init( static_cast( strlen(copy) )); - memcpy(start(), copy, length()); - } - - // TiXmlString constructor, based on a string - TIXML_EXPLICIT TiXmlString ( const char * str, size_type len) : rep_(0) - { - init(len); - memcpy(start(), str, len); - } - - // TiXmlString destructor - ~TiXmlString () - { - quit(); - } - - TiXmlString& operator = (const char * copy) - { - return assign( copy, (size_type)strlen(copy)); - } - - TiXmlString& operator = (const TiXmlString & copy) - { - return assign(copy.start(), copy.length()); - } - - - // += operator. Maps to append - TiXmlString& operator += (const char * suffix) - { - return append(suffix, static_cast( strlen(suffix) )); - } - - // += operator. Maps to append - TiXmlString& operator += (char single) - { - return append(&single, 1); - } - - // += operator. Maps to append - TiXmlString& operator += (const TiXmlString & suffix) - { - return append(suffix.data(), suffix.length()); - } - - - // Convert a TiXmlString into a null-terminated char * - const char * c_str () const { return rep_->str; } - - // Convert a TiXmlString into a char * (need not be null terminated). - const char * data () const { return rep_->str; } - - // Return the length of a TiXmlString - size_type length () const { return rep_->size; } - - // Alias for length() - size_type size () const { return rep_->size; } - - // Checks if a TiXmlString is empty - bool empty () const { return rep_->size == 0; } - - // Return capacity of string - size_type capacity () const { return rep_->capacity; } - - - // single char extraction - const char& at (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // [] operator - char& operator [] (size_type index) const - { - assert( index < length() ); - return rep_->str[ index ]; - } - - // find a char in a string. Return TiXmlString::npos if not found - size_type find (char lookup) const - { - return find(lookup, 0); - } - - // find a char in a string from an offset. Return TiXmlString::npos if not found - size_type find (char tofind, size_type offset) const - { - if (offset >= length()) return npos; - - for (const char* p = c_str() + offset; *p != '\0'; ++p) - { - if (*p == tofind) return static_cast< size_type >( p - c_str() ); - } - return npos; - } - - void clear () - { - //Lee: - //The original was just too strange, though correct: - // TiXmlString().swap(*this); - //Instead use the quit & re-init: - quit(); - init(0,0); - } - - /* Function to reserve a big amount of data when we know we'll need it. Be aware that this - function DOES NOT clear the content of the TiXmlString if any exists. - */ - void reserve (size_type cap); - - TiXmlString& assign (const char* str, size_type len); - - TiXmlString& append (const char* str, size_type len); - - void swap (TiXmlString& other) - { - Rep* r = rep_; - rep_ = other.rep_; - other.rep_ = r; - } - - private: - - void init(size_type sz) { init(sz, sz); } - void set_size(size_type sz) { rep_->str[ rep_->size = sz ] = '\0'; } - char* start() const { return rep_->str; } - char* finish() const { return rep_->str + rep_->size; } - - struct Rep - { - size_type size, capacity; - char str[1]; - }; - - void init(size_type sz, size_type cap) - { - if (cap) - { - // Lee: the original form: - // rep_ = static_cast(operator new(sizeof(Rep) + cap)); - // doesn't work in some cases of new being overloaded. Switching - // to the normal allocation, although use an 'int' for systems - // that are overly picky about structure alignment. - const size_type bytesNeeded = sizeof(Rep) + cap; - const size_type intsNeeded = ( bytesNeeded + sizeof(int) - 1 ) / sizeof( int ); - rep_ = reinterpret_cast( new int[ intsNeeded ] ); - - rep_->str[ rep_->size = sz ] = '\0'; - rep_->capacity = cap; - } - else - { - rep_ = &nullrep_; - } - } - - void quit() - { - if (rep_ != &nullrep_) - { - // The rep_ is really an array of ints. (see the allocator, above). - // Cast it back before delete, so the compiler won't incorrectly call destructors. - delete [] ( reinterpret_cast( rep_ ) ); - } - } - - Rep * rep_; - static Rep nullrep_; - -} ; - - -inline bool operator == (const TiXmlString & a, const TiXmlString & b) -{ - return ( a.length() == b.length() ) // optimization on some platforms - && ( strcmp(a.c_str(), b.c_str()) == 0 ); // actual compare -} -inline bool operator < (const TiXmlString & a, const TiXmlString & b) -{ - return strcmp(a.c_str(), b.c_str()) < 0; -} - -inline bool operator != (const TiXmlString & a, const TiXmlString & b) { return !(a == b); } -inline bool operator > (const TiXmlString & a, const TiXmlString & b) { return b < a; } -inline bool operator <= (const TiXmlString & a, const TiXmlString & b) { return !(b < a); } -inline bool operator >= (const TiXmlString & a, const TiXmlString & b) { return !(a < b); } - -inline bool operator == (const TiXmlString & a, const char* b) { return strcmp(a.c_str(), b) == 0; } -inline bool operator == (const char* a, const TiXmlString & b) { return b == a; } -inline bool operator != (const TiXmlString & a, const char* b) { return !(a == b); } -inline bool operator != (const char* a, const TiXmlString & b) { return !(b == a); } - -TiXmlString operator + (const TiXmlString & a, const TiXmlString & b); -TiXmlString operator + (const TiXmlString & a, const char* b); -TiXmlString operator + (const char* a, const TiXmlString & b); - - -/* - TiXmlOutStream is an emulation of std::ostream. It is based on TiXmlString. - Only the operators that we need for TinyXML have been developped. -*/ -class TiXmlOutStream : public TiXmlString -{ -public : - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const TiXmlString & in) - { - *this += in; - return *this; - } - - // TiXmlOutStream << operator. - TiXmlOutStream & operator << (const char * in) - { - *this += in; - return *this; - } - -} ; - -#endif // TIXML_STRING_INCLUDED -#endif // TIXML_USE_STL diff --git a/Extras/Serialize/BulletXmlWorldImporter/tinyxml.cpp b/Extras/Serialize/BulletXmlWorldImporter/tinyxml.cpp deleted file mode 100644 index 9c161dfcb..000000000 --- a/Extras/Serialize/BulletXmlWorldImporter/tinyxml.cpp +++ /dev/null @@ -1,1886 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code by Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - -#include - -#ifdef TIXML_USE_STL -#include -#include -#endif - -#include "tinyxml.h" - -FILE* TiXmlFOpen( const char* filename, const char* mode ); - -bool TiXmlBase::condenseWhiteSpace = true; - -// Microsoft compiler security -FILE* TiXmlFOpen( const char* filename, const char* mode ) -{ - #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - FILE* fp = 0; - errno_t err = fopen_s( &fp, filename, mode ); - if ( !err && fp ) - return fp; - return 0; - #else - return fopen( filename, mode ); - #endif -} - -void TiXmlBase::EncodeString( const TIXML_STRING& str, TIXML_STRING* outString ) -{ - int i=0; - - while( i<(int)str.length() ) - { - unsigned char c = (unsigned char) str[i]; - - if ( c == '&' - && i < ( (int)str.length() - 2 ) - && str[i+1] == '#' - && str[i+2] == 'x' ) - { - // Hexadecimal character reference. - // Pass through unchanged. - // © -- copyright symbol, for example. - // - // The -1 is a bug fix from Rob Laveaux. It keeps - // an overflow from happening if there is no ';'. - // There are actually 2 ways to exit this loop - - // while fails (error case) and break (semicolon found). - // However, there is no mechanism (currently) for - // this function to return an error. - while ( i<(int)str.length()-1 ) - { - outString->append( str.c_str() + i, 1 ); - ++i; - if ( str[i] == ';' ) - break; - } - } - else if ( c == '&' ) - { - outString->append( entity[0].str, entity[0].strLength ); - ++i; - } - else if ( c == '<' ) - { - outString->append( entity[1].str, entity[1].strLength ); - ++i; - } - else if ( c == '>' ) - { - outString->append( entity[2].str, entity[2].strLength ); - ++i; - } - else if ( c == '\"' ) - { - outString->append( entity[3].str, entity[3].strLength ); - ++i; - } - else if ( c == '\'' ) - { - outString->append( entity[4].str, entity[4].strLength ); - ++i; - } - else if ( c < 32 ) - { - // Easy pass at non-alpha/numeric/symbol - // Below 32 is symbolic. - char buf[ 32 ]; - - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "&#x%02X;", (unsigned) ( c & 0xff ) ); - #else - sprintf( buf, "&#x%02X;", (unsigned) ( c & 0xff ) ); - #endif - - //*ME: warning C4267: convert 'size_t' to 'int' - //*ME: Int-Cast to make compiler happy ... - outString->append( buf, (int)strlen( buf ) ); - ++i; - } - else - { - //char realc = (char) c; - //outString->append( &realc, 1 ); - *outString += (char) c; // somewhat more efficient function call. - ++i; - } - } -} - - -TiXmlNode::TiXmlNode( NodeType _type ) : TiXmlBase() -{ - parent = 0; - type = _type; - firstChild = 0; - lastChild = 0; - prev = 0; - next = 0; -} - - -TiXmlNode::~TiXmlNode() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } -} - - -void TiXmlNode::CopyTo( TiXmlNode* target ) const -{ - target->SetValue (value.c_str() ); - target->userData = userData; - target->location = location; -} - - -void TiXmlNode::Clear() -{ - TiXmlNode* node = firstChild; - TiXmlNode* temp = 0; - - while ( node ) - { - temp = node; - node = node->next; - delete temp; - } - - firstChild = 0; - lastChild = 0; -} - - -TiXmlNode* TiXmlNode::LinkEndChild( TiXmlNode* node ) -{ - assert( node->parent == 0 || node->parent == this ); - assert( node->GetDocument() == 0 || node->GetDocument() == this->GetDocument() ); - - if ( node->Type() == TiXmlNode::TINYXML_DOCUMENT ) - { - delete node; - if ( GetDocument() ) - GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - node->parent = this; - - node->prev = lastChild; - node->next = 0; - - if ( lastChild ) - lastChild->next = node; - else - firstChild = node; // it was an empty list. - - lastChild = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertEndChild( const TiXmlNode& addThis ) -{ - if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) - { - if ( GetDocument() ) - GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - - return LinkEndChild( node ); -} - - -TiXmlNode* TiXmlNode::InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ) -{ - if ( !beforeThis || beforeThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) - { - if ( GetDocument() ) - GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->next = beforeThis; - node->prev = beforeThis->prev; - if ( beforeThis->prev ) - { - beforeThis->prev->next = node; - } - else - { - assert( firstChild == beforeThis ); - firstChild = node; - } - beforeThis->prev = node; - return node; -} - - -TiXmlNode* TiXmlNode::InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ) -{ - if ( !afterThis || afterThis->parent != this ) { - return 0; - } - if ( addThis.Type() == TiXmlNode::TINYXML_DOCUMENT ) - { - if ( GetDocument() ) - GetDocument()->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = addThis.Clone(); - if ( !node ) - return 0; - node->parent = this; - - node->prev = afterThis; - node->next = afterThis->next; - if ( afterThis->next ) - { - afterThis->next->prev = node; - } - else - { - assert( lastChild == afterThis ); - lastChild = node; - } - afterThis->next = node; - return node; -} - - -TiXmlNode* TiXmlNode::ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ) -{ - if ( !replaceThis ) - return 0; - - if ( replaceThis->parent != this ) - return 0; - - if ( withThis.ToDocument() ) { - // A document can never be a child. Thanks to Noam. - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_DOCUMENT_TOP_ONLY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - TiXmlNode* node = withThis.Clone(); - if ( !node ) - return 0; - - node->next = replaceThis->next; - node->prev = replaceThis->prev; - - if ( replaceThis->next ) - replaceThis->next->prev = node; - else - lastChild = node; - - if ( replaceThis->prev ) - replaceThis->prev->next = node; - else - firstChild = node; - - delete replaceThis; - node->parent = this; - return node; -} - - -bool TiXmlNode::RemoveChild( TiXmlNode* removeThis ) -{ - if ( !removeThis ) { - return false; - } - - if ( removeThis->parent != this ) - { - assert( 0 ); - return false; - } - - if ( removeThis->next ) - removeThis->next->prev = removeThis->prev; - else - lastChild = removeThis->prev; - - if ( removeThis->prev ) - removeThis->prev->next = removeThis->next; - else - firstChild = removeThis->next; - - delete removeThis; - return true; -} - -const TiXmlNode* TiXmlNode::FirstChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = firstChild; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::LastChild( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = lastChild; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild(); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling(); - } -} - - -const TiXmlNode* TiXmlNode::IterateChildren( const char * val, const TiXmlNode* previous ) const -{ - if ( !previous ) - { - return FirstChild( val ); - } - else - { - assert( previous->parent == this ); - return previous->NextSibling( val ); - } -} - - -const TiXmlNode* TiXmlNode::NextSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = next; node; node = node->next ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -const TiXmlNode* TiXmlNode::PreviousSibling( const char * _value ) const -{ - const TiXmlNode* node; - for ( node = prev; node; node = node->prev ) - { - if ( strcmp( node->Value(), _value ) == 0 ) - return node; - } - return 0; -} - - -void TiXmlElement::RemoveAttribute( const char * name ) -{ - #ifdef TIXML_USE_STL - TIXML_STRING str( name ); - TiXmlAttribute* node = attributeSet.Find( str ); - #else - TiXmlAttribute* node = attributeSet.Find( name ); - #endif - if ( node ) - { - attributeSet.Remove( node ); - delete node; - } -} - -const TiXmlElement* TiXmlNode::FirstChildElement() const -{ - const TiXmlNode* node; - - for ( node = FirstChild(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::FirstChildElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = FirstChild( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement() const -{ - const TiXmlNode* node; - - for ( node = NextSibling(); - node; - node = node->NextSibling() ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlElement* TiXmlNode::NextSiblingElement( const char * _value ) const -{ - const TiXmlNode* node; - - for ( node = NextSibling( _value ); - node; - node = node->NextSibling( _value ) ) - { - if ( node->ToElement() ) - return node->ToElement(); - } - return 0; -} - - -const TiXmlDocument* TiXmlNode::GetDocument() const -{ - const TiXmlNode* node; - - for( node = this; node; node = node->parent ) - { - if ( node->ToDocument() ) - return node->ToDocument(); - } - return 0; -} - - -TiXmlElement::TiXmlElement (const char * _value) - : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} - - -#ifdef TIXML_USE_STL -TiXmlElement::TiXmlElement( const std::string& _value ) - : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) -{ - firstChild = lastChild = 0; - value = _value; -} -#endif - - -TiXmlElement::TiXmlElement( const TiXmlElement& copy) - : TiXmlNode( TiXmlNode::TINYXML_ELEMENT ) -{ - firstChild = lastChild = 0; - copy.CopyTo( this ); -} - - -TiXmlElement& TiXmlElement::operator=( const TiXmlElement& base ) -{ - ClearThis(); - base.CopyTo( this ); - return *this; -} - - -TiXmlElement::~TiXmlElement() -{ - ClearThis(); -} - - -void TiXmlElement::ClearThis() -{ - Clear(); - while( attributeSet.First() ) - { - TiXmlAttribute* node = attributeSet.First(); - attributeSet.Remove( node ); - delete node; - } -} - - -const char* TiXmlElement::Attribute( const char* name ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( node ) - return node->Value(); - return 0; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( attrib ) - return &attrib->ValueStr(); - return 0; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, int* i ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - const char* result = 0; - - if ( attrib ) { - result = attrib->Value(); - if ( i ) { - attrib->QueryIntValue( i ); - } - } - return result; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, int* i ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - const std::string* result = 0; - - if ( attrib ) { - result = &attrib->ValueStr(); - if ( i ) { - attrib->QueryIntValue( i ); - } - } - return result; -} -#endif - - -const char* TiXmlElement::Attribute( const char* name, double* d ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - const char* result = 0; - - if ( attrib ) { - result = attrib->Value(); - if ( d ) { - attrib->QueryDoubleValue( d ); - } - } - return result; -} - - -#ifdef TIXML_USE_STL -const std::string* TiXmlElement::Attribute( const std::string& name, double* d ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - const std::string* result = 0; - - if ( attrib ) { - result = &attrib->ValueStr(); - if ( d ) { - attrib->QueryDoubleValue( d ); - } - } - return result; -} -#endif - - -int TiXmlElement::QueryIntAttribute( const char* name, int* ival ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( !attrib ) - return TIXML_NO_ATTRIBUTE; - return attrib->QueryIntValue( ival ); -} - - -int TiXmlElement::QueryUnsignedAttribute( const char* name, unsigned* value ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - - int ival = 0; - int result = node->QueryIntValue( &ival ); - *value = (unsigned)ival; - return result; -} - - -int TiXmlElement::QueryBoolAttribute( const char* name, bool* bval ) const -{ - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - - int result = TIXML_WRONG_TYPE; - if ( StringEqual( node->Value(), "true", true, TIXML_ENCODING_UNKNOWN ) - || StringEqual( node->Value(), "yes", true, TIXML_ENCODING_UNKNOWN ) - || StringEqual( node->Value(), "1", true, TIXML_ENCODING_UNKNOWN ) ) - { - *bval = true; - result = TIXML_SUCCESS; - } - else if ( StringEqual( node->Value(), "false", true, TIXML_ENCODING_UNKNOWN ) - || StringEqual( node->Value(), "no", true, TIXML_ENCODING_UNKNOWN ) - || StringEqual( node->Value(), "0", true, TIXML_ENCODING_UNKNOWN ) ) - { - *bval = false; - result = TIXML_SUCCESS; - } - return result; -} - - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryIntAttribute( const std::string& name, int* ival ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( !attrib ) - return TIXML_NO_ATTRIBUTE; - return attrib->QueryIntValue( ival ); -} -#endif - - -int TiXmlElement::QueryDoubleAttribute( const char* name, double* dval ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( !attrib ) - return TIXML_NO_ATTRIBUTE; - return attrib->QueryDoubleValue( dval ); -} - - -#ifdef TIXML_USE_STL -int TiXmlElement::QueryDoubleAttribute( const std::string& name, double* dval ) const -{ - const TiXmlAttribute* attrib = attributeSet.Find( name ); - if ( !attrib ) - return TIXML_NO_ATTRIBUTE; - return attrib->QueryDoubleValue( dval ); -} -#endif - - -void TiXmlElement::SetAttribute( const char * name, int val ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); - if ( attrib ) { - attrib->SetIntValue( val ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& name, int val ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); - if ( attrib ) { - attrib->SetIntValue( val ); - } -} -#endif - - -void TiXmlElement::SetDoubleAttribute( const char * name, double val ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); - if ( attrib ) { - attrib->SetDoubleValue( val ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetDoubleAttribute( const std::string& name, double val ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( name ); - if ( attrib ) { - attrib->SetDoubleValue( val ); - } -} -#endif - - -void TiXmlElement::SetAttribute( const char * cname, const char * cvalue ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( cname ); - if ( attrib ) { - attrib->SetValue( cvalue ); - } -} - - -#ifdef TIXML_USE_STL -void TiXmlElement::SetAttribute( const std::string& _name, const std::string& _value ) -{ - TiXmlAttribute* attrib = attributeSet.FindOrCreate( _name ); - if ( attrib ) { - attrib->SetValue( _value ); - } -} -#endif - - -void TiXmlElement::Print( FILE* cfile, int depth ) const -{ - int i; - assert( cfile ); - for ( i=0; iNext() ) - { - fprintf( cfile, " " ); - attrib->Print( cfile, depth ); - } - - // There are 3 different formatting approaches: - // 1) An element without children is printed as a node - // 2) An element with only a text child is printed as text - // 3) An element with children is printed on multiple lines. - TiXmlNode* node; - if ( !firstChild ) - { - fprintf( cfile, " />" ); - } - else if ( firstChild == lastChild && firstChild->ToText() ) - { - fprintf( cfile, ">" ); - firstChild->Print( cfile, depth + 1 ); - fprintf( cfile, "", value.c_str() ); - } - else - { - fprintf( cfile, ">" ); - - for ( node = firstChild; node; node=node->NextSibling() ) - { - if ( !node->ToText() ) - { - fprintf( cfile, "\n" ); - } - node->Print( cfile, depth+1 ); - } - fprintf( cfile, "\n" ); - for( i=0; i", value.c_str() ); - } -} - - -void TiXmlElement::CopyTo( TiXmlElement* target ) const -{ - // superclass: - TiXmlNode::CopyTo( target ); - - // Element class: - // Clone the attributes, then clone the children. - const TiXmlAttribute* attribute = 0; - for( attribute = attributeSet.First(); - attribute; - attribute = attribute->Next() ) - { - target->SetAttribute( attribute->Name(), attribute->Value() ); - } - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - -bool TiXmlElement::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this, attributeSet.First() ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -TiXmlNode* TiXmlElement::Clone() const -{ - TiXmlElement* clone = new TiXmlElement( Value() ); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -const char* TiXmlElement::GetText() const -{ - const TiXmlNode* child = this->FirstChild(); - if ( child ) { - const TiXmlText* childText = child->ToText(); - if ( childText ) { - return childText->Value(); - } - } - return 0; -} - - -TiXmlDocument::TiXmlDocument() : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - ClearError(); -} - -TiXmlDocument::TiXmlDocument( const char * documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} - - -#ifdef TIXML_USE_STL -TiXmlDocument::TiXmlDocument( const std::string& documentName ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) -{ - tabsize = 4; - useMicrosoftBOM = false; - value = documentName; - ClearError(); -} -#endif - - -TiXmlDocument::TiXmlDocument( const TiXmlDocument& copy ) : TiXmlNode( TiXmlNode::TINYXML_DOCUMENT ) -{ - copy.CopyTo( this ); -} - - -TiXmlDocument& TiXmlDocument::operator=( const TiXmlDocument& copy ) -{ - Clear(); - copy.CopyTo( this ); - return *this; -} - - -bool TiXmlDocument::LoadFile( TiXmlEncoding encoding ) -{ - return LoadFile( Value(), encoding ); -} - - -bool TiXmlDocument::SaveFile() const -{ - return SaveFile( Value() ); -} - -bool TiXmlDocument::LoadFile( const char* _filename, TiXmlEncoding encoding ) -{ - TIXML_STRING filename( _filename ); - value = filename; - - // reading in binary mode so that tinyxml can normalize the EOL - FILE* file = TiXmlFOpen( value.c_str (), "rb" ); - - if ( file ) - { - bool result = LoadFile( file, encoding ); - fclose( file ); - return result; - } - else - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } -} - -bool TiXmlDocument::LoadFile( FILE* file, TiXmlEncoding encoding ) -{ - if ( !file ) - { - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Delete the existing data: - Clear(); - location.Clear(); - - // Get the file size, so we can pre-allocate the string. HUGE speed impact. - long length = 0; - fseek( file, 0, SEEK_END ); - length = ftell( file ); - fseek( file, 0, SEEK_SET ); - - // Strange case, but good to handle up front. - if ( length <= 0 ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Subtle bug here. TinyXml did use fgets. But from the XML spec: - // 2.11 End-of-Line Handling - // - // - // ...the XML processor MUST behave as if it normalized all line breaks in external - // parsed entities (including the document entity) on input, before parsing, by translating - // both the two-character sequence #xD #xA and any #xD that is not followed by #xA to - // a single #xA character. - // - // - // It is not clear fgets does that, and certainly isn't clear it works cross platform. - // Generally, you expect fgets to translate from the convention of the OS to the c/unix - // convention, and not work generally. - - /* - while( fgets( buf, sizeof(buf), file ) ) - { - data += buf; - } - */ - - char* buf = new char[ length+1 ]; - buf[0] = 0; - - if ( fread( buf, length, 1, file ) != 1 ) { - delete [] buf; - SetError( TIXML_ERROR_OPENING_FILE, 0, 0, TIXML_ENCODING_UNKNOWN ); - return false; - } - - // Process the buffer in place to normalize new lines. (See comment above.) - // Copies from the 'p' to 'q' pointer, where p can advance faster if - // a newline-carriage return is hit. - // - // Wikipedia: - // Systems based on ASCII or a compatible character set use either LF (Line feed, '\n', 0x0A, 10 in decimal) or - // CR (Carriage return, '\r', 0x0D, 13 in decimal) individually, or CR followed by LF (CR+LF, 0x0D 0x0A)... - // * LF: Multics, Unix and Unix-like systems (GNU/Linux, AIX, Xenix, Mac OS X, FreeBSD, etc.), BeOS, Amiga, RISC OS, and others - // * CR+LF: DEC RT-11 and most other early non-Unix, non-IBM OSes, CP/M, MP/M, DOS, OS/2, Microsoft Windows, Symbian OS - // * CR: Commodore 8-bit machines, Apple II family, Mac OS up to version 9 and OS-9 - - const char* p = buf; // the read head - char* q = buf; // the write head - const char CR = 0x0d; - const char LF = 0x0a; - - buf[length] = 0; - while( *p ) { - assert( p < (buf+length) ); - assert( q <= (buf+length) ); - assert( q <= p ); - - if ( *p == CR ) { - *q++ = LF; - p++; - if ( *p == LF ) { // check for CR+LF (and skip LF) - p++; - } - } - else { - *q++ = *p++; - } - } - assert( q <= (buf+length) ); - *q = 0; - - Parse( buf, 0, encoding ); - - delete [] buf; - return !Error(); -} - - -bool TiXmlDocument::SaveFile( const char * filename ) const -{ - // The old c stuff lives on... - FILE* fp = TiXmlFOpen( filename, "w" ); - if ( fp ) - { - bool result = SaveFile( fp ); - fclose( fp ); - return result; - } - return false; -} - - -bool TiXmlDocument::SaveFile( FILE* fp ) const -{ - if ( useMicrosoftBOM ) - { - const unsigned char TIXML_UTF_LEAD_0 = 0xefU; - const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; - const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - - fputc( TIXML_UTF_LEAD_0, fp ); - fputc( TIXML_UTF_LEAD_1, fp ); - fputc( TIXML_UTF_LEAD_2, fp ); - } - Print( fp, 0 ); - return (ferror(fp) == 0); -} - - -void TiXmlDocument::CopyTo( TiXmlDocument* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->error = error; - target->errorId = errorId; - target->errorDesc = errorDesc; - target->tabsize = tabsize; - target->errorLocation = errorLocation; - target->useMicrosoftBOM = useMicrosoftBOM; - - TiXmlNode* node = 0; - for ( node = firstChild; node; node = node->NextSibling() ) - { - target->LinkEndChild( node->Clone() ); - } -} - - -TiXmlNode* TiXmlDocument::Clone() const -{ - TiXmlDocument* clone = new TiXmlDocument(); - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlDocument::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - node->Print( cfile, depth ); - fprintf( cfile, "\n" ); - } -} - - -bool TiXmlDocument::Accept( TiXmlVisitor* visitor ) const -{ - if ( visitor->VisitEnter( *this ) ) - { - for ( const TiXmlNode* node=FirstChild(); node; node=node->NextSibling() ) - { - if ( !node->Accept( visitor ) ) - break; - } - } - return visitor->VisitExit( *this ); -} - - -const TiXmlAttribute* TiXmlAttribute::Next() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} - -/* -TiXmlAttribute* TiXmlAttribute::Next() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( next->value.empty() && next->name.empty() ) - return 0; - return next; -} -*/ - -const TiXmlAttribute* TiXmlAttribute::Previous() const -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} - -/* -TiXmlAttribute* TiXmlAttribute::Previous() -{ - // We are using knowledge of the sentinel. The sentinel - // have a value or name. - if ( prev->value.empty() && prev->name.empty() ) - return 0; - return prev; -} -*/ - -void TiXmlAttribute::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - TIXML_STRING n, v; - - EncodeString( name, &n ); - EncodeString( value, &v ); - - if (value.find ('\"') == TIXML_STRING::npos) { - if ( cfile ) { - fprintf (cfile, "%s=\"%s\"", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "=\""; (*str) += v; (*str) += "\""; - } - } - else { - if ( cfile ) { - fprintf (cfile, "%s='%s'", n.c_str(), v.c_str() ); - } - if ( str ) { - (*str) += n; (*str) += "='"; (*str) += v; (*str) += "'"; - } - } -} - - -int TiXmlAttribute::QueryIntValue( int* ival ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%d", ival ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -int TiXmlAttribute::QueryDoubleValue( double* dval ) const -{ - if ( TIXML_SSCANF( value.c_str(), "%lf", dval ) == 1 ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; -} - -void TiXmlAttribute::SetIntValue( int _value ) -{ - char buf [64]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF(buf, sizeof(buf), "%d", _value); - #else - sprintf (buf, "%d", _value); - #endif - SetValue (buf); -} - -void TiXmlAttribute::SetDoubleValue( double _value ) -{ - char buf [256]; - #if defined(TIXML_SNPRINTF) - TIXML_SNPRINTF( buf, sizeof(buf), "%g", _value); - #else - sprintf (buf, "%g", _value); - #endif - SetValue (buf); -} - -int TiXmlAttribute::IntValue() const -{ - return atoi (value.c_str ()); -} - -double TiXmlAttribute::DoubleValue() const -{ - return atof (value.c_str ()); -} - - -TiXmlComment::TiXmlComment( const TiXmlComment& copy ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) -{ - copy.CopyTo( this ); -} - - -TiXmlComment& TiXmlComment::operator=( const TiXmlComment& base ) -{ - Clear(); - base.CopyTo( this ); - return *this; -} - - -void TiXmlComment::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlComment::CopyTo( TiXmlComment* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlComment::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlComment::Clone() const -{ - TiXmlComment* clone = new TiXmlComment(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlText::Print( FILE* cfile, int depth ) const -{ - assert( cfile ); - if ( cdata ) - { - int i; - fprintf( cfile, "\n" ); - for ( i=0; i\n", value.c_str() ); // unformatted output - } - else - { - TIXML_STRING buffer; - EncodeString( value, &buffer ); - fprintf( cfile, "%s", buffer.c_str() ); - } -} - - -void TiXmlText::CopyTo( TiXmlText* target ) const -{ - TiXmlNode::CopyTo( target ); - target->cdata = cdata; -} - - -bool TiXmlText::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlText::Clone() const -{ - TiXmlText* clone = 0; - clone = new TiXmlText( "" ); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlDeclaration::TiXmlDeclaration( const char * _version, - const char * _encoding, - const char * _standalone ) - : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} - - -#ifdef TIXML_USE_STL -TiXmlDeclaration::TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ) - : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) -{ - version = _version; - encoding = _encoding; - standalone = _standalone; -} -#endif - - -TiXmlDeclaration::TiXmlDeclaration( const TiXmlDeclaration& copy ) - : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) -{ - copy.CopyTo( this ); -} - - -TiXmlDeclaration& TiXmlDeclaration::operator=( const TiXmlDeclaration& copy ) -{ - Clear(); - copy.CopyTo( this ); - return *this; -} - - -void TiXmlDeclaration::Print( FILE* cfile, int /*depth*/, TIXML_STRING* str ) const -{ - if ( cfile ) fprintf( cfile, "" ); - if ( str ) (*str) += "?>"; -} - - -void TiXmlDeclaration::CopyTo( TiXmlDeclaration* target ) const -{ - TiXmlNode::CopyTo( target ); - - target->version = version; - target->encoding = encoding; - target->standalone = standalone; -} - - -bool TiXmlDeclaration::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlDeclaration::Clone() const -{ - TiXmlDeclaration* clone = new TiXmlDeclaration(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -void TiXmlUnknown::Print( FILE* cfile, int depth ) const -{ - for ( int i=0; i", value.c_str() ); -} - - -void TiXmlUnknown::CopyTo( TiXmlUnknown* target ) const -{ - TiXmlNode::CopyTo( target ); -} - - -bool TiXmlUnknown::Accept( TiXmlVisitor* visitor ) const -{ - return visitor->Visit( *this ); -} - - -TiXmlNode* TiXmlUnknown::Clone() const -{ - TiXmlUnknown* clone = new TiXmlUnknown(); - - if ( !clone ) - return 0; - - CopyTo( clone ); - return clone; -} - - -TiXmlAttributeSet::TiXmlAttributeSet() -{ - sentinel.next = &sentinel; - sentinel.prev = &sentinel; -} - - -TiXmlAttributeSet::~TiXmlAttributeSet() -{ - assert( sentinel.next == &sentinel ); - assert( sentinel.prev == &sentinel ); -} - - -void TiXmlAttributeSet::Add( TiXmlAttribute* addMe ) -{ - #ifdef TIXML_USE_STL - assert( !Find( TIXML_STRING( addMe->Name() ) ) ); // Shouldn't be multiply adding to the set. - #else - assert( !Find( addMe->Name() ) ); // Shouldn't be multiply adding to the set. - #endif - - addMe->next = &sentinel; - addMe->prev = sentinel.prev; - - sentinel.prev->next = addMe; - sentinel.prev = addMe; -} - -void TiXmlAttributeSet::Remove( TiXmlAttribute* removeMe ) -{ - TiXmlAttribute* node; - - for( node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node == removeMe ) - { - node->prev->next = node->next; - node->next->prev = node->prev; - node->next = 0; - node->prev = 0; - return; - } - } - assert( 0 ); // we tried to remove a non-linked attribute. -} - - -#ifdef TIXML_USE_STL -TiXmlAttribute* TiXmlAttributeSet::Find( const std::string& name ) const -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( node->name == name ) - return node; - } - return 0; -} - -TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const std::string& _name ) -{ - TiXmlAttribute* attrib = Find( _name ); - if ( !attrib ) { - attrib = new TiXmlAttribute(); - Add( attrib ); - attrib->SetName( _name ); - } - return attrib; -} -#endif - - -TiXmlAttribute* TiXmlAttributeSet::Find( const char* name ) const -{ - for( TiXmlAttribute* node = sentinel.next; node != &sentinel; node = node->next ) - { - if ( strcmp( node->name.c_str(), name ) == 0 ) - return node; - } - return 0; -} - - -TiXmlAttribute* TiXmlAttributeSet::FindOrCreate( const char* _name ) -{ - TiXmlAttribute* attrib = Find( _name ); - if ( !attrib ) { - attrib = new TiXmlAttribute(); - Add( attrib ); - attrib->SetName( _name ); - } - return attrib; -} - - -#ifdef TIXML_USE_STL -std::istream& operator>> (std::istream & in, TiXmlNode & base) -{ - TIXML_STRING tag; - tag.reserve( 8 * 1000 ); - base.StreamIn( &in, &tag ); - - base.Parse( tag.c_str(), 0, TIXML_DEFAULT_ENCODING ); - return in; -} -#endif - - -#ifdef TIXML_USE_STL -std::ostream& operator<< (std::ostream & out, const TiXmlNode & base) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out << printer.Str(); - - return out; -} - - -std::string& operator<< (std::string& out, const TiXmlNode& base ) -{ - TiXmlPrinter printer; - printer.SetStreamPrinting(); - base.Accept( &printer ); - out.append( printer.Str() ); - - return out; -} -#endif - - -TiXmlHandle TiXmlHandle::FirstChild() const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChild( const char * value ) const -{ - if ( node ) - { - TiXmlNode* child = node->FirstChild( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement() const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement(); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::FirstChildElement( const char * value ) const -{ - if ( node ) - { - TiXmlElement* child = node->FirstChildElement( value ); - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild(); - for ( i=0; - child && iNextSibling(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::Child( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlNode* child = node->FirstChild( value ); - for ( i=0; - child && iNextSibling( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement(); - for ( i=0; - child && iNextSiblingElement(), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -TiXmlHandle TiXmlHandle::ChildElement( const char* value, int count ) const -{ - if ( node ) - { - int i; - TiXmlElement* child = node->FirstChildElement( value ); - for ( i=0; - child && iNextSiblingElement( value ), ++i ) - { - // nothing - } - if ( child ) - return TiXmlHandle( child ); - } - return TiXmlHandle( 0 ); -} - - -bool TiXmlPrinter::VisitEnter( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitExit( const TiXmlDocument& ) -{ - return true; -} - -bool TiXmlPrinter::VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ) -{ - DoIndent(); - buffer += "<"; - buffer += element.Value(); - - for( const TiXmlAttribute* attrib = firstAttribute; attrib; attrib = attrib->Next() ) - { - buffer += " "; - attrib->Print( 0, 0, &buffer ); - } - - if ( !element.FirstChild() ) - { - buffer += " />"; - DoLineBreak(); - } - else - { - buffer += ">"; - if ( element.FirstChild()->ToText() - && element.LastChild() == element.FirstChild() - && element.FirstChild()->ToText()->CDATA() == false ) - { - simpleTextPrint = true; - // no DoLineBreak()! - } - else - { - DoLineBreak(); - } - } - ++depth; - return true; -} - - -bool TiXmlPrinter::VisitExit( const TiXmlElement& element ) -{ - --depth; - if ( !element.FirstChild() ) - { - // nothing. - } - else - { - if ( simpleTextPrint ) - { - simpleTextPrint = false; - } - else - { - DoIndent(); - } - buffer += ""; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlText& text ) -{ - if ( text.CDATA() ) - { - DoIndent(); - buffer += ""; - DoLineBreak(); - } - else if ( simpleTextPrint ) - { - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - } - else - { - DoIndent(); - TIXML_STRING str; - TiXmlBase::EncodeString( text.ValueTStr(), &str ); - buffer += str; - DoLineBreak(); - } - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlDeclaration& declaration ) -{ - DoIndent(); - declaration.Print( 0, 0, &buffer ); - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlComment& comment ) -{ - DoIndent(); - buffer += ""; - DoLineBreak(); - return true; -} - - -bool TiXmlPrinter::Visit( const TiXmlUnknown& unknown ) -{ - DoIndent(); - buffer += "<"; - buffer += unknown.Value(); - buffer += ">"; - DoLineBreak(); - return true; -} - diff --git a/Extras/Serialize/BulletXmlWorldImporter/tinyxml.h b/Extras/Serialize/BulletXmlWorldImporter/tinyxml.h deleted file mode 100644 index a3589e5b2..000000000 --- a/Extras/Serialize/BulletXmlWorldImporter/tinyxml.h +++ /dev/null @@ -1,1805 +0,0 @@ -/* -www.sourceforge.net/projects/tinyxml -Original code by Lee Thomason (www.grinninglizard.com) - -This software is provided 'as-is', without any express or implied -warranty. In no event will the authors be held liable for any -damages arising from the use of this software. - -Permission is granted to anyone to use this software for any -purpose, including commercial applications, and to alter it and -redistribute it freely, subject to the following restrictions: - -1. The origin of this software must not be misrepresented; you must -not claim that you wrote the original software. If you use this -software in a product, an acknowledgment in the product documentation -would be appreciated but is not required. - -2. Altered source versions must be plainly marked as such, and -must not be misrepresented as being the original software. - -3. This notice may not be removed or altered from any source -distribution. -*/ - - -#ifndef TINYXML_INCLUDED -#define TINYXML_INCLUDED - -#ifdef _MSC_VER -#pragma warning( push ) -#pragma warning( disable : 4530 ) -#pragma warning( disable : 4786 ) -#endif - -#include -#include -#include -#include -#include - -// Help out windows: -#if defined( _DEBUG ) && !defined( DEBUG ) -#define DEBUG -#endif - -#ifdef TIXML_USE_STL - #include - #include - #include - #define TIXML_STRING std::string -#else - #include "tinystr.h" - #define TIXML_STRING TiXmlString -#endif - -// Deprecated library function hell. Compilers want to use the -// new safe versions. This probably doesn't fully address the problem, -// but it gets closer. There are too many compilers for me to fully -// test. If you get compilation troubles, undefine TIXML_SAFE -#define TIXML_SAFE - -#ifdef TIXML_SAFE - #if defined(_MSC_VER) && (_MSC_VER >= 1400 ) - // Microsoft visual studio, version 2005 and higher. - #define TIXML_SNPRINTF _snprintf_s - #define TIXML_SSCANF sscanf_s - #elif defined(_MSC_VER) && (_MSC_VER >= 1200 ) - // Microsoft visual studio, version 6 and higher. - //#pragma message( "Using _sn* functions." ) - #define TIXML_SNPRINTF _snprintf - #define TIXML_SSCANF sscanf - #elif defined(__GNUC__) && (__GNUC__ >= 3 ) - // GCC version 3 and higher.s - //#warning( "Using sn* functions." ) - #define TIXML_SNPRINTF snprintf - #define TIXML_SSCANF sscanf - #else - #define TIXML_SNPRINTF snprintf - #define TIXML_SSCANF sscanf - #endif -#endif - -class TiXmlDocument; -class TiXmlElement; -class TiXmlComment; -class TiXmlUnknown; -class TiXmlAttribute; -class TiXmlText; -class TiXmlDeclaration; -class TiXmlParsingData; - -const int TIXML_MAJOR_VERSION = 2; -const int TIXML_MINOR_VERSION = 6; -const int TIXML_PATCH_VERSION = 2; - -/* Internal structure for tracking location of items - in the XML file. -*/ -struct TiXmlCursor -{ - TiXmlCursor() { Clear(); } - void Clear() { row = col = -1; } - - int row; // 0 based. - int col; // 0 based. -}; - - -/** - Implements the interface to the "Visitor pattern" (see the Accept() method.) - If you call the Accept() method, it requires being passed a TiXmlVisitor - class to handle callbacks. For nodes that contain other nodes (Document, Element) - you will get called with a VisitEnter/VisitExit pair. Nodes that are always leaves - are simply called with Visit(). - - If you return 'true' from a Visit method, recursive parsing will continue. If you return - false, no children of this node or its sibilings will be Visited. - - All flavors of Visit methods have a default implementation that returns 'true' (continue - visiting). You need to only override methods that are interesting to you. - - Generally Accept() is called on the TiXmlDocument, although all nodes suppert Visiting. - - You should never change the document from a callback. - - @sa TiXmlNode::Accept() -*/ -class TiXmlVisitor -{ -public: - virtual ~TiXmlVisitor() {} - - /// Visit a document. - virtual bool VisitEnter( const TiXmlDocument& /*doc*/ ) { return true; } - /// Visit a document. - virtual bool VisitExit( const TiXmlDocument& /*doc*/ ) { return true; } - - /// Visit an element. - virtual bool VisitEnter( const TiXmlElement& /*element*/, const TiXmlAttribute* /*firstAttribute*/ ) { return true; } - /// Visit an element. - virtual bool VisitExit( const TiXmlElement& /*element*/ ) { return true; } - - /// Visit a declaration - virtual bool Visit( const TiXmlDeclaration& /*declaration*/ ) { return true; } - /// Visit a text node - virtual bool Visit( const TiXmlText& /*text*/ ) { return true; } - /// Visit a comment node - virtual bool Visit( const TiXmlComment& /*comment*/ ) { return true; } - /// Visit an unknown node - virtual bool Visit( const TiXmlUnknown& /*unknown*/ ) { return true; } -}; - -// Only used by Attribute::Query functions -enum -{ - TIXML_SUCCESS, - TIXML_NO_ATTRIBUTE, - TIXML_WRONG_TYPE -}; - - -// Used by the parsing routines. -enum TiXmlEncoding -{ - TIXML_ENCODING_UNKNOWN, - TIXML_ENCODING_UTF8, - TIXML_ENCODING_LEGACY -}; - -const TiXmlEncoding TIXML_DEFAULT_ENCODING = TIXML_ENCODING_UNKNOWN; - -/** TiXmlBase is a base class for every class in TinyXml. - It does little except to establish that TinyXml classes - can be printed and provide some utility functions. - - In XML, the document and elements can contain - other elements and other types of nodes. - - @verbatim - A Document can contain: Element (container or leaf) - Comment (leaf) - Unknown (leaf) - Declaration( leaf ) - - An Element can contain: Element (container or leaf) - Text (leaf) - Attributes (not on tree) - Comment (leaf) - Unknown (leaf) - - A Decleration contains: Attributes (not on tree) - @endverbatim -*/ -class TiXmlBase -{ - friend class TiXmlNode; - friend class TiXmlElement; - friend class TiXmlDocument; - -public: - TiXmlBase() : userData(0) {} - virtual ~TiXmlBase() {} - - /** All TinyXml classes can print themselves to a filestream - or the string class (TiXmlString in non-STL mode, std::string - in STL mode.) Either or both cfile and str can be null. - - This is a formatted print, and will insert - tabs and newlines. - - (For an unformatted stream, use the << operator.) - */ - virtual void Print( FILE* cfile, int depth ) const = 0; - - /** The world does not agree on whether white space should be kept or - not. In order to make everyone happy, these global, static functions - are provided to set whether or not TinyXml will condense all white space - into a single space or not. The default is to condense. Note changing this - value is not thread safe. - */ - static void SetCondenseWhiteSpace( bool condense ) { condenseWhiteSpace = condense; } - - /// Return the current white space setting. - static bool IsWhiteSpaceCondensed() { return condenseWhiteSpace; } - - /** Return the position, in the original source file, of this node or attribute. - The row and column are 1-based. (That is the first row and first column is - 1,1). If the returns values are 0 or less, then the parser does not have - a row and column value. - - Generally, the row and column value will be set when the TiXmlDocument::Load(), - TiXmlDocument::LoadFile(), or any TiXmlNode::Parse() is called. It will NOT be set - when the DOM was created from operator>>. - - The values reflect the initial load. Once the DOM is modified programmatically - (by adding or changing nodes and attributes) the new values will NOT update to - reflect changes in the document. - - There is a minor performance cost to computing the row and column. Computation - can be disabled if TiXmlDocument::SetTabSize() is called with 0 as the value. - - @sa TiXmlDocument::SetTabSize() - */ - int Row() const { return location.row + 1; } - int Column() const { return location.col + 1; } ///< See Row() - - void SetUserData( void* user ) { userData = user; } ///< Set a pointer to arbitrary user data. - void* GetUserData() { return userData; } ///< Get a pointer to arbitrary user data. - const void* GetUserData() const { return userData; } ///< Get a pointer to arbitrary user data. - - // Table that returs, for a given lead byte, the total number of bytes - // in the UTF-8 sequence. - static const int utf8ByteTable[256]; - - virtual const char* Parse( const char* p, - TiXmlParsingData* data, - TiXmlEncoding encoding /*= TIXML_ENCODING_UNKNOWN */ ) = 0; - - /** Expands entities in a string. Note this should not contian the tag's '<', '>', etc, - or they will be transformed into entities! - */ - static void EncodeString( const TIXML_STRING& str, TIXML_STRING* out ); - - enum - { - TIXML_NO_ERROR = 0, - TIXML_ERROR, - TIXML_ERROR_OPENING_FILE, - TIXML_ERROR_PARSING_ELEMENT, - TIXML_ERROR_FAILED_TO_READ_ELEMENT_NAME, - TIXML_ERROR_READING_ELEMENT_VALUE, - TIXML_ERROR_READING_ATTRIBUTES, - TIXML_ERROR_PARSING_EMPTY, - TIXML_ERROR_READING_END_TAG, - TIXML_ERROR_PARSING_UNKNOWN, - TIXML_ERROR_PARSING_COMMENT, - TIXML_ERROR_PARSING_DECLARATION, - TIXML_ERROR_DOCUMENT_EMPTY, - TIXML_ERROR_EMBEDDED_NULL, - TIXML_ERROR_PARSING_CDATA, - TIXML_ERROR_DOCUMENT_TOP_ONLY, - - TIXML_ERROR_STRING_COUNT - }; - -protected: - - static const char* SkipWhiteSpace( const char*, TiXmlEncoding encoding ); - - inline static bool IsWhiteSpace( char c ) - { - return ( isspace( (unsigned char) c ) || c == '\n' || c == '\r' ); - } - inline static bool IsWhiteSpace( int c ) - { - if ( c < 256 ) - return IsWhiteSpace( (char) c ); - return false; // Again, only truly correct for English/Latin...but usually works. - } - - #ifdef TIXML_USE_STL - static bool StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ); - static bool StreamTo( std::istream * in, int character, TIXML_STRING * tag ); - #endif - - /* Reads an XML name into the string provided. Returns - a pointer just past the last character of the name, - or 0 if the function has an error. - */ - static const char* ReadName( const char* p, TIXML_STRING* name, TiXmlEncoding encoding ); - - /* Reads text. Returns a pointer past the given end tag. - Wickedly complex options, but it keeps the (sensitive) code in one place. - */ - static const char* ReadText( const char* in, // where to start - TIXML_STRING* text, // the string read - bool ignoreWhiteSpace, // whether to keep the white space - const char* endTag, // what ends this text - bool ignoreCase, // whether to ignore case in the end tag - TiXmlEncoding encoding ); // the current encoding - - // If an entity has been found, transform it into a character. - static const char* GetEntity( const char* in, char* value, int* length, TiXmlEncoding encoding ); - - // Get a character, while interpreting entities. - // The length can be from 0 to 4 bytes. - inline static const char* GetChar( const char* p, char* _value, int* length, TiXmlEncoding encoding ) - { - assert( p ); - if ( encoding == TIXML_ENCODING_UTF8 ) - { - *length = utf8ByteTable[ *((const unsigned char*)p) ]; - assert( *length >= 0 && *length < 5 ); - } - else - { - *length = 1; - } - - if ( *length == 1 ) - { - if ( *p == '&' ) - return GetEntity( p, _value, length, encoding ); - *_value = *p; - return p+1; - } - else if ( *length ) - { - //strncpy( _value, p, *length ); // lots of compilers don't like this function (unsafe), - // and the null terminator isn't needed - for( int i=0; p[i] && i<*length; ++i ) { - _value[i] = p[i]; - } - return p + (*length); - } - else - { - // Not valid text. - return 0; - } - } - - // Return true if the next characters in the stream are any of the endTag sequences. - // Ignore case only works for english, and should only be relied on when comparing - // to English words: StringEqual( p, "version", true ) is fine. - static bool StringEqual( const char* p, - const char* endTag, - bool ignoreCase, - TiXmlEncoding encoding ); - - static const char* errorString[ TIXML_ERROR_STRING_COUNT ]; - - TiXmlCursor location; - - /// Field containing a generic user pointer - void* userData; - - // None of these methods are reliable for any language except English. - // Good for approximation, not great for accuracy. - static int IsAlpha( unsigned char anyByte, TiXmlEncoding encoding ); - static int IsAlphaNum( unsigned char anyByte, TiXmlEncoding encoding ); - inline static int ToLower( int v, TiXmlEncoding encoding ) - { - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( v < 128 ) return tolower( v ); - return v; - } - else - { - return tolower( v ); - } - } - static void ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ); - -private: - TiXmlBase( const TiXmlBase& ); // not implemented. - void operator=( const TiXmlBase& base ); // not allowed. - - struct Entity - { - const char* str; - unsigned int strLength; - char chr; - }; - enum - { - NUM_ENTITY = 5, - MAX_ENTITY_LENGTH = 6 - - }; - static Entity entity[ NUM_ENTITY ]; - static bool condenseWhiteSpace; -}; - - -/** The parent class for everything in the Document Object Model. - (Except for attributes). - Nodes have siblings, a parent, and children. A node can be - in a document, or stand on its own. The type of a TiXmlNode - can be queried, and it can be cast to its more defined type. -*/ -class TiXmlNode : public TiXmlBase -{ - friend class TiXmlDocument; - friend class TiXmlElement; - -public: - #ifdef TIXML_USE_STL - - /** An input stream operator, for every class. Tolerant of newlines and - formatting, but doesn't expect them. - */ - friend std::istream& operator >> (std::istream& in, TiXmlNode& base); - - /** An output stream operator, for every class. Note that this outputs - without any newlines or formatting, as opposed to Print(), which - includes tabs and new lines. - - The operator<< and operator>> are not completely symmetric. Writing - a node to a stream is very well defined. You'll get a nice stream - of output, without any extra whitespace or newlines. - - But reading is not as well defined. (As it always is.) If you create - a TiXmlElement (for example) and read that from an input stream, - the text needs to define an element or junk will result. This is - true of all input streams, but it's worth keeping in mind. - - A TiXmlDocument will read nodes until it reads a root element, and - all the children of that root element. - */ - friend std::ostream& operator<< (std::ostream& out, const TiXmlNode& base); - - /// Appends the XML node or attribute to a std::string. - friend std::string& operator<< (std::string& out, const TiXmlNode& base ); - - #endif - - /** The types of XML nodes supported by TinyXml. (All the - unsupported types are picked up by UNKNOWN.) - */ - enum NodeType - { - TINYXML_DOCUMENT, - TINYXML_ELEMENT, - TINYXML_COMMENT, - TINYXML_UNKNOWN, - TINYXML_TEXT, - TINYXML_DECLARATION, - TINYXML_TYPECOUNT - }; - - virtual ~TiXmlNode(); - - /** The meaning of 'value' changes for the specific type of - TiXmlNode. - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - - The subclasses will wrap this function. - */ - const char *Value() const { return value.c_str (); } - - #ifdef TIXML_USE_STL - /** Return Value() as a std::string. If you only use STL, - this is more efficient than calling Value(). - Only available in STL mode. - */ - const std::string& ValueStr() const { return value; } - #endif - - const TIXML_STRING& ValueTStr() const { return value; } - - /** Changes the value of the node. Defined as: - @verbatim - Document: filename of the xml file - Element: name of the element - Comment: the comment text - Unknown: the tag contents - Text: the text string - @endverbatim - */ - void SetValue(const char * _value) { value = _value;} - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Delete all the children of this node. Does not affect 'this'. - void Clear(); - - /// One step up the DOM. - TiXmlNode* Parent() { return parent; } - const TiXmlNode* Parent() const { return parent; } - - const TiXmlNode* FirstChild() const { return firstChild; } ///< The first child of this node. Will be null if there are no children. - TiXmlNode* FirstChild() { return firstChild; } - const TiXmlNode* FirstChild( const char * value ) const; ///< The first child of this node with the matching 'value'. Will be null if none found. - /// The first child of this node with the matching 'value'. Will be null if none found. - TiXmlNode* FirstChild( const char * _value ) { - // Call through to the const version - safe since nothing is changed. Exiting syntax: cast this to a const (always safe) - // call the method, cast the return back to non-const. - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->FirstChild( _value )); - } - const TiXmlNode* LastChild() const { return lastChild; } /// The last child of this node. Will be null if there are no children. - TiXmlNode* LastChild() { return lastChild; } - - const TiXmlNode* LastChild( const char * value ) const; /// The last child of this node matching 'value'. Will be null if there are no children. - TiXmlNode* LastChild( const char * _value ) { - return const_cast< TiXmlNode* > ((const_cast< const TiXmlNode* >(this))->LastChild( _value )); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. - #endif - - /** An alternate way to walk the children of a node. - One way to iterate over nodes is: - @verbatim - for( child = parent->FirstChild(); child; child = child->NextSibling() ) - @endverbatim - - IterateChildren does the same thing with the syntax: - @verbatim - child = 0; - while( child = parent->IterateChildren( child ) ) - @endverbatim - - IterateChildren takes the previous child as input and finds - the next one. If the previous child is null, it returns the - first. IterateChildren will return null when done. - */ - const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( previous ) ); - } - - /// This flavor of IterateChildren searches for children with a particular 'value' - const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; - TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->IterateChildren( _value, previous ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. - #endif - - /** Add a new node related to this. Adds a child past the LastChild. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); - - - /** Add a new node related to this. Adds a child past the LastChild. - - NOTE: the node to be added is passed by pointer, and will be - henceforth owned (and deleted) by tinyXml. This method is efficient - and avoids an extra copy, but should be used with care as it - uses a different memory model than the other insert functions. - - @sa InsertEndChild - */ - TiXmlNode* LinkEndChild( TiXmlNode* addThis ); - - /** Add a new node related to this. Adds a child before the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); - - /** Add a new node related to this. Adds a child after the specified child. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); - - /** Replace a child of this node. - Returns a pointer to the new object or NULL if an error occured. - */ - TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); - - /// Delete a child of this node. - bool RemoveChild( TiXmlNode* removeThis ); - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling() const { return prev; } - TiXmlNode* PreviousSibling() { return prev; } - - /// Navigate to a sibling node. - const TiXmlNode* PreviousSibling( const char * ) const; - TiXmlNode* PreviousSibling( const char *_prev ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->PreviousSibling( _prev ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. - const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. - TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Navigate to a sibling node. - const TiXmlNode* NextSibling() const { return next; } - TiXmlNode* NextSibling() { return next; } - - /// Navigate to a sibling node with the given 'value'. - const TiXmlNode* NextSibling( const char * ) const; - TiXmlNode* NextSibling( const char* _next ) { - return const_cast< TiXmlNode* >( (const_cast< const TiXmlNode* >(this))->NextSibling( _next ) ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement() const; - TiXmlElement* NextSiblingElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement() ); - } - - /** Convenience function to get through elements. - Calls NextSibling and ToElement. Will skip all non-Element - nodes. Returns 0 if there is not another element. - */ - const TiXmlElement* NextSiblingElement( const char * ) const; - TiXmlElement* NextSiblingElement( const char *_next ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->NextSiblingElement( _next ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement() const; - TiXmlElement* FirstChildElement() { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement() ); - } - - /// Convenience function to get through elements. - const TiXmlElement* FirstChildElement( const char * _value ) const; - TiXmlElement* FirstChildElement( const char * _value ) { - return const_cast< TiXmlElement* >( (const_cast< const TiXmlNode* >(this))->FirstChildElement( _value ) ); - } - - #ifdef TIXML_USE_STL - const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. - #endif - - /** Query the type (as an enumerated value, above) of this node. - The possible types are: TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, - TINYXML_UNKNOWN, TINYXML_TEXT, and TINYXML_DECLARATION. - */ - int Type() const { return type; } - - /** Return a pointer to the Document this node lives in. - Returns null if not in a document. - */ - const TiXmlDocument* GetDocument() const; - TiXmlDocument* GetDocument() { - return const_cast< TiXmlDocument* >( (const_cast< const TiXmlNode* >(this))->GetDocument() ); - } - - /// Returns true if this node has no children. - bool NoChildren() const { return !firstChild; } - - virtual const TiXmlDocument* ToDocument() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlElement* ToElement() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlComment* ToComment() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlUnknown* ToUnknown() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlText* ToText() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - virtual TiXmlDocument* ToDocument() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlElement* ToElement() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlComment* ToComment() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlText* ToText() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return 0; } ///< Cast to a more defined type. Will return null if not of the requested type. - - /** Create an exact duplicate of this node and return it. The memory must be deleted - by the caller. - */ - virtual TiXmlNode* Clone() const = 0; - - /** Accept a hierchical visit the nodes in the TinyXML DOM. Every node in the - XML tree will be conditionally visited and the host will be called back - via the TiXmlVisitor interface. - - This is essentially a SAX interface for TinyXML. (Note however it doesn't re-parse - the XML for the callbacks, so the performance of TinyXML is unchanged by using this - interface versus any other.) - - The interface has been based on ideas from: - - - http://www.saxproject.org/ - - http://c2.com/cgi/wiki?HierarchicalVisitorPattern - - Which are both good references for "visiting". - - An example of using Accept(): - @verbatim - TiXmlPrinter printer; - tinyxmlDoc.Accept( &printer ); - const char* xmlcstr = printer.CStr(); - @endverbatim - */ - virtual bool Accept( TiXmlVisitor* visitor ) const = 0; - -protected: - TiXmlNode( NodeType _type ); - - // Copy to the allocated object. Shared functionality between Clone, Copy constructor, - // and the assignment operator. - void CopyTo( TiXmlNode* target ) const; - - #ifdef TIXML_USE_STL - // The real work of the input operator. - virtual void StreamIn( std::istream* in, TIXML_STRING* tag ) = 0; - #endif - - // Figure out what is at *p, and parse it. Returns null if it is not an xml node. - TiXmlNode* Identify( const char* start, TiXmlEncoding encoding ); - - TiXmlNode* parent; - NodeType type; - - TiXmlNode* firstChild; - TiXmlNode* lastChild; - - TIXML_STRING value; - - TiXmlNode* prev; - TiXmlNode* next; - -private: - TiXmlNode( const TiXmlNode& ); // not implemented. - void operator=( const TiXmlNode& base ); // not allowed. -}; - - -/** An attribute is a name-value pair. Elements have an arbitrary - number of attributes, each with a unique name. - - @note The attributes are not TiXmlNodes, since they are not - part of the tinyXML document object model. There are other - suggested ways to look at this problem. -*/ -class TiXmlAttribute : public TiXmlBase -{ - friend class TiXmlAttributeSet; - -public: - /// Construct an empty attribute. - TiXmlAttribute() : TiXmlBase() - { - document = 0; - prev = next = 0; - } - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlAttribute( const std::string& _name, const std::string& _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - #endif - - /// Construct an attribute with a name and value. - TiXmlAttribute( const char * _name, const char * _value ) - { - name = _name; - value = _value; - document = 0; - prev = next = 0; - } - - const char* Name() const { return name.c_str(); } ///< Return the name of this attribute. - const char* Value() const { return value.c_str(); } ///< Return the value of this attribute. - #ifdef TIXML_USE_STL - const std::string& ValueStr() const { return value; } ///< Return the value of this attribute. - #endif - int IntValue() const; ///< Return the value of this attribute, converted to an integer. - double DoubleValue() const; ///< Return the value of this attribute, converted to a double. - - // Get the tinyxml string representation - const TIXML_STRING& NameTStr() const { return name; } - - /** QueryIntValue examines the value string. It is an alternative to the - IntValue() method with richer error checking. - If the value is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. - - A specialized but useful call. Note that for success it returns 0, - which is the opposite of almost all other TinyXml calls. - */ - int QueryIntValue( int* _value ) const; - /// QueryDoubleValue examines the value string. See QueryIntValue(). - int QueryDoubleValue( double* _value ) const; - - void SetName( const char* _name ) { name = _name; } ///< Set the name of this attribute. - void SetValue( const char* _value ) { value = _value; } ///< Set the value. - - void SetIntValue( int _value ); ///< Set the value from an integer. - void SetDoubleValue( double _value ); ///< Set the value from a double. - - #ifdef TIXML_USE_STL - /// STL std::string form. - void SetName( const std::string& _name ) { name = _name; } - /// STL std::string form. - void SetValue( const std::string& _value ) { value = _value; } - #endif - - /// Get the next sibling attribute in the DOM. Returns null at end. - const TiXmlAttribute* Next() const; - TiXmlAttribute* Next() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Next() ); - } - - /// Get the previous sibling attribute in the DOM. Returns null at beginning. - const TiXmlAttribute* Previous() const; - TiXmlAttribute* Previous() { - return const_cast< TiXmlAttribute* >( (const_cast< const TiXmlAttribute* >(this))->Previous() ); - } - - bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } - bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } - bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } - - /* Attribute parsing starts: first letter of the name - returns: the next char after the value end quote - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - // Prints this Attribute to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - - // [internal use] - // Set the document pointer so the attribute can report errors. - void SetDocument( TiXmlDocument* doc ) { document = doc; } - -private: - TiXmlAttribute( const TiXmlAttribute& ); // not implemented. - void operator=( const TiXmlAttribute& base ); // not allowed. - - TiXmlDocument* document; // A pointer back to a document, for error reporting. - TIXML_STRING name; - TIXML_STRING value; - TiXmlAttribute* prev; - TiXmlAttribute* next; -}; - - -/* A class used to manage a group of attributes. - It is only used internally, both by the ELEMENT and the DECLARATION. - - The set can be changed transparent to the Element and Declaration - classes that use it, but NOT transparent to the Attribute - which has to implement a next() and previous() method. Which makes - it a bit problematic and prevents the use of STL. - - This version is implemented with circular lists because: - - I like circular lists - - it demonstrates some independence from the (typical) doubly linked list. -*/ -class TiXmlAttributeSet -{ -public: - TiXmlAttributeSet(); - ~TiXmlAttributeSet(); - - void Add( TiXmlAttribute* attribute ); - void Remove( TiXmlAttribute* attribute ); - - const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } - const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } - - TiXmlAttribute* Find( const char* _name ) const; - TiXmlAttribute* FindOrCreate( const char* _name ); - -# ifdef TIXML_USE_STL - TiXmlAttribute* Find( const std::string& _name ) const; - TiXmlAttribute* FindOrCreate( const std::string& _name ); -# endif - - -private: - //*ME: Because of hidden/disabled copy-construktor in TiXmlAttribute (sentinel-element), - //*ME: this class must be also use a hidden/disabled copy-constructor !!! - TiXmlAttributeSet( const TiXmlAttributeSet& ); // not allowed - void operator=( const TiXmlAttributeSet& ); // not allowed (as TiXmlAttribute) - - TiXmlAttribute sentinel; -}; - - -/** The element is a container class. It has a value, the element name, - and can contain other elements, text, comments, and unknowns. - Elements also contain an arbitrary number of attributes. -*/ -class TiXmlElement : public TiXmlNode -{ -public: - /// Construct an element. - TiXmlElement (const char * in_value); - - #ifdef TIXML_USE_STL - /// std::string constructor. - TiXmlElement( const std::string& _value ); - #endif - - TiXmlElement( const TiXmlElement& ); - - TiXmlElement& operator=( const TiXmlElement& base ); - - virtual ~TiXmlElement(); - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - */ - const char* Attribute( const char* name ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an integer, - the integer value will be put in the return 'i', if 'i' - is non-null. - */ - const char* Attribute( const char* name, int* i ) const; - - /** Given an attribute name, Attribute() returns the value - for the attribute of that name, or null if none exists. - If the attribute exists and can be converted to an double, - the double value will be put in the return 'd', if 'd' - is non-null. - */ - const char* Attribute( const char* name, double* d ) const; - - /** QueryIntAttribute examines the attribute - it is an alternative to the - Attribute() method with richer error checking. - If the attribute is an integer, it is stored in 'value' and - the call returns TIXML_SUCCESS. If it is not - an integer, it returns TIXML_WRONG_TYPE. If the attribute - does not exist, then TIXML_NO_ATTRIBUTE is returned. - */ - int QueryIntAttribute( const char* name, int* _value ) const; - /// QueryUnsignedAttribute examines the attribute - see QueryIntAttribute(). - int QueryUnsignedAttribute( const char* name, unsigned* _value ) const; - /** QueryBoolAttribute examines the attribute - see QueryIntAttribute(). - Note that '1', 'true', or 'yes' are considered true, while '0', 'false' - and 'no' are considered false. - */ - int QueryBoolAttribute( const char* name, bool* _value ) const; - /// QueryDoubleAttribute examines the attribute - see QueryIntAttribute(). - int QueryDoubleAttribute( const char* name, double* _value ) const; - /// QueryFloatAttribute examines the attribute - see QueryIntAttribute(). - int QueryFloatAttribute( const char* name, float* _value ) const { - double d; - int result = QueryDoubleAttribute( name, &d ); - if ( result == TIXML_SUCCESS ) { - *_value = (float)d; - } - return result; - } - - #ifdef TIXML_USE_STL - /// QueryStringAttribute examines the attribute - see QueryIntAttribute(). - int QueryStringAttribute( const char* name, std::string* _value ) const { - const char* cstr = Attribute( name ); - if ( cstr ) { - *_value = std::string( cstr ); - return TIXML_SUCCESS; - } - return TIXML_NO_ATTRIBUTE; - } - - /** Template form of the attribute query which will try to read the - attribute into the specified type. Very easy, very powerful, but - be careful to make sure to call this with the correct type. - - NOTE: This method doesn't work correctly for 'string' types that contain spaces. - - @return TIXML_SUCCESS, TIXML_WRONG_TYPE, or TIXML_NO_ATTRIBUTE - */ - template< typename T > int QueryValueAttribute( const std::string& name, T* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - - std::stringstream sstream( node->ValueStr() ); - sstream >> *outValue; - if ( !sstream.fail() ) - return TIXML_SUCCESS; - return TIXML_WRONG_TYPE; - } - - int QueryValueAttribute( const std::string& name, std::string* outValue ) const - { - const TiXmlAttribute* node = attributeSet.Find( name ); - if ( !node ) - return TIXML_NO_ATTRIBUTE; - *outValue = node->ValueStr(); - return TIXML_SUCCESS; - } - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char* name, const char * _value ); - - #ifdef TIXML_USE_STL - const std::string* Attribute( const std::string& name ) const; - const std::string* Attribute( const std::string& name, int* i ) const; - const std::string* Attribute( const std::string& name, double* d ) const; - int QueryIntAttribute( const std::string& name, int* _value ) const; - int QueryDoubleAttribute( const std::string& name, double* _value ) const; - - /// STL std::string form. - void SetAttribute( const std::string& name, const std::string& _value ); - ///< STL std::string form. - void SetAttribute( const std::string& name, int _value ); - ///< STL std::string form. - void SetDoubleAttribute( const std::string& name, double value ); - #endif - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetAttribute( const char * name, int value ); - - /** Sets an attribute of name to a given value. The attribute - will be created if it does not exist, or changed if it does. - */ - void SetDoubleAttribute( const char * name, double value ); - - /** Deletes an attribute with the given name. - */ - void RemoveAttribute( const char * name ); - #ifdef TIXML_USE_STL - void RemoveAttribute( const std::string& name ) { RemoveAttribute (name.c_str ()); } ///< STL std::string form. - #endif - - const TiXmlAttribute* FirstAttribute() const { return attributeSet.First(); } ///< Access the first attribute in this element. - TiXmlAttribute* FirstAttribute() { return attributeSet.First(); } - const TiXmlAttribute* LastAttribute() const { return attributeSet.Last(); } ///< Access the last attribute in this element. - TiXmlAttribute* LastAttribute() { return attributeSet.Last(); } - - /** Convenience function for easy access to the text inside an element. Although easy - and concise, GetText() is limited compared to getting the TiXmlText child - and accessing it directly. - - If the first child of 'this' is a TiXmlText, the GetText() - returns the character string of the Text node, else null is returned. - - This is a convenient method for getting the text of simple contained text: - @verbatim - This is text - const char* str = fooElement->GetText(); - @endverbatim - - 'str' will be a pointer to "This is text". - - Note that this function can be misleading. If the element foo was created from - this XML: - @verbatim - This is text - @endverbatim - - then the value of str would be null. The first child node isn't a text node, it is - another element. From this XML: - @verbatim - This is text - @endverbatim - GetText() will return "This is ". - - WARNING: GetText() accesses a child node - don't become confused with the - similarly named TiXmlHandle::Text() and TiXmlNode::ToText() which are - safe type casts on the referenced node. - */ - const char* GetText() const; - - /// Creates a new Element and returns it - the returned element is a copy. - virtual TiXmlNode* Clone() const; - // Print the Element to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: next char past '<' - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlElement* ToElement() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlElement* ToElement() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - - void CopyTo( TiXmlElement* target ) const; - void ClearThis(); // like clear, but initializes 'this' object as well - - // Used to be public [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - /* [internal use] - Reads the "value" of the element -- another element, or text. - This should terminate with the current end tag. - */ - const char* ReadValue( const char* in, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - -private: - TiXmlAttributeSet attributeSet; -}; - - -/** An XML comment. -*/ -class TiXmlComment : public TiXmlNode -{ -public: - /// Constructs an empty comment. - TiXmlComment() : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) {} - /// Construct a comment from text. - TiXmlComment( const char* _value ) : TiXmlNode( TiXmlNode::TINYXML_COMMENT ) { - SetValue( _value ); - } - TiXmlComment( const TiXmlComment& ); - TiXmlComment& operator=( const TiXmlComment& base ); - - virtual ~TiXmlComment() {} - - /// Returns a copy of this Comment. - virtual TiXmlNode* Clone() const; - // Write this Comment to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /* Attribtue parsing starts: at the ! of the !-- - returns: next char past '>' - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlComment* ToComment() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlComment* ToComment() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlComment* target ) const; - - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif -// virtual void StreamOut( TIXML_OSTREAM * out ) const; - -private: - -}; - - -/** XML text. A text node can have 2 ways to output the next. "normal" output - and CDATA. It will default to the mode it was parsed from the XML file and - you generally want to leave it alone, but you can change the output mode with - SetCDATA() and query it with CDATA(). -*/ -class TiXmlText : public TiXmlNode -{ - friend class TiXmlElement; -public: - /** Constructor for text element. By default, it is treated as - normal, encoded text. If you want it be output as a CDATA text - element, set the parameter _cdata to 'true' - */ - TiXmlText (const char * initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) - { - SetValue( initValue ); - cdata = false; - } - virtual ~TiXmlText() {} - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlText( const std::string& initValue ) : TiXmlNode (TiXmlNode::TINYXML_TEXT) - { - SetValue( initValue ); - cdata = false; - } - #endif - - TiXmlText( const TiXmlText& copy ) : TiXmlNode( TiXmlNode::TINYXML_TEXT ) { copy.CopyTo( this ); } - TiXmlText& operator=( const TiXmlText& base ) { base.CopyTo( this ); return *this; } - - // Write this text object to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - /// Queries whether this represents text using a CDATA section. - bool CDATA() const { return cdata; } - /// Turns on or off a CDATA representation of text. - void SetCDATA( bool _cdata ) { cdata = _cdata; } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlText* ToText() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlText* ToText() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - /// [internal use] Creates a new Element and returns it. - virtual TiXmlNode* Clone() const; - void CopyTo( TiXmlText* target ) const; - - bool Blank() const; // returns true if all white space and new lines - // [internal use] - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - bool cdata; // true if this should be input and output as a CDATA style text element -}; - - -/** In correct XML the declaration is the first entry in the file. - @verbatim - - @endverbatim - - TinyXml will happily read or write files without a declaration, - however. There are 3 possible attributes to the declaration: - version, encoding, and standalone. - - Note: In this version of the code, the attributes are - handled as special cases, not generic attributes, simply - because there can only be at most 3 and they are always the same. -*/ -class TiXmlDeclaration : public TiXmlNode -{ -public: - /// Construct an empty declaration. - TiXmlDeclaration() : TiXmlNode( TiXmlNode::TINYXML_DECLARATION ) {} - -#ifdef TIXML_USE_STL - /// Constructor. - TiXmlDeclaration( const std::string& _version, - const std::string& _encoding, - const std::string& _standalone ); -#endif - - /// Construct. - TiXmlDeclaration( const char* _version, - const char* _encoding, - const char* _standalone ); - - TiXmlDeclaration( const TiXmlDeclaration& copy ); - TiXmlDeclaration& operator=( const TiXmlDeclaration& copy ); - - virtual ~TiXmlDeclaration() {} - - /// Version. Will return an empty string if none was found. - const char *Version() const { return version.c_str (); } - /// Encoding. Will return an empty string if none was found. - const char *Encoding() const { return encoding.c_str (); } - /// Is this a standalone document? - const char *Standalone() const { return standalone.c_str (); } - - /// Creates a copy of this Declaration and returns it. - virtual TiXmlNode* Clone() const; - // Print this declaration to a FILE stream. - virtual void Print( FILE* cfile, int depth, TIXML_STRING* str ) const; - virtual void Print( FILE* cfile, int depth ) const { - Print( cfile, depth, 0 ); - } - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlDeclaration* ToDeclaration() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDeclaration* ToDeclaration() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* visitor ) const; - -protected: - void CopyTo( TiXmlDeclaration* target ) const; - // used to be public - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - - TIXML_STRING version; - TIXML_STRING encoding; - TIXML_STRING standalone; -}; - - -/** Any tag that tinyXml doesn't recognize is saved as an - unknown. It is a tag of text, but should not be modified. - It will be written back to the XML, unchanged, when the file - is saved. - - DTD tags get thrown into TiXmlUnknowns. -*/ -class TiXmlUnknown : public TiXmlNode -{ -public: - TiXmlUnknown() : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) {} - virtual ~TiXmlUnknown() {} - - TiXmlUnknown( const TiXmlUnknown& copy ) : TiXmlNode( TiXmlNode::TINYXML_UNKNOWN ) { copy.CopyTo( this ); } - TiXmlUnknown& operator=( const TiXmlUnknown& copy ) { copy.CopyTo( this ); return *this; } - - /// Creates a copy of this Unknown and returns it. - virtual TiXmlNode* Clone() const; - // Print this Unknown to a FILE stream. - virtual void Print( FILE* cfile, int depth ) const; - - virtual const char* Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ); - - virtual const TiXmlUnknown* ToUnknown() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlUnknown* ToUnknown() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected: - void CopyTo( TiXmlUnknown* target ) const; - - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - -}; - - -/** Always the top level node. A document binds together all the - XML pieces. It can be saved, loaded, and printed to the screen. - The 'value' of a document node is the xml file name. -*/ -class TiXmlDocument : public TiXmlNode -{ -public: - /// Create an empty document, that has no name. - TiXmlDocument(); - /// Create a document with a name. The name of the document is also the filename of the xml. - TiXmlDocument( const char * documentName ); - - #ifdef TIXML_USE_STL - /// Constructor. - TiXmlDocument( const std::string& documentName ); - #endif - - TiXmlDocument( const TiXmlDocument& copy ); - TiXmlDocument& operator=( const TiXmlDocument& copy ); - - virtual ~TiXmlDocument() {} - - /** Load a file using the current document value. - Returns true if successful. Will delete any existing - document data before loading. - */ - bool LoadFile( TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the current document value. Returns true if successful. - bool SaveFile() const; - /// Load a file using the given filename. Returns true if successful. - bool LoadFile( const char * filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given filename. Returns true if successful. - bool SaveFile( const char * filename ) const; - /** Load a file using the given FILE*. Returns true if successful. Note that this method - doesn't stream - the entire object pointed at by the FILE* - will be interpreted as an XML file. TinyXML doesn't stream in XML from the current - file location. Streaming may be added in the future. - */ - bool LoadFile( FILE*, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - /// Save a file using the given FILE*. Returns true if successful. - bool SaveFile( FILE* ) const; - - #ifdef TIXML_USE_STL - bool LoadFile( const std::string& filename, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ) ///< STL std::string version. - { - return LoadFile( filename.c_str(), encoding ); - } - bool SaveFile( const std::string& filename ) const ///< STL std::string version. - { - return SaveFile( filename.c_str() ); - } - #endif - - /** Parse the given null terminated block of xml data. Passing in an encoding to this - method (either TIXML_ENCODING_LEGACY or TIXML_ENCODING_UTF8 will force TinyXml - to use that encoding, regardless of what TinyXml might otherwise try to detect. - */ - virtual const char* Parse( const char* p, TiXmlParsingData* data = 0, TiXmlEncoding encoding = TIXML_DEFAULT_ENCODING ); - - /** Get the root element -- the only top level element -- of the document. - In well formed XML, there should only be one. TinyXml is tolerant of - multiple elements at the document level. - */ - const TiXmlElement* RootElement() const { return FirstChildElement(); } - TiXmlElement* RootElement() { return FirstChildElement(); } - - /** If an error occurs, Error will be set to true. Also, - - The ErrorId() will contain the integer identifier of the error (not generally useful) - - The ErrorDesc() method will return the name of the error. (very useful) - - The ErrorRow() and ErrorCol() will return the location of the error (if known) - */ - bool Error() const { return error; } - - /// Contains a textual (english) description of the error if one occurs. - const char * ErrorDesc() const { return errorDesc.c_str (); } - - /** Generally, you probably want the error string ( ErrorDesc() ). But if you - prefer the ErrorId, this function will fetch it. - */ - int ErrorId() const { return errorId; } - - /** Returns the location (if known) of the error. The first column is column 1, - and the first row is row 1. A value of 0 means the row and column wasn't applicable - (memory errors, for example, have no row/column) or the parser lost the error. (An - error in the error reporting, in that case.) - - @sa SetTabSize, Row, Column - */ - int ErrorRow() const { return errorLocation.row+1; } - int ErrorCol() const { return errorLocation.col+1; } ///< The column where the error occured. See ErrorRow() - - /** SetTabSize() allows the error reporting functions (ErrorRow() and ErrorCol()) - to report the correct values for row and column. It does not change the output - or input in any way. - - By calling this method, with a tab size - greater than 0, the row and column of each node and attribute is stored - when the file is loaded. Very useful for tracking the DOM back in to - the source file. - - The tab size is required for calculating the location of nodes. If not - set, the default of 4 is used. The tabsize is set per document. Setting - the tabsize to 0 disables row/column tracking. - - Note that row and column tracking is not supported when using operator>>. - - The tab size needs to be enabled before the parse or load. Correct usage: - @verbatim - TiXmlDocument doc; - doc.SetTabSize( 8 ); - doc.Load( "myfile.xml" ); - @endverbatim - - @sa Row, Column - */ - void SetTabSize( int _tabsize ) { tabsize = _tabsize; } - - int TabSize() const { return tabsize; } - - /** If you have handled the error, it can be reset with this call. The error - state is automatically cleared if you Parse a new XML block. - */ - void ClearError() { error = false; - errorId = 0; - errorDesc = ""; - errorLocation.row = errorLocation.col = 0; - //errorLocation.last = 0; - } - - /** Write the document to standard out using formatted printing ("pretty print"). */ - void Print() const { Print( stdout, 0 ); } - - /* Write the document to a string using formatted printing ("pretty print"). This - will allocate a character array (new char[]) and return it as a pointer. The - calling code pust call delete[] on the return char* to avoid a memory leak. - */ - //char* PrintToMemory() const; - - /// Print this Document to a FILE stream. - virtual void Print( FILE* cfile, int depth = 0 ) const; - // [internal use] - void SetError( int err, const char* errorLocation, TiXmlParsingData* prevData, TiXmlEncoding encoding ); - - virtual const TiXmlDocument* ToDocument() const { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - virtual TiXmlDocument* ToDocument() { return this; } ///< Cast to a more defined type. Will return null not of the requested type. - - /** Walk the XML tree visiting this node and all of its children. - */ - virtual bool Accept( TiXmlVisitor* content ) const; - -protected : - // [internal use] - virtual TiXmlNode* Clone() const; - #ifdef TIXML_USE_STL - virtual void StreamIn( std::istream * in, TIXML_STRING * tag ); - #endif - -private: - void CopyTo( TiXmlDocument* target ) const; - - bool error; - int errorId; - TIXML_STRING errorDesc; - int tabsize; - TiXmlCursor errorLocation; - bool useMicrosoftBOM; // the UTF-8 BOM were found when read. Note this, and try to write. -}; - - -/** - A TiXmlHandle is a class that wraps a node pointer with null checks; this is - an incredibly useful thing. Note that TiXmlHandle is not part of the TinyXml - DOM structure. It is a separate utility class. - - Take an example: - @verbatim - - - - - - - @endverbatim - - Assuming you want the value of "attributeB" in the 2nd "Child" element, it's very - easy to write a *lot* of code that looks like: - - @verbatim - TiXmlElement* root = document.FirstChildElement( "Document" ); - if ( root ) - { - TiXmlElement* element = root->FirstChildElement( "Element" ); - if ( element ) - { - TiXmlElement* child = element->FirstChildElement( "Child" ); - if ( child ) - { - TiXmlElement* child2 = child->NextSiblingElement( "Child" ); - if ( child2 ) - { - // Finally do something useful. - @endverbatim - - And that doesn't even cover "else" cases. TiXmlHandle addresses the verbosity - of such code. A TiXmlHandle checks for null pointers so it is perfectly safe - and correct to use: - - @verbatim - TiXmlHandle docHandle( &document ); - TiXmlElement* child2 = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", 1 ).ToElement(); - if ( child2 ) - { - // do something useful - @endverbatim - - Which is MUCH more concise and useful. - - It is also safe to copy handles - internally they are nothing more than node pointers. - @verbatim - TiXmlHandle handleCopy = handle; - @endverbatim - - What they should not be used for is iteration: - - @verbatim - int i=0; - while ( true ) - { - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).Child( "Child", i ).ToElement(); - if ( !child ) - break; - // do something - ++i; - } - @endverbatim - - It seems reasonable, but it is in fact two embedded while loops. The Child method is - a linear walk to find the element, so this code would iterate much more than it needs - to. Instead, prefer: - - @verbatim - TiXmlElement* child = docHandle.FirstChild( "Document" ).FirstChild( "Element" ).FirstChild( "Child" ).ToElement(); - - for( child; child; child=child->NextSiblingElement() ) - { - // do something - } - @endverbatim -*/ -class TiXmlHandle -{ -public: - /// Create a handle from any node (at any depth of the tree.) This can be a null pointer. - TiXmlHandle( TiXmlNode* _node ) { this->node = _node; } - /// Copy constructor - TiXmlHandle( const TiXmlHandle& ref ) { this->node = ref.node; } - TiXmlHandle operator=( const TiXmlHandle& ref ) { if ( &ref != this ) this->node = ref.node; return *this; } - - /// Return a handle to the first child node. - TiXmlHandle FirstChild() const; - /// Return a handle to the first child node with the given name. - TiXmlHandle FirstChild( const char * value ) const; - /// Return a handle to the first child element. - TiXmlHandle FirstChildElement() const; - /// Return a handle to the first child element with the given name. - TiXmlHandle FirstChildElement( const char * value ) const; - - /** Return a handle to the "index" child with the given name. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( const char* value, int index ) const; - /** Return a handle to the "index" child. - The first child is 0, the second 1, etc. - */ - TiXmlHandle Child( int index ) const; - /** Return a handle to the "index" child element with the given name. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( const char* value, int index ) const; - /** Return a handle to the "index" child element. - The first child element is 0, the second 1, etc. Note that only TiXmlElements - are indexed: other types are not counted. - */ - TiXmlHandle ChildElement( int index ) const; - - #ifdef TIXML_USE_STL - TiXmlHandle FirstChild( const std::string& _value ) const { return FirstChild( _value.c_str() ); } - TiXmlHandle FirstChildElement( const std::string& _value ) const { return FirstChildElement( _value.c_str() ); } - - TiXmlHandle Child( const std::string& _value, int index ) const { return Child( _value.c_str(), index ); } - TiXmlHandle ChildElement( const std::string& _value, int index ) const { return ChildElement( _value.c_str(), index ); } - #endif - - /** Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* ToNode() const { return node; } - /** Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* ToElement() const { return ( ( node && node->ToElement() ) ? node->ToElement() : 0 ); } - /** Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* ToText() const { return ( ( node && node->ToText() ) ? node->ToText() : 0 ); } - /** Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* ToUnknown() const { return ( ( node && node->ToUnknown() ) ? node->ToUnknown() : 0 ); } - - /** @deprecated use ToNode. - Return the handle as a TiXmlNode. This may return null. - */ - TiXmlNode* Node() const { return ToNode(); } - /** @deprecated use ToElement. - Return the handle as a TiXmlElement. This may return null. - */ - TiXmlElement* Element() const { return ToElement(); } - /** @deprecated use ToText() - Return the handle as a TiXmlText. This may return null. - */ - TiXmlText* Text() const { return ToText(); } - /** @deprecated use ToUnknown() - Return the handle as a TiXmlUnknown. This may return null. - */ - TiXmlUnknown* Unknown() const { return ToUnknown(); } - -private: - TiXmlNode* node; -}; - - -/** Print to memory functionality. The TiXmlPrinter is useful when you need to: - - -# Print to memory (especially in non-STL mode) - -# Control formatting (line endings, etc.) - - When constructed, the TiXmlPrinter is in its default "pretty printing" mode. - Before calling Accept() you can call methods to control the printing - of the XML document. After TiXmlNode::Accept() is called, the printed document can - be accessed via the CStr(), Str(), and Size() methods. - - TiXmlPrinter uses the Visitor API. - @verbatim - TiXmlPrinter printer; - printer.SetIndent( "\t" ); - - doc.Accept( &printer ); - fprintf( stdout, "%s", printer.CStr() ); - @endverbatim -*/ -class TiXmlPrinter : public TiXmlVisitor -{ -public: - TiXmlPrinter() : depth( 0 ), simpleTextPrint( false ), - buffer(), indent( " " ), lineBreak( "\n" ) {} - - virtual bool VisitEnter( const TiXmlDocument& doc ); - virtual bool VisitExit( const TiXmlDocument& doc ); - - virtual bool VisitEnter( const TiXmlElement& element, const TiXmlAttribute* firstAttribute ); - virtual bool VisitExit( const TiXmlElement& element ); - - virtual bool Visit( const TiXmlDeclaration& declaration ); - virtual bool Visit( const TiXmlText& text ); - virtual bool Visit( const TiXmlComment& comment ); - virtual bool Visit( const TiXmlUnknown& unknown ); - - /** Set the indent characters for printing. By default 4 spaces - but tab (\t) is also useful, or null/empty string for no indentation. - */ - void SetIndent( const char* _indent ) { indent = _indent ? _indent : "" ; } - /// Query the indention string. - const char* Indent() { return indent.c_str(); } - /** Set the line breaking string. By default set to newline (\n). - Some operating systems prefer other characters, or can be - set to the null/empty string for no indenation. - */ - void SetLineBreak( const char* _lineBreak ) { lineBreak = _lineBreak ? _lineBreak : ""; } - /// Query the current line breaking string. - const char* LineBreak() { return lineBreak.c_str(); } - - /** Switch over to "stream printing" which is the most dense formatting without - linebreaks. Common when the XML is needed for network transmission. - */ - void SetStreamPrinting() { indent = ""; - lineBreak = ""; - } - /// Return the result. - const char* CStr() { return buffer.c_str(); } - /// Return the length of the result string. - size_t Size() { return buffer.size(); } - - #ifdef TIXML_USE_STL - /// Return the result. - const std::string& Str() { return buffer; } - #endif - -private: - void DoIndent() { - for( int i=0; i -#include - -#include "tinyxml.h" - -//#define DEBUG_PARSER -#if defined( DEBUG_PARSER ) -# if defined( DEBUG ) && defined( _MSC_VER ) -# include -# define TIXML_LOG OutputDebugString -# else -# define TIXML_LOG printf -# endif -#endif - -// Note tha "PutString" hardcodes the same list. This -// is less flexible than it appears. Changing the entries -// or order will break putstring. -TiXmlBase::Entity TiXmlBase::entity[ TiXmlBase::NUM_ENTITY ] = -{ - { "&", 5, '&' }, - { "<", 4, '<' }, - { ">", 4, '>' }, - { """, 6, '\"' }, - { "'", 6, '\'' } -}; - -// Bunch of unicode info at: -// http://www.unicode.org/faq/utf_bom.html -// Including the basic of this table, which determines the #bytes in the -// sequence from the lead byte. 1 placed for invalid sequences -- -// although the result will be junk, pass it through as much as possible. -// Beware of the non-characters in UTF-8: -// ef bb bf (Microsoft "lead bytes") -// ef bf be -// ef bf bf - -const unsigned char TIXML_UTF_LEAD_0 = 0xefU; -const unsigned char TIXML_UTF_LEAD_1 = 0xbbU; -const unsigned char TIXML_UTF_LEAD_2 = 0xbfU; - -const int TiXmlBase::utf8ByteTable[256] = -{ - // 0 1 2 3 4 5 6 7 8 9 a b c d e f - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x00 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x10 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x20 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x30 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x40 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x50 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x60 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x70 End of ASCII range - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x80 0x80 to 0xc1 invalid - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0x90 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xa0 - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, // 0xb0 - 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xc0 0xc2 to 0xdf 2 byte - 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, // 0xd0 - 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, // 0xe0 0xe0 to 0xef 3 byte - 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 // 0xf0 0xf0 to 0xf4 4 byte, 0xf5 and higher invalid -}; - - -void TiXmlBase::ConvertUTF32ToUTF8( unsigned long input, char* output, int* length ) -{ - const unsigned long BYTE_MASK = 0xBF; - const unsigned long BYTE_MARK = 0x80; - const unsigned long FIRST_BYTE_MARK[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; - - if (input < 0x80) - *length = 1; - else if ( input < 0x800 ) - *length = 2; - else if ( input < 0x10000 ) - *length = 3; - else if ( input < 0x200000 ) - *length = 4; - else - { *length = 0; return; } // This code won't covert this correctly anyway. - - output += *length; - - // Scary scary fall throughs. - switch (*length) - { - case 4: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 3: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 2: - --output; - *output = (char)((input | BYTE_MARK) & BYTE_MASK); - input >>= 6; - case 1: - --output; - *output = (char)(input | FIRST_BYTE_MARK[*length]); - } -} - - -/*static*/ int TiXmlBase::IsAlpha( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalpha( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalpha( anyByte ); -// } -} - - -/*static*/ int TiXmlBase::IsAlphaNum( unsigned char anyByte, TiXmlEncoding /*encoding*/ ) -{ - // This will only work for low-ascii, everything else is assumed to be a valid - // letter. I'm not sure this is the best approach, but it is quite tricky trying - // to figure out alhabetical vs. not across encoding. So take a very - // conservative approach. - -// if ( encoding == TIXML_ENCODING_UTF8 ) -// { - if ( anyByte < 127 ) - return isalnum( anyByte ); - else - return 1; // What else to do? The unicode set is huge...get the english ones right. -// } -// else -// { -// return isalnum( anyByte ); -// } -} - - -class TiXmlParsingData -{ - friend class TiXmlDocument; - public: - void Stamp( const char* now, TiXmlEncoding encoding ); - - const TiXmlCursor& Cursor() const { return cursor; } - - private: - // Only used by the document! - TiXmlParsingData( const char* start, int _tabsize, int row, int col ) - { - assert( start ); - stamp = start; - tabsize = _tabsize; - cursor.row = row; - cursor.col = col; - } - - TiXmlCursor cursor; - const char* stamp; - int tabsize; -}; - - -void TiXmlParsingData::Stamp( const char* now, TiXmlEncoding encoding ) -{ - assert( now ); - - // Do nothing if the tabsize is 0. - if ( tabsize < 1 ) - { - return; - } - - // Get the current row, column. - int row = cursor.row; - int col = cursor.col; - const char* p = stamp; - assert( p ); - - while ( p < now ) - { - // Treat p as unsigned, so we have a happy compiler. - const unsigned char* pU = (const unsigned char*)p; - - // Code contributed by Fletcher Dunn: (modified by lee) - switch (*pU) { - case 0: - // We *should* never get here, but in case we do, don't - // advance past the terminating null character, ever - return; - - case '\r': - // bump down to the next line - ++row; - col = 0; - // Eat the character - ++p; - - // Check for \r\n sequence, and treat this as a single character - if (*p == '\n') { - ++p; - } - break; - - case '\n': - // bump down to the next line - ++row; - col = 0; - - // Eat the character - ++p; - - // Check for \n\r sequence, and treat this as a single - // character. (Yes, this bizarre thing does occur still - // on some arcane platforms...) - if (*p == '\r') { - ++p; - } - break; - - case '\t': - // Eat the character - ++p; - - // Skip to next tab stop - col = (col / tabsize + 1) * tabsize; - break; - - case TIXML_UTF_LEAD_0: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - if ( *(p+1) && *(p+2) ) - { - // In these cases, don't advance the column. These are - // 0-width spaces. - if ( *(pU+1)==TIXML_UTF_LEAD_1 && *(pU+2)==TIXML_UTF_LEAD_2 ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbeU ) - p += 3; - else if ( *(pU+1)==0xbfU && *(pU+2)==0xbfU ) - p += 3; - else - { p +=3; ++col; } // A normal character. - } - } - else - { - ++p; - ++col; - } - break; - - default: - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // Eat the 1 to 4 byte utf8 character. - int step = TiXmlBase::utf8ByteTable[*((const unsigned char*)p)]; - if ( step == 0 ) - step = 1; // Error case from bad encoding, but handle gracefully. - p += step; - - // Just advance one column, of course. - ++col; - } - else - { - ++p; - ++col; - } - break; - } - } - cursor.row = row; - cursor.col = col; - assert( cursor.row >= -1 ); - assert( cursor.col >= -1 ); - stamp = p; - assert( stamp ); -} - - -const char* TiXmlBase::SkipWhiteSpace( const char* p, TiXmlEncoding encoding ) -{ - if ( !p || !*p ) - { - return 0; - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - while ( *p ) - { - const unsigned char* pU = (const unsigned char*)p; - - // Skip the stupid Microsoft UTF-8 Byte order marks - if ( *(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==TIXML_UTF_LEAD_1 - && *(pU+2)==TIXML_UTF_LEAD_2 ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbeU ) - { - p += 3; - continue; - } - else if(*(pU+0)==TIXML_UTF_LEAD_0 - && *(pU+1)==0xbfU - && *(pU+2)==0xbfU ) - { - p += 3; - continue; - } - - if ( IsWhiteSpace( *p ) ) // Still using old rules for white space. - ++p; - else - break; - } - } - else - { - while ( *p && IsWhiteSpace( *p ) ) - ++p; - } - - return p; -} - -#ifdef TIXML_USE_STL -/*static*/ bool TiXmlBase::StreamWhiteSpace( std::istream * in, TIXML_STRING * tag ) -{ - for( ;; ) - { - if ( !in->good() ) return false; - - int c = in->peek(); - // At this scope, we can't get to a document. So fail silently. - if ( !IsWhiteSpace( c ) || c <= 0 ) - return true; - - *tag += (char) in->get(); - } -} - -/*static*/ bool TiXmlBase::StreamTo( std::istream * in, int character, TIXML_STRING * tag ) -{ - //assert( character > 0 && character < 128 ); // else it won't work in utf-8 - while ( in->good() ) - { - int c = in->peek(); - if ( c == character ) - return true; - if ( c <= 0 ) // Silent failure: can't get document at this scope - return false; - - in->get(); - *tag += (char) c; - } - return false; -} -#endif - -// One of TinyXML's more performance demanding functions. Try to keep the memory overhead down. The -// "assign" optimization removes over 10% of the execution time. -// -const char* TiXmlBase::ReadName( const char* p, TIXML_STRING * name, TiXmlEncoding encoding ) -{ - // Oddly, not supported on some comilers, - //name->clear(); - // So use this: - *name = ""; - assert( p ); - - // Names start with letters or underscores. - // Of course, in unicode, tinyxml has no idea what a letter *is*. The - // algorithm is generous. - // - // After that, they can be letters, underscores, numbers, - // hyphens, or colons. (Colons are valid ony for namespaces, - // but tinyxml can't tell namespaces from names.) - if ( p && *p - && ( IsAlpha( (unsigned char) *p, encoding ) || *p == '_' ) ) - { - const char* start = p; - while( p && *p - && ( IsAlphaNum( (unsigned char ) *p, encoding ) - || *p == '_' - || *p == '-' - || *p == '.' - || *p == ':' ) ) - { - //(*name) += *p; // expensive - ++p; - } - if ( p-start > 0 ) { - name->assign( start, p-start ); - } - return p; - } - return 0; -} - -const char* TiXmlBase::GetEntity( const char* p, char* value, int* length, TiXmlEncoding encoding ) -{ - // Presume an entity, and pull it out. - TIXML_STRING ent; - int i; - *length = 0; - - if ( *(p+1) && *(p+1) == '#' && *(p+2) ) - { - unsigned long ucs = 0; - ptrdiff_t delta = 0; - unsigned mult = 1; - - if ( *(p+2) == 'x' ) - { - // Hexadecimal. - if ( !*(p+3) ) return 0; - - const char* q = p+3; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != 'x' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else if ( *q >= 'a' && *q <= 'f' ) - ucs += mult * (*q - 'a' + 10); - else if ( *q >= 'A' && *q <= 'F' ) - ucs += mult * (*q - 'A' + 10 ); - else - return 0; - mult *= 16; - --q; - } - } - else - { - // Decimal. - if ( !*(p+2) ) return 0; - - const char* q = p+2; - q = strchr( q, ';' ); - - if ( !q || !*q ) return 0; - - delta = q-p; - --q; - - while ( *q != '#' ) - { - if ( *q >= '0' && *q <= '9' ) - ucs += mult * (*q - '0'); - else - return 0; - mult *= 10; - --q; - } - } - if ( encoding == TIXML_ENCODING_UTF8 ) - { - // convert the UCS to UTF-8 - ConvertUTF32ToUTF8( ucs, value, length ); - } - else - { - *value = (char)ucs; - *length = 1; - } - return p + delta + 1; - } - - // Now try to match it. - for( i=0; iappend( cArr, len ); - } - } - else - { - bool whitespace = false; - - // Remove leading white space: - p = SkipWhiteSpace( p, encoding ); - while ( p && *p - && !StringEqual( p, endTag, caseInsensitive, encoding ) ) - { - if ( *p == '\r' || *p == '\n' ) - { - whitespace = true; - ++p; - } - else if ( IsWhiteSpace( *p ) ) - { - whitespace = true; - ++p; - } - else - { - // If we've found whitespace, add it before the - // new character. Any whitespace just becomes a space. - if ( whitespace ) - { - (*text) += ' '; - whitespace = false; - } - int len; - char cArr[4] = { 0, 0, 0, 0 }; - p = GetChar( p, cArr, &len, encoding ); - if ( len == 1 ) - (*text) += cArr[0]; // more efficient - else - text->append( cArr, len ); - } - } - } - if ( p && *p ) - p += strlen( endTag ); - return ( p && *p ) ? p : 0; -} - -#ifdef TIXML_USE_STL - -void TiXmlDocument::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - // The basic issue with a document is that we don't know what we're - // streaming. Read something presumed to be a tag (and hope), then - // identify it, and call the appropriate stream method on the tag. - // - // This "pre-streaming" will never read the closing ">" so the - // sub-tag can orient itself. - - if ( !StreamTo( in, '<', tag ) ) - { - SetError( TIXML_ERROR_PARSING_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - while ( in->good() ) - { - int tagIndex = (int) tag->length(); - while ( in->good() && in->peek() != '>' ) - { - int c = in->get(); - if ( c <= 0 ) - { - SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - break; - } - (*tag) += (char) c; - } - - if ( in->good() ) - { - // We now have something we presume to be a node of - // some sort. Identify it, and call the node to - // continue streaming. - TiXmlNode* node = Identify( tag->c_str() + tagIndex, TIXML_DEFAULT_ENCODING ); - - if ( node ) - { - node->StreamIn( in, tag ); - bool isElement = node->ToElement() != 0; - delete node; - node = 0; - - // If this is the root element, we're done. Parsing will be - // done by the >> operator. - if ( isElement ) - { - return; - } - } - else - { - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - } - } - // We should have returned sooner. - SetError( TIXML_ERROR, 0, 0, TIXML_ENCODING_UNKNOWN ); -} - -#endif - -const char* TiXmlDocument::Parse( const char* p, TiXmlParsingData* prevData, TiXmlEncoding encoding ) -{ - ClearError(); - - // Parse away, at the document level. Since a document - // contains nothing but other tags, most of what happens - // here is skipping white space. - if ( !p || !*p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - // Note that, for a document, this needs to come - // before the while space skip, so that parsing - // starts from the pointer we are given. - location.Clear(); - if ( prevData ) - { - location.row = prevData->cursor.row; - location.col = prevData->cursor.col; - } - else - { - location.row = 0; - location.col = 0; - } - TiXmlParsingData data( p, TabSize(), location.row, location.col ); - location = data.Cursor(); - - if ( encoding == TIXML_ENCODING_UNKNOWN ) - { - // Check for the Microsoft UTF-8 lead bytes. - const unsigned char* pU = (const unsigned char*)p; - if ( *(pU+0) && *(pU+0) == TIXML_UTF_LEAD_0 - && *(pU+1) && *(pU+1) == TIXML_UTF_LEAD_1 - && *(pU+2) && *(pU+2) == TIXML_UTF_LEAD_2 ) - { - encoding = TIXML_ENCODING_UTF8; - useMicrosoftBOM = true; - } - } - - p = SkipWhiteSpace( p, encoding ); - if ( !p ) - { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, TIXML_ENCODING_UNKNOWN ); - return 0; - } - - while ( p && *p ) - { - TiXmlNode* node = Identify( p, encoding ); - if ( node ) - { - p = node->Parse( p, &data, encoding ); - LinkEndChild( node ); - } - else - { - break; - } - - // Did we get encoding info? - if ( encoding == TIXML_ENCODING_UNKNOWN - && node->ToDeclaration() ) - { - TiXmlDeclaration* dec = node->ToDeclaration(); - const char* enc = dec->Encoding(); - assert( enc ); - - if ( *enc == 0 ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF-8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; - else if ( StringEqual( enc, "UTF8", true, TIXML_ENCODING_UNKNOWN ) ) - encoding = TIXML_ENCODING_UTF8; // incorrect, but be nice - else - encoding = TIXML_ENCODING_LEGACY; - } - - p = SkipWhiteSpace( p, encoding ); - } - - // Was this empty? - if ( !firstChild ) { - SetError( TIXML_ERROR_DOCUMENT_EMPTY, 0, 0, encoding ); - return 0; - } - - // All is well. - return p; -} - -void TiXmlDocument::SetError( int err, const char* pError, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - // The first error in a chain is more accurate - don't set again! - if ( error ) - return; - - assert( err > 0 && err < TIXML_ERROR_STRING_COUNT ); - error = true; - errorId = err; - errorDesc = errorString[ errorId ]; - - errorLocation.Clear(); - if ( pError && data ) - { - data->Stamp( pError, encoding ); - errorLocation = data->Cursor(); - } -} - - -TiXmlNode* TiXmlNode::Identify( const char* p, TiXmlEncoding encoding ) -{ - TiXmlNode* returnNode = 0; - - p = SkipWhiteSpace( p, encoding ); - if( !p || !*p || *p != '<' ) - { - return 0; - } - - p = SkipWhiteSpace( p, encoding ); - - if ( !p || !*p ) - { - return 0; - } - - // What is this thing? - // - Elements start with a letter or underscore, but xml is reserved. - // - Comments: "; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - if ( document ) - document->SetError( TIXML_ERROR_PARSING_COMMENT, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // [ 1475201 ] TinyXML parses entities in comments - // Oops - ReadText doesn't work, because we don't want to parse the entities. - // p = ReadText( p, &value, false, endTag, false, encoding ); - // - // from the XML spec: - /* - [Definition: Comments may appear anywhere in a document outside other markup; in addition, - they may appear within the document type declaration at places allowed by the grammar. - They are not part of the document's character data; an XML processor MAY, but need not, - make it possible for an application to retrieve the text of comments. For compatibility, - the string "--" (double-hyphen) MUST NOT occur within comments.] Parameter entity - references MUST NOT be recognized within comments. - - An example of a comment: - - - */ - - value = ""; - // Keep all the white space. - while ( p && *p && !StringEqual( p, endTag, false, encoding ) ) - { - value.append( p, 1 ); - ++p; - } - if ( p && *p ) - p += strlen( endTag ); - - return p; -} - - -const char* TiXmlAttribute::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) return 0; - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - // Read the name, the '=' and the value. - const char* pErr = p; - p = ReadName( p, &name, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, pErr, data, encoding ); - return 0; - } - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p || *p != '=' ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - ++p; // skip '=' - p = SkipWhiteSpace( p, encoding ); - if ( !p || !*p ) - { - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - - const char* end; - const char SINGLE_QUOTE = '\''; - const char DOUBLE_QUOTE = '\"'; - - if ( *p == SINGLE_QUOTE ) - { - ++p; - end = "\'"; // single quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else if ( *p == DOUBLE_QUOTE ) - { - ++p; - end = "\""; // double quote in string - p = ReadText( p, &value, false, end, false, encoding ); - } - else - { - // All attribute values should be in single or double quotes. - // But this is such a common error that the parser will try - // its best, even without them. - value = ""; - while ( p && *p // existence - && !IsWhiteSpace( *p ) // whitespace - && *p != '/' && *p != '>' ) // tag end - { - if ( *p == SINGLE_QUOTE || *p == DOUBLE_QUOTE ) { - // [ 1451649 ] Attribute values with trailing quotes not handled correctly - // We did not have an opening quote but seem to have a - // closing one. Give up and throw an error. - if ( document ) document->SetError( TIXML_ERROR_READING_ATTRIBUTES, p, data, encoding ); - return 0; - } - value += *p; - ++p; - } - } - return p; -} - -#ifdef TIXML_USE_STL -void TiXmlText::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->peek(); - if ( !cdata && (c == '<' ) ) - { - return; - } - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - - (*tag) += (char) c; - in->get(); // "commits" the peek made above - - if ( cdata && c == '>' && tag->size() >= 3 ) { - size_t len = tag->size(); - if ( (*tag)[len-2] == ']' && (*tag)[len-3] == ']' ) { - // terminator of cdata. - return; - } - } - } -} -#endif - -const char* TiXmlText::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding encoding ) -{ - value = ""; - TiXmlDocument* document = GetDocument(); - - if ( data ) - { - data->Stamp( p, encoding ); - location = data->Cursor(); - } - - const char* const startTag = ""; - - if ( cdata || StringEqual( p, startTag, false, encoding ) ) - { - cdata = true; - - if ( !StringEqual( p, startTag, false, encoding ) ) - { - if ( document ) - document->SetError( TIXML_ERROR_PARSING_CDATA, p, data, encoding ); - return 0; - } - p += strlen( startTag ); - - // Keep all the white space, ignore the encoding, etc. - while ( p && *p - && !StringEqual( p, endTag, false, encoding ) - ) - { - value += *p; - ++p; - } - - TIXML_STRING dummy; - p = ReadText( p, &dummy, false, endTag, false, encoding ); - return p; - } - else - { - bool ignoreWhite = true; - - const char* end = "<"; - p = ReadText( p, &value, ignoreWhite, end, false, encoding ); - if ( p && *p ) - return p-1; // don't truncate the '<' - return 0; - } -} - -#ifdef TIXML_USE_STL -void TiXmlDeclaration::StreamIn( std::istream * in, TIXML_STRING * tag ) -{ - while ( in->good() ) - { - int c = in->get(); - if ( c <= 0 ) - { - TiXmlDocument* document = GetDocument(); - if ( document ) - document->SetError( TIXML_ERROR_EMBEDDED_NULL, 0, 0, TIXML_ENCODING_UNKNOWN ); - return; - } - (*tag) += (char) c; - - if ( c == '>' ) - { - // All is well. - return; - } - } -} -#endif - -const char* TiXmlDeclaration::Parse( const char* p, TiXmlParsingData* data, TiXmlEncoding _encoding ) -{ - p = SkipWhiteSpace( p, _encoding ); - // Find the beginning, find the end, and look for - // the stuff in-between. - TiXmlDocument* document = GetDocument(); - if ( !p || !*p || !StringEqual( p, "SetError( TIXML_ERROR_PARSING_DECLARATION, 0, 0, _encoding ); - return 0; - } - if ( data ) - { - data->Stamp( p, _encoding ); - location = data->Cursor(); - } - p += 5; - - version = ""; - encoding = ""; - standalone = ""; - - while ( p && *p ) - { - if ( *p == '>' ) - { - ++p; - return p; - } - - p = SkipWhiteSpace( p, _encoding ); - if ( StringEqual( p, "version", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - version = attrib.Value(); - } - else if ( StringEqual( p, "encoding", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - encoding = attrib.Value(); - } - else if ( StringEqual( p, "standalone", true, _encoding ) ) - { - TiXmlAttribute attrib; - p = attrib.Parse( p, data, _encoding ); - standalone = attrib.Value(); - } - else - { - // Read over whatever it is. - while( p && *p && *p != '>' && !IsWhiteSpace( *p ) ) - ++p; - } - } - return 0; -} - -bool TiXmlText::Blank() const -{ - for ( unsigned i=0; i + + + + + + + + \ No newline at end of file diff --git a/data/plane_transparent.mtl b/data/plane_transparent.mtl index 6b700a066..8ce3f6b30 100644 --- a/data/plane_transparent.mtl +++ b/data/plane_transparent.mtl @@ -9,6 +9,6 @@ newmtl Material Kd 0.5880 0.5880 0.5880 Ks 0.0000 0.0000 0.0000 Ke 0.0000 0.0000 0.0000 - map_Kd tex4x4.png + map_Kd checker_blue.png diff --git a/data/plane_transparent.obj b/data/plane_transparent.obj index b1317066e..02e572bcc 100644 --- a/data/plane_transparent.obj +++ b/data/plane_transparent.obj @@ -7,9 +7,9 @@ v 15.000000 15.000000 0.000000 v -15.000000 15.000000 0.000000 v -15.000000 -15.000000 0.000000 -vt 1.000000 0.000000 -vt 1.000000 1.000000 -vt 0.000000 1.000000 +vt 15.000000 0.000000 +vt 15.000000 15.000000 +vt 0.000000 15.000000 vt 0.000000 0.000000 usemtl Material diff --git a/data/plane_transparent.urdf b/data/plane_transparent.urdf index 1634fd4b7..15deeac4a 100644 --- a/data/plane_transparent.urdf +++ b/data/plane_transparent.urdf @@ -12,7 +12,7 @@ - + diff --git a/data/toys/concave_box.cdf b/data/toys/concave_box.cdf new file mode 100644 index 000000000..1183762d8 Binary files /dev/null and b/data/toys/concave_box.cdf differ diff --git a/data/toys/concave_box.mtl b/data/toys/concave_box.mtl new file mode 100644 index 000000000..35c3a209b --- /dev/null +++ b/data/toys/concave_box.mtl @@ -0,0 +1,11 @@ +# Blender MTL File: 'None' +# Material Count: 1 + +newmtl None +Ns 0 +Ka 0.000000 0.000000 0.000000 +Kd 0.8 0.8 0.8 +Ks 0.8 0.8 0.8 +d 1 +illum 2 +map_Kd ../checker_grid.jpg diff --git a/data/toys/concave_box.obj b/data/toys/concave_box.obj new file mode 100644 index 000000000..bc58715ec --- /dev/null +++ b/data/toys/concave_box.obj @@ -0,0 +1,949 @@ +# Blender v2.78 (sub 0) OBJ File: '' +# www.blender.org +mtllib concave_box.mtl +o Cube_Cube.003 +v 0.252358 -0.051546 0.073254 +v 0.196823 -0.040500 0.026785 +v 0.133463 -0.027897 -0.007745 +v 0.064714 -0.014222 -0.029009 +v 0.237323 -0.101112 0.073254 +v 0.185009 -0.079443 0.026785 +v 0.125326 -0.054721 -0.007745 +v 0.060565 -0.027897 -0.029009 +v 0.212906 -0.146792 0.073254 +v 0.165826 -0.115334 0.026785 +v 0.112112 -0.079443 -0.007745 +v 0.053829 -0.040500 -0.029009 +v 0.180047 -0.186831 0.073254 +v 0.140008 -0.146792 0.026785 +v 0.094329 -0.101112 -0.007745 +v 0.044763 -0.051546 -0.029009 +v 0.140008 -0.219690 0.073254 +v 0.108550 -0.172609 0.026785 +v 0.072660 -0.118895 -0.007745 +v 0.033716 -0.060612 -0.029009 +v -0.006783 -0.000000 -0.036189 +v 0.094329 -0.244106 0.073254 +v 0.072660 -0.191793 0.026785 +v 0.047938 -0.132109 -0.007745 +v 0.021113 -0.067349 -0.029009 +v 0.044763 -0.259142 0.073254 +v 0.033716 -0.203606 0.026785 +v 0.021113 -0.140246 -0.007745 +v 0.007438 -0.071497 -0.029009 +v -0.006783 -0.264218 0.073254 +v -0.006783 -0.207595 0.026785 +v -0.006783 -0.142994 -0.007745 +v -0.006783 -0.072898 -0.029009 +v -0.058330 -0.259142 0.073254 +v -0.047283 -0.203606 0.026785 +v -0.034680 -0.140246 -0.007745 +v -0.021005 -0.071497 -0.029009 +v -0.107895 -0.244106 0.073254 +v -0.086227 -0.191793 0.026785 +v -0.061505 -0.132109 -0.007745 +v -0.034680 -0.067349 -0.029009 +v -0.153575 -0.219690 0.073254 +v -0.122117 -0.172609 0.026785 +v -0.086227 -0.118895 -0.007745 +v -0.047283 -0.060612 -0.029009 +v -0.193614 -0.186831 0.073254 +v -0.153575 -0.146792 0.026785 +v -0.107895 -0.101112 -0.007745 +v -0.058330 -0.051546 -0.029009 +v -0.226473 -0.146792 0.073254 +v -0.179392 -0.115334 0.026785 +v -0.125679 -0.079443 -0.007745 +v -0.067396 -0.040500 -0.029009 +v -0.250889 -0.101112 0.073254 +v -0.198576 -0.079443 0.026785 +v -0.138893 -0.054721 -0.007745 +v -0.074132 -0.027897 -0.029009 +v -0.265925 -0.051546 0.073254 +v -0.210390 -0.040500 0.026785 +v -0.147030 -0.027897 -0.007745 +v -0.078280 -0.014222 -0.029009 +v -0.271002 0.000000 0.073254 +v -0.214378 0.000000 0.026785 +v -0.149777 -0.000000 -0.007745 +v -0.079681 -0.000000 -0.029009 +v -0.265925 0.051546 0.073254 +v -0.210390 0.040500 0.026785 +v -0.147030 0.027897 -0.007745 +v -0.078280 0.014222 -0.029009 +v -0.250889 0.101112 0.073254 +v -0.198576 0.079443 0.026785 +v -0.138893 0.054721 -0.007745 +v -0.074132 0.027897 -0.029009 +v -0.226473 0.146792 0.073254 +v -0.179392 0.115334 0.026785 +v -0.125679 0.079443 -0.007745 +v -0.067396 0.040500 -0.029009 +v -0.193614 0.186831 0.073254 +v -0.153575 0.146792 0.026785 +v -0.107895 0.101112 -0.007745 +v -0.058330 0.051546 -0.029009 +v -0.153575 0.219690 0.073254 +v -0.122117 0.172609 0.026785 +v -0.086227 0.118895 -0.007745 +v -0.047283 0.060612 -0.029009 +v -0.107895 0.244106 0.073254 +v -0.086227 0.191793 0.026785 +v -0.061505 0.132109 -0.007745 +v -0.034680 0.067349 -0.029009 +v -0.058330 0.259141 0.073254 +v -0.047283 0.203606 0.026785 +v -0.034680 0.140246 -0.007745 +v -0.021005 0.071497 -0.029009 +v -0.006783 0.264218 0.073254 +v -0.006783 0.207595 0.026785 +v -0.006783 0.142994 -0.007745 +v -0.006783 0.072898 -0.029009 +v 0.044763 0.259141 0.073254 +v 0.033716 0.203606 0.026785 +v 0.021113 0.140246 -0.007745 +v 0.007438 0.071497 -0.029009 +v 0.094329 0.244106 0.073254 +v 0.072660 0.191793 0.026785 +v 0.047938 0.132109 -0.007745 +v 0.021113 0.067349 -0.029009 +v 0.140008 0.219689 0.073254 +v 0.108550 0.172609 0.026785 +v 0.072660 0.118895 -0.007745 +v 0.033716 0.060612 -0.029009 +v 0.180047 0.186831 0.073254 +v 0.140008 0.146792 0.026785 +v 0.094328 0.101112 -0.007745 +v 0.044763 0.051546 -0.029009 +v 0.212906 0.146792 0.073254 +v 0.165825 0.115334 0.026785 +v 0.112112 0.079443 -0.007745 +v 0.053829 0.040500 -0.029009 +v 0.237322 0.101112 0.073254 +v 0.185009 0.079443 0.026785 +v 0.125326 0.054721 -0.007745 +v 0.060565 0.027897 -0.029009 +v 0.252358 0.051546 0.073254 +v 0.196823 0.040500 0.026785 +v 0.133463 0.027897 -0.007745 +v 0.064713 0.014222 -0.029009 +v 0.257435 -0.000000 0.073254 +v 0.200811 -0.000000 0.026785 +v 0.136210 -0.000000 -0.007745 +v 0.066114 -0.000000 -0.029009 +v -1.000000 1.000000 -0.100000 +v -1.000000 1.000000 0.100000 +v 1.000000 1.000000 -0.100000 +v 1.000000 1.000000 0.100000 +v -1.000000 -1.000000 -0.100000 +v -1.000000 -1.000000 0.100000 +v 1.000000 -1.000000 -0.100000 +v 1.000000 -1.000000 0.100000 +v -0.006783 -0.286168 0.100000 +v -0.062612 -0.280669 0.100000 +v 0.195568 -0.202351 0.100000 +v 0.231157 -0.158987 0.100000 +v 0.257601 -0.109512 0.100000 +v 0.195568 0.202351 0.100000 +v -0.209135 0.202351 0.100000 +v 0.273886 -0.055829 0.100000 +v 0.273886 0.055829 0.100000 +v 0.257601 0.109512 0.100000 +v 0.152203 0.237940 0.100000 +v -0.209135 -0.202351 0.100000 +v -0.165770 -0.237940 0.100000 +v -0.244724 -0.158986 0.100000 +v -0.116295 -0.264385 0.100000 +v -0.244723 0.158986 0.100000 +v -0.165770 0.237940 0.100000 +v -0.116295 0.264385 0.100000 +v 0.231156 0.158986 0.100000 +v -0.271168 -0.109512 0.100000 +v -0.287453 0.055829 0.100000 +v -0.292951 0.000000 0.100000 +v 0.279384 -0.000000 0.100000 +v 0.102728 -0.264385 0.100000 +v 0.049045 0.280669 0.100000 +v 0.049045 -0.280669 0.100000 +v -0.287453 -0.055829 0.100000 +v -0.062612 0.280669 0.100000 +v -0.006783 0.286168 0.100000 +v 0.152203 -0.237940 0.100000 +v 0.102728 0.264385 0.100000 +v -0.271168 0.109512 0.100000 +vt 0.5258 0.8663 +vt 0.5000 1.0000 +vt 0.5000 0.8663 +vt 0.5202 0.6339 +vt 0.5000 0.6339 +vt 0.5139 0.4613 +vt 0.5000 0.4613 +vt 0.5071 0.3550 +vt 0.5000 0.3550 +vt 0.5000 0.4966 +vt 0.5071 0.5324 +vt 0.5000 0.5331 +vt 0.5139 0.5303 +vt 0.5506 0.8663 +vt 0.5279 1.0000 +vt 0.5274 0.4613 +vt 0.5139 0.3550 +vt 0.5734 0.8663 +vt 0.5548 1.0000 +vt 0.5577 0.6339 +vt 0.5397 0.6339 +vt 0.5397 0.4613 +vt 0.5202 0.3550 +vt 0.5202 0.5269 +vt 0.5258 0.5224 +vt 0.6012 1.0000 +vt 0.5795 1.0000 +vt 0.5734 0.6339 +vt 0.5506 0.4613 +vt 0.5258 0.3550 +vt 0.5700 0.6339 +vt 0.5700 0.8663 +vt 0.5900 0.8663 +vt 0.5363 0.4613 +vt 0.5472 0.4613 +vt 0.5169 0.3550 +vt 0.5224 0.3550 +vt 0.5303 0.5169 +vt 0.5978 1.0000 +vt 0.5514 1.0000 +vt 0.5761 1.0000 +vt 0.5543 0.6339 +vt 0.5472 0.8663 +vt 0.5363 0.6339 +vt 0.5240 0.4613 +vt 0.5337 0.5106 +vt 0.5224 0.8663 +vt 0.5106 0.4613 +vt 0.5106 0.3550 +vt 0.5357 0.5037 +vt 0.4966 1.0000 +vt 0.5245 1.0000 +vt 0.5169 0.6339 +vt 0.4966 0.8663 +vt 0.4966 0.6339 +vt 0.5037 0.3550 +vt 0.4966 0.4613 +vt 0.5364 0.4966 +vt 0.4827 0.4613 +vt 0.4895 0.3550 +vt 0.4966 0.3550 +vt 0.5357 0.4895 +vt 0.4708 0.8663 +vt 0.4461 0.8663 +vt 0.4687 1.0000 +vt 0.4764 0.6339 +vt 0.4569 0.6339 +vt 0.4692 0.4613 +vt 0.5337 0.4827 +vt 0.4827 0.3550 +vt 0.4569 0.4613 +vt 0.5303 0.4764 +vt 0.4232 0.8663 +vt 0.4419 1.0000 +vt 0.4389 0.6339 +vt 0.4032 0.8663 +vt 0.4171 1.0000 +vt 0.4232 0.6339 +vt 0.4708 0.3550 +vt 0.4764 0.3550 +vt 0.5258 0.4708 +vt 0.5202 0.3550 +vt 0.5506 0.4613 +vt 0.5258 0.3550 +vt 0.5202 0.4663 +vt 0.5734 0.8663 +vt 0.6012 1.0000 +vt 0.5934 0.8663 +vt 0.5734 0.6339 +vt 0.5577 0.6339 +vt 0.5506 0.8663 +vt 0.5795 1.0000 +vt 0.5274 0.4613 +vt 0.5397 0.4613 +vt 0.5139 0.4629 +vt 0.5071 0.4609 +vt 0.5279 1.0000 +vt 0.5548 1.0000 +vt 0.5202 0.6339 +vt 0.5397 0.6339 +vt 0.5139 0.4613 +vt 0.5071 0.3550 +vt 0.5139 0.3550 +vt 0.5000 0.8663 +vt 0.5258 0.8663 +vt 0.5000 0.6339 +vt 0.5000 0.4613 +vt 0.5000 0.4602 +vt 0.4929 0.4609 +vt 0.4742 0.8663 +vt 0.5000 1.0000 +vt 0.4798 0.6339 +vt 0.4861 0.4613 +vt 0.4929 0.3550 +vt 0.5000 0.3550 +vt 0.4603 0.6339 +vt 0.4726 0.4613 +vt 0.4861 0.4629 +vt 0.4494 0.8663 +vt 0.4721 1.0000 +vt 0.4266 0.8663 +vt 0.4452 1.0000 +vt 0.4603 0.4613 +vt 0.4861 0.3550 +vt 0.4798 0.4663 +vt 0.4266 0.6339 +vt 0.4423 0.6339 +vt 0.4742 0.3550 +vt 0.4798 0.3550 +vt 0.4742 0.4708 +vt 0.4066 0.8663 +vt 0.4205 1.0000 +vt 0.4232 0.8663 +vt 0.3954 1.0000 +vt 0.4032 0.8663 +vt 0.4389 0.6339 +vt 0.4232 0.6339 +vt 0.4569 0.4613 +vt 0.4461 0.4613 +vt 0.4708 0.3550 +vt 0.4697 0.4764 +vt 0.4569 0.6339 +vt 0.4827 0.3550 +vt 0.4764 0.3550 +vt 0.4663 0.4827 +vt 0.4461 0.8663 +vt 0.4171 1.0000 +vt 0.4708 0.8663 +vt 0.4419 1.0000 +vt 0.4764 0.6339 +vt 0.4827 0.4613 +vt 0.4692 0.4613 +vt 0.4895 0.3550 +vt 0.4643 0.4895 +vt 0.4966 0.3550 +vt 0.4636 0.4966 +vt 0.4966 0.8663 +vt 0.4687 1.0000 +vt 0.4966 0.6339 +vt 0.5224 0.8663 +vt 0.4966 1.0000 +vt 0.5169 0.6339 +vt 0.4966 0.4613 +vt 0.5037 0.3550 +vt 0.4643 0.5037 +vt 0.5106 0.3550 +vt 0.5106 0.4613 +vt 0.4663 0.5106 +vt 0.5472 0.8663 +vt 0.5245 1.0000 +vt 0.5363 0.6339 +vt 0.5240 0.4613 +vt 0.5700 0.8663 +vt 0.5514 1.0000 +vt 0.5363 0.4613 +vt 0.5169 0.3550 +vt 0.4697 0.5169 +vt 0.4742 0.5224 +vt 0.5900 0.8663 +vt 0.5761 1.0000 +vt 0.5700 0.6339 +vt 0.5543 0.6339 +vt 0.5224 0.3550 +vt 0.4423 0.6339 +vt 0.4066 0.8663 +vt 0.4266 0.6339 +vt 0.4603 0.4613 +vt 0.4494 0.4613 +vt 0.4798 0.3550 +vt 0.4742 0.3550 +vt 0.4798 0.5269 +vt 0.4266 0.8663 +vt 0.3988 1.0000 +vt 0.4494 0.8663 +vt 0.4205 1.0000 +vt 0.4603 0.6339 +vt 0.4861 0.3550 +vt 0.4861 0.5303 +vt 0.4798 0.6339 +vt 0.4861 0.4613 +vt 0.4726 0.4613 +vt 0.4929 0.3550 +vt 0.4929 0.5324 +vt 0.4742 0.8663 +vt 0.4452 1.0000 +vt 0.4721 1.0000 +vt 0.0000 1.0000 +vt 1.0000 0.0000 +vt 0.0000 0.0000 +vt 0.0000 1.0000 +vt 1.0000 0.0000 +vt 0.0000 0.0000 +vt 0.0000 1.0000 +vt -1.0000 0.0000 +vt 0.0000 0.0000 +vt 0.0000 1.0000 +vt -1.0000 0.0000 +vt 0.0000 0.0000 +vt 0.0000 -1.0000 +vt -1.0000 0.0000 +vt -0.5279 -0.3631 +vt -0.5000 -0.3603 +vt -0.5000 0.3535 +vt -0.5279 0.3563 +vt -1.0000 0.0000 +vt 0.5934 0.8663 +vt 0.3954 1.0000 +vt 0.4461 0.4613 +vt 0.4494 0.4613 +vt 0.3988 1.0000 +vt 0.5978 1.0000 +vt 0.5472 0.4613 +vt 1.0000 1.0000 +vt 1.0000 1.0000 +vt -1.0000 1.0000 +vt -1.0000 1.0000 +vt 1.0000 -1.0000 +vt -1.0000 -1.0000 +vt -0.6431 -0.5034 +vt -0.6403 -0.4755 +vt -0.3569 -0.5034 +vt 0.0000 -1.0000 +vt 0.0000 0.0000 +vt -0.3597 -0.4755 +vt -0.6322 -0.4486 +vt -0.6190 -0.4239 +vt -0.3678 -0.4486 +vt -0.3810 -0.4239 +vt -0.6012 -0.4022 +vt -0.5795 -0.3844 +vt -0.3988 -0.4022 +vt -0.4205 -0.3844 +vt -0.5548 -0.3712 +vt -0.4452 -0.3712 +vt -0.4721 -0.3631 +vt 0.0000 0.0000 +vt -0.3569 0.4966 +vt -0.3597 0.4687 +vt -0.3678 0.4419 +vt -0.6403 0.4687 +vt -0.6431 0.4966 +vt -0.6322 0.4419 +vt -0.3810 0.4171 +vt -0.3988 0.3954 +vt -0.6190 0.4171 +vt -0.6012 0.3954 +vt -0.4205 0.3776 +vt -0.4452 0.3644 +vt -0.5795 0.3776 +vt -0.5548 0.3644 +vt -0.4721 0.3563 +vn -0.7708 0.0759 0.6326 +vn -0.6332 0.0624 0.7715 +vn -0.4709 0.0464 0.8810 +vn -0.2902 0.0286 0.9565 +vn -0.0980 0.0097 0.9951 +vn -0.0942 0.0286 0.9951 +vn -0.7412 0.2248 0.6326 +vn -0.6088 0.1847 0.7715 +vn -0.4528 0.1374 0.8810 +vn -0.2790 0.0846 0.9565 +vn -0.6831 0.3651 0.6326 +vn -0.5611 0.2999 0.7715 +vn -0.4173 0.2230 0.8810 +vn -0.2571 0.1374 0.9565 +vn -0.0869 0.0464 0.9951 +vn -0.0761 0.0625 0.9951 +vn -0.5987 0.4913 0.6326 +vn -0.4918 0.4036 0.7715 +vn -0.3658 0.3002 0.8810 +vn -0.2254 0.1850 0.9565 +vn -0.4036 0.4918 0.7715 +vn -0.3002 0.3658 0.8810 +vn -0.1850 0.2254 0.9565 +vn -0.0625 0.0761 0.9951 +vn -0.4913 0.5987 0.6326 +vn -0.3651 0.6831 0.6326 +vn -0.2999 0.5611 0.7715 +vn -0.2230 0.4173 0.8810 +vn -0.1374 0.2571 0.9565 +vn -0.0464 0.0869 0.9951 +vn -0.1847 0.6088 0.7715 +vn -0.1374 0.4528 0.8810 +vn -0.0846 0.2790 0.9565 +vn -0.0286 0.0942 0.9951 +vn -0.2248 0.7412 0.6326 +vn -0.0759 0.7708 0.6326 +vn -0.0624 0.6332 0.7715 +vn -0.0464 0.4709 0.8810 +vn -0.0286 0.2902 0.9565 +vn -0.0097 0.0980 0.9951 +vn 0.0464 0.4709 0.8810 +vn 0.0286 0.2902 0.9565 +vn 0.0097 0.0980 0.9951 +vn 0.0759 0.7708 0.6326 +vn 0.0624 0.6332 0.7715 +vn 0.2248 0.7412 0.6326 +vn 0.1847 0.6088 0.7715 +vn 0.1374 0.4528 0.8810 +vn 0.0846 0.2790 0.9565 +vn 0.0286 0.0942 0.9951 +vn 0.1374 0.2571 0.9565 +vn 0.0464 0.0869 0.9951 +vn 0.3651 0.6831 0.6326 +vn 0.2999 0.5611 0.7715 +vn 0.2230 0.4173 0.8810 +vn 0.4913 0.5987 0.6326 +vn 0.4036 0.4918 0.7715 +vn 0.3002 0.3658 0.8810 +vn 0.1850 0.2254 0.9565 +vn 0.0625 0.0761 0.9951 +vn 0.2254 0.1850 0.9565 +vn 0.0761 0.0625 0.9951 +vn 0.5987 0.4913 0.6326 +vn 0.4918 0.4036 0.7715 +vn 0.3658 0.3002 0.8810 +vn 0.6831 0.3651 0.6326 +vn 0.5611 0.2999 0.7715 +vn 0.4173 0.2230 0.8810 +vn 0.2571 0.1374 0.9565 +vn 0.0869 0.0464 0.9951 +vn 0.0942 0.0286 0.9951 +vn 0.7412 0.2248 0.6326 +vn 0.6088 0.1847 0.7715 +vn 0.4528 0.1374 0.8810 +vn 0.2790 0.0846 0.9565 +vn 0.7708 0.0759 0.6326 +vn 0.6332 0.0624 0.7715 +vn 0.4709 0.0464 0.8810 +vn 0.2902 0.0286 0.9565 +vn 0.0980 0.0097 0.9951 +vn 0.0980 -0.0097 0.9951 +vn 0.7708 -0.0759 0.6326 +vn 0.6332 -0.0624 0.7715 +vn 0.4709 -0.0464 0.8810 +vn 0.2902 -0.0286 0.9565 +vn 0.6088 -0.1847 0.7715 +vn 0.4528 -0.1374 0.8810 +vn 0.2790 -0.0846 0.9565 +vn 0.0942 -0.0286 0.9951 +vn 0.7412 -0.2248 0.6326 +vn 0.6831 -0.3651 0.6326 +vn 0.5611 -0.2999 0.7715 +vn 0.4173 -0.2230 0.8810 +vn 0.2571 -0.1374 0.9565 +vn 0.0869 -0.0464 0.9951 +vn 0.3658 -0.3002 0.8810 +vn 0.2254 -0.1850 0.9565 +vn 0.0761 -0.0625 0.9951 +vn 0.5987 -0.4913 0.6326 +vn 0.4918 -0.4036 0.7715 +vn 0.4913 -0.5987 0.6326 +vn 0.4036 -0.4918 0.7715 +vn 0.3002 -0.3658 0.8810 +vn 0.1850 -0.2254 0.9565 +vn 0.0625 -0.0761 0.9951 +vn 0.2230 -0.4173 0.8810 +vn 0.1374 -0.2571 0.9565 +vn 0.0464 -0.0869 0.9951 +vn 0.3651 -0.6831 0.6326 +vn 0.2999 -0.5611 0.7715 +vn 0.2248 -0.7412 0.6326 +vn 0.1847 -0.6088 0.7715 +vn 0.1374 -0.4528 0.8810 +vn 0.0846 -0.2790 0.9565 +vn 0.0286 -0.0942 0.9951 +vn 0.0286 -0.2902 0.9565 +vn 0.0097 -0.0980 0.9951 +vn 0.0759 -0.7708 0.6326 +vn 0.0624 -0.6332 0.7715 +vn 0.0464 -0.4709 0.8810 +vn -0.0759 -0.7708 0.6326 +vn -0.0624 -0.6332 0.7715 +vn -0.0464 -0.4709 0.8810 +vn -0.0286 -0.2902 0.9565 +vn -0.0097 -0.0980 0.9951 +vn -0.0846 -0.2790 0.9565 +vn -0.0286 -0.0942 0.9951 +vn -0.2248 -0.7412 0.6326 +vn -0.1847 -0.6088 0.7715 +vn -0.1374 -0.4528 0.8810 +vn -0.3651 -0.6831 0.6326 +vn -0.2999 -0.5611 0.7715 +vn -0.2231 -0.4173 0.8810 +vn -0.1374 -0.2571 0.9565 +vn -0.0464 -0.0869 0.9951 +vn -0.0625 -0.0761 0.9951 +vn -0.4913 -0.5987 0.6326 +vn -0.4036 -0.4918 0.7715 +vn -0.3002 -0.3658 0.8810 +vn -0.1850 -0.2254 0.9565 +vn -0.4918 -0.4036 0.7715 +vn -0.3658 -0.3002 0.8810 +vn -0.2254 -0.1850 0.9565 +vn -0.0761 -0.0625 0.9951 +vn -0.5987 -0.4913 0.6326 +vn -0.6831 -0.3651 0.6326 +vn -0.5611 -0.2999 0.7715 +vn -0.4173 -0.2231 0.8810 +vn -0.2571 -0.1374 0.9565 +vn -0.0869 -0.0464 0.9951 +vn -0.6088 -0.1847 0.7715 +vn -0.4528 -0.1374 0.8810 +vn -0.2790 -0.0846 0.9565 +vn -0.0942 -0.0286 0.9951 +vn -0.7412 -0.2248 0.6326 +vn -0.7708 -0.0759 0.6326 +vn -0.6332 -0.0624 0.7715 +vn -0.4709 -0.0464 0.8810 +vn -0.2902 -0.0286 0.9565 +vn -0.0980 -0.0097 0.9951 +vn 0.0000 1.0000 0.0000 +vn 1.0000 0.0000 0.0000 +vn 0.0000 -1.0000 0.0000 +vn -1.0000 0.0000 0.0000 +vn 0.0000 0.0000 -1.0000 +vn -0.0000 0.0000 1.0000 +vn 0.2231 0.4173 0.8810 +vn 0.4173 -0.2231 0.8810 +vn -0.4173 -0.2230 0.8810 +usemtl None +s off +f 1/1/1 160/2/1 126/3/1 +f 2/4/2 126/3/2 127/5/2 +f 3/6/3 127/5/3 128/7/3 +f 4/8/4 128/7/4 129/9/4 +f 21/10/5 4/11/5 129/12/5 +f 21/10/6 8/13/6 4/11/6 +f 5/14/7 145/15/7 1/1/7 +f 2/4/8 5/14/8 1/1/8 +f 7/16/9 2/4/9 3/6/9 +f 8/17/10 3/6/10 4/8/10 +f 9/18/11 142/19/11 5/14/11 +f 10/20/12 5/14/12 6/21/12 +f 11/22/13 6/21/13 7/16/13 +f 12/23/14 7/16/14 8/17/14 +f 21/10/15 12/24/15 8/13/15 +f 21/10/16 16/25/16 12/24/16 +f 9/18/17 140/26/17 141/27/17 +f 14/28/18 9/18/18 10/20/18 +f 15/29/19 10/20/19 11/22/19 +f 16/30/20 11/22/20 12/23/20 +f 14/31/21 17/32/21 13/33/21 +f 19/34/22 14/31/22 15/35/22 +f 20/36/23 15/35/23 16/37/23 +f 21/10/24 20/38/24 16/25/24 +f 17/32/25 140/39/25 13/33/25 +f 17/32/26 161/40/26 167/41/26 +f 18/42/27 22/43/27 17/32/27 +f 19/34/28 23/44/28 18/42/28 +f 20/36/29 24/45/29 19/34/29 +f 21/10/30 25/46/30 20/38/30 +f 23/44/31 26/47/31 22/43/31 +f 28/48/32 23/44/32 24/45/32 +f 25/49/33 28/48/33 24/45/33 +f 21/10/34 29/50/34 25/46/34 +f 26/47/35 161/40/35 22/43/35 +f 26/47/36 138/51/36 163/52/36 +f 27/53/37 30/54/37 26/47/37 +f 28/48/38 31/55/38 27/53/38 +f 29/56/39 32/57/39 28/48/39 +f 21/10/40 33/58/40 29/50/40 +f 36/59/41 31/55/41 32/57/41 +f 37/60/42 32/57/42 33/61/42 +f 21/10/43 37/62/43 33/58/43 +f 34/63/44 138/51/44 30/54/44 +f 31/55/45 34/63/45 30/54/45 +f 38/64/46 139/65/46 34/63/46 +f 35/66/47 38/64/47 34/63/47 +f 36/59/48 39/67/48 35/66/48 +f 37/60/49 40/68/49 36/59/49 +f 21/10/50 41/69/50 37/62/50 +f 41/70/51 44/71/51 40/68/51 +f 21/10/52 45/72/52 41/69/52 +f 42/73/53 152/74/53 38/64/53 +f 43/75/54 38/64/54 39/67/54 +f 44/71/55 39/67/55 40/68/55 +f 46/76/56 150/77/56 42/73/56 +f 43/75/57 46/76/57 42/73/57 +f 44/71/58 47/78/58 43/75/58 +f 49/79/59 44/71/59 45/80/59 +f 21/10/60 49/81/60 45/72/60 +f 53/82/61 48/83/61 49/84/61 +f 21/10/62 53/85/62 49/81/62 +f 50/86/63 149/87/63 46/88/63 +f 47/89/64 50/86/64 46/88/64 +f 48/83/65 51/90/65 47/89/65 +f 54/91/66 151/92/66 50/86/66 +f 51/90/67 54/91/67 50/86/67 +f 56/93/68 51/90/68 52/94/68 +f 53/82/69 56/93/69 52/94/69 +f 21/10/70 57/95/70 53/85/70 +f 21/10/71 61/96/71 57/95/71 +f 54/91/72 164/97/72 157/98/72 +f 59/99/73 54/91/73 55/100/73 +f 60/101/74 55/100/74 56/93/74 +f 61/102/75 56/93/75 57/103/75 +f 62/104/76 164/97/76 58/105/76 +f 63/106/77 58/105/77 59/99/77 +f 64/107/78 59/99/78 60/101/78 +f 61/102/79 64/107/79 60/101/79 +f 21/10/80 65/108/80 61/96/80 +f 21/10/81 69/109/81 65/108/81 +f 66/110/82 159/111/82 62/104/82 +f 67/112/83 62/104/83 63/106/83 +f 68/113/84 63/106/84 64/107/84 +f 69/114/85 64/107/85 65/115/85 +f 71/116/86 66/110/86 67/112/86 +f 72/117/87 67/112/87 68/113/87 +f 69/114/88 72/117/88 68/113/88 +f 21/10/89 73/118/89 69/109/89 +f 70/119/90 158/120/90 66/110/90 +f 74/121/91 169/122/91 70/119/91 +f 71/116/92 74/121/92 70/119/92 +f 76/123/93 71/116/93 72/117/93 +f 73/124/94 76/123/94 72/117/94 +f 21/10/95 77/125/95 73/118/95 +f 76/123/96 79/126/96 75/127/96 +f 81/128/97 76/123/97 77/129/97 +f 21/10/98 81/130/98 77/125/98 +f 78/131/99 153/132/99 74/121/99 +f 79/126/100 74/121/100 75/127/100 +f 82/133/101 144/134/101 78/135/101 +f 83/136/102 78/135/102 79/137/102 +f 84/138/103 79/137/103 80/139/103 +f 81/140/104 84/138/104 80/139/104 +f 21/10/105 85/141/105 81/130/105 +f 84/138/106 87/142/106 83/136/106 +f 89/143/107 84/138/107 85/144/107 +f 21/10/108 89/145/108 85/141/108 +f 86/146/109 154/147/109 82/133/109 +f 87/142/110 82/133/110 83/136/110 +f 90/148/111 155/149/111 86/146/111 +f 91/150/112 86/146/112 87/142/112 +f 92/151/113 87/142/113 88/152/113 +f 93/153/114 88/152/114 89/143/114 +f 21/10/115 93/154/115 89/145/115 +f 97/155/116 92/151/116 93/153/116 +f 21/10/117 97/156/117 93/154/117 +f 94/157/118 165/158/118 90/148/118 +f 95/159/119 90/148/119 91/150/119 +f 92/151/120 95/159/120 91/150/120 +f 98/160/121 166/161/121 94/157/121 +f 99/162/122 94/157/122 95/159/122 +f 96/163/123 99/162/123 95/159/123 +f 101/164/124 96/163/124 97/155/124 +f 21/10/125 101/165/125 97/156/125 +f 105/166/126 100/167/126 101/164/126 +f 21/10/127 105/168/127 101/165/127 +f 102/169/128 162/170/128 98/160/128 +f 103/171/129 98/160/129 99/162/129 +f 104/172/130 99/162/130 100/167/130 +f 106/173/131 168/174/131 102/169/131 +f 103/171/132 106/173/132 102/169/132 +f 108/175/133 103/171/133 104/172/133 +f 109/176/134 104/172/134 105/166/134 +f 21/10/135 109/177/135 105/168/135 +f 21/10/136 113/178/136 109/177/136 +f 110/179/137 148/180/137 106/173/137 +f 111/181/138 106/173/138 107/182/138 +f 108/175/139 111/181/139 107/182/139 +f 113/183/140 108/175/140 109/176/140 +f 115/184/141 110/185/141 111/186/141 +f 116/187/142 111/186/142 112/188/142 +f 117/189/143 112/188/143 113/190/143 +f 21/10/144 117/191/144 113/178/144 +f 114/192/145 143/193/145 110/185/145 +f 118/194/146 156/195/146 114/192/146 +f 119/196/147 114/192/147 115/184/147 +f 116/187/148 119/196/148 115/184/148 +f 121/197/149 116/187/149 117/189/149 +f 21/10/150 121/198/150 117/191/150 +f 123/199/151 118/194/151 119/196/151 +f 124/200/152 119/196/152 120/201/152 +f 125/202/153 120/201/153 121/197/153 +f 21/10/154 125/203/154 121/198/154 +f 122/204/155 147/205/155 118/194/155 +f 126/3/156 146/206/156 122/204/156 +f 127/5/157 122/204/157 123/199/157 +f 128/7/158 123/199/158 124/200/158 +f 129/9/159 124/200/159 125/202/159 +f 21/10/160 129/12/160 125/203/160 +f 131/207/161 132/208/161 130/209/161 +f 133/210/162 136/211/162 132/212/162 +f 137/213/163 134/214/163 136/215/163 +f 135/216/164 130/217/164 134/218/164 +f 136/211/165 130/219/165 132/212/165 +f 133/220/166 146/221/166 160/222/166 +f 159/223/166 158/224/166 131/225/166 +f 1/1/1 145/15/1 160/2/1 +f 2/4/2 1/1/2 126/3/2 +f 3/6/3 2/4/3 127/5/3 +f 4/8/4 3/6/4 128/7/4 +f 5/14/7 142/19/7 145/15/7 +f 2/4/8 6/21/8 5/14/8 +f 7/16/9 6/21/9 2/4/9 +f 8/17/10 7/16/10 3/6/10 +f 9/18/11 141/27/11 142/19/11 +f 10/20/12 9/18/12 5/14/12 +f 11/22/13 10/20/13 6/21/13 +f 12/23/14 11/22/14 7/16/14 +f 9/18/17 13/226/17 140/26/17 +f 14/28/18 13/226/18 9/18/18 +f 15/29/19 14/28/19 10/20/19 +f 16/30/20 15/29/20 11/22/20 +f 14/31/21 18/42/21 17/32/21 +f 19/34/22 18/42/22 14/31/22 +f 20/36/23 19/34/23 15/35/23 +f 17/32/25 167/41/25 140/39/25 +f 17/32/26 22/43/26 161/40/26 +f 18/42/27 23/44/27 22/43/27 +f 19/34/28 24/45/28 23/44/28 +f 20/36/29 25/49/29 24/45/29 +f 23/44/31 27/53/31 26/47/31 +f 28/48/32 27/53/32 23/44/32 +f 25/49/33 29/56/33 28/48/33 +f 26/47/35 163/52/35 161/40/35 +f 26/47/36 30/54/36 138/51/36 +f 27/53/37 31/55/37 30/54/37 +f 28/48/38 32/57/38 31/55/38 +f 29/56/39 33/61/39 32/57/39 +f 36/59/41 35/66/41 31/55/41 +f 37/60/42 36/59/42 32/57/42 +f 34/63/44 139/65/44 138/51/44 +f 31/55/45 35/66/45 34/63/45 +f 38/64/46 152/74/46 139/65/46 +f 35/66/47 39/67/47 38/64/47 +f 36/59/48 40/68/48 39/67/48 +f 37/60/49 41/70/49 40/68/49 +f 41/70/51 45/80/51 44/71/51 +f 42/73/53 150/77/53 152/74/53 +f 43/75/54 42/73/54 38/64/54 +f 44/71/167 43/75/167 39/67/167 +f 46/76/56 149/227/56 150/77/56 +f 43/75/57 47/78/57 46/76/57 +f 44/71/58 48/228/58 47/78/58 +f 49/79/59 48/228/59 44/71/59 +f 53/82/61 52/94/61 48/83/61 +f 50/86/63 151/92/63 149/87/63 +f 47/89/64 51/90/64 50/86/64 +f 48/83/65 52/94/65 51/90/65 +f 54/91/66 157/98/66 151/92/66 +f 51/90/67 55/100/67 54/91/67 +f 56/93/68 55/100/68 51/90/68 +f 53/82/69 57/103/69 56/93/69 +f 54/91/72 58/105/72 164/97/72 +f 59/99/73 58/105/73 54/91/73 +f 60/101/74 59/99/74 55/100/74 +f 61/102/75 60/101/75 56/93/75 +f 62/104/76 159/111/76 164/97/76 +f 63/106/77 62/104/77 58/105/77 +f 64/107/78 63/106/78 59/99/78 +f 61/102/79 65/115/79 64/107/79 +f 66/110/82 158/120/82 159/111/82 +f 67/112/83 66/110/83 62/104/83 +f 68/113/84 67/112/84 63/106/84 +f 69/114/85 68/113/85 64/107/85 +f 71/116/86 70/119/86 66/110/86 +f 72/117/87 71/116/87 67/112/87 +f 69/114/88 73/124/88 72/117/88 +f 70/119/90 169/122/90 158/120/90 +f 74/121/91 153/132/91 169/122/91 +f 71/116/92 75/127/92 74/121/92 +f 76/123/168 75/127/168 71/116/168 +f 73/124/94 77/129/94 76/123/94 +f 76/123/96 80/229/96 79/126/96 +f 81/128/97 80/229/97 76/123/97 +f 78/131/99 144/230/99 153/132/99 +f 79/126/100 78/131/100 74/121/100 +f 82/133/101 154/147/101 144/134/101 +f 83/136/102 82/133/102 78/135/102 +f 84/138/103 83/136/103 79/137/103 +f 81/140/104 85/144/104 84/138/104 +f 84/138/106 88/152/106 87/142/106 +f 89/143/107 88/152/107 84/138/107 +f 86/146/109 155/149/109 154/147/109 +f 87/142/110 86/146/110 82/133/110 +f 90/148/111 165/158/111 155/149/111 +f 91/150/112 90/148/112 86/146/112 +f 92/151/113 91/150/113 87/142/113 +f 93/153/114 92/151/114 88/152/114 +f 97/155/116 96/163/116 92/151/116 +f 94/157/118 166/161/118 165/158/118 +f 95/159/119 94/157/119 90/148/119 +f 92/151/120 96/163/120 95/159/120 +f 98/160/121 162/170/121 166/161/121 +f 99/162/122 98/160/122 94/157/122 +f 96/163/123 100/167/123 99/162/123 +f 101/164/124 100/167/124 96/163/124 +f 105/166/126 104/172/126 100/167/126 +f 102/169/128 168/174/128 162/170/128 +f 103/171/129 102/169/129 98/160/129 +f 104/172/130 103/171/130 99/162/130 +f 106/173/131 148/180/131 168/174/131 +f 103/171/132 107/182/132 106/173/132 +f 108/175/133 107/182/133 103/171/133 +f 109/176/134 108/175/134 104/172/134 +f 110/179/137 143/231/137 148/180/137 +f 111/181/138 110/179/138 106/173/138 +f 108/175/139 112/232/139 111/181/139 +f 113/183/140 112/232/140 108/175/140 +f 115/184/141 114/192/141 110/185/141 +f 116/187/142 115/184/142 111/186/142 +f 117/189/143 116/187/143 112/188/143 +f 114/192/145 156/195/145 143/193/145 +f 118/194/146 147/205/146 156/195/146 +f 119/196/147 118/194/147 114/192/147 +f 116/187/169 120/201/169 119/196/169 +f 121/197/149 120/201/149 116/187/149 +f 123/199/151 122/204/151 118/194/151 +f 124/200/152 123/199/152 119/196/152 +f 125/202/153 124/200/153 120/201/153 +f 122/204/155 146/206/155 147/205/155 +f 126/3/156 160/2/156 146/206/156 +f 127/5/157 126/3/157 122/204/157 +f 128/7/158 127/5/158 123/199/158 +f 129/9/159 128/7/159 124/200/159 +f 131/207/161 133/233/161 132/208/161 +f 133/210/162 137/234/162 136/211/162 +f 137/213/163 135/235/163 134/214/163 +f 135/216/164 131/236/164 130/217/164 +f 136/211/165 134/237/165 130/219/165 +f 133/220/166 131/238/166 166/239/166 +f 133/220/166 166/239/166 162/240/166 +f 138/241/166 135/242/166 137/243/166 +f 163/244/166 138/241/166 137/243/166 +f 133/220/166 162/240/166 168/245/166 +f 133/220/166 168/245/166 148/246/166 +f 161/247/166 163/244/166 137/243/166 +f 167/248/166 161/247/166 137/243/166 +f 133/220/166 148/246/166 143/249/166 +f 133/220/166 143/249/166 156/250/166 +f 140/251/166 167/248/166 137/243/166 +f 141/252/166 140/251/166 137/243/166 +f 137/243/166 133/220/166 160/222/166 +f 133/220/166 156/250/166 147/253/166 +f 142/254/166 141/252/166 137/243/166 +f 145/255/166 142/254/166 137/243/166 +f 133/220/166 147/253/166 146/221/166 +f 160/222/166 145/255/166 137/243/166 +f 135/256/166 138/257/166 139/258/166 +f 135/256/166 139/258/166 152/259/166 +f 165/260/166 166/261/166 131/225/166 +f 155/262/166 165/260/166 131/225/166 +f 135/256/166 152/259/166 150/263/166 +f 135/256/166 150/263/166 149/264/166 +f 154/265/166 155/262/166 131/225/166 +f 144/266/166 154/265/166 131/225/166 +f 135/256/166 149/264/166 151/267/166 +f 135/256/166 151/267/166 157/268/166 +f 153/269/166 144/266/166 131/225/166 +f 169/270/166 153/269/166 131/225/166 +f 131/225/166 135/256/166 159/223/166 +f 135/256/166 157/268/166 164/271/166 +f 158/224/166 169/270/166 131/225/166 +f 135/256/166 164/271/166 159/223/166 diff --git a/data/toys/concave_box.urdf b/data/toys/concave_box.urdf new file mode 100644 index 000000000..08ff9c02d --- /dev/null +++ b/data/toys/concave_box.urdf @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/data/toys/cube.mtl b/data/toys/cube.mtl new file mode 100644 index 000000000..c221299b1 --- /dev/null +++ b/data/toys/cube.mtl @@ -0,0 +1,11 @@ +# Blender MTL File: 'shape_sort.blend' +# Material Count: 1 + +newmtl Material.002 +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.017444 0.640000 0.032216 +Ks 0.034126 0.500000 0.031333 +Ni 1.000000 +d 1.000000 +illum 2 diff --git a/data/toys/cube.obj b/data/toys/cube.obj new file mode 100644 index 000000000..c2849fe05 --- /dev/null +++ b/data/toys/cube.obj @@ -0,0 +1,64 @@ +# Blender v2.71 (sub 0) OBJ File: 'shape_sort.blend' +# www.blender.org +mtllib cube.mtl +o Cube.001_Cube.002 +v -0.231854 0.040516 -0.056463 +v -0.231854 0.040516 -0.121937 +v -0.144556 0.040516 -0.121937 +v -0.144556 0.040516 -0.056463 +v -0.231854 0.127815 -0.056463 +v -0.231854 0.127815 -0.121937 +v -0.144556 0.127815 -0.121937 +v -0.144556 0.127815 -0.056463 +v -0.231854 0.040516 -0.056463 +v -0.231854 0.040516 -0.121937 +v -0.144556 0.040516 -0.121937 +v -0.144556 0.040516 -0.056463 +v -0.231854 0.127815 -0.056463 +v -0.231854 0.127815 -0.121937 +v -0.144556 0.127815 -0.121937 +v -0.144556 0.127815 -0.056463 +vt 1.044600 0.042083 +vt 1.044600 -0.957917 +vt 0.044600 -0.957917 +vt 1.905897 0.042083 +vt 1.905897 -0.957917 +vt 0.905898 -0.957917 +vt -0.955400 0.042083 +vt -0.955400 -0.957917 +vt -0.094102 0.042083 +vt -0.094102 -0.957917 +vt 0.905898 1.044600 +vt 1.905897 1.044600 +vt 1.905897 0.044600 +vt -0.094102 1.044600 +vt -0.094102 0.044600 +vt 0.044600 0.042083 +vt 0.905898 0.042083 +vt 0.905898 0.044600 +usemtl Material.002 +s off +f 6/1 2/2 1/3 +f 7/4 3/5 2/6 +f 8/7 4/8 3/3 +f 5/9 1/10 4/6 +f 2/11 3/12 4/13 +f 7/11 6/14 5/15 +f 14/1 10/2 9/3 +f 15/4 11/5 10/6 +f 16/7 12/8 11/3 +f 13/9 9/10 12/6 +f 10/11 11/12 12/13 +f 15/11 14/14 13/15 +f 5/16 6/1 1/3 +f 6/17 7/4 2/6 +f 7/16 8/7 3/3 +f 8/17 5/9 4/6 +f 1/18 2/11 4/13 +f 8/18 7/11 5/15 +f 13/16 14/1 9/3 +f 14/17 15/4 10/6 +f 15/16 16/7 11/3 +f 16/17 13/9 12/6 +f 9/18 10/11 12/13 +f 16/18 15/11 13/15 diff --git a/data/toys/cylinder.mtl b/data/toys/cylinder.mtl new file mode 100644 index 000000000..3efd48560 --- /dev/null +++ b/data/toys/cylinder.mtl @@ -0,0 +1,11 @@ +# Blender MTL File: 'shape_sort.blend' +# Material Count: 1 + +newmtl Material.001 +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.013473 0.018536 0.640000 +Ks 0.500000 0.500000 0.500000 +Ni 1.000000 +d 1.000000 +illum 2 diff --git a/data/toys/cylinder.obj b/data/toys/cylinder.obj new file mode 100644 index 000000000..b2abf963d --- /dev/null +++ b/data/toys/cylinder.obj @@ -0,0 +1,282 @@ +# Blender v2.71 (sub 0) OBJ File: 'shape_sort.blend' +# www.blender.org +mtllib cylinder.mtl +o Cylinder.001 +v -0.291246 0.045696 0.165546 +v -0.214241 0.045696 0.165546 +v -0.291246 0.034429 0.166100 +v -0.214241 0.034429 0.166100 +v -0.291246 0.023595 0.167744 +v -0.214241 0.023595 0.167744 +v -0.291246 0.013610 0.170412 +v -0.214241 0.013610 0.170412 +v -0.291246 0.004859 0.174003 +v -0.214241 0.004858 0.174003 +v -0.291246 -0.002324 0.178379 +v -0.214241 -0.002324 0.178379 +v -0.291246 -0.007661 0.183372 +v -0.214241 -0.007661 0.183372 +v -0.291246 -0.010947 0.188789 +v -0.214241 -0.010947 0.188789 +v -0.291246 -0.012057 0.194422 +v -0.214241 -0.012057 0.194422 +v -0.291246 -0.010947 0.200056 +v -0.214241 -0.010947 0.200056 +v -0.291246 -0.007661 0.205473 +v -0.214241 -0.007661 0.205473 +v -0.291246 -0.002324 0.210465 +v -0.214241 -0.002324 0.210465 +v -0.291246 0.004859 0.214841 +v -0.214241 0.004858 0.214841 +v -0.291246 0.013610 0.218432 +v -0.214241 0.013610 0.218432 +v -0.291246 0.023595 0.221101 +v -0.214241 0.023595 0.221101 +v -0.291246 0.034429 0.222744 +v -0.214241 0.034429 0.222744 +v -0.291246 0.045696 0.223299 +v -0.214241 0.045696 0.223299 +v -0.291246 0.056963 0.222744 +v -0.214241 0.056963 0.222744 +v -0.291246 0.067797 0.221101 +v -0.214241 0.067797 0.221101 +v -0.291246 0.077782 0.218432 +v -0.214241 0.077782 0.218432 +v -0.291246 0.086534 0.214841 +v -0.214241 0.086534 0.214841 +v -0.291246 0.093716 0.210465 +v -0.214241 0.093716 0.210465 +v -0.291246 0.099053 0.205473 +v -0.214241 0.099053 0.205473 +v -0.291246 0.102340 0.200056 +v -0.214241 0.102340 0.200056 +v -0.291246 0.103449 0.194422 +v -0.214241 0.103449 0.194422 +v -0.291246 0.102340 0.188789 +v -0.214241 0.102340 0.188789 +v -0.291246 0.099053 0.183371 +v -0.214241 0.099053 0.183371 +v -0.291246 0.093716 0.178379 +v -0.214241 0.093716 0.178379 +v -0.291246 0.086534 0.174003 +v -0.214241 0.086534 0.174003 +v -0.291246 0.077782 0.170412 +v -0.214241 0.077782 0.170412 +v -0.291246 0.067797 0.167744 +v -0.214241 0.067797 0.167744 +v -0.291246 0.056963 0.166100 +v -0.214241 0.056963 0.166100 +vt 0.306049 0.488177 +vt 0.092448 0.519423 +vt 0.067655 0.516411 +vt 0.270128 0.485165 +vt 0.049219 0.513369 +vt 0.232794 0.482123 +vt 0.034123 0.510414 +vt 0.020864 0.507658 +vt 0.163092 0.476412 +vt 0.008587 0.505209 +vt 0.133302 0.473963 +vt 1.008587 0.505209 +vt 0.996728 0.503160 +vt 1.106812 0.471914 +vt 0.984865 0.501590 +vt 1.082707 0.470344 +vt 0.972628 0.500559 +vt 0.959652 0.500107 +vt 1.036012 0.468861 +vt 0.945535 0.500252 +vt 1.008811 0.469006 +vt 0.929810 0.500987 +vt 0.972352 0.469741 +vt 0.911918 0.502285 +vt 0.913273 0.471038 +vt 0.891203 0.504095 +vt 0.866959 0.506348 +vt 0.698338 0.475102 +vt 0.838607 0.508958 +vt 0.630535 0.477711 +vt 0.806049 0.511823 +vt 0.592448 0.480577 +vt 0.770128 0.514835 +vt 0.732794 0.517877 +vt 0.549219 0.486631 +vt 0.696491 0.520833 +vt 0.534123 0.489586 +vt 0.663092 0.523588 +vt 0.520864 0.492342 +vt 0.633302 0.526037 +vt 0.508586 0.494791 +vt 0.606812 0.528086 +vt 0.496728 0.496840 +vt 0.582707 0.529656 +vt 0.559695 0.530687 +vt 0.472628 0.499441 +vt 0.536012 0.531139 +vt 0.459652 0.499893 +vt 0.508810 0.530994 +vt 0.445535 0.499748 +vt 0.472352 0.530259 +vt 0.413273 0.528962 +vt 0.411918 0.497715 +vt 0.310810 0.527152 +vt 0.391202 0.495905 +vt 0.198337 0.524898 +vt 1.020864 0.507658 +vt 1.034123 0.510414 +vt 0.130535 0.522289 +vt 0.366959 0.493652 +vt 1.391202 0.495905 +vt 0.196491 0.479167 +vt 1.133302 0.473963 +vt 1.059695 0.469313 +vt 0.810811 0.472848 +vt 0.567655 0.483589 +vt 0.484865 0.498410 +vt 0.429810 0.499013 +vt 1.092448 0.519423 +vt 1.067655 0.516411 +vt 1.198337 0.524898 +vt 1.413273 0.528962 +vt 1.310810 0.527152 +vt 1.472352 0.530259 +vt 1.130535 0.522289 +vt 1.049219 0.513369 +vt 0.338607 0.491042 +vt 1.270128 0.485165 +vt 1.306049 0.488177 +vt 1.196491 0.479167 +vt 1.232794 0.482123 +vt 1.163092 0.476412 +vt 1.366959 0.493652 +vt 1.338607 0.491042 +vt 1.429810 0.499013 +vt 1.411918 0.497715 +vt 1.445535 0.499748 +vt 1.459652 0.499893 +usemtl Material.001 +s off +f 1/1 2/2 4/3 +f 3/4 4/3 6/5 +f 5/6 6/5 8/7 +f 8/7 10/8 9/9 +f 10/8 12/10 11/11 +f 12/12 14/13 13/14 +f 14/13 16/15 15/16 +f 15/16 16/15 18/17 +f 18/17 20/18 19/19 +f 20/18 22/20 21/21 +f 22/20 24/22 23/23 +f 24/22 26/24 25/25 +f 25/25 26/24 28/26 +f 28/26 30/27 29/28 +f 30/27 32/29 31/30 +f 32/29 34/31 33/32 +f 33/32 34/31 36/33 +f 36/33 38/34 37/35 +f 38/34 40/36 39/37 +f 40/36 42/38 41/39 +f 42/38 44/40 43/41 +f 44/40 46/42 45/43 +f 45/43 46/42 48/44 +f 48/44 50/45 49/46 +f 50/45 52/47 51/48 +f 52/47 54/49 53/50 +f 53/50 54/49 56/51 +f 56/51 58/52 57/53 +f 58/52 60/54 59/55 +f 59/55 60/54 62/56 +f 26/24 10/57 8/58 +f 64/59 2/2 1/1 +f 61/60 62/56 64/59 +f 37/35 39/37 59/61 +f 3/4 1/1 4/3 +f 5/6 3/4 6/5 +f 7/62 5/6 8/7 +f 7/62 8/7 9/9 +f 9/9 10/8 11/11 +f 11/63 12/12 13/14 +f 13/14 14/13 15/16 +f 17/64 15/16 18/17 +f 17/64 18/17 19/19 +f 19/19 20/18 21/21 +f 21/21 22/20 23/23 +f 23/23 24/22 25/25 +f 27/65 25/25 28/26 +f 27/65 28/26 29/28 +f 29/28 30/27 31/30 +f 31/30 32/29 33/32 +f 35/66 33/32 36/33 +f 35/66 36/33 37/35 +f 37/35 38/34 39/37 +f 39/37 40/36 41/39 +f 41/39 42/38 43/41 +f 43/41 44/40 45/43 +f 47/67 45/43 48/44 +f 47/67 48/44 49/46 +f 49/46 50/45 51/48 +f 51/48 52/47 53/50 +f 55/68 53/50 56/51 +f 55/68 56/51 57/53 +f 57/53 58/52 59/55 +f 61/60 59/55 62/56 +f 2/69 34/31 4/70 +f 38/34 36/33 62/71 +f 58/72 40/36 60/73 +f 54/49 44/40 56/74 +f 50/45 48/44 52/47 +f 46/42 54/49 48/44 +f 14/13 22/20 20/18 +f 12/12 10/57 24/22 +f 2/69 64/75 34/31 +f 30/27 6/76 32/29 +f 26/24 8/58 28/26 +f 63/77 61/60 64/59 +f 64/75 36/33 34/31 +f 14/13 20/18 16/15 +f 44/40 42/38 56/74 +f 40/36 38/34 60/73 +f 38/34 62/71 60/73 +f 10/57 26/24 24/22 +f 48/44 54/49 52/47 +f 34/31 32/29 4/70 +f 8/58 6/76 28/26 +f 54/49 46/42 44/40 +f 20/18 18/17 16/15 +f 42/38 58/72 56/74 +f 63/77 64/59 1/1 +f 32/29 6/76 4/70 +f 12/12 24/22 14/13 +f 58/72 42/38 40/36 +f 36/33 64/75 62/71 +f 24/22 22/20 14/13 +f 6/76 30/27 28/26 +f 3/78 31/30 1/79 +f 7/80 29/28 5/81 +f 11/63 23/23 9/82 +f 15/16 21/21 13/14 +f 15/16 17/64 19/19 +f 61/83 63/84 35/66 +f 27/65 7/80 25/25 +f 41/39 55/85 57/86 +f 35/66 63/84 33/32 +f 53/87 55/85 43/41 +f 43/41 55/85 41/39 +f 47/67 53/87 45/43 +f 47/67 49/46 51/88 +f 59/61 39/37 57/86 +f 29/28 31/30 5/81 +f 7/80 27/65 29/28 +f 45/43 53/87 43/41 +f 47/67 51/88 53/87 +f 61/83 37/35 59/61 +f 31/30 3/78 5/81 +f 15/16 19/19 21/21 +f 21/21 23/23 13/14 +f 39/37 41/39 57/86 +f 7/80 9/82 25/25 +f 1/79 31/30 33/32 +f 23/23 11/63 13/14 +f 9/82 23/23 25/25 +f 37/35 61/83 35/66 +f 63/84 1/79 33/32 diff --git a/data/toys/prism.mtl b/data/toys/prism.mtl new file mode 100644 index 000000000..ed3e8a1ae --- /dev/null +++ b/data/toys/prism.mtl @@ -0,0 +1,11 @@ +# Blender MTL File: 'shape_sort.blend' +# Material Count: 1 + +newmtl Material.003 +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.640000 0.007339 0.006282 +Ks 0.500000 0.500000 0.500000 +Ni 1.000000 +d 1.000000 +illum 2 diff --git a/data/toys/prism.obj b/data/toys/prism.obj new file mode 100644 index 000000000..b8b0d6f0f --- /dev/null +++ b/data/toys/prism.obj @@ -0,0 +1,45 @@ +# Blender v2.71 (sub 0) OBJ File: 'shape_sort.blend' +# www.blender.org +mtllib prism.mtl +o Cube.002_Cube.005 +v -0.233641 -0.103557 0.060897 +v -0.233641 -0.103557 -0.057063 +v -0.149383 -0.103557 -0.057063 +v -0.149383 -0.103557 0.060897 +v -0.233013 -0.039217 0.035115 +v -0.233013 -0.039217 -0.031280 +v -0.150011 -0.039217 -0.031280 +v -0.150011 -0.039217 0.035115 +vt 0.780473 0.523151 +vt 0.999041 -0.022288 +vt -0.000959 -0.022288 +vt 1.896793 0.523151 +vt 1.904244 -0.022288 +vt 0.904244 -0.022288 +vt 0.217610 0.523151 +vt -0.088305 0.523151 +vt -0.095756 -0.022288 +vt 0.904244 1.999041 +vt 1.904244 1.999041 +vt 1.904244 0.999041 +vt 0.896793 0.780473 +vt -0.088305 0.780473 +vt -0.088305 0.217610 +vt 0.911695 0.523151 +vt 0.896793 0.523151 +vt 0.904244 0.999041 +vt 0.896793 0.217610 +usemtl Material.003 +s off +f 6/1 2/2 1/3 +f 7/4 3/5 2/6 +f 8/7 4/3 3/2 +f 5/8 1/9 4/6 +f 2/10 3/11 4/12 +f 7/13 6/14 5/15 +f 5/7 6/1 1/3 +f 6/16 7/4 2/6 +f 7/1 8/7 3/2 +f 8/17 5/8 4/6 +f 1/18 2/10 4/12 +f 8/19 7/13 5/15 diff --git a/data/toys/shape_sorter.mtl b/data/toys/shape_sorter.mtl new file mode 100644 index 000000000..4e5935766 --- /dev/null +++ b/data/toys/shape_sorter.mtl @@ -0,0 +1,21 @@ +# Blender MTL File: 'shape_sort.blend' +# Material Count: 2 + +newmtl Material.004 +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.640000 0.640000 0.640000 +Ks 0.500000 0.500000 0.500000 +Ni 1.000000 +d 1.000000 +illum 2 +map_Kd E:\develop\bullet3\data\table\table.png + +newmtl Material.004_NONE +Ns 96.078431 +Ka 0.000000 0.000000 0.000000 +Kd 0.640000 0.640000 0.640000 +Ks 0.500000 0.500000 0.500000 +Ni 1.000000 +d 1.000000 +illum 2 diff --git a/data/toys/shape_sorter.obj b/data/toys/shape_sorter.obj new file mode 100644 index 000000000..a8b6dfd84 --- /dev/null +++ b/data/toys/shape_sorter.obj @@ -0,0 +1,400 @@ +# Blender v2.71 (sub 0) OBJ File: 'shape_sort.blend' +# www.blender.org +mtllib shape_sorter.mtl +o Cube +v -0.200000 0.200000 -0.200000 +v -0.200000 -0.200000 -0.200000 +v -0.200000 0.037707 -0.055248 +v -0.200000 0.037707 -0.124929 +v -0.200000 0.130615 -0.124929 +v -0.200000 0.130615 -0.055248 +v -0.200000 -0.200000 0.200000 +v -0.200000 0.014752 0.076444 +v -0.200000 -0.109627 0.071917 +v -0.200000 -0.109627 -0.068083 +v -0.200000 -0.033266 -0.037483 +v -0.200000 -0.033266 0.041318 +v -0.200000 0.015905 0.070592 +v -0.200000 0.019320 0.064964 +v -0.200000 0.024864 0.059777 +v -0.200000 0.032326 0.055231 +v -0.200000 0.041418 0.051500 +v -0.200000 0.051791 0.048728 +v -0.200000 0.063047 0.047021 +v -0.200000 0.074753 0.046444 +v -0.200000 0.086458 0.047021 +v -0.200000 0.097713 0.048728 +v -0.200000 0.108087 0.051500 +v -0.200000 0.117179 0.055231 +v -0.200000 0.124641 0.059777 +v -0.200000 0.130185 0.064964 +v -0.200000 0.133600 0.070592 +v -0.200000 0.200000 0.200000 +v 0.200000 0.200000 -0.200000 +v 0.200000 -0.200000 -0.200000 +v -0.179938 0.037707 -0.055248 +v -0.179938 0.037707 -0.124929 +v -0.179938 0.130615 -0.124929 +v -0.179938 0.130615 -0.055248 +v -0.179938 0.200000 0.179938 +v -0.179938 0.200000 -0.179938 +v 0.179938 0.200000 -0.179938 +v 0.200000 -0.200000 0.200000 +v -0.200000 0.134752 0.076444 +v -0.200000 0.133600 0.082297 +v -0.200000 0.130185 0.087925 +v -0.200000 0.124641 0.093111 +v -0.200000 0.117179 0.097657 +v -0.200000 0.108087 0.101388 +v -0.200000 0.097714 0.104161 +v -0.200000 0.086458 0.105868 +v -0.200000 0.074753 0.106444 +v -0.200000 0.063047 0.105868 +v -0.200000 0.051792 0.104161 +v -0.200000 0.041418 0.101388 +v -0.200000 0.032326 0.097657 +v -0.200000 0.024864 0.093111 +v -0.200000 0.019320 0.087925 +v -0.200000 0.015905 0.082297 +v -0.179938 0.014752 0.076444 +v -0.179938 0.015905 0.070592 +v -0.179938 0.019320 0.064964 +v -0.179938 0.024864 0.059777 +v -0.179938 0.032326 0.055231 +v -0.179938 0.041418 0.051500 +v -0.179938 0.051791 0.048728 +v -0.179938 0.063047 0.047021 +v -0.179938 0.074752 0.046444 +v -0.179938 0.086458 0.047021 +v -0.179938 0.097713 0.048728 +v -0.179938 0.108087 0.051500 +v -0.179938 0.117179 0.055231 +v -0.179938 0.124641 0.059777 +v -0.179938 0.130185 0.064964 +v -0.179938 0.133600 0.070592 +v 0.200000 0.200000 0.200000 +v -0.179938 -0.185168 -0.179938 +v 0.179938 0.200000 0.179938 +v -0.179938 -0.185168 0.179938 +v -0.179938 0.015905 0.082297 +v -0.179938 0.019320 0.087925 +v -0.179938 0.024864 0.093111 +v -0.179938 0.032326 0.097657 +v -0.179938 0.041418 0.101388 +v -0.179938 0.051791 0.104161 +v -0.179938 0.063047 0.105868 +v -0.179938 0.074753 0.106444 +v -0.179938 0.086458 0.105868 +v -0.179938 0.097714 0.104161 +v -0.179938 0.108087 0.101388 +v -0.179938 0.117179 0.097657 +v -0.179938 0.124641 0.093111 +v -0.179938 0.130185 0.087925 +v -0.179938 0.133600 0.082297 +v -0.179938 0.134752 0.076444 +v 0.179938 -0.185168 -0.179938 +v -0.179938 -0.109627 0.071917 +v -0.179938 -0.033266 0.041318 +v -0.179938 -0.033266 -0.037483 +v -0.179938 -0.109627 -0.068083 +v 0.179938 -0.185168 0.179938 +vt 0.337529 0.596545 +vt 0.387821 0.596545 +vt 0.283346 0.663317 +vt 0.379674 0.386434 +vt 0.283346 0.278382 +vt 0.572047 0.278383 +vt 0.387821 0.507137 +vt 0.461218 0.542787 +vt 0.461634 0.554051 +vt 0.372847 0.595850 +vt 0.372847 0.369934 +vt 0.391646 0.506894 +vt 0.343069 0.506894 +vt 0.337529 0.507137 +vt 0.343069 0.593253 +vt 0.391646 0.593253 +vt 0.304720 0.657748 +vt 0.378834 0.597878 +vt 0.542284 0.369934 +vt 0.572047 0.663317 +vt 0.504523 0.542787 +vt 0.504107 0.531523 +vt 0.482871 0.485047 +vt 0.483455 0.485557 +vt 0.479374 0.486628 +vt 0.478646 0.486156 +vt 0.475451 0.489802 +vt 0.474584 0.489442 +vt 0.471835 0.494956 +vt 0.467560 0.501959 +vt 0.470841 0.494778 +vt 0.468666 0.501892 +vt 0.466065 0.510343 +vt 0.462866 0.520691 +vt 0.464867 0.510708 +vt 0.461634 0.531522 +vt 0.464132 0.519985 +vt 0.462942 0.530448 +vt 0.462540 0.541328 +vt 0.462942 0.552208 +vt 0.462866 0.564883 +vt 0.464132 0.562671 +vt 0.466065 0.572313 +vt 0.467560 0.583615 +vt 0.464867 0.574866 +vt 0.468666 0.580764 +vt 0.471835 0.587700 +vt 0.474584 0.596132 +vt 0.470841 0.590796 +vt 0.475451 0.592854 +vt 0.479374 0.596028 +vt 0.542284 0.595850 +vt 0.304720 0.299726 +vt 0.555605 0.657748 +vt 0.504369 0.541328 +vt 0.503967 0.552209 +vt 0.378834 0.375736 +vt 0.383150 0.371876 +vt 0.555605 0.299726 +vt 0.478646 0.599418 +vt 0.483455 0.597099 +vt 0.482870 0.600527 +vt 0.487535 0.596028 +vt 0.487095 0.599418 +vt 0.491458 0.592854 +vt 0.491157 0.596132 +vt 0.495074 0.587700 +vt 0.494900 0.590796 +vt 0.498243 0.580764 +vt 0.498181 0.583615 +vt 0.500844 0.572313 +vt 0.502875 0.564883 +vt 0.500874 0.574866 +vt 0.502777 0.562671 +vt 0.504107 0.554052 +vt 0.503967 0.530448 +vt 0.502777 0.519985 +vt 0.502875 0.520691 +vt 0.500844 0.510343 +vt 0.500874 0.510708 +vt 0.498243 0.501892 +vt 0.498181 0.501959 +vt 0.495074 0.494956 +vt 0.494900 0.494778 +vt 0.491458 0.489802 +vt 0.491157 0.489442 +vt 0.487535 0.486628 +vt 0.487095 0.486156 +vt 0.534501 0.375736 +vt 0.534501 0.597878 +vt 0.478009 0.388189 +vt 0.400119 0.458779 +vt 0.457642 0.460616 +vt 0.480077 0.374691 +vt 0.459415 0.445604 +vt 0.404578 0.442049 +vt 0.000000 0.000000 +usemtl Material.004 +s off +f 5/1 6/2 1/3 +f 10/4 2/5 7/6 +f 3/7 20/8 21/9 +f 29/10 30/11 2/5 +f 3/7 31/12 32/13 +f 4/14 32/13 33/15 +f 34/16 6/2 5/1 +f 36/17 37/18 29/10 +f 31/12 3/7 6/2 +f 2/5 30/11 38/19 +f 28/20 47/21 48/22 +f 8/23 55/24 56/25 +f 13/26 56/25 57/27 +f 14/28 57/27 58/29 +f 16/30 15/31 58/29 +f 16/30 59/32 60/33 +f 18/34 17/35 60/33 +f 19/36 18/34 61/37 +f 20/8 19/36 62/38 +f 20/8 63/39 64/40 +f 22/41 21/9 64/40 +f 22/41 65/42 66/43 +f 24/44 23/45 66/43 +f 24/44 67/46 68/47 +f 26/48 25/49 68/47 +f 26/48 69/50 70/51 +f 71/52 38/19 30/11 +f 32/13 31/12 72/53 +f 71/52 29/10 37/18 +f 35/54 82/55 83/56 +f 36/17 72/53 91/57 +f 62/38 61/37 31/12 +f 95/58 74/59 72/53 +f 28/20 7/6 38/19 +f 27/60 70/51 90/61 +f 39/62 90/61 89/63 +f 40/64 89/63 88/65 +f 41/66 88/65 87/67 +f 42/68 87/67 86/69 +f 43/70 86/69 85/71 +f 45/72 44/73 85/71 +f 45/72 84/74 83/56 +f 46/75 83/56 82/55 +f 47/21 82/55 81/76 +f 48/22 81/76 80/77 +f 49/78 80/77 79/79 +f 50/80 79/79 78/81 +f 51/82 78/81 77/83 +f 52/84 77/83 76/85 +f 53/86 76/85 75/87 +f 54/88 75/87 55/24 +f 37/18 91/57 96/89 +f 73/90 96/89 74/59 +f 74/59 96/89 91/57 +f 2/5 3/7 4/14 +f 7/6 8/23 9/91 +f 1/3 2/5 4/14 +f 1/3 4/14 5/1 +f 10/4 11/92 3/7 +f 9/91 10/4 7/6 +f 10/4 3/7 2/5 +f 12/93 16/30 11/92 +f 28/20 1/3 6/2 +f 12/93 9/91 8/23 +f 27/60 28/20 6/2 +f 14/28 15/31 12/93 +f 12/93 8/23 13/26 +f 26/48 27/60 6/2 +f 12/93 13/26 14/28 +f 25/49 26/48 6/2 +f 1/3 29/10 2/5 +f 24/44 25/49 6/2 +f 3/7 16/30 17/35 +f 23/45 24/44 6/2 +f 3/7 17/35 18/34 +f 22/41 23/45 6/2 +f 3/7 18/34 19/36 +f 21/9 22/41 6/2 +f 16/30 3/7 11/92 +f 6/2 3/7 21/9 +f 12/93 15/31 16/30 +f 4/14 3/7 32/13 +f 3/7 19/36 20/8 +f 5/1 4/14 33/15 +f 33/15 34/16 5/1 +f 1/3 28/20 35/54 +f 34/16 31/12 6/2 +f 1/3 35/54 36/17 +f 36/17 29/10 1/3 +f 7/6 2/5 38/19 +f 28/20 27/60 39/62 +f 54/88 8/23 7/6 +f 28/20 39/62 40/64 +f 53/86 54/88 7/6 +f 28/20 40/64 41/66 +f 52/84 53/86 7/6 +f 28/20 41/66 42/68 +f 51/82 52/84 7/6 +f 28/20 42/68 43/70 +f 50/80 51/82 7/6 +f 28/20 43/70 44/73 +f 49/78 50/80 7/6 +f 44/73 45/72 28/20 +f 7/6 28/20 49/78 +f 28/20 45/72 46/75 +f 14/28 13/26 57/27 +f 13/26 8/23 56/25 +f 28/20 48/22 49/78 +f 28/20 46/75 47/21 +f 15/31 14/28 58/29 +f 59/32 16/30 58/29 +f 17/35 16/30 60/33 +f 61/37 18/34 60/33 +f 62/38 19/36 61/37 +f 63/39 20/8 62/38 +f 21/9 20/8 64/40 +f 65/42 22/41 64/40 +f 23/45 22/41 66/43 +f 67/46 24/44 66/43 +f 25/49 24/44 68/47 +f 69/50 26/48 68/47 +f 27/60 26/48 70/51 +f 29/10 71/52 30/11 +f 36/17 34/16 33/15 +f 35/54 28/20 71/52 +f 33/15 32/13 36/17 +f 74/59 55/24 75/87 +f 32/13 72/53 36/17 +f 73/90 35/54 71/52 +f 71/52 37/18 73/90 +f 36/17 35/54 34/16 +f 74/59 75/87 76/85 +f 31/12 63/39 62/38 +f 74/59 76/85 77/83 +f 35/54 90/61 34/16 +f 74/59 77/83 78/81 +f 88/65 89/63 35/54 +f 78/81 79/79 74/59 +f 87/67 88/65 35/54 +f 74/59 79/79 80/77 +f 86/69 87/67 35/54 +f 35/54 74/59 80/77 +f 85/71 86/69 35/54 +f 35/54 80/77 81/76 +f 84/74 85/71 35/54 +f 35/54 81/76 82/55 +f 83/56 84/74 35/54 +f 37/18 36/17 91/57 +f 35/54 89/63 90/61 +f 34/16 90/61 70/51 +f 92/94 93/95 55/24 +f 92/94 55/24 74/59 +f 34/16 70/51 69/50 +f 59/32 94/96 31/12 +f 34/16 69/50 68/47 +f 31/12 34/16 64/40 +f 34/16 68/47 67/46 +f 93/95 57/27 56/25 +f 34/16 67/46 66/43 +f 93/95 58/29 57/27 +f 34/16 66/43 65/42 +f 93/95 59/32 58/29 +f 34/16 65/42 64/40 +f 93/95 94/96 59/32 +f 63/39 31/12 64/40 +f 61/37 60/33 31/12 +f 93/95 56/25 55/24 +f 94/96 95/58 31/12 +f 60/33 59/32 31/12 +f 39/62 27/60 90/61 +f 95/58 92/94 74/59 +f 71/52 28/20 38/19 +f 95/58 72/53 31/12 +f 40/64 39/62 89/63 +f 41/66 40/64 88/65 +f 42/68 41/66 87/67 +f 43/70 42/68 86/69 +f 44/73 43/70 85/71 +f 84/74 45/72 85/71 +f 46/75 45/72 83/56 +f 47/21 46/75 82/55 +f 48/22 47/21 81/76 +f 49/78 48/22 80/77 +f 50/80 49/78 79/79 +f 51/82 50/80 78/81 +f 52/84 51/82 77/83 +f 53/86 52/84 76/85 +f 54/88 53/86 75/87 +f 8/23 54/88 55/24 +f 73/90 37/18 96/89 +f 35/54 73/90 74/59 +f 72/53 74/59 91/57 +usemtl Material.004_NONE +f 10/97 95/97 94/97 +f 93/97 12/97 11/97 +f 10/97 9/97 92/97 +f 92/97 9/97 12/97 +f 11/97 10/97 94/97 +f 94/97 93/97 11/97 +f 95/97 10/97 92/97 +f 93/97 92/97 12/97 diff --git a/examples/CommonInterfaces/CommonGUIHelperInterface.h b/examples/CommonInterfaces/CommonGUIHelperInterface.h index 916a82343..a9e273f02 100644 --- a/examples/CommonInterfaces/CommonGUIHelperInterface.h +++ b/examples/CommonInterfaces/CommonGUIHelperInterface.h @@ -94,8 +94,8 @@ struct GUIHelperInterface int* segmentationMaskBuffer, int segmentationMaskBufferSizeInPixels, int startPixelIndex, int destinationWidth, int destinationHeight, int* numPixelsCopied){} - virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16])=0; - virtual void setProjectiveTexture(bool useProjectiveTexture)=0; + virtual void setProjectiveTextureMatrices(const float viewMatrix[16], const float projectionMatrix[16]){} + virtual void setProjectiveTexture(bool useProjectiveTexture){} virtual void autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWorld) =0; diff --git a/examples/CommonInterfaces/CommonRenderInterface.h b/examples/CommonInterfaces/CommonRenderInterface.h index a64fe7dde..4401f96e7 100644 --- a/examples/CommonInterfaces/CommonRenderInterface.h +++ b/examples/CommonInterfaces/CommonRenderInterface.h @@ -16,6 +16,7 @@ enum B3_CREATE_SHADOWMAP_RENDERMODE, B3_USE_SHADOWMAP_RENDERMODE, B3_USE_SHADOWMAP_RENDERMODE_REFLECTION, + B3_USE_SHADOWMAP_RENDERMODE_REFLECTION_PLANE, B3_USE_PROJECTIVE_TEXTURE_RENDERMODE, }; @@ -77,6 +78,8 @@ struct CommonRenderInterface virtual void replaceTexture(int shapeIndex, int textureIndex){}; virtual void removeTexture(int textureIndex) = 0; + virtual void setPlaneReflectionShapeIndex(int index) {} + virtual int getShapeIndexFromInstance(int srcIndex) {return -1;} virtual bool readSingleInstanceTransformToCPU(float* position, float* orientation, int srcIndex)=0; diff --git a/examples/Constraints/ConstraintDemo.cpp b/examples/Constraints/ConstraintDemo.cpp index 72ad1a8a6..cf7dc063d 100644 --- a/examples/Constraints/ConstraintDemo.cpp +++ b/examples/Constraints/ConstraintDemo.cpp @@ -356,7 +356,7 @@ void AllConstraintDemo::initPhysics() spSlider6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true; spSlider6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = -5.0f; - spSlider6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f; + spSlider6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 6.0f; m_dynamicsWorld->addConstraint(spSlider6Dof); @@ -431,7 +431,7 @@ void AllConstraintDemo::initPhysics() // pGen6DOF->getTranslationalLimitMotor()->m_enableMotor[0] = true; // pGen6DOF->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f; -// pGen6DOF->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f; +// pGen6DOF->getTranslationalLimitMotor()->m_maxMotorForce[0] = 6.0f; // pGen6DOF->setAngularLowerLimit(btVector3(0., SIMD_HALF_PI*0.9, 0.)); @@ -662,7 +662,7 @@ void AllConstraintDemo::initPhysics() pGen6Dof->getTranslationalLimitMotor()->m_enableMotor[0] = true; pGen6Dof->getTranslationalLimitMotor()->m_targetVelocity[0] = 5.0f; - pGen6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 0.1f; + pGen6Dof->getTranslationalLimitMotor()->m_maxMotorForce[0] = 6.0f; } #endif diff --git a/examples/Constraints/Dof6Spring2Setup.cpp b/examples/Constraints/Dof6Spring2Setup.cpp index 89129f7a6..a3fd5e8f4 100644 --- a/examples/Constraints/Dof6Spring2Setup.cpp +++ b/examples/Constraints/Dof6Spring2Setup.cpp @@ -300,11 +300,11 @@ void Dof6Spring2Setup::initPhysics() #ifdef USE_6DOF2 constraint->enableMotor(5,true); constraint->setTargetVelocity(5,3.f); - constraint->setMaxMotorForce(5,10.f); + constraint->setMaxMotorForce(5,600.f); #else constraint->getRotationalLimitMotor(2)->m_enableMotor = true; constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f; - constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10; + constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f; #endif constraint->setDbgDrawSize(btScalar(2.f)); m_dynamicsWorld->addConstraint(constraint, true); @@ -335,13 +335,13 @@ void Dof6Spring2Setup::initPhysics() #ifdef USE_6DOF2 constraint->enableMotor(5,true); constraint->setTargetVelocity(5,3.f); - constraint->setMaxMotorForce(5,10.f); + constraint->setMaxMotorForce(5,600.f); constraint->setServo(5,true); constraint->setServoTarget(5, M_PI_2); #else constraint->getRotationalLimitMotor(2)->m_enableMotor = true; constraint->getRotationalLimitMotor(2)->m_targetVelocity = 3.f; - constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 10; + constraint->getRotationalLimitMotor(2)->m_maxMotorForce = 600.f; //servo motor is not implemented in 6dofspring constraint #endif constraint->setDbgDrawSize(btScalar(2.f)); diff --git a/examples/ExampleBrowser/CMakeLists.txt b/examples/ExampleBrowser/CMakeLists.txt index cd50c7cf2..c19aca104 100644 --- a/examples/ExampleBrowser/CMakeLists.txt +++ b/examples/ExampleBrowser/CMakeLists.txt @@ -226,7 +226,6 @@ SET(BulletExampleBrowser_SRCS ../MultiThreading/b3PosixThreadSupport.cpp ../MultiThreading/b3Win32ThreadSupport.cpp ../MultiThreading/b3ThreadSupportInterface.cpp - ../MultiThreading/btTaskScheduler.cpp ../RenderingExamples/TinyRendererSetup.cpp ../RenderingExamples/TimeSeriesCanvas.cpp ../RenderingExamples/TimeSeriesCanvas.h @@ -339,15 +338,8 @@ SET(BulletExampleBrowser_SRCS ../ThirdPartyLibs/stb_image/stb_image.h ../ThirdPartyLibs/Wavefront/tiny_obj_loader.cpp - ../ThirdPartyLibs/tinyxml/tinystr.cpp - ../ThirdPartyLibs/tinyxml/tinyxml.cpp - ../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp - ../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp - - ../ThirdPartyLibs/tinyxml/tinystr.cpp - ../ThirdPartyLibs/tinyxml/tinyxml.cpp - ../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp - ../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp + + ../ThirdPartyLibs/tinyxml2/tinyxml2.cpp InProcessExampleBrowser.cpp ${BULLET_PHYSICS_SOURCE_DIR}/build3/bullet.rc ) diff --git a/examples/ExampleBrowser/CollisionShape2TriangleMesh.cpp b/examples/ExampleBrowser/CollisionShape2TriangleMesh.cpp index 868d25529..a4f4b9b3a 100644 --- a/examples/ExampleBrowser/CollisionShape2TriangleMesh.cpp +++ b/examples/ExampleBrowser/CollisionShape2TriangleMesh.cpp @@ -185,7 +185,13 @@ void CollisionShape2TriangleMesh(btCollisionShape* collisionShape, const btTrans } } else { - btAssert(0); + if (collisionShape->getShapeType()==SDF_SHAPE_PROXYTYPE) + { + //not yet + } else + { + btAssert(0); + } } } diff --git a/examples/ExampleBrowser/InProcessExampleBrowser.cpp b/examples/ExampleBrowser/InProcessExampleBrowser.cpp index caf32a51a..6a6d413a1 100644 --- a/examples/ExampleBrowser/InProcessExampleBrowser.cpp +++ b/examples/ExampleBrowser/InProcessExampleBrowser.cpp @@ -18,6 +18,8 @@ void ExampleBrowserThreadFunc(void* userPtr,void* lsMemory); void* ExampleBrowserMemoryFunc(); +void ExampleBrowserMemoryReleaseFunc(void* ptr); + #include //#include "BulletMultiThreaded/PlatformDefinitions.h" @@ -42,6 +44,7 @@ static b3ThreadSupportInterface* createExampleBrowserThreadSupport(int numThread b3PosixThreadSupport::ThreadConstructionInfo constructionInfo("testThreads", ExampleBrowserThreadFunc, ExampleBrowserMemoryFunc, + ExampleBrowserMemoryReleaseFunc, numThreads); b3ThreadSupportInterface* threadSupport = new b3PosixThreadSupport(constructionInfo); @@ -56,7 +59,7 @@ static b3ThreadSupportInterface* createExampleBrowserThreadSupport(int numThread b3ThreadSupportInterface* createExampleBrowserThreadSupport(int numThreads) { - b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("testThreads",ExampleBrowserThreadFunc,ExampleBrowserMemoryFunc,numThreads); + b3Win32ThreadSupport::Win32ThreadConstructionInfo threadConstructionInfo("testThreads",ExampleBrowserThreadFunc,ExampleBrowserMemoryFunc,ExampleBrowserMemoryReleaseFunc,numThreads); b3Win32ThreadSupport* threadSupport = new b3Win32ThreadSupport(threadConstructionInfo); return threadSupport; @@ -303,6 +306,12 @@ void* ExampleBrowserMemoryFunc() return new ExampleBrowserThreadLocalStorage; } +void ExampleBrowserMemoryReleaseFunc(void* ptr) +{ + ExampleBrowserThreadLocalStorage* p = (ExampleBrowserThreadLocalStorage*) ptr; + delete p; +} + diff --git a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp index 3a43573f8..99c953c09 100644 --- a/examples/ExampleBrowser/OpenGLExampleBrowser.cpp +++ b/examples/ExampleBrowser/OpenGLExampleBrowser.cpp @@ -410,6 +410,14 @@ void OpenGLExampleBrowserVisualizerFlagCallback(int flag, bool enable) if (flag == COV_ENABLE_WIREFRAME) { visualWireframe = enable; + if (visualWireframe) + { + gDebugDrawFlags |= btIDebugDraw::DBG_DrawWireframe; + } + else + { + gDebugDrawFlags &= ~btIDebugDraw::DBG_DrawWireframe; + } } } @@ -1257,7 +1265,7 @@ void OpenGLExampleBrowser::update(float deltaTime) { skip=gPngSkipFrames; //printf("gPngFileName=%s\n",gPngFileName); - static int s_frameCount = 100; + static int s_frameCount = 0; sprintf(staticPngFileName,"%s%d.png",gPngFileName,s_frameCount++); //b3Printf("Made screenshot %s",staticPngFileName); diff --git a/examples/ExampleBrowser/OpenGLGuiHelper.cpp b/examples/ExampleBrowser/OpenGLGuiHelper.cpp index 71970893a..536843450 100644 --- a/examples/ExampleBrowser/OpenGLGuiHelper.cpp +++ b/examples/ExampleBrowser/OpenGLGuiHelper.cpp @@ -433,10 +433,14 @@ void OpenGLGuiHelper::createCollisionShapeGraphicsObject(btCollisionShape* colli if (collisionShape->getShapeType() == SOFTBODY_SHAPE_PROXYTYPE) { computeSoftBodyVertices(collisionShape, gfxVertices, indices); - int shapeId = registerGraphicsShape(&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, - m_data->m_checkedTexture); - b3Assert(shapeId >= 0); - collisionShape->setUserIndex(shapeId); + if (gfxVertices.size() && indices.size()) + { + int shapeId = registerGraphicsShape(&gfxVertices[0].xyzw[0], gfxVertices.size(), &indices[0], indices.size(), B3_GL_TRIANGLES, + m_data->m_checkedTexture); + + b3Assert(shapeId >= 0); + collisionShape->setUserIndex(shapeId); + } } if (collisionShape->getShapeType()==MULTI_SPHERE_SHAPE_PROXYTYPE) { @@ -1026,6 +1030,10 @@ void OpenGLGuiHelper::setVisualizerFlagCallback(VisualizerFlagCallback callback) void OpenGLGuiHelper::setVisualizerFlag(int flag, int enable) { + if (getRenderInterface() && flag==16)//COV_ENABLE_PLANAR_REFLECTION + { + getRenderInterface()->setPlaneReflectionShapeIndex(enable); + } if (m_data->m_visualizerFlagCallback) (m_data->m_visualizerFlagCallback)(flag,enable); } @@ -1261,6 +1269,11 @@ void OpenGLGuiHelper::autogenerateGraphicsObjects(btDiscreteDynamicsWorld* rbWor btCollisionObject* colObj = sortedObjects[i]; //btRigidBody* body = btRigidBody::upcast(colObj); //does this also work for btMultiBody/btMultiBodyLinkCollider? + btSoftBody* sb = btSoftBody::upcast(colObj); + if (sb) + { + colObj->getCollisionShape()->setUserPointer(sb); + } createCollisionShapeGraphicsObject(colObj->getCollisionShape()); int colorIndex = colObj->getBroadphaseHandle()->getUid() & 3; @@ -1309,6 +1322,8 @@ void OpenGLGuiHelper::computeSoftBodyVertices(btCollisionShape* collisionShape, btAlignedObjectArray& gfxVertices, btAlignedObjectArray& indices) { + if (collisionShape->getUserPointer()==0) + return; b3Assert(collisionShape->getUserPointer()); btSoftBody* psb = (btSoftBody*)collisionShape->getUserPointer(); gfxVertices.resize(psb->m_faces.size() * 3); diff --git a/examples/ExampleBrowser/premake4.lua b/examples/ExampleBrowser/premake4.lua index 3c38d756d..817c4233d 100644 --- a/examples/ExampleBrowser/premake4.lua +++ b/examples/ExampleBrowser/premake4.lua @@ -164,14 +164,11 @@ project "App_BulletExampleBrowser" "../RigidBody/RigidBodySoftContact.cpp", "../ThirdPartyLibs/stb_image/*", "../ThirdPartyLibs/Wavefront/tiny_obj_loader.*", - "../ThirdPartyLibs/tinyxml/*", "../ThirdPartyLibs/BussIK/*", "../GyroscopicDemo/GyroscopicSetup.cpp", "../GyroscopicDemo/GyroscopicSetup.h", - "../ThirdPartyLibs/tinyxml/tinystr.cpp", - "../ThirdPartyLibs/tinyxml/tinyxml.cpp", - "../ThirdPartyLibs/tinyxml/tinyxmlerror.cpp", - "../ThirdPartyLibs/tinyxml/tinyxmlparser.cpp", + "../ThirdPartyLibs/tinyxml2/tinyxml2.cpp", + "../ThirdPartyLibs/tinyxml2/tinyxml2.h", } if (hasCL and findOpenGL3()) then files { diff --git a/examples/ExtendedTutorials/SimpleCloth.cpp b/examples/ExtendedTutorials/SimpleCloth.cpp index ec0dd337c..0d62a2dc2 100644 --- a/examples/ExtendedTutorials/SimpleCloth.cpp +++ b/examples/ExtendedTutorials/SimpleCloth.cpp @@ -121,6 +121,7 @@ void SimpleClothExample::createSoftBody(const btScalar s, fixed,true); cloth->getCollisionShape()->setMargin(0.001f); + cloth->getCollisionShape()->setUserPointer((void*)cloth); cloth->generateBendingConstraints(2,cloth->appendMaterial()); cloth->setTotalMass(10); //cloth->m_cfg.citerations = 10; diff --git a/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp b/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp index 348b96d7c..f5c5cc563 100644 --- a/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp +++ b/examples/Importers/ImportColladaDemo/LoadMeshFromCollada.cpp @@ -20,7 +20,8 @@ subject to the following restrictions: #include //fopen #include "Bullet3Common/b3AlignedObjectArray.h" #include -#include "../../ThirdPartyLibs/tinyxml/tinyxml.h" +#include "../../ThirdPartyLibs/tinyxml2/tinyxml2.h" +using namespace tinyxml2; #include "Bullet3Common/b3FileUtils.h" #include "LinearMath/btHashMap.h" @@ -90,14 +91,14 @@ void tokenize(const std::string& str, AddToken& tokenAdder, const std::string& d } -void readFloatArray(TiXmlElement* source, btAlignedObjectArray& floatArray, int& componentStride) +void readFloatArray(XMLElement* source, btAlignedObjectArray& floatArray, int& componentStride) { int numVals, stride; - TiXmlElement* array = source->FirstChildElement("float_array"); + XMLElement* array = source->FirstChildElement("float_array"); if(array) { componentStride = 1; - if (source->FirstChildElement("technique_common")->FirstChildElement("accessor")->QueryIntAttribute("stride", &stride)!= TIXML_NO_ATTRIBUTE) + if (source->FirstChildElement("technique_common")->FirstChildElement("accessor")->QueryIntAttribute("stride", &stride)!= XML_NO_ATTRIBUTE) { componentStride = stride; } @@ -140,11 +141,11 @@ btVector4 getVector4FromXmlText(const char* text) } -void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray& visualShapes, btHashMap& name2Shape, float extraScaling) +void readLibraryGeometries(XMLDocument& doc, btAlignedObjectArray& visualShapes, btHashMap& name2Shape, float extraScaling) { - btHashMap allSources; + btHashMap allSources; btHashMap vertexSources; - for(TiXmlElement* geometry = doc.RootElement()->FirstChildElement("library_geometries")->FirstChildElement("geometry"); + for(XMLElement* geometry = doc.RootElement()->FirstChildElement("library_geometries")->FirstChildElement("geometry"); geometry != NULL; geometry = geometry->NextSiblingElement("geometry")) { btAlignedObjectArray vertexPositions; @@ -152,11 +153,11 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray indices; const char* geometryName = geometry->Attribute("id"); - for (TiXmlElement* mesh = geometry->FirstChildElement("mesh");(mesh != NULL); mesh = mesh->NextSiblingElement("mesh")) + for (XMLElement* mesh = geometry->FirstChildElement("mesh");(mesh != NULL); mesh = mesh->NextSiblingElement("mesh")) { - TiXmlElement* vertices2 = mesh->FirstChildElement("vertices"); + XMLElement* vertices2 = mesh->FirstChildElement("vertices"); - for (TiXmlElement* source = mesh->FirstChildElement("source");source != NULL;source = source->NextSiblingElement("source")) + for (XMLElement* source = mesh->FirstChildElement("source");source != NULL;source = source->NextSiblingElement("source")) { const char* srcId= source->Attribute("id"); // printf("source id=%s\n",srcId); @@ -165,7 +166,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArrayAttribute("id"); //printf("vertices id=%s\n",vertexId); VertexSource vs; - for(TiXmlElement* input = vertices2->FirstChildElement("input");input != NULL;input = input->NextSiblingElement("input")) + for(XMLElement* input = vertices2->FirstChildElement("input");input != NULL;input = input->NextSiblingElement("input")) { const char* sem = input->Attribute("semantic"); std::string semName(sem); @@ -187,7 +188,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArrayFirstChildElement("triangles"); primitive; primitive = primitive->NextSiblingElement("triangles")) + for (XMLElement* primitive = mesh->FirstChildElement("triangles"); primitive; primitive = primitive->NextSiblingElement("triangles")) { std::string positionSourceName; std::string normalSourceName; @@ -199,7 +200,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArrayFirstChildElement("input");input != NULL;input = input->NextSiblingElement("input")) + for (XMLElement* input = primitive->FirstChildElement("input");input != NULL;input = input->NextSiblingElement("input")) { const char* sem = input->Attribute("semantic"); std::string semName(sem); @@ -241,7 +242,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray positionFloatArray; int posStride=1; - TiXmlElement** sourcePtr = allSources[positionSourceName.c_str()]; + XMLElement** sourcePtr = allSources[positionSourceName.c_str()]; if (sourcePtr) { readFloatArray(*sourcePtr,positionFloatArray, posStride); @@ -334,7 +335,7 @@ void readLibraryGeometries(TiXmlDocument& doc, btAlignedObjectArray& name2Shape, btAlignedObjectArray& visualShapeInstances, const btMatrix4x4& parentTransMat) +void readNodeHierarchy(XMLElement* node,btHashMap& name2Shape, btAlignedObjectArray& visualShapeInstances, const btMatrix4x4& parentTransMat) { @@ -343,7 +344,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap& name2Shap ///todo(erwincoumans) we probably have to read the elements 'translate', 'scale', 'rotate' and 'matrix' in-order and accumulate them... { - for (TiXmlElement* transElem = node->FirstChildElement("matrix");transElem;transElem=node->NextSiblingElement("matrix")) + for (XMLElement* transElem = node->FirstChildElement("matrix");transElem;transElem=node->NextSiblingElement("matrix")) { if (transElem->GetText()) { @@ -367,7 +368,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap& name2Shap } { - for (TiXmlElement* transElem = node->FirstChildElement("translate");transElem;transElem=node->NextSiblingElement("translate")) + for (XMLElement* transElem = node->FirstChildElement("translate");transElem;transElem=node->NextSiblingElement("translate")) { if (transElem->GetText()) { @@ -381,7 +382,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap& name2Shap } } { - for(TiXmlElement* scaleElem = node->FirstChildElement("scale"); + for(XMLElement* scaleElem = node->FirstChildElement("scale"); scaleElem!= NULL; scaleElem= node->NextSiblingElement("scale")) { if (scaleElem->GetText()) @@ -394,7 +395,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap& name2Shap } } { - for(TiXmlElement* rotateElem = node->FirstChildElement("rotate"); + for(XMLElement* rotateElem = node->FirstChildElement("rotate"); rotateElem!= NULL; rotateElem= node->NextSiblingElement("rotate")) { if (rotateElem->GetText()) @@ -411,7 +412,7 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap& name2Shap nodeTrans = parentTransMat*nodeTrans; - for (TiXmlElement* instanceGeom = node->FirstChildElement("instance_geometry"); + for (XMLElement* instanceGeom = node->FirstChildElement("instance_geometry"); instanceGeom!=0; instanceGeom=instanceGeom->NextSiblingElement("instance_geometry")) { @@ -432,22 +433,22 @@ void readNodeHierarchy(TiXmlElement* node,btHashMap& name2Shap } } - for(TiXmlElement* childNode = node->FirstChildElement("node"); + for(XMLElement* childNode = node->FirstChildElement("node"); childNode!= NULL; childNode = childNode->NextSiblingElement("node")) { readNodeHierarchy(childNode,name2Shape,visualShapeInstances, nodeTrans); } } -void readVisualSceneInstanceGeometries(TiXmlDocument& doc, btHashMap& name2Shape, btAlignedObjectArray& visualShapeInstances) +void readVisualSceneInstanceGeometries(XMLDocument& doc, btHashMap& name2Shape, btAlignedObjectArray& visualShapeInstances) { - btHashMap allVisualScenes; + btHashMap allVisualScenes; - TiXmlElement* libVisualScenes = doc.RootElement()->FirstChildElement("library_visual_scenes"); + XMLElement* libVisualScenes = doc.RootElement()->FirstChildElement("library_visual_scenes"); if (libVisualScenes==0) return; { - for(TiXmlElement* scene = libVisualScenes->FirstChildElement("visual_scene"); + for(XMLElement* scene = libVisualScenes->FirstChildElement("visual_scene"); scene != NULL; scene = scene->NextSiblingElement("visual_scene")) { const char* sceneName = scene->Attribute("id"); @@ -455,16 +456,16 @@ void readVisualSceneInstanceGeometries(TiXmlDocument& doc, btHashMapFirstChildElement("scene"); + XMLElement* scenes = doc.RootElement()->FirstChildElement("scene"); if (scenes) { - TiXmlElement* instanceSceneReference = scenes->FirstChildElement("instance_visual_scene"); + XMLElement* instanceSceneReference = scenes->FirstChildElement("instance_visual_scene"); if (instanceSceneReference) { const char* instanceSceneUrl = instanceSceneReference->Attribute("url"); - TiXmlElement** sceneInstancePtr = allVisualScenes[instanceSceneUrl+1];//skip # + XMLElement** sceneInstancePtr = allVisualScenes[instanceSceneUrl+1];//skip # if (sceneInstancePtr) { scene = *sceneInstancePtr; @@ -475,7 +476,7 @@ void readVisualSceneInstanceGeometries(TiXmlDocument& doc, btHashMapFirstChildElement("node"); + for(XMLElement* node = scene->FirstChildElement("node"); node != NULL; node = node->NextSiblingElement("node")) { btMatrix4x4 identity; @@ -488,11 +489,11 @@ void readVisualSceneInstanceGeometries(TiXmlDocument& doc, btHashMapFirstChildElement("asset")->FirstChildElement("unit"); + XMLElement* unitMeter = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("unit"); if (unitMeter) { const char* meterText = unitMeter->Attribute("meter"); @@ -500,7 +501,7 @@ void getUnitMeterScalingAndUpAxisTransform(TiXmlDocument& doc, btTransform& tr, unitMeterScaling = atof(meterText); } - TiXmlElement* upAxisElem = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("up_axis"); + XMLElement* upAxisElem = doc.RootElement()->FirstChildElement("asset")->FirstChildElement("up_axis"); if (upAxisElem) { switch (clientUpAxis) @@ -573,8 +574,8 @@ void LoadMeshFromCollada(const char* relativeFileName, btAlignedObjectArrayRow()); + sprintf(row,"%d",e->GetLineNum()); std::string str = m_sourceFileName.c_str() + std::string(":") + std::string(row); return str; #endif @@ -261,7 +261,7 @@ struct BulletMJCFImporterInternalData return 0; } - void parseCompiler(TiXmlElement* root_xml, MJCFErrorLogger* logger) + void parseCompiler(XMLElement* root_xml, MJCFErrorLogger* logger) { const char* meshDirStr = root_xml->Attribute("meshdir"); @@ -284,10 +284,10 @@ struct BulletMJCFImporterInternalData } - void parseAssets(TiXmlElement* root_xml, MJCFErrorLogger* logger) + void parseAssets(XMLElement* root_xml, MJCFErrorLogger* logger) { // - for (TiXmlElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement()) + for (XMLElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement()) { std::string n = child_xml->Value(); if (n=="mesh") @@ -307,11 +307,11 @@ struct BulletMJCFImporterInternalData } - bool parseDefaults(MyMJCFDefaults& defaults, TiXmlElement* root_xml, MJCFErrorLogger* logger) + bool parseDefaults(MyMJCFDefaults& defaults, XMLElement* root_xml, MJCFErrorLogger* logger) { bool handled= false; //rudimentary 'default' support, would need more work for better feature coverage - for (TiXmlElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement()) + for (XMLElement* child_xml = root_xml->FirstChildElement() ; child_xml ; child_xml = child_xml->NextSiblingElement()) { std::string n = child_xml->Value(); @@ -413,9 +413,9 @@ struct BulletMJCFImporterInternalData handled=true; return handled; } - bool parseRootLevel(MyMJCFDefaults& defaults, TiXmlElement* root_xml,MJCFErrorLogger* logger) + bool parseRootLevel(MyMJCFDefaults& defaults, XMLElement* root_xml,MJCFErrorLogger* logger) { - for (TiXmlElement* rootxml = root_xml->FirstChildElement() ; rootxml ; rootxml = rootxml->NextSiblingElement()) + for (XMLElement* rootxml = root_xml->FirstChildElement() ; rootxml ; rootxml = rootxml->NextSiblingElement()) { bool handled = false; std::string n = rootxml->Value(); @@ -473,7 +473,7 @@ struct BulletMJCFImporterInternalData return true; } - bool parseJoint(MyMJCFDefaults& defaults, TiXmlElement* link_xml, int modelIndex, int parentLinkIndex, int linkIndex, MJCFErrorLogger* logger, const btTransform& parentToLinkTrans, btTransform& jointTransOut) + bool parseJoint(MyMJCFDefaults& defaults, XMLElement* link_xml, int modelIndex, int parentLinkIndex, int linkIndex, MJCFErrorLogger* logger, const btTransform& parentToLinkTrans, btTransform& jointTransOut) { bool jointHandled = false; const char* jType = link_xml->Attribute("type"); @@ -649,7 +649,7 @@ struct BulletMJCFImporterInternalData */ return false; } - bool parseGeom(MyMJCFDefaults& defaults, TiXmlElement* link_xml, int modelIndex, int linkIndex, MJCFErrorLogger* logger, btVector3& inertialShift) + bool parseGeom(MyMJCFDefaults& defaults, XMLElement* link_xml, int modelIndex, int linkIndex, MJCFErrorLogger* logger, btVector3& inertialShift) { UrdfLink** linkPtrPtr = m_models[modelIndex]->m_links.getAtIndex(linkIndex); if (linkPtrPtr==0) @@ -963,7 +963,7 @@ struct BulletMJCFImporterInternalData return handledGeomType; } - btTransform parseTransform(TiXmlElement* link_xml, MJCFErrorLogger* logger) + btTransform parseTransform(XMLElement* link_xml, MJCFErrorLogger* logger) { btTransform tr; tr.setIdentity(); @@ -1032,6 +1032,11 @@ struct BulletMJCFImporterInternalData //todo break; } + case URDF_GEOM_CDF: + { + //todo + break; + } case URDF_GEOM_CYLINDER: case URDF_GEOM_CAPSULE: { @@ -1090,7 +1095,7 @@ struct BulletMJCFImporterInternalData return orgChildLinkIndex; } - bool parseBody(MyMJCFDefaults& defaults, TiXmlElement* link_xml, int modelIndex, int orgParentLinkIndex, MJCFErrorLogger* logger) + bool parseBody(MyMJCFDefaults& defaults, XMLElement* link_xml, int modelIndex, int orgParentLinkIndex, MJCFErrorLogger* logger) { MyMJCFDefaults curDefaults = defaults; @@ -1142,7 +1147,7 @@ struct BulletMJCFImporterInternalData jointTrans.setIdentity(); bool skipFixedJoint = false; - for (TiXmlElement* xml = link_xml->FirstChildElement() ; xml ; xml = xml->NextSiblingElement()) + for (XMLElement* xml = link_xml->FirstChildElement() ; xml ; xml = xml->NextSiblingElement()) { bool handled = false; std::string n = xml->Value(); @@ -1482,16 +1487,16 @@ bool BulletMJCFImporter::loadMJCF(const char* fileName, MJCFErrorLogger* logger, bool BulletMJCFImporter::parseMJCFString(const char* xmlText, MJCFErrorLogger* logger) { - TiXmlDocument xml_doc; + XMLDocument xml_doc; xml_doc.Parse(xmlText); if (xml_doc.Error()) { - logger->reportError(xml_doc.ErrorDesc()); + logger->reportError(xml_doc.ErrorStr()); xml_doc.ClearError(); return false; } - TiXmlElement *mujoco_xml = xml_doc.FirstChildElement("mujoco"); + XMLElement *mujoco_xml = xml_doc.FirstChildElement("mujoco"); if (!mujoco_xml) { logger->reportWarning("Cannot find root element"); @@ -1507,28 +1512,28 @@ bool BulletMJCFImporter::parseMJCFString(const char* xmlText, MJCFErrorLogger* l //,