Commit 492e71b3 authored by untereiner's avatar untereiner

Adding volume Regular tilings

Cubic tiling ok
parent 0bd11b96
...@@ -1114,10 +1114,10 @@ int main(int argc, char** argv) ...@@ -1114,10 +1114,10 @@ int main(int argc, char** argv)
} }
else else
{ {
sqt.position = sqt.myMap.addAttribute<PFP::VEC3, VERTEX>("position"); sqt.position = sqt.myMap.addAttribute<PFP::VEC3, VERTEX>("position");
Algo::Volume::Modelisation::Primitive3D<PFP> prim(sqt.myMap, sqt.position);
prim.hexaGrid_topo(10,10,10); Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(sqt.myMap, 10,10,10);
prim.embedHexaGrid(1.0f,1.0f,1.0f); cubic.embedIntoGrid(sqt.position, 1.0f, 1.0f, 1.0f);
} }
sqt.initGUI(); sqt.initGUI();
......
...@@ -57,7 +57,7 @@ ...@@ -57,7 +57,7 @@
#include "Utils/cgognStream.h" #include "Utils/cgognStream.h"
#include "Utils/drawer.h" #include "Utils/drawer.h"
#include "Algo/Modelisation/primitives3d.h" #include "Algo/Tiling/Volume/cubic.h"
#include <string> #include <string>
#include <sstream> #include <sstream>
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "simpleGMap3.h" #include "simpleGMap3.h"
#include "Utils/GLSLShader.h" #include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/primitives3d.h" #include "Algo/Tiling/Volume/cubic.h"
#include "Algo/Modelisation/subdivision3.h" #include "Algo/Modelisation/subdivision3.h"
SimpleGMap3::SimpleGMap3() SimpleGMap3::SimpleGMap3()
...@@ -35,22 +35,21 @@ SimpleGMap3::SimpleGMap3() ...@@ -35,22 +35,21 @@ SimpleGMap3::SimpleGMap3()
// CellMarker<EDGE> mE(myMap); // CellMarker<EDGE> mE(myMap);
Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap,position); Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, 1, 1, 1);
Dart d = primCat.hexaGrid_topo(1,1,1); cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
primCat.embedHexaGrid(1,1,1);
myMap.check(); myMap.check();
Dart dp = Algo::Surface::Modelisation::createQuadrangularPyramid<PFP>(myMap); // Dart dp = Algo::Surface::Modelisation::createQuadrangularPyramid<PFP>(myMap);
position[dp] = typename PFP::VEC3(0.5,0.5,-0.5); // position[dp] = typename PFP::VEC3(0.5,0.5,-0.5);
position[myMap.phi1(dp)] = typename PFP::VEC3(0.5,0.5,0.5); // position[myMap.phi1(dp)] = typename PFP::VEC3(0.5,0.5,0.5);
position[myMap.phi1(myMap.phi1(dp))] = typename PFP::VEC3(0.5,-0.5,0.5); // position[myMap.phi1(myMap.phi1(dp))] = typename PFP::VEC3(0.5,-0.5,0.5);
position[myMap.phi_1(dp)] = typename PFP::VEC3(0.5,-0.5,-0.5); // position[myMap.phi_1(dp)] = typename PFP::VEC3(0.5,-0.5,-0.5);
position[myMap.phi_1(myMap.phi2(dp))] = typename PFP::VEC3(1.5f, 0.0f, 0.0f); // position[myMap.phi_1(myMap.phi2(dp))] = typename PFP::VEC3(1.5f, 0.0f, 0.0f);
Dart dtemp = myMap.beta1(myMap.beta0(myMap.beta1(myMap.beta2(myMap.beta1(myMap.beta0(myMap.beta1(myMap.beta2(d)))))))); // Dart dtemp = myMap.beta1(myMap.beta0(myMap.beta1(myMap.beta2(myMap.beta1(myMap.beta0(myMap.beta1(myMap.beta2(d))))))));
myMap.sewVolumes(dtemp,dp); // myMap.sewVolumes(dtemp,dp);
// Geom::Plane3D<PFP::REAL> pl(VEC3(-1,-0.5,-0.5),VEC3(-1,-0.5,0.5),VEC3(1,0.5,0.5)); // Geom::Plane3D<PFP::REAL> pl(VEC3(-1,-0.5,-0.5),VEC3(-1,-0.5,0.5),VEC3(1,0.5,0.5));
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(myMap, position, d, pl); // Algo::Volume::Modelisation::sliceConvexVolume<PFP>(myMap, position, d, pl);
......
...@@ -25,35 +25,34 @@ ...@@ -25,35 +25,34 @@
#include "simpleMap3.h" #include "simpleMap3.h"
#include "Utils/GLSLShader.h" #include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h" #include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/primitives3d.h" #include "Algo/Tiling/Volume/cubic.h"
#include "Algo/Modelisation/subdivision3.h" #include "Algo/Modelisation/subdivision3.h"
SimpleMap3::SimpleMap3() SimpleMap3::SimpleMap3()
{ {
position = myMap.addAttribute<VEC3, VERTEX>("position"); position = myMap.addAttribute<VEC3, VERTEX>("position");
Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(1,1,1);
primCat.embedHexaGrid(1,1,1);
myMap.closeMap();
myMap.check();
Dart dp = Algo::Surface::Modelisation::createQuadrangularPyramid<PFP>(myMap); Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, 1, 1, 1);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
myMap.check();
position[dp] = typename PFP::VEC3(0.5,0.5,-0.5);
position[myMap.phi1(dp)] = typename PFP::VEC3(0.5,0.5,0.5);
position[myMap.phi1(myMap.phi1(dp))] = typename PFP::VEC3(0.5,-0.5,0.5);
position[myMap.phi_1(dp)] = typename PFP::VEC3(0.5,-0.5,-0.5);
position[myMap.phi_1(myMap.phi2(dp))] = typename PFP::VEC3(1.5f, 0.0f, 0.0f);
Dart dtemp = myMap.phi_1(myMap.phi2(myMap.phi_1(myMap.phi_1(myMap.phi2(d))))); // Dart dp = Algo::Surface::Modelisation::createQuadrangularPyramid<PFP>(myMap);
myMap.sewVolumes(dtemp,dp); // position[dp] = typename PFP::VEC3(0.5,0.5,-0.5);
// position[myMap.phi1(dp)] = typename PFP::VEC3(0.5,0.5,0.5);
// position[myMap.phi1(myMap.phi1(dp))] = typename PFP::VEC3(0.5,-0.5,0.5);
// position[myMap.phi_1(dp)] = typename PFP::VEC3(0.5,-0.5,-0.5);
// position[myMap.phi_1(myMap.phi2(dp))] = typename PFP::VEC3(1.5f, 0.0f, 0.0f);
// Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap, position); // Dart dtemp = myMap.phi_1(myMap.phi2(myMap.phi_1(myMap.phi_1(myMap.phi2(d)))));
// Dart d = primCat.hexaGrid_topo(2,1,1);
// primCat.embedHexaGrid(1,1,1); // myMap.sewVolumes(dtemp,dp);
// myMap.closeMap();
// Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, 2, 1, 1);
// cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
// myMap.check();
// unsigned int nb=0; // unsigned int nb=0;
// for(unsigned int i = position.begin(); i!=position.end(); position.next(i)) // for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
......
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include "volumeExplorer.h" #include "volumeExplorer.h"
#include <iostream> #include <iostream>
#include "Algo/Modelisation/primitives3d.h" #include "Algo/Tiling/Volume/cubic.h"
#include "Algo/Modelisation/polyhedron.h" #include "Algo/Modelisation/polyhedron.h"
#include "Algo/Import/import.h" #include "Algo/Import/import.h"
#include "Algo/Geometry/volume.h" #include "Algo/Geometry/volume.h"
...@@ -440,10 +440,10 @@ int main(int argc, char **argv) ...@@ -440,10 +440,10 @@ int main(int argc, char **argv)
else else
{ {
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position"); position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
int nb = 8; int nb = 8;
prim.hexaGrid_topo(nb,nb,nb); Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
prim.embedHexaGrid(1.0f,1.0f,1.0f); cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
for (unsigned int i=position.begin(); i != position.end(); position.next(i)) for (unsigned int i=position.begin(); i != position.end(); position.next(i))
{ {
......
...@@ -26,7 +26,8 @@ ENDIF(WIN32) ...@@ -26,7 +26,8 @@ ENDIF(WIN32)
add_executable(multi_att multi_att.cpp) add_executable(multi_att multi_att.cpp)
target_link_libraries(multi_att ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) target_link_libraries(multi_att ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
add_executable(tilings tilings.cpp) QT4_WRAP_CPP(tilings_moc tilings.h)
add_executable(tilings tilings.cpp ${tilings_moc})
target_link_libraries(tilings ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS}) target_link_libraries(tilings ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
# Example with Qt # Example with Qt
......
...@@ -22,19 +22,19 @@ ...@@ -22,19 +22,19 @@
* * * *
*******************************************************************************/ *******************************************************************************/
#include <iostream> #include "tilings.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Geometry/vector_gen.h" #include "Geometry/vector_gen.h"
#include "Algo/Export/export.h" #include "Algo/Import/import.h"
#include "Algo/Geometry/boundingbox.h"
#include "Utils/GLSLShader.h"
//#include "Algo/Geometry/area.h"
#include "Algo/Geometry/normal.h"
#include "Algo/Tiling/square.h" #include "Utils/cgognStream.h"
//#include "Algo/Tiling/triangular.h" #include "Utils/chrono.h"
//#include "Algo/Tiling/hexagonal.h"
using namespace CGoGN ; using namespace CGoGN ;
...@@ -48,91 +48,186 @@ struct PFP: public PFP_STANDARD ...@@ -48,91 +48,186 @@ struct PFP: public PFP_STANDARD
typedef EmbeddedMap2 MAP; typedef EmbeddedMap2 MAP;
}; };
int main(int argc, char **argv)
PFP::MAP myMap;
VertexAttribute<PFP::VEC3> position;
VertexAttribute<PFP::VEC3> position2;
VertexAttribute<PFP::VEC3> normal;
void MyQT::cb_initGL()
{
Utils::GLSLShader::setCurrentOGLVersion(2);
// create the render
m_render = new Algo::Render::GL2::MapRender();
// create VBO for position
m_positionVBO = new Utils::VBO();
m_positionVBO->updateData(position);
m_normalVBO = new Utils::VBO();
m_shader = new Utils::ShaderSimpleColor();
m_shader->setAttributePosition(m_positionVBO);
m_shader->setColor(Geom::Vec4f(1.,1.,0.,0.));
m_lines = new Utils::ShaderVectorPerVertex();
m_lines->setAttributePosition(m_positionVBO);
m_lines->setAttributeVector(m_normalVBO);
m_lines->setScale(0.2f);
m_lines->setColor(Geom::Vec4f(0.0f, 1.0f, 0.2f, 0.0f));
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::POINTS);
registerShader(m_shader);
registerShader(m_lines);
m_normalVBO->updateData(normal);
}
void MyQT::cb_redraw()
{
m_render->draw(m_shader, Algo::Render::GL2::LINES);
m_render->draw(m_lines, Algo::Render::GL2::POINTS);
}
// mouse picking
void MyQT::tiling(int code)
{ {
if(argc != 2) //myMap.clear(false);
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:
{ {
CGoGNout << "Usage : " << argv[0] << " tiling-type" << CGoGNendl; std::cout << "square cylinder cone tiling" << std::endl;
return 0; Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
c.embedIntoTore(position,5.0,2.0);
break;
} }
unsigned int tiling; default:
std::istringstream iss(argv[1]); {
iss >> tiling; break;
}
}
// declaration of the map // m_positionVBO->updateData(position);
PFP::MAP myMap; // m_lines->setAttributePosition(m_positionVBO);
// updateGL();
}
VertexAttribute<PFP::VEC3> position = myMap.addAttribute<PFP::VEC3, VERTEX>("position"); int main(int argc, char **argv)
{
// interface:
QApplication app(argc, argv);
MyQT sqt;
sqt.statusMsg("Neww to create a sphere or Load for a mesh file");
CGoGNStream::allToConsole(&sqt);
if (!position.isValid())
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
switch(tiling) if (!normal.isValid())
normal = myMap.addAttribute<PFP::VEC3, VERTEX>("normal");
if(argc == 2)
{ {
case 1: sqt.tiling(atoi(argv[1]));
{
std::cout << "square grid tiling" << std::endl;
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
g.embedIntoGrid(position,50,50);
Algo::Surface::Export::exportOFF<PFP>(myMap,position,"square_grid.off");
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);
Algo::Surface::Export::exportOFF<PFP>(myMap,position,"square_grid_strip.off");
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);
Algo::Surface::Export::exportOFF<PFP>(myMap,position,"square_grid_helicoid.off");
break;
}
case 4:
{
std::cout << "square cylinder tiling" << std::endl;
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.closeTop();
c.closeBottom();
//c.triangleTop();
//c.triangleBottom();
c.embedIntoCylinder(position,0.5,0.7,5.0);
Algo::Surface::Export::exportOFF<PFP>(myMap,position,"square_cylinder.off");
break;
}
case 5:
{
std::cout << "square cylinder sphere tiling" << std::endl;
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.closeTop();
c.closeBottom();
c.triangleTop();
c.triangleBottom();
c.embedIntoSphere(position,0.5);
Algo::Surface::Export::exportOFF<PFP>(myMap,position,"square_cylinder_sphere.off");
break;
}
default:
{
break;
}
} }
return 0; // bounding box
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));
Geom::Vec3f lPosObj = (bb.min() + bb.max()) / PFP::REAL(2);
CGoGNout << "lPosObj=" << lPosObj << CGoGNendl;
CGoGNout << "lWidthObj=" << lWidthObj << CGoGNendl;
sqt.setParamObject(lWidthObj,lPosObj.data());
// myMap.enableQuickTraversal<EDGE>() ;
// myMap.enableQuickTraversal<VERTEX>() ;
sqt.show();
return app.exec();
} }
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
#include "show_traversors.h" #include "show_traversors.h"
#include <iostream> #include <iostream>
#include "Algo/Modelisation/primitives3d.h" #include "Algo/Tiling/Volume/cubic.h"
#include "Algo/Modelisation/polyhedron.h" #include "Algo/Modelisation/polyhedron.h"
#include "Algo/Modelisation/subdivision.h" #include "Algo/Modelisation/subdivision.h"
...@@ -613,9 +613,9 @@ int main(int argc, char **argv) ...@@ -613,9 +613,9 @@ int main(int argc, char **argv)
{ {
position = myMap.addAttribute<VEC3, VERTEX>( "position"); position = myMap.addAttribute<VEC3, VERTEX>( "position");
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position); Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, 3, 3, 3);
dglobal = prim.hexaGrid_topo(3,3,3); cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
prim.embedHexaGrid(1.0f,1.0f,1.0f); dglobal = NIL;
} }
else else
{ {
......
...@@ -32,27 +32,27 @@ using namespace CGoGN ; ...@@ -32,27 +32,27 @@ using namespace CGoGN ;
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;
// copy output tout Qt console of application (shift enter) // copy output tout Qt console of application (shift enter)
CGoGNout.toConsole(&sqt); CGoGNout.toConsole(&sqt);
// example code itself // example code itself
sqt.createMap(); sqt.createMap();
sqt.traverseMap(); sqt.traverseMap();
// set help message in menu // set help message in menu
sqt.setHelpMsg("Tuto 3: \nUsage of DartMarker and CellMarker\nPick of dart with mouse"); sqt.setHelpMsg("Tuto 3: \nUsage of DartMarker and CellMarker\nPick of dart with mouse");
// final show for redraw // final show for redraw
sqt.show(); sqt.show();
CGoGNout << "You can pick darts dans see it's id with left mouse button"<< CGoGNendl; CGoGNout << "You can pick darts dans see it's id with left mouse button"<< CGoGNendl;
// and wait for the end // and wait for the end
return app.exec(); return app.exec();
} }
Dart xd1; Dart xd1;
...@@ -60,29 +60,29 @@ Dart xd1; ...@@ -60,29 +60,29 @@ Dart xd1;
void MyQT::traverseMap() void MyQT::traverseMap()
{ {
DartMarker m1(myMap); DartMarker m1(myMap);
DartMarker m2(myMap); DartMarker m2(myMap);
myMap.rdfi(myMap.begin(),m1,m2); myMap.rdfi(myMap.begin(),m1,m2);
m1.unmarkAll(); m1.unmarkAll();
m1.markOrbit<VOLUME>(xd1); m1.markOrbit<VOLUME>(xd1);
// render the topo of the map without boundary darts // render the topo of the map without boundary darts
// SelectorDartNoBoundary<PFP::MAP> nb(myMap); // SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f); // nb m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f); // nb
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d)) for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{ {
if (m2.isMarked(d)) if (m2.isMarked(d))
{ {
m_render_topo->setDartColor(d,1.0f,0.0f,0.0f); m_render_topo->setDartColor(d,1.0f,0.0f,0.0f);
} }