Subversion Repositories gelsvn

Rev

Rev 79 | Rev 178 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 79 Rev 89
Line 8... Line 8...
8
 
8
 
9
namespace Geometry
9
namespace Geometry
10
{
10
{
11
	const CGLA::Vec3i NULL_FACE(-1,-1,-1);
11
	const CGLA::Vec3i NULL_FACE(-1,-1,-1);
12
	
12
	
13
	/** This class represents the simplest possible triangle mesh data structure.
13
	/** \brief This class represents the simplest possible triangle mesh data
-
 
14
			structure.
-
 
15
 
14
			Faces must be triangular, and 3D coordinates are the only values 
16
			Faces must be triangular, and 3D coordinates are the only values 
15
			associated with the vertices. */
17
			associated with the vertices. */
16
	class IndexedFaceSet
18
	class IndexedFaceSet
17
	{
19
	{
18
		/// Vertices
20
		/// Vertices
Line 27... Line 29...
27
 
29
 
28
		// ----------------------------------------
30
		// ----------------------------------------
29
		// Functions that operate on faces
31
		// Functions that operate on faces
30
		// ----------------------------------------
32
		// ----------------------------------------
31
				
33
				
32
		/** Add a face and return the index of the new face. If the optional
34
		/** Add a face and return the index of the new face. 
-
 
35
				
33
				idx argument is present, the face array is resized so that the 
36
		If the optional idx argument is present, the face array is resized so 
34
				new index == idx. */
37
		that the new index == idx. */
35
		int add_face(const CGLA::Vec3i& f, int idx=-1) 
38
		int add_face(const CGLA::Vec3i& f, int idx=-1) 
36
		{
39
		{
37
			if(idx < 0)
40
			if(idx < 0)
38
				idx = faces.size();
41
				idx = faces.size();
39
			faces.resize(idx+1,NULL_FACE);
42
			faces.resize(idx+1,NULL_FACE);
Line 42... Line 45...
42
		}
45
		}
43
 
46
 
44
		/// Return the number of faces.
47
		/// Return the number of faces.
45
		int no_faces() const {return faces.size();}
48
		int no_faces() const {return faces.size();}
46
 
49
 
47
		/** Return the face corresponding to a given index. The NULL_FACE
50
		/** Return the face corresponding to a given index. 
-
 
51
				
48
				is returned if the index is out of bounds. */
52
				The NULL_FACE	is returned if the index is out of bounds. */
49
		const CGLA::Vec3i& face(int idx) const
53
		const CGLA::Vec3i& face(int idx) const
50
		{
54
		{
51
			if(idx<faces.size())
55
			if(idx<faces.size())
52
				return faces[idx];
56
				return faces[idx];
53
			return NULL_FACE;
57
			return NULL_FACE;
Line 72... Line 76...
72
		}
76
		}
73
 
77
 
74
		/// Return the number of vertices.
78
		/// Return the number of vertices.
75
		int no_vertices() const {return verts.size();}
79
		int no_vertices() const {return verts.size();}
76
 
80
 
77
		/** Return the vertex corresponding to a given index. User is responsible
81
		/** Return the vertex corresponding to a given index. 
-
 
82
				
78
				for bounds checking. */
83
		User is responsible	for bounds checking. */
79
		const CGLA::Vec3f& vertex(int idx) const
84
		const CGLA::Vec3f& vertex(int idx) const
80
		{
85
		{
81
			return verts[idx];
86
			return verts[idx];
82
		}
87
		}
83
 
88