OpenMesh
|
00001 /*===========================================================================*\ 00002 * * 00003 * OpenMesh * 00004 * Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen * 00005 * www.openmesh.org * 00006 * * 00007 *---------------------------------------------------------------------------* 00008 * This file is part of OpenMesh. * 00009 * * 00010 * OpenMesh is free software: you can redistribute it and/or modify * 00011 * it under the terms of the GNU Lesser General Public License as * 00012 * published by the Free Software Foundation, either version 3 of * 00013 * the License, or (at your option) any later version with the * 00014 * following exceptions: * 00015 * * 00016 * If other files instantiate templates or use macros * 00017 * or inline functions from this file, or you compile this file and * 00018 * link it with other files to produce an executable, this file does * 00019 * not by itself cause the resulting executable to be covered by the * 00020 * GNU Lesser General Public License. This exception does not however * 00021 * invalidate any other reasons why the executable file might be * 00022 * covered by the GNU Lesser General Public License. * 00023 * * 00024 * OpenMesh is distributed in the hope that it will be useful, * 00025 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00026 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00027 * GNU Lesser General Public License for more details. * 00028 * * 00029 * You should have received a copy of the GNU LesserGeneral Public * 00030 * License along with OpenMesh. If not, * 00031 * see <http://www.gnu.org/licenses/>. * 00032 * * 00033 \*===========================================================================*/ 00034 00035 /*===========================================================================*\ 00036 * * 00037 * $Revision: 362 $ * 00038 * $Date: 2011-01-26 10:21:12 +0100 (Mi, 26 Jan 2011) $ * 00039 * * 00040 \*===========================================================================*/ 00041 00042 00043 //============================================================================= 00044 // 00045 // Kernel Concept 00046 // 00047 //============================================================================= 00048 00049 00050 #error this file is for documentation purposes only 00051 00052 00053 //== NAMESPACES =============================================================== 00054 00055 00056 namespace OpenMesh { 00057 namespace Concepts { 00058 00059 00060 //== CLASS DEFINITION ========================================================= 00061 00062 00075 template <class FinalMeshItems> class KernelT 00076 { 00077 public: 00078 00080 00081 00083 typedef typename FinalMeshItems::Vertex Vertex; 00084 typedef typename FinalMeshItems::Halfedge Halfedge; 00085 typedef typename FinalMeshItems::Edge Edge; 00086 typedef typename FinalMeshItems::Face Face; 00087 typedef typename FinalMeshItems::Point Point; 00088 typedef typename FinalMeshItems::Scalar Scalar; 00089 typedef typename FinalMeshItems::Normal Normal; 00090 typedef typename FinalMeshItems::Color Color; 00091 typedef typename FinalMeshItems::TexCoord TexCoord; 00092 typedef typename FinalMeshItems::VertexHandle VertexHandle; 00093 typedef typename FinalMeshItems::HalfedgeHandle HalfedgeHandle; 00094 typedef typename FinalMeshItems::EdgeHandle EdgeHandle; 00095 typedef typename FinalMeshItems::FaceHandle FaceHandle; 00096 00098 00099 00101 00102 00103 typedef SomeIterator KernelVertexIter; 00104 typedef SomeIterator KernelConstVertexIter; 00105 typedef SomeIterator KernelEdgeIter; 00106 typedef SomeIterator KernelConstEdgeIter; 00107 typedef SomeIterator KernelFaceIter; 00108 typedef SomeIterator KernelConstFaceIter; 00110 00112 00113 00114 KernelT() {} 00115 00117 ~KernelT(); 00119 00121 KernelT& operator=(const KernelT& _rhs); 00122 00123 00136 void reserve( unsigned int _n_vertices, 00137 unsigned int _n_edges, 00138 unsigned int _n_faces ); 00139 00140 00142 00143 00144 const Vertex& vertex(VertexHandle _h) const { return deref(_h); } 00145 Vertex& vertex(VertexHandle _h) { return deref(_h); } 00146 const Halfedge& halfedge(HalfedgeHandle _h) const { return deref(_h); } 00147 Halfedge& halfedge(HalfedgeHandle _h) { return deref(_h); } 00148 const Edge& edge(EdgeHandle _h) const { return deref(_h); } 00149 Edge& edge(EdgeHandle _h) { return deref(_h); } 00150 const Face& face(FaceHandle _h) const { return deref(_h); } 00151 Face& face(FaceHandle _h) { return deref(_h); } 00153 00154 00156 00157 00158 VertexHandle handle(const Vertex& _v) const; 00159 HalfedgeHandle handle(const Halfedge& _he) const; 00160 EdgeHandle handle(const Edge& _e) const; 00161 FaceHandle handle(const Face& _f) const; 00163 00164 00166 00167 00168 VertexHandle vertex_handle(unsigned int _i) const; 00169 HalfedgeHandle halfedge_handle(unsigned int _i) const; 00170 EdgeHandle edge_handle(unsigned int _i) const; 00171 FaceHandle face_handle(unsigned int _i) const; 00173 00174 00176 00177 00178 void clear(); 00184 void garbage_collection(); 00185 00189 void remove_last_vertex() { vertices_.pop_back(); } 00193 void remove_last_edge() { edges_.pop_back(); } 00197 void remove_last_face() { faces_.pop_back(); } 00198 00200 00201 00202 00203 00205 00206 00207 unsigned int n_vertices() const; 00209 unsigned int n_halfedges() const; 00211 unsigned int n_edges() const; 00213 unsigned int n_faces() const; 00215 bool vertices_empty() const; 00217 bool halfedges_empty() const; 00219 bool edges_empty() const; 00221 bool faces_empty() const; 00223 00224 00225 00227 00228 00229 HalfedgeHandle halfedge_handle(VertexHandle _vh) const; 00231 void set_halfedge_handle(VertexHandle _vh, HalfedgeHandle _heh); 00233 const Point& point(VertexHandle _vh) const; 00235 const Point& point(const Vertex& _v) const; 00237 void set_point(VertexHandle _vh, const Point& _p); 00239 void set_point(Vertex& _v, const Point& _p); 00241 00242 00243 00244 00246 00247 00248 VertexHandle to_vertex_handle(HalfedgeHandle _heh) const; 00251 VertexHandle from_vertex_handle(HalfedgeHandle _heh) const; 00253 void set_vertex_handle(HalfedgeHandle _heh, VertexHandle _vh); 00256 FaceHandle face_handle(HalfedgeHandle _heh) const; 00258 void set_face_handle(HalfedgeHandle _heh, FaceHandle _fh); 00260 HalfedgeHandle next_halfedge_handle(HalfedgeHandle _heh) const; 00264 void set_next_halfedge_handle(HalfedgeHandle _heh, HalfedgeHandle _nheh); 00268 HalfedgeHandle prev_halfedge_handle(HalfedgeHandle _heh) const; 00270 HalfedgeHandle opposite_halfedge_handle(HalfedgeHandle _heh) const; 00272 HalfedgeHandle ccw_rotated_halfedge_handle(HalfedgeHandle _heh) const; 00274 HalfedgeHandle cw_rotated_halfedge_handle(HalfedgeHandle _heh) const; 00276 EdgeHandle edge_handle(HalfedgeHandle _heh) const; 00278 00279 00280 00282 00283 00284 HalfedgeHandle halfedge_handle(EdgeHandle _eh, unsigned int _i) const; 00286 00287 00288 00290 00291 00292 HalfedgeHandle halfedge_handle(FaceHandle _fh) const; 00294 void set_halfedge_handle(FaceHandle _fh, HalfedgeHandle _heh); 00296 00297 00298 public: // Standard Property Management 00299 00301 00302 00303 // vertex 00304 const Point& point(VertexHandle _vh) const; 00305 void set_point(VertexHandle _vh, const Point& _p); 00306 Point& point(VertexHandle _vh); 00307 00308 const Normal& normal(VertexHandle _vh) const; 00309 void set_normal(VertexHandle _vh, const Normal& _n); 00310 00311 const Color& color(VertexHandle _vh) const; 00312 void set_color(VertexHandle _vh, const Color& _c); 00313 00314 const TexCoord1D& texcoord1D(VertexHandle _vh) const; 00315 void set_texcoord1D(VertexHandle _vh, const TexCoord1D& _t); 00316 00317 const TexCoord2D& texcoord2D(VertexHandle _vh) const; 00318 void set_texcoord2D(VertexHandle _vh, const TexCoord2D& _t); 00319 00320 const TexCoord3D& texcoord3D(VertexHandle _vh) const; 00321 void set_texcoord3D(VertexHandle _vh, const TexCoord3D& _t); 00322 00323 const TexCoord1D& texcoord1D(HalfedgeHandle _hh) const; 00324 void set_texcoord1D(HalfedgeHandle _hh, const TexCoord1D& _t); 00325 00326 const TexCoord2D& texcoord2D(HalfedgeHandle _hh) const; 00327 void set_texcoord2D(HalfedgeHandle _hh, const TexCoord2D& _t); 00328 00329 const TexCoord3D& texcoord3D(HalfedgeHandle _hh) const; 00330 void set_texcoord3D(HalfedgeHandle _hh, const TexCoord3D& _t); 00331 00332 const StatusInfo& status(VertexHandle _vh) const; 00333 StatusInfo& status(VertexHandle _vh); 00334 00335 // halfedge 00336 const StatusInfo& status(HalfedgeHandle _vh) const; 00337 StatusInfo& status(HalfedgeHandle _vh); 00338 00339 // edge 00340 const StatusInfo& status(EdgeHandle _vh) const; 00341 StatusInfo& status(EdgeHandle _vh); 00342 00343 // face 00344 const Normal& normal(FaceHandle _fh) const; 00345 void set_normal(FaceHandle _fh, const Normal& _n); 00346 00347 const Color& color(FaceHandle _fh) const; 00348 void set_color(FaceHandle _fh, const Color& _c); 00349 00350 const StatusInfo& status(FaceHandle _vh) const; 00351 StatusInfo& status(FaceHandle _vh); 00352 00354 00356 00357 00358 void request_vertex_normals(); 00359 void request_vertex_colors(); 00360 void request_vertex_texcoords1D(); 00361 void request_vertex_texcoords2D(); 00362 void request_vertex_texcoords3D(); 00363 void request_vertex_status(); 00364 00365 void request_halfedge_status(); 00366 void request_halfedge_texcoords1D(); 00367 void request_halfedge_texcoords2D(); 00368 void request_halfedge_texcoords3D(); 00369 00370 void request_edge_status(); 00371 void request_edge_colors(); 00372 00373 void request_face_normals(); 00374 void request_face_colors(); 00375 void request_face_status(); 00376 void request_face_texture_index(); 00378 00380 00381 00382 void release_vertex_normals(); 00383 void release_vertex_colors(); 00384 void release_vertex_texcoords1D(); 00385 void release_vertex_texcoords2D(); 00386 void release_vertex_texcoords3D(); 00387 void release_vertex_status(); 00388 00389 void release_halfedge_status(); 00390 void release_halfedge_texcoords1D(); 00391 void release_halfedge_texcoords2D(); 00392 void release_halfedge_texcoords3D(); 00393 00394 void release_edge_status(); 00395 void release_edge_colors(); 00396 00397 void release_face_normals(); 00398 void release_face_colors(); 00399 void release_face_status(); 00400 void release_face_texture_index(); 00402 00404 00405 00406 bool has_vertex_normals() const; 00407 bool has_vertex_colors() const; 00408 bool has_vertex_texcoords1D() const; 00409 bool has_vertex_texcoords2D() const; 00410 bool has_vertex_texcoords3D() const; 00411 bool has_vertex_status() const; 00412 00413 bool has_halfedge_status() const; 00414 bool has_halfedge_texcoords1D() const; 00415 bool has_halfedge_texcoords2D() const; 00416 bool has_halfedge_texcoords3D() const; 00417 00418 bool has_edge_status() const; 00419 bool has_edge_colors() const; 00420 00421 bool has_face_normals() const; 00422 bool has_face_colors() const; 00423 bool has_face_status() const; 00424 bool has_face_texture_index() const; 00426 00427 public: // Property Management 00428 00430 00432 00433 00434 00435 template <typename T> bool add_property( [VEHFM]PropHandleT<T>& _ph, 00436 const std::string& _name = "" ); 00438 00440 00441 00442 template <typename T> void remove_property( [VEHFM]PropHandleT<T>& ); 00444 00446 00447 00448 template <typename T> 00449 bool get_property_handle( [VEHFM]PropHandleT<T>& ph, const std::string& _n ) const; 00451 00453 00454 00455 template <typename T> PropertyT<T>& property( [VEHF]PropHandleT<T> _ph ); 00456 template <typename T> const PropertyT<T>& property( [VEHF]PropHandleT<T> _ph ) const; 00457 template <typename T> PropertyT<T>& mproperty( MPropHandleT<T> _ph ); 00458 template <typename T> const PropertyT<T>& mproperty( MPropHandleT<T> _ph ) const; 00460 00462 00463 00465 template <typename T> 00466 T& property( VPropHandleT<T> _ph, VertexHandle _vh ); 00467 template <typename T> 00468 const T& property( VPropHandleT<T> _ph, VertexHandle _vh ) const; 00469 00470 template <typename T> 00471 T& property( EPropHandleT<T> _ph, EdgeHandle _vh ); 00472 template <typename T> 00473 const T& property( EPropHandleT<T> _ph, EdgeHandle _vh ) const; 00474 00475 template <typename T> 00476 T& property( HPropHandleT<T> _ph, HalfedgeHandle _vh ); 00477 template <typename T> 00478 const T& property( HPropHandleT<T> _ph, HalfedgeHandle _vh ) const; 00479 00480 template <typename T> 00481 T& property( FPropHandleT<T> _ph, FaceHandle _vh ); 00482 template <typename T> 00483 const T& property( FPropHandleT<T> _ph, FaceHandle _vh ) const; 00484 00485 template <typename T> 00486 T& property( MPropHandleT<T> _ph ); 00487 template <typename T> 00488 const T& property( MPropHandleT<T> _ph ) const; 00489 00491 00492 public: 00493 00494 00496 00497 00499 VertexHandle new_vertex(); 00502 VertexHandle new_vertex(const Point& _p); 00505 VertexHandle new_vertex(const Vertex& _v); 00511 HalfedgeHandle new_edge(VertexHandle _start_vertex_handle, 00512 VertexHandle _end_vertex_handle); 00513 00517 FaceHandle new_face(); 00520 FaceHandle new_face(const Face& _f); 00522 00523 00524 // --- iterators --- 00525 00527 00528 00530 KernelVertexIter vertices_begin(); 00531 KernelConstVertexIter vertices_begin() const; 00532 KernelVertexIter vertices_end(); 00533 KernelConstVertexIter vertices_end() const; 00534 KernelEdgeIter edges_begin(); 00535 KernelConstEdgeIter edges_begin() const; 00536 KernelEdgeIter edges_end(); 00537 KernelConstEdgeIter edges_end() const; 00538 KernelFaceIter faces_begin(); 00539 KernelConstFaceIter faces_begin() const; 00540 KernelFaceIter faces_end(); 00541 KernelConstFaceIter faces_end() const; 00543 00544 00545 00546 private: 00547 00548 00549 // --- private functions --- 00550 00552 KernelT(const KernelT& _rhs); 00553 }; 00554 }; 00555 00556 00557 //============================================================================= 00558 } // namespace Concepts 00559 } // namespace OpenMesh 00560 //=============================================================================