MorphoGraphX
2.0-1-227
src
LassoSelect.hpp
Go to the documentation of this file.
1
#ifndef LASSOSELECT_H
2
#define LASSOSELECT_H
3
#include<vector>
4
#include<
Geometry.hpp
>
5
using
mgx::Point3f
;
6
7
class
LassoSelect
{
8
public
:
9
bool
LassoContains
(
Point3f
v){
10
11
int
int_count = 0;
12
for
(
uint
i=0;i<
contour
.size();i++){
13
Point3f
p1 =
contour
[i];
14
Point3f
p2 =
contour
[(i+1)%
contour
.size()];
15
if
( (v.y()-p1.y())*(v.y()-p2.y())<0){
16
if
(v.x()>p1.x() && v.x()>p2.x())
17
int_count++;
18
else
if
( (v.x()-p1.x())*(v.x()-p2.x())<0 ){
19
float
side = ((p2-p1)%(v-p1)).z();
20
side *= (p2-p1).y()>0? -1:1;
21
if
(side>0)
22
int_count++;
23
}
24
}
25
26
}
27
return
int_count%2;
28
}
29
30
void
AddPoint
(
Point3f
v){
contour
.push_back(v);};
31
void
Clear
(){
contour
.clear();};
32
//member variables
33
std::vector<Point3f>
contour
;
34
35
};
36
37
38
#endif
LassoSelect::LassoContains
bool LassoContains(Point3f v)
Definition:
LassoSelect.hpp:9
uint
unsigned int uint
Definition:
MorphoGraphX.hpp:14
LassoSelect
Definition:
LassoSelect.hpp:7
LassoSelect::contour
std::vector< Point3f > contour
Definition:
LassoSelect.hpp:31
Geometry.hpp
mgx::Point3f
Vector< 3, float > Point3f
Definition:
CuttingSurface.hpp:25
LassoSelect::AddPoint
void AddPoint(Point3f v)
Definition:
LassoSelect.hpp:30
LassoSelect::Clear
void Clear()
Definition:
LassoSelect.hpp:31
Generated on Fri Jul 9 2021 18:34:54 for MorphoGraphX by
1.8.17