Commit aa405fe8 authored by Sylvain Thery's avatar Sylvain Thery
Browse files

add Surface & Volume namespace into Algo

parent 01cf528d
......@@ -31,6 +31,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -66,6 +69,8 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -33,6 +33,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -244,6 +247,8 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......@@ -33,6 +33,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -70,6 +73,8 @@ bool isTriangleObtuse(typename PFP::MAP& map, Dart d, const VertexAttribute<type
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -34,6 +34,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -151,6 +154,8 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -36,6 +36,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -209,6 +212,8 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......@@ -40,6 +40,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -154,6 +157,8 @@ void computeCurvatureVertices_QuadraticFitting(
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -42,6 +42,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -512,6 +515,8 @@ void computeCurvatureVertices_QuadraticFitting(
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......@@ -31,6 +31,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -166,6 +169,8 @@ std::vector<typename PFP::VEC3> occludingContoursDetection(
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -32,6 +32,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -516,6 +519,8 @@ std::vector<typename PFP::VEC3> occludingContoursDetection(
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......@@ -36,6 +36,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -125,6 +128,8 @@ bool isConvexFaceInOrIntersectingTetrahedron(typename PFP::MAP& map, Dart d, con
} // namespace Geometry
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -35,6 +35,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Geometry
{
......@@ -84,7 +87,7 @@ bool isPointInVolume(typename PFP::MAP& map, Dart d, const VertexAttribute<typen
{
Dart e = visitedFaces[iface];
VEC3 inter;
bool interRes = Algo::Geometry::intersectionLineConvexFace<PFP>(map, e, position, point, dir, inter);
bool interRes = intersectionLineConvexFace<PFP>(map, e, position, point, dir, inter);
if (interRes)
{
// check if already intersect on same point (a vertex certainly)
......@@ -141,7 +144,7 @@ bool isPointInConvexVolume(typename PFP::MAP& map, Dart d, const VertexAttribute
{
if (!mark.isMarked(*face))
{
Geom::Plane3D<REAL> p = Geometry::facePlane<PFP>(map, *face, position);
Geom::Plane3D<REAL> p = facePlane<PFP>(map, *face, position);
Geom::Orientation3D o3d = p.orient(point);
if(CCW)
{
......@@ -234,7 +237,7 @@ bool isPointOnEdge(typename PFP::MAP& map, Dart d, const VertexAttribute<typenam
// typedef typename PFP::REAL REAL;
// typedef typename PFP::VEC3 VEC3 ;
//
// VEC3 v1 = Algo::Geometry::vectorOutOfDart<PFP>(map, d, positions);
// VEC3 v1 = vectorOutOfDart<PFP>(map, d, positions);
// VEC3 v2(point - positions[d]);
//
// v1.normalize();
......@@ -243,9 +246,9 @@ bool isPointOnEdge(typename PFP::MAP& map, Dart d, const VertexAttribute<typenam
// return fabs(REAL(1) - (v1*v2)) < std::numeric_limits<REAL>::min();
if(
( Algo::Geometry::isPointOnHalfEdge<PFP>(map,d,position,point) && Algo::Geometry::isPointOnHalfEdge<PFP>(map,map.phi2(d),position,point) ) ||
Algo::Geometry::isPointOnVertex<PFP>(map,d,position,point) ||
Algo::Geometry::isPointOnVertex<PFP>(map,map.phi1(d),position,point)
( isPointOnHalfEdge<PFP>(map,d,position,point) && isPointOnHalfEdge<PFP>(map,map.phi2(d),position,point) ) ||
isPointOnVertex<PFP>(map,d,position,point) ||
isPointOnVertex<PFP>(map,map.phi1(d),position,point)
)
return true;
else
......@@ -262,7 +265,7 @@ bool isPointOnHalfEdge(typename PFP::MAP& map, Dart d, const VertexAttribute<typ
typedef typename PFP::REAL REAL;
typedef typename PFP::VEC3 VEC3;
VEC3 v1 = Algo::Geometry::vectorOutOfDart<PFP>(map, d, position);
VEC3 v1 = vectorOutOfDart<PFP>(map, d, position);
VEC3 v2(point - position[d]);
v1.normalize();
......@@ -304,6 +307,8 @@ bool isConvexFaceInOrIntersectingTetrahedron(typename PFP::MAP& map, Dart d, con
} // namespace Geometry
}
} // namspace Algo
} // namespace CGoGN
......@@ -37,6 +37,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Import
{
......@@ -51,6 +54,27 @@ namespace Import
template <typename PFP>
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, bool mergeCloseVertices = false);
/**
* import a Choupi file
* @param map
* @param filename
* @return
*/
template <typename PFP>
bool importChoupi(const std::string& filename, const std::vector<typename PFP::VEC3>& tabV, const std::vector<unsigned int>& tabE);
} // namespace Import
} // Surface
namespace Volume
{
namespace Import
{
/**
* import a volumetric mesh
* @param map the map in which the function imports the mesh
......@@ -76,24 +100,6 @@ bool importMeshToExtrude(typename PFP::MAP& map, const std::string& filename, st
template <typename PFP>
bool importMeshSAsV(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames);
/*
* import a MOKA file
* @param gmap the gmap in which the function imports the mesh
* @param filename
* @param attrNames attribute names
*/
template <typename PFP>
bool importMoka(typename PFP::MAP& gmap, const std::string& filename, std::vector<std::string>& attrNames);
/**
* import a Choupi file
* @param map
* @param filename
* @return
*/
template <typename PFP>
bool importChoupi(const std::string& filename, const std::vector<typename PFP::VEC3>& tabV, const std::vector<unsigned int>& tabE);
/*
* TODO a transformer en utilisant un MeshTableVolume.
*/
......@@ -112,7 +118,10 @@ bool importMoka(typename PFP::MAP& the_gmap, const std::string& filename, std::v
template <typename PFP>
bool importTs(typename PFP::MAP& the_map, const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor = 1.0f);
} // namespace Import
} // Import
} // Volume
} // namespace Algo
......
......@@ -46,18 +46,19 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Import
{
namespace ImportSurfacique
{
enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, MESHBIN, PLY, /*PLYPTM, */PLYSLFgeneric, PLYSLFgenericBin, OFF, OBJ, VRML, AHEM };
}
enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, MESHBIN, PLY, /*PLYPTM, */PLYSLFgeneric, PLYSLFgenericBin, OFF, OBJ, VRML, AHEM };
// namespace ImportSurfacique
// {
//
// }
namespace ImportVolumique
{
enum ImportType { UNKNOWNVOLUME , TET, OFF, TS, MOKA, NODE};
}
template <typename PFP>
......@@ -82,7 +83,7 @@ protected:
*/
std::vector<unsigned int> m_emb;
static ImportSurfacique::ImportType getFileType(const std::string& filename);
static ImportType getFileType(const std::string& filename);
#ifdef WITH_ASSIMP
void extractMeshRec(AttributeContainer& container, VertexAttribute<typename PFP::VEC3>& positions, const struct aiScene* scene, const struct aiNode* nd, struct aiMatrix4x4* trafo);
......@@ -136,6 +137,16 @@ public:
}
};
}
}
namespace Volume
{
namespace Import
{
enum ImportType { UNKNOWNVOLUME , TET, OFF, TS, MOKA, NODE};
template <typename PFP>
class MeshTablesVolume
......@@ -193,8 +204,12 @@ public:
}
};
} // namespace Import
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -40,91 +40,94 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Import
{
template<typename PFP>
ImportSurfacique::ImportType MeshTablesSurface<PFP>::getFileType(const std::string& filename)
ImportType MeshTablesSurface<PFP>::getFileType(const std::string& filename)
{
if ((filename.rfind(".trianbgz")!=std::string::npos) || (filename.rfind(".TRIANBGZ")!=std::string::npos))
return ImportSurfacique::TRIANBGZ;
return TRIANBGZ;
if ((filename.rfind(".trian")!=std::string::npos) || (filename.rfind(".TRIAN")!=std::string::npos))
return ImportSurfacique::TRIAN;
return TRIAN;
if ((filename.rfind(".meshbin")!=std::string::npos) || (filename.rfind(".MESHBIN")!=std::string::npos))
return ImportSurfacique::MESHBIN;
return MESHBIN;
/* if ((filename.rfind(".plyptm")!=std::string::npos) || (filename.rfind(".PLYGEN")!=std::string::npos))
return ImportSurfacique::PLYPTM;
return PLYPTM;
*/
if ((filename.rfind(".plyPTMextBin")!=std::string::npos) || (filename.rfind(".plySHrealBin")!=std::string::npos))
return ImportSurfacique::PLYSLFgenericBin;
return PLYSLFgenericBin;
if ((filename.rfind(".plyPTMext")!=std::string::npos) || (filename.rfind(".plySHreal")!=std::string::npos))
return ImportSurfacique::PLYSLFgeneric;
return PLYSLFgeneric;
if ((filename.rfind(".ply")!=std::string::npos) || (filename.rfind(".PLY")!=std::string::npos))
return ImportSurfacique::PLY;
return PLY;
if ((filename.rfind(".off")!=std::string::npos) || (filename.rfind(".OFF")!=std::string::npos))
return ImportSurfacique::OFF;
return OFF;
if ((filename.rfind(".obj")!=std::string::npos) || (filename.rfind(".OBJ")!=std::string::npos))
return ImportSurfacique::OBJ;
return OBJ;
if ((filename.rfind(".ahem")!=std::string::npos) || (filename.rfind(".AHEM")!=std::string::npos))
return ImportSurfacique::AHEM;
return AHEM;
return ImportSurfacique::UNKNOWNSURFACE;
return UNKNOWNSURFACE;
}
template<typename PFP>
bool MeshTablesSurface<PFP>::importMesh(const std::string& filename, std::vector<std::string>& attrNames)
{
ImportSurfacique::ImportType kind = getFileType(filename);
ImportType kind = getFileType(filename);
attrNames.clear() ;
switch (kind)
{
case ImportSurfacique::TRIAN:
case TRIAN:
CGoGNout << "TYPE: TRIAN" << CGoGNendl;
return importTrian(filename, attrNames);
break;
case ImportSurfacique::TRIANBGZ:
case TRIANBGZ:
CGoGNout << "TYPE: TRIANBGZ" << CGoGNendl;
return importTrianBinGz(filename, attrNames);
break;
case ImportSurfacique::OFF:
case OFF:
CGoGNout << "TYPE: OFF" << CGoGNendl;
return importOff(filename, attrNames);
break;
case ImportSurfacique::MESHBIN:
case MESHBIN:
CGoGNout << "TYPE: MESHBIN" << CGoGNendl;
return importMeshBin(filename, attrNames);
break;
case ImportSurfacique::PLY:
case PLY:
CGoGNout << "TYPE: PLY" << CGoGNendl;
return importPly(filename, attrNames);
break;
/* case ImportSurfacique::PLYPTM:
/* case PLYPTM:
CGoGNout << "TYPE: PLYPTM" << CGoGNendl;
return importPlyPTM(filename, attrNames);
break;
*/ case ImportSurfacique::PLYSLFgeneric:
*/ case PLYSLFgeneric:
CGoGNout << "TYPE: PLYSLFgeneric" << CGoGNendl;
return importPlySLFgeneric(filename, attrNames);
break;
case ImportSurfacique::PLYSLFgenericBin:
case PLYSLFgenericBin:
CGoGNout << "TYPE: PLYSLFgenericBin" << CGoGNendl;
return importPlySLFgenericBin(filename, attrNames);
break;
case ImportSurfacique::OBJ:
case OBJ:
CGoGNout << "TYPE: OBJ" << CGoGNendl;
return importObj(filename, attrNames);
break;
case ImportSurfacique::AHEM:
case AHEM:
CGoGNout << "TYPE: AHEM" << CGoGNendl;
return importAHEM(filename, attrNames);
break;
......@@ -1634,6 +1637,8 @@ bool MeshTablesSurface<PFP>::mergeCloseVertices()
} // namespace Import
}
} // namespace Algo
} // namespace CGoGN
......@@ -28,6 +28,9 @@ namespace CGoGN
namespace Algo
{
namespace Volume
{
namespace Import
{
......@@ -189,6 +192,8 @@ bool MeshTablesVolume<PFP>::importTet(const std::string& filename, std::vector<s
} // namespace Import
}
} // namespace Algo
} // namespace CGoGN
......@@ -29,6 +29,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Import
{
......@@ -125,6 +128,8 @@ bool importChoupi(const std::string& filename, std::vector<typename PFP::VEC3>&
} // namespace Import
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -31,6 +31,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Import
{
......@@ -182,6 +185,8 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto
} // namespace Import
}
} // namespace Algo
} // namespace CGoGN
......
......@@ -28,6 +28,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Import
{
......@@ -270,6 +273,8 @@ bool importMRDAT(typename PFP::MAP& map, const std::string& filename, std::vecto
} // namespace Import
}
} // namespace Algo
} // namespace CGoGN
......@@ -33,6 +33,9 @@ namespace CGoGN
namespace Algo
{
namespace Surface
{
namespace Import
{
......@@ -130,8 +133,138 @@ bool importMesh(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
return true ;
}
template <typename PFP>
bool importMeshSToV(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts, float dist)
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, bool mergeCloseVertices)
{
MeshTablesSurface<PFP> mts(map);
if(!mts.importMesh(filename, attrNames))
return false;
if (mergeCloseVertices)
mts.mergeCloseVertices();