COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
Cosmos::wavefront::face Struct Reference

#include <objlib.h>

Collaboration diagram for Cosmos::wavefront::face:

Public Member Functions

json11::Json to_json () const
 Convert class contents to JSON object. More...
 
void from_json (const string &s)
 Set class contents from JSON string. More...
 

Public Attributes

vector< size_t > groups
 
vector< vertexvertices
 
Vector com
 
Vector normal
 
double area = 0.
 

Member Function Documentation

json11::Json Cosmos::wavefront::face::to_json ( ) const
inline

Convert class contents to JSON object.

Returns a json11 JSON object of the class

Returns
A json11 JSON object containing every member variable within the class
154  {
155  vector<double> d_groups(groups.begin(), groups.end());
156  return json11::Json::object {
157  { "groups" , d_groups },
158  { "vertices" , vertices },
159  { "com" , com },
160  { "normal" , normal },
161  { "area" , area }
162  };
163  }
std::map< std::string, Json > object
Definition: json11.hpp:88
Vector normal
Definition: objlib.h:147
double area
Definition: objlib.h:148
vector< size_t > groups
Definition: objlib.h:144
vector< vertex > vertices
Definition: objlib.h:145
Vector com
Definition: objlib.h:146
void Cosmos::wavefront::face::from_json ( const string &  s)
inline

Set class contents from JSON string.

Parses the provided JSON-formatted string and sets the class data. String should be formatted like the string returned from to_json()

Parameters
sJSON-formatted string to set class contents to
Returns
n/a
171  {
172  string error;
174  if(error.empty()) {
175  for(size_t i = 0; i < groups.size(); ++i) {
176  if(!p["groups"][i].is_null())
177  groups[i] = static_cast<size_t>(p["groups"][i].number_value());
178  }
179  for(size_t i = 0; i < vertices.size(); ++i) {
180  if(!p["vertices"][i].is_null()) vertices[i].from_json(p["vertices"][i].dump());
181  }
182  if(!p["com"].is_null()) com.from_json(p["com"].dump());
183  if(!p["normal"].is_null()) normal.from_json(p["normal"].dump());
184  if(!p["area"].is_null()) area = p["area"].number_value();
185  } else {
186  cerr<<"ERROR: <"<<error<<">"<<endl;
187  }
188  return;
189  }
Definition: json11.hpp:79
int i
Definition: rw_test.cpp:37
Vector normal
Definition: objlib.h:147
void from_json(const string &s)
Set class contents from JSON string.
Definition: objlib.h:171
static double * p
Definition: gauss_jackson_test.cpp:42
void dump(std::string &out) const
void from_json(const string &s)
Set class contents from JSON string.
Definition: vector.h:783
static Json parse(const std::string &in, std::string &err, JsonParse strategy=JsonParse::STANDARD)
double area
Definition: objlib.h:148
static void dump(NullStruct, string &out)
Definition: json11.cpp:53
vector< size_t > groups
Definition: objlib.h:144
vector< vertex > vertices
Definition: objlib.h:145
Vector com
Definition: objlib.h:146

Member Data Documentation

vector<size_t> Cosmos::wavefront::face::groups
vector<vertex> Cosmos::wavefront::face::vertices
Vector Cosmos::wavefront::face::com
Vector Cosmos::wavefront::face::normal
double Cosmos::wavefront::face::area = 0.

The documentation for this struct was generated from the following file: