Beispiel #1
0
SKYSPHERE *Copy_Skysphere(const SKYSPHERE *Old)
{
	int i;
	SKYSPHERE *New;

	New = Create_Skysphere();

	Destroy_Transform(New->Trans);

	*New = *Old;

	New->Trans = Copy_Transform(Old->Trans);

	if (New->Count > 0)
	{
		New->Pigments = reinterpret_cast<PIGMENT **>(POV_MALLOC(New->Count*sizeof(PIGMENT *), "skysphere pigment"));

		for (i = 0; i < New->Count; i++)
		{
			New->Pigments[i] = Copy_Pigment(Old->Pigments[i]);
		}
	}

	return (New);
}
CAMERA *Copy_Camera(CAMERA *Old)
{
  CAMERA *New;

  if (Old != NULL)
  {
    New = Create_Camera();

    Destroy_Tnormal(New->Tnormal);
    Destroy_Transform(New->Trans);

    *New = *Old;
    New->Tnormal = NULL; // clear in case the copy fails
    if(Old->Tnormal != NULL)
       New->Tnormal = Copy_Tnormal(Old->Tnormal);

    New->Trans = NULL; // clear in case the copy fails
    if(Old->Trans != NULL)
       New->Trans = Copy_Transform(Old->Trans);
  }
  else
  {
    New = NULL;
  }

  return (New);
}
Beispiel #3
0
ObjectPtr Cone::Copy()
{
    Cone *New = new Cone();
    Destroy_Transform(New->Trans);
    *New = *this;
    New->Trans = Copy_Transform(Trans);
    return (New);
}
Beispiel #4
0
ObjectPtr Copy_Object (ObjectPtr Old)
{
	ObjectPtr New;

	if(Old == NULL)
		return NULL;

	New = Old->Copy();

	/*
	 * The following copying of OBJECT_FIELDS is redundant if Copy
	 * did *New = *Old but we cannot assume it did. It is safe for
	 * Copy to do *New = *Old but it should not otherwise
	 * touch OBJECT_FIELDS.
	 */

	New->Type    = Old->Type;
	New->Bound   = Old->Bound;
	New->Clip    = Old->Clip;
	New->BBox    = Old->BBox;
	New->Flags   = Old->Flags;

	New->Ph_Density             = Old->Ph_Density;
	New->RadiosityImportance    = Old->RadiosityImportance;

	// TODO FIXME - An explanation WHY this is important would be nice [CLi]
	New->LLights.clear(); // important

	New->Texture = Copy_Textures (Old->Texture);
	New->Interior_Texture = Copy_Textures (Old->Interior_Texture);
	if(Old->interior != NULL)
		New->interior = new Interior(*(Old->interior));
	else
		New->interior = NULL;

	/* NK 1998 */
	New->UV_Trans = Copy_Transform(Old->UV_Trans);
	/* NK ---- */

	// TODO: we really ought to decide whether or not it's useful to maintain
	//       the overhead of having multiple clip and bound objects ... it is
	//       after all possible for the user to use CSG and give us one object
	//       meaning we could use a plain pointer here.
	if (Old->Bound.empty() == false)
		New->Bound = Copy_Objects(Old->Bound);
	if (Old->Clip.empty() == false)
	{
		// note that in this case the objects are shared and should only be
		// destroyed the once !!! ... to be frank POV really needs a reference-
		// counted system for sharing objects with copy-on-write semantics.
		if(Old->Bound != Old->Clip)
			New->Clip = Copy_Objects(Old->Clip);
		else
			New->Clip = New->Bound;
	}

	return New;
}
Beispiel #5
0
ObjectPtr Disc::Copy()
{
    Disc *New = new Disc();
    Destroy_Transform(New->Trans);
    *New = *this;
    New->Trans = Copy_Transform(Trans);

    return (New);
}
Beispiel #6
0
ObjectPtr Sphere::Copy()
{
    Sphere *New = new Sphere();
    Destroy_Transform(New->Trans);
    *New = *this;
    New->Trans = Copy_Transform(Trans);

    return(New);
}
Beispiel #7
0
ObjectPtr Lemon::Copy()
{
    Lemon *New = new Lemon();

    Destroy_Transform(New->Trans);
    *New = *this;
    New->Trans = Copy_Transform(Trans);

    return (New);
}
Beispiel #8
0
ObjectPtr Fractal::Copy()
{
    Fractal *New = new Fractal();
    Destroy_Transform(New->Trans);
    *New = *this;
    New->Trans = Copy_Transform(Trans);
    New->Rules = Rules;

    return (New);
}
Beispiel #9
0
ObjectPtr Torus::Copy()
{
	Torus *New = new Torus();

	Destroy_Transform(New->Trans);
	*New = *this;
	New->Trans = Copy_Transform(Trans);

	return (New);
}
Beispiel #10
0
ObjectPtr Superellipsoid::Copy()
{
    Superellipsoid *New = new Superellipsoid();

    Destroy_Transform(New->Trans);
    *New = *this;
    New->Trans = Copy_Transform(Trans);

    return(New);
}
Beispiel #11
0
ObjectPtr Lathe::Copy()
{
    Lathe *New = new Lathe();
    Destroy_Transform(New->Trans);
    *New = *this;
    New->Trans = Copy_Transform(Trans);
    New->Spline = Spline;
    New->Spline->References++;

    return(New);
}
Beispiel #12
0
ObjectPtr Sor::Copy()
{
    Sor *New = new Sor();
    Destroy_Transform(New->Trans);
    *New = *this;
    New->Trans = Copy_Transform(Trans);

    New->Spline->References++;

    return(New);
}
Beispiel #13
0
ObjectPtr Polygon::Copy()
{
    Polygon *New = new Polygon();

    Destroy_Transform(New->Trans);
    *New = *this;
    New->Trans = Copy_Transform(Trans);
    New->Data = Data;
    New->Data->References++;

    return (New);
}
Beispiel #14
0
OBJECT *Copy_Object (OBJECT *Old)
{
  OBJECT *New;

  if (Old == NULL)
  {
    return (NULL);
  }

  New = (OBJECT *)Copy(Old);

 /*
  * The following copying of OBJECT_FIELDS is redundant if Copy
  * did *New = *Old but we cannot assume it did. It is safe for
  * Copy to do *New = *Old but it should not otherwise
  * touch OBJECT_FIELDS.
  */

  New->Methods = Old->Methods;
  New->Type    = Old->Type;
  New->Sibling = Old->Sibling;
  New->Texture = Old->Texture;
  New->Bound   = Old->Bound;
  New->Clip    = Old->Clip;
  New->BBox    = Old->BBox;
  New->Flags   = Old->Flags;
  New->LLights = NULL;  /* Important */

  New->Sibling = NULL;  /* Important */

  New->Texture = Copy_Textures (Old->Texture);
  New->Interior_Texture = Copy_Textures (Old->Interior_Texture);

  New->Bound   = Copy_Bound_Clip (Old->Bound);

  New->Interior = Copy_Interior(Old->Interior);

  /* NK 1998 */
  New->UV_Trans = Copy_Transform(Old->UV_Trans);
  /* NK ---- */

  if (Old->Bound != Old->Clip)
  {
    New->Clip  = Copy_Bound_Clip (Old->Clip);
  }
  else
  {
    New->Clip  = New->Bound;
  }

  return (New);
}
Beispiel #15
0
BOX *Copy_Box(OBJECT *Object)
{
  BOX *New;

  New  = Create_Box();

  /* Copy box. */

  *New = *((BOX *)Object);

  New->Trans = Copy_Transform(((BOX *)Object)->Trans);

  return (New);
}
Beispiel #16
0
Camera& Camera::operator=(const Camera& src)
{
	Assign_Vector(Location, src.Location);
	Assign_Vector(Direction, src.Direction);
	Assign_Vector(Up, src.Up);
	Assign_Vector(Right, src.Right);
	Assign_Vector(Sky, src.Sky);
	Assign_Vector(Look_At, src.Look_At);
	Assign_Vector(Focal_Point, src.Focal_Point);

	Focal_Distance = src.Focal_Distance;
	Aperture = src.Aperture;
	Blur_Samples = src.Blur_Samples;
	Blur_Samples_Min = src.Blur_Samples_Min;
	Confidence = src.Confidence;
	Variance = src.Variance;
	Type = src.Type;
	Angle = src.Angle;
	H_Angle = src.H_Angle;
	V_Angle = src.V_Angle;

	if (Tnormal != NULL)
		Destroy_Tnormal(Tnormal);
	Tnormal = src.Tnormal ? Copy_Tnormal(src.Tnormal) : NULL;
	if (Trans != NULL)
		Destroy_Transform(Trans);
	Trans = src.Trans ? Copy_Transform(src.Trans) : NULL;

	if (Bokeh != NULL)
		Destroy_Pigment(Bokeh);
	Bokeh = src.Bokeh ? Copy_Pigment(src.Bokeh) : NULL;

	for (std::vector<ObjectPtr>::iterator it = Meshes.begin(); it != Meshes.end(); it++)
		Destroy_Object(*it);
	Meshes.clear();
	for (std::vector<ObjectPtr>::const_iterator it = src.Meshes.begin(); it != src.Meshes.end(); it++)
		Meshes.push_back(Copy_Object(*it));
	Face_Distribution_Method = src.Face_Distribution_Method;
	Rays_Per_Pixel = src.Rays_Per_Pixel;
	Max_Ray_Distance = src.Max_Ray_Distance;
	Mesh_Index = src.Mesh_Index;
	for (int i = 0; i < 10; i++)
	{
		U_Xref[i] = src.U_Xref[i];
		V_Xref[i] = src.V_Xref[i];
	}
	Smooth = src.Smooth;

	return *this;
}
Beispiel #17
0
ObjectPtr Parametric::Copy()
{
	Parametric *New = new Parametric();
	Destroy_Transform(New->Trans);
	*New = *this;

	New->Function[0] = Parser::Copy_Function(vm, Function[0]);
	New->Function[1] = Parser::Copy_Function(vm, Function[1]);
	New->Function[2] = Parser::Copy_Function(vm, Function[2]);
	New->Trans = Copy_Transform(Trans);
	New->PData = Copy_PrecompParVal();

	return (New);
}
Beispiel #18
0
void* Copy_IsoSurface(OBJECT* Object)
{
	ISOSURFACE *New;

	New = (ISOSURFACE *)POV_MALLOC(sizeof(ISOSURFACE), "isosurface");
	*New = *((ISOSURFACE *)Object);

	New->Function = Copy_Function(((ISOSURFACE *)Object)->Function);
	New->Trans = Copy_Transform(((ISOSURFACE *)Object)->Trans);

	New->mginfo->refcnt++;

	return (New);
}
static PLANE *Copy_Plane (OBJECT *Object)
{
  PLANE *New;

  New = Create_Plane();

  Destroy_Transform(New->Trans);

  *New = *((PLANE *)Object);

  New->Trans = Copy_Transform(((PLANE *)Object)->Trans);

  return(New);
}
Beispiel #20
0
void* Copy_Parametric(OBJECT* Object)
{
	PARAMETRIC *New, *Old;

	Old = (PARAMETRIC *)Object;

	New = Create_Parametric();
	*New = *((PARAMETRIC *)Object);

	New->Function[0] = Copy_Function(Old->Function[0]);
	New->Function[1] = Copy_Function(Old->Function[1]);
	New->Function[2] = Copy_Function(Old->Function[2]);
	New->Trans = Copy_Transform(Old->Trans);
	New->PData = Copy_PrecompParVal(Old->PData);

	return (New);
}
Beispiel #21
0
static CONE *Copy_Cone(OBJECT *Object)
{
  CONE *New;

  New = Create_Cone();

  /* Get rid of the transformation created in Create_Cone(). */

  Destroy_Transform(New->Trans);

  /* Copy cone. */

  *New = *((CONE *)Object);

  New->Trans = Copy_Transform(((CONE *)Object)->Trans);

  return (New);
}
Beispiel #22
0
static DISC *Copy_Disc (OBJECT *Object)
{
  DISC *New;

  New  = Create_Disc();

  /* Get rid of the transformation created in Create_Disc(). */

  Destroy_Transform(New->Trans);

  /* Copy disc. */

  *New = *((DISC *) Object);

  New->Trans = Copy_Transform(((DISC *)Object)->Trans);

  return (New);
}
Beispiel #23
0
ObjectPtr IsoSurface::Copy()
{
    IsoSurface *New = new IsoSurface();
    Destroy_Transform(New->Trans);
    *New = *this;

    New->Function = Function->Clone();
    New->Trans = Copy_Transform(Trans);

    New->mginfo = mginfo;
    New->mginfo->refcnt++;

    // mark it as copy for use by max_gradient warning code
    New->isCopy = true;

    New->container = shared_ptr<ContainedByShape>(container->Copy());

    return (New);
}
Beispiel #24
0
static POLYGON *Copy_Polygon(OBJECT *Object)
{
  POLYGON *New, *Polyg = (POLYGON *)Object;

  New = Create_Polygon ();

  /* Get rid of the transformation created in Create_Polygon(). */

  Destroy_Transform(New->Trans);

  /* Copy polygon. */

  *New = *Polyg;

  New->Trans = Copy_Transform(Polyg->Trans);

  New->Data->References++;

  return (New);
}