raySelector.h 10.4 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
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef RAYSELECTOR_H_
#define RAYSELECTOR_H_

28

Pierre Kraemer's avatar
Pierre Kraemer committed
29 30 31 32 33 34 35 36 37 38 39
#include <vector>
#include "Algo/Selection/raySelectFunctor.hpp"

namespace CGoGN
{

namespace Algo
{

namespace Selection
{
40

Pierre Kraemer's avatar
Pierre Kraemer committed
41 42 43
/**
 * Function that does the selection of faces, returned darts are sorted from closest to farthest
 * @param map the map we want to test
Pierre Kraemer's avatar
Pierre Kraemer committed
44
 * @param position the vertex attribute storing positions
45 46 47
 * @param rayA first point of ray (user side)
 * @param rayAB direction of ray (directed to the scene)
 * @param vecFaces (out) vector to store the darts of intersected faces
Pierre Kraemer's avatar
Pierre Kraemer committed
48
 * @param iPoints (out) vector to store the intersection points
Pierre Kraemer's avatar
Pierre Kraemer committed
49 50
 */
template<typename PFP>
Pierre Kraemer's avatar
Pierre Kraemer committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
void facesRaySelection(
		typename PFP::MAP& map,
		const VertexAttribute<typename PFP::VEC3>& position,
		const typename PFP::VEC3& rayA,
		const typename PFP::VEC3& rayAB,
		std::vector<Dart>& vecFaces,
		std::vector<typename PFP::VEC3>& iPoints);

/**
 * Function that does the selection of faces, returned darts are sorted from closest to farthest
 * @param map the map we want to test
 * @param position the vertex attribute storing positions
 * @param rayA first point of ray (user side)
 * @param rayAB direction of ray (directed to the scene)
 * @param vecFaces (out) vector to store the darts of intersected faces
 */
template<typename PFP>
void facesRaySelection(
		typename PFP::MAP& map,
		const VertexAttribute<typename PFP::VEC3>& position,
		const typename PFP::VEC3& rayA,
		const typename PFP::VEC3& rayAB,
		std::vector<Dart>& vecFaces);

/**
 * Function that does the selection of one face
 * @param map the map we want to test
 * @param position the vertex attribute storing positions
 * @param rayA first point of  ray (user side)
 * @param rayAB vector of ray (directed ot the scene)
 * @param face (out) dart of selected vertex (set to NIL if no face selected)
 */
template<typename PFP>
void faceRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
		const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, Dart& face);
Pierre Kraemer's avatar
Pierre Kraemer committed
86 87 88 89

/**
 * Function that does the selection of edges, returned darts are sorted from closest to farthest
 * @param map the map we want to test
Pierre Kraemer's avatar
Pierre Kraemer committed
90
 * @param position the vertex attribute storing positions
Pierre Kraemer's avatar
Pierre Kraemer committed
91 92 93
 * @param rayA first point of  ray (user side)
 * @param rayAB vector of ray (directed ot the scene)
 * @param vecEdges (out) vector to store dart of intersected edges
94
 * @param dist radius of the cylinder of selection
Pierre Kraemer's avatar
Pierre Kraemer committed
95 96
 */
template<typename PFP>
97
void edgesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
98
				const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecEdges, float distMax);
Pierre Kraemer's avatar
Pierre Kraemer committed
99

Pierre Kraemer's avatar
Pierre Kraemer committed
100 101 102 103 104 105 106 107 108 109 110 111
/**
 * Function that does the selection of one vertex
 * @param map the map we want to test
 * @param position the vertex attribute storing positions
 * @param rayA first point of  ray (user side)
 * @param rayAB vector of ray (directed ot the scene)
 * @param edge (out) dart of selected vertex (set to NIL if no edge selected)
 */
template<typename PFP>
void edgeRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
		const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, Dart& edge);

Pierre Kraemer's avatar
Pierre Kraemer committed
112 113 114
/**
 * Function that does the selection of vertices, returned darts are sorted from closest to farthest
 * @param map the map we want to test
Pierre Kraemer's avatar
Pierre Kraemer committed
115
 * @param position the vertex attribute storing positions
Pierre Kraemer's avatar
Pierre Kraemer committed
116 117
 * @param rayA first point of  ray (user side)
 * @param rayAB vector of ray (directed ot the scene)
118 119
 * @param vecVertices (out) vector to store dart of intersected vertices
 * @param dist radius of the cylinder of selection
Pierre Kraemer's avatar
Pierre Kraemer committed
120 121
 */
template<typename PFP>
122
void verticesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
123
		const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecVertices);
Pierre Kraemer's avatar
Pierre Kraemer committed
124

125 126 127
/**
 * Function that does the selection of one vertex
 * @param map the map we want to test
Pierre Kraemer's avatar
Pierre Kraemer committed
128
 * @param position the vertex attribute storing positions
129 130 131 132
 * @param rayA first point of  ray (user side)
 * @param rayAB vector of ray (directed ot the scene)
 * @param vertex (out) dart of selected vertex (set to NIL if no vertex selected)
 */
133
template<typename PFP>
134
void vertexRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
135
		const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, Dart& vertex);
136

Pierre Kraemer's avatar
Pierre Kraemer committed
137 138 139 140 141 142 143 144
/**
 * Volume selection, not yet functional
 */
template<typename PFP>
void volumesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
		const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecVolumes);


145 146

template<typename PFP>
147
void facesPlanSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
148
		const typename Geom::Plane3D<typename PFP::VEC3::DATA_TYPE>& plan, std::vector<Dart>& vecDartss);
149 150


151 152 153 154 155 156 157 158 159 160 161
/**
 * Function that does the selection of vertices in a cone, returned darts are sorted from closest to farthest
 * @param map the map we want to test
 * @param position the position attribute
 * @param rayA first point of  ray (user side)
 * @param rayAB vector of ray (directed ot the scene)
 * @param angle angle of the code in degree.
 * @param vecVertices (out) vector to store dart of intersected vertices
 */
template<typename PFP>
void verticesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
162
		const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, float angle, std::vector<Dart>& vecVertices);
163

164 165 166 167 168 169 170 171 172 173 174
/**
 * Function that does the selection of edges, returned darts are sorted from closest to farthest
 * @param map the map we want to test
 * @param position the position attribute
 * @param rayA first point of  ray (user side)
 * @param rayAB vector of ray (directed ot the scene)
 * @param angle radius of the cylinder of selection
 * @param vecEdges (out) vector to store dart of intersected edges
 */
template<typename PFP>
void edgesConeSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
175
				const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, float angle, std::vector<Dart>& vecEdges);
176 177


178 179 180 181 182 183 184
/**
 * Function that select the closest vertex in the bubble
 * @param map the map we want to test
 * @param position the position attribute
 * @param cursor the cursor position (center of bubble)
 * @param radiusMax max radius of selection
 */
185
template<typename PFP>
186
Dart verticesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
187
		const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax);
188

189

Pierre Kraemer's avatar
Pierre Kraemer committed
190
/**
191
 * Function that select the closest edge in the bubble
Pierre Kraemer's avatar
Pierre Kraemer committed
192
 * @param map the map we want to test
193 194 195
 * @param position the position attribute
 * @param cursor the cursor position (center of bubble)
 * @param radiusMax max radius of selection
Pierre Kraemer's avatar
Pierre Kraemer committed
196 197
 */
template<typename PFP>
198
Dart edgesBubbleSelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position,
199
		const typename PFP::VEC3& cursor, typename PFP::REAL radiusMax);
200 201 202 203




Pierre Kraemer's avatar
Pierre Kraemer committed
204 205

/**
206 207
 * Fonction that do the selection of darts, returned darts are sorted from closest to farthest
 * Dart is here considered as a triangle formed by the 2 end vertices of the edge and the face centroid
Pierre Kraemer's avatar
Pierre Kraemer committed
208 209 210 211 212
 * @param map the map we want to test
 * @param rayA first point of  ray (user side)
 * @param rayAB vector of ray (directed ot the scene)
 * @param vecDarts (out) vector to store dart of intersected darts
 */
213
//template<typename PFP>
214
//void dartsRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecDarts);
215 216 217 218 219 220 221 222

//namespace Parallel
//{
//template<typename PFP>
//void facesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& good, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecFaces, unsigned int nbth=0, unsigned int current_thread=0);
//template<typename PFP>
//void edgesRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const FunctorSelect& good, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, std::vector<Dart>& vecEdges, float dist, unsigned int nbth=0, unsigned int current_thread=0);
//template<typename PFP>
223
//void vertexRaySelection(typename PFP::MAP& map, const VertexAttribute<typename PFP::VEC3>& position, const typename PFP::VEC3& rayA, const typename PFP::VEC3& rayAB, Dart& vertex, unsigned int nbth=0, unsigned int current_thread=0);
224
//}
225

Pierre Kraemer's avatar
Pierre Kraemer committed
226 227 228 229 230 231
} //namespace Selection

} //namespace Algo

} //namespace CGoGN

232 233
#include "Algo/Selection/raySelector.hpp"

Pierre Kraemer's avatar
Pierre Kraemer committed
234
#endif /* RAYSELECTOR_H_ */