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

#include "Sphere.H"
#include "xrmlP.H"

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

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

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

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

Sphere::Sphere()
{
  interfaceMember* the_interface[1] = {
    new field("radius", fieldValue(&radius), assign_Sphere_radius),
  };
  SFNode::construct(SphereTypeId, 1, the_interface);

  radius = 1;
  
  Geometry::util_init();
  Sphere::util_init();
}

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

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

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

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

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

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

}  // namespace xrml
