Subversion Repositories gelsvn

Rev

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

/* ----------------------------------------------------------------------- *
 * This file is part of GEL, www.imm.dtu.dk/GEL
 * Copyright (C) the authors (see AUTHORS.txt) and DTU Informatics
 *
 * Principal authors:
 *  Christian Thode Larsen (thode2d@gmail.com)
 *  J. Andreas Baerentzen (jab@imm.dtu.dk)
 *
 * See LICENSE.txt for licensing information
 * ----------------------------------------------------------------------- */

#ifndef __HMESH_MESH_OPTIMIZATION_H
#define __HMESH_MESH_OPTIMIZATION_H

#include "Manifold.h"

namespace HMesh
{
    // forward declarations
    //class Manifold;
    //class HalfEdgeID;

    /// 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(const Manifold& m, HalfEdgeID h) const = 0;
        virtual double energy(const Manifold& m, HalfEdgeID h) const {return 0;}
    };

    /// Optimize in a greedy fashion.
    void priority_queue_optimization(Manifold& m, const EnergyFun& efun);

    /// Optimize with simulated annealing. Avoids getting trapped in local minima
    void simulated_annealing_optimization(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(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(Manifold& m, bool anneal=false);

    /// Minimizes gaussian curvature. Probably less useful than mean curvature.
    void minimize_gauss_curvature(Manifold& m, bool anneal=false);

    /// Maximizes the minimum angle of triangles. Makes the mesh more Delaunay.
    void maximize_min_angle(Manifold& m, float thresh, bool anneal=false);

    /// Tries to achieve valence 6 internally and 4 along edges.
    void optimize_valency(Manifold& m, bool anneal=false);

    /// Make radom flips. Useful for generating synthetic test cases.
    void randomize_mesh(Manifold& m, int max_iter);

}


#endif