subdivision.h 5.16 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1 2 3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
*                                                                              *
* 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.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21 22 23 24
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

25 26
#ifndef __SUBDIVISION_H__
#define __SUBDIVISION_H__
Pierre Kraemer's avatar
Pierre Kraemer committed
27 28 29

#include <math.h>
#include <vector>
Sylvain Thery's avatar
Sylvain Thery committed
30
#include "Algo/Geometry/centroid.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52

namespace CGoGN
{

namespace Algo
{

namespace Modelisation
{

/**
* Triangule a face with central vertex
* @param d dart of face
* @return a dart of the central vertex
*/
template <typename PFP>
Dart trianguleFace(typename PFP::MAP& map, Dart d);

/**
 * Triangule all the faces of the mesh
 */
template <typename PFP, typename EMBV, typename EMB>
Pierre Kraemer's avatar
Pierre Kraemer committed
53
void trianguleFaces(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected = allDarts) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
54

55
template <typename PFP>
56
void trianguleFaces(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& selected = allDarts) ;
57

Pierre Kraemer's avatar
Pierre Kraemer committed
58 59 60 61 62 63 64
/**
 * Triangule all the faces of the mesh
 * positions for new vertices are given as face attribute
 */
template <typename PFP>
void trianguleFaces(
	typename PFP::MAP& map,
65
	VertexAttribute<typename PFP::VEC3>& position, const FaceAttribute<typename PFP::VEC3>& positionF,
Pierre Kraemer's avatar
Pierre Kraemer committed
66
	const FunctorSelect& selected = allDarts) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
67

Pierre Kraemer's avatar
Pierre Kraemer committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81
/**
* Quadrangule a face with central vertex
* warning: edges are considered here as already cut !!
* A face with 2n edges give n quads
* @param d dart of face with belong to a vertex introduce when cutting the edge
* @return a dart of central point
*/
template <typename PFP>
Dart quadranguleFace(typename PFP::MAP& map, Dart d);

/**
 * Quadrangule all the faces of the mesh
 */
template <typename PFP, typename EMBV, typename EMB>
Pierre Kraemer's avatar
Pierre Kraemer committed
82
void quadranguleFaces(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected = allDarts) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
83

84
template <typename PFP>
85
void quadranguleFaces(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& selected = allDarts) ;
86

Pierre Kraemer's avatar
Pierre Kraemer committed
87 88 89 90
/**
 * Catmull-Clark subdivision scheme
 */
template <typename PFP, typename EMBV, typename EMB>
Pierre Kraemer's avatar
Pierre Kraemer committed
91
void CatmullClarkSubdivision(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected = allDarts) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
92

93
template <typename PFP>
94
void CatmullClarkSubdivision(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& selected = allDarts) ;
95

Pierre Kraemer's avatar
Pierre Kraemer committed
96 97 98 99
/**
 * Loop subdivision scheme
 */
template <typename PFP, typename EMBV, typename EMB>
Pierre Kraemer's avatar
Pierre Kraemer committed
100
void LoopSubdivision(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected = allDarts) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
101

102
template <typename PFP>
103
void LoopSubdivision(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& selected = allDarts) ;
104

105 106 107 108

template <typename PFP, typename EMBV, typename EMB>
void TwoNPlusOneSubdivision(typename PFP::MAP& map, EMBV& attributs, const FunctorSelect& selected = allDarts) ;

109 110 111 112 113 114
/**
 * Reverse the orientation of the map
 */
template <typename PFP>
void reverseOrientation(typename PFP::MAP& map) ;

Sylvain Thery's avatar
Sylvain Thery committed
115 116 117 118 119 120
/**
 * Doo-Sabin subdivision scheme
 */
template <typename PFP>
void DooSabin(typename PFP::MAP& map, VertexAttribute<typename PFP::VEC3>& position);

Pierre Kraemer's avatar
Pierre Kraemer committed
121 122 123 124 125 126 127 128 129 130 131
///**
// * Dual mesh computation
// */
//template <typename PFP>
//void computeDual(typename PFP::MAP& map, const FunctorSelect& selected = allDarts) ;

///**
// * Sqrt(3) subdivision scheme
// */
//template <typename PFP>
//void Sqrt3Subdivision(typename PFP::MAP& map, typename PFP::TVEC3& position, const FunctorSelect& selected = allDarts) ;
132 133


Sylvain Thery's avatar
Sylvain Thery committed
134 135


Pierre Kraemer's avatar
Pierre Kraemer committed
136 137 138 139 140 141 142 143 144
} // namespace Modelisation

} // namespace Algo

} // namespace CGoGN

#include "Algo/Modelisation/subdivision.hpp"

#endif