Commit ff85b800 authored by untereiner's avatar untereiner

ihm3

parent 2bd9824e
......@@ -62,6 +62,15 @@ void coarsenFace(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
template <typename PFP>
void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/***********************************************************************************
* Raffinement
***********************************************************************************/
/*
* Un brin de la face oppose aux faces a spliter
*/
template <typename PFP>
void splitVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position);
/*******************************************************
*
*/
......
......@@ -173,12 +173,11 @@ Dart subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& positi
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.volumeIsSubdivided(d) || !"Trying to subdivide an already subdivided volume") ;
unsigned int vLevel = map.volumeLevel(d) ;
Dart old = map.volumeOldestDart(d) ;
unsigned int cur = map.getCurrentLevel() ;
map.setCurrentLevel(vLevel) ; // go to the level of the face to subdivide its edges
unsigned int vLevel = map.volumeLevel(d);
Dart old = map.volumeOldestDart(d);
unsigned int cur = map.getCurrentLevel();
map.setCurrentLevel(vLevel);
/*
* au niveau du volume courant i
......@@ -740,10 +739,81 @@ void coarsenVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position
}
/***********************************************************************************
* Raffinement
***********************************************************************************/
template <typename PFP>
void splitVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position)
{
assert(map.getDartLevel(d) <= map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
assert(!map.volumeIsSubdivided(d) || !"Trying to subdivide an already subdivided volume") ;
unsigned int cur = map.getCurrentLevel() ;
unsigned int vLevel = map.volumeLevel(d) ;
map.setCurrentLevel(vLevel) ;
// first cut the edges (if they are not already)
Dart t = d;
do
{
if(!map.edgeIsSubdivided(map.phi1(map.phi2(t))))
Algo::IHM::subdivideEdge<PFP>(map, map.phi1(map.phi2(t)), position) ;
t = map.phi1(t);
}
while(t != d);
unsigned int fLevel = map.faceLevel(map.phi1(d));
map.setCurrentLevel(fLevel+1) ; // go to the level of the face to subdivide its edges
Dart neighboordVolume = map.phi1(map.phi1(map.phi2(d)));
//map.setCurrentLevel(cur) ; // go to the next level to perform volume subdivision
//Split the faces and open the midlle
do
{
Dart t2 = map.phi2(t);
unsigned int fLevel = map.faceLevel(t2) ;
map.setCurrentLevel(fLevel+1) ; // go to the level of the face to subdivide its edges
Dart face2 = map.phi1(map.phi1(t2));
map.splitFace(map.phi_1(t2), face2);
map.unsewFaces(map.phi1(map.phi1(t2)));
//id de face pour les 2 nouveaux brins
unsigned int idface = map.getFaceId(t2);
map.setFaceId(map.phi1(map.phi1(t2)), idface, DART);
map.setFaceId(map.phi_1(face2), idface, DART);
t = map.phi1(t);
}
while(t != d);
//close the middle to create volumes & sew them
map.setCurrentLevel(vLevel + 1) ; // go to the next level to perform volume subdivision
map.closeHole(map.phi1(map.phi1(map.phi2(d))));
map.closeHole(map.phi_1(neighboordVolume));
map.sewVolumes(map.phi2(map.phi1(map.phi1(map.phi2(d)))), map.phi2(map.phi_1(neighboordVolume)));
unsigned int idface = map.getNewFaceId();
map.setFaceId(map.phi2(map.phi_1(neighboordVolume)), idface, FACE);
do
{
Dart t211 = map.phi1(map.phi1(map.phi2(t)));
unsigned int idedge = map.getNewEdgeId();
map.setEdgeId(t211, idedge, EDGE);
t = map.phi1(t);
}
while(t != d);
map.setCurrentLevel(cur) ;
}
/*************************************************************************************
*
*/
template <typename PFP>
void subdivideVolume(typename PFP::MAP& map, Dart d, typename PFP::TVEC3& position, SubdivideType sType)
{
......
......@@ -22,6 +22,19 @@ template <typename PFP>
bool importSVG(typename PFP::MAP& map, const std::string& filename, typename PFP::TVEC3& position, CellMarker& polygons);
/**
*
*/
template <typename PFP>
bool readSVG(const std::string& filename, std::vector<std::vector<typename PFP::VEC3 > > &allPoly);
template <typename PFP>
bool importBB(const std::string& filename, std::vector<Geom::BoundingBox<typename PFP::VEC3> > &bb);
template <typename PFP>
bool importSVG(typename PFP::MAP& map, const std::string& filename, std::vector<std::string>& attrNames);
}
......
This diff is collapsed.
......@@ -71,6 +71,8 @@ class BoundingBox
VEC center() const ;
bool isInitialized() const ;
/**********************************************/
/* FUNCTIONS */
/**********************************************/
......
......@@ -118,6 +118,12 @@ VEC BoundingBox<VEC>::center() const
return center ;
}
template <typename VEC>
bool BoundingBox<VEC>::isInitialized() const
{
return m_initialized;
}
/**********************************************/
/* FUNCTIONS */
/**********************************************/
......
......@@ -138,7 +138,7 @@ public:
unsigned int insert(const T& elt) ;
/**
* insert un element with default value (warning we add here a complete line in container)
* insert an element with default value (warning we add here a complete line in container)
*/
unsigned int newElt() ;
......
......@@ -100,6 +100,9 @@ public:
virtual unsigned int closeHole(Dart d);
virtual void closeMap(DartMarker &marker);
virtual bool check();
} ;
} // namespace CGoGN
......
......@@ -128,8 +128,8 @@ void EmbeddedMap3<MAP3>::splitFace(Dart d, Dart e)
if(MAP3::isOrbitEmbedded(VERTEX))
{
MAP3::copyDartEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(d)), d);
MAP3::copyDartEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(e)), e);
MAP3::copyDartEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(d)), d);
MAP3::copyDartEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(e)), e);
if(MAP3::phi3(d) != d)
{
......@@ -310,4 +310,52 @@ void EmbeddedMap3<MAP3>::closeMap(DartMarker &marker)
}
template <typename MAP3>
bool EmbeddedMap3<MAP3>::check()
{
bool topo = MAP3::check() ;
if (!topo)
return false ;
CGoGNout << "Check: embedding begin" << CGoGNendl ;
for(Dart d = MAP3::begin(); d != MAP3::end(); MAP3::next(d))
{
if (MAP3::isOrbitEmbedded(VERTEX))
{
if (MAP3::phi2(MAP3::phi_1(d)) != MAP3::phi_1(d) && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi2(MAP3::phi_1(d))))
{
CGoGNout << "Check: different embeddings on vertex" << CGoGNendl ;
return false ;
}
if(MAP3::phi3(d) != d && MAP3::getEmbedding(VERTEX, d) != MAP3::getEmbedding(VERTEX, MAP3::phi3(MAP3::phi2(d))))
{
CGoGNout << "Check: different embeddings on vertex in the 2 oriented faces" << CGoGNendl ;
return false ;
}
}
// if (MAP2::isOrbitEmbedded(EDGE))
// {
// if (MAP2::getEmbedding(EDGE, d) != MAP2::getEmbedding(EDGE, MAP2::phi2(d)))
// {
// CGoGNout << "Check: different embeddings on edge" << CGoGNendl ;
// return false ;
// }
// }
//
// if (MAP2::isOrbitEmbedded(FACE))
// {
// if (MAP2::getEmbedding(FACE, d) != MAP2::getEmbedding(FACE, MAP2::phi1(d)))
// {
// CGoGNout << "Check: different embeddings on face" << CGoGNendl ;
// return false ;
// }
// }
}
CGoGNout << "Check: embedding ok" << CGoGNendl ;
return true ;
}
} // namespace CGoGN
......@@ -345,7 +345,7 @@ public:
//@{
// TODO devrait disparaitre
// pour les mêmes raisons que dans map2
//bool check();
bool check();
//@}
};
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* 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 *
* 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.u-strasbg.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "Utils/qtSimple.h"
#include <QtGui/QTextEdit>
namespace CGoGN
{
namespace CGoGNStream
{
template<int LEVEL>
Out<LEVEL>::Out():
m_out_mode(STDOUT),
m_sqt_bar(NULL),
m_sqt_console(NULL),
m_qte(NULL),
m_ofs(NULL),
m_oss(NULL),
m_code(0)
{}
template<int LEVEL>
Out<LEVEL>::~Out()
{
if (LEVEL <= DBG_MAX_LEVEL)
{
if (m_ofs != NULL)
{
m_ofs->close();
delete m_ofs;
}
}
}
template<int LEVEL>
void Out<LEVEL>::toStd(bool yes)
{
if (LEVEL<=DBG_MAX_LEVEL)
{
if (m_code)
{
if (yes)
this->m_out_mode |= STDERR;
else
this->m_out_mode &= ~STDERR;
}
else
{
if (yes)
m_out_mode |= STDOUT;
else
m_out_mode &= ~STDOUT;
}
}
}
//template<int LEVEL>
//void Err<LEVEL>::toStd(bool yes)
//{
// if (LEVEL<=DBG_MAX_LEVEL)
// {
// if (yes)
// this->m_out_mode |= STDERR;
// else
// this->m_out_mode &= ~STDERR;
// }
//}
template<int LEVEL>
void Out<LEVEL>::toFile(const std::string& filename )
{
if (LEVEL <= DBG_MAX_LEVEL)
{
if (!filename.empty())
m_out_mode |= FILEOUT;
else
m_out_mode &= ~FILEOUT;
if (m_ofs != NULL)
{
m_ofs->close();
delete m_ofs;
}
m_ofs = new std::ofstream(filename.c_str());
}
}
template<int LEVEL>
void Out<LEVEL>::toStatusBar(Utils::QT::SimpleQT* sqt)
{
if (LEVEL <= DBG_MAX_LEVEL)
{
if (sqt != NULL)
m_out_mode |= QTSTATUSBAR;
else
m_out_mode &= ~QTSTATUSBAR;
m_sqt_bar = sqt;
}
}
template<int LEVEL>
void Out<LEVEL>::toConsole(Utils::QT::SimpleQT* sqt)
{
if (LEVEL <= DBG_MAX_LEVEL)
{
if (sqt)
m_out_mode |= QTCONSOLE;
else
m_out_mode &= ~QTCONSOLE;
m_sqt_console = sqt;
}
}
template<int LEVEL>
void Out<LEVEL>::toBuffer(std::stringstream* ss)
{
if (LEVEL <= DBG_MAX_LEVEL)
{
if (ss != NULL)
m_out_mode |= SSBUFFER;
else
m_out_mode &= ~SSBUFFER;
m_oss = ss;
}
}
template<int LEVEL>
Out<LEVEL>& Out<LEVEL>::operator<< (Out& os)
{
return *this;
}
template<int LEVEL>
void Out<LEVEL>::close()
{
if (LEVEL <= DBG_MAX_LEVEL)
{
if (m_ofs != NULL)
{
m_ofs->close();
}
}
}
template<int LEVEL>
template <typename T>
Out<LEVEL>& Out<LEVEL>::operator<< (const T& val)
{
if (m_out_mode & STDOUT)
std::cout << val;
if (m_out_mode & STDERR)
std::cerr << val;
if (m_out_mode && (FILEOUT|QTSTATUSBAR|QTCONSOLE|SSBUFFER))
m_buffer << val;
return *this;
}
template<int LEVEL>
Out<LEVEL>& Out<LEVEL>::operator<< (Special& os )
{
if (LEVEL <= DBG_MAX_LEVEL)
{
if (&os == &CGoGNendl)
{
char bufc[512];
// for cout & cerr just do the endl
if (m_out_mode & STDOUT)
std::cout << std::endl;;
if (m_out_mode & STDERR)
std::cerr << std::endl;
if (m_out_mode & FILEOUT)
{
while (! m_buffer.eof())
{
m_buffer.getline(bufc,512);
*m_ofs << bufc << std::endl;
}
}
if (m_out_mode & QTSTATUSBAR)
{
while (! m_buffer.eof())
{
m_buffer.getline(bufc,512);
m_sqt_bar->statusMsg(bufc);
}
}
if (m_out_mode & QTCONSOLE)
{
while (! m_buffer.eof())
{
m_buffer.getline(bufc,512);
if (m_code >= 100)
m_sqt_console->console()->setTextColor(QColor(0, 150 - (m_code-100) * 20, 50 + (m_code-100) * 20));
else
{
if (m_code > 0)
m_sqt_console->console()->setTextColor(QColor(150, 0, 0));
else
m_sqt_console->console()->setTextColor(QColor(0, 0, 150));
}
// m_sqt_console->console()->insertPlainText(QString(bufc));
// m_sqt_console->console()->insertPlainText(QString("\n"));
m_sqt_console->console()->append(QString(bufc));
}
}
if (m_out_mode & SSBUFFER)
{
while (! m_buffer.eof())
{
m_buffer.getline(bufc, 512);
*m_oss << bufc << std::endl;
}
}
}
if (&os == &CGoGNflush)
{
char bufc[512];
// for cout & cerr just do the endl
if (m_out_mode & STDOUT)
std::cout << std::flush;
if (m_out_mode & STDERR)
std::cerr << std::flush;
if (m_out_mode & FILEOUT)
{
while (! m_buffer.eof())
{
m_buffer.getline(bufc,512);
*m_ofs << bufc << std::flush;
}
}
if (m_out_mode & QTSTATUSBAR)
{
while (! m_buffer.eof())
{
m_buffer.getline(bufc,512);
m_sqt_bar->statusMsg(bufc);
}
}
if (m_out_mode & QTCONSOLE)
{
while (! m_buffer.eof())
{
m_buffer.getline(bufc,512);
if (m_code >= 100)
m_sqt_console->console()->setTextColor(QColor(0, 150 - (m_code-100) * 20, 50 + (m_code-100) * 20));
else
{
if (m_code > 0)
m_sqt_console->console()->setTextColor(QColor(150, 0, 0));
else
m_sqt_console->console()->setTextColor(QColor(0, 0, 150));
}
m_sqt_console->console()->moveCursor(QTextCursor::End);
m_sqt_console->console()->insertPlainText(QString(bufc));
}
}
if (m_out_mode & SSBUFFER)
{
while (! m_buffer.eof())
{
m_buffer.getline(bufc, 512);
*m_oss << bufc << std::flush;
}
}
}
}
m_buffer.clear();
return *this;
}
} // namespace CGoGNStream
} // namespace CGoGN
......@@ -144,6 +144,7 @@ unsigned int ImplicitHierarchicalMap3::faceLevel(Dart d)
fLevel = l < fLevel ? l : fLevel ; // of its edges
} while(it != d) ;
unsigned int cur = m_curLevel ;
m_curLevel = fLevel ;
......@@ -171,7 +172,6 @@ unsigned int ImplicitHierarchicalMap3::volumeLevel(Dart d)
{
assert(m_dartLevel[d] <= m_curLevel || !"Access to a dart introduced after current level") ;
//std::cout << "volumeLevel" << std::endl;
if(m_curLevel == 0)
return 0 ;
......
......@@ -1141,66 +1141,74 @@ void Map3::closeMap(DartMarker& marker)
// this->releaseMarker(DART,mf3);
//}
//
//bool Map3::check()
//{
// CGoGNout << "Check: topology begin" << CGoGNendl;
// Marker m = this->getNewMarker();
// for(Dart d = this->begin(); d != this->end(); this->next(d))
// {
// Dart d3 = phi3(d);
// if (phi3(d3) != d) // phi3 involution ?
// {
// CGoGNout << "Check: phi3 is not an involution" << CGoGNendl;
// return false;
// }
//
// Dart d2 = phi2(d);
// if (phi2(d2) != d) // phi2 involution ?
// {
// CGoGNout << "Check: phi2 is not an involution" << CGoGNendl;
// return false;
// }
//
// Dart d1 = phi1(d);
// if (phi_1(d1) != d) // phi1 a une image correcte ?
// {
// CGoGNout << "Check: unconsistent phi_1 link" << CGoGNendl;
// return false;
// }
//
// if (isMarkedDart(d1,m)) // phi1 a un seul antécédent ?
// {
// CGoGNout << "Check: dart with two phi1 predecessors" << CGoGNendl;
// return false;
// }
// markOrbit(DART,d1,m);
//
// if (d1 == d)
// CGoGNout << "Check: (warning) face loop (one edge)" << CGoGNendl;
//
// if (phi1(d1) == d)
// CGoGNout << "Check: (warning) face with only two edges" << CGoGNendl;
//
// if (phi2(d1) == d)
// CGoGNout << "Check: (warning) dandling edge (phi2)" << CGoGNendl;
//
// if (phi3(d1) == d)
// CGoGNout << "Check: (warning) dandling edge (phi3)" << CGoGNendl;
// }
//
// for(Dart d = this->begin(); d != this->end(); this->next(d))
// {
// if (!isMarkedDart(d,m)) // phi1 a au moins un antécédent ?
// {
// CGoGNout << "Check: dart with no phi1 predecessor" << CGoGNendl;
// return false;
// }
// }
// this->unmarkAll(DART,m);
// this->releaseMarker(DART,m);
// CGoGNout << "Check: topology ok" << CGoGNendl;
// return true;
//}
bool Map3::check()
{
CGoGNout << "Check: topology begin" << CGoGNendl;
DartMarker m(*this);
for(Dart d = this->begin(); d != this->end(); this->next(d))
{
Dart d3 = phi3(d);
if (phi3(d3) != d) // phi3 involution ?
{
CGoGNout << "Check: phi3 is not an involution" << CGoGNendl;
return false;
}
if(d3 != d)
{
if(phi1(d3) != phi3(phi_1(d)))
{
CGoGNout << "Check: phi3 , faces are not entirely sewn" << CGoGNendl;
return false;
}
}
Dart d2 = phi2(d);
if (phi2(d2) != d) // phi2 involution ?
{
CGoGNout << "Check: phi2 is not an involution" << CGoGNendl;
return false;
}
Dart d1 = phi1(d);
if (phi_1(d1) != d) // phi1 a une image correcte ?
{
CGoGNout << "Check: unconsistent phi_1 link" << CGoGNendl;
return false;
}
if (m.isMarked(d1)) // phi1 a un seul antécédent ?
{
CGoGNout << "Check: dart with two phi1 predecessors" << CGoGNendl;
return false;
}
m.mark(d1);
if (d1 == d)
CGoGNout << "Check: (warning) face loop (one edge)" << CGoGNendl;
if (phi1(d1) == d)
CGoGNout << "Check: (warning) face with only two edges" << CGoGNendl;
if (phi2(d1) == d)
CGoGNout << "Check: (warning) dandling edge (phi2)" << CGoGNendl;
if (phi3(d1) == d)
CGoGNout << "Check: (warning) dandling edge (phi3)" << CGoGNendl;
}