Subversion Repositories gelsvn

Rev

Rev 182 | Rev 595 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#ifndef __HMESHUTIL_MESH_OPTIMIZATION_H
#define __HMESHUTIL_MESH_OPTIMIZATION_H

#include "HMesh/Manifold.h"

namespace HMesh
{
        /** This class represents the energy of an edge. It is used in optimization 
        schemes where edges are swapped (aka flipped). */
  class EnergyFun
  {
  public:
    virtual double delta_energy(HMesh::HalfEdgeIter) const = 0;
    virtual double energy(HMesh::HalfEdgeIter) const {return 0;}
  };

        /// Optimize in a greedy fashion.
  void priority_queue_optimization(HMesh::Manifold& m, const EnergyFun& efun);
        /// Optimize with simulated annealing. Avoids getting trapped in local minima
  void simulated_annealing_optimization(HMesh::Manifold& m, 
                                        const EnergyFun& efun,
                                        int max_iter=10000);
    
        /** Minimize the angle between adjacent triangles. Almost the same as mean curvature 
                minimization */
        void minimize_dihedral_angle(HMesh::Manifold& m,
                                                                                                                         int max_iter=10000,
                                                                                                                         bool anneal=false,
                                                                                                                         bool alpha=false,
                                                                                                                         double gamma=4.0);
                                                                                                                         
        /** Minimizes mean curvature. This is really the same as dihedral angle optimization
                except that we weight by edge length */
  void minimize_curvature(HMesh::Manifold& m, bool anneal=false);
  
  /// Minimizes gaussian curvature. Probably less useful than mean curvature.
  void minimize_gauss_curvature(HMesh::Manifold& m, bool anneal=false);
  
  /// Maximizes the minimum angle of triangles. Makes the mesh more Delaunay.
  void maximize_min_angle(HMesh::Manifold& m, float thresh, bool anneal=false);
  
  /// Tries to achieve valence 6 internally and 4 along edges.
  void optimize_valency(HMesh::Manifold& m, bool anneal=false);
  
  /// Make radom flips. Useful for generating synthetic test cases.
  void randomize_mesh(HMesh::Manifold& m, int max_iter);

}


#endif