Commit 6018ea78 authored by Sylvain Thery's avatar Sylvain Thery

more test of compil.

parent 1666a619
......@@ -4,14 +4,14 @@ project(testing_algo)
#add_subdirectory(BooleanOperator)
add_subdirectory(Decimation)
#add_subdirectory(Export)
add_subdirectory(Export)
add_subdirectory(Filtering)
add_subdirectory(Geometry)
#add_subdirectory(Histogram)
#add_subdirectory(ImplicitHierarchicalMesh)
#add_subdirectory(Import)
add_subdirectory(Import)
#add_subdirectory(LinearSolving)
#add_subdirectory(MC)
add_subdirectory(MC)
add_subdirectory(Modelisation)
#add_subdirectory(MovingObjects)
#add_subdirectory(Multiresolution)
......
cmake_minimum_required(VERSION 2.6)
project(testing_algo_export)
add_executable( test_algo_export
algo_export.cpp
export.cpp
exportPov.cpp
exportVTU.cpp
exportVol.cpp
)
target_link_libraries( test_algo_export
${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
\ No newline at end of file
#include <iostream>
extern int test_export();
extern int test_exportPov();
extern int test_exportVTU();
extern int test_exportVol();
int main()
{
test_export();
test_exportPov();
test_exportVTU();
test_exportVol();
return 0;
}
This diff is collapsed.
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 *
* *
* 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
#ifndef __EXPORT_VTU_H__
#define __EXPORT_VTU_H__
#include "Topology/generic/attributeHandler.h"
#include "Algo/Import/importFileTypes.h"
#include "Algo/Export/exportVTU.h"
using namespace CGoGN;
#include <stdint.h>
namespace CGoGN
{
namespace Algo
{
namespace Surface
struct PFP1 : public PFP_STANDARD
{
namespace Export
{
/**
* simple export of the geometry of map into a VTU file (VTK unstructured grid xml format)
* @param map map to be exported
* @param position the position container
* @param filename filename of ply file
* @return true if ok
*/
template <typename PFP>
bool exportVTU(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const char* filename);
/**
* simple export of the geometry of map into a binary VTU file (VTK unstructured grid xml format)
* @param map map to be exported
* @param position the position container
* @param filename filename of ply file
* @return true if ok
*/
template <typename PFP>
bool exportVTUBinary(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const char* filename);
//template <typename PFP>
//bool exportVTUCompressed(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const char* filename);
/**
* class that allow the export of VTU file (ascii or binary)
* with vertex and face attributes
*/
template <typename PFP>
class VTUExporter
{
protected:
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
typename PFP::MAP& m_map;
const VertexAttribute<typename PFP::VEC3>& m_position;
unsigned int nbtotal;
bool noPointData;
bool noCellData;
bool closed;
std::ofstream fout ;
std::vector<unsigned int> triangles;
std::vector<unsigned int> quads;
std::vector<unsigned int> others;
std::vector<unsigned int> others_begin;
std::vector<Dart> bufferTri;
std::vector<Dart> bufferQuad;
std::vector<Dart> bufferOther;
std::string m_filename;
bool binaryMode;
unsigned int offsetAppend;
FILE* f_tempoBin_out ;
template<typename T>
void addBinaryVertexAttribute(const VertexAttribute<T>& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name="");
template<typename T>
void addBinaryFaceAttribute(const FaceAttribute<T>& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name="");
bool binaryClose();
public:
VTUExporter(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position);
~VTUExporter();
/**
* @brief start writing header of vtu file
* @param filename
* @param bin true if binray mode wanted
* @return true if ok
*/
bool init(const char* filename, bool bin=false);
/**
* @brief add a vertex attribute
* @param attrib vertex attribute
* @param vtkType Float32/Int32/..
* @param nbComp number of components in attribute (if none computed from size of attribute divide bye the vtkType)
* @param name data name, if none then used attribute's name
*/
template<typename T>
void addVertexAttribute(const VertexAttribute<T>& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name="");
/**
* @brief finish adding vertex attributes data
*/
void endVertexAttributes();
/**
* @brief add a face attribute
* @param attrib vertex attribute
* @param vtkType Float32/Int32/..
* @param nbComp number of components in attribute (if none computed from size of attribute divide bye the vtkType)
* @param name data name, if none then used attribute's name
*/
template<typename T>
void addFaceAttribute(const FaceAttribute<T>& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name="");
/**
* @brief finish adding face attributes data
*/
void endFaceAttributes();
/**
* @brief finalize file writing & close (automatically called at destruction of not yet done)
* @return true if ok
*/
bool close();
typedef EmbeddedMap2 MAP;
};
} // namespace Export
template bool Algo::Surface::Export::exportVTU<PFP1>(PFP1::MAP& map, const VertexAttribute<PFP1::VEC3, PFP1::MAP>& position, const char* filename);
template bool Algo::Surface::Export::exportVTUBinary<PFP1>(PFP1::MAP& map, const VertexAttribute<PFP1::VEC3, PFP1::MAP>& position, const char* filename);
template class Algo::Surface::Export::VTUExporter<PFP1>;
} // Surface
namespace Volume
{
namespace Export
struct PFP2 : public PFP_STANDARD
{
/**
* class that allow the export of VTU file (ascii or binary)
* with vertex and volume attributes
*/
template <typename PFP>
class VTUExporter
{
protected:
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
typename PFP::MAP& m_map;
const VertexAttribute<typename PFP::VEC3>& m_position;
unsigned int nbtotal;
bool noPointData;
bool noCellData;
bool closed;
std::ofstream fout ;
std::vector<unsigned int> tetras;
std::vector<unsigned int> hexas;
std::vector<Dart> bufferTetra;
std::vector<Dart> bufferHexa;
std::string m_filename;
bool binaryMode;
unsigned int offsetAppend;
FILE* f_tempoBin_out ;
template<typename T>
void addBinaryVertexAttribute(const VertexAttribute<T>& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name="");
template<typename T>
void addBinaryVolumeAttribute(const VolumeAttribute<T>& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name="");
bool binaryClose();
public:
VTUExporter(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position);
~VTUExporter();
/**
* @brief start writing header of vtu file
* @param filename
* @param bin true if binray mode wanted
* @return true if ok
*/
bool init(const char* filename, bool bin=false);
/**
* @brief add a vertex attribute
* @param attrib vertex attribute
* @param vtkType Float32/Int32/..
* @param nbComp number of components in attribute (if none computed from size of attribute divide bye the vtkType)
* @param name data name, if none then used attribute's name
*/
template<typename T>
void addVertexAttribute(const VertexAttribute<T>& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name="");
/**
* @brief finish adding vertex attributes data
*/
void endVertexAttributes();
/**
* @brief add a volume attribute
* @param attrib vertex attribute
* @param vtkType Float32/Int32/..
* @param nbComp number of components in attribute (if none computed from size of attribute divide bye the vtkType)
* @param name data name, if none then used attribute's name
*/
template<typename T>
void addVolumeAttribute(const VolumeAttribute<T>& attrib, const std::string& vtkType, unsigned int nbComp=0, const std::string& name="");
/**
* @brief finish adding volume attributes data
*/
void endVolumeAttributes();
/**
* @brief finalize file writing & close (automatically called at destruction of not yet done)
* @return true if ok
*/
bool close();
typedef EmbeddedMap3 MAP;
};
} // namespace Export
} // Volume
template class Algo::Volume::Export::VTUExporter<PFP2>;
int test_exportVTU()
{
} // namespace Algo
} // namespace CGoGN
#include "Algo/Export/exportVTU.hpp"
#endif
return 0;
}
\ No newline at end of file
/*******************************************************************************
* 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap3.h"
#ifndef __EXPORT_VOL_H__
#define __EXPORT_VOL_H__
#include "Algo/Export/exportVol.hpp"
#include "Topology/generic/attributeHandler.h"
#include <stdint.h>
using namespace CGoGN;
namespace CGoGN
struct PFP1 : public PFP_STANDARD
{
typedef EmbeddedMap3 MAP;
};
namespace Algo
{
namespace Volume
{
template bool Algo::Volume::Export::exportMesh<PFP1>(PFP1::MAP& map, const VertexAttribute<PFP1::VEC3, PFP1::MAP>& position, const std::string& filename) ;
namespace Export
int test_exportVol()
{
/**
* 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, typename PFP::MAP>& 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 mesh file
* @return true
*/
template <typename PFP>
bool exportNAS(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename) ;
/**
* export the map into a vtu file (vtk unstructured grid)
* @param the_map map to be exported
* @param position the position container
* @param filename filename of mesh file
* @return true
*/
template <typename PFP>
bool exportVTU(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename) ;
/**
* export the map into a .msh (gmesh file)
* @param the_map map to be exported
* @param position the position container
* @param filename filename of mesh file
* @return true
*/
template <typename PFP>
bool exportMSH(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename) ;
/**
* export the map into a .tet file
* @param the_map map to be exported
* @param position the position container
* @param filename filename of mesh file
* @return true
*/
template <typename PFP>
bool exportTet(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename) ;
/**
* 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 mesh file
* @return true
*/
template <typename PFP>
bool exportNodeEle(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename) ;
/**
* 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 mesh file
*/
template <typename PFP>
bool exportVolBinGz(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename);
/**
* export tetmesh format
* @warning if macro _OPTIMIZED_FOR_TETRA_ONLY_ (before include) is define assume map contain only tetrahedrons
* @param the_map map to be exported
* @param position the position container
* @param filename filename of mesh file
*/
template <typename PFP>
bool exportTetmesh(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename);
template <typename PFP>
bool exportBoundaryOFF(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename);
} // namespace Export
} // namespace Volume
} // namespace Algo
} // namespace CGoGN
#include "Algo/Export/exportVol.hpp"
#endif
return 0;
}
\ No newline at end of file
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
#ifndef __AHEMIMPORTER_H__
#define __AHEMIMPORTER_H__
#include <fstream>
#include "Algo/Import/AHEM.h"
#include "Algo/Import/AHEMImporter.h"
using namespace CGoGN;
namespace CGoGN
{
namespace Algo
{
namespace Import
{
/*
* Actual loaders for attributes
*/
template<typename MapType>
class AttributeImporter
struct PFP1 : public PFP_STANDARD
{
public:
#ifdef _WIN32
virtual ~AttributeImporter() = 0 {}
#else
virtual ~AttributeImporter() {}
#endif
virtual bool Handleable(const AHEMAttributeDescriptor* ad) const = 0;
virtual void ImportAttribute( MapType& map,
const unsigned int* verticesId,
const Dart* facesId,
const AHEMHeader* hdr,
const char* attrName,
const AHEMAttributeDescriptor* ad,
const void* buffer) const = 0;
typedef EmbeddedMap2 MAP;
};
template class Algo::Import::AHEMImporter<PFP1>;
static const unsigned int ATTRIBUTE_NOTFOUND = (unsigned int)-1;
/*
* Importer
*/
template<typename PFP>
class AHEMImporter
struct PFP2 : public PFP_DOUBLE
{
public:
AHEMImporter(bool useDefaultImporters = true);
~AHEMImporter();
bool Open(typename PFP::MAP* m, const char* filename);
void Close();
void LoadMesh();
bool LoadAttribute(unsigned int attrIx, const char* attrName, const AttributeImporter<typename PFP::MAP>* imp);
bool LoadAttribute(const GUID& semantic, const char* attrName = NULL);
void LoadAllAttributes(bool* status = NULL);
// Low-level access to attributes
inline unsigned int GetAttributesNum();
inline void GetAttribute(AHEMAttributeDescriptor** ad, char** attrName, unsigned int ix);
inline unsigned int FindAttribute(const GUID& semantic);
// Attribute importers and helpers
std::vector<AttributeImporter<typename PFP::MAP>*> loadersRegistry;
inline std::vector<AttributeImporter<typename PFP::MAP>*> FindImporters(const GUID& attrSemanticId);
inline std::vector<AttributeImporter<typename PFP::MAP>*> FindImporters(const AHEMAttributeDescriptor* ad);
protected:
void LoadTopology();
void LoadPosition(AHEMAttributeDescriptor* posDescr);
typename PFP::MAP* map;
std::ifstream f;
AHEMHeader hdr;
AHEMAttributeDescriptor* attrDesc;
char** attrNames;
char* buffer;
unsigned int bufferSize;
unsigned int* verticesId;
Dart* facesId;
typedef EmbeddedMap2 MAP;
};
template class Algo::Import::AHEMImporter<PFP2>;
int test_AHEMImporter()
{
} // namespace Import
} // namespace Algo
} // namespace CGoGN
return 0;
}
#include "Algo/Import/AHEMImporter.hpp"
#endif
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009, 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Geometry/matrix.h"
#include "Algo/Import/AHEM.h"
namespace CGoGN
{
namespace Algo
{
#include "Algo/Import/AHEMImporterDefAttr.h"
namespace Import
{
using namespace CGoGN;