Subversion Repositories gelsvn

Rev

Rev 362 | Rev 595 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 362 Rev 448
1
#ifndef __HMESHUTIL_MESH_OPTIMIZATION_H
1
#ifndef __HMESH_MESH_OPTIMIZATION_H
2
#define __HMESHUTIL_MESH_OPTIMIZATION_H
2
#define __HMESH_MESH_OPTIMIZATION_H
3
 
3
 
4
#include "HMesh/Manifold.h"
4
#include "HMesh/Manifold.h"
5
 
5
 
6
namespace HMesh
6
namespace HMesh
7
{
7
{
8
	/** This class represents the energy of an edge. It is used in optimization 
8
	/** This class represents the energy of an edge. It is used in optimization 
9
	schemes where edges are swapped (aka flipped). */
9
	schemes where edges are swapped (aka flipped). */
10
  class EnergyFun
10
  class EnergyFun
11
  {
11
  {
12
  public:
12
  public:
13
    virtual double delta_energy(HMesh::HalfEdgeIter) const = 0;
13
    virtual double delta_energy(HMesh::HalfEdgeIter) const = 0;
14
    virtual double energy(HMesh::HalfEdgeIter) const {return 0;}
14
    virtual double energy(HMesh::HalfEdgeIter) const {return 0;}
15
  };
15
  };
16
 
16
 
17
	/// Optimize in a greedy fashion.
17
	/// Optimize in a greedy fashion.
18
  void priority_queue_optimization(HMesh::Manifold& m, const EnergyFun& efun);
18
  void priority_queue_optimization(HMesh::Manifold& m, const EnergyFun& efun);
19
	/// Optimize with simulated annealing. Avoids getting trapped in local minima
19
	/// Optimize with simulated annealing. Avoids getting trapped in local minima
20
  void simulated_annealing_optimization(HMesh::Manifold& m, 
20
  void simulated_annealing_optimization(HMesh::Manifold& m, 
21
					const EnergyFun& efun,
21
					const EnergyFun& efun,
22
					int max_iter=10000);
22
					int max_iter=10000);
23
    
23
    
24
	/** Minimize the angle between adjacent triangles. Almost the same as mean curvature 
24
	/** Minimize the angle between adjacent triangles. Almost the same as mean curvature 
25
		minimization */
25
		minimization */
26
	void minimize_dihedral_angle(HMesh::Manifold& m,
26
	void minimize_dihedral_angle(HMesh::Manifold& m,
27
															 int max_iter=10000,
27
															 int max_iter=10000,
28
															 bool anneal=false,
28
															 bool anneal=false,
29
															 bool alpha=false,
29
															 bool alpha=false,
30
															 double gamma=4.0);
30
															 double gamma=4.0);
31
															 
31
															 
32
	/** Minimizes mean curvature. This is really the same as dihedral angle optimization
32
	/** Minimizes mean curvature. This is really the same as dihedral angle optimization
33
		except that we weight by edge length */
33
		except that we weight by edge length */
34
  void minimize_curvature(HMesh::Manifold& m, bool anneal=false);
34
  void minimize_curvature(HMesh::Manifold& m, bool anneal=false);
35
  
35
  
36
  /// Minimizes gaussian curvature. Probably less useful than mean curvature.
36
  /// Minimizes gaussian curvature. Probably less useful than mean curvature.
37
  void minimize_gauss_curvature(HMesh::Manifold& m, bool anneal=false);
37
  void minimize_gauss_curvature(HMesh::Manifold& m, bool anneal=false);
38
  
38
  
39
  /// Maximizes the minimum angle of triangles. Makes the mesh more Delaunay.
39
  /// Maximizes the minimum angle of triangles. Makes the mesh more Delaunay.
40
  void maximize_min_angle(HMesh::Manifold& m, float thresh, bool anneal=false);
40
  void maximize_min_angle(HMesh::Manifold& m, float thresh, bool anneal=false);
41
  
41
  
42
  /// Tries to achieve valence 6 internally and 4 along edges.
42
  /// Tries to achieve valence 6 internally and 4 along edges.
43
  void optimize_valency(HMesh::Manifold& m, bool anneal=false);
43
  void optimize_valency(HMesh::Manifold& m, bool anneal=false);
44
  
44
  
45
  /// Make radom flips. Useful for generating synthetic test cases.
45
  /// Make radom flips. Useful for generating synthetic test cases.
46
  void randomize_mesh(HMesh::Manifold& m, int max_iter);
46
  void randomize_mesh(HMesh::Manifold& m, int max_iter);
47
 
47
 
48
}
48
}
49
 
49
 
50
 
50
 
51
#endif
51
#endif
52
 
52