Warning, /include/Geant4/tools/sg/gstos_add 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_gstos_add
0005 #define tools_sg_gstos_add
0006
0007 #include "../vmanip"
0008 #include "../glprims"
0009 #include "../lina/mat4f"
0010
0011 namespace tools {
0012 namespace sg {
0013
0014 class gstos_add {
0015 public:
0016 gstos_add(){}
0017 virtual ~gstos_add(){}
0018 public:
0019 gstos_add(const gstos_add&) {}
0020 gstos_add& operator=(const gstos_add&){return *this;}
0021 public:
0022 void clear() {m_xyzs.clear();m_nms.clear();}
0023
0024 void add_points(size_t a_floatn,const float* a_xyzs) {
0025 append(m_xyzs,a_floatn,a_xyzs);
0026 }
0027 void add_lines(size_t a_floatn,const float* a_xyzs) {
0028 append(m_xyzs,a_floatn,a_xyzs);
0029 }
0030 void add_line_strip(size_t a_floatn,const float* a_xyzs) {
0031 size_t num = a_floatn/3;
0032 if(num<2) return;
0033 size_t nxyzs = (num-1)*2*3;
0034 size_t offset = m_xyzs.size();
0035 m_xyzs.resize(offset+nxyzs);
0036 float* pxyzs = (m_xyzs.data())+offset;
0037 gl::line_strip_to_lines(num,a_xyzs,pxyzs);
0038 }
0039 void add_line_loop(size_t a_floatn,const float* a_xyzs) {
0040 size_t num = a_floatn/3;
0041 if(num<2) return;
0042 size_t nxyzs = num*2*3;
0043 size_t offset = m_xyzs.size();
0044 m_xyzs.resize(offset+nxyzs);
0045 float* pxyzs = (m_xyzs.data())+offset;
0046 gl::line_loop_to_lines(num,a_xyzs,pxyzs);
0047 }
0048 void add_triangles_normal(size_t a_floatn,const float* a_xyzs,const float* a_nms) {
0049 append(m_xyzs,a_floatn,a_xyzs);
0050 append(m_nms,a_floatn,a_nms);
0051 }
0052 void add_triangle_strip_normal(size_t a_floatn,const float* a_xyzs,const float* a_nms) {
0053 size_t num = a_floatn/3;
0054 if(num<3) return;
0055 size_t nxyzs = (num-2)*3*3;
0056 size_t offset = m_xyzs.size();
0057 m_xyzs.resize(offset+nxyzs);
0058 float* pxyzs = (m_xyzs.data())+offset;
0059 offset = m_nms.size();
0060 m_nms.resize(offset+nxyzs);
0061 float* pnms = (m_nms.data())+offset;
0062 gl::triangle_strip_to_triangles_nms(num,a_xyzs,a_nms,pxyzs,pnms);
0063 }
0064 void add_triangle_fan_normal(size_t a_floatn,const float* a_xyzs,const float* a_nms) {
0065 size_t num = a_floatn/3;
0066 if(num<3) return;
0067 size_t nxyzs = (num-2)*3*3;
0068 size_t offset = m_xyzs.size();
0069 m_xyzs.resize(offset+nxyzs);
0070 float* pxyzs = (m_xyzs.data())+offset;
0071 offset = m_nms.size();
0072 m_nms.resize(offset+nxyzs);
0073 float* pnms = (m_nms.data())+offset;
0074 gl::triangle_fan_to_triangles_nms(num,a_xyzs,a_nms,pxyzs,pnms);
0075 }
0076
0077 void add_triangle_strip_as_triangles(size_t a_floatn,const float* a_xyzs,const float* a_nms) { //used in sg::sphere, icosahedron_sphere.
0078 add_triangle_strip_normal(a_floatn,a_xyzs,a_nms);
0079 }
0080
0081 public:
0082 std::vector<float> m_xyzs;
0083 std::vector<float> m_nms;
0084
0085 size_t m_gsto_points_sz;
0086 size_t m_gsto_lines_sz;
0087 size_t m_gsto_tris_sz;
0088 size_t m_gsto_nms_sz;
0089 };
0090
0091 }}
0092
0093 #endif