Commit b2e6f0ef authored by untereiner's avatar untereiner

triangular tiling

parent c052557b
......@@ -31,7 +31,8 @@
#include "Utils/GLSLShader.h"
//#include "Algo/Geometry/area.h"
#include "Algo/Geometry/normal.h"
#include "Geometry/matrix.h"
#include "Geometry/transfo.h"
#include "Utils/cgognStream.h"
#include "Utils/chrono.h"
......@@ -104,7 +105,12 @@ void MyQT::squareTiling(int code)
{
std::cout << "square grid tiling" << std::endl;
Algo::Surface::Tilings::Square::Grid<PFP> g(myMap,10,10,true);
g.embedIntoGrid(position,50,50);
g.embedIntoGrid(position,1.0,1.0, 0.0);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(0.5,0.5,0.0,trf);
g.transform(position, trf);
g.exportPositions(position, "grid.bs");
......@@ -114,7 +120,13 @@ void MyQT::squareTiling(int code)
{
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);
g.embedIntoTwistedStrip(position, 0.2, 0.7, 5);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(0.5,0.5,0.0,trf);
g.transform(position, trf);
g.exportPositions(position, "gridtwisted.bs");
......@@ -124,7 +136,13 @@ void MyQT::squareTiling(int code)
{
std::cout << "square grid helicoid 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);
g.embedIntoHelicoid(position, 0.2, 0.3, 0.8, 2.0);
// Geom::Matrix44f trf;
// trf.identity();
// Geom::translate<float>(0.5,0.5,0.0,trf);
// g.transform(position, trf);
g.exportPositions(position, "gridhelicoid.bs");
......@@ -134,7 +152,13 @@ void MyQT::squareTiling(int code)
{
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);
c.embedIntoCylinder(position,0.5,0.7,1.0);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(0.5,0.5,0.0,trf);
c.transform(position, trf);
c.exportPositions(position, "cylinder.bs");
......@@ -146,7 +170,7 @@ void MyQT::squareTiling(int code)
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.triangleBottom();
c.triangleTop();
c.embedIntoCylinder(position,0.5,0.7,5.0);
c.embedIntoCylinder(position,0.5,0.7,1.0);
break;
}
......@@ -166,7 +190,7 @@ void MyQT::squareTiling(int code)
Algo::Surface::Tilings::Square::Cylinder<PFP> c(myMap,20,20);
c.triangleTop();
c.triangleBottom();
c.embedIntoCone(position,0.5, 5.0);
c.embedIntoCone(position,0.5, 1.0);
break;
}
......@@ -174,7 +198,12 @@ void MyQT::squareTiling(int code)
{
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);
c.embedIntoCube(position,1.0, 1.0, 1.0);
Geom::Matrix44f trf;
trf.identity();
Geom::translate<float>(0.5,0.5,0.5,trf);
c.transform(position, trf);
c.exportPositions(position, "cube.bs");
......@@ -184,7 +213,7 @@ void MyQT::squareTiling(int code)
{
std::cout << "square tore tiling" << std::endl;
Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
c.embedIntoTore(position,5.0,2.0);
c.embedIntoTore(position, 0.9, 0.5);
c.exportPositions(position, "tore.bs");
break;
......@@ -206,69 +235,69 @@ void MyQT::triangularTiling(int 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);
std::cout << "triangle grid tiling" << std::endl;
Algo::Surface::Tilings::Triangular::Grid<PFP> g(myMap,10,6,true);
g.embedIntoGrid(position,1,1);
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);
std::cout << "triangle grid twisted strip tiling" << std::endl;
Algo::Surface::Tilings::Triangular::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);
std::cout << "triangle grid helocoid tiling" << std::endl;
Algo::Surface::Tilings::Triangular::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);
std::cout << "triangle cylinder tiling" << std::endl;
Algo::Surface::Tilings::Triangular::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);
std::cout << "triangle cylinder tiling" << std::endl;
Algo::Surface::Tilings::Triangular::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);
std::cout << "triangle cylinder sphere tiling" << std::endl;
Algo::Surface::Tilings::Triangular::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);
std::cout << "triangle cylinder cone tiling" << std::endl;
Algo::Surface::Tilings::Triangular::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;
// std::cout << "triangle 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);
......@@ -276,7 +305,7 @@ void MyQT::triangularTiling(int code)
}
case 9:
{
// std::cout << "square cylinder cone tiling" << std::endl;
// std::cout << "triangle cylinder cone tiling" << std::endl;
// Algo::Surface::Tilings::Square::Tore<PFP> c(myMap,20,10);
// c.embedIntoTore(position,5.0,2.0);
......
......@@ -111,6 +111,97 @@ protected:
};
/*! \brief The class of regular cylinder square tiling or subdivided sphere (with pole)
*/
template <typename PFP>
class Cylinder : public Tiling<PFP>
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
private:
bool m_top_closed, m_bottom_closed;
bool m_top_triangulated, m_bottom_triangulated;
Dart m_topVertDart, m_bottomVertDart;
public:
Cylinder(MAP& map, unsigned int n, unsigned int z, bool close_top, bool close_bottom):
Tiling<PFP>(map, n, -1, z),
m_top_closed(close_top),
m_bottom_closed(close_bottom),
m_top_triangulated(false),
m_bottom_triangulated(false)
{
cylinder(n,z);
}
Cylinder(MAP& map, unsigned int n, unsigned int z):
Tiling<PFP>(map, n, -1, z),
m_top_closed(true),
m_bottom_closed(true),
m_top_triangulated(false),
m_bottom_triangulated(false)
{
cylinder(n,z);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological cylinder
/*! @param position Attribute used to store vertices positions
* @param bottom_radius
* @param top_radius
* @param height
*/
void embedIntoCylinder(VertexAttribute<VEC3>& position, float bottom_radius, float top_radius, float height);
//! Embed a topological sphere
/*! @param position Attribute used to store vertices positions
* @param radius
* @param height
*/
void embedIntoSphere(VertexAttribute<VEC3>& position, float radius);
//! Embed a topological cone
/*! @param position Attribute used to store vertices positions
* @param radius
* @param height
*/
void embedIntoCone(VertexAttribute<VEC3>& position, float radius, float height);
//@}
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
//@{
//! Close the top with a n-sided face
void closeTop();
//! Triangulate the top face with triangles fan
void triangleTop();
//! Close the bottom with a n-sided face
void closeBottom();
//! Triangulate the bottom face with triangles fan
void triangleBottom();
protected:
//! Create a subdivided 2D cylinder
/*! @param n nb of squares around circumference
* @param z nb of squares in height
* @param top_closed close the top (with triangles fan)
* @param bottom_closed close the bottom (with triangles fan)
*/
//square -> cylinder -> grid + finish sewing -> open or closed (closeHole) -> triangule face ?
void cylinder(unsigned int n, unsigned int z);
//@}
};
} // namespace Triangular
} // namespace Tilings
......
This diff is collapsed.
......@@ -121,12 +121,14 @@ bool Tiling<PFP>::exportPositions(const VertexAttribute<typename PFP::VEC3>& pos
out << (m_nx + 1) << " ";
out << (m_ny + 1) << " ";
out << (m_nz + 1) << " ";
for(std::vector<Dart>::iterator it = m_tableVertDarts.begin() ; it != m_tableVertDarts.end() ; ++it)
{
out << position[*it];
}
return true;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment