Commit 192d8ed6 authored by Sylvain Thery's avatar Sylvain Thery

add volume generic exportMesh function

parent 802b0310
......@@ -26,6 +26,9 @@
#define __EXPORT_H__
#include "Topology/generic/attributeHandler.h"
#include "Algo/Import/importFileTypes.h"
#include <stdint.h>
namespace CGoGN
......
......@@ -39,12 +39,21 @@ namespace Volume
namespace Export
{
/**
* Export a mesh choosing the format according to filename extension
* @param the_map map to be exported
* @param position the position container
* @param filename filename of mesh file
* @return true
*/
template <typename PFP>
bool exportMesh(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const std::string& filename) ;
/**
* export the map into a .nas (nastran file)
* @param the_map map to be exported
* @param position the position container
* @param filename filename of ply file
* @param filename filename of mesh file
* @return true
*/
template <typename PFP>
......@@ -55,7 +64,7 @@ bool exportNAS(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>
* export the map into a vtu file (vtk unstructured grid)
* @param the_map map to be exported
* @param position the position container
* @param binary write in binary mode
* @param filename filename of mesh file
* @return true
*/
template <typename PFP>
......@@ -66,7 +75,7 @@ bool exportVTU(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>
* export the map into a .msh (gmesh file)
* @param the_map map to be exported
* @param position the position container
* @param filename filename of ply file
* @param filename filename of mesh file
* @return true
*/
template <typename PFP>
......@@ -77,7 +86,7 @@ bool exportMSH(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>
* export the map into a .tet file
* @param the_map map to be exported
* @param position the position container
* @param filename filename of ply file
* @param filename filename of mesh file
* @return true
*/
template <typename PFP>
......@@ -88,7 +97,7 @@ bool exportTet(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>
* export the map into a .node/.ele file pair
* @param the_map map to be exported
* @param position the position container
* @param filename filename of ply file
* @param filename filename of mesh file
* @return true
*/
template <typename PFP>
......@@ -99,7 +108,7 @@ bool exportNodeEle(typename PFP::MAP& map, const VertexAttribute<typename PFP::V
* export in binary volume file (nb_vert,nb_tetra,nb_hexa, vertices, tetra, hexa)
* @param the_map map to be exported
* @param position the position container
* @param filename filename of ply file
* @param filename filename of mesh file
*/
template <typename PFP>
bool exportVolBinGz(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const char* filename);
......
......@@ -27,6 +27,7 @@
#include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h"
#include "Topology/generic/cellmarker.h"
#include "Algo/Import/importFileTypes.h"
namespace CGoGN
{
......@@ -535,6 +536,8 @@ bool exportNodeEle(typename PFP::MAP& map, const VertexAttribute<typename PFP::V
typedef typename PFP::VEC3 VEC3;
std::string base(filename);
size_t pos = base.rfind(".");
base.erase(pos);
std::string fnNode = base + ".node";
std::string fnEle = base + ".ele";
......@@ -588,27 +591,6 @@ bool exportNodeEle(typename PFP::MAP& map, const VertexAttribute<typename PFP::V
degree++;
}
// if (degree == 8)
// {
// //CAS HEXAEDRIQUE (ordre 2 quad superposes, le premier en CW)
// Dart e = d;
// Dart f = map.template phi<21121>(d);
// hexa.push_back(indices[f]);
// e = map.phi_1(f);
// hexa.push_back(indices[f]);
// e = map.phi_1(f);
// hexa.push_back(indices[f]);
// e = map.phi_1(f);
// hexa.push_back(indices[f]);
// hexa.push_back(indices[e]);
// e = map.phi1(e);
// hexa.push_back(indices[e]);
// e = map.phi1(e);
// hexa.push_back(indices[e]);
// e = map.phi1(e);
// hexa.push_back(indices[e]);
// }
if (degree == 4)
{
//CAS TETRAEDRIQUE
......@@ -718,23 +700,6 @@ bool exportVolBinGz(typename PFP::MAP& map, const VertexAttribute<typename PFP::
e = map.phi1(e);
hexa.push_back(indices[e]);
// hexa.push_back(indices[e]);
// e = map.phi1(e);
// hexa.push_back(indices[e]);
// e = map.phi1(e);
// hexa.push_back(indices[e]);
// e = map.phi1(e);
// hexa.push_back(indices[e]);
// Dart f = map.template phi<21121>(d);
// hexa.push_back(indices[f]);
// f = map.phi_1(f);
// hexa.push_back(indices[f]);
// f = map.phi_1(f);
// hexa.push_back(indices[f]);
// f = map.phi_1(f);
// hexa.push_back(indices[f]);
}
if (degree == 4)
......@@ -792,6 +757,37 @@ bool exportVolBinGz(typename PFP::MAP& map, const VertexAttribute<typename PFP::
}
template <typename PFP>
bool exportMesh(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const std::string& filename)
{
Import::ImportType kind = Import::getFileType(filename);
// manque TS, OFF ?
switch (kind)
{
case Import::TET:
return exportTet<PFP>(map, position, filename.c_str());
break;
case Import::NODE:
return exportNodeEle<PFP>(map, position, filename.c_str());
break;
case Import::MSH:
return exportMSH<PFP>(map, position, filename.c_str());
break;
case Import::VTU:
return exportVTU<PFP>(map, position, filename.c_str());
break;
case Import::NAS:
return exportNAS<PFP>(map, position, filename.c_str());
break;
case Import::VBGZ:
return exportVolBinGz<PFP>(map, position, filename.c_str());
break;
default:
CGoGNerr << "unknown file format for " << filename << CGoGNendl;
break;
}
}
......
......@@ -35,6 +35,8 @@
#include "Utils/gzstream.h"
#include "Algo/Import/importFileTypes.h"
#ifdef WITH_ASSIMP
#include "Assimp/assimp.h"
#include "Assimp/aiPostProcess.h"
......@@ -53,15 +55,6 @@ namespace Surface
namespace Import
{
enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, MESHBIN, PLY, /*PLYPTM, */PLYSLFgeneric, PLYSLFgenericBin, OFF, OBJ, VRML, AHEM, STL, STLB };
// namespace ImportSurfacique
// {
//
// }
template <typename PFP>
class MeshTablesSurface
{
......@@ -151,8 +144,6 @@ namespace Volume
namespace Import
{
enum ImportType { UNKNOWNVOLUME , TET, OFF, TS, MOKA, NODE, MSH, VTU, NAS, VBGZ};
template <typename PFP>
class MeshTablesVolume
{
......
......@@ -34,26 +34,6 @@ namespace Volume
namespace Import
{
template <typename PFP>
ImportType MeshTablesVolume<PFP>::getFileType(const std::string& filename)
{
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(".moka")!=std::string::npos) || (filename.rfind(".MOKA")!=std::string::npos))
return MOKA;
return UNKNOWNVOLUME;
}
template <typename PFP>
bool MeshTablesVolume<PFP>::importMesh(const std::string& filename, std::vector<std::string>& attrNames, float scaleFactor)
......
/*******************************************************************************
* 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 *
* *
*******************************************************************************/
#ifndef _IMPORT_FILE_TYPES_H
#define _IMPORT_FILE_TYPES_H
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Import
{
enum ImportType { UNKNOWNSURFACE, TRIAN, TRIANBGZ, MESHBIN, PLY, /*PLYPTM, */PLYSLFgeneric, PLYSLFgenericBin, OFF, OBJ, VRML, AHEM, STL, STLB };
inline ImportType 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;
}
}
}
namespace Volume
{
namespace Import
{
enum ImportType { UNKNOWNVOLUME , TET, OFF, TS, MOKA, NODE, MSH, VTU, NAS, VBGZ};
inline ImportType getFileType(const std::string& filename)
{
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(".moka")!=std::string::npos) || (filename.rfind(".MOKA")!=std::string::npos))
return MOKA;
if ((filename.rfind(".node")!=std::string::npos) || (filename.rfind(".NODE")!=std::string::npos))
return NODE;
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;
}
}
}
}
}
#endif
......@@ -516,32 +516,8 @@ bool importMesh(typename PFP::MAP& map, MeshTablesVolume<PFP>& mtv)
template <typename PFP>
bool importMesh(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames, bool /*mergeCloseVertices*/)
{
ImportType kind = Volume::Import::UNKNOWNVOLUME;
if ((filename.rfind(".tet") != std::string::npos) || (filename.rfind(".TET") != std::string::npos))
kind = TET;
if ((filename.rfind(".off") != std::string::npos) || (filename.rfind(".OFF") != std::string::npos))
kind = OFF;
if ((filename.rfind(".node") != std::string::npos) || (filename.rfind(".NODE") != std::string::npos))
kind = NODE;
if ((filename.rfind(".ts") != std::string::npos) || (filename.rfind(".TS") != std::string::npos))
kind = TS;
if ((filename.rfind(".msh") != std::string::npos) || (filename.rfind(".MSH") != std::string::npos))
kind = MSH;
if ((filename.rfind(".vtu") != std::string::npos) || (filename.rfind(".VTU") != std::string::npos))
kind = VTU;
if ((filename.rfind(".nas") != std::string::npos) || (filename.rfind(".NAS") != std::string::npos))
kind = NAS;
if ((filename.rfind(".volbgz") != std::string::npos) || (filename.rfind(".VOLBGZ") != std::string::npos))
kind = VBGZ;
ImportType kind = getFileType(filename);
switch (kind)
{
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment