// CylinderP.C: Cylinder nodes (private source).
// Automatically generated with nodegen 0.5a - do not edit.

#include "Cylinder.H"
#include "xrmlP.H"

namespace xrml {
int Cylinder::major_version(void) { return 0; }
int Cylinder::minor_version(void) { return 5; }
bool Cylinder::is_leaf_class(void) { return true; }

bool IsCylinder(SFNode* node)
{
  return (dynamic_cast<Cylinder*>(node) != 0);
}

bool Cylinder::assign_bottom(const SFBool& value)
{
  // TODO: value range check!
  bottom = value;
  status |= bottom_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Cylinder_bottom(SFNode* node, const fieldValue& value)
{
  Cylinder* Cylinder_node = dynamic_cast<Cylinder*>(node);
  if (!Cylinder_node)
    Fatal(-1, "assign_Cylinder_bottom", "called for a non-Cylinder node");
  return Cylinder_node->assign_bottom((const SFBool&)value);
}

bool Cylinder::assign_height(const SFFloat& value)
{
  // TODO: value range check!
  height = value;
  status |= height_updated;
  timestamp = interface[1]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Cylinder_height(SFNode* node, const fieldValue& value)
{
  Cylinder* Cylinder_node = dynamic_cast<Cylinder*>(node);
  if (!Cylinder_node)
    Fatal(-1, "assign_Cylinder_height", "called for a non-Cylinder node");
  return Cylinder_node->assign_height((const SFFloat&)value);
}

bool Cylinder::assign_radius(const SFFloat& value)
{
  // TODO: value range check!
  radius = value;
  status |= radius_updated;
  timestamp = interface[2]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Cylinder_radius(SFNode* node, const fieldValue& value)
{
  Cylinder* Cylinder_node = dynamic_cast<Cylinder*>(node);
  if (!Cylinder_node)
    Fatal(-1, "assign_Cylinder_radius", "called for a non-Cylinder node");
  return Cylinder_node->assign_radius((const SFFloat&)value);
}

bool Cylinder::assign_side(const SFBool& value)
{
  // TODO: value range check!
  side = value;
  status |= side_updated;
  timestamp = interface[3]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Cylinder_side(SFNode* node, const fieldValue& value)
{
  Cylinder* Cylinder_node = dynamic_cast<Cylinder*>(node);
  if (!Cylinder_node)
    Fatal(-1, "assign_Cylinder_side", "called for a non-Cylinder node");
  return Cylinder_node->assign_side((const SFBool&)value);
}

bool Cylinder::assign_top(const SFBool& value)
{
  // TODO: value range check!
  top = value;
  status |= top_updated;
  timestamp = interface[4]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Cylinder_top(SFNode* node, const fieldValue& value)
{
  Cylinder* Cylinder_node = dynamic_cast<Cylinder*>(node);
  if (!Cylinder_node)
    Fatal(-1, "assign_Cylinder_top", "called for a non-Cylinder node");
  return Cylinder_node->assign_top((const SFBool&)value);
}

Cylinder::Cylinder()
{
  interfaceMember* the_interface[5] = {
    new field("bottom", fieldValue(&bottom), assign_Cylinder_bottom),
    new field("height", fieldValue(&height), assign_Cylinder_height),
    new field("radius", fieldValue(&radius), assign_Cylinder_radius),
    new field("side", fieldValue(&side), assign_Cylinder_side),
    new field("top", fieldValue(&top), assign_Cylinder_top),
  };
  SFNode::construct(CylinderTypeId, 5, the_interface);

  bottom = 1;
  height = 2;
  radius = 1;
  side = 1;
  top = 1;
  
  Geometry::util_init();
  Cylinder::util_init();
}

void Cylinder::destruct(void)
{
  Cylinder::util_destruct();
  Geometry::util_destruct();
  SFNode::destruct();
}

Cylinder::~Cylinder()
{
  destruct();
}

void Cylinder::clone_here(const Cylinder& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&bottom);
  interface[1]->value = fieldValue(&height);
  interface[2]->value = fieldValue(&radius);
  interface[3]->value = fieldValue(&side);
  interface[4]->value = fieldValue(&top);
  
  bottom = src.bottom;
  height = src.height;
  radius = src.radius;
  side = src.side;
  top = src.top;
  
  Geometry::util_clone(src);
  Cylinder::util_clone(src);
}

Cylinder::Cylinder(const Cylinder& src)
{
  clone_here(src);
}

Cylinder& Cylinder::operator=(const Cylinder& src)
{
  if (this != &src) {
    destruct();
    clone_here(src);
  }
  return *this;
}

SFNode* Cylinder::instantiate(Proto *enclosing_proto)
{
  if (nameIndex>=0)
    // named node: return pointer to pre-made instance
    return enclosing_proto ? enclosing_proto->namedNodes[nameIndex] : this;
  
  Cylinder* instance = new Cylinder(*this);
  instance->instantiate_interface(enclosing_proto);
  return instance;
}

}  // namespace xrml
