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_sf_rotf 5 #define tools_sg_sf_rotf 6 7 #include "sf" 8 9 #include "../lina/rotf" 10 11 #include "../HEADER" 12 13 namespace tools { 14 namespace sg { 15 16 class sf_rotf : public bsf<rotf> { 17 TOOLS_HEADER(sf_rotf,tools::sg::sf_rotf,bsf<rotf>) 18 public: 19 virtual bool write(io::iwbuf& a_buffer) { 20 const vec4<float>& vec = m_value.quat(); 21 const float* d = get_data(vec); 22 return a_buffer.write_vec(vec.size(),d); 23 } 24 virtual bool read(io::irbuf& a_buffer) { 25 vec4<float>& vec = m_value.quat(); 26 uint32 n; 27 float* v; 28 if(!a_buffer.read_vec(n,v)) return false; 29 if(n!=vec.size()) { 30 delete [] v; 31 #ifdef TOOLS_MEM 32 mem::decrement(s_new().c_str()); 33 #endif 34 return false; 35 } 36 for(uint32 index=0;index<n;index++) vec[index] = v[index]; 37 delete [] v; 38 #ifdef TOOLS_MEM 39 mem::decrement(s_new().c_str()); 40 #endif 41 return true; 42 } 43 virtual bool dump(std::ostream&) { 44 //a_out << parent::m_value << std::endl; 45 return true; 46 } 47 virtual bool s_value(std::string& a_s) const {a_s.clear();return false;} 48 virtual bool s2value(const std::string&) {return false;} 49 public: 50 sf_rotf():parent(){} 51 sf_rotf(const rotf& a_value):parent(a_value){} 52 virtual ~sf_rotf(){} 53 public: 54 sf_rotf(const sf_rotf& a_from):parent(a_from){} 55 sf_rotf& operator=(const sf_rotf& a_from){ 56 parent::operator=(a_from); 57 return *this; 58 } 59 public: 60 sf_rotf& operator=(const rotf& a_value){ 61 parent::operator=(a_value); 62 return *this; 63 } 64 public: //iv2ps 65 void setValue(const vec3f& a_axis,float a_angle) { 66 value(rotf(a_axis,a_angle)); 67 } 68 void setValue(const rotf& a_value) { 69 value(a_value); 70 } 71 }; 72 73 }} 74 75 #endif