g4tools  5.4.0
sf_rotf
Go to the documentation of this file.
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> {
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:
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
tools::sg::sf_rotf::sf_rotf
sf_rotf(const rotf &a_value)
Definition: sf_rotf:51
tools::sg::sf_rotf::sf_rotf
sf_rotf()
Definition: sf_rotf:50
tools::sg::sf_rotf::sf_rotf
sf_rotf(const sf_rotf &a_from)
Definition: sf_rotf:54
tools::sg::bsf
Definition: bsf:19
tools::rotf
Definition: rotf:16
tools::sg::bsf< rotf >::m_value
rotf m_value
Definition: bsf:120
tools::io::irbuf::read_vec
virtual bool read_vec(uint32 &, uchar *&)=0
tools::sg::sf_rotf::setValue
void setValue(const rotf &a_value)
Definition: sf_rotf:68
tools::sg::sf_rotf::write
virtual bool write(io::iwbuf &a_buffer)
Definition: sf_rotf:19
tools::sg::field
Definition: field:25
tools::qrot::quat
const VEC4 & quat() const
Definition: qrot:366
tools::sg::sf_rotf::dump
virtual bool dump(std::ostream &)
Definition: sf_rotf:43
tools::sg::sf_rotf::read
virtual bool read(io::irbuf &a_buffer)
Definition: sf_rotf:24
tools::sg::field::operator=
field & operator=(const field &)
Definition: field:57
tools::io::iwbuf::write_vec
virtual bool write_vec(uint32, const uchar *)=0
TOOLS_HEADER
#define TOOLS_HEADER(a__class, a__sclass, a__parent)
Definition: HEADER:10
tools::vec4::size
size_type size() const
Definition: vec4:259
sf
tools::vec3f
Definition: vec3f:13
tools::sg::sf_rotf
Definition: sf_rotf:16
tools::sg::sf_rotf::s_value
virtual bool s_value(std::string &a_s) const
Definition: sf_rotf:47
tools
inlined C code : ///////////////////////////////////
Definition: aida_ntuple:26
tools::io::irbuf
Definition: irbuf:19
tools::sg::sf_rotf::~sf_rotf
virtual ~sf_rotf()
Definition: sf_rotf:52
tools::sg::sf_rotf::s2value
virtual bool s2value(const std::string &)
Definition: sf_rotf:48
tools::sg::get_data
const std::string * get_data(const std::vector< std::string > &a_v)
Definition: mf:191
tools::io::iwbuf
Definition: iwbuf:15
tools::sg::sf_rotf::operator=
sf_rotf & operator=(const sf_rotf &a_from)
Definition: sf_rotf:55
tools::sg::bsf< rotf >::value
rotf & value()
Definition: bsf:98
tools::vec4< float >
tools::uint32
unsigned int uint32
Definition: typedefs:71
tools::sg::sf_rotf::setValue
void setValue(const vec3f &a_axis, float a_angle)
Definition: sf_rotf:65
tools::sg::sf_rotf::operator=
sf_rotf & operator=(const rotf &a_value)
Definition: sf_rotf:60