Warning, /include/Geant4/tools/sg/bbox_action is written in an unsupported language. File is not indexed.
0001 // Copyright (C) 2010, Guy Barrand. All rights reserved.
0002 // See the file tools.license for terms.
0003
0004 #ifndef tools_sg_bbox_action
0005 #define tools_sg_bbox_action
0006
0007 #include "matrix_action"
0008 #include "primitive_visitor"
0009
0010 #include "../lina/box3f"
0011
0012 namespace tools {
0013 namespace sg {
0014
0015 class bbox_action : public matrix_action,public primitive_visitor {
0016 TOOLS_ACTION(bbox_action,tools::sg::bbox_action,matrix_action)
0017 protected:
0018 virtual bool project(float& a_x,float& a_y,float& a_z,float& a_w) {
0019 model_point(a_x,a_y,a_z,a_w);
0020 return true;
0021 }
0022
0023 virtual bool add_point(float a_x,float a_y,float a_z,float) {
0024 m_box.extend_by(a_x,a_y,a_z);
0025 return true;
0026 }
0027
0028 virtual bool add_point(float a_x,float a_y,float a_z,float,
0029 float,float,float,float) {
0030 m_box.extend_by(a_x,a_y,a_z);
0031 return true;
0032 }
0033
0034 virtual bool add_line(float a_bx,float a_by,float a_bz,float,
0035 float a_ex,float a_ey,float a_ez,float) {
0036 m_box.extend_by(a_bx,a_by,a_bz);
0037 m_box.extend_by(a_ex,a_ey,a_ez);
0038 return true;
0039 }
0040
0041 virtual bool add_line(float a_bx,float a_by,float a_bz,float a_bw,
0042 float,float,float,float,
0043 float a_ex,float a_ey,float a_ez,float a_ew,
0044 float,float,float,float) {
0045 return add_line(a_bx,a_by,a_bz,a_bw,
0046 a_ex,a_ey,a_ez,a_ew);
0047 }
0048
0049 virtual bool add_triangle(float a_p1x,float a_p1y,float a_p1z,float,
0050 float a_p2x,float a_p2y,float a_p2z,float,
0051 float a_p3x,float a_p3y,float a_p3z,float){
0052 m_box.extend_by(a_p1x,a_p1y,a_p1z);
0053 m_box.extend_by(a_p2x,a_p2y,a_p2z);
0054 m_box.extend_by(a_p3x,a_p3y,a_p3z);
0055 return true;
0056 }
0057
0058 virtual bool add_triangle(float a_p1x,float a_p1y,float a_p1z,float a_p1w,
0059 float,float,float,float,
0060 float a_p2x,float a_p2y,float a_p2z,float a_p2w,
0061 float,float,float,float,
0062 float a_p3x,float a_p3y,float a_p3z,float a_p3w,
0063 float,float,float,float){
0064 return bbox_action::add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
0065 a_p2x,a_p2y,a_p2z,a_p2w,
0066 a_p3x,a_p3y,a_p3z,a_p3w);
0067 }
0068
0069 virtual bool project_normal(float&,float&,float&) {return true;}
0070 virtual bool add_point_normal(float a_x,float a_y,float a_z,float a_w,
0071 float,float,float) {
0072 return bbox_action::add_point(a_x,a_y,a_z,a_w);
0073 }
0074
0075 virtual bool add_point_normal(float a_x,float a_y,float a_z,float a_w,
0076 float,float,float,
0077 float,float,float,float) {
0078 return bbox_action::add_point(a_x,a_y,a_z,a_w);
0079 }
0080
0081 virtual bool add_line_normal(float a_bx,float a_by,float a_bz,float a_bw, float,float,float,
0082 float a_ex,float a_ey,float a_ez,float a_ew, float,float,float) {
0083 return bbox_action::add_line(a_bx,a_by,a_bz,a_bw,a_ex,a_ey,a_ez,a_ew);
0084 }
0085 virtual bool add_line_normal(float a_bx,float a_by,float a_bz,float a_bw, float,float,float, float,float,float,float,
0086 float a_ex,float a_ey,float a_ez,float a_ew, float,float,float, float,float,float,float) {
0087 return bbox_action::add_line(a_bx,a_by,a_bz,a_bw,a_ex,a_ey,a_ez,a_ew);
0088 }
0089
0090 virtual bool add_triangle_normal(float a_p1x,float a_p1y,float a_p1z,float a_p1w, float,float,float,
0091 float a_p2x,float a_p2y,float a_p2z,float a_p2w, float,float,float,
0092 float a_p3x,float a_p3y,float a_p3z,float a_p3w, float,float,float) {
0093 return bbox_action::add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
0094 a_p2x,a_p2y,a_p2z,a_p2w,
0095 a_p3x,a_p3y,a_p3z,a_p3w);
0096 }
0097 virtual bool add_triangle_normal(float a_p1x,float a_p1y,float a_p1z,float a_p1w,
0098 float,float,float, float,float,float,float,
0099 float a_p2x,float a_p2y,float a_p2z,float a_p2w,
0100 float,float,float, float,float,float,float,
0101 float a_p3x,float a_p3y,float a_p3z,float a_p3w,
0102 float,float,float, float,float,float,float) {
0103 return bbox_action::add_triangle(a_p1x,a_p1y,a_p1z,a_p1w,
0104 a_p2x,a_p2y,a_p2z,a_p2w,
0105 a_p3x,a_p3y,a_p3z,a_p3w);
0106 }
0107 public:
0108 bbox_action(std::ostream& a_out)
0109 :parent(a_out,0,0)
0110 {}
0111 virtual ~bbox_action(){}
0112 public:
0113 bbox_action(const bbox_action& a_from)
0114 :parent(a_from)
0115 ,primitive_visitor(a_from)
0116 {}
0117 bbox_action& operator=(const bbox_action& a_from){
0118 if(&a_from==this) return *this;
0119 parent::operator=(a_from);
0120 primitive_visitor::operator=(a_from);
0121 m_box.make_empty();
0122 return *this;
0123 }
0124 public:
0125 void reset() {
0126 parent::reset();
0127 m_box.make_empty();
0128 }
0129 const box3f& box() const {return m_box;}
0130 box3f& box() {return m_box;}
0131 protected:
0132 box3f m_box;
0133 };
0134
0135 }}
0136
0137 #endif