Subversion Repositories gelsvn

Rev

Rev 596 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 596 Rev 614
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 <HMesh/AttributeVector.h>
16
#include <LinAlg/Matrix.h>
16
#include <LinAlg/Matrix.h>
17
#include <LinAlg/Vector.h>
17
#include <LinAlg/Vector.h>
18
#include <GLGraphics/ManifoldRenderer.h>
18
#include <GLGraphics/ManifoldRenderer.h>
19
#include <GLGraphics/Console.h>
19
#include <GLGraphics/Console.h>
20
 
20
 
21
#define USE_SPARSE_MATRIX 0
21
#define USE_SPARSE_MATRIX 0
22
 
22
 
23
class Harmonics
23
class Harmonics
24
{
24
{
25
	HMesh::Manifold& mani;
25
	HMesh::Manifold& mani;
26
    HMesh::VertexAttributeVector<int> vtouched;
26
    HMesh::VertexAttributeVector<int> vtouched;
27
	
27
	
28
	int maximum_eigenvalue;
28
	int maximum_eigenvalue;
29
 
29
    
30
	static bool is_initialized;
30
    bool is_initialized;
31
	static GLuint prog_P0;
31
    GLuint prog_P0;
32
	
32
	
33
	std::vector<CGLA::Vec3d> proj;
33
	std::vector<CGLA::Vec3d> proj;
34
	
34
	
35
	LinAlg::CMatrix Q;
35
	LinAlg::CMatrix Q;
36
	LinAlg::CVector qnorm;
36
	LinAlg::CVector qnorm;
37
	LinAlg::CVector V;
37
	LinAlg::CVector V;
38
	LinAlg::CVector S;
38
	LinAlg::CVector S;
-
 
39
    
-
 
40
    GLGraphics::Console::variable<float> display_harmonics_time;
-
 
41
    GLGraphics::Console::variable<int> display_harmonics_diffuse;
-
 
42
    GLGraphics::Console::variable<int> display_harmonics_highlight;
-
 
43
    
39
	std::vector<float> max_eig_values;
44
	std::vector<float> max_eig_values;
40
 
45
    
41
	void make_laplace_operator();
46
	void make_laplace_operator();
42
	void make_laplace_operator_sparse();
47
	void make_laplace_operator_sparse();
43
 
48
    
44
public:
49
public:
45
	
50
	
46
	/// Initialize API (must be called first)
-
 
47
	static void init(GLGraphics::Console& cs);
-
 
48
	
-
 
49
	/// Initial analysis of harmonics (must be called second)
51
	/// Initial analysis of harmonics
50
	Harmonics(HMesh::Manifold& mani);
52
	Harmonics(HMesh::Manifold& mani, GLGraphics::Console& cs);
51
	
53
	
52
	/// Add a frequency to mesh reconstruction
54
	/// Add a frequency to mesh reconstruction
53
	void add_frequency(int f, float scale = 1.0f);
55
	void add_frequency(int f, float scale = 1.0f);
54
	
56
	
55
	/// Reset the shape to use 0 eigenvalues
57
	/// Reset the shape to use 0 eigenvalues
56
	void reset_shape();
58
	void reset_shape();
57
	
59
	
58
	/// Do a partial reconstruct with an interval of eigenvalues
60
	/// Do a partial reconstruct with an interval of eigenvalues
59
	void partial_reconstruct(int E0, int E1, float scale=1.0f);
61
	void partial_reconstruct(int E0, int E1, float scale=1.0f);
60
	
62
	
61
	/// Parse keystrokes that would influence the interactive display
63
	/// Parse keystrokes that would influence the interactive display
62
	void parse_key(unsigned char key);
64
	void parse_key(unsigned char key);
63
	
65
	
64
	/// Draw with eigenvalues
66
	/// Draw with eigenvalues
65
	void draw_adf();
67
	void draw_adf();
66
	
68
	
67
};
69
};
68
 
70
 
69
 
71
 
70
class HarmonicsRenderer: public GLGraphics::ManifoldRenderer
72
class HarmonicsRenderer: public GLGraphics::ManifoldRenderer
71
	{
73
{
72
		
74
    
73
	public:
75
public:
74
		HarmonicsRenderer(Harmonics* h)
76
    HarmonicsRenderer(Harmonics* h)
75
		{
77
    {
76
			glNewList(display_list,GL_COMPILE);
78
        glNewList(display_list,GL_COMPILE);
77
			if(h) h->draw_adf();
79
        if(h) h->draw_adf();
78
			glEndList();
80
        glEndList();
79
		}
81
    }
80
	};
82
};
81
 
83
 
82
 
84
 
83
#endif
85
#endif
84
 
86
 
85
 
87