Commit f3132155 authored by untereiner's avatar untereiner
Browse files

some changes to implicit MR management

parent 10e52114
...@@ -44,8 +44,8 @@ using namespace CGoGN ; ...@@ -44,8 +44,8 @@ using namespace CGoGN ;
*/ */
struct PFP: public PFP_STANDARD struct PFP: public PFP_STANDARD
{ {
// definition of the map // definition of the map
typedef EmbeddedMap2 MAP; typedef EmbeddedMap2 MAP;
}; };
...@@ -56,178 +56,265 @@ VertexAttribute<PFP::VEC3> normal; ...@@ -56,178 +56,265 @@ VertexAttribute<PFP::VEC3> normal;
void MyQT::cb_initGL() void MyQT::cb_initGL()
{ {
Utils::GLSLShader::setCurrentOGLVersion(2); Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render // create the render
m_render = new Algo::Render::GL2::MapRender(); m_render = new Algo::Render::GL2::MapRender();
// create VBO for position // create VBO for position
m_positionVBO = new Utils::VBO(); m_positionVBO = new Utils::VBO();
m_positionVBO->updateData(position); m_positionVBO->updateData(position);
m_normalVBO = new Utils::VBO(); m_normalVBO = new Utils::VBO();
m_shader = new Utils::ShaderSimpleColor(); m_shader = new Utils::ShaderSimpleColor();
m_shader->setAttributePosition(m_positionVBO); m_shader->setAttributePosition(m_positionVBO);
m_shader->setColor(Geom::Vec4f(1.,1.,0.,0.)); m_shader->setColor(Geom::Vec4f(1.,1.,0.,0.));
m_lines = new Utils::ShaderVectorPerVertex(); m_lines = new Utils::ShaderVectorPerVertex();
m_lines->setAttributePosition(m_positionVBO); m_lines->setAttributePosition(m_positionVBO);
m_lines->setAttributeVector(m_normalVBO); m_lines->setAttributeVector(m_normalVBO);
m_lines->setScale(0.2f); m_lines->setScale(0.2f);
m_lines->setColor(Geom::Vec4f(0.0f, 1.0f, 0.2f, 0.0f)); m_lines->setColor(Geom::Vec4f(0.0f, 1.0f, 0.2f, 0.0f));
Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ; Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES); m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::LINES);
m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::POINTS); m_render->initPrimitives<PFP>(myMap, Algo::Render::GL2::POINTS);
registerShader(m_shader); registerShader(m_shader);
registerShader(m_lines); registerShader(m_lines);
m_normalVBO->updateData(normal); m_normalVBO->updateData(normal);
} }
void MyQT::cb_redraw() void MyQT::cb_redraw()
{ {
m_render->draw(m_shader, Algo::Render::GL2::LINES); m_render->draw(m_shader, Algo::Render::GL2::LINES);
m_render->draw(m_lines, Algo::Render::GL2::POINTS); m_render->draw(m_lines, Algo::Render::GL2::POINTS);
}
void MyQT::squareTiling(int code)
{
switch(code)
{
case 1:
{
std::cout << "square grid tiling" << std::endl;
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
g.embedIntoGrid(position,50,50);
break;
}
case 2:
{
std::cout << "square grid twisted strip tiling" << std::endl;
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
g.embedIntoTwistedStrip(position, 0.3, 0.8, 5);
break;
}
case 3:
{
std::cout << "square grid helocoid tiling" << std::endl;
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,20,20,true);
g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0);
break;
}
case 4:
{
std::cout << "square cylinder tiling" << std::endl;
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 5:
{
std::cout << "square cylinder tiling" << std::endl;
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.triangleBottom();
c.triangleTop();
c.embedIntoCylinder(position,0.5,0.7,5.0);
break;
}
case 6:
{
std::cout << "square cylinder sphere tiling" << std::endl;
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.triangleTop();
c.triangleBottom();
c.embedIntoSphere(position,0.5);
break;
}
case 7:
{
std::cout << "square cylinder cone tiling" << std::endl;
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.triangleTop();
c.triangleBottom();
c.embedIntoCone(position,0.5, 5.0);
break;
}
case 8:
{
std::cout << "square cylinder cone tiling" << std::endl;
Algo::Surface::Tilings::Square::Cube<PFP> c(myMap,20,20,20);
c.embedIntoCube(position,5.0,5.0, 5.0);
break;
}
case 9:
{
std::cout << "square cylinder cone tiling" << std::endl;
Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
c.embedIntoTore(position,5.0,2.0);
break;
}
default:
{
break;
}
}
} }
// mouse picking // mouse picking
void MyQT::tiling(int code) void MyQT::triangularTiling(int code)
{ {
//myMap.clear(false); switch(code)
{
switch(code) case 1:
{ {
case 1: std::cout << "square grid tiling" << std::endl;
{ Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,10,10,true);
std::cout << "square grid tiling" << std::endl; g.embedIntoGrid(position,50,50);
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
g.embedIntoGrid(position,50,50); break;
}
break; case 2:
} {
case 2: // std::cout << "square grid twisted strip tiling" << std::endl;
{ // Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
std::cout << "square grid twisted strip tiling" << std::endl; // g.embedIntoTwistedStrip(position, 0.3, 0.8, 5);
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
g.embedIntoTwistedStrip(position, 0.3, 0.8, 5); break;
}
break; case 3:
} {
case 3: // std::cout << "square grid helocoid tiling" << std::endl;
{ // Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,20,20,true);
std::cout << "square grid helocoid tiling" << std::endl; // g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0);
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,20,20,true);
g.embedIntoHelicoid(position, 0.3, 0.8, 5.0, 2.0); break;
}
break; case 4:
} {
case 4: // std::cout << "square cylinder tiling" << std::endl;
{ // Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
std::cout << "square cylinder tiling" << std::endl; // c.embedIntoCylinder(position,0.5,0.7,5.0);
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.embedIntoCylinder(position,0.5,0.7,5.0); break;
}
break; case 5:
} {
case 5: // std::cout << "square cylinder tiling" << std::endl;
{ // Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
std::cout << "square cylinder tiling" << std::endl; // c.triangleBottom();
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20); // c.triangleTop();
c.triangleBottom(); // c.embedIntoCylinder(position,0.5,0.7,5.0);
c.triangleTop();
c.embedIntoCylinder(position,0.5,0.7,5.0); break;
}
break; case 6:
} {
case 6: // std::cout << "square cylinder sphere tiling" << std::endl;
{ // Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
std::cout << "square cylinder sphere tiling" << std::endl; // c.triangleTop();
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20); // c.triangleBottom();
c.triangleTop(); // c.embedIntoSphere(position,0.5);
c.triangleBottom();
c.embedIntoSphere(position,0.5); break;
}
break; case 7:
} {
case 7: // std::cout << "square cylinder cone tiling" << std::endl;
{ // Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
std::cout << "square cylinder cone tiling" << std::endl; // c.triangleTop();
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20); // c.triangleBottom();
c.triangleTop(); // c.embedIntoCone(position,0.5, 5.0);
c.triangleBottom();
c.embedIntoCone(position,0.5, 5.0); break;
}
break; case 8:
} {
case 8: // std::cout << "square cylinder cone tiling" << std::endl;
{ // Algo::Surface::Tilings::Square::Cube<PFP> c(myMap,20,20,20);
std::cout << "square cylinder cone tiling" << std::endl; // c.embedIntoCube(position,5.0,5.0, 5.0);
Algo::Surface::Tilings::Square::Cube<PFP> c(myMap,20,20,20);
c.embedIntoCube(position,5.0,5.0, 5.0); break;
}
break; case 9:
} {
case 9: // std::cout << "square cylinder cone tiling" << std::endl;
{ // Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
std::cout << "square cylinder cone tiling" << std::endl; // c.embedIntoTore(position,5.0,2.0);
Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
c.embedIntoTore(position,5.0,2.0); break;
}
break;
} default:
{
default: break;
{ }
break; }
}
}
// m_positionVBO->updateData(position);
// m_lines->setAttributePosition(m_positionVBO);
// updateGL();
} }
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
// interface: // interface:
QApplication app(argc, argv); QApplication app(argc, argv);
MyQT sqt; MyQT sqt;
sqt.statusMsg("Neww to create a sphere or Load for a mesh file"); sqt.statusMsg("Neww to create a sphere or Load for a mesh file");
CGoGNStream::allToConsole(&sqt); CGoGNStream::allToConsole(&sqt);
if (!position.isValid()) if (!position.isValid())
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position"); position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
if (!normal.isValid()) if (!normal.isValid())
normal = myMap.addAttribute<PFP::VEC3, VERTEX>("normal"); normal = myMap.addAttribute<PFP::VEC3, VERTEX>("normal");
if(argc == 2) if(argc == 3)
{ {
sqt.tiling(atoi(argv[1])); if(argv[1][0] == 'S')
} sqt.squareTiling(atoi(argv[2]));
else if(argv[1][0] == 'T')
sqt.triangularTiling(atoi(argv[2]));
}
// bounding box // bounding box
Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position); Geom::BoundingBox<PFP::VEC3> bb = Algo::Geometry::computeBoundingBox<PFP>(myMap, position);
float lWidthObj = std::max<PFP::REAL>(std::max<PFP::REAL>(bb.size(0), bb.size(1)), bb.size(2)); float lWidthObj = std::max<PFP::REAL>(std::max<PFP::REAL>(bb.size(0), bb.size(1)), bb.size(2));
Geom::Vec3f lPosObj = (bb.min() + bb.max()) / PFP::REAL(2); Geom::Vec3f lPosObj = (bb.min() + bb.max()) / PFP::REAL(2);
CGoGNout << "lPosObj=" << lPosObj << CGoGNendl; CGoGNout << "lPosObj=" << lPosObj << CGoGNendl;
CGoGNout << "lWidthObj=" << lWidthObj << CGoGNendl; CGoGNout << "lWidthObj=" << lWidthObj << CGoGNendl;
sqt.setParamObject(lWidthObj,lPosObj.data()); sqt.setParamObject(lWidthObj,lPosObj.data());
// myMap.enableQuickTraversal<EDGE>() ; // myMap.enableQuickTraversal<EDGE>() ;
// myMap.enableQuickTraversal<VERTEX>() ; // myMap.enableQuickTraversal<VERTEX>() ;
sqt.show(); sqt.show();
return app.exec(); return app.exec();
} }
...@@ -37,15 +37,34 @@ namespace Surface ...@@ -37,15 +37,34 @@ namespace Surface
namespace Geometry namespace Geometry
{ {
//! \brief Compute triangle area
//! @param map
//! @param d
//! @param position
//! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ; typename PFP::REAL triangleArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
//! \brief Compute convex polygonal face area
//! @param map
//! @param d
//! @param position
//! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ; typename PFP::REAL convexFaceArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
//! \brief Compute the total area of a mesh by summing all face areas.
//! @param map
//! @param position
//! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, unsigned int thread = 0) ; typename PFP::REAL totalArea(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, unsigned int thread = 0) ;
//! \brief Compute the area of the faces around a vertex.
//! @param map
//! @param d
//! @param position
//! @return
template <typename PFP> template <typename PFP>
typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ; typename PFP::REAL vertexOneRingArea(typename PFP::MAP& map, Dart d, const VertexAttribute<typename PFP::VEC3>& position) ;
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#ifndef __MAP2MR_PRIMAL_ADAPT__ #ifndef __MAP2MR_PRIMAL_ADAPT__
#define __MAP2MR_PRIMAL_ADAPT__ #define __MAP2MR_PRIMAL_ADAPT__
#include "Topology/map/embeddedMap2.h" #include "Topology/ihmap/ihm2.h"
#include "Topology/generic/traversorCell.h" #include "Topology/generic/traversorCell.h"
#include "Topology/generic/traversor2.h" #include "Topology/generic/traversor2.h"
...@@ -52,8 +52,6 @@ class IHM2 ...@@ -52,8 +52,6 @@ class IHM2
public: public:
typedef typename PFP::MAP MAP ; typedef typename PFP::MAP MAP ;
typedef typename PFP::VEC3 VEC3 ;
typedef typename PFP::REAL REAL ;
protected: protected:
MAP& m_map; MAP& m_map;
...@@ -67,6 +65,59 @@ public: ...@@ -67,6 +65,59 @@ public:
IHM2(MAP& map) ; IHM2(MAP& map) ;
/***************************************************
* CELLS INFORMATION *
***************************************************/
/**
* Return the level of the edge of d in the current level map
*/
unsigned int edgeLevel(Dart d) ;
/**
* Return the level of the face of d in the current level map
*/
unsigned int faceLevel(Dart d) ;
/**
* Given the face of d in the current level map,
* return a level 0 dart of its origin face
*/
Dart faceOrigin(Dart d) ;
/**
* Return the oldest dart of the face of d in the current level map
*/
Dart faceOldestDart(Dart d) ;
/**
* Return true if the edge of d in the current level map
* has already been subdivided to the next level
*/
bool edgeIsSubdivided(Dart d) ;
/**
* Return true if the edge of d in the current level map
* is subdivided to the next level,
* none of its resulting edges is in turn subdivided to the next level
* and the middle vertex is of degree 2
*/
bool edgeCanBeCoarsened(Dart d) ;
/**
* Return true if the face of d in the current level map
* has already been subdivided to the next level
*/
bool faceIsSubdivided(Dart d) ;
/**
* Return true if the face of d in the current level map
* is subdivided to the next level
* and none of its resulting faces is in turn subdivided to the next level
*/
bool faceIsSubdividedOnce(Dart d) ;
protected: protected:
/*************************************************** /***************************************************
* SUBDIVISION * * SUBDIVISION *
...@@ -88,11 +139,6 @@ public: ...@@ -88,11 +139,6 @@ public:
*/ */
unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true); unsigned int subdivideFace(Dart d, bool triQuad = true, bool OneLevelDifference = true);
/**
*
*/
unsigned int subdivideFaceSqrt3(Dart d);
/** /**
* coarsen the face of d from the next level * coarsen the face of d from the next level
*/ */
......
...@@ -50,25 +50,276 @@ IHM2<PFP>::IHM2(typename PFP::MAP& map) : ...@@ -50,25 +50,276 @@ IHM2<PFP>::IHM2(typename PFP::MAP& map) :
} }
/***************************************************
* CELLS INFORMATION *
***************************************************/
template <typename PFP>
unsigned int IHM2<PFP>::edgeLevel(Dart d)
{
assert(m_map.getDartLevel(d) <= m_map.getCurrentLevel() || !"Access to a dart introduced after current level") ;
unsigned int ld = m_map.getDartLevel(d);
// unsigned int ldd = m_dartLevel[phi2(d)] ; // the level of an edge is the maximum of the
unsigned int ldd = m_map.getDartLevel(m_map.phi1(d));
return ld < ldd ? ldd : ld ;
}
template <typename PFP>
unsigned int IHM2<PFP>::faceLevel(Dart d)
{
assert(m_map.getDartLevel(<