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: 514 $ * 00038 * $Date: 2012-01-20 09:08:18 +0100 (Fr, 20 Jan 2012) $ * 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 Normal& normal(HalfedgeHandle _heh) const; 00312 void set_normal(HalfedgeHandle _heh, const Normal& _n); 00313 00314 const Color& color(VertexHandle _vh) const; 00315 void set_color(VertexHandle _vh, const Color& _c); 00316 00317 const TexCoord1D& texcoord1D(VertexHandle _vh) const; 00318 void set_texcoord1D(VertexHandle _vh, const TexCoord1D& _t); 00319 00320 const TexCoord2D& texcoord2D(VertexHandle _vh) const; 00321 void set_texcoord2D(VertexHandle _vh, const TexCoord2D& _t); 00322 00323 const TexCoord3D& texcoord3D(VertexHandle _vh) const; 00324 void set_texcoord3D(VertexHandle _vh, const TexCoord3D& _t); 00325 00326 const TexCoord1D& texcoord1D(HalfedgeHandle _hh) const; 00327 void set_texcoord1D(HalfedgeHandle _hh, const TexCoord1D& _t); 00328 00329 const TexCoord2D& texcoord2D(HalfedgeHandle _hh) const; 00330 void set_texcoord2D(HalfedgeHandle _hh, const TexCoord2D& _t); 00331 00332 const TexCoord3D& texcoord3D(HalfedgeHandle _hh) const; 00333 void set_texcoord3D(HalfedgeHandle _hh, const TexCoord3D& _t); 00334 00335 const StatusInfo& status(VertexHandle _vh) const; 00336 StatusInfo& status(VertexHandle _vh); 00337 00338 // halfedge 00339 const StatusInfo& status(HalfedgeHandle _vh) const; 00340 StatusInfo& status(HalfedgeHandle _vh); 00341 00342 // edge 00343 const StatusInfo& status(EdgeHandle _vh) const; 00344 StatusInfo& status(EdgeHandle _vh); 00345 00346 // face 00347 const Normal& normal(FaceHandle _fh) const; 00348 void set_normal(FaceHandle _fh, const Normal& _n); 00349 00350 const Color& color(FaceHandle _fh) const; 00351 void set_color(FaceHandle _fh, const Color& _c); 00352 00353 const StatusInfo& status(FaceHandle _vh) const; 00354 StatusInfo& status(FaceHandle _vh); 00355 00357 00359 00360 00361 void request_vertex_normals(); 00362 void request_vertex_colors(); 00363 void request_vertex_texcoords1D(); 00364 void request_vertex_texcoords2D(); 00365 void request_vertex_texcoords3D(); 00366 void request_vertex_status(); 00367 00368 void request_halfedge_status(); 00369 void request_halfedge_normals(); 00370 void request_halfedge_texcoords1D(); 00371 void request_halfedge_texcoords2D(); 00372 void request_halfedge_texcoords3D(); 00373 00374 void request_edge_status(); 00375 void request_edge_colors(); 00376 00377 void request_face_normals(); 00378 void request_face_colors(); 00379 void request_face_status(); 00380 void request_face_texture_index(); 00382 00384 00385 00386 void release_vertex_normals(); 00387 void release_vertex_colors(); 00388 void release_vertex_texcoords1D(); 00389 void release_vertex_texcoords2D(); 00390 void release_vertex_texcoords3D(); 00391 void release_vertex_status(); 00392 00393 void release_halfedge_status(); 00394 void release_halfedge_normals(); 00395 void release_halfedge_texcoords1D(); 00396 void release_halfedge_texcoords2D(); 00397 void release_halfedge_texcoords3D(); 00398 00399 void release_edge_status(); 00400 void release_edge_colors(); 00401 00402 void release_face_normals(); 00403 void release_face_colors(); 00404 void release_face_status(); 00405 void release_face_texture_index(); 00407 00409 00410 00411 bool has_vertex_normals() const; 00412 bool has_vertex_colors() const; 00413 bool has_vertex_texcoords1D() const; 00414 bool has_vertex_texcoords2D() const; 00415 bool has_vertex_texcoords3D() const; 00416 bool has_vertex_status() const; 00417 00418 bool has_halfedge_status() const; 00419 bool has_halfedge_normals(); const; 00420 bool has_halfedge_texcoords1D() const; 00421 bool has_halfedge_texcoords2D() const; 00422 bool has_halfedge_texcoords3D() const; 00423 00424 bool has_edge_status() const; 00425 bool has_edge_colors() const; 00426 00427 bool has_face_normals() const; 00428 bool has_face_colors() const; 00429 bool has_face_status() const; 00430 bool has_face_texture_index() const; 00432 00433 public: // Property Management 00434 00436 00438 00439 00440 00441 template <typename T> bool add_property( [VEHFM]PropHandleT<T>& _ph, 00442 const std::string& _name = "" ); 00444 00446 00447 00448 template <typename T> void remove_property( [VEHFM]PropHandleT<T>& ); 00450 00452 00453 00454 template <typename T> 00455 bool get_property_handle( [VEHFM]PropHandleT<T>& ph, const std::string& _n ) const; 00457 00459 00460 00461 template <typename T> PropertyT<T>& property( [VEHF]PropHandleT<T> _ph ); 00462 template <typename T> const PropertyT<T>& property( [VEHF]PropHandleT<T> _ph ) const; 00463 template <typename T> PropertyT<T>& mproperty( MPropHandleT<T> _ph ); 00464 template <typename T> const PropertyT<T>& mproperty( MPropHandleT<T> _ph ) const; 00466 00468 00469 00471 template <typename T> 00472 T& property( VPropHandleT<T> _ph, VertexHandle _vh ); 00473 template <typename T> 00474 const T& property( VPropHandleT<T> _ph, VertexHandle _vh ) const; 00475 00476 template <typename T> 00477 T& property( EPropHandleT<T> _ph, EdgeHandle _vh ); 00478 template <typename T> 00479 const T& property( EPropHandleT<T> _ph, EdgeHandle _vh ) const; 00480 00481 template <typename T> 00482 T& property( HPropHandleT<T> _ph, HalfedgeHandle _vh ); 00483 template <typename T> 00484 const T& property( HPropHandleT<T> _ph, HalfedgeHandle _vh ) const; 00485 00486 template <typename T> 00487 T& property( FPropHandleT<T> _ph, FaceHandle _vh ); 00488 template <typename T> 00489 const T& property( FPropHandleT<T> _ph, FaceHandle _vh ) const; 00490 00491 template <typename T> 00492 T& property( MPropHandleT<T> _ph ); 00493 template <typename T> 00494 const T& property( MPropHandleT<T> _ph ) const; 00495 00497 00498 public: 00499 00500 00502 00503 00505 VertexHandle new_vertex(); 00508 VertexHandle new_vertex(const Point& _p); 00511 VertexHandle new_vertex(const Vertex& _v); 00517 HalfedgeHandle new_edge(VertexHandle _start_vertex_handle, 00518 VertexHandle _end_vertex_handle); 00519 00523 FaceHandle new_face(); 00526 FaceHandle new_face(const Face& _f); 00528 00529 00530 // --- iterators --- 00531 00533 00534 00536 KernelVertexIter vertices_begin(); 00537 KernelConstVertexIter vertices_begin() const; 00538 KernelVertexIter vertices_end(); 00539 KernelConstVertexIter vertices_end() const; 00540 KernelEdgeIter edges_begin(); 00541 KernelConstEdgeIter edges_begin() const; 00542 KernelEdgeIter edges_end(); 00543 KernelConstEdgeIter edges_end() const; 00544 KernelFaceIter faces_begin(); 00545 KernelConstFaceIter faces_begin() const; 00546 KernelFaceIter faces_end(); 00547 KernelConstFaceIter faces_end() const; 00549 00550 00551 00552 private: 00553 00554 00555 // --- private functions --- 00556 00558 KernelT(const KernelT& _rhs); 00559 }; 00560 }; 00561 00562 00563 //============================================================================= 00564 } // namespace Concepts 00565 } // namespace OpenMesh 00566 //=============================================================================