COSMOS core  1.0.2 (beta)
Comprehensive Open-architecture Solution for Mission Operations Systems
facestruc Struct Reference

Face structure: information on each face of a piece. More...

#include <jsondef.h>

Collaboration diagram for facestruc:

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

uint16_t vertex_cnt = 0
 
vector< uint16_t > vertex_idx
 
Vector com
 
Vector normal
 
double area =0.
 

Detailed Description

Face structure: information on each face of a piece.

Member Function Documentation

json11::Json facestruc::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
1411  {
1412  return json11::Json::object {
1413  { "vertex_cnt" , vertex_cnt},
1414  { "vertex_idx" , vertex_idx },
1415  { "com" , com },
1416  { "normal" , normal },
1417  { "area" , area }
1418  };
1419  }
std::map< std::string, Json > object
Definition: json11.hpp:88
Vector normal
Definition: jsondef.h:1404
uint16_t vertex_cnt
Definition: jsondef.h:1401
Vector com
Definition: jsondef.h:1403
vector< uint16_t > vertex_idx
Definition: jsondef.h:1402
double area
Definition: jsondef.h:1405
void facestruc::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
1427  {
1428  string error;
1429  json11::Json parsed = json11::Json::parse(s,error);
1430  if(error.empty()) {
1431  if(!parsed["vertex_cnt"].is_null()) { vertex_cnt = parsed["vertex_cnt"].int_value(); }
1432  for(size_t i = 0; i < vertex_idx.size(); ++i) {
1433  if(!parsed["vertex_idx"][i].is_null()) { vertex_idx[i] = parsed["vertex_idx"][i].int_value(); }
1434  }
1435  if(!parsed["com"].is_null()) { com.from_json(parsed["com"].dump()); }
1436  if(!parsed["normal"].is_null()) { normal.from_json(parsed["normal"].dump()); }
1437  if(!parsed["area"].is_null()) { area = parsed["area"].number_value(); }
1438  } else {
1439  cerr<<"ERROR: <"<<error<<">"<<endl;
1440  }
1441  return;
1442  }
Definition: json11.hpp:79
int i
Definition: rw_test.cpp:37
Vector normal
Definition: jsondef.h:1404
uint16_t vertex_cnt
Definition: jsondef.h:1401
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 com
Definition: jsondef.h:1403
vector< uint16_t > vertex_idx
Definition: jsondef.h:1402
double area
Definition: jsondef.h:1405
int int_value() const
Definition: json11.cpp:281
double number_value() const
Definition: json11.cpp:280

Member Data Documentation

uint16_t facestruc::vertex_cnt = 0
vector<uint16_t> facestruc::vertex_idx
Vector facestruc::com
Vector facestruc::normal
double facestruc::area =0.

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