Commit 6d8c1419 authored by Sylvain Thery's avatar Sylvain Thery

Merge cgogn:~untereiner/CGoGN

parents 95cf4074 a119b8e3
......@@ -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>
......
......@@ -26,6 +26,7 @@
#include "Utils/GLSLShader.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Tiling/Surface/square.h"
SimpleGMap2::SimpleGMap2()
{
......@@ -41,11 +42,9 @@ SimpleGMap2::SimpleGMap2()
myMap.cutEdge(d);
position[myMap.phi1(d)] = mid;
Algo::Surface::Modelisation::Polyhedron<PFP> poly(myMap, position);
d = poly.cylinder_topo(5, 1, false, false);
poly.embedCylinder(10, 10, 5);
Algo::Surface::Tilings::Square::Cylinder<PFP> poly(myMap, 5 ,1, false, false);
d = poly.getDart();
poly.embedIntoCylinder(position, 10, 10, 5);
d = myMap.phi1(d);
Dart dd = myMap.beta2(d);
......
......@@ -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))
......
......@@ -24,7 +24,7 @@
#include "texturesExample.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Modelisation/polyhedron.h"
#include "Algo/Tiling/Surface/square.h"
#include "Utils/vbo.h"
TexView::TexView():
......@@ -215,9 +215,9 @@ void TexView::computeTore()
VertexAttribute<VEC3> position = myMap.addAttribute<VEC3, VERTEX>("position");
VertexAttribute<Geom::Vec2f> texcoord = myMap.addAttribute<Geom::Vec2f, VERTEX>("texcoord");
Algo::Surface::Modelisation::Polyhedron<PFP> prim(myMap, position);
prim.tore_topo(NB, NB);
prim.embedTore(40.0f,20.0f);
//Algo::Surface::Modelisation::Polyhedron<PFP> prim(myMap, position);
Algo::Surface::Tilings::Square::Tore<PFP> prim(myMap, NB, NB);
prim.embedIntoTore(position, 40.0f,20.0f);
Dart d = prim.getDart();
for(unsigned int i=0; i<NB; ++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"
......@@ -214,7 +214,7 @@ void MyQT::cb_initGL()
// create the renders
m_topo_render = new Algo::Render::GL2::Topo3Render();
m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender(true,true,false);
m_explode_render = new Algo::Render::GL2::ExplodeVolumeRender(true,true,true);
// SelectorDartNoBoundary<PFP::MAP> nb(myMap);
m_topo_render->updateData<PFP>(myMap, position, 0.8f, 0.8f, 0.8f);
......@@ -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))
{
......
......@@ -23,8 +23,12 @@ ENDIF(WIN32)
#define exec to compile
add_executable( multi_att multi_att.cpp)
target_link_libraries( multi_att ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS} )
add_executable(multi_att multi_att.cpp)
target_link_libraries(multi_att ${CGoGN_LIBS_D} ${CGoGN_EXT_LIBS})
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
#
......
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#include "tilings.h"
#include "Geometry/vector_gen.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 "Utils/cgognStream.h"
#include "Utils/chrono.h"
using namespace CGoGN ;
/**
* Struct that contains some informations about the types of the manipulated objects
* Mainly here to be used by the algorithms that are parameterized by it
*/
struct PFP: public PFP_STANDARD
{
// definition of the map
typedef EmbeddedMap2 MAP;
};
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);
}
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
void MyQT::triangularTiling(int code)
{
switch(code)
{
case 1:
{
std::cout << "square grid tiling" << std::endl;
Algo::Surface::Tilings::Triangular::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;
}
}
}
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");
if (!normal.isValid())
normal = myMap.addAttribute<PFP::VEC3, VERTEX>("normal");
if(argc == 3)
{
if(argv[1][0] == 'S')
sqt.squareTiling(atoi(argv[2]));
else if(argv[1][0] == 'T')
sqt.triangularTiling(atoi(argv[2]));
}
// 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();
}
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps *
* version 0.1 *
* Copyright (C) 2009-2012, 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.unistra.fr/ *
* Contact information: cgogn@unistra.fr *
* *
*******************************************************************************/
#ifndef TUTO_TILINGS_H
#define TUTO_TILINGS_H
#include <iostream>
#include "Utils/Qt/qtSimple.h"
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Geometry/vector_gen.h"
#include "Algo/Geometry/boundingbox.h"
#include "Algo/Render/GL2/mapRender.h"
#include "Utils/Shaders/shaderSimpleColor.h"
#include "Utils/Shaders/shaderVectorPerVertex.h"
#include "Utils/vbo.h"
#include "Utils/cgognStream.h"
#include "Algo/Tiling/Surface/square.h"
#include "Algo/Tiling/Surface/triangular.h"
// forward definitions (minimize includes)
namespace CGoGN { namespace Algo { namespace Render { namespace GL1 { class MapRender; } } } }
namespace CGoGN { namespace Utils { class VBO; } }
namespace CGoGN { namespace Utils { class ShaderSimpleColor; } }
using namespace CGoGN ;
/**
* A class for a little interface and rendering
*/
class MyQT: public Utils::QT::SimpleQT
{
Q_OBJECT
public:
Algo::Render::GL2::MapRender* m_render;
Utils::VBO* m_positionVBO;
Utils::VBO* m_normalVBO;
Utils::ShaderSimpleColor* m_shader;
Utils::ShaderVectorPerVertex* m_lines;