Subversion Repositories gelsvn

Rev

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

Rev 145 Rev 155
Line 17... Line 17...
17
	/** \brief A Data structure representing an open or closed manifold.
17
	/** \brief A Data structure representing an open or closed manifold.
18
			Manifold keeps lists of the entities making up a halfedge mesh
18
			Manifold keeps lists of the entities making up a halfedge mesh
19
			and provides basic functions for creating new faces, halfedges
19
			and provides basic functions for creating new faces, halfedges
20
			and vertices. There are also primitive operations for editing 
20
			and vertices. There are also primitive operations for editing 
21
			such as edge collapse. */
21
			such as edge collapse. */
22
	struct Manifold
22
	class Manifold
23
	{
23
	{
24
		std::list<Vertex> vertex_db;
24
		std::list<Vertex> vertex_db;
25
		std::list<Face> face_db;
25
		std::list<Face> face_db;
26
		std::list<HalfEdge> halfedge_db;
26
		std::list<HalfEdge> halfedge_db;
27
 
27
 
Line 97... Line 97...
97
		{
97
		{
98
			halfedge_db.push_back(HalfEdge());
98
			halfedge_db.push_back(HalfEdge());
99
			return --halfedge_db.end();
99
			return --halfedge_db.end();
100
		}
100
		}
101
 
101
 
-
 
102
		/** Erase halfedge h. 
-
 
103
				In general, you should never call this function but use the 
102
		/// Erase halfedge h. Assumes it is safe to do so. Use with care.
104
				collapse_halfedge function instead since blindly erasing geometry
-
 
105
				is most likely to invalidate the Mesh. Quite possibly this function
-
 
106
				will be removed from the public interface. */
103
		void erase_halfedge(HalfEdgeIter h)
107
		void erase_halfedge(HalfEdgeIter h)
104
		{
108
		{
105
			halfedge_db.erase(h);
109
			halfedge_db.erase(h);
106
		}
110
		}
107
 
111
 
-
 
112
		/** Erase vertex v.
-
 
113
				In general, you should never call this function but use the 
108
		/// Erase vertex v. Assumes it is safe to do so. Use with care.
114
				collapse_halfedge function to collapse the vertex away.
-
 
115
				Blindly erasing is extremely likely to invalidate the
-
 
116
				Mesh. Quite possibly this function will be removed from the
-
 
117
				public interface. */
109
		void erase_vertex(VertexIter v)
118
		void erase_vertex(VertexIter v)
110
		{
119
		{
111
			vertex_db.erase(v);
120
			vertex_db.erase(v);
112
		}
121
		}
113
	
122
	
-
 
123
		/** Erase face f. 
114
		/// Erase face f. Assumes it is safe to do so. Use with care.
124
				In general, you should never call this function but use 
-
 
125
				collapse_halfedge in conjunction with other functions to
-
 
126
				remove the face through (Euler) operations which preserve
-
 
127
				the mesh in a valid state.
-
 
128
				Blindly erasing is extremely likely to invalidate the
-
 
129
				Mesh. Quite possibly this function will be removed from the
-
 
130
				public interface. */
115
		void erase_face(FaceIter f)
131
		void erase_face(FaceIter f)
116
		{
132
		{
117
			face_db.erase(f);
133
			face_db.erase(f);
118
		}
134
		}
119
 
135
 
Line 135... Line 151...
135
		/// Return iterator pointing to beyond the last face.
151
		/// Return iterator pointing to beyond the last face.
136
		FaceIter faces_end() { return face_db.end(); }
152
		FaceIter faces_end() { return face_db.end(); }
137
 
153
 
138
		/** \brief HalfEdge collapse precondition. 
154
		/** \brief HalfEdge collapse precondition. 
139
 
155
 
140
				The first argument, v, is the vertex we want to remove. The
156
		    The argument h is the halfedge we want to collapse. 
141
				second, h, is a halfedge pointing away from that vertex.
-
 
142
 
157
 
143
				If this function does not return true, it is illegal to collapse
158
				If this function does not return true, it is illegal to collapse
144
				h. The reason is that the collapse would violate the manifold property
159
				h. The reason is that the collapse would violate the manifold property
145
				of the mesh.
160
				of the mesh.
146
 
161
 
Line 180... Line 195...
180
				6. PREVENT MERGING HOLES:
195
				6. PREVENT MERGING HOLES:
181
				We do not want to collapse an edge if its end points are boundary
196
				We do not want to collapse an edge if its end points are boundary
182
				vertices, but its two adjacent faces are not NULL faces, because
197
				vertices, but its two adjacent faces are not NULL faces, because
183
				in that case we create a vertex where two holes meet. A non manifold
198
				in that case we create a vertex where two holes meet. A non manifold
184
				situation.	*/
199
				situation.	*/
185
		bool collapse_precond(VertexIter v, HalfEdgeIter h);
200
		bool collapse_precond(HalfEdgeIter h);
186
		
201
		
187
		/** Collapse the halfedge h.
202
		/** Collapse the halfedge h.
188
 
203
 
189
				The first argument, v, is the vertex that is being removed. The
204
		    The argument h is the halfedge being removed. The vertex 
190
				second, h, is a halfedge pointing away from that vertex.
205
				v=h->opp->vert is the one being removed while h->vert survives.
191
 
206
 
192
				The final argument is a boolean indicating whether the vertex
207
				The final argument is a boolean indicating whether the vertex
193
				that survives the collapse should have a position which is the
208
				that survives the collapse should have a position which is the
194
				average of its own position and the vertex that is removed.
209
				average of its own position and the vertex that is removed.
-
 
210
				By default false meaning that the surviving vertex retains it 
195
				By default false.
211
				position.
196
 
212
 
197
				This function is not guaranteed to keep the mesh sane unless,
213
				This function is not guaranteed to keep the mesh sane unless,
198
				collapse_precond has returned true.
214
				collapse_precond has returned true !!
199
		*/
215
		*/
200
		void collapse_halfedge(VertexIter v, HalfEdgeIter h, bool=false);
216
		void collapse_halfedge(HalfEdgeIter h, bool=false);
201
 
217
 
202
		/** Split a face.
218
		/** Split a face.
203
		    The face, f, is split by connecting two
219
		    The face, f, is split by connecting two
204
				vertices v0 and v1 (the next two arguments). The vertices of
220
				vertices v0 and v1 (the next two arguments). The vertices of
205
				the old face between v0 and v1 (in counter clockwise order) 
221
				the old face between v0 and v1 (in counter clockwise order)