- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- File List
- File Members

# Doc/Concepts/MeshKernel.hh

    00001 //=============================================================================
    00002 //
    00003 //                               OpenMesh
    00004 //      Copyright (C) 2001-2005 by Computer Graphics Group, RWTH Aachen
    00005 //                           www.openmesh.org
    00006 //
    00007 //-----------------------------------------------------------------------------
    00008 //
    00009 //                                License
    00010 //
    00011 //   This library is free software; you can redistribute it and/or modify it
    00012 //   under the terms of the GNU Library General Public License as published
    00013 //   by the Free Software Foundation, version 2.
    00014 //
    00015 //   This library is distributed in the hope that it will be useful, but
    00016 //   WITHOUT ANY WARRANTY; without even the implied warranty of
    00017 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00018 //   Library General Public License for more details.
    00019 //
    00020 //   You should have received a copy of the GNU Library General Public
    00021 //   License along with this library; if not, write to the Free Software
    00022 //   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    00023 //
    00024 //-----------------------------------------------------------------------------
    00025 //
    00026 //   $Revision: 1.2 $
    00027 //   $Date: 2005-12-21 14:05:27 $
    00028 //
    00029 //=============================================================================
    00030
    00031
    00032 //=============================================================================
    00033 //
    00034 //  Kernel Concept
    00035 //
    00036 //=============================================================================
    00037
    00038
    00039 #error this file is for documentation purposes only
    00040
    00041
    00042 //== NAMESPACES ===============================================================
    00043
    00044
    00045 namespace OpenMesh {
    00046 namespace Concepts {
    00047
    00048
    00049 //== CLASS DEFINITION =========================================================
    00050
    00051
    00064 template <class FinalMeshItems> class KernelT
    00065 {
    00066 public:
    00067
    00069
    00070
    00072   typedef typename FinalMeshItems::Vertex             Vertex;
    00073   typedef typename FinalMeshItems::Halfedge           Halfedge;
    00074   typedef typename FinalMeshItems::Edge               Edge;
    00075   typedef typename FinalMeshItems::Face               Face;
    00076   typedef typename FinalMeshItems::Point              Point;
    00077   typedef typename FinalMeshItems::Scalar             Scalar;
    00078   typedef typename FinalMeshItems::Normal             Normal;
    00079   typedef typename FinalMeshItems::Color              Color;
    00080   typedef typename FinalMeshItems::TexCoord           TexCoord;
    00081   typedef typename FinalMeshItems::VertexHandle       VertexHandle;
    00082   typedef typename FinalMeshItems::HalfedgeHandle     HalfedgeHandle;
    00083   typedef typename FinalMeshItems::EdgeHandle         EdgeHandle;
    00084   typedef typename FinalMeshItems::FaceHandle         FaceHandle;
    00085
    00087
    00088
    00090
    00091
    00092   typedef SomeIterator KernelVertexIter;
    00093   typedef SomeIterator KernelConstVertexIter;
    00094   typedef SomeIterator KernelEdgeIter;
    00095   typedef SomeIterator KernelConstEdgeIter;
    00096   typedef SomeIterator KernelFaceIter;
    00097   typedef SomeIterator KernelConstFaceIter;
    00099
    00101
    00102
    00103   KernelT() {}
    00104
    00106   ~KernelT();
    00108
    00110   KernelT& operator=(const KernelT& _rhs);
    00111
    00112
    00125   void reserve( unsigned int _n_vertices,
    00126                 unsigned int _n_edges,
    00127                 unsigned int _n_faces );
    00128
    00129
    00131
    00132
    00133   const Vertex& vertex(VertexHandle _h) const { return deref(_h); }
    00134   Vertex& vertex(VertexHandle _h) { return deref(_h); }
    00135   const Halfedge& halfedge(HalfedgeHandle _h) const { return deref(_h); }
    00136   Halfedge& halfedge(HalfedgeHandle _h) { return deref(_h); }
    00137   const Edge& edge(EdgeHandle _h) const { return deref(_h); }
    00138   Edge& edge(EdgeHandle _h) { return deref(_h); }
    00139   const Face& face(FaceHandle _h) const { return deref(_h); }
    00140   Face& face(FaceHandle _h) { return deref(_h); }
    00142
    00143
    00145
    00146
    00147   VertexHandle handle(const Vertex& _v) const;
    00148   HalfedgeHandle handle(const Halfedge& _he) const;
    00149   EdgeHandle handle(const Edge& _e) const;
    00150   FaceHandle handle(const Face& _f) const;
    00152
    00153
    00155
    00156
    00157   VertexHandle   vertex_handle(unsigned int _i) const;
    00158   HalfedgeHandle halfedge_handle(unsigned int _i) const;
    00159   EdgeHandle     edge_handle(unsigned int _i) const;
    00160   FaceHandle     face_handle(unsigned int _i) const;
    00162
    00163
    00165
    00166
    00167   void clear();
    00173   void garbage_collection();
    00174
    00178   void remove_last_vertex() { vertices_.pop_back(); }
    00182   void remove_last_edge()   { edges_.pop_back();    }
    00186   void remove_last_face()   { faces_.pop_back();    }
    00187
    00189
    00190
    00191
    00192
    00194
    00195
    00196   unsigned int n_vertices() const;
    00198   unsigned int n_halfedges() const;
    00200   unsigned int n_edges() const;
    00202   unsigned int n_faces() const;
    00204   bool vertices_empty() const;
    00206   bool halfedges_empty() const;
    00208   bool edges_empty() const;
    00210   bool faces_empty() const;
    00212
    00213
    00214
    00216
    00217
    00218   HalfedgeHandle halfedge_handle(VertexHandle _vh) const;
    00220   void set_halfedge_handle(VertexHandle _vh, HalfedgeHandle _heh);
    00222   const Point& point(VertexHandle _vh) const;
    00224   const Point& point(const Vertex& _v) const;
    00226   void set_point(VertexHandle _vh, const Point& _p);
    00228   void set_point(Vertex& _v, const Point& _p);
    00230
    00231
    00232
    00233
    00235
    00236
    00237   VertexHandle to_vertex_handle(HalfedgeHandle _heh) const;
    00240   VertexHandle from_vertex_handle(HalfedgeHandle _heh) const;
    00242   void set_vertex_handle(HalfedgeHandle _heh, VertexHandle _vh);
    00245   FaceHandle face_handle(HalfedgeHandle _heh) const;
    00247   void set_face_handle(HalfedgeHandle _heh, FaceHandle _fh);
    00249   HalfedgeHandle next_halfedge_handle(HalfedgeHandle _heh) const;
    00253   void set_next_halfedge_handle(HalfedgeHandle _heh, HalfedgeHandle _nheh);
    00257   HalfedgeHandle prev_halfedge_handle(HalfedgeHandle _heh) const;
    00259   HalfedgeHandle opposite_halfedge_handle(HalfedgeHandle _heh) const;
    00261   HalfedgeHandle ccw_rotated_halfedge_handle(HalfedgeHandle _heh) const;
    00263   HalfedgeHandle cw_rotated_halfedge_handle(HalfedgeHandle _heh) const;
    00265   EdgeHandle edge_handle(HalfedgeHandle _heh) const;
    00267
    00268
    00269
    00271
    00272
    00273   HalfedgeHandle halfedge_handle(EdgeHandle _eh, unsigned int _i) const;
    00275
    00276
    00277
    00279
    00280
    00281   HalfedgeHandle halfedge_handle(FaceHandle _fh) const;
    00283   void set_halfedge_handle(FaceHandle _fh, HalfedgeHandle _heh);
    00285
    00286
    00287 public: // Standard Property Management
    00288
    00290
    00291
    00292   // vertex
    00293   const Point& point(VertexHandle _vh) const;
    00294   void set_point(VertexHandle _vh, const Point& _p);
    00295   Point& point(VertexHandle _vh);
    00296
    00297   const Normal& normal(VertexHandle _vh) const;
    00298   void set_normal(VertexHandle _vh, const Normal& _n);
    00299
    00300   const Color& color(VertexHandle _vh) const;
    00301   void set_color(VertexHandle _vh, const Color& _c)
    00302
    00303   const TexCoord& texcoord(VertexHandle _vh) const;
    00304   void set_texcoord(VertexHandle _vh, const TexCoord& _t);
    00305
    00306   const StatusInfo& status(VertexHandle _vh) const;
    00307   StatusInfo& status(VertexHandle _vh);
    00308
    00309   // halfedge
    00310   const StatusInfo& status(HalfedgeHandle _vh) const;
    00311   StatusInfo& status(HalfedgeHandle _vh);
    00312
    00313   // edge
    00314   const StatusInfo& status(EdgeHandle _vh) const;
    00315   StatusInfo& status(EdgeHandle _vh);
    00316
    00317   // face
    00318   const Normal& normal(FaceHandle _fh) const;
    00319   void set_normal(FaceHandle _fh, const Normal& _n);
    00320
    00321   const Color& color(FaceHandle _fh) const;
    00322   void set_color(FaceHandle _fh, const Color& _c);
    00323
    00324   const StatusInfo& status(FaceHandle _vh) const;
    00325   StatusInfo& status(FaceHandle _vh);
    00326
    00328
    00330
    00331
    00332   void request_vertex_normals();
    00333   void request_vertex_colors();
    00334   void request_vertex_texcoords();
    00335   void request_vertex_status();
    00336
    00337   void request_halfedge_status();
    00338
    00339   void request_edge_status();
    00340
    00341   void request_face_normals();
    00342   void request_face_colors();
    00343   void request_face_status();
    00345
    00347
    00348
    00349   void release_vertex_normals();
    00350   void release_vertex_colors();
    00351   void release_vertex_texcoords();
    00352   void release_vertex_status();
    00353
    00354   void release_halfedge_status();
    00355
    00356   void release_edge_status();
    00357
    00358   void release_face_normals();
    00359   void release_face_colors();
    00360   void release_face_status();
    00362
    00364
    00365
    00366   bool has_vertex_normals()   const;
    00367   bool has_vertex_colors()    const;
    00368   bool has_vertex_texcoords() const;
    00369   bool has_vertex_status()    const;
    00370   bool has_edge_status()      const;
    00371   bool has_halfedge_status()  const;
    00372   bool has_face_normals()     const;
    00373   bool has_face_colors()      const;
    00374   bool has_face_status()      const;
    00376
    00377 public: // Property Management
    00378
    00380
    00382
    00383
    00384
    00385   template <typename T> bool add_property( [VEHFM]PropHandleT<T>& _ph,
    00386                                            const std::string& _name = "" );
    00388
    00390
    00391
    00392   template <typename T> void remove_property( [VEHFM]PropHandleT<T>& );
    00394
    00396
    00397
    00398   template <typename T>
    00399   bool get_property_handle( [VEHFM]PropHandleT<T>& ph, const std::string& _n ) const;
    00401
    00403
    00404
    00405   template <typename T> PropertyT<T>& property( [VEHF]PropHandleT<T> _ph );
    00406   template <typename T> const PropertyT<T>& property( [VEHF]PropHandleT<T> _ph ) const;
    00407   template <typename T> PropertyT<T>& mproperty( MPropHandleT<T> _ph );
    00408   template <typename T> const PropertyT<T>& mproperty( MPropHandleT<T> _ph ) const;
    00410
    00412
    00413
    00415   template <typename T>
    00416   T& property( VPropHandleT<T> _ph, VertexHandle _vh );
    00417   template <typename T>
    00418   const T& property( VPropHandleT<T> _ph, VertexHandle _vh ) const;
    00419
    00420   template <typename T>
    00421   T& property( EPropHandleT<T> _ph, EdgeHandle _vh );
    00422   template <typename T>
    00423   const T& property( EPropHandleT<T> _ph, EdgeHandle _vh ) const;
    00424
    00425   template <typename T>
    00426   T& property( HPropHandleT<T> _ph, HalfedgeHandle _vh );
    00427   template <typename T>
    00428   const T& property( HPropHandleT<T> _ph, HalfedgeHandle _vh ) const;
    00429
    00430   template <typename T>
    00431   T& property( FPropHandleT<T> _ph, FaceHandle _vh );
    00432   template <typename T>
    00433   const T& property( FPropHandleT<T> _ph, FaceHandle _vh ) const;
    00434
    00435   template <typename T>
    00436   T& property( MPropHandleT<T> _ph );
    00437   template <typename T>
    00438   const T& property( MPropHandleT<T> _ph ) const;
    00439
    00441
    00442 public:
    00443
    00444
    00446
    00447
    00449   VertexHandle new_vertex();
    00452   VertexHandle new_vertex(const Point& _p);
    00455   VertexHandle new_vertex(const Vertex& _v);
    00461   HalfedgeHandle new_edge(VertexHandle _start_vertex_handle,
    00462                           VertexHandle _end_vertex_handle);
    00463
    00467   FaceHandle new_face();
    00470   FaceHandle new_face(const Face& _f);
    00472
    00473
    00474   // --- iterators ---
    00475
    00477
    00478
    00480   KernelVertexIter vertices_begin();
    00481   KernelConstVertexIter vertices_begin() const;
    00482   KernelVertexIter vertices_end();
    00483   KernelConstVertexIter vertices_end() const;
    00484   KernelEdgeIter edges_begin();
    00485   KernelConstEdgeIter edges_begin() const;
    00486   KernelEdgeIter edges_end();
    00487   KernelConstEdgeIter edges_end() const;
    00488   KernelFaceIter faces_begin();
    00489   KernelConstFaceIter faces_begin() const;
    00490   KernelFaceIter faces_end();
    00491   KernelConstFaceIter faces_end() const;
    00493
    00494
    00495
    00496 private:
    00497
    00498
    00499   // --- private functions ---
    00500
    00502   KernelT(const KernelT& _rhs);
    00503 };
    00504 };
    00505
    00506
    00507 //=============================================================================
    00508 } // namespace Concepts
    00509 } // namespace OpenMesh
    00510 //=============================================================================