Commit 652fa86d authored by Lionel Untereiner's avatar Lionel Untereiner

Merge branch 'develop' of icube-forge.unistra.fr:cgogn/cgogn into develop

parents e38ed6af 6471d0c6
...@@ -9,6 +9,29 @@ SET ( CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR} ) ...@@ -9,6 +9,29 @@ SET ( CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR} )
SET ( CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/ ) SET ( CMAKE_MODULE_PATH ${CGoGN_ROOT_DIR}/cmake_modules/ )
# ====== Check GCC VERSION FOR C++11 ======
if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_LESS 4.8)
message(FATAL_ERROR "Full support of C++11 needed. Therefore a gcc/g++ compiler with a version at least 4.8 is needed.")
endif()
endif()
# ====== Check CLANG VERSION FOR C++11 ======
if (APPLE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE CLANG_VERSION)
if (CLANG_VERSION VERSION_LESS 3.1)
message(FATAL_ERROR "Full support of C++11 needed. Therefore a clang compiler with a version at least 3.1 is needed !!")
endif()
endif()
# ====== Check MSVC VERSION FOR C++11 ======
if(WIN32)
if(MSVC_VERSION LESS 1800)
message(FATAL_ERROR "Full support of C++11 needed. Therefore a microsoft compiler with a version at least 12 is needed.")
endif()
endif()
IF (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug|Release")) IF (NOT (${CMAKE_BUILD_TYPE} MATCHES "Debug|Release"))
IF (${CMAKE_CURRENT_BINARY_DIR} MATCHES "(.*)Debug|(.*)debug|(.*)DEBUG") IF (${CMAKE_CURRENT_BINARY_DIR} MATCHES "(.*)Debug|(.*)debug|(.*)DEBUG")
...@@ -58,7 +81,6 @@ ENDIF(WIN32) ...@@ -58,7 +81,6 @@ ENDIF(WIN32)
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(Boost COMPONENTS regex REQUIRED) find_package(Boost COMPONENTS regex REQUIRED)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(GLEW REQUIRED) find_package(GLEW REQUIRED)
# MESSAGE HERE FOR MORE EASY USER READING # MESSAGE HERE FOR MORE EASY USER READING
...@@ -98,7 +120,6 @@ SET (CGoGN_EXT_INCLUDES ...@@ -98,7 +120,6 @@ SET (CGoGN_EXT_INCLUDES
${OPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
) )
...@@ -108,8 +129,8 @@ SET (CGoGN_EXT_LIBS ...@@ -108,8 +129,8 @@ SET (CGoGN_EXT_LIBS
${OPENGL_LIBRARY} ${OPENGL_LIBRARY}
${GLEW_LIBRARIES} ${GLEW_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${LIBXML2_LIBRARIES}
${Boost_REGEX_LIBRARY} ${Boost_REGEX_LIBRARY}
tinyxml2
) )
IF(WIN32) IF(WIN32)
......
...@@ -3,7 +3,7 @@ English version bellow ...@@ -3,7 +3,7 @@ English version bellow
Dépendences Linux Dépendences Linux
================= =================
installer les paquets suivants: installer les paquets suivants:
cmake cmake-curses-gui cmake-qt-gui libXi-dev libXmu-dev libglew-dev libxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev libgsl0-dev libsuitesparse-dev cmake cmake-curses-gui cmake-qt-gui libXi-dev libXmu-dev libglew-dev libtinyxml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev libgsl0-dev libsuitesparse-dev
Pour compiler CGoGN Pour compiler CGoGN
......
...@@ -23,7 +23,6 @@ SET( USE_OGL_CORE_PROFILE OFF CACHE BOOL "use OpenGL 3.3 core profile (do not wo ...@@ -23,7 +23,6 @@ SET( USE_OGL_CORE_PROFILE OFF CACHE BOOL "use OpenGL 3.3 core profile (do not wo
find_package(OpenGL REQUIRED) find_package(OpenGL REQUIRED)
find_package(Boost COMPONENTS regex system REQUIRED) find_package(Boost COMPONENTS regex system REQUIRED)
find_package(ZLIB REQUIRED) find_package(ZLIB REQUIRED)
find_package(LibXml2 REQUIRED)
find_package(GLEW REQUIRED) find_package(GLEW REQUIRED)
find_package(Qt4 REQUIRED) find_package(Qt4 REQUIRED)
find_package(QGLViewer REQUIRED) find_package(QGLViewer REQUIRED)
...@@ -73,7 +72,6 @@ SET (EXT_INCLUDES ...@@ -73,7 +72,6 @@ SET (EXT_INCLUDES
${OPENGL_INCLUDE_DIR} ${OPENGL_INCLUDE_DIR}
${GLEW_INCLUDE_DIRS} ${GLEW_INCLUDE_DIRS}
${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIRS}
${LIBXML2_INCLUDE_DIR}
${Boost_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS}
${QT_INCLUDE_DIR} ${QT_INCLUDE_DIR}
${QGLVIEWER_INCLUDE_DIR} ${QGLVIEWER_INCLUDE_DIR}
...@@ -86,17 +84,17 @@ SET (EXT_INCLUDES ...@@ -86,17 +84,17 @@ SET (EXT_INCLUDES
SET (EXT_LIBS SET (EXT_LIBS
PythonQt PythonQt
nl nl
${QGLVIEWER_LIBRARIES}
${OPENGL_LIBRARY} ${OPENGL_LIBRARY}
${GLEW_LIBRARIES} ${GLEW_LIBRARIES}
${ZLIB_LIBRARIES} ${ZLIB_LIBRARIES}
${LIBXML2_LIBRARIES}
${Boost_SYSTEM_LIBRARY} ${Boost_SYSTEM_LIBRARY}
${Boost_REGEX_LIBRARY} ${Boost_REGEX_LIBRARY}
${QT_LIBRARIES} ${QT_LIBRARIES}
${QGLVIEWER_LIBRARIES}
${PYTHON_LIBRARIES} ${PYTHON_LIBRARIES}
${SUITESPARSE_LIBRARIES} ${SUITESPARSE_LIBRARIES}
# ${SUPERLU_LIBRARIES} # ${SUPERLU_LIBRARIES}
tinyxml2
) )
......
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 2.8)
include(ExternalProject)
project(CGoGN_ThirdParty) project(CGoGN_ThirdParty)
SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/..) SET(CGoGN_ROOT_DIR ${CMAKE_SOURCE_DIR}/..)
IF(WIN32) IF(WIN32)
...@@ -36,6 +39,7 @@ ENDIF(WIN32) ...@@ -36,6 +39,7 @@ ENDIF(WIN32)
SET (BUILD_SHARED_LIBS OFF CACHE BOOL SET (BUILD_SHARED_LIBS OFF CACHE BOOL
"if used all library are build as shared type (.so/.dylib/.dll)") "if used all library are build as shared type (.so/.dylib/.dll)")
SET (WITH_TINYXML2 ON CACHE BOOL "get & build tinyxml2")
SET (WITH_ASSIMP OFF CACHE BOOL "build with Assimp") SET (WITH_ASSIMP OFF CACHE BOOL "build with Assimp")
SET (WITH_ZINRI ON CACHE BOOL "build with Zinri libs") SET (WITH_ZINRI ON CACHE BOOL "build with Zinri libs")
SET (WITH_PYTHONQT ON CACHE BOOL "build PythonQt (for Schnapps)") SET (WITH_PYTHONQT ON CACHE BOOL "build PythonQt (for Schnapps)")
...@@ -67,5 +71,18 @@ IF (WITH_ASSIMP) ...@@ -67,5 +71,18 @@ IF (WITH_ASSIMP)
INSTALL (DIRECTORY Assimp/include/ DESTINATION ${CGoGN_ROOT_DIR}/ThirdParty/include/Assimp) INSTALL (DIRECTORY Assimp/include/ DESTINATION ${CGoGN_ROOT_DIR}/ThirdParty/include/Assimp)
ENDIF (WITH_ASSIMP) ENDIF (WITH_ASSIMP)
IF (WITH_TINYXML2)
ExternalProject_Add(
Tinyxml2
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/tinyxml2
GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git
CMAKE_CACHE_ARGS "-DCMAKE_BUILD_TYPE:string=${CMAKE_BUILD_TYPE}"
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CGoGN_ROOT_DIR}/ThirdParty/TinyXml2"
BUILD_COMMAND make
INSTALL_COMMAND make install
)
INSTALL (DIRECTORY TinyXml2/include/ DESTINATION ${CGoGN_ROOT_DIR}/ThirdParty/include)
FILE(GLOB_RECURSE tinyLib_files ${CGoGN_ROOT_DIR}/ThirdParty/TinyXml2/lib/*.so.* ${CGoGN_ROOT_DIR}/ThirdParty/TinyXml2/lib/*.a )
INSTALL (FILES ${tinyLib_files} DESTINATION ${CGoGN_ROOT_DIR}/lib/${CMAKE_BUILD_TYPE})
ENDIF (WITH_TINYXML2)
\ No newline at end of file
#########################
# UPDATE VARIABLES:
# - TINYXML2_FOUND
# - TINYXML2_INCLUDE_DIR
# - TINYXML2_LIBRARY
#########################
find_path(TINYXML2_INCLUDE_DIR tinyxml2.h
HINTS $ENV{TINYXML2DIR}
PATH_SUFFIXES include
PATHS ~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr)
find_library(TINYXML2_LIBRARY tinyxml2
HINTS $ENV{TINYXML2DIR}
PATH_SUFFIXES lib64 lib
PATH_SUFFIXESS ~/Library/Frameworks
/Library/Frameworks
/usr/local
/usr)
include(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(TINYXML2 DEFAULT_MSG TINYXML2_LIBRARY)
mark_as_advanced(TINYXML2_LIBRARY TINYXML2_INCLUDE_DIR)
...@@ -24,9 +24,12 @@ ...@@ -24,9 +24,12 @@
#include "Geometry/orientation.h" #include "Geometry/orientation.h"
#include <libxml/encoding.h> //#include <libxml/encoding.h>
#include <libxml/xmlwriter.h> //#include <libxml/xmlwriter.h>
#include <libxml/parser.h> //#include <libxml/parser.h>
//#include <tinyxml2.h>
#include "Utils/xml.h"
namespace CGoGN namespace CGoGN
{ {
...@@ -1467,9 +1470,249 @@ bool MeshTablesVolume<PFP>::importVBGZ(const std::string& filename, std::vector< ...@@ -1467,9 +1470,249 @@ bool MeshTablesVolume<PFP>::importVBGZ(const std::string& filename, std::vector<
return true; return true;
} }
//template <typename PFP>
//bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<std::string>& attrNames)
//{
// VertexAttribute<VEC3, MAP> position = m_map.template getAttribute<VEC3, VERTEX, MAP>("position") ;
// if (!position.isValid())
// position = m_map.template addAttribute<VEC3, VERTEX, MAP>("position") ;
// attrNames.push_back(position.name()) ;
// //
// AttributeContainer& container = m_map.template getAttributeContainer<VERTEX>() ;
// xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0);
// xmlNodePtr vtu_node = xmlDocGetRootElement(doc);
// // std::cout << " NAME "<<vtu_node->name << std::endl;
// xmlChar *prop = xmlGetProp(vtu_node, BAD_CAST "type");
// // std::cout << "type = "<< prop << std::endl;
// xmlNode* grid_node = vtu_node->children;
// while (strcmp((char*)(grid_node->name),(char*)"UnstructuredGrid")!=0)
// grid_node = grid_node->next;
// xmlNode* piece_node = grid_node->children;
// while (strcmp((char*)(piece_node->name),(char*)"Piece")!=0)
// piece_node = piece_node->next;
// prop = xmlGetProp(piece_node, BAD_CAST "NumberOfPoints");
// m_nbVertices = atoi((char*)(prop));
// prop = xmlGetProp(piece_node, BAD_CAST "NumberOfCells");
// m_nbVolumes = atoi((char*)(prop));
// std::cout << "Number of points = "<< m_nbVertices<< std::endl;
// std::cout << "Number of cells = "<< m_nbVolumes << std::endl;
// xmlNode* points_node = piece_node->children;
// while (strcmp((char*)(points_node->name),(char*)"Points")!=0)
// points_node = points_node->next;
// points_node = points_node->children;
// while (strcmp((char*)(points_node->name),(char*)"DataArray")!=0)
// points_node = points_node->next;
// std::vector<unsigned int> verticesID;
// verticesID.reserve(m_nbVertices);
// std::stringstream ss((char*)(xmlNodeGetContent(points_node->children)));
// for (unsigned int i=0; i< m_nbVertices; ++i)
// {
// typename PFP::VEC3 P;
// ss >> P[0]; ss >> P[1]; ss >> P[2];
// unsigned int id = container.insertLine();
// position[id] = P;
// verticesID.push_back(id);
// }
// xmlNode* cell_node = piece_node->children;
// while (strcmp((char*)(cell_node->name),(char*)"Cells")!=0)
// cell_node = cell_node->next;
// std::cout <<"CELL NODE = "<< cell_node->name << std::endl;
// std::vector<unsigned char> typeVols;
// typeVols.reserve(m_nbVolumes);
// std::vector<unsigned int> offsets;
// offsets.reserve(m_nbVolumes);
// std::vector<unsigned int> indices;
// indices.reserve(m_nbVolumes*4);
// for (xmlNode* x_node = cell_node->children; x_node!=NULL; x_node = x_node->next)
// {
// while ((x_node!=NULL) && (strcmp((char*)(x_node->name),(char*)"DataArray")!=0))
// x_node = x_node->next;
// if (x_node == NULL)
// break;
// else
// {
// xmlChar* type = xmlGetProp(x_node, BAD_CAST "Name");
// if (strcmp((char*)(type),(char*)"connectivity")==0)
// {
// std::stringstream ss((char*)(xmlNodeGetContent(x_node->children)));
// while (!ss.eof())
// {
// unsigned int ind;
// ss >> ind;
// indices.push_back(ind);
// }
// }
// if (strcmp((char*)(type),(char*)"offsets")==0)
// {
// std::stringstream ss((char*)(xmlNodeGetContent(x_node->children)));
// for (unsigned int i=0; i< m_nbVolumes; ++i)
// {
// unsigned int o;
// ss >> o;
// offsets.push_back(o);
// }
// }
// if (strcmp((char*)(type),(char*)"types")==0)
// {
// bool unsupported = false;
// std::stringstream ss((char*)(xmlNodeGetContent(x_node->children)));
// for (unsigned int i=0; i< m_nbVolumes; ++i)
// {
// unsigned int t;
// ss >> t;
// if ((t != 12) && (t!= 10))
// {
// unsupported = true;
// typeVols.push_back(0);
// }
// else
// {
// typeVols.push_back((unsigned char)t);
// }
// }
// if (unsupported)
// CGoGNerr << "warning, some unsupported volume cell types"<< CGoGNendl;
// }
// }
// }
// xmlFreeDoc(doc);
// unsigned int currentOffset = 0;
// for (unsigned int i=0; i< m_nbVolumes; ++i)
// {
// if (typeVols[i]==12)
// {
// m_nbFaces.push_back(8);
// unsigned int pt[8];
// pt[0] = indices[currentOffset];
// pt[1] = indices[currentOffset+1];
// pt[2] = indices[currentOffset+2];
// pt[3] = indices[currentOffset+3];
// pt[4] = indices[currentOffset+4];
// typename PFP::VEC3 P = position[verticesID[indices[currentOffset+4]]];
// typename PFP::VEC3 A = position[verticesID[indices[currentOffset ]]];
// typename PFP::VEC3 B = position[verticesID[indices[currentOffset+1]]];
// typename PFP::VEC3 C = position[verticesID[indices[currentOffset+2]]];
// if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::OVER)
// {
// pt[0] = indices[currentOffset+3];
// pt[1] = indices[currentOffset+2];
// pt[2] = indices[currentOffset+1];
// pt[3] = indices[currentOffset+0];
// pt[4] = indices[currentOffset+7];
// pt[5] = indices[currentOffset+6];
// pt[6] = indices[currentOffset+5];
// pt[7] = indices[currentOffset+4];
// }
// else
// {
// pt[0] = indices[currentOffset+0];
// pt[1] = indices[currentOffset+1];
// pt[2] = indices[currentOffset+2];
// pt[3] = indices[currentOffset+3];
// pt[4] = indices[currentOffset+4];
// pt[5] = indices[currentOffset+5];
// pt[6] = indices[currentOffset+6];
// pt[7] = indices[currentOffset+7];
// }
// m_emb.push_back(verticesID[pt[0]]);
// m_emb.push_back(verticesID[pt[1]]);
// m_emb.push_back(verticesID[pt[2]]);
// m_emb.push_back(verticesID[pt[3]]);
// m_emb.push_back(verticesID[pt[4]]);
// m_emb.push_back(verticesID[pt[5]]);
// m_emb.push_back(verticesID[pt[6]]);
// m_emb.push_back(verticesID[pt[7]]);
// }
// else if (typeVols[i]==10)
// {
// m_nbFaces.push_back(4);
// Geom::Vec4ui pt;
// pt[0] = indices[currentOffset];
// pt[1] = indices[currentOffset+1];
// pt[2] = indices[currentOffset+2];
// pt[3] = indices[currentOffset+3];
// typename PFP::VEC3 P = position[verticesID[pt[0]]];
// typename PFP::VEC3 A = position[verticesID[pt[1]]];
// typename PFP::VEC3 B = position[verticesID[pt[2]]];
// typename PFP::VEC3 C = position[verticesID[pt[3]]];
// if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::OVER)
// {
// unsigned int ui=pt[1];
// pt[1] = pt[2];
// pt[2] = ui;
// }
// m_emb.push_back(verticesID[pt[0]]);
// m_emb.push_back(verticesID[pt[1]]);
// m_emb.push_back(verticesID[pt[2]]);
// m_emb.push_back(verticesID[pt[3]]);
// }
// currentOffset = offsets[i];
// }
// return true;
//}
//inline bool XMLisError(tinyxml2::XMLError err, const std::string& msg)
//{
// if (err != tinyxml2::XML_NO_ERROR)
// {
// CGoGNerr << msg << CGoGNendl;
// return true;
// }
// return false;
//}
//inline std::string XMLAttribute(tinyxml2::XMLElement* node, const char* attName)
//{
// const char *ptr = node->Attribute(attName);
// if (ptr == NULL)
// {
// CGoGNerr << "Warning attrbute "<< attName << " not found"<< CGoGNendl;
// return "";
// }
// return std::string(ptr);
//}
template <typename PFP> template <typename PFP>
bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<std::string>& attrNames) bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<std::string>& attrNames)
{ {
VertexAttribute<VEC3, MAP> position = m_map.template getAttribute<VEC3, VERTEX, MAP>("position") ; VertexAttribute<VEC3, MAP> position = m_map.template getAttribute<VEC3, VERTEX, MAP>("position") ;
if (!position.isValid()) if (!position.isValid())
...@@ -1480,43 +1723,36 @@ bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<s ...@@ -1480,43 +1723,36 @@ bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<s
// //
AttributeContainer& container = m_map.template getAttributeContainer<VERTEX>() ; AttributeContainer& container = m_map.template getAttributeContainer<VERTEX>() ;
xmlDocPtr doc = xmlReadFile(filename.c_str(), NULL, 0);
xmlNodePtr vtu_node = xmlDocGetRootElement(doc);
// std::cout << " NAME "<<vtu_node->name << std::endl;
xmlChar *prop = xmlGetProp(vtu_node, BAD_CAST "type");
// std::cout << "type = "<< prop << std::endl;
xmlNode* grid_node = vtu_node->children; tinyxml2::XMLDocument doc;
while (strcmp((char*)(grid_node->name),(char*)"UnstructuredGrid")!=0) tinyxml2::XMLError eResult = doc.LoadFile(filename.c_str());
grid_node = grid_node->next;
xmlNode* piece_node = grid_node->children; if (XMLisError(eResult,"unable loading file"+filename))
while (strcmp((char*)(piece_node->name),(char*)"Piece")!=0) return false;
piece_node = piece_node->next;
prop = xmlGetProp(piece_node, BAD_CAST "NumberOfPoints"); tinyxml2::XMLElement* vtu_node = doc.RootElement();
m_nbVertices = atoi((char*)(prop));
prop = xmlGetProp(piece_node, BAD_CAST "NumberOfCells"); tinyxml2::XMLElement* grid_node = vtu_node->FirstChildElement("UnstructuredGrid");
m_nbVolumes = atoi((char*)(prop)); tinyxml2::XMLElement* piece_node = grid_node->FirstChildElement("Piece");
std::cout << "Number of points = "<< m_nbVertices<< std::endl; eResult = piece_node->QueryUnsignedAttribute("NumberOfPoints",&m_nbVertices);
std::cout << "Number of cells = "<< m_nbVolumes << std::endl; if (XMLisError(eResult,"unreadable VTU file: "+filename))
return false;
eResult = piece_node->QueryUnsignedAttribute("NumberOfCells",&m_nbVolumes);
if (XMLisError(eResult,"unreadable VTU file: "+filename))
return false;
xmlNode* points_node = piece_node->children; CGoGNout << "Number of points = "<< m_nbVertices<< CGoGNendl;
while (strcmp((char*)(points_node->name),(char*)"Points")!=0) CGoGNout << "Number of cells = "<< m_nbVolumes << CGoGNendl;
points_node = points_node->next;
points_node = points_node->children; tinyxml2::XMLElement* points_node = piece_node->FirstChildElement("Points");
while (strcmp((char*)(points_node->name),(char*)"DataArray")!=0) tinyxml2::XMLElement* array_node = points_node->FirstChildElement("DataArray");
points_node = points_node->next;
std::vector<unsigned int> verticesID; std::vector<unsigned int> verticesID;
verticesID.reserve(m_nbVertices); verticesID.reserve(m_nbVertices);
std::stringstream ss((char*)(xmlNodeGetContent(points_node->children))); std::stringstream ss(array_node->GetText());
for (unsigned int i=0; i< m_nbVertices; ++i) for (unsigned int i=0; i< m_nbVertices; ++i)
{ {
typename PFP::VEC3 P; typename PFP::VEC3 P;
...@@ -1526,12 +1762,8 @@ bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<s ...@@ -1526,12 +1762,8 @@ bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<s
verticesID.push_back(id); verticesID.push_back(id);
} }
xmlNode* cell_node = piece_node->children; tinyxml2::XMLElement* cell_node = piece_node->FirstChildElement("Cells");
while (strcmp((char*)(cell_node->name),(char*)"Cells")!=0) array_node = cell_node->FirstChildElement("DataArray");
cell_node = cell_node->next;
std::cout <<"CELL NODE = "<< cell_node->name << std::endl;
std::vector<unsigned char> typeVols; std::vector<unsigned char> typeVols;
typeVols.reserve(m_nbVolumes); typeVols.reserve(m_nbVolumes);
...@@ -1540,63 +1772,60 @@ bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<s ...@@ -1540,63 +1772,60 @@ bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<s
std::vector<unsigned int> indices; std::vector<unsigned int> indices;
indices.reserve(m_nbVolumes*4); indices.reserve(m_nbVolumes*4);
for (xmlNode* x_node = cell_node->children; x_node!=NULL; x_node = x_node->next) while (array_node)
{ {
while ((x_node!=NULL) && (strcmp((char*)(x_node->name),(char*)"DataArray")!=0)) std::string propName = XMLAttribute(array_node,"Name");
x_node = x_node->next;
if (x_node == NULL) if (propName == "")
break;
else
{ {
xmlChar* type = xmlGetProp(x_node, BAD_CAST "Name"); CGoGNerr << "Error reading VTU unreadable file: "<<filename<< CGoGNendl;
return false;
}
if (strcmp((char*)(type),(char*)"connectivity")==0) if (propName == "connectivity")
{
std::stringstream ss(array_node->GetText());
while (!ss.eof())
{ {
std::stringstream ss((char*)(xmlNodeGetContent(x_node->children))); unsigned int ind;
while (!ss.eof()) ss >> ind;
{ indices.push_back(ind);
unsigned int ind;
ss >> ind;
indices.push_back(ind);
}
} }
if (strcmp((char*)(type),(char*)"offsets")==0) }
if (propName == "offsets")
{
std::stringstream ss(array_node->GetText());
for (unsigned int i=0; i< m_nbVolumes; ++i)
{ {
std::stringstream ss((char*)(xmlNodeGetContent(x_node->children))); unsigned int o;
for (unsigned int i=0; i< m_nbVolumes; ++i) ss >> o;
{ offsets.push_back(o);
unsigned int o;
ss >> o;
offsets.push_back(o);
}
} }
if (strcmp((char*)(type),(char*)"types")==0) }
if (propName == "types")
{
bool unsupported = false;
std::stringstream ss(array_node->GetText());
for (unsigned int i=0; i< m_nbVolumes; ++i)
{ {
bool unsupported = false; unsigned int t;
std::stringstream ss((char*)(xmlNodeGetContent(x_node->children))); ss >> t;
for (unsigned int i=0; i< m_nbVolumes; ++i) if ((t != 12) && (t!= 10))
{ {
unsigned int t; unsupported = true;
ss >> t; typeVols.push_back(0);
if ((t != 12) && (t!= 10)) }
{ else
unsupported = true; {
typeVols.push_back(0);