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

#include <objlib.h>

Collaboration diagram for Cosmos::wavefront::line:

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 centroid
 
double length = 0.
 

Member Function Documentation

json11::Json Cosmos::wavefront::line::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
106  {
107  vector<double> d_groups(groups.begin(), groups.end());
108  return json11::Json::object {
109  { "groups" , d_groups },
110  { "vertices" , vertices },
111  { "centroid" , centroid },
112  { "length" , length }
113  };
114  }
std::map< std::string, Json > object
Definition: json11.hpp:88
double length
Definition: objlib.h:100
Vector centroid
Definition: objlib.h:99
vector< vertex > vertices
Definition: objlib.h:98
vector< size_t > groups
Definition: objlib.h:97
void Cosmos::wavefront::line::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
122  {
123  string error;
125  if(error.empty()) {
126  for(size_t i = 0; i < groups.size(); ++i) {
127  if(!p["groups"][i].is_null())
128  groups[i] = static_cast<size_t>(p["groups"][i].number_value());
129  }
130  for(size_t i = 0; i < vertices.size(); ++i) {
131  if(!p["vertices"][i].is_null()) vertices[i].from_json(p["vertices"][i].dump());
132  }
133  if(!p["centroid"].is_null()) centroid.from_json(p["centroid"].dump());
134  if(!p["length"].is_null()) length = p["length"].number_value();
135  } else {
136  cerr<<"ERROR: <"<<error<<">"<<endl;
137  }
138  return;
139  }
Definition: json11.hpp:79
void from_json(const string &s)
Set class contents from JSON string.
Definition: objlib.h:122
int i
Definition: rw_test.cpp:37
static double * p
Definition: gauss_jackson_test.cpp:42
void dump(std::string &out) const
double length
Definition: objlib.h:100
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)
static void dump(NullStruct, string &out)
Definition: json11.cpp:53
Vector centroid
Definition: objlib.h:99
vector< vertex > vertices
Definition: objlib.h:98
vector< size_t > groups
Definition: objlib.h:97

Member Data Documentation

vector<size_t> Cosmos::wavefront::line::groups
vector<vertex> Cosmos::wavefront::line::vertices
Vector Cosmos::wavefront::line::centroid
double Cosmos::wavefront::line::length = 0.

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