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

#include <objlib.h>

Collaboration diagram for Cosmos::wavefront::group:

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

string name = ""
 
size_t materialidx = 0
 
vector< size_t > pointidx
 
vector< size_t > lineidx
 
vector< size_t > faceidx
 
Vector com
 
double volume = 0
 

Member Function Documentation

json11::Json Cosmos::wavefront::group::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
206  {
207  vector<double> d_pointidx(pointidx.begin(), pointidx.end());
208  vector<double> d_lineidx(lineidx.begin(), lineidx.end());
209  vector<double> d_faceidx(faceidx.begin(), faceidx.end());
210  return json11::Json::object {
211  { "name" , name },
212  { "materialidx" , static_cast<double>(materialidx) },
213  { "pointidx" , d_pointidx },
214  { "lineidx" , d_lineidx },
215  { "faceidx" , d_faceidx },
216  { "com" , com },
217  { "volume", volume }
218  };
219  }
std::map< std::string, Json > object
Definition: json11.hpp:88
string name
Definition: objlib.h:194
size_t materialidx
Definition: objlib.h:195
vector< size_t > pointidx
Definition: objlib.h:196
vector< size_t > lineidx
Definition: objlib.h:197
Vector com
Definition: objlib.h:199
vector< size_t > faceidx
Definition: objlib.h:198
double volume
Definition: objlib.h:200
void Cosmos::wavefront::group::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
227  {
228  string error;
230  if(error.empty()) {
231  if(!p["name"].is_null()) name = p["name"].string_value();
232  if(!p["materialidx"].is_null()) materialidx = static_cast<size_t>(p["materialidx"].number_value());
233  for(size_t i = 0; i < pointidx.size(); ++i) {
234  if(!p["pointidx"][i].is_null())
235  pointidx[i] = static_cast<size_t>(p["pointidx"][i].number_value());
236  }
237  for(size_t i = 0; i < lineidx.size(); ++i) {
238  if(!p["lineidx"][i].is_null())
239  lineidx[i] = static_cast<size_t>(p["lineidx"][i].number_value());
240  }
241  for(size_t i = 0; i < faceidx.size(); ++i) {
242  if(!p["faceidx"][i].is_null())
243  faceidx[i] = static_cast<size_t>(p["faceidx"][i].number_value());
244  }
245  if(!p["com"].is_null()) com.from_json(p["com"].dump());
246  if(!p["volume"].is_null()) volume = p["volume"].number_value();
247  } else {
248  cerr<<"ERROR: <"<<error<<">"<<endl;
249  }
250  return;
251  }
Definition: json11.hpp:79
int i
Definition: rw_test.cpp:37
string name
Definition: objlib.h:194
size_t materialidx
Definition: objlib.h:195
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)
vector< size_t > pointidx
Definition: objlib.h:196
vector< size_t > lineidx
Definition: objlib.h:197
Vector com
Definition: objlib.h:199
vector< size_t > faceidx
Definition: objlib.h:198
double volume
Definition: objlib.h:200

Member Data Documentation

string Cosmos::wavefront::group::name = ""
size_t Cosmos::wavefront::group::materialidx = 0
vector<size_t> Cosmos::wavefront::group::pointidx
vector<size_t> Cosmos::wavefront::group::lineidx
vector<size_t> Cosmos::wavefront::group::faceidx
Vector Cosmos::wavefront::group::com
double Cosmos::wavefront::group::volume = 0

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