Go to the documentation of this file.
4 #ifndef tools_sg_pick_action
5 #define tools_sg_pick_action
10 #include "../lina/plane"
44 const std::vector<float>&
zs()
const {
return m_zs;}
45 std::vector<float>&
zs() {
return m_zs;}
47 const std::vector<float>&
ws()
const {
return m_ws;}
48 std::vector<float>&
ws() {
return m_ws;}
63 virtual bool project(
float& a_x,
float& a_y,
float& a_z,
float& a_w) {
64 return parent::project_point(a_x,a_y,a_z,a_w);
67 virtual bool add_point(
float a_x,
float a_y,
float a_z,
float a_w) {
75 virtual bool add_point(
float a_x,
float a_y,
float a_z,
float a_w,
76 float,
float,
float,
float) {
80 virtual bool add_line(
float a_bx,
float a_by,
float a_bz,
float a_bw,
81 float a_ex,
float a_ey,
float a_ez,
float a_ew) {
91 a_ex,a_ey,a_ez,a_ew)) {
98 virtual bool add_line(
float a_bx,
float a_by,
float a_bz,
float a_bw,
99 float,
float,
float,
float,
100 float a_ex,
float a_ey,
float a_ez,
float a_ew,
101 float,
float,
float,
float){
105 virtual bool add_triangle(
float a_p1x,
float a_p1y,
float a_p1z,
float a_p1w,
106 float a_p2x,
float a_p2y,
float a_p2z,
float a_p2w,
107 float a_p3x,
float a_p3y,
float a_p3z,
float a_p3w){
109 a_p2x,a_p2y,a_p2z,a_p2w,
110 a_p3x,a_p3y,a_p3z,a_p3w)) {
117 virtual bool add_triangle(
float a_p1x,
float a_p1y,
float a_p1z,
float a_p1w,
118 float,
float,
float,
float,
119 float a_p2x,
float a_p2y,
float a_p2z,
float a_p2w,
120 float,
float,
float,
float,
121 float a_p3x,
float a_p3y,
float a_p3z,
float a_p3w,
122 float,
float,
float,
float){
124 a_p2x,a_p2y,a_p2z,a_p2w,
125 a_p3x,a_p3y,a_p3z,a_p3w);
136 float,
float,
float,
float) {
140 virtual bool add_line_normal(
float a_bx,
float a_by,
float a_bz,
float a_bw,
float,
float,
float,
141 float a_ex,
float a_ey,
float a_ez,
float a_ew,
float,
float,
float) {
144 virtual bool add_line_normal(
float a_bx,
float a_by,
float a_bz,
float a_bw,
float,
float,
float,
float,
float,
float,
float,
145 float a_ex,
float a_ey,
float a_ez,
float a_ew,
float,
float,
float,
float,
float,
float,
float) {
150 float a_p2x,
float a_p2y,
float a_p2z,
float a_p2w,
float,
float,
float,
151 float a_p3x,
float a_p3y,
float a_p3z,
float a_p3w,
float,
float,
float) {
153 a_p2x,a_p2y,a_p2z,a_p2w,
154 a_p3x,a_p3y,a_p3z,a_p3w);
157 float,
float,
float,
float,
float,
float,
float,
158 float a_p2x,
float a_p2y,
float a_p2z,
float a_p2w,
159 float,
float,
float,
float,
float,
float,
float,
160 float a_p3x,
float a_p3y,
float a_p3z,
float a_p3w,
161 float,
float,
float,
float,
float,
float,
float) {
163 a_p2x,a_p2y,a_p2z,a_p2w,
164 a_p3x,a_p3y,a_p3z,a_p3w);
167 pick_action(std::ostream& a_out,
unsigned int a_ww,
unsigned int a_wh,
float a_l,
float a_r,
float a_b,
float a_t)
168 :parent(a_out,a_ww,a_wh)
195 parent::operator=(a_from);
230 void set_area(
float a_l,
float a_r,
float a_b,
float a_t) {
241 void get_area(
float& a_l,
float& a_r,
float& a_b,
float& a_t)
const {
266 const std::vector<float>& a_zs,
267 const std::vector<float>& a_ws,
274 m_out <<
"tools::sg::pick_action :"
275 <<
" number of picks " <<
m_picks.size()
277 std::vector<pick_t>::const_iterator it;
279 m_out <<
" " << (*it).node().s_cls();
281 std::vector<float>::const_iterator itz;
282 for(itz=(*it).zs().begin();itz!=(*it).zs().end();++itz) {
283 m_out <<
" " << *itz;
299 std::vector<pick_t>::const_iterator it;
320 const std::vector<float>&
zs()
const {
return m_zs;}
323 const std::vector<float>&
ws()
const {
return m_ws;}
338 size_t a_floatn,
const float* a_xys,
340 bool a_triangle_revert =
false){
341 if(!a_floatn)
return false;
363 const std::vector<float>& a_xys,
365 bool a_triangle_revert =
false){
366 if(a_xys.empty())
return false;
387 if(!a_floatn)
return false;
408 const std::vector<float>& a_xys,
409 bool a_stop =
false) {
410 if(a_xys.empty())
return false;
432 if(!a_floatn)
return false;
453 if(a_xyzs.empty())
return false;
474 if(!a_floatn)
return false;
497 bool a_stop =
false){
498 if(!a_floatn)
return false;
519 const std::vector<float>& a_xyzs,
520 bool a_stop =
false){
521 if(a_xyzs.empty())
return false;
542 bool is_inside(
float a_x,
float a_y,
float a_z,
float a_w) {
554 if(x<-1)
return false;
555 if(1<x)
return false;
556 if(y<-1)
return false;
557 if(1<y)
return false;
569 float a_ex,
float a_ey,
float a_ez,
float a_ew) {
595 float a_2x,
float a_2y,
float a_2z,
float a_2w,
596 float a_3x,
float a_3y,
float a_3z,
float a_3w) {
599 if(
is_inside(a_1x,a_1y,a_1z,a_1w))
return true;
600 if(
is_inside(a_2x,a_2y,a_2z,a_2w))
return true;
601 if(
is_inside(a_3x,a_3y,a_3z,a_3w))
return true;
611 float bx,by,bz,bw,ex,ey,ez,ew;
670 {
float cp2 = (x2-x1)*(y3-y1)-(y2-y1)*(x3-x1);
671 if(cp2==0)
return false;
672 float cp1 = (x2-x1)*(yo-y1)-(y2-y1)*(xo-x1);
679 if((cp1*cp2)<0)
return false;}
681 {
float cp2 = (x3-x2)*(y1-y2)-(y3-y2)*(x1-x2);
682 if(cp2==0)
return false;
683 float cp1 = (x3-x2)*(yo-y2)-(y3-y2)*(xo-x2);
690 if((cp1*cp2)<0)
return false;}
692 {
float cp2 = (x1-x3)*(y2-y3)-(y1-y3)*(x2-x3);
693 if(cp2==0)
return false;
694 float cp1 = (x1-x3)*(yo-y3)-(y1-y3)*(xo-x3);
701 if((cp1*cp2)<0)
return false;}
713 {
vec3f p1(x1,y1,a_1z);
714 vec3f p2(x2,y2,a_2z);
715 vec3f p3(x3,y3,a_3z);
718 m_out <<
"pick_action::intersect_triangle :"
719 <<
" z plane/line intersection failed."
729 {
vec3f p1(x1,y1,a_1w);
730 vec3f p2(x2,y2,a_2w);
731 vec3f p3(x3,y3,a_3w);
734 m_out <<
"pick_action::intersect_triangle :"
735 <<
" plane/line intersection failed."
745 m_zs.push_back(pz[2]);
746 m_ws.push_back(pw[2]);
818 void to_pick_ndc(
const float& a_fx,
const float& a_fy,
float& a_x,
float& a_y)
const {
824 float& a_ex,
float& a_ey,
float& a_ez,
float& a_ew,
841 const unsigned int FILTER__NOZ = 0xf;
847 unsigned int bout =
ortho_out(a_bx,a_by);
848 unsigned int eout =
ortho_out(a_ex,a_ey);
849 bool reject = ( (bout & eout & FILTER__NOZ) !=0 ?
true :
false);
853 accept = !bout && !eout;
858 unsigned int tout = eout;
879 float t = a_ey - a_by;
882 a_bx += (a_ex - a_bx) * t;
884 a_bz += (a_ez - a_bz) * t;
885 a_bw += (a_ew - a_bw) * t;
886 }
else if(bout & (1<<1)) {
890 a_bx += (a_ex - a_bx) * t;
892 a_bz += (a_ez - a_bz) * t;
893 a_bw += (a_ew - a_bw) * t;
894 }
else if(bout & (1<<2)) {
899 a_by += (a_ey - a_by) * t;
900 a_bz += (a_ez - a_bz) * t;
901 a_bw += (a_ew - a_bw) * t;
902 }
else if(bout & (1<<3)) {
907 a_by += (a_ey - a_by) * t;
908 a_bz += (a_ez - a_bz) * t;
909 a_bw += (a_ew - a_bw) * t;
938 unsigned int out = 0;
939 if(a_y> 1)
out |= (1<<0);
940 if(a_y<-1)
out |= (1<<1);
941 if(a_x> 1)
out |= (1<<2);
942 if(a_x<-1)
out |= (1<<3);
#define TOOLS_ACTION(a__class, a__sclass, a__parent)