Subversion Repositories gelsvn

Rev

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

Rev 457 Rev 596
1
/*
1
/*
2
 *  harmonics.h
2
 *  harmonics.h
3
 *  GEL
3
 *  GEL
4
 *
4
 *
5
 *  Created by J. Andreas Bærentzen on 01/09/08.
5
 *  Created by J. Andreas Bærentzen on 01/09/08.
6
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
6
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
7
 *
7
 *
8
 */
8
 */
9
 
9
 
10
#ifndef __MESHEDIT_HARMONICS_H__
10
#ifndef __MESHEDIT_HARMONICS_H__
11
#define __MESHEDIT_HARMONICS_H__
11
#define __MESHEDIT_HARMONICS_H__
12
 
12
 
13
#include <CGLA/Vec3d.h>
13
#include <CGLA/Vec3d.h>
14
#include <HMesh/Manifold.h>
14
#include <HMesh/Manifold.h>
-
 
15
#include <HMesh/AttributeVector.h>
15
#include <LinAlg/Matrix.h>
16
#include <LinAlg/Matrix.h>
16
#include <LinAlg/Vector.h>
17
#include <LinAlg/Vector.h>
17
#include "Renderer.h"
18
#include <GLGraphics/ManifoldRenderer.h>
18
 
-
 
19
#define USE_SPARSE_MATRIX 1
19
#include <GLGraphics/Console.h>
20
 
20
 
-
 
21
#define USE_SPARSE_MATRIX 0
21
 
22
 
22
class Harmonics
23
class Harmonics
23
{
24
{
24
	HMesh::Manifold& mani;
25
	HMesh::Manifold& mani;
-
 
26
    HMesh::VertexAttributeVector<int> vtouched;
25
	
27
	
26
	int maximum_eigenvalue;
28
	int maximum_eigenvalue;
27
 
29
 
28
	static bool is_initialized;
30
	static bool is_initialized;
29
	static GLuint prog_P0;
31
	static GLuint prog_P0;
30
	
32
	
31
	std::vector<CGLA::Vec3d> proj;
33
	std::vector<CGLA::Vec3d> proj;
32
	
34
	
33
	LinAlg::CMatrix Q;
35
	LinAlg::CMatrix Q;
34
	LinAlg::CVector qnorm;
36
	LinAlg::CVector qnorm;
35
	LinAlg::CVector V;
37
	LinAlg::CVector V;
36
	LinAlg::CVector S;
38
	LinAlg::CVector S;
37
	std::vector<float> max_eig_values;
39
	std::vector<float> max_eig_values;
38
 
40
 
39
	void make_laplace_operator();
41
	void make_laplace_operator();
40
	void make_laplace_operator_sparse();
42
	void make_laplace_operator_sparse();
41
 
43
 
42
public:
44
public:
43
	
45
	
44
	/// Initialize API (must be called first)
46
	/// Initialize API (must be called first)
45
	static void init();
47
	static void init(GLGraphics::Console& cs);
46
	
48
	
47
	/// Initial analysis of harmonics (must be called second)
49
	/// Initial analysis of harmonics (must be called second)
48
	Harmonics(HMesh::Manifold& mani);
50
	Harmonics(HMesh::Manifold& mani);
49
	
51
	
50
	/// Add a frequency to mesh reconstruction
52
	/// Add a frequency to mesh reconstruction
51
	void add_frequency(int f, float scale = 1.0f);
53
	void add_frequency(int f, float scale = 1.0f);
52
	
54
	
53
	/// Reset the shape to use 0 eigenvalues
55
	/// Reset the shape to use 0 eigenvalues
54
	void reset_shape();
56
	void reset_shape();
55
	
57
	
56
	/// Do a partial reconstruct with an interval of eigenvalues
58
	/// Do a partial reconstruct with an interval of eigenvalues
57
	void partial_reconstruct(int E0, int E1, float scale=1.0f);
59
	void partial_reconstruct(int E0, int E1, float scale=1.0f);
58
	
60
	
59
	/// Parse keystrokes that would influence the interactive display
61
	/// Parse keystrokes that would influence the interactive display
60
	void parse_key(unsigned char key);
62
	void parse_key(unsigned char key);
61
	
63
	
62
	/// Draw with eigenvalues
64
	/// Draw with eigenvalues
63
	void draw_adf();
65
	void draw_adf();
64
	
66
	
65
};
67
};
66
 
68
 
67
 
69
 
68
class HarmonicsRenderer: public ManifoldRenderer
70
class HarmonicsRenderer: public GLGraphics::ManifoldRenderer
69
	{
71
	{
70
		
72
		
71
	public:
73
	public:
72
		HarmonicsRenderer(Harmonics* h)
74
		HarmonicsRenderer(Harmonics* h)
73
		{
75
		{
74
			glNewList(display_list,GL_COMPILE);
76
			glNewList(display_list,GL_COMPILE);
75
			if(h) h->draw_adf();
77
			if(h) h->draw_adf();
76
			glEndList();
78
			glEndList();
77
		}
79
		}
78
	};
80
	};
79
 
81
 
80
 
82
 
81
#endif
83
#endif
82
 
84
 
83
 
85