Commit 6d4091ee authored by Pierre Kraemer's avatar Pierre Kraemer

Merge cgogn.unistra.fr:~kraemer/CGoGN

parents 91c76a9d 8e0ed488
......@@ -138,7 +138,7 @@ int main(int argc, char **argv)
}
// extrusion
Dart d = Algo::Modelisation::extrusion_scale<PFP>(myMap, position, objV, PFP::VEC3(0.0,0.0,0.0), PFP::VEC3(0.0,1.0,0.0),true, pathV, false, pathRadius);
Algo::Modelisation::extrusion_scale<PFP>(myMap, position, objV, PFP::VEC3(0.0,0.0,0.0), PFP::VEC3(0.0,1.0,0.0),true, pathV, false, pathRadius);
// bounding box
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
......
......@@ -54,7 +54,7 @@ SimpleGMap3::SimpleGMap3()
SelectorMarked sm(markOrient);
std::cout << "AAA"<< std::endl;
Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap, position, sm);
//Algo::Modelisation::catmullClarkVol<PFP,PFP::TVEC3,PFP::VEC3>(myMap, position, sm);
for(unsigned int i = position.begin() ; i != position.end() ; position.next(i))
position[i] += VEC3(2,0,0);
......
......@@ -266,8 +266,8 @@ void MyQT::cb_keyPress(int code)
if(code == 'c')
{
SelectorDartNoBoundary<PFP::MAP> nb(myMap);
Algo::Modelisation::catmullClarkVol<PFP>(myMap, position, nb);
//SelectorDartNoBoundary<PFP::MAP> nb(myMap);
Algo::Modelisation::catmullClarkVol<PFP>(myMap, position);
m_positionVBO->updateData(position);
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::TRIANGLES);
......@@ -275,7 +275,7 @@ void MyQT::cb_keyPress(int code)
m_render->initPrimitives<PFP>(myMap, allDarts, Algo::Render::GL2::POINTS);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, 0.9f, nb);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f, 0.9f, allDarts);
}
}
......
......@@ -76,7 +76,37 @@ bool exportTrian(typename PFP::MAP& map, const typename PFP::TVEC3& position, ch
* @return true
*/
template <typename PFP>
bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const FunctorSelect& good = allDarts) ;
bool exportPlySLFgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ;
/**
* export the map into a PLYPTMgeneric file (K. Vanhoey generic format).
*
* exports position + any attribute named : "frame_T" (frame tangent : VEC3), "frame_B" (frame binormal : VEC3), "frame_N" (frame normal : VEC3),
* "colorPTM_a<i> : VEC3" (coefficient number i of the 3 polynomials - one per channel - ; the max i depends on the degree of the PTM polynomial),
* "errL2 : REAL" (L2 fitting error), "errLmax : REAL" (maximal fitting error), "stdDev : REAL" (standard deviation of the L2 fitting errors).
*
* @param map map to be exported
* @param filename filename of ply file
* @param position the position container
* @return true
*/
template <typename PFP>
bool exportPlySLFgenericBin(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ;
/**
* export the map into a PLYSLF file (K. Vanhoey generic format).
*
* exports position + any attribute named : "frame_T" (frame tangent : VEC3), "frame_B" (frame binormal : VEC3), "frame_N" (frame normal : VEC3),
* "SLF_<i> : VEC3" (coefficient number i of the 3 - one per channel - ; the max i is nbCoefs),
*
* @param map map to be exported
* @param filename filename of ply file
* @param position the position container
* @param nbCoefs the number of coefficients of the representation
* @return true
*/
template <typename PFP>
bool exportPlyPTMgeneric(typename PFP::MAP& map, const typename PFP::TVEC3& position, const char* filename, const FunctorSelect& good = allDarts) ;
/**
* export the map into a PLYPTMgeneric file (K. Vanhoey generic format)
......@@ -88,7 +118,7 @@ bool exportPlyPTMgeneric(typename PFP::MAP& map, const char* filename, const typ
* @return true
*/
template <typename PFP>
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good) ;
bool exportPLYPTM(typename PFP::MAP& map, const char* filename, const typename PFP::TVEC3& position, const typename PFP::TVEC3 frame[3], const typename PFP::TVEC3 colorPTM[6], const FunctorSelect& good = allDarts) ;
} // namespace Export
......
This diff is collapsed.
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2011, 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 *
......@@ -17,7 +17,7 @@
* 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/ *
* Web site: http://cgogn.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
......@@ -37,9 +37,42 @@ namespace Geometry
template <typename PFP>
void featureEdgeDetection(typename PFP::MAP& map, const typename PFP::TVEC3& position, CellMarker& featureEdge) ;
template <typename PFP>
void computeArea(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0) ;
template <typename PFP>
void computeFaceGradient(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_gradient, const typename PFP::TVEC3& face_normal, const typename PFP::TREAL& kmax, const typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0) ;
template <typename PFP>
void computeGradient(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& gradient, typename PFP::TVEC3& face_gradient, const typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0) ;
template <typename PFP>
void computeTriangleType(typename PFP::MAP& map, const typename PFP::TVEC3& position, CellMarker& regularMarker, const FunctorSelect& select = allDarts, unsigned int thread = 0) ;
template <typename PFP>
void computeCurvatureSign(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& triangle_type, typename PFP::TVEC3& k, const FunctorSelect& select = allDarts, unsigned int thread = 0) ;
template <typename PFP>
std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& map, const typename PFP::VEC3& cameraPosition, const typename PFP::TVEC3& position, const typename PFP::TVEC3& normal) ;
template <typename PFP>
typename PFP::TREAL faceArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ;
template <typename PFP>
typename PFP::VEC3 faceGradient(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, const typename PFP::TVEC3& face_normal, const typename PFP::TREAL& kmax, const typename PFP::TREAL& area) ;
template <typename PFP>
bool triangleType(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position) ;
template <typename PFP>
bool isInSameOctant(const typename PFP::VEC3& pos1, const typename PFP::VEC3& pos2) ;
template <typename PFP>
void curvatureSign(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, typename PFP::TVEC3& triangle_type, typename PFP::TVEC3& k) ;
template <typename PFP>
typename PFP::TVEC3 vertexGradient(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, const typename PFP::TVEC3& face_gradient, const typename PFP::TREAL& area) ;
} // namespace Geometry
} // namespace Algo
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg *
* Copyright (C) 2009-2011, 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 *
......@@ -17,7 +17,7 @@
* 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/ *
* Web site: http://cgogn.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
......@@ -58,6 +58,53 @@ void featureEdgeDetection(typename PFP::MAP& map, typename PFP::TVEC3& position,
// map.template removeAttribute<VEC3>(fNormal) ;
}
template <typename PFP>
void computeArea(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0)
{
TraversorF<typename PFP::MAP> trav(map, select, thread);
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
area[d] = faceArea<PFP>(map, d, position)[1] ;
}
template <typename PFP>
void computeFaceGradient(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& face_gradient, const typename PFP::TVEC3& face_normal, const typename PFP::TREAL& kmax, const typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0)
{
TraversorF<typename PFP::MAP> trav(map, select, thread);
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
face_gradient[d] = faceGradient<PFP>(map, d, position, face_normal, kmax, area) ;
}
template <typename PFP>
void computeGradient(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& gradient, typename PFP::TVEC3& face_gradient, const typename PFP::TREAL& area, const FunctorSelect& select = allDarts, unsigned int thread = 0)
{
TraversorV<typename PFP::MAP> trav(map, select, thread);
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
gradient[d] = vertexGradient<PFP>(map, d, position, face_gradient, area) ;
}
template <typename PFP>
void computeTriangleType(typename PFP::MAP& map, const typename PFP::TVEC3& position, CellMarker& regularMarker, const FunctorSelect& select = allDarts, unsigned int thread = 0)
{
TraversorF<typename PFP::MAP> trav(map, select, thread);
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
if(triangleType<PFP>(map, d, position))
regularMarker.mark(d) ;
}
template <typename PFP>
void computeCurvatureSign(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& triangle_type, typename PFP::TVEC3& k, const FunctorSelect& select = allDarts, unsigned int thread = 0)
{
CellMarker mv(map, VERTEX, thread);
TraversorV<typename PFP::MAP> trav(map, select, thread);
for (Dart d = trav.begin(); d != trav.end(); d = trav.next())
{
if (!mv.isMarked(d))
{
curvatureSign<PFP>(map, d, position, triangle_type, k) ;
}
}
}
template <typename PFP>
std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& map, const typename PFP::VEC3& cameraPosition, const typename PFP::TVEC3& position, const typename PFP::TVEC3& normal)
{
......@@ -112,6 +159,188 @@ std::vector<typename PFP::VEC3> occludingContoursDetection(typename PFP::MAP& ma
return occludingContours ;
}
template <typename PFP>
float faceArea(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{
typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC3 VEC3 ;
float A [1] ;
VEC3 pos1(0) ;
VEC3 pos2(0) ;
VEC3 pos3(0) ;
Traversor2FV<typename PFP::MAP> t(map, d) ;
Dart it = t.begin() ;
pos1 += position[it] ;
it = t.next ;
pos2 += position[it] ;
it = t.next ;
pos3 += position[it] ;
A = 1/2 * abs(
( (pos2.x - pos1.x) * (pos3.y - pos1.y) )
-
( (pos3.x - pos1.x) * (pos2.y - pos1.y) )
) ;
return A ;
}
template <typename PFP>
typename PFP::VEC3 faceGradient(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, const typename PFP::TVEC3& face_normal, const typename PFP::TREAL& kmax, const typename PFP::TREAL& area)
{
typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC3 VEC3 ;
VEC3 G(0) ;
VEC3 pos1(0) ;
VEC3 pos2(0) ;
VEC3 pos3(0) ;
VEC3 n = face_normal[d] ;
REAL k1 ;
REAL k2 ;
REAL k3 ;
REAL a = area[d] ;
Traversor2FV<typename PFP::MAP> t(map, d) ;
Dart it = t.begin() ;
pos1 += position[it] ;
k1 = kmax[it] ;
it = t.next() ;
pos2 += position[it] ;
k2 = kmax[it] ;
it = t.next() ;
pos3 += position[it] ;
k3 = kmax[it] ;
G += k1 * ( ( n ^ ( pos3 - pos2 ) ) / ( 2 * a ) ) +
k2 * ( ( n ^ ( pos1 - pos3 ) ) / ( 2 * a ) ) +
k3 * ( ( n ^ ( pos2 - pos1 ) ) / ( 2 * a ) ) ;
G.normalize() ;
return G ;
}
template <typename PFP>
bool triangleType(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position)
{
typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC3 VEC3 ;
VEC3 pos1(0) ;
VEC3 pos2(0) ;
VEC3 pos3(0) ;
Traversor2FV<typename PFP::MAP> t(map, d) ;
Dart it = t.begin() ;
pos1 += position[it] ;
it = t.next() ;
pos2 += position[it] ;
it = t.next() ;
pos3 += position[it] ;
if ( isInSameOctant<PFP>(pos1,pos2) && isInSameOctant<PFP>(pos1,pos3) )
{
//regular triangle
return true ;
}
else
{
//singular triangle
return false ;
}
}
template <typename PFP>
bool isInSameOctant(const typename PFP::VEC3& pos1, const typename PFP::VEC3& pos2)
{
return ( ( pos1[0] > 0 && pos1[1] > 0 && pos1[2] > 0 && //one of the eight octant
( ( pos2[0] > 0 && pos2[1] > 0 && pos2[2] > 0 ) or //one choice of sign
( pos2[0] < 0 && pos2[1] < 0 && pos2[2] < 0 ) ) ) or //the other choice
( pos1[0] > 0 && pos1[1] > 0 && pos1[2] < 0 &&
( ( pos2[0] > 0 && pos2[1] > 0 && pos2[2] < 0 ) or
( pos2[0] < 0 && pos2[1] < 0 && pos2[2] > 0 ) ) ) or
( pos1[0] > 0 && pos1[1] < 0 && pos1[2] > 0 &&
( ( pos2[0] > 0 && pos2[1] < 0 && pos2[2] > 0 ) or
( pos2[0] < 0 && pos2[1] > 0 && pos2[2] < 0 ) ) ) or
( pos1[0] > 0 && pos1[1] < 0 && pos1[2] < 0 &&
( ( pos2[0] > 0 && pos2[1] < 0 && pos2[2] < 0 ) or
( pos2[0] < 0 && pos2[1] > 0 && pos2[2] > 0 ) ) ) or
( pos1[0] < 0 && pos1[1] > 0 && pos1[2] > 0 &&
( ( pos2[0] < 0 && pos2[1] > 0 && pos2[2] > 0 ) or
( pos2[0] > 0 && pos2[1] < 0 && pos2[2] < 0 ) ) ) or
( pos1[0] < 0 && pos1[1] > 0 && pos1[2] < 0 &&
( ( pos2[0] < 0 && pos2[1] > 0 && pos2[2] < 0 ) or
( pos2[0] > 0 && pos2[1] < 0 && pos2[2] > 0 ) ) ) or
( pos1[0] < 0 && pos1[1] < 0 && pos1[2] > 0 &&
( ( pos2[0] < 0 && pos2[1] < 0 && pos2[2] > 0 ) or
( pos2[0] > 0 && pos2[1] > 0 && pos2[2] < 0 ) ) ) or
( pos1[0] < 0 && pos1[1] < 0 && pos1[2] < 0 &&
( ( pos2[0] < 0 && pos2[1] < 0 && pos2[2] < 0 ) or
( pos2[0] > 0 && pos2[1] > 0 && pos2[2] > 0 ) ) ) ) ;
}
template <typename PFP>
void curvatureSign(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, typename PFP::TVEC3& triangle_type, typename PFP::TVEC3& k)
{
/*sommetTraité = true ;*/
Traversor2VE<typename PFP::MAP> trav2(map, d) ;
for (Dart d2 = trav2.begin(); d2 != trav2.end(); d2 = trav2.next())
{
if (/*arrete non traité*/ true)
{
if((k[d] * k[d2]) <= 0)
{
k[d2] *= -1 ;
}
/*arreteTraité = true ;*/
/*meme chose avec sommet le long de l'arrete*/
/*curvatureSign(sommet le long del'arrete) ;*/
}
}
}
template <typename PFP>
typename PFP::TVEC3 vertexGradient(typename PFP::MAP& map, Dart d, const typename PFP::TVEC3& position, const typename PFP::TVEC3& face_gradient, const typename PFP::TREAL& area)
{
typedef typename PFP::REAL REAL ;
typedef typename PFP::VEC3 VEC3 ;
VEC3 G(0) ;
REAL A = 0 ;
Traversor2VF<typename PFP::MAP> t(map, d) ;
for (Dart d = t.begin(); d != t.end(); d = t.next())
{
G += area[d] * face_gradient[d] ;
A += area[d] ;
}
G = G / A ;
G.normalize() ;
return G ;
}
} // namespace Geometry
} // namespace Algo
......
......@@ -461,7 +461,7 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
}
}
//position[centralDart] = volCenter;
position[centralDart] = volCenter;
......@@ -478,7 +478,7 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
// std::cout << "boundary" << std::endl;
// //id pour toutes les faces interieures
// map.sewVolumes(map.phi2(f1), map.phi2(f2));
// break;
//
////
//// //Fais a la couture !!!!!
//// unsigned int idface = map.getNewFaceId();
......@@ -492,18 +492,18 @@ Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, typename PFP::TVEC3
//// map.setEdgeId( map.phi2(f2), idedge, DART);
// }
// //LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!!
// //id pour les aretes interieurs : (i.e. 6 pour un hexa)
// DartMarker mne(map);
// for(unsigned int i = 0; i < newEdges.size(); ++i)
// {
// if(!mne.isMarked(newEdges[i]))
// {
// unsigned int idedge = map.getNewEdgeId();
// map.setEdgeId(newEdges[i], idedge, EDGE);
// mne.markOrbit(EDGE, newEdges[i]);
// }
// }
//LA copie de L'id est a gerer avec le sewVolumes normalement !!!!!!
//id pour les aretes interieurs : (i.e. 6 pour un hexa)
DartMarker mne(map);
for(unsigned int i = 0; i < newEdges.size(); ++i)
{
if(!mne.isMarked(newEdges[i]))
{
unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(newEdges[i], idedge, EDGE);
mne.markOrbit(EDGE, newEdges[i]);
}
}
//plonger a la fin de la boucle ????
......
......@@ -44,10 +44,9 @@ namespace Import
* import a mesh
* @param map the map in which the function imports the mesh
* @param filename (*.{trian,trianbgz,off,obj,ply})
* @param positions table of vertices positions attribute
* @param m a marker that will be set by the function. If closeObject=false the phi2 that have fixed point are marked, else the created darts of the boundary are marked.
* @param attrNames attribute names
* @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values)
* @param closeObject a boolean indicating if the imported mesh should be closed
* @param mergeColseVertces a boolean indicating if the imported mesh should be closed
* @return a boolean indicating if import was successfull
*/
template <typename PFP>
......@@ -55,14 +54,25 @@ bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector
/**
* import a volumetric mesh
* @param map the map in which the function imports the mesh
* @param filename (*.{tet,off,ts})
* @param attrNames attribute names
* @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values)
* @param mergeColseVertces a boolean indicating if the imported mesh should be closed
* @return a boolean indicating if import was successfull
*/
//template <typename PFP>
//bool importMesh(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& positions, ImportVolumique::ImportType kind = ImportVolumique::UNKNOWNVOLUME);
//template <typename PFP>
//bool importObjWithTex(typename PFP::MAP& map, const std::string& filename);
//
template <typename PFP>
bool importMeshV(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportVolumique::ImportType kind = ImportVolumique::UNKNOWNVOLUME, bool mergeCloseVertices=false);
/**
* import a mesh and extrud it
* @param map the map in which the function imports the mesh
* @param filename (*.{trian,trianbgz,off,obj,ply})
* @param attrNames attribute names
* @param kind what kind of mesh is the file (if none (-1) determined by filename extension) (cf enum in Mesh2Tables for other kind values)
* @param mergeColseVertces a boolean indicating if the imported mesh should be closed
* @return a boolean indicating if import was successfull
*/
template <typename PFP>
bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, ImportSurfacique::ImportType kind = ImportSurfacique::UNKNOWNSURFACE);
......@@ -80,6 +90,10 @@ template <typename PFP>
bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
//template <typename PFP>
//bool importObjWithTex(typename PFP::MAP& map, const std::string& filename);
//
} // namespace Import
} // namespace Algo
......
......@@ -52,12 +52,12 @@ namespace Import
namespace ImportSurfacique
{
enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, PLY, PLYPTM, PLYPTMgeneric, OFF, OBJ, VRML, AHEM };
enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, MESHBIN, PLY, PLYPTM, PLYSLFgeneric, PLYSLFgenericBin, OFF, OBJ, VRML, AHEM };
}
namespace ImportVolumique
{
enum ImportType { UNKNOWNVOLUME ,TET ,TRIANBGZ ,PLY ,OFF, OBJ };
enum ImportType { UNKNOWNVOLUME , TET, ELE, TS };
}
......@@ -109,12 +109,16 @@ public:
bool importOff(const std::string& filename, std::vector<std::string>& attrNames);
bool importMeshBin(const std::string& filename, std::vector<std::string>& attrNames);
bool importObj(const std::string& filename, std::vector<std::string>& attrNames);
bool importPly(const std::string& filename, std::vector<std::string>& attrNames);
bool importPlyPTM(const std::string& filename, std::vector<std::string>& attrNames);
bool importPlyPTMgeneric(const std::string& filename, std::vector<std::string>& attrNames);
bool importPlySLFgeneric(const std::string& filename, std::vector<std::string>& attrNames);
bool importPlySLFgenericBin(const std::string& filename, std::vector<std::string>& attrNames);
#ifdef WITH_ASSIMP
bool importASSIMP(const std::string& filename, std::vector<std::string>& attrNames);
#endif
......@@ -184,9 +188,6 @@ public:
bool importTet(const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor);
bool importPly(const std::string& filename, std::vector<std::string>& attrNames);
bool importTrianBinGz(const std::string& filename, std::vector<std::string>& attrNames);
MeshTablesVolume(typename PFP::MAP& map):
m_map(map)
......
......@@ -37,11 +37,11 @@ ImportVolumique::ImportType MeshTablesVolume<PFP>::getFileType(const std::string
if ((filename.rfind(".tet")!=std::string::npos) || (filename.rfind(".TET")!=std::string::npos))
return ImportVolumique::TET;
if ((filename.rfind(".trianbgz")!=std::string::npos) || (filename.rfind(".TRIANBGZ")!=std::string::npos))
return ImportVolumique::TRIANBGZ;
if ((filename.rfind(".ele")!=std::string::npos) || (filename.rfind(".ELE")!=std::string::npos))
return ImportVolumique::ELE;
if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos))
return ImportVolumique::PLY;
if ((filename.rfind(".ts")!=std::string::npos) || (filename.rfind(".TS")!=std::string::npos))
return ImportVolumique::TS;
return ImportVolumique::UNKNOWNVOLUME;
}
......@@ -54,14 +54,12 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, std::vector<
switch (kind)
{
case ImportVolumique::PLY:
return importPly(filename, attrNames);
break;
case ImportVolumique::TET:
return importTet(filename, attrNames, scaleFactor);
break;
case ImportVolumique::TRIANBGZ:
return importTrianBinGz(filename, attrNames);
case ImportVolumique::ELE:
break;
case ImportVolumique::TS:
break;
default:
CGoGNerr << "Not yet supported" << CGoGNendl;
......@@ -73,48 +71,44 @@ bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, std::vector<
template <typename PFP>
bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor=1.0f)
{
AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ;
// AttributeHandler<typename PFP::VEC3> positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "position") ;
AttributeHandler<typename PFP::VEC3> positions = m_map.template getAttribute<typename PFP::VEC3>(VERTEX, "position") ;
AttributeHandler<VEC3> positions = m_map.template getAttribute<VEC3>(VERTEX, "position") ;
if (!positions.isValid())
positions = m_map.template addAttribute<typename PFP::VEC3>(VERTEX, "position") ;
positions = m_map.template addAttribute<VEC3>(VERTEX, "position") ;
attrNames.push_back(positions.name()) ;
// open file
AttributeContainer& container = m_map.getAttributeContainer(VERTEX) ;
//open file
std::ifstream fp(filename.c_str(), std::ios::in);
if (!fp.good())
{
CGoGNerr << "Unable to open file " << filename<< CGoGNendl;
CGoGNerr << "Unable to open file " << filename << CGoGNendl;
return false;
}
std::string ligne;
int nbv,nbt;
// lecture des nombres de sommets/tetra
std::string ligne;
unsigned int nbv, nbt;
// reading number of vertices
std::getline (fp, ligne);
std::stringstream oss(ligne);
oss >> nbv;
//CGoGNout << "nbV = " << nbv << CGoGNendl;
// reading number of tetrahedra
std::getline (fp, ligne);
std::stringstream oss2(ligne);
oss2 >> nbt;
//CGoGNout << "nbT = " << nbt << CGoGNendl;
//lecture sommets
//reading vertices
std::vector<unsigned int> verticesID;
verticesID.reserve(nbv);
for(int i=0; i<nbv;++i)
for(unsigned int i = 0; i < nbv;++i)
{
do
{
std::getline (fp, ligne);
} while (ligne.size()==0);
do
{
std::getline (fp, ligne);
} while (ligne.size() == 0);
std::stringstream oss(ligne);
......@@ -122,21 +116,18 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s
oss >> x;
oss >> y;
oss >> z;
// on peut ajouter ici la lecture de couleur si elle existe
// TODO : if required read other vertices attributes here
VEC3 pos(x*scaleFactor,y*scaleFactor,z*scaleFactor);
//CGoGNout << "VEC3 = " << pos << CGoGNendl;
unsigned int id = container.insertLine();