OpenMesh
OpenMesh/Tools/Subdivider/Adaptive/Composite/RulesT.hh
Go to the documentation of this file.
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 
00047 //=============================================================================
00048 //
00049 //  Composite Subdivision and Averaging Rules
00050 //
00051 //=============================================================================
00052 
00053 #ifndef OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH
00054 #define OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH
00055 
00056 
00057 //== INCLUDES =================================================================
00058 
00059 #include <OpenMesh/Core/System/config.hh>
00060 #include <OpenMesh/Tools/Subdivider/Adaptive/Composite/RuleInterfaceT.hh>
00061 // -------------------- STL
00062 #include <vector>
00063 
00064 
00065 #if defined(OM_CC_MIPS) // avoid warnings
00066 #  define MIPS_WARN_WA( Item ) \
00067   void raise(typename M:: ## Item ## Handle &_h, state_t _target_state ) \
00068   { Inherited::raise(_h, _target_state); }
00069 #else
00070 #  define MIPS_WARN_WA( Item )
00071 #endif
00072 
00073 //== NAMESPACE ================================================================
00074 
00075 namespace OpenMesh   { // BEGIN_NS_OPENMESH
00076 namespace Subdivider { // BEGIN_NS_SUBDIVIDER
00077 namespace Adaptive   { // BEGIN_NS_ADAPTIVE
00078 
00079 
00080 //== CLASS DEFINITION =========================================================
00081 
00086 //=============================================================================
00087   
00090 template <class M> class Tvv3 : public RuleInterfaceT<M>
00091 {
00092   COMPOSITE_RULE( Tvv3, M );
00093 private:
00094   typedef RuleInterfaceT<M>                 Base;
00095   
00096 public:
00097 
00098   typedef RuleInterfaceT<M> Inherited;
00099 
00100   Tvv3(M& _mesh) : Inherited(_mesh) { Base::set_subdiv_type(3); };
00101 
00102   void raise(typename M::FaceHandle&   _fh, state_t _target_state);
00103   void raise(typename M::VertexHandle& _vh, state_t _target_state);
00104   MIPS_WARN_WA(Edge); // avoid warning
00105 };
00106 
00107 
00108 //=============================================================================
00109 
00110 
00113 template <class M> class Tvv4 : public RuleInterfaceT<M>
00114 {
00115   COMPOSITE_RULE( Tvv4, M );
00116 
00117 private:
00118   typedef RuleInterfaceT<M>                 Base;
00119 public:
00120   typedef typename M::HalfedgeHandle HEH;
00121   typedef typename M::VertexHandle   VH;
00122    
00123   typedef RuleInterfaceT<M> Inherited;
00124 
00125   Tvv4(M& _mesh) : Inherited(_mesh) { Base::set_subdiv_type(4); };
00126 
00127   void raise(typename M::FaceHandle&   _fh, state_t _target_state); 
00128   void raise(typename M::VertexHandle& _vh, state_t _target_state);
00129   void raise(typename M::EdgeHandle&   _eh, state_t _target_state);
00130 
00131 private:
00132 
00133   void split_edge(HEH& _hh, VH& _vh, state_t _target_state);
00134   void check_edge(const typename M::HalfedgeHandle& _hh, 
00135                   state_t _target_state);
00136 };
00137 
00138 
00139 //=============================================================================
00140 
00141 
00144 template <class M> class VF : public RuleInterfaceT<M>
00145 {
00146   COMPOSITE_RULE( VF, M );
00147 private:
00148   typedef RuleInterfaceT<M>                 Base;
00149 
00150 public:
00151   typedef RuleInterfaceT<M> Inherited;
00152 
00153   VF(M& _mesh) : Inherited(_mesh) {}
00154 
00155   void raise(typename M::FaceHandle& _fh, state_t _target_state);
00156   MIPS_WARN_WA(Edge);
00157   MIPS_WARN_WA(Vertex);
00158 };
00159 
00160 
00161 //=============================================================================
00162 
00163 
00166 template <class M> class FF : public RuleInterfaceT<M>
00167 {
00168   COMPOSITE_RULE( FF, M );
00169 private:
00170   typedef RuleInterfaceT<M>                 Base;
00171 
00172 public:
00173   typedef RuleInterfaceT<M> Inherited;
00174 
00175   FF(M& _mesh) : Inherited(_mesh) {}
00176 
00177   void raise(typename M::FaceHandle& _fh, state_t _target_state);
00178   MIPS_WARN_WA(Vertex); // avoid warning
00179   MIPS_WARN_WA(Edge  ); // avoid warning
00180 };
00181 
00182 
00183 //=============================================================================
00184 
00185 
00188 template <class M> class FFc : public RuleInterfaceT<M>
00189 {
00190   COMPOSITE_RULE( FFc, M );
00191 private:
00192   typedef RuleInterfaceT<M>                 Base;
00193 
00194 public:
00195   typedef RuleInterfaceT<M> Inherited;
00196 
00197   FFc(M& _mesh) : Inherited(_mesh) {}
00198 
00199   void raise(typename M::FaceHandle& _fh, state_t _target_state);
00200   MIPS_WARN_WA(Vertex); // avoid warning
00201   MIPS_WARN_WA(Edge  ); // avoid warning
00202 };
00203 
00204 
00205 //=============================================================================
00206 
00207 
00210 template <class M> class FV : public RuleInterfaceT<M>
00211 {
00212   COMPOSITE_RULE( FV, M );
00213 private:
00214   typedef RuleInterfaceT<M>                 Base;
00215 
00216 public:
00217   typedef RuleInterfaceT<M> Inherited;
00218 
00219   FV(M& _mesh) : Inherited(_mesh) {}
00220 
00221   void raise(typename M::VertexHandle& _vh, state_t _target_state);
00222   MIPS_WARN_WA(Face); // avoid warning
00223   MIPS_WARN_WA(Edge); // avoid warning
00224 };
00225 
00226 
00227 //=============================================================================
00228 
00229 
00232 template <class M> class FVc : public RuleInterfaceT<M>
00233 {
00234   COMPOSITE_RULE( FVc, M );
00235 private:
00236   typedef RuleInterfaceT<M>                 Base;
00237 
00238 public:
00239   typedef RuleInterfaceT<M> Inherited;
00240 
00241   FVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
00242 
00243   void raise(typename M::VertexHandle& _vh, state_t _target_state);
00244   MIPS_WARN_WA(Face); // avoid warning
00245   MIPS_WARN_WA(Edge); // avoid warning
00246 
00247   static void init_coeffs(size_t _max_valence);
00248   static const std::vector<double>& coeffs() { return coeffs_; }
00249 
00250   double coeff( size_t _valence )
00251   {
00252     assert(_valence < coeffs_.size());
00253     return coeffs_[_valence];
00254   }
00255 
00256 private:
00257 
00258   static std::vector<double> coeffs_;
00259 
00260 };
00261 
00262 
00263 //=============================================================================
00264 
00265 
00268 template <class M> class VV : public RuleInterfaceT<M>
00269 {
00270   COMPOSITE_RULE( VV, M );
00271 private:
00272   typedef RuleInterfaceT<M>                 Base;
00273 
00274 public:
00275 
00276   typedef RuleInterfaceT<M> Inherited;
00277 
00278   VV(M& _mesh) : Inherited(_mesh) {}
00279 
00280   void raise(typename M::VertexHandle& _vh, state_t _target_state);
00281   MIPS_WARN_WA(Face); // avoid warning
00282   MIPS_WARN_WA(Edge); // avoid warning
00283 };
00284 
00285 
00286 //=============================================================================
00287 
00288 
00291 template <class M> class VVc : public RuleInterfaceT<M>
00292 {
00293   COMPOSITE_RULE( VVc, M );
00294 private:
00295   typedef RuleInterfaceT<M>                 Base;
00296 
00297 public:
00298   typedef RuleInterfaceT<M> Inherited;
00299 
00300   VVc(M& _mesh) : Inherited(_mesh) {}
00301 
00302   void raise(typename M::VertexHandle& _vh, state_t _target_state);
00303   MIPS_WARN_WA(Face); // avoid warning
00304   MIPS_WARN_WA(Edge); // avoid warning
00305 };
00306 
00307 
00308 //=============================================================================
00309 
00310 
00313 template <class M> class VE : public RuleInterfaceT<M>
00314 {
00315   COMPOSITE_RULE( VE, M );
00316 private:
00317   typedef RuleInterfaceT<M>                 Base;
00318 
00319 public:
00320   typedef RuleInterfaceT<M> Inherited;
00321 
00322   VE(M& _mesh) : Inherited(_mesh) {}
00323 
00324   void raise(typename M::EdgeHandle& _eh, state_t _target_state);
00325   MIPS_WARN_WA(Face  ); // avoid warning
00326   MIPS_WARN_WA(Vertex); // avoid warning
00327 };
00328 
00329 
00330 //=============================================================================
00331 
00332 
00335 template <class M> class VdE : public RuleInterfaceT<M>
00336 {
00337   COMPOSITE_RULE( VdE, M );
00338 private:
00339   typedef RuleInterfaceT<M>                 Base;
00340 
00341 public:
00342   typedef RuleInterfaceT<M> Inherited;
00343 
00344   VdE(M& _mesh) : Inherited(_mesh) {}
00345 
00346   void raise(typename M::EdgeHandle& _eh, state_t _target_state);
00347   MIPS_WARN_WA(Face  ); // avoid warning
00348   MIPS_WARN_WA(Vertex); // avoid warning
00349 };
00350 
00351 
00352 //=============================================================================
00353 
00354 
00357 template <class M> class VdEc : public RuleInterfaceT<M>
00358 {
00359   COMPOSITE_RULE( VdEc, M );
00360 private:
00361   typedef RuleInterfaceT<M>                 Base;
00362 
00363 public:
00364   typedef RuleInterfaceT<M> Inherited;
00365 
00366   VdEc(M& _mesh) : Inherited(_mesh) {}
00367 
00368   void raise(typename M::EdgeHandle& _eh, state_t _target_state);
00369   MIPS_WARN_WA(Face  ); // avoid warning
00370   MIPS_WARN_WA(Vertex); // avoid warning
00371 };
00372 
00373 
00374 //=============================================================================
00375 
00376 
00379 template <class M> class EV : public RuleInterfaceT<M>
00380 {
00381   COMPOSITE_RULE( EV, M );
00382 private:
00383   typedef RuleInterfaceT<M>                 Base;
00384 
00385 public:
00386   typedef RuleInterfaceT<M> Inherited;
00387 
00388   EV(M& _mesh) : Inherited(_mesh) {}
00389 
00390   void raise(typename M::VertexHandle& _vh, state_t _target_state);
00391   MIPS_WARN_WA(Face); // avoid warning
00392   MIPS_WARN_WA(Edge); // avoid warning
00393 };
00394 
00395 
00396 //=============================================================================
00397 
00398 
00401 template <class M> class EVc : public RuleInterfaceT<M>
00402 {
00403   COMPOSITE_RULE( EVc, M );
00404 private:
00405   typedef RuleInterfaceT<M>                 Base;
00406 
00407 public:
00408 
00409   typedef RuleInterfaceT<M> Inherited;
00410 
00411   EVc(M& _mesh) : Inherited(_mesh) { init_coeffs(50); }
00412 
00413   void raise(typename M::VertexHandle& _vh, state_t _target_state);
00414   MIPS_WARN_WA(Face); // avoid warning
00415   MIPS_WARN_WA(Edge); // avoid warning
00416 
00417   static void init_coeffs(size_t _max_valence);
00418   static const std::vector<double>& coeffs() { return coeffs_; }
00419 
00420   double coeff( size_t _valence )
00421   {
00422     assert(_valence < coeffs_.size());
00423     return coeffs_[_valence];
00424   }
00425 
00426 private:
00427 
00428   static std::vector<double> coeffs_;
00429   
00430 };
00431 
00432 
00433 //=============================================================================
00434 
00435 
00438 template <class M> class EF : public RuleInterfaceT<M>
00439 {
00440   COMPOSITE_RULE( EF, M );
00441 private:
00442   typedef RuleInterfaceT<M>                 Base;
00443 
00444 public:
00445   typedef RuleInterfaceT<M> Inherited;
00446 
00447   EF(M& _mesh) : Inherited(_mesh) {}
00448 
00449   void raise(typename M::FaceHandle& _fh, state_t _target_state);
00450   MIPS_WARN_WA(Edge  ); // avoid warning
00451   MIPS_WARN_WA(Vertex); // avoid warning
00452 };
00453 
00454 
00455 //=============================================================================
00456 
00457 
00460 template <class M> class FE : public RuleInterfaceT<M>
00461 {
00462   COMPOSITE_RULE( FE, M );
00463 private:
00464   typedef RuleInterfaceT<M>                 Base;
00465 
00466 public:
00467   typedef RuleInterfaceT<M> Inherited;
00468 
00469   FE(M& _mesh) : Inherited(_mesh) {}
00470 
00471   void raise(typename M::EdgeHandle& _eh, state_t _target_state);
00472   MIPS_WARN_WA(Face  ); // avoid warning
00473   MIPS_WARN_WA(Vertex); // avoid warning
00474 };
00475 
00476 
00477 //=============================================================================
00478 
00479 
00482 template <class M> class EdE : public RuleInterfaceT<M>
00483 {
00484   COMPOSITE_RULE( EdE, M );
00485 private:
00486   typedef RuleInterfaceT<M>                 Base;
00487 
00488 public:
00489   typedef RuleInterfaceT<M> Inherited;
00490 
00491   EdE(M& _mesh) : Inherited(_mesh) {}
00492 
00493   void raise(typename M::EdgeHandle& _eh, state_t _target_state);
00494   MIPS_WARN_WA(Face  ); // avoid warning
00495   MIPS_WARN_WA(Vertex); // avoid warning
00496 };
00497 
00498 
00499 //=============================================================================
00500 
00501 
00504 template <class M> class EdEc : public RuleInterfaceT<M>
00505 {
00506   COMPOSITE_RULE( EdEc, M );
00507 private:
00508   typedef RuleInterfaceT<M>                 Base;
00509 
00510 public:
00511   typedef RuleInterfaceT<M> Inherited;
00512 
00513   EdEc(M& _mesh) : Inherited(_mesh) {}
00514 
00515   void raise(typename M::EdgeHandle& _eh, state_t _target_state);
00516   MIPS_WARN_WA(Face  ); // avoid warning
00517   MIPS_WARN_WA(Vertex); // avoid warning
00518 };
00519 
00520 // ----------------------------------------------------------------------------
00521 
00522 #undef MIPS_WARN_WA
00523 
00524 //=============================================================================
00525 } // END_NS_ADAPTIVE
00526 } // END_NS_SUBDIVIDER
00527 } // END_NS_OPENMESH
00528 //=============================================================================
00529 #if defined(OM_INCLUDE_TEMPLATES) && !defined(OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_CC)
00530 #  define OPENMESH_SUBDIVIDER_TEMPLATES
00531 #  include "RulesT.cc"
00532 #endif
00533 //=============================================================================
00534 #endif // OPENMESH_SUBDIVIDER_ADAPTIVE_RULEST_HH defined
00535 //=============================================================================
00536