This repository has been archived by the owner on Dec 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
PickedPoint.h
64 lines (46 loc) · 1.88 KB
/
PickedPoint.h
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
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
58
59
60
61
62
63
64
#ifndef GLPICKEDPOINT_H
#define GLPICKEDPOINT_H
#include <SofaSimpleGUI/config.h>
#include <iostream>
#include <sofa/core/behavior/BaseMechanicalState.h>
using sofa::core::behavior::BaseMechanicalState;
typedef std::size_t nat;
typedef sofa::type::Vec3 Vec3;
namespace sofa::simplegui
{
/**
* @brief The PickedPoint struct represents a vertex of a State, typically picked using the mouse.
* It is returned by the Sofa interface to the user application to set up an interaction.
* We call it valid if it corresponds to a valid index of an existing mechanical state, and invalid if not so (the pointer to the mechanical state is null)
* @author Francois Faure, 2014
*/
struct SOFA_SOFASIMPLEGUI_API PickedPoint
{
BaseMechanicalState::SPtr state; ///< the DOF of the picked object
nat index; ///< index of the particle picked
Vec3 point; ///< location of the picked particle in world space
/// Conversion to boolean for easier test writing. True iff the PickedPoint is valid. Default value is converted to false.
operator bool() const { return state != NULL; }
PickedPoint(BaseMechanicalState::SPtr state=0, nat index=0)
: state(state)
, index(index)
{ }
inline friend std::ostream& operator << ( std::ostream& out, const PickedPoint p){
out << "state: " << p.state->getName() << ", index: " << p.index << ", point: " << p.point;
return out;
}
/// Comparison operator used in maps
bool operator < (const PickedPoint& p ) const {
return state < p.state || index < p.index;
}
/// Comparison operator used in maps
bool operator != (const PickedPoint& p ) const {
return *this<p || p<*this;
}
/// Comparison operator used in maps
bool operator == (const PickedPoint& p ) const {
return ! *this!=p;
}
};
}
#endif // GLPICKEDPOINT_H