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

#include "Cone.H"
#include "xrmlP.H"

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

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

bool Cone::assign_bottomRadius(const SFFloat& value)
{
  // TODO: value range check!
  bottomRadius = value;
  status |= bottomRadius_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Cone_bottomRadius(SFNode* node, const fieldValue& value)
{
  Cone* Cone_node = dynamic_cast<Cone*>(node);
  if (!Cone_node)
    Fatal(-1, "assign_Cone_bottomRadius", "called for a non-Cone node");
  return Cone_node->assign_bottomRadius((const SFFloat&)value);
}

bool Cone::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_Cone_height(SFNode* node, const fieldValue& value)
{
  Cone* Cone_node = dynamic_cast<Cone*>(node);
  if (!Cone_node)
    Fatal(-1, "assign_Cone_height", "called for a non-Cone node");
  return Cone_node->assign_height((const SFFloat&)value);
}

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

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

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

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

Cone::Cone()
{
  interfaceMember* the_interface[4] = {
    new field("bottomRadius", fieldValue(&bottomRadius), assign_Cone_bottomRadius),
    new field("height", fieldValue(&height), assign_Cone_height),
    new field("side", fieldValue(&side), assign_Cone_side),
    new field("bottom", fieldValue(&bottom), assign_Cone_bottom),
  };
  SFNode::construct(ConeTypeId, 4, the_interface);

  bottomRadius = 1;
  height = 2;
  side = 1;
  bottom = 1;
  
  Geometry::util_init();
  Cone::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
