tiling.h 3.95 KB
Newer Older
Lionel Untereiner's avatar
Lionel Untereiner committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
/*******************************************************************************
* 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 _TILING_H_
#define _TILING_H_

untereiner's avatar
untereiner committed
28 29 30
#include "Geometry/transfo.h"
#include "Topology/generic/cellmarker.h"

Lionel Untereiner's avatar
Lionel Untereiner committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
namespace CGoGN
{

namespace Algo
{

namespace Surface
{

namespace Tilings
{

/*! \brief The class of regular tiling
 */
template <typename PFP>
class Tiling
{
48
	typedef typename PFP::MAP MAP;
Lionel Untereiner's avatar
Lionel Untereiner committed
49 50 51 52 53 54 55 56 57 58
    typedef typename PFP::VEC3 VEC3;

protected:
    /**
    * Map in which we are working
    */
    MAP& m_map;

    unsigned int m_nx, m_ny, m_nz;

untereiner's avatar
untereiner committed
59 60
    VEC3 m_center;

untereiner's avatar
untereiner committed
61 62 63 64 65
    /**
        * Reference dart of Polyhedron
        */
    Dart m_dart;

Lionel Untereiner's avatar
Lionel Untereiner committed
66 67 68 69 70 71
    /**
    * Table of vertex darts (one dart per vertex)
    * Order depend on tiling kind
    */
    std::vector<Dart> m_tableVertDarts;

72 73 74 75 76 77
	/**
	* Table of vertex darts (one dart per vertex)
	* Order depend on tiling kind
	*/
	std::vector<Dart> m_tableFaceDarts;

Lionel Untereiner's avatar
Lionel Untereiner committed
78 79 80 81
public:
    Tiling(MAP& map, unsigned int x, unsigned int y, unsigned int z):
        m_map(map),
        m_nx(x), m_ny(y), m_nz(z)
82
	{}
Lionel Untereiner's avatar
Lionel Untereiner committed
83

untereiner's avatar
untereiner committed
84 85 86
    Tiling(MAP& map) :
        m_map(map),
        m_nx(-1), m_ny(-1), m_nz(-1)
87
	{}
untereiner's avatar
untereiner committed
88

untereiner's avatar
untereiner committed
89 90
    Tiling(const Tiling<PFP>& t1, const Tiling<PFP> t2);

Lionel Untereiner's avatar
Lionel Untereiner committed
91
    /**
92
	* get the table of vertex darts (one per vertex)
Lionel Untereiner's avatar
Lionel Untereiner committed
93 94 95
    */
    std::vector<Dart>& getVertexDarts() { return m_tableVertDarts; }

96 97 98 99 100
	/**
	* get the table of face darts (one per face)
	*/
	std::vector<Dart>& getFaceDarts() { return m_tableFaceDarts; }

101
	void computeCenter(VertexAttribute<VEC3, MAP>& position);
untereiner's avatar
untereiner committed
102 103

    //void Polyhedron<PFP>::transform(float* matrice)
104
	void transform(VertexAttribute<VEC3, MAP>& position, const Geom::Matrix44f& matrice);
untereiner's avatar
untereiner committed
105

106
	void mark(CellMarker<MAP, VERTEX>& m);
untereiner's avatar
untereiner committed
107

untereiner's avatar
untereiner committed
108
    /*
109 110
	* get the reference dart
	*/
untereiner's avatar
untereiner committed
111 112
    Dart getDart() { return m_dart; }

113
	bool exportPositions(const VertexAttribute<VEC3, MAP>& position, const char* filename);
untereiner's avatar
untereiner committed
114 115 116 117 118 119 120 121 122 123 124 125

	//	/**
	//	* mark all embedded vertices of the Polyhedron
	//	* @param m the marker to use
	//	*/
	////	void markEmbVertices(Mark m);

	//	/**
	//	* test if a vertex is in the Polyhedron
	//	* @param d a dart of the vertex to test
	//	*/
	//	bool containVertex(Dart d);
Lionel Untereiner's avatar
Lionel Untereiner committed
126 127 128 129 130 131 132 133 134 135
};

} // namespace Tilings

} // namespace Surface

} // namespace Algo

} // namespace CGoGN

untereiner's avatar
untereiner committed
136 137
#include "Algo/Tiling/tiling.hpp"

Lionel Untereiner's avatar
Lionel Untereiner committed
138
#endif //_TILING_H_