Commit e9606c65 authored by Sylvain Thery's avatar Sylvain Thery

more tests

parent 2ac35316
......@@ -14,7 +14,7 @@ IF (WIN32)
link_directories( ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE})
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/${CMAKE_BUILD_TYPE}) # Release/Debug added automatically by visual
ELSE()
link_directories( ${CGoGN_ROOT_DIR}/bin/${ConfigurationName})
link_directories( ${CGoGN_ROOT_DIR}/bin/$(ConfigurationName))
SET(EXECUTABLE_OUTPUT_PATH ${CGoGN_ROOT_DIR}/bin/) # Release/Debug added automatically by visual
ENDIF()
ELSE()
......
......@@ -20,5 +20,5 @@ add_subdirectory(Geometry)
#add_subdirectory(Render)
#add_subdirectory(Selection)
#add_subdirectory(Simulation)
#add_subdirectory(Tiling)
#add_subdirectory(Topo)
add_subdirectory(Tiling)
add_subdirectory(Topo)
#include "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Topology/map/embeddedMap3.h"
#include "Algo/Geometry/normal.h"
......@@ -19,14 +20,26 @@ template VATT1::DATA_TYPE Algo::Surface::Geometry::triangleNormal<PFP1, VATT1>(P
template VATT1::DATA_TYPE Algo::Surface::Geometry::newellNormal<PFP1, VATT1>(PFP1::MAP& map, Face f, const VATT1& position);
template VATT1::DATA_TYPE Algo::Surface::Geometry::faceNormal<PFP1, VATT1>(PFP1::MAP& map, Face f, const VATT1& position);
template VATT1::DATA_TYPE Algo::Surface::Geometry::vertexNormal<PFP1, VATT1>(PFP1::MAP& map, Vertex v, const VATT1& position);
//TODO COMPILER ERROR
// template VATT1::DATA_TYPE Algo::Surface::Geometry::vertexBorderNormal<PFP1, VATT1>(PFP1::MAP& map, Vertex v, const VATT1& position);
template void Algo::Surface::Geometry::computeNormalFaces<PFP1, VATT1, FATT1>(PFP1::MAP& map, const VATT1& position, FATT1& face_normal);
template void Algo::Surface::Geometry::computeNormalVertices<PFP1, VATT1>(PFP1::MAP& map, const VATT1& position, VATT1& normal);
template PFP1::REAL Algo::Surface::Geometry::computeAngleBetweenNormalsOnEdge<PFP1, VATT1>(PFP1::MAP& map, Edge d, const VATT1& position);
template void Algo::Surface::Geometry::computeAnglesBetweenNormalsOnEdges<PFP1,VATT1,EATT1>(PFP1::MAP& map, const VATT1& position, EATT1& angles);
struct PFP11 : public PFP_STANDARD
{
typedef EmbeddedMap3 MAP;
};
typedef VertexAttribute<PFP11::VEC3, PFP11::MAP> VATT11;
typedef FaceAttribute<PFP11::VEC3, PFP11::MAP> FATT11;
typedef EdgeAttribute<PFP11::REAL, PFP11::MAP> EATT11;
template VATT11::DATA_TYPE Algo::Surface::Geometry::vertexBorderNormal<PFP11, VATT11>(PFP11::MAP& map, Vertex v, const VATT11& position);
struct PFP2 : public PFP_DOUBLE
{
typedef EmbeddedMap2 MAP;
......@@ -40,7 +53,7 @@ template VATT2::DATA_TYPE Algo::Surface::Geometry::triangleNormal<PFP2, VATT2>(P
template VATT2::DATA_TYPE Algo::Surface::Geometry::newellNormal<PFP2, VATT2>(PFP2::MAP& map, Face f, const VATT2& position);
template VATT2::DATA_TYPE Algo::Surface::Geometry::faceNormal<PFP2, VATT2>(PFP2::MAP& map, Face f, const VATT2& position);
template VATT2::DATA_TYPE Algo::Surface::Geometry::vertexNormal<PFP2, VATT2>(PFP2::MAP& map, Vertex v, const VATT2& position);
//TODO COMPILER ERROR
//TODO VOLUME INSTANTIATION
// template VATT2::DATA_TYPE Algo::Surface::Geometry::vertexBorderNormal<PFP2, VATT2>(PFP2::MAP& map, Vertex v, const VATT2& position);
template void Algo::Surface::Geometry::computeNormalFaces<PFP2, VATT2, FATT2>(PFP2::MAP& map, const VATT2& position, FATT2& face_normal);
template void Algo::Surface::Geometry::computeNormalVertices<PFP2, VATT2>(PFP2::MAP& map, const VATT2& position, VATT2& normal);
......@@ -61,7 +74,7 @@ template VATT3::DATA_TYPE Algo::Surface::Geometry::triangleNormal<PFP3, VATT3>(P
template VATT3::DATA_TYPE Algo::Surface::Geometry::newellNormal<PFP3, VATT3>(PFP3::MAP& map, Face f, const VATT3& position);
template VATT3::DATA_TYPE Algo::Surface::Geometry::faceNormal<PFP3, VATT3>(PFP3::MAP& map, Face f, const VATT3& position);
template VATT3::DATA_TYPE Algo::Surface::Geometry::vertexNormal<PFP3, VATT3>(PFP3::MAP& map, Vertex v, const VATT3& position);
//TODO COMPILER ERROR
//TODO VOLUME INSTANTIATION
// template VATT3::DATA_TYPE Algo::Surface::Geometry::vertexBorderNormal<PFP3, VATT3>(PFP3::MAP& map, Vertex v, const VATT3& position);
template void Algo::Surface::Geometry::computeNormalFaces<PFP3, VATT3, FATT3>(PFP3::MAP& map, const VATT3& position, FATT3& face_normal);
template void Algo::Surface::Geometry::computeNormalVertices<PFP3, VATT3>(PFP3::MAP& map, const VATT3& position, VATT3& normal);
......
cmake_minimum_required(VERSION 2.6)
project(testing_algo_tiling)
add_executable( test_algo_tiling
algo_tiling.cpp
Surface/hexagonal.cpp
Surface/square.cpp
Surface/triangular.cpp
Volume/cubic.cpp
)
target_link_libraries( test_algo_tiling
${CGoGN_LIBS} ${CGoGN_EXT_LIBS})
/*******************************************************************************
* 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Algo/Tiling/tiling.h"
#ifndef _TILING_HEXAGONAL_H_
#define _TILING_HEXAGONAL_H_
using namespace CGoGN;
#include "Algo/Tiling/Surface/hexagonal.h"
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Tilings
struct PFP1 : public PFP_STANDARD
{
typedef EmbeddedMap2 MAP;
};
namespace Hexagonal
struct PFP2 : public PFP_DOUBLE
{
typedef EmbeddedMap2 MAP;
};
/*! \brief The class of regular grid square tiling
*/
template <typename PFP>
class Grid : public Tiling<PFP>
struct PFP3 : public PFP_DOUBLE
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
public:
Grid(MAP& map, unsigned int x, unsigned int y, bool close):
Tiling<PFP>(map, x, y, -1)
{
grid(x, y, close);
}
Grid(MAP& map, unsigned int x, unsigned int y):
Tiling<PFP>(map, x, y, -1)
{
grid(x, y, true);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological grid
/*! @param position Attribute used to store vertices positions
* @param x size in X
* @param x size in Y
* @param y position in Z (centered on 0 by default)
*/
void embedIntoGrid(VertexAttribute<VEC3, MAP>& position, float x, float y, float z = 0.0f);
//! Embed a topological grid into a twister open ribbon with turns=PI it is a Moebius strip, needs only to be closed (if model allow it)
/*! @param position Attribute used to store vertices positions
* @param radius_min
* @param radius_max
* @param turns number of turn multiplied by 2*PI
*/
void embedIntoTwistedStrip(VertexAttribute<VEC3, MAP>& position, float radius_min, float radius_max, float turns);
//! Embed a topological grid into a helicoid
/*! @param position Attribute used to store vertices positions
* @param radius_min
* @param radius_max
* @param maxHeight height to reach
* @param turns number of turn
*/
void embedIntoHelicoid(VertexAttribute<VEC3, MAP>& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1);
//@}
protected:
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
//@{
//! Create a 2D grid
/*! @param x nb of squares in x
* @param y nb of squares in y
* @param closed close the boundary face of the 2D grid
*/
void grid(unsigned int x, unsigned int y, bool close);
//@}
typedef EmbeddedGMap2 MAP;
};
} // namespace Hexagonal
} // namespace Tilings
} // namespace Surface
// TODO implementation !!!
template Algo::Surface::Tilings::Hexagonal::Grid<PFP1>;
template Algo::Surface::Tilings::Hexagonal::Grid<PFP2>;
template Algo::Surface::Tilings::Hexagonal::Grid<PFP3>;
} // namespace Algo
} // namespace CGoGN
#include "Algo/Tiling/Surface/hexagonal.hpp"
#endif // _TILING_HEXAGONAL_H_
int test_hexagonal()
{
return 0;
}
/*******************************************************************************
* 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Algo/Tiling/tiling.h"
#ifndef _TILING_SQUARE_H_
#define _TILING_SQUARE_H_
using namespace CGoGN;
#include "Algo/Tiling/Surface/square.h"
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Tilings
{
namespace Square
{
/*! \brief The class of regular grid square tiling
*/
template <typename PFP>
class Grid : public Tiling<PFP>
struct PFP1 : public PFP_STANDARD
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
public:
Grid(MAP& map, unsigned int x, unsigned int y, bool close):
Tiling<PFP>(map, x, y, -1)
{
grid(x, y, close);
}
Grid(MAP& map, unsigned int x, unsigned int y):
Tiling<PFP>(map, x, y, -1)
{
grid(x, y, true);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological grid
/*! @param position Attribute used to store vertices positions
* @param x size in X
* @param x size in Y
* @param y position in Z (centered on 0 by default)
*/
void embedIntoGrid(VertexAttribute<VEC3, MAP>& position, float x, float y, float z = 0.0f);
//! Embed a topological grid into a twister open ribbon with turns=PI it is a Moebius strip, needs only to be closed (if model allow it)
/*! @param position Attribute used to store vertices positions
* @param radius_min
* @param radius_max
* @param turns number of turn multiplied by 2*PI
*/
void embedIntoTwistedStrip(VertexAttribute<VEC3, MAP>& position, float radius_min, float radius_max, float turns);
//! Embed a topological grid into a helicoid
/*! @param position Attribute used to store vertices positions
* @param radius_min
* @param radius_max
* @param maxHeight height to reach
* @param turns number of turn
*/
void embedIntoHelicoid(VertexAttribute<VEC3, MAP>& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1);
//@}
protected:
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
//@{
//! Create a 2D grid
/*! @param x nb of squares in x
* @param y nb of squares in y
* @param closed close the boundary face of the 2D grid
*/
void grid(unsigned int x, unsigned int y, bool close);
//@}
typedef EmbeddedMap2 MAP;
};
/*! \brief The class of regular cylinder square tiling or subdivided sphere (with pole)
*/
template <typename PFP>
class Cylinder : public Tiling<PFP>
struct PFP2 : public PFP_DOUBLE
{
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, MAP>& 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, MAP>& position, float radius);
//! Embed a topological cone
/*! @param position Attribute used to store vertices positions
* @param radius
* @param height
*/
void embedIntoCone(VertexAttribute<VEC3, MAP>& 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);
//@}
typedef EmbeddedMap2 MAP;
};
/*! \brief The class of regular cube square tiling
*/
template <typename PFP>
class Cube : public Cylinder<PFP>
struct PFP3 : public PFP_DOUBLE
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
public:
Cube(MAP& map, unsigned int x, unsigned int y, unsigned int z):
Cylinder<PFP>(map, 2*(x+y), z, false, false)
{
cube(x, y, z);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological cube
/*! @param position Attribute used to store vertices positions
* @param x
* @param y
* @param z
*/
void embedIntoCube(VertexAttribute<VEC3, MAP>& position, float x, float y, float z);
//@}
protected:
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
//@{
//! Create a subdivided 2D cube
/*! @param x nb of squares in x
* @param y nb of squares in y
* @param z nb of squares un z
*/
void cube(unsigned int x, unsigned int y, unsigned int z);
//@}
typedef EmbeddedGMap2 MAP;
};
/*! \brief The class of regular tore square tiling
*/
template <typename PFP>
class Tore : public Cylinder<PFP>
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
public:
Tore(MAP& map, unsigned int n, unsigned int m):
Cylinder<PFP>(map,n,m)
{
tore(n,m);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological tore
/*! @param position Attribute used to store vertices positions
* @param big_radius
* @param small_radius
*/
void embedIntoTore(VertexAttribute<VEC3, MAP>& position, float big_radius, float small_radius);
//@}
template Algo::Surface::Tilings::Square::Grid<PFP1>;
template Algo::Surface::Tilings::Square::Cylinder<PFP1>;
template Algo::Surface::Tilings::Square::Cube<PFP1>;
template Algo::Surface::Tilings::Square::Tore<PFP1>;
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
template Algo::Surface::Tilings::Square::Grid<PFP2>;
template Algo::Surface::Tilings::Square::Cylinder<PFP2>;
template Algo::Surface::Tilings::Square::Cube<PFP2>;
template Algo::Surface::Tilings::Square::Tore<PFP2>;
//@{
protected:
//! Create a subdivided 2D tore
/*! @param n nb of squares around big circumference
* @param m nb of squares around small circumference
*/
//square -> tore -> cylinder + finish sewing
void tore(unsigned int n, unsigned int m);
//@}
};
template Algo::Surface::Tilings::Square::Grid<PFP3>;
template Algo::Surface::Tilings::Square::Cylinder<PFP3>;
template Algo::Surface::Tilings::Square::Cube<PFP3>;
template Algo::Surface::Tilings::Square::Tore<PFP3>;
} // namespace Square
} // namespace Tilings
} // namespace Surface
} // namespace Algo
} // namespace CGoGN
#include "Algo/Tiling/Surface/square.hpp"
int test_square()
{
return 0;
}
#endif // _TILING_SQUARE_H_
/*******************************************************************************
* 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 "Topology/generic/parameters.h"
#include "Topology/map/embeddedMap2.h"
#include "Topology/gmap/embeddedGMap2.h"
#include "Algo/Tiling/tiling.h"
#ifndef _TILING_TRIANGULAR_H_
#define _TILING_TRIANGULAR_H_
using namespace CGoGN;
#include "Algo/Tiling/Surface/triangular.h"
namespace CGoGN
{
namespace Algo
{
namespace Surface
{
namespace Tilings
{
namespace Triangular
{
/*! \brief The class of regular grid square tiling
*/
template <typename PFP>
class Grid : public Tiling<PFP>
struct PFP1 : public PFP_STANDARD
{
typedef typename PFP::MAP MAP;
typedef typename PFP::VEC3 VEC3;
public:
Grid(MAP& map, unsigned int x, unsigned int y, bool close):
Tiling<PFP>(map, x, y, -1)
{
grid(x, y, close);
}
Grid(MAP& map, unsigned int x, unsigned int y):
Tiling<PFP>(map, x, y, -1)
{
grid(x, y, true);
}
/*! @name Embedding Operators
* Tiling creation
*************************************************************************/
//@{
//! Embed a topological grid
/*! @param position Attribute used to store vertices positions
* @param x size in X
* @param x size in Y
* @param y position in Z (centered on 0 by default)
*/
void embedIntoGrid(VertexAttribute<VEC3, MAP>& position, float x, float y, float z = 0.0f);
//! Embed a topological grid into a twister open ribbon with turns=PI it is a Moebius strip, needs only to be closed (if model allow it)
/*! @param position Attribute used to store vertices positions
* @param radius_min
* @param radius_max
* @param turns number of turn multiplied by 2*PI
*/
void embedIntoTwistedStrip(VertexAttribute<VEC3, MAP>& position, float radius_min, float radius_max, float turns);
//! Embed a topological grid into a helicoid
/*! @param position Attribute used to store vertices positions
* @param radius_min
* @param radius_max
* @param maxHeight height to reach
* @param turns number of turn
*/
void embedIntoHelicoid(VertexAttribute<VEC3, MAP>& position, float radius_min, float radius_max, float maxHeight, float nbTurn, int orient = 1);
//@}
protected:
/*! @name Topological Operators
* Tiling creation
*************************************************************************/
//@{
//! Create a 2D grid
/*! @param x nb of squares in x
* @param y nb of squares in y
* @param closed close the boundary face of the 2D grid
*/
void grid(unsigned int x, unsigned int y, bool close);
//@}
};
/*! \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),