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

#include "Extrusion.H"
#include "xrmlP.H"

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

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

static void process_Extrusion_set_crossSection(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "process_Extrusion_set_crossSection", "called for a non-Extrusion node");
  Extrusion_node->set_crossSection((const MFVec2f&)value);
}

static void process_Extrusion_set_orientation(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "process_Extrusion_set_orientation", "called for a non-Extrusion node");
  Extrusion_node->set_orientation((const MFRotation&)value);
}

static void process_Extrusion_set_scale(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "process_Extrusion_set_scale", "called for a non-Extrusion node");
  Extrusion_node->set_scale((const MFVec2f&)value);
}

static void process_Extrusion_set_spine(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "process_Extrusion_set_spine", "called for a non-Extrusion node");
  Extrusion_node->set_spine((const MFVec3f&)value);
}

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

static bool assign_Extrusion_beginCap(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_beginCap", "called for a non-Extrusion node");
  return Extrusion_node->assign_beginCap((const SFBool&)value);
}

bool Extrusion::assign_ccw(const SFBool& value)
{
  // TODO: value range check!
  ccw = value;
  status |= ccw_updated;
  timestamp = interface[5]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Extrusion_ccw(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_ccw", "called for a non-Extrusion node");
  return Extrusion_node->assign_ccw((const SFBool&)value);
}

bool Extrusion::assign_convex(const SFBool& value)
{
  // TODO: value range check!
  convex = value;
  status |= convex_updated;
  timestamp = interface[6]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Extrusion_convex(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_convex", "called for a non-Extrusion node");
  return Extrusion_node->assign_convex((const SFBool&)value);
}

bool Extrusion::assign_creaseAngle(const SFFloat& value)
{
  // TODO: value range check!
  creaseAngle = value;
  status |= creaseAngle_updated;
  timestamp = interface[7]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Extrusion_creaseAngle(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_creaseAngle", "called for a non-Extrusion node");
  return Extrusion_node->assign_creaseAngle((const SFFloat&)value);
}

bool Extrusion::assign_crossSection(const MFVec2f& value)
{
  // TODO: value range check!
  crossSection = value;
  status |= crossSection_updated;
  timestamp = interface[8]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Extrusion_crossSection(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_crossSection", "called for a non-Extrusion node");
  return Extrusion_node->assign_crossSection((const MFVec2f&)value);
}

bool Extrusion::assign_endCap(const SFBool& value)
{
  // TODO: value range check!
  endCap = value;
  status |= endCap_updated;
  timestamp = interface[9]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Extrusion_endCap(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_endCap", "called for a non-Extrusion node");
  return Extrusion_node->assign_endCap((const SFBool&)value);
}

bool Extrusion::assign_orientation(const MFRotation& value)
{
  // TODO: value range check!
  orientation = value;
  status |= orientation_updated;
  timestamp = interface[10]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Extrusion_orientation(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_orientation", "called for a non-Extrusion node");
  return Extrusion_node->assign_orientation((const MFRotation&)value);
}

bool Extrusion::assign_scale(const MFVec2f& value)
{
  // TODO: value range check!
  scale = value;
  status |= scale_updated;
  timestamp = interface[11]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Extrusion_scale(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_scale", "called for a non-Extrusion node");
  return Extrusion_node->assign_scale((const MFVec2f&)value);
}

bool Extrusion::assign_solid(const SFBool& value)
{
  // TODO: value range check!
  solid = value;
  status |= solid_updated;
  timestamp = interface[12]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Extrusion_solid(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_solid", "called for a non-Extrusion node");
  return Extrusion_node->assign_solid((const SFBool&)value);
}

bool Extrusion::assign_spine(const MFVec3f& value)
{
  // TODO: value range check!
  spine = value;
  status |= spine_updated;
  timestamp = interface[13]->timestamp = world ? world->time : 0;
  return true;
}

static bool assign_Extrusion_spine(SFNode* node, const fieldValue& value)
{
  Extrusion* Extrusion_node = dynamic_cast<Extrusion*>(node);
  if (!Extrusion_node)
    Fatal(-1, "assign_Extrusion_spine", "called for a non-Extrusion node");
  return Extrusion_node->assign_spine((const MFVec3f&)value);
}

Extrusion::Extrusion()
{
  interfaceMember* the_interface[14] = {
    new eventIn("set_crossSection", tMFVec2f, process_Extrusion_set_crossSection),
    new eventIn("set_orientation", tMFRotation, process_Extrusion_set_orientation),
    new eventIn("set_scale", tMFVec2f, process_Extrusion_set_scale),
    new eventIn("set_spine", tMFVec3f, process_Extrusion_set_spine),
    new field("beginCap", fieldValue(&beginCap), assign_Extrusion_beginCap),
    new field("ccw", fieldValue(&ccw), assign_Extrusion_ccw),
    new field("convex", fieldValue(&convex), assign_Extrusion_convex),
    new field("creaseAngle", fieldValue(&creaseAngle), assign_Extrusion_creaseAngle),
    new field("crossSection", fieldValue(&crossSection), assign_Extrusion_crossSection),
    new field("endCap", fieldValue(&endCap), assign_Extrusion_endCap),
    new field("orientation", fieldValue(&orientation), assign_Extrusion_orientation),
    new field("scale", fieldValue(&scale), assign_Extrusion_scale),
    new field("solid", fieldValue(&solid), assign_Extrusion_solid),
    new field("spine", fieldValue(&spine), assign_Extrusion_spine),
  };
  SFNode::construct(ExtrusionTypeId, 14, the_interface);

  beginCap = 1;
  ccw = 1;
  convex = 1;
  creaseAngle = 0;
  const SFVec2f _crossSection[5] = {SFVec2f(1,1), SFVec2f(1,-1), SFVec2f(-1,-1), SFVec2f(-1,1), SFVec2f(1,1)};
  crossSection = MFVec2f(5,(SFVec2f *)_crossSection);
  endCap = 1;
  const SFRotation _orientation[1] = {SFRotation(0,0,1,0)};
  orientation = MFRotation(1,(SFRotation *)_orientation);
  const SFVec2f _scale[1] = {SFVec2f(1,1)};
  scale = MFVec2f(1,(SFVec2f *)_scale);
  solid = 1;
  const SFVec3f _spine[2] = {SFVec3f(0,0,0), SFVec3f(0,1,0)};
  spine = MFVec3f(2,(SFVec3f *)_spine);
  
  Geometry::util_init();
  Extrusion::util_init();
}

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

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

void Extrusion::clone_here(const Extrusion& src)
{
  SFNode::clone(src);
  
  interface[4]->value = fieldValue(&beginCap);
  interface[5]->value = fieldValue(&ccw);
  interface[6]->value = fieldValue(&convex);
  interface[7]->value = fieldValue(&creaseAngle);
  interface[8]->value = fieldValue(&crossSection);
  interface[9]->value = fieldValue(&endCap);
  interface[10]->value = fieldValue(&orientation);
  interface[11]->value = fieldValue(&scale);
  interface[12]->value = fieldValue(&solid);
  interface[13]->value = fieldValue(&spine);
  
  beginCap = src.beginCap;
  ccw = src.ccw;
  convex = src.convex;
  creaseAngle = src.creaseAngle;
  crossSection = src.crossSection;
  endCap = src.endCap;
  orientation = src.orientation;
  scale = src.scale;
  solid = src.solid;
  spine = src.spine;
  
  Geometry::util_clone(src);
  Extrusion::util_clone(src);
}

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

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

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

}  // namespace xrml
