File: VCopyObj.c

package info (click to toggle)
acm4 4.7-18
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 4,776 kB
  • ctags: 1,621
  • sloc: ansic: 16,777; makefile: 364; sh: 31
file content (39 lines) | stat: -rw-r--r-- 894 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include "Vlib.h"

VObject*
VCopyObject (obj)
VObject	*obj;
{

	register int		i;
	register VObject	*newObj;

	newObj = (VObject *) Vmalloc (sizeof (VObject));
	newObj->name = obj->name;
	newObj->extent = obj->extent;
	newObj->center = obj->center;
	newObj->numPolys = obj->numPolys;
	newObj->polygon =
		(VPolygon **) Vmalloc (sizeof(VPolygon *) * newObj->numPolys);
	if (obj->order) {
		newObj->order = (unsigned short *)
			Vmalloc (sizeof(unsigned short) * NUM_ASPECTS *
			newObj->numPolys);
		memcpy ((char *) newObj->order, (char *) obj->order,
			sizeof(unsigned short) * NUM_ASPECTS *
			newObj->numPolys);
	}
	else {
		newObj->order = (unsigned short *) NULL;
	}

	for (i=0; i <obj->numPolys; ++i) {
		if ((newObj->polygon[i] = VCopyPolygon (obj->polygon[i]))
			== (VPolygon *) NULL) {
			fprintf (stderr, "VCopyObject: can't copy polygons\n");
			exit (1);
		}
	}

	return newObj;
}