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

#include "Box.H"
#include "xrmlP.H"

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

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

bool Box::assign_size(const SFVec3f& value)
{
  // TODO: value range check!
  size = value;
  status |= size_updated;
  timestamp = interface[0]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Box_size(SFNode* node, const fieldValue& value)
{
  Box* Box_node = dynamic_cast<Box*>(node);
  if (!Box_node)
    Fatal(-1, "assign_Box_size", "called for a non-Box node");
  return Box_node->assign_size((const SFVec3f&)value);
}

Box::Box()
{
  interfaceMember* the_interface[1] = {
    new field("size", fieldValue(&size), assign_Box_size),
  };
  SFNode::construct(BoxTypeId, 1, the_interface);

  size = SFVec3f(2,2,2);
  
  Geometry::util_init();
  Box::util_init();
}

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

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

void Box::clone_here(const Box& src)
{
  SFNode::clone(src);
  
  interface[0]->value = fieldValue(&size);
  
  size = src.size;
  
  Geometry::util_clone(src);
  Box::util_clone(src);
}

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

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

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

}  // namespace xrml
