Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
David Cazier
CGoGN
Commits
51206dcd
Commit
51206dcd
authored
Nov 28, 2014
by
Sylvain Thery
Browse files
replace libXml2 by tinyxml2
parent
f2a4af2f
Changes
9
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
51206dcd
...
...
@@ -58,7 +58,7 @@ ENDIF(WIN32)
find_package
(
OpenGL REQUIRED
)
find_package
(
Boost COMPONENTS regex REQUIRED
)
find_package
(
ZLIB REQUIRED
)
find_package
(
LibXml2 REQUIRED
)
#
find_package(LibXml2 REQUIRED)
find_package
(
GLEW REQUIRED
)
# MESSAGE HERE FOR MORE EASY USER READING
...
...
@@ -98,7 +98,7 @@ SET (CGoGN_EXT_INCLUDES
${
OPENGL_INCLUDE_DIR
}
${
GLEW_INCLUDE_DIRS
}
${
ZLIB_INCLUDE_DIRS
}
${
LIBXML2_INCLUDE_DIR
}
#
${LIBXML2_INCLUDE_DIR}
${
Boost_INCLUDE_DIRS
}
)
...
...
@@ -108,7 +108,8 @@ SET (CGoGN_EXT_LIBS
${
OPENGL_LIBRARY
}
${
GLEW_LIBRARIES
}
${
ZLIB_LIBRARIES
}
${
LIBXML2_LIBRARIES
}
# ${LIBXML2_LIBRARIES}
tinyxml2
${
Boost_REGEX_LIBRARY
}
)
...
...
README.TXT
View file @
51206dcd
...
...
@@ -3,7 +3,7 @@ English version bellow
Dépendences Linux
=================
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 lib
tiny
xml2-dev libboost-all-dev zlib1g-dev qt4-designer qt4-dev-tools uuid-dev libgsl0-dev libsuitesparse-dev
Pour compiler CGoGN
...
...
include/Algo/Import/import2tablesVolume.hpp
View file @
51206dcd
...
...
@@ -24,9 +24,12 @@
#include
"Geometry/orientation.h"
#include
<libxml/encoding.h>
#include
<libxml/xmlwriter.h>
#include
<libxml/parser.h>
//#include <libxml/encoding.h>
//#include <libxml/xmlwriter.h>
//#include <libxml/parser.h>
//#include <tinyxml2.h>
#include
"Utils/xml.h"
namespace
CGoGN
{
...
...
@@ -1436,9 +1439,249 @@ bool MeshTablesVolume<PFP>::importVBGZ(const std::string& filename, std::vector<
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
>
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
())
...
...
@@ -1449,43 +1692,36 @@ bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<s
//
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
;
tinyxml2
::
XMLDocument
doc
;
tinyxml2
::
XMLError
eResult
=
doc
.
LoadFile
(
filename
.
c_str
());
xmlNode
*
piece_node
=
grid_node
->
children
;
while
(
strcmp
((
char
*
)(
piece_node
->
name
),(
char
*
)
"Piece"
)
!=
0
)
piece_node
=
piece_node
->
next
;
if
(
XMLisError
(
eResult
,
"unable loading file"
+
filename
))
return
false
;
prop
=
xmlGetProp
(
piece_node
,
BAD_CAST
"NumberOfPoints"
);
m_nbVertices
=
atoi
((
char
*
)(
prop
));
tinyxml2
::
XMLElement
*
vtu_node
=
doc
.
RootElement
();
prop
=
xmlGetProp
(
piece_node
,
BAD_CAST
"NumberOfCells
"
);
m_nbVolumes
=
atoi
((
char
*
)(
prop
)
);
tinyxml2
::
XMLElement
*
grid_node
=
vtu_node
->
FirstChildElement
(
"UnstructuredGrid
"
);
tinyxml2
::
XMLElement
*
piece_node
=
grid_node
->
FirstChildElement
(
"Piece"
);
std
::
cout
<<
"Number of points = "
<<
m_nbVertices
<<
std
::
endl
;
std
::
cout
<<
"Number of cells = "
<<
m_nbVolumes
<<
std
::
endl
;
eResult
=
piece_node
->
QueryUnsignedAttribute
(
"NumberOfPoints"
,
&
m_nbVertices
);
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
;
while
(
strcmp
((
char
*
)(
points_node
->
name
),(
char
*
)
"Points"
)
!=
0
)
points_node
=
points_node
->
next
;
CGoGNout
<<
"Number of points = "
<<
m_nbVertices
<<
CGoGNendl
;
CGoGNout
<<
"Number of cells = "
<<
m_nbVolumes
<<
CGoGNendl
;
points_node
=
points_node
->
children
;
while
(
strcmp
((
char
*
)(
points_node
->
name
),(
char
*
)
"DataArray"
)
!=
0
)
points_node
=
points_node
->
next
;
tinyxml2
::
XMLElement
*
points_node
=
piece_node
->
FirstChildElement
(
"Points"
);
tinyxml2
::
XMLElement
*
array_node
=
points_node
->
FirstChildElement
(
"DataArray"
);
std
::
vector
<
unsigned
int
>
verticesID
;
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
)
{
typename
PFP
::
VEC3
P
;
...
...
@@ -1495,12 +1731,8 @@ bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<s
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
;
tinyxml2
::
XMLElement
*
cell_node
=
piece_node
->
FirstChildElement
(
"Cells"
);
array_node
=
cell_node
->
FirstChildElement
(
"DataArray"
);
std
::
vector
<
unsigned
char
>
typeVols
;
typeVols
.
reserve
(
m_nbVolumes
);
...
...
@@ -1509,63 +1741,60 @@ bool MeshTablesVolume<PFP>::importVTU(const std::string& filename, std::vector<s
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
(
array_node
)
{
while
((
x_node
!=
NULL
)
&&
(
strcmp
((
char
*
)(
x_node
->
name
),(
char
*
)
"DataArray"
)
!=
0
))
x_node
=
x_node
->
next
;
std
::
string
propName
=
XMLAttribute
(
array_node
,
"Name"
);
if
(
x_node
==
NULL
)
break
;
else
if
(
propName
==
""
)
{
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
)));
while
(
!
ss
.
eof
())
{
unsigned
int
ind
;
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
)));
for
(
unsigned
int
i
=
0
;
i
<
m_nbVolumes
;
++
i
)
{
unsigned
int
o
;
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
;
s
td
::
stringstream
ss
((
char
*
)(
xmlNodeGetContent
(
x_node
->
children
)))
;
for
(
unsigned
int
i
=
0
;
i
<
m_nbVolumes
;
++
i
)
unsigned
int
t
;
s
s
>>
t
;
if
((
t
!=
12
)
&&
(
t
!=
10
)
)
{
unsigned
int
t
;
ss
>>
t
;
if
((
t
!=
12
)
&&
(
t
!=
10
))
{
unsupported
=
true
;
typeVols
.
push_back
(
0
);
}
else
{
typeVols
.
push_back
((
unsigned
char
)
t
);
}
unsupported
=
true
;
typeVols
.
push_back
(
0
);
}
else
{
typeVols
.
push_back
((
unsigned
char
)
t
);
}
if
(
unsupported
)
CGoGNerr
<<
"warning, some unsupported volume cell types"
<<
CGoGNendl
;
}
if
(
unsupported
)
CGoGNerr
<<
"warning, some unsupported volume cell types"
<<
CGoGNendl
;
}
array_node
=
array_node
->
NextSiblingElement
(
"DataArray"
);
}
xmlFreeDoc
(
doc
);
unsigned
int
currentOffset
=
0
;
for
(
unsigned
int
i
=
0
;
i
<
m_nbVolumes
;
++
i
)
{
...
...
include/Algo/Import/importSvg.h
View file @
51206dcd
...
...
@@ -25,6 +25,8 @@
#ifndef __IMPORTSVG_H__
#define __IMPORTSVG_H__
#include
"Utils/xml.h"
namespace
CGoGN
{
...
...
@@ -43,16 +45,16 @@ namespace Import
* @param name the name
* @ return true if node has the good name
*/
bool
checkXmlNode
(
xmlNodePtr
node
,
const
std
::
string
&
name
);
bool
checkXmlNode
(
tinyxml2
::
XMLElement
*
node
,
const
std
::
string
&
name
);
template
<
typename
PFP
>
void
readCoordAndStyle
(
xmlNode
*
cur_path
,
void
readCoordAndStyle
(
tinyxml2
::
XMLElement
*
cur_path
,
std
::
vector
<
std
::
vector
<
VEC3
>
>&
allPoly
,
std
::
vector
<
std
::
vector
<
VEC3
>
>&
allBrokenLines
,
std
::
vector
<
float
>&
allBrokenLinesWidth
);
template
<
typename
PFP
>
bool
importSVG
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
CellMarker
<
EDGE
>&
polygons
,
CellMarker
<
FACE
>&
polygonsFaces
);
bool
importSVG
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
>&
position
,
CellMarker
<
typename
PFP
::
MAP
,
EDGE
>&
polygons
,
CellMarker
<
typename
PFP
::
MAP
,
FACE
>&
polygonsFaces
);
/**
*
...
...
include/Algo/Import/importSvg.hpp
View file @
51206dcd
...
...
@@ -26,9 +26,13 @@
#include
"Geometry/bounding_box.h"
#include
"Geometry/plane_3d.h"
#include
"Algo/BooleanOperator/mergeVertices.h"
#include
"Algo/Topo/basic.h"
#include
"Container/fakeAttribute.h"
#include
<limits>
#include
"Utils/xml.h"
// just for highlighting/completion in editor
namespace
CGoGN
{
...
...
@@ -41,9 +45,14 @@ namespace Surface
namespace
Import
{
inline
bool
checkXmlNode
(
xmlNodePtr
node
,
const
std
::
string
&
name
)
//inline bool checkXmlNode(xmlNodePtr node, const std::string& name)
//{
// return (strcmp((char*)(node->name),(char*)(name.c_str())) == 0);
//}
inline
bool
checkXmlNode
(
tinyxml2
::
XMLElement
*
node
,
const
std
::
string
&
name
)
{
return
(
strcmp
(
(
char
*
)(
node
->
n
ame
),
(
char
*
)(
name
.
c_str
())
)
==
0
);
return
(
strcmp
(
node
->
N
ame
(
),
name
.
c_str
())
==
0
);
}
template
<
typename
T
>
...
...
@@ -206,7 +215,7 @@ void getPolygonFromSVG(std::string allcoords, std::vector<VEC3>& curPoly, bool&
}
template
<
typename
PFP
>
void
readCoordAndStyle
(
xmlNode
*
cur_path
,
void
readCoordAndStyle
(
tinyxml2
::
XMLElement
*
cur_path
,
std
::
vector
<
std
::
vector
<
VEC3
>
>&
allPoly
,
std
::
vector
<
std
::
vector
<
VEC3
>
>&
allBrokenLines
,
std
::
vector
<
float
>&
allBrokenLinesWidth
)
...
...
@@ -218,14 +227,16 @@ void readCoordAndStyle(xmlNode* cur_path,
POLYGON
curPoly
;
// CGoGNout << "--load a path--"<< CGoGNendl;
xmlChar
*
prop
=
xmlGetProp
(
cur_path
,
BAD_CAST
"d"
);
std
::
string
allcoords
((
reinterpret_cast
<
const
char
*>
(
prop
)));
// xmlChar* prop = xmlGetProp(cur_path, BAD_CAST "d");
// std::string allcoords((reinterpret_cast<const char*>(prop)));
std
::
string
allcoords
=
XMLAttribute
(
cur_path
,
"d"
);
getPolygonFromSVG
(
allcoords
,
curPoly
,
closedPoly
);
//check orientation : set in CCW
if
(
curPoly
.
size
()
>
2
)
{
VEC3
v
(
0
),
v1
,
v2
;
VEC3
v
(
0
)
/*
, v1, v2
*/
;
typename
std
::
vector
<
VEC3
>::
iterator
it0
,
it1
,
it2
;
it0
=
curPoly
.
begin
();
it1
=
it0
+
1
;
...
...
@@ -255,8 +266,11 @@ void readCoordAndStyle(xmlNode* cur_path,
{
//if not : read the linewidth for further dilatation
allBrokenLines
.
push_back
(
curPoly
);
xmlChar
*
prop
=
xmlGetProp
(
cur_path
,
BAD_CAST
"style"
);
std
::
string
allstyle
((
reinterpret_cast
<
const
char
*>
(
prop
)));
// xmlChar* prop = xmlGetProp(cur_path, BAD_CAST "style");
// std::string allstyle((reinterpret_cast<const char*>(prop)));
std
::
string
allstyle
=
XMLAttribute
(
cur_path
,
"style"
);
std
::
stringstream
is
(
allstyle
);
std
::
string
style
;
while
(
std
::
getline
(
is
,
style
,
';'
)
)
...
...
@@ -274,7 +288,7 @@ void readCoordAndStyle(xmlNode* cur_path,
}
template
<
typename
PFP
>
bool
importSVG
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
VertexAttribute
<
typename
PFP
::
VEC3
>&
position
,
CellMarker
<
EDGE
>&
obstacleMark
,
CellMarker
<
FACE
>&
buildingMark
)
bool
importSVG
(
typename
PFP
::
MAP
&
map
,
const
std
::
string
&
filename
,
VertexAttribute
<
typename
PFP
::
VEC3
,
typename
PFP
::
MAP
>&
position
,
CellMarker
<
typename
PFP
::
MAP
,
EDGE
>&
obstacleMark
,
CellMarker
<
typename
PFP
::
MAP
,
FACE
>&
buildingMark
)
{
//TODO : remove auto-intersecting faces
//TODO : handling polygons with holes
...
...
@@ -282,8 +296,18 @@ bool importSVG(typename PFP::MAP& map, const std::string& filename, VertexAttrib
typedef
typename
PFP
::
VEC3
VEC3
;
typedef
std
::
vector
<
VEC3
>
POLYGON
;
xmlDocPtr
doc
=
xmlReadFile
(
filename
.
c_str
(),
NULL
,
0
);
xmlNodePtr
map_node
=
xmlDocGetRootElement
(
doc
);
tinyxml2
::
XMLDocument
doc
;
tinyxml2
::
XMLError
eResult
=
doc
.
LoadFile
(
filename
.
c_str
());
if
(
XMLisError
(
eResult
,
"unable loading file"
+
filename
))
return
false
;
tinyxml2
::
XMLElement
*
map_node
=
doc
.
RootElement
();