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)
}
else
{
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);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
sqt.position = sqt.myMap.addAttribute<PFP::VEC3, VERTEX>("position");
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(sqt.myMap, 10,10,10);
cubic.embedIntoGrid(sqt.position, 1.0f, 1.0f, 1.0f);
}
sqt.initGUI();
......
......@@ -57,7 +57,7 @@
#include "Utils/cgognStream.h"
#include "Utils/drawer.h"
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Tiling/Volume/cubic.h"
#include <string>
#include <sstream>
......
......@@ -25,7 +25,7 @@
#include "simpleGMap3.h"
#include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Tiling/Volume/cubic.h"
#include "Algo/Modelisation/subdivision3.h"
SimpleGMap3::SimpleGMap3()
......@@ -35,22 +35,21 @@ SimpleGMap3::SimpleGMap3()
// CellMarker<EDGE> mE(myMap);
Algo::Volume::Modelisation::Primitive3D<PFP> primCat(myMap,position);
Dart d = primCat.hexaGrid_topo(1,1,1);
primCat.embedHexaGrid(1,1,1);
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, 1, 1, 1);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
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[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);
// 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.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));
// Algo::Volume::Modelisation::sliceConvexVolume<PFP>(myMap, position, d, pl);
......
......@@ -25,35 +25,34 @@
#include "simpleMap3.h"
#include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Tiling/Volume/cubic.h"
#include "Algo/Modelisation/subdivision3.h"
SimpleMap3::SimpleMap3()
{
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 d = primCat.hexaGrid_topo(2,1,1);
// primCat.embedHexaGrid(1,1,1);
// myMap.closeMap();
// Dart dtemp = myMap.phi_1(myMap.phi2(myMap.phi_1(myMap.phi_1(myMap.phi2(d)))));
// myMap.sewVolumes(dtemp,dp);
// 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;
// for(unsigned int i = position.begin(); i!=position.end(); position.next(i))
......
......@@ -26,7 +26,7 @@
#include "volumeExplorer.h"
#include <iostream>
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Tiling/Volume/cubic.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Import/import.h"
#include "Algo/Geometry/volume.h"
......@@ -440,10 +440,10 @@ int main(int argc, char **argv)
else
{
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
int nb = 8;
prim.hexaGrid_topo(nb,nb,nb);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, nb, nb, nb);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
for (unsigned int i=position.begin(); i != position.end(); position.next(i))
{
......
......@@ -26,7 +26,8 @@ ENDIF(WIN32)
add_executable(multi_att multi_att.cpp)
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})
# Example with Qt
......
......@@ -22,19 +22,19 @@
* *
*******************************************************************************/
#include <iostream>
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "tilings.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 "Algo/Tiling/triangular.h"
//#include "Algo/Tiling/hexagonal.h"
#include "Utils/cgognStream.h"
#include "Utils/chrono.h"
using namespace CGoGN ;
......@@ -48,91 +48,186 @@ struct PFP: public PFP_STANDARD
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;
return 0;
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;
}
unsigned int tiling;
std::istringstream iss(argv[1]);
iss >> tiling;
default:
{
break;
}
}
// declaration of the map
PFP::MAP myMap;
// m_positionVBO->updateData(position);
// 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:
{
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;
}
sqt.tiling(atoi(argv[1]));
}
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 @@
#include "show_traversors.h"
#include <iostream>
#include "Algo/Modelisation/primitives3d.h"
#include "Algo/Tiling/Volume/cubic.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Modelisation/subdivision.h"
......@@ -613,9 +613,9 @@ int main(int argc, char **argv)
{
position = myMap.addAttribute<VEC3, VERTEX>( "position");
Algo::Volume::Modelisation::Primitive3D<PFP> prim(myMap, position);
dglobal = prim.hexaGrid_topo(3,3,3);
prim.embedHexaGrid(1.0f,1.0f,1.0f);
Algo::Volume::Tilings::Cubic::Grid<PFP> cubic(myMap, 3, 3, 3);
cubic.embedIntoGrid(position, 1.0f, 1.0f, 1.0f);
dglobal = NIL;
}
else
{
......
......@@ -32,27 +32,27 @@ using namespace CGoGN ;
int main(int argc, char **argv)
{
// // interface
QApplication app(argc, argv);
MyQT sqt;
// copy output tout Qt console of application (shift enter)
CGoGNout.toConsole(&sqt);
// // interface
QApplication app(argc, argv);
MyQT sqt;
// copy output tout Qt console of application (shift enter)
CGoGNout.toConsole(&sqt);
// example code itself
sqt.createMap();
// example code itself
sqt.createMap();
sqt.traverseMap();
sqt.traverseMap();
// set help message in menu
sqt.setHelpMsg("Tuto 3: \nUsage of DartMarker and CellMarker\nPick of dart with mouse");
// final show for redraw
sqt.show();
// set help message in menu
sqt.setHelpMsg("Tuto 3: \nUsage of DartMarker and CellMarker\nPick of dart with mouse");
// final show for redraw
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
return app.exec();
// and wait for the end
return app.exec();
}
Dart xd1;
......@@ -60,29 +60,29 @@ Dart xd1;
void MyQT::traverseMap()
{
DartMarker m1(myMap);
DartMarker m2(myMap);
myMap.rdfi(myMap.begin(),m1,m2);
DartMarker m1(myMap);
DartMarker m2(myMap);
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);
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f); // nb
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (m2.isMarked(d))
{
m_render_topo->setDartColor(d,1.0f,0.0f,0.0f);
}
if (m1.isMarked(d))
{
m_render_topo->setDartColor(d,0.0f,1.0f,0.0f);
}
}
m_render_topo->updateData<PFP>(myMap, position, 0.9f, 0.9f); // nb
for (Dart d = myMap.begin(); d != myMap.end(); myMap.next(d))
{
if (m2.isMarked(d))
{
m_render_topo->setDartColor(d,1.0f,0.0f,0.0f);
}
if (m1.isMarked(d))
{
m_render_topo->setDartColor(d,0.0f,1.0f,0.0f);
}
}
//
//
......@@ -152,11 +152,11 @@ void MyQT::createMap()
// Dart d2 = d1;
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
position = myMap.addAttribute<PFP::VEC3, VERTEX>("position");
Algo::Surface::Modelisation::Polyhedron<PFP> prim1(myMap, position);
prim1.cylinder_topo(256, 256, true, true); // topo of sphere is a closed cylinder
prim1.embedSphere(2.0f);
Algo::Surface::Modelisation::Polyhedron<PFP> prim1(myMap, position);
prim1.cylinder_topo(256, 256, true, true); // topo of sphere is a closed cylinder
prim1.embedSphere(2.0f);
// Dart d2 = d1;
// position[d2] = PFP::VEC3(1, 0, 0);
......@@ -167,16 +167,16 @@ void MyQT::createMap()
// d2 = PHI<211>(d2);
// position[d2] = PFP::VEC3(0, 1, 2);
Algo::Surface::Modelisation::Polyhedron<PFP> prim2(myMap, position);
prim2.cylinder_topo(256, 256, true, true); // topo of sphere is a closed cylinder
prim2.embedSphere(2.0f);
Algo::Surface::Modelisation::Polyhedron<PFP> prim2(myMap, position);
prim2.cylinder_topo(256, 256, true, true); // topo of sphere is a closed cylinder
prim2.embedSphere(2.0f);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(5.0f, 0.0, 0.0, trf);
prim2.transform(trf);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(5.0f, 0.0, 0.0, trf);
prim2.transform(trf);
xd1 = prim2.getDart();
xd1 = prim2.getDart();
// xd1 = Algo::Modelisation::Polyhedron<PFP>::createTetra(myMap);
// Dart xd2 = xd1;
......@@ -195,40 +195,40 @@ void MyQT::createMap()
Geom::Vec3f lPosObj = (bb.min() + bb.max()) / PFP::REAL(2);
// send BB info to interface for centering on GL screen
setParamObject(lWidthObj, lPosObj.data());
setParamObject(lWidthObj, lPosObj.data());
// first show for be sure that GL context is binded
show();
// first show for be sure that GL context is binded
show();
// render the topo of the map without boundary darts
// render the topo of the map without boundary darts
// 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
}
// initialization GL callback
void MyQT::cb_initGL()
{
m_render_topo = new Algo::Render::GL2::TopoRender();
m_render_topo = new Algo::Render::GL2::TopoRender();
}
// redraw GL callback (clear and swap already done)
void MyQT::cb_redraw()