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] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

  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