15 #include "xFileDataObject.h" 16 #include "xFileTemplate.h" 18 #include "xFileDataNodeTemplate.h" 19 #include "xFileDataObjectInteger.h" 20 #include "xFileDataObjectDouble.h" 21 #include "xFileDataObjectString.h" 22 #include "config_xfile.h" 157 (*node)[
"index"] = index;
158 (*node)[
"indexColor"] = LCAST(
double, color);
203 out <<
"(" << get_type() <<
"::output_data() not implemented.)";
213 write_data(ostream &out,
int indent_level,
const char *)
const {
214 indent(out, indent_level)
215 <<
"(" << get_type() <<
"::write_data() not implemented.)\n";
224 void XFileDataObject::
225 set_int_value(
int int_value) {
236 void XFileDataObject::
237 set_double_value(
double double_value) {
239 <<
get_type_name() <<
" does not support floating-point values.\n";
248 void XFileDataObject::
249 set_string_value(
const string &string_value) {
262 void XFileDataObject::
263 store_double_array(
int num_elements,
const double *values) {
264 if (get_num_elements() != num_elements) {
267 << num_elements <<
" values.\n";
271 for (
int i = 0;
i < num_elements;
i++) {
272 get_element(
i)->set_double_value(values[
i]);
283 int XFileDataObject::
284 get_int_value()
const {
294 double XFileDataObject::
295 get_double_value()
const {
305 string XFileDataObject::
306 get_string_value()
const {
318 void XFileDataObject::
319 get_double_array(
int num_elements,
double *values)
const {
320 if (get_num_elements() != num_elements) {
323 << num_elements <<
" values.\n";
327 for (
int i = 0;
i < num_elements;
i++) {
339 int XFileDataObject::
340 get_num_elements()
const {
353 <<
"Looking for [" << n <<
"] within data object of type " 354 <<
get_type_name() <<
", does not support nested objects.\n";
365 get_element(
const string &name) {
367 <<
"Looking for [\"" << name <<
"\"] within data object of type " 368 <<
get_type_name() <<
", does not support nested objects.\n";
virtual void output_data(ostream &out) const
Writes a suitable representation of this node to an .x file in text mode.
virtual bool add_element(XFileDataObject *element)
Adds the indicated element as a nested data element, if this data object type supports it...
XFileDataObject & add_int(int int_value)
Appends a new integer value to the data object, if it makes sense to do so.
This is the base class for all two-component vectors and points.
int i() const
Unambiguously returns the object's representation as an integer, or 0 if the object has no integer re...
virtual void write_data(ostream &out, int indent_level, const char *separator) const
Writes a suitable representation of this node to an .x file in text mode.
An string-valued data element.
string get_name(TypedObject *object=(TypedObject *) NULL) const
Returns the name of the type.
const XFileDataDef * get_data_def() const
Returns the data object that this object is represented by, if any, or NULL if there is none...
XFileDataObject & add_MeshFace(XFile *x_file)
Appends a new MeshFace instance.
void zero_fill()
Fills the data node with zero-valued elements appropriate to the template.
static XFileTemplate * find_standard_template(const string &name)
Returns the standard template associated with the indicated name, if any, or NULL if none...
This is a node which contains all of the data elements defined by a template.
XFileDataObject & add_Vector(XFile *x_file, const LVecBase3d &vector)
Appends a new Vector instance.
XFileDataObject & add_Coords2d(XFile *x_file, const LVecBase2d &coords)
Appends a new Coords2d instance.
XFileDataObject & add_IndexedColor(XFile *x_file, int index, const LColor &color)
Appends a new IndexedColor instance.
void set(int int_value)
Stores the indicated integer value into the object, if it makes sense to do so.
XFileDataObject & add_double(double double_value)
Appends a new floating-point value to the data object, if it makes sense to do so.
An integer-valued data element.
virtual string get_type_name() const
Returns a string that represents the type of object this data object represents.
XFileDataObject & add_string(const string &string_value)
Appends a new string value to the data object, if it makes sense to do so.
This is the base class for all three-component vectors and points.
This is the base class for all three-component vectors and points.
An double-valued data element.
This represents the complete contents of an X file (file.x) in memory.
A template definition in the X file.
virtual bool is_complex_object() const
Returns true if this kind of data object is a complex object that can hold nested data elements...
TypeHandle is the identifier used to differentiate C++ class types.
The abstract base class for a number of different types of data elements that may be stored in the X ...