Geant4 Cross Reference |
1 // Copyright (C) 2010, Guy Barrand. All rights reserved. 2 // See the file tools.license for terms. 3 4 #ifndef tools_sg_bbox_action 5 #define tools_sg_bbox_action 6 7 #include "matrix_action" 8 #include "primitive_visitor" 9 10 #include "../lina/box3f" 11 12 namespace tools { 13 namespace sg { 14 15 class bbox_action : public matrix_action,public primitive_visitor { 16 TOOLS_ACTION(bbox_action,tools::sg::bbox_action,matrix_action) 17 protected: 18 virtual bool project(float& a_x,float& a_y,float& a_z,float& a_w) { 19 model_point(a_x,a_y,a_z,a_w); 20 return true; 21 } 22 23 virtual bool add_point(float a_x,float a_y,float a_z,float) { 24 m_box.extend_by(a_x,a_y,a_z); 25 return true; 26 } 27 28 virtual bool add_point(float a_x,float a_y,float a_z,float, 29 float,float,float,float) { 30 m_box.extend_by(a_x,a_y,a_z); 31 return true; 32 } 33 34 virtual bool add_line(float a_bx,float a_by,float a_bz,float, 35 float a_ex,float a_ey,float a_ez,float) { 36 m_box.extend_by(a_bx,a_by,a_bz); 37 m_box.extend_by(a_ex,a_ey,a_ez); 38 return true; 39 } 40 41 virtual bool add_line(float a_bx,float a_by,float a_bz,float a_bw, 42 float,float,float,float, 43 float a_ex,float a_ey,float a_ez,float a_ew, 44 float,float,float,float) { 45 return add_line(a_bx,a_by,a_bz,a_bw, 46 a_ex,a_ey,a_ez,a_ew); 47 } 48 49 virtual bool add_triangle(float a_p1x,float a_p1y,float a_p1z,float, 50 float a_p2x,float a_p2y,float a_p2z,float, 51 float a_p3x,float a_p3y,float a_p3z,float){ 52 m_box.extend_by(a_p1x,a_p1y,a_p1z); 53 m_box.extend_by(a_p2x,a_p2y,a_p2z); 54 m_box.extend_by(a_p3x,a_p3y,a_p3z); 55 return true; 56 } 57 58 virtual bool add_triangle(float a_p1x,float a_p1y,float a_p1z,float a_p1w, 59 float,float,float,float, 60 float a_p2x,float a_p2y,float a_p2z,float a_p2w, 61 float,float,float,float, 62 float a_p3x,float a_p3y,float a_p3z,float a_p3w, 63 float,float,float,float){ 64 return bbox_action::add_triangle(a_p1x,a_p1y,a_p1z,a_p1w, 65 a_p2x,a_p2y,a_p2z,a_p2w, 66 a_p3x,a_p3y,a_p3z,a_p3w); 67 } 68 69 virtual bool project_normal(float&,float&,float&) {return true;} 70 virtual bool add_point_normal(float a_x,float a_y,float a_z,float a_w, 71 float,float,float) { 72 return bbox_action::add_point(a_x,a_y,a_z,a_w); 73 } 74 75 virtual bool add_point_normal(float a_x,float a_y,float a_z,float a_w, 76 float,float,float, 77 float,float,float,float) { 78 return bbox_action::add_point(a_x,a_y,a_z,a_w); 79 } 80 81 virtual bool add_line_normal(float a_bx,float a_by,float a_bz,float a_bw, float,float,float, 82 float a_ex,float a_ey,float a_ez,float a_ew, float,float,float) { 83 return bbox_action::add_line(a_bx,a_by,a_bz,a_bw,a_ex,a_ey,a_ez,a_ew); 84 } 85 virtual bool add_line_normal(float a_bx,float a_by,float a_bz,float a_bw, float,float,float, float,float,float,float, 86 float a_ex,float a_ey,float a_ez,float a_ew, float,float,float, float,float,float,float) { 87 return bbox_action::add_line(a_bx,a_by,a_bz,a_bw,a_ex,a_ey,a_ez,a_ew); 88 } 89 90 virtual bool add_triangle_normal(float a_p1x,float a_p1y,float a_p1z,float a_p1w, float,float,float, 91 float a_p2x,float a_p2y,float a_p2z,float a_p2w, float,float,float, 92 float a_p3x,float a_p3y,float a_p3z,float a_p3w, float,float,float) { 93 return bbox_action::add_triangle(a_p1x,a_p1y,a_p1z,a_p1w, 94 a_p2x,a_p2y,a_p2z,a_p2w, 95 a_p3x,a_p3y,a_p3z,a_p3w); 96 } 97 virtual bool add_triangle_normal(float a_p1x,float a_p1y,float a_p1z,float a_p1w, 98 float,float,float, float,float,float,float, 99 float a_p2x,float a_p2y,float a_p2z,float a_p2w, 100 float,float,float, float,float,float,float, 101 float a_p3x,float a_p3y,float a_p3z,float a_p3w, 102 float,float,float, float,float,float,float) { 103 return bbox_action::add_triangle(a_p1x,a_p1y,a_p1z,a_p1w, 104 a_p2x,a_p2y,a_p2z,a_p2w, 105 a_p3x,a_p3y,a_p3z,a_p3w); 106 } 107 public: 108 bbox_action(std::ostream& a_out) 109 :parent(a_out,0,0) 110 {} 111 virtual ~bbox_action(){} 112 public: 113 bbox_action(const bbox_action& a_from) 114 :parent(a_from) 115 ,primitive_visitor(a_from) 116 {} 117 bbox_action& operator=(const bbox_action& a_from){ 118 if(&a_from==this) return *this; 119 parent::operator=(a_from); 120 primitive_visitor::operator=(a_from); 121 m_box.make_empty(); 122 return *this; 123 } 124 public: 125 void reset() { 126 parent::reset(); 127 m_box.make_empty(); 128 } 129 const box3f& box() const {return m_box;} 130 box3f& box() {return m_box;} 131 protected: 132 box3f m_box; 133 }; 134 135 }} 136 137 #endif