PeriDyno 1.0.0
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Color.inl
Go to the documentation of this file.
1#ifndef COLOR_SERIALIZATION
2#define COLOR_SERIALIZATION
3
4#include "Field.h"
5
6namespace dyno
7{
8 template<>
9 inline std::string FVar<Color>::serialize()
10 {
11 if (isEmpty())
12 return "";
13
14 Color val = this->getValue();
15
16 std::stringstream ss;
17 ss << val.r << " " << val.g << " " << val.b;
18
19 return ss.str();
20 }
21
22 template<>
23 inline bool FVar<Color>::deserialize(const std::string& str)
24 {
25 if (str.empty())
26 return false;
27
28 std::stringstream ss(str);
29 std::string substr;
30
31 ss >> substr;
32 double x = std::stod(substr);
33
34 ss >> substr;
35 double y = std::stod(substr);
36
37 ss >> substr;
38 double z = std::stod(substr);
39
40 this->setValue(Color(x, y, z));
41
42 return true;
43 }
44
45 template class FVar<Color>;
46}
47
48#endif // !COLOR_SERIALIZATION
float r
Definition Color.h:528
float b
Definition Color.h:530
float g
Definition Color.h:529
bool isEmpty() override
Definition Field.h:58
std::string serialize() override
Definition Field.h:55
bool deserialize(const std::string &str) override
Definition Field.h:56
float getValue()
Definition Field.h:130
void setValue(float val)
Definition Field.h:111
This is an implementation of AdditiveCCD based on peridyno.
Definition Array.h:25