Changeset 15 in flair-src for trunk/lib/FlairCore/src/Vector3Ddata.cpp
- Timestamp:
- 04/08/16 15:40:57 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/Vector3Ddata.cpp
r2 r15 25 25 using std::string; 26 26 27 namespace flair { namespace core { 27 namespace flair { 28 namespace core { 28 29 29 /*! \class Vector3DdataElement 30 */ 31 class Vector3DdataElement: public IODataElement { 32 public: 33 Vector3DdataElement(const Vector3Ddata *data,string name,uint32_t elem):IODataElement(data,name) { 34 this->data=data; 35 this->elem=elem; 36 size=4; 37 } 30 /*! \class Vector3DdataElement 31 */ 32 class Vector3DdataElement : public IODataElement { 33 public: 34 Vector3DdataElement(const Vector3Ddata *data, string name, uint32_t elem) 35 : IODataElement(data, name) { 36 this->data = data; 37 this->elem = elem; 38 size = 4; 39 } 38 40 39 ~Vector3DdataElement() { 40 } 41 ~Vector3DdataElement() {} 41 42 42 void CopyData(char*dst) const {43 44 45 switch(elem) {46 47 value=data->x;48 49 50 value=data->y;51 52 53 value=data->z;54 55 56 57 value=0;58 59 60 43 void CopyData(char *dst) const { 44 float value; 45 data->GetMutex(); 46 switch (elem) { 47 case X: 48 value = data->x; 49 break; 50 case Y: 51 value = data->y; 52 break; 53 case Z: 54 value = data->z; 55 break; 56 default: 57 data->Err("type not handled\n"); 58 value = 0; 59 break; 60 } 61 data->ReleaseMutex(); 61 62 62 memcpy(dst,&value,sizeof(float));63 63 memcpy(dst, &value, sizeof(float)); 64 } 64 65 65 ScalarType const &GetDataType() const { 66 return dataType; 67 } 66 ScalarType const &GetDataType() const { return dataType; } 68 67 69 70 71 72 73 68 private: 69 const Vector3Ddata *data; 70 uint32_t elem; 71 FloatType dataType; 72 }; 74 73 75 Vector3Ddata::Vector3Ddata(const Object* parent, string name,float x,float y,float z,uint32_t n): io_data(parent,name,n), Vector3D(x,y,z) { 74 Vector3Ddata::Vector3Ddata(const Object *parent, string name, float x, float y, 75 float z, uint32_t n) 76 : io_data(parent, name, n), Vector3D(x, y, z) {} 76 77 78 Vector3Ddata::~Vector3Ddata() {} 79 80 void Vector3Ddata::CopyDatas(char *dst) const { 81 GetMutex(); 82 memcpy(dst, &x, sizeof(float)); 83 memcpy(dst + sizeof(float), &y, sizeof(float)); 84 memcpy(dst + 2 * sizeof(float), &z, sizeof(float)); 85 ReleaseMutex(); 77 86 } 78 87 79 Vector3Ddata::~Vector3Ddata(){80 88 IODataElement *Vector3Ddata::XElement(void) const { 89 return new Vector3DdataElement(this, "x", X); 81 90 } 82 91 83 void Vector3Ddata::CopyDatas(char* dst) const { 84 GetMutex(); 85 memcpy(dst,&x,sizeof(float)); 86 memcpy(dst+sizeof(float),&y,sizeof(float)); 87 memcpy(dst+2*sizeof(float),&z,sizeof(float)); 88 ReleaseMutex(); 92 IODataElement *Vector3Ddata::YElement(void) const { 93 return new Vector3DdataElement(this, "y", Y); 89 94 } 90 95 91 IODataElement* Vector3Ddata::XElement(void) const { 92 return new Vector3DdataElement(this,"x",X); 93 } 94 95 IODataElement* Vector3Ddata::YElement(void) const { 96 return new Vector3DdataElement(this,"y",Y); 97 } 98 99 IODataElement* Vector3Ddata::ZElement(void) const { 100 return new Vector3DdataElement(this,"z",Z); 96 IODataElement *Vector3Ddata::ZElement(void) const { 97 return new Vector3DdataElement(this, "z", Z); 101 98 } 102 99
Note:
See TracChangeset
for help on using the changeset viewer.