extrusion.h 8.69 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
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef EXTRUSION_H
#define EXTRUSION_H

#include <math.h>
#include <vector>
#include "Algo/Modelisation/polyhedron.h"

#include "Algo/Modelisation/subdivision.h"
#include "Algo/Geometry/normal.h"

namespace CGoGN
{

namespace Algo
{

namespace Modelisation
{

/**
* extrusion with scale
* WARNING: this function use OpenGL to create transformation matrix !
* @param the_map the map in which include created surface
* @param profile vector of points that describe the profile (must be almost coplanar for best result)
* @param center profile virtual point defined as the center of the profile (follow the path)
* @param normalProfile normal direction of profile plane
* @param profile_closed profile is a closed polygon or not ?
* @param path the vector of points that define the path to follow
* @param path_closed path is a closed polygon or not ?
* @param scalePath a vector of scale value to apply on profile at each node of path,
* size of vector must be the same as path
*/
template<typename PFP>
58
Dart extrusion_scale(typename PFP::MAP& the_map, VertexAttribute<typename PFP::VEC3>& positions,
Pierre Kraemer's avatar
Pierre Kraemer committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
	const std::vector<typename PFP::VEC3>& profile,
	const typename PFP::VEC3& centerProfile,
	const typename PFP::VEC3& normalProfile,
	bool profile_closed,
	const std::vector<typename PFP::VEC3>& path,
	bool path_closed,
	const std::vector<float>& scalePath);

/**
* extrusion with scale, return a Polyhedron that can be easily transform
* WARNING: this function use OpenGL to create transformation matrix !
* WARNING: return a pointer on Polyhedron it is up to the use to delete this Polyhedron
* @param the_map the map in which include created surface
* @param profile vector of points that describe the profile (must be almost coplanar for best result)
* @param center profile virtual point defined as the center of the profile (follow the path)
* @param normalProfile normal direction of profile plane
* @param profile_closed profile is a closed polygon or not ?
* @param path the vector of points that define the path to follow
* @param path_closed path is a closed polygon or not ?
* @param scalePath a vector of scale value to apply on profile at each node of path,
* size of vector must be the same as path
*/
template<typename PFP>
82
Polyhedron<PFP>* extrusion_scale_prim(typename PFP::MAP& the_map, VertexAttribute<typename PFP::VEC3>& positions,
Pierre Kraemer's avatar
Pierre Kraemer committed
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
	const std::vector<typename PFP::VEC3>& profile,
	const typename PFP::VEC3& centerProfile,
	const typename PFP::VEC3& normalProfile,
	bool profile_closed,
	const std::vector<typename PFP::VEC3>& path,
	bool path_closed,
	const std::vector<float>& scalePath);

/**
* extrusion with scale, return a Polyhedron that can be easily transform
* WARNING: this function use OpenGL to create transformation matrix !
* WARNING: return a pointer on Polyhedron it is up to the use to delete this Polyhedron
* @param the_map the map in which include created surface
* @param profile vector of points that describe the profile (must be almost coplanar for best result)
* @param center profile virtual point defined as the center of the profile (follow the path)
* @param normalProfile normal direction of profile plane
* @param profile_closed profile is a closed polygon or not ?
* @param path the vector of points that define the path to follow
* @param path_closed path is a closed polygon or not ?
* @param scalePath a vector of scale value to apply on profile at each node of path,
* size of vector must be the same as path
*/
template<typename PFP>
106
Polyhedron<PFP>* extrusion_prim(typename PFP::MAP& the_map, VertexAttribute<typename PFP::VEC3>& positions,
Pierre Kraemer's avatar
Pierre Kraemer committed
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
	const std::vector<typename PFP::VEC3>& profile,
	const typename PFP::VEC3& centerProfile,
	const typename PFP::VEC3& normalProfile,
	bool profile_closed,
	const std::vector<typename PFP::VEC3>& path,
	bool path_closed);

/**
* extrusion!
* WARNING: this function use OpenGL to create transformation matrix !
* @param the_map the map in which include created surface
* @param profile vector of points that describe the profile (must be almost coplanar for best result)
* @param centerProfile virtual point defined as the center of the profile (follow the path)
* @param normalProfile normal direction of profile plane
* @param profile_closed profile is a closed polygon or not ?
* @param path the vector of points that define the path to follow
* @param path_closed path is a closed polygon or not ?
* size of vector must be the same as path
*/
template<typename PFP>
127
Dart extrusion(typename PFP::MAP& the_map, VertexAttribute<typename PFP::VEC3>& positions,
Pierre Kraemer's avatar
Pierre Kraemer committed
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
	const std::vector<typename PFP::VEC3>& profile,
	const typename PFP::VEC3& centerProfile,
	const typename PFP::VEC3& normal,
	bool profile_closed,
	const std::vector<typename PFP::VEC3>& path,
	bool path_closed);

/**
* revolution!
* WARNING: this function use OpenGL to create transformation matrix !
* @param the_map the map in which include created surface
* @param profile vector of points that describe the profile (must be almost coplanar for best result)
* @param center center (point) of axis revolution
* @param axis direction of axis revolution
* @param profile_closed profile is a closed polygon or not ?
* @param nbSide number of steps around the revolution
*/
template<typename PFP>
146
Polyhedron<PFP>* revolution_prim(typename PFP::MAP& the_map, VertexAttribute<typename PFP::VEC3>& positions,
Pierre Kraemer's avatar
Pierre Kraemer committed
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
	const std::vector<typename PFP::VEC3>& profile,
	const typename PFP::VEC3& center,
	const typename PFP::VEC3& axis,
	bool profile_closed,
	int nbSides);

/**
* revolution!
* WARNING: this function use OpenGL to create transformation matrix !
* @param the_map the map in which include created surface
* @param profile vector of points that describe the profile (must be almost coplanar for best result)
* @param center center (point) of axis revolution
* @param axis direction of axis revolution
* @param profile_closed profile is a closed polygon or not ?
* @param nbSide number of steps around the revolution
*/
template<typename PFP>
164
Dart revolution(typename PFP::MAP& the_map, VertexAttribute<typename PFP::VEC3>& positions,
Pierre Kraemer's avatar
Pierre Kraemer committed
165
166
167
168
169
170
171
172
173
174
175
176
177
	const std::vector<typename PFP::VEC3>& profile,
	const typename PFP::VEC3& center,
	const typename PFP::VEC3& axis,
	bool profile_closed,
	int nbSides);

/**
* Face extrusion
* @param the_map the map in which include created surface
* @param d a dart of the face to extrude
* @param N the vector use to extrude face center (point) of axis revolution
*/
template<typename PFP>
178
Dart extrudeFace(typename PFP::MAP& the_map, VertexAttribute<typename PFP::VEC3>& positions,
Pierre Kraemer's avatar
Pierre Kraemer committed
179
180
181
182
183
184
	Dart d,	const typename PFP::VEC3& N);

/**
* Face extrusion
* @param the_map the map in which include created surface
* @param d a dart of the face to extrude
Jund Thomas's avatar
Jund Thomas committed
185
* @param dist the height to extrude face
Pierre Kraemer's avatar
Pierre Kraemer committed
186
187
*/
template<typename PFP>
188
Dart extrudeFace(typename PFP::MAP& the_map, VertexAttribute<typename PFP::VEC3>& positions,
Pierre Kraemer's avatar
Pierre Kraemer committed
189
190
	Dart d,	float dist);

Pierre Kraemer's avatar
Pierre Kraemer committed
191
192
193
194
195
} // namespace Modelisation

} // namespace Algo

} // namespace CGoGN
Pierre Kraemer's avatar
Pierre Kraemer committed
196
197
198
199

#include "Algo/Modelisation/extrusion.hpp"

#endif