Commit a0a2dc32 authored by Lionel Untereiner's avatar Lionel Untereiner

old fashioned IHM3 are back

parent 652fa86d
......@@ -31,7 +31,7 @@ Viewer::Viewer() :
m_drawFaces(true),
m_drawNormals(false),
m_drawTopo(false),
m_drawBoundaryTopo(true),
m_drawBoundaryTopo(false),
m_render(NULL),
m_phongShader(NULL),
m_flatShader(NULL),
......@@ -87,7 +87,7 @@ void Viewer::cb_initGL()
m_render = new Algo::Render::GL2::MapRender() ;
m_topoRender = new Algo::Render::GL2::TopoRender() ;
m_topoRender->setInitialDartsColor(0.25f, 0.25f, 0.25f) ;
m_topoRender->setInitialDartsColor(1.0f, 1.00f, 1.00f) ;
m_positionVBO = new Utils::VBO() ;
m_normalVBO = new Utils::VBO() ;
......@@ -552,11 +552,14 @@ void Viewer::importMesh(std::string& filename)
// myMap.enableQuickTraversal<VERTEX>() ;
std::cout << "The mesh is " << (myMap.isOpen() ? "open" : "closed") << std::endl;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::POINTS) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::TRIANGLES) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo) ;
m_topoRender->updateData<PFP>(myMap, position, 0.85f, 0.85f, m_drawBoundaryTopo, true) ;
bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position) ;
normalBaseSize = bb.diagSize() / 100.0f ;
......
......@@ -248,7 +248,7 @@ void MyQT::cb_redraw()
if(!m_selecteds.empty())
{
for(std::vector<Dart>::iterator it = m_selecteds.begin() ; it != m_selecteds.end() ; ++it)
m_render_topo->overdrawDart(*it, 11, 0.0f, 0.0f, 1.0f);
m_render_topo->overdrawDart(myMap, *it, 11, 0.0f, 0.0f, 1.0f);
}
m_render_topo->overdrawDart(myMap, m_selected2, 11, 0.0f, 1.0f, 0.0f);
......
# all build directory ignored !
*
# all build directory ignored !
*
......@@ -69,6 +69,7 @@ SET (COMMON_LIBS
${LIBXML2_LIBRARIES}
${Boost_SYSTEM_LIBRARY}
${Boost_REGEX_LIBRARY}
tinyxml2
)
IF(WIN32)
......
#ignore all build directory
*
#ignore all build directory
*
......@@ -125,6 +125,9 @@ 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
......
......@@ -853,6 +853,81 @@ bool exportMesh(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3
}
}
template <typename PFP>
bool exportBoundaryOFF(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, const char* filename)
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
std::ofstream out(filename, std::ios::out) ;
if (!out.good())
{
CGoGNerr << "Unable to open file " << CGoGNendl ;
return false ;
}
unsigned int nbDarts = map.getNbDarts() ;
std::vector<unsigned int> facesSize ;
std::vector<std::vector<unsigned int> > facesIdx ;
facesSize.reserve(nbDarts/3) ;
facesIdx.reserve(nbDarts/3) ;
std::map<unsigned int, unsigned int> vIndex ;
unsigned int vCpt = 0 ;
std::vector<unsigned int> vertices ;
vertices.reserve(nbDarts/6) ;
CellMarker<typename PFP::MAP,VERTEX> markV(map) ;
TraversorF<MAP> t(map) ;
for(Dart d = t.begin(); d != t.end(); d = t.next())
{
if(map.isBoundaryFace(d))
{
Dart db = d;
if(!map.template isBoundaryMarked<3>(db))
db = map.phi3(db);
std::vector<unsigned int> fidx ;
fidx.reserve(8) ;
unsigned int degree = 0 ;
Traversor2FV<typename PFP::MAP> tfv(map, db) ;
for(Dart it = tfv.begin(); it != tfv.end(); it = tfv.next())
{
++degree ;
unsigned int vNum = map.template getEmbedding<VERTEX>(it) ;
if(!markV.isMarked(it))
{
markV.mark(it) ;
vIndex[vNum] = vCpt++ ;
vertices.push_back(vNum) ;
}
fidx.push_back(vIndex[vNum]) ;
}
facesSize.push_back(degree) ;
facesIdx.push_back(fidx) ;
}
}
out << "OFF" << std::endl ;
out << vertices.size() << " " << facesSize.size() << " " << 0 << std::endl ;
for(unsigned int i = 0; i < vertices.size(); ++i)
{
const VEC3& v = position[vertices[i]] ;
out << v[0] << " " << v[1] << " " << v[2] << std::endl ;
}
for(unsigned int i = 0; i < facesSize.size(); ++i)
{
out << facesSize[i] ;
for(unsigned int j = 0; j < facesIdx[i].size(); ++j)
out << " " << facesIdx[i][j] ;
out << std::endl ;
}
out.close() ;
return true ;
}
} // namespace Export
} // namespace Volume
......
......@@ -57,9 +57,9 @@ public:
unsigned int m_edgeIdCount ;
unsigned int m_faceIdCount;
DartAttribute<unsigned int, ImplicitHierarchicalMap3> m_dartLevel ;
DartAttribute<unsigned int, ImplicitHierarchicalMap3> m_edgeId ;
DartAttribute<unsigned int, ImplicitHierarchicalMap3> m_faceId ;
DartAttribute<unsigned int, EmbeddedMap3> m_dartLevel ;
DartAttribute<unsigned int, EmbeddedMap3> m_edgeId ;
DartAttribute<unsigned int, EmbeddedMap3> m_faceId ;
AttributeMultiVector<unsigned int>* m_nextLevelCell[NB_ORBITS] ;
......@@ -100,15 +100,15 @@ public:
/*!
*
*/
template <typename T, unsigned int ORBIT>
AttributeHandler_IHM<T, ORBIT> addAttribute(const std::string& nameAttr) ;
// template <typename T, unsigned int ORBIT>
// AttributeHandler_IHM<T, ORBIT> addAttribute(const std::string& nameAttr) ;
//!
/*!
*
*/
template <typename T, unsigned int ORBIT>
AttributeHandler_IHM<T, ORBIT> getAttribute(const std::string& nameAttr) ;
// template <typename T, unsigned int ORBIT>
// AttributeHandler_IHM<T, ORBIT> getAttribute(const std::string& nameAttr) ;
//@}
/*! @name Basic Topological Operators
......@@ -419,8 +419,8 @@ public:
void foreach_dart_of_cc(Dart d, FUNC& f) const ;
//@}
template <unsigned int ORBIT>
unsigned int getEmbedding(Cell<ORBIT> c) const;
// template <unsigned int ORBIT>
// unsigned int getEmbedding(Cell<ORBIT> c) const;
} ;
template <typename T, unsigned int ORBIT>
......
......@@ -37,7 +37,7 @@ namespace IHM
/***************************************************
* ATTRIBUTES MANAGEMENT *
***************************************************/
/*
template <typename T, unsigned int ORBIT>
AttributeHandler_IHM<T, ORBIT> ImplicitHierarchicalMap3::addAttribute(const std::string& nameAttr)
{
......@@ -65,13 +65,13 @@ AttributeHandler_IHM<T, ORBIT> ImplicitHierarchicalMap3::getAttribute(const std:
AttributeHandler<T, ORBIT, ImplicitHierarchicalMap3> h = Map3::getAttribute<T, ORBIT, ImplicitHierarchicalMap3>(nameAttr) ;
return AttributeHandler_IHM<T, ORBIT>(this, h.getDataVector()) ;
}
*/
inline void ImplicitHierarchicalMap3::update_topo_shortcuts()
{
// Map3::update_topo_shortcuts();
m_dartLevel = Map3::getAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("dartLevel") ;
m_faceId = Map3::getAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("faceId") ;
m_edgeId = Map3::getAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("edgeId") ;
m_dartLevel = Map3::getAttribute<unsigned int, DART, EmbeddedMap3>("dartLevel") ;
m_faceId = Map3::getAttribute<unsigned int, DART, EmbeddedMap3>("faceId") ;
m_edgeId = Map3::getAttribute<unsigned int, DART, EmbeddedMap3>("edgeId") ;
//AttributeContainer& cont = m_attribs[DART] ;
//m_nextLevelCell = cont.getDataVector<unsigned int>(cont.getAttributeIndex("nextLevelCell")) ;
......@@ -638,6 +638,7 @@ inline unsigned int ImplicitHierarchicalMap3::edgeLevel(Dart d)
return r;
}
/*
template <unsigned int ORBIT>
inline unsigned int ImplicitHierarchicalMap3::getEmbedding(Cell<ORBIT> c) const
{
......@@ -655,7 +656,7 @@ inline unsigned int ImplicitHierarchicalMap3::getEmbedding(Cell<ORBIT> c) const
}
return index;
}
}*/
inline bool ImplicitHierarchicalMap3::isWellEmbedded()
{
......
......@@ -48,7 +48,7 @@ enum SubdivideType
template <typename PFP>
void newLevelHexa(typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
void newLevelHexa(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
/***********************************************************************************
......@@ -56,13 +56,13 @@ void newLevelHexa(typename PFP::MAP& map, AttributeHandler<typename PFP::VEC3, V
***********************************************************************************/
template <typename PFP>
void subdivideEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position) ;
void subdivideEdge(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position) ;
template <typename PFP>
void subdivideFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType = S_TRI);
void subdivideFace(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, SubdivideType sType = S_TRI);
template <typename PFP>
Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
......@@ -72,13 +72,13 @@ Dart subdivideVolumeClassic(typename PFP::MAP& map, Dart d, AttributeHandler<typ
template <typename PFP>
void subdivideEdgeWrong(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position) ;
void subdivideEdgeWrong(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position) ;
template <typename PFP>
void subdivideFaceWrong(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType = S_TRI);
void subdivideFaceWrong(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, SubdivideType sType = S_TRI);
template <typename PFP>
Dart subdivideVolumeClassicWrong(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
Dart subdivideVolumeClassicWrong(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
......@@ -89,23 +89,23 @@ Dart subdivideVolumeClassicWrong(typename PFP::MAP& map, Dart d, AttributeHandle
template <typename PFP>
Dart subdivideVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
Dart subdivideVolume(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
template <typename PFP>
Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
Dart subdivideVolumeGen(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
template <typename PFP>
Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
Dart subdivideVolumeClassic2(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
template <typename PFP>
void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
void subdivideLoop(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
/***********************************************************************************
......@@ -113,13 +113,13 @@ void subdivideLoop(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
***********************************************************************************/
template <typename PFP>
void coarsenEdge(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
void coarsenEdge(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
template <typename PFP>
void coarsenFace(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position, SubdivideType sType = S_TRI);
void coarsenFace(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position, SubdivideType sType = S_TRI);
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
void coarsenVolume(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
/***********************************************************************************
* Raffinement
......@@ -128,7 +128,7 @@ void coarsenVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP
* Un brin de la face oppose aux faces a spliter
*/
template <typename PFP>
void splitVolume(typename PFP::MAP& map, Dart d, AttributeHandler<typename PFP::VEC3, VERTEX>& position);
void splitVolume(typename PFP::MAP& map, Dart d, VertexAttribute<typename PFP::VEC3, typename PFP::MAP>& position);
......
......@@ -182,6 +182,19 @@ bool importVoxellisation(typename PFP::MAP& map, Algo::Surface::Modelisation::Vo
return importMesh<PFP>(map, mts);
}
template <typename PFP2, typename PFP3>
bool import3DMap(typename PFP2::MAP& map2, typename PFP3::MAP& map3, std::vector<std::string>& attrNames, bool mergeCloseVertices)
{
MeshTablesSurface<PFP2> mts(map2);
if(!mts.template import3DMap<PFP3>(map3, attrNames))
return false;
if(mergeCloseVertices)
mts.mergeCloseVertices();
return importMesh<PFP2>(map2, mts);
}
template <typename PFP>
bool importMeshSAsV(typename PFP::MAP& map, MeshTablesSurface<PFP>& mts)
......
......@@ -133,6 +133,10 @@ public:
bool importPlySLFgenericBin(const std::string& filename, std::vector<std::string>& attrNames);
template <typename PFP3>
bool import3DMap(typename PFP3::MAP& map, std::vector<std::string>& attrNames);
MeshTablesSurface(MAP& map):
m_map(map)
{ }
......
......@@ -381,6 +381,92 @@ bool MeshTablesSurface<PFP>::importVoxellisation(Algo::Surface::Modelisation::Vo
return true;
}
template <typename PFP>
template <typename PFP3>
bool MeshTablesSurface<PFP>::import3DMap(typename PFP3::MAP& map, std::vector<std::string>& attrNames)
{
VertexAttribute<VEC3, MAP> positions = m_map.template getAttribute<VEC3, VERTEX, MAP>("position") ;
VertexAttribute<VEC3, typename PFP3::MAP> position_from = map.template getAttribute<VEC3, VERTEX, typename PFP3::MAP>("position") ;
if (!positions.isValid())
positions = m_map.template addAttribute<VEC3, VERTEX, MAP>("position") ;
attrNames.push_back(positions.name()) ;
AttributeContainer& container = m_map.template getAttributeContainer<VERTEX>() ;
// lecture des nombres de sommets / faces du bord
m_nbVertices = 0;
foreach_cell<VERTEX>(map, [&] (Vertex v)
{
if(map.isBoundaryVertex(v.dart))
++m_nbVertices;
}, FORCE_DART_MARKING);
std::cout << "nbVertices = " << m_nbVertices << std::endl;
m_nbFaces = 0;
foreach_cell<FACE>(map, [&] (Face f)
{
if(map.isBoundaryFace(f.dart))
++m_nbFaces;
}, FORCE_DART_MARKING);
std::cout << "m_nbFaces = " << m_nbFaces << std::endl;
// std::vector<unsigned int> verticesID;
// verticesID.reserve(m_nbVertices);
// //parcours des sommets de la 3-carte
// foreach_cell<VERTEX>(map, [&] (Vertex v)
// {
// //si c'est un sommet du bord
// if(map.isBoundaryVertex(v.dart))
// {
// // insert une nouvelle ligne dans le container
// unsigned int id = container.insertLine();
// // copie de la position
// positions[id] = position_from[id];
// // push_back
// verticesID.push_back(id);
// }
// }, FORCE_DART_MARKING);
// //parcours des faces de la 3-carte
// // normalement nbVertices*8 devrait suffire largement
// m_nbEdges.reserve(m_nbFaces);
// m_emb.reserve(m_nbVertices*8);
// foreach_cell<FACE>(map, [&] (Face f)
// {
// if(map.isBoundaryFace(f.dart))
// {
// Dart d = f.dart;
// if(!map.template isBoundaryMarked<3>(d))
// d = map.phi3(d);
// Dart dit = d;
// do
// {
// unsigned int index ; // index of embedding
// index = map.getEmbedding(Vertex(d));
// m_emb.push_back(verticesID[index]) ;
// dit = map.phi1(dit);
// }while(dit != d);
// }
// }, FORCE_DART_MARKING);
return true;
}
template<typename PFP>
bool MeshTablesSurface<PFP>::importMeshBin(const std::string& filename, std::vector<std::string>& attrNames)
{
......
......@@ -26,7 +26,7 @@
#define __TRAVERSOR2_CLOSED_H__
#include "Topology/generic/dart.h"
#include "Topology/generic/traversorGen.h"
#include "Topology/generic/traversor/traversorGen.h"
namespace CGoGN
{
......@@ -255,6 +255,6 @@ public:
} // namespace CGoGN
#include "Topology/generic/traversor2_closed.hpp"
#include "Topology/generic/traversor/traversor2_closed.hpp"
#endif
......@@ -430,6 +430,12 @@ public:
*/
bool isTriangular() const;
/**
* @brief isOpen check if the mesh is open or not
* @return a boolean indicating the mesh is open
*/
bool isOpen() const;
// TODO a mettre en algo
/**
* Check if map is complete
......
......@@ -960,6 +960,24 @@ bool Map2<MAP_IMPL>::isTriangular() const
return tri;
}
template <typename MAP_IMPL>
bool Map2<MAP_IMPL>::isOpen() const
{
bool open = false;
for(Dart d = Map2::begin(); d != Map2::end(); Map2::next(d))
{
if(this->template isBoundaryMarked<2>(d))
{
open = true;
return open;
}
}
return open;
}
template <typename MAP_IMPL>
bool Map2<MAP_IMPL>::check() const
{
......
......@@ -976,7 +976,7 @@ bool Map3<MAP_IMPL>::isBoundaryVertex(Dart d) const
for(unsigned int i = 0; i < darts.size(); ++i)
{
if(this->isBoundaryMarked3(darts[i]))
if(this->template isBoundaryMarked<3>(darts[i]))
return true ;
//add phi21 and phi23 successor if they are not marked yet
......
......@@ -41,9 +41,9 @@ namespace IHM
ImplicitHierarchicalMap3::ImplicitHierarchicalMap3() : m_curLevel(0), m_maxLevel(0), m_edgeIdCount(0), m_faceIdCount(0)
{
m_dartLevel = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("dartLevel") ;
m_edgeId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("edgeId") ;
m_faceId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("faceId") ;
m_dartLevel = Map3::addAttribute<unsigned int, DART, EmbeddedMap3>("dartLevel") ;
m_edgeId = Map3::addAttribute<unsigned int, DART, EmbeddedMap3>("edgeId") ;
m_faceId = Map3::addAttribute<unsigned int, DART, EmbeddedMap3>("faceId") ;
for(unsigned int i = 0; i < NB_ORBITS; ++i)
m_nextLevelCell[i] = NULL ;
......@@ -61,9 +61,9 @@ void ImplicitHierarchicalMap3::clear(bool removeAttrib)
Map3::clear(removeAttrib) ;
if (removeAttrib)
{
m_dartLevel = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("dartLevel") ;
m_faceId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("faceId") ;
m_edgeId = Map3::addAttribute<unsigned int, DART, ImplicitHierarchicalMap3>("edgeId") ;
m_dartLevel = Map3::addAttribute<unsigned int, DART, EmbeddedMap3>("dartLevel") ;
m_faceId = Map3::addAttribute<unsigned int, DART, EmbeddedMap3>("faceId") ;
m_edgeId = Map3::addAttribute<unsigned int, DART, EmbeddedMap3>("edgeId") ;
for(unsigned int i = 0; i < NB_ORBITS; ++i)
m_nextLevelCell[i] = NULL ;
......
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