Commit bbfcab3f authored by untereiner's avatar untereiner

ShapeMatching + ShapeMatching Linear + ShapeMatching Quadratic => ok

Deleting old tet import files
parent fd9a5728
......@@ -387,9 +387,9 @@ int main(int argc, char **argv)
{
std::vector<std::string> attrNames ;
std::string filename(argv[1]);
size_t pos = filename.rfind("."); // position of "." in filename
std::string extension = filename.substr(pos);
// size_t pos = filename.rfind("."); // position of "." in filename
// std::string extension = filename.substr(pos);
/*
if(extension == std::string(".off"))
{
if(!Algo::Volume::Import::importMeshToExtrude<PFP>(myMap, filename, attrNames))
......@@ -405,14 +405,14 @@ int main(int argc, char **argv)
}
else
{
if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
*/ if(!Algo::Volume::Import::importMesh<PFP>(myMap, filename, attrNames))
{
std::cerr << "could not import " << filename << std::endl ;
return 1;
}
else
position = myMap.getAttribute<PFP::VEC3,VERTEX>(attrNames[0]) ;
}
// }
color = myMap.addAttribute<PFP::VEC3, VOLUME>("color");
......
......@@ -42,48 +42,6 @@ namespace Surface
namespace Import
{
//template<typename PFP>
//ImportType MeshTablesSurface<PFP>::getFileType(const std::string& filename)
//{
// if ((filename.rfind(".trianbgz")!=std::string::npos) || (filename.rfind(".TRIANBGZ")!=std::string::npos))
// return TRIANBGZ;
// if ((filename.rfind(".trian")!=std::string::npos) || (filename.rfind(".TRIAN")!=std::string::npos))
// return TRIAN;
// if ((filename.rfind(".meshbin")!=std::string::npos) || (filename.rfind(".MESHBIN")!=std::string::npos))
// return MESHBIN;
///* if ((filename.rfind(".plyptm")!=std::string::npos) || (filename.rfind(".PLYGEN")!=std::string::npos))
// return PLYPTM;
//*/
// if ((filename.rfind(".plyPTMextBin")!=std::string::npos) || (filename.rfind(".plySHrealBin")!=std::string::npos))
// return PLYSLFgenericBin;
// if ((filename.rfind(".plyPTMext")!=std::string::npos) || (filename.rfind(".plySHreal")!=std::string::npos))
// return PLYSLFgeneric;
// if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos))
// return PLY;
// if ((filename.rfind(".off")!=std::string::npos) || (filename.rfind(".OFF")!=std::string::npos))
// return OFF;
// if ((filename.rfind(".obj")!=std::string::npos) || (filename.rfind(".OBJ")!=std::string::npos))
// return OBJ;
// if ((filename.rfind(".ahem")!=std::string::npos) || (filename.rfind(".AHEM")!=std::string::npos))
// return AHEM;
// if ((filename.rfind(".stlb")!=std::string::npos) || (filename.rfind(".STLB")!=std::string::npos))
// return STLB;
// if ((filename.rfind(".stl")!=std::string::npos) || (filename.rfind(".STL")!=std::string::npos))
// return STL;
// return UNKNOWNSURFACE;
//}
template<typename PFP>
bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector<std::string>& attrNames)
{
......
......@@ -22,6 +22,8 @@
* *
*******************************************************************************/
#include "Geometry/orientation.h"
namespace CGoGN
{
......@@ -34,40 +36,6 @@ namespace Volume
namespace Import
{
//template<typename PFP>
//ImportType MeshTablesVolume<PFP>::getFileType(const std::string& filename)
//{
// if ((filename.rfind(".tetmesh")!=std::string::npos) || (filename.rfind(".TETMESH")!=std::string::npos))
// return TETMESH;
// if ((filename.rfind(".tet")!=std::string::npos) || (filename.rfind(".TET")!=std::string::npos))
// return TET;
// if ((filename.rfind(".node")!=std::string::npos) || (filename.rfind(".NODE")!=std::string::npos))
// return NODE;
// if ((filename.rfind(".off")!=std::string::npos) || (filename.rfind(".OFF")!=std::string::npos))
// return OFF;
// if ((filename.rfind(".ts")!=std::string::npos) || (filename.rfind(".TS")!=std::string::npos))
// return TS;
// if ((filename.rfind(".msh")!=std::string::npos) || (filename.rfind(".MSH")!=std::string::npos))
// return MSH;
// if ((filename.rfind(".vtu")!=std::string::npos) || (filename.rfind(".VTU")!=std::string::npos))
// return VTU;
// if ((filename.rfind(".nas")!=std::string::npos) || (filename.rfind(".NAS")!=std::string::npos))
// return NAS;
// if ((filename.rfind(".vbgz")!=std::string::npos) || (filename.rfind(".VBGZ")!=std::string::npos))
// return VBGZ;
// return UNKNOWNVOLUME;
//}
template <typename PFP>
bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, std::vector<std::string>& attrNames)
{
......@@ -211,6 +179,18 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s
oss >> s2;
oss >> s3;
typename PFP::VEC3 P = position[verticesID[s0]];
typename PFP::VEC3 A = position[verticesID[s1]];
typename PFP::VEC3 B = position[verticesID[s2]];
typename PFP::VEC3 C = position[verticesID[s3]];
if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::UNDER)
{
int ui = s1;
s1 = s2;
s2 = ui;
}
m_emb.push_back(verticesID[s0]);
m_emb.push_back(verticesID[s1]);
m_emb.push_back(verticesID[s2]);
......@@ -336,6 +316,20 @@ bool MeshTablesVolume<PFP>::importOFFWithELERegions(const std::string& filenameO
oss >> s2;
oss >> s3;
typename PFP::VEC3 P = position[verticesID[s0]];
typename PFP::VEC3 A = position[verticesID[s1]];
typename PFP::VEC3 B = position[verticesID[s2]];
typename PFP::VEC3 C = position[verticesID[s3]];
if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::UNDER)
{
int ui= s0;
s0 = s3;
s3 = s2;
s2 = s1;
s1 = ui;
}
m_emb.push_back(verticesID[s0]);
m_emb.push_back(verticesID[s1]);
m_emb.push_back(verticesID[s2]);
......@@ -457,6 +451,20 @@ bool MeshTablesVolume<PFP>::importNodeWithELERegions(const std::string& filename
oss >> s2;
oss >> s3;
typename PFP::VEC3 P = position[verticesMapID[s0]];
typename PFP::VEC3 A = position[verticesMapID[s1]];
typename PFP::VEC3 B = position[verticesMapID[s2]];
typename PFP::VEC3 C = position[verticesMapID[s3]];
if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::UNDER)
{
int ui= s0;
s0 = s3;
s3 = s2;
s2 = s1;
s1 = ui;
}
m_emb.push_back(verticesMapID[s0]);
m_emb.push_back(verticesMapID[s1]);
m_emb.push_back(verticesMapID[s2]);
......@@ -558,6 +566,18 @@ bool MeshTablesVolume<PFP>::importTetmesh(const std::string& filename, std::vect
oss >> s2;
oss >> s3;
typename PFP::VEC3 P = position[verticesID[s0]];
typename PFP::VEC3 A = position[verticesID[s1]];
typename PFP::VEC3 B = position[verticesID[s2]];
typename PFP::VEC3 C = position[verticesID[s3]];
if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::UNDER)
{
int ui=s1;
s1 = s2;
s2 = ui;
}
m_emb.push_back(verticesID[s0]);
m_emb.push_back(verticesID[s1]);
m_emb.push_back(verticesID[s2]);
......@@ -638,8 +658,7 @@ bool MeshTablesVolume<PFP>::importTs(const std::string& filename, std::vector<st
//Read and embed all tetrahedrons
for(unsigned int i = 0; i < m_nbVolumes ; ++i)
{
int nbe;
{
do
{
std::getline(fp,ligne);
......@@ -649,13 +668,26 @@ bool MeshTablesVolume<PFP>::importTs(const std::string& filename, std::vector<st
m_nbFaces.push_back(4);
int s0,s1,s2,s3;
int s0,s1,s2,s3,nbe;
oss >> s0;
oss >> s1;
oss >> s2;
oss >> s3;
typename PFP::VEC3 P = position[verticesID[s0]];
typename PFP::VEC3 A = position[verticesID[s1]];
typename PFP::VEC3 B = position[verticesID[s2]];
typename PFP::VEC3 C = position[verticesID[s3]];
if(Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::UNDER)
{
int ui = s1;
s1 = s2;
s2 = ui;
}
//if regions are defined use this number
oss >> nbe; //ignored here
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Algo/Modelisation/polyhedron.h"
#include "Geometry/orientation.h"
#include <vector>
namespace CGoGN
{
namespace Algo
{
namespace Volume
{
namespace Import
{
template <typename PFP>
bool importNodeWithELERegions(typename PFP::MAP& map, const std::string& filenameNode, const std::string& filenameELE, std::vector<std::string>& attrNames)
{
typedef typename PFP::VEC3 VEC3;
VertexAttribute<VEC3> position = map.template addAttribute<VEC3, VERTEX>("position") ;
attrNames.push_back(position.name()) ;
AttributeContainer& container = map.template getAttributeContainer<VERTEX>() ;
unsigned int m_nbVertices = 0, m_nbFaces = 0, m_nbEdges = 0, m_nbVolumes = 0;
VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, "incidents");
//open file
std::ifstream fnode(filenameNode.c_str(), std::ios::in);
if (!fnode.good())
{
CGoGNerr << "Unable to open file " << filenameNode << CGoGNendl;
return false;
}
std::ifstream fele(filenameELE.c_str(), std::ios::in);
if (!fele.good())
{
CGoGNerr << "Unable to open file " << filenameELE << CGoGNendl;
return false;
}
std::string line;
// do
// {
// std::getline(fnode,line);
// }while(line.rfind("#") == 0);
//Reading NODE file
//First line: [# of points] [dimension (must be 3)] [# of attributes] [# of boundary markers (0 or 1)]
unsigned int nbe;
{
do
{
std::getline(fnode,line);
}while(line.size() == 0);
std::stringstream oss(line);
oss >> m_nbVertices;
oss >> nbe;
oss >> nbe;
oss >> nbe;
}
//Reading number of tetrahedra in ELE file
unsigned int nbv;
{
do
{
std::getline(fele,line);
}while(line.size() == 0);
std::stringstream oss(line);
oss >> m_nbVolumes;
oss >> nbv ; oss >> nbv;
}
CGoGNout << "nb points = " << m_nbVertices << " / nb faces = " << m_nbFaces << " / nb edges = " << m_nbEdges << " / nb tet = " << m_nbVolumes << CGoGNendl;
//Reading vertices
//Remaining lines: [point #] [x] [y] [z] [optional attributes] [optional boundary marker]
// std::vector<unsigned int> verticesID;
// verticesID.reserve(m_nbVertices);
std::map<unsigned int,unsigned int> verticesMapID;
for(unsigned int i = 0 ; i < m_nbVertices ; ++i)
{
do
{
std::getline(fnode,line);
}while(line.size() == 0);
std::stringstream oss(line);
int idv;
oss >> idv;
float x,y,z;
oss >> x;
oss >> y;
oss >> z;
//we can read colors informations if exists
VEC3 pos(x,y,z);
unsigned int id = container.insertLine();
position[id] = pos;
// verticesID.push_back(id);
verticesMapID.insert(std::pair<unsigned int, unsigned int>(idv,id));
}
DartMarkerNoUnmark m(map) ;
bool invertVol=false;
//Read and embed tetrahedra TODO
for(unsigned i = 0; i < m_nbVolumes ; ++i)
{
do
{
std::getline(fele,line);
} while(line.size() == 0);
std::stringstream oss(line);
oss >> nbe;
Dart d = Surface::Modelisation::createTetrahedron<PFP>(map,false);
Geom::Vec4ui pt;
// test orientation of first tetra
if (i==0)
{
oss >> pt[0];
oss >> pt[1];
oss >> pt[2];
oss >> pt[3];
typename PFP::VEC3 P = position[verticesMapID[pt[0]]];
typename PFP::VEC3 A = position[verticesMapID[pt[1]]];
typename PFP::VEC3 B = position[verticesMapID[pt[2]]];
typename PFP::VEC3 C = position[verticesMapID[pt[3]]];
if (Geom::testOrientation3D<typename PFP::VEC3>(P,A,B,C) == Geom::OVER)
{
invertVol=true;
unsigned int ui=pt[0];
pt[0] = pt[3];
pt[3] = pt[2];
pt[2] = pt[1];
pt[1] = ui;
}
}
else
{
if (invertVol)
{
oss >> pt[1];
oss >> pt[2];
oss >> pt[3];
oss >> pt[0];
}
else
{
oss >> pt[0];
oss >> pt[1];
oss >> pt[2];
oss >> pt[3];
}
}
// Embed three vertices
for(unsigned int j = 0 ; j < 3 ; ++j)
{
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, verticesMapID[pt[2-j]]);
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
//store darts per vertices to optimize reconstruction
Dart dd = d;
do
{
m.mark(dd) ;
vecDartsPerVertex[verticesMapID[pt[2-j]]].push_back(dd);
dd = map.phi1(map.phi2(dd));
} while(dd != d);
d = map.phi1(d);
}
//Embed the last vertex
d = map.phi_1(map.phi2(d));
FunctorSetEmb<typename PFP::MAP, VERTEX> fsetemb(map, verticesMapID[pt[3]]);
map.template foreach_dart_of_orbit<PFP::MAP::VERTEX_OF_PARENT>(d, fsetemb);
//store darts per vertices to optimize reconstruction
Dart dd = d;
do
{
m.mark(dd) ;
vecDartsPerVertex[verticesMapID[pt[3]]].push_back(dd);
dd = map.phi1(map.phi2(dd));
} while(dd != d);
}
fnode.close();
fele.close();
//Association des phi3
unsigned int nbBoundaryFaces = 0 ;
for (Dart d = map.begin(); d != map.end(); map.next(d))
{
if (m.isMarked(d))
{
std::vector<Dart>& vec = vecDartsPerVertex[map.phi1(d)];
Dart good_dart = NIL;
for(typename std::vector<Dart>::iterator it = vec.begin(); it != vec.end() && good_dart == NIL; ++it)
{
if(map.template getEmbedding<VERTEX>(map.phi1(*it)) == map.template getEmbedding<VERTEX>(d) &&
map.template getEmbedding<VERTEX>(map.phi_1(*it)) == map.template getEmbedding<VERTEX>(map.phi_1(d)) /*&&
map.template getEmbedding<VERTEX>(*it) == map.template getEmbedding<VERTEX>(map.phi1(d)) */)
{
good_dart = *it ;
}
}
if (good_dart != NIL)
{
map.sewVolumes(d, good_dart, false);
m.template unmarkOrbit<FACE>(d);
}
else
{
m.unmarkOrbit<PFP::MAP::FACE_OF_PARENT>(d);
++nbBoundaryFaces;
}
}
}
if (nbBoundaryFaces > 0)
{
std::cout << "closing" << std::endl ;
map.closeMap();
CGoGNout << "Map closed (" << nbBoundaryFaces << " boundary faces)" << CGoGNendl;
}
return true;
}
} // namespace Import
}
} // namespace Algo
} // namespace CGoGN
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* *
* This library is free software; you can redistribute it and/or modify it *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your *
* option) any later version. *
* *
* This library is distributed in the hope that it will be useful, but WITHOUT *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License *
* for more details. *
* *
* You should have received a copy of the GNU Lesser General Public License *
* along with this library; if not, write to the Free Software Foundation, *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. *
* *
* Web site: http://cgogn.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Algo/Modelisation/polyhedron.h"
#include <vector>
namespace CGoGN
{
namespace Algo
{
namespace Volume
{
namespace Import
{
template<typename PFP>
bool importOFFWithELERegions(typename PFP::MAP& map, const std::string& filenameOFF, const std::string& filenameELE, std::vector<std::string>& attrNames)
{
typedef typename PFP::VEC3 VEC3;
VertexAttribute<VEC3> position = map.template addAttribute<VEC3, VERTEX>("position") ;
attrNames.push_back(position.name()) ;
AttributeContainer& container = map.template getAttributeContainer<VERTEX>() ;
unsigned int m_nbVertices = 0, m_nbFaces = 0, m_nbEdges = 0, m_nbVolumes = 0;
VertexAutoAttribute< NoTypeNameAttribute< std::vector<Dart> > > vecDartsPerVertex(map, "incidents");
// open files
std::ifstream foff(filenameOFF.c_str(), std::ios::in);
if (!foff.good())
{
CGoGNerr << "Unable to open OFF file " << CGoGNendl;
return false;
}
std::ifstream fele(filenameELE.c_str(), std::ios::in);
if (!fele.good())
{
CGoGNerr << "Unable to open ELE file " << CGoGNendl;
return false;
}
std::string line;
//OFF reading
std::getline(foff, line);
if(line.rfind("OFF") == std::string::npos)
{
CGoGNerr << "Problem reading off file: not an off file"<<CGoGNendl;
CGoGNerr << line << CGoGNendl;
return false;
}
//Reading number of vertex/faces/edges in OFF file
unsigned int nbe;
{
do
{
std::getline(foff,line);
}while(line.size() == 0);
std::stringstream oss(line);
oss >> m_nbVertices;
oss >> m_nbFaces;
oss >> m_nbEdges;
oss >> nbe;
}
//Reading number of tetrahedra in ELE file
unsigned int nbv;
{
do
{
std::getline(fele,line);
}while(line.size() == 0);
std::stringstream oss(line);
oss >> m_nbVolumes;
oss >> nbv ; oss >> nbv;
}
CGoGNout << "nb points = " << m_nbVertices << " / nb faces = " << m_nbFaces << " / nb edges = " << m_nbEdges << " / nb tet = " << m_nbVolumes << CGoGNendl;
//Reading vertices
std::vector<unsigned int> verticesID;
verticesID.reserve(m_nbVertices);
for(unsigned int i = 0 ; i < m_nbVertices ; ++i)
{
do
{
std::getline(foff,line);
}while(line.size() == 0);
std::stringstream oss(line);