Subversion Repositories gelsvn

Rev

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

Rev 662 Rev 663
1
/*
1
/*
2
 *  VisObj.h
2
 *  VisObj.h
3
 *  GEL
3
 *  GEL
4
 *
4
 *
5
 *  Created by J. Andreas Bærentzen on 20/09/08.
5
 *  Created by J. Andreas Bærentzen on 20/09/08.
6
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
6
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
7
 *
7
 *
8
 */
8
 */
9
#ifndef __MESHEDIT_VISOBJ_H__
9
#ifndef __MESHEDIT_VISOBJ_H__
10
#define __MESHEDIT_VISOBJ_H__
10
#define __MESHEDIT_VISOBJ_H__
11
 
11
 
12
 
12
 
13
#include <string>
13
#include <string>
14
#include "../GL/glew.h"
14
#include "../GL/glew.h"
15
#include "../HMesh/Manifold.h"
15
#include "../HMesh/Manifold.h"
16
#include "../CGLA/Vec3d.h"
16
#include "../CGLA/Vec3d.h"
17
#include "../GLGraphics/draw.h"
17
#include "../GLGraphics/draw.h"
18
#include "../GLGraphics/Console.h"
18
#include "../GLGraphics/Console.h"
19
#include "../GLGraphics/GLViewController.h"
19
#include "../GLGraphics/GLViewController.h"
20
#include "../GLGraphics/ManifoldRenderer.h"
20
#include "../GLGraphics/ManifoldRenderer.h"
21
#include "../HMesh/harmonics.h"
21
#include "../HMesh/harmonics.h"
22
 
22
 
23
extern int WINX;
23
extern int WINX;
24
extern int WINY;
24
extern int WINY;
25
 
25
 
26
namespace GLGraphics {
26
namespace GLGraphics {
27
 
27
 
28
class VisObj
28
class VisObj
29
{
29
{
30
    std::string file = "";
30
    std::string file = "";
31
    GLGraphics::GLViewController view_ctrl;
31
    GLGraphics::GLViewController view_ctrl;
32
    bool create_display_list = true;
32
    bool create_display_list = true;
33
    
33
    
34
    HMesh::Manifold mani;
34
    HMesh::Manifold mani;
35
    HMesh::Manifold old_mani;
35
    HMesh::Manifold old_mani;
36
    
36
    
37
    GLGraphics::ManifoldRenderer* renderer = nullptr;
37
    GLGraphics::ManifoldRenderer* renderer = nullptr;
38
    
38
    
39
    bool active_selection = false;
39
    bool active_selection = false;
40
    HMesh::VertexAttributeVector<int> vertex_selection;
40
    HMesh::VertexAttributeVector<int> vertex_selection;
41
    HMesh::VertexAttributeVector<double> scalar_field;
41
    HMesh::VertexAttributeVector<double> scalar_field;
-
 
42
    HMesh::VertexAttributeVector<CGLA::Vec3d> line_field;
42
    
43
    
43
    HMesh::Harmonics* harm;
44
    HMesh::Harmonics* harm;
44
    CGLA::Vec3d bsphere_center;
45
    CGLA::Vec3d bsphere_center;
45
    float bsphere_radius;
46
    float bsphere_radius;
46
    
47
    
47
    void produce_renderer(const std::string& display_method , Console& cs, bool smooth, float gamma);
48
    void produce_renderer(const std::string& display_method , Console& cs, bool smooth, float gamma);
48
    void draw_selection();
49
    void draw_selection();
49
public:
50
public:
50
    
51
    
51
    VisObj(): view_ctrl(WINX,WINY, CGLA::Vec3f(0), 1.0) {}
52
    VisObj(): view_ctrl(WINX,WINY, CGLA::Vec3f(0), 1.0) {}
52
    
53
    
53
    HMesh::VertexAttributeVector<int>& get_vertex_selection() {
54
    HMesh::VertexAttributeVector<int>& get_vertex_selection() {
54
        return vertex_selection;
55
        return vertex_selection;
55
    }
56
    }
56
    bool select_vertex(const CGLA::Vec2i& pos);
57
    bool select_vertex(const CGLA::Vec2i& pos);
57
    void clear_selection() {
58
    void clear_selection() {
58
        for(auto vid : mani.vertices()) vertex_selection[vid] = 0;
59
        for(auto vid : mani.vertices()) vertex_selection[vid] = 0;
59
        active_selection = false;
60
        active_selection = false;
60
    }
61
    }
-
 
62
    
61
    HMesh::VertexAttributeVector<double>& get_scalar_field_attrib_vector() {
63
    HMesh::VertexAttributeVector<double>& get_scalar_field_attrib_vector() {
62
        return scalar_field;
64
        return scalar_field;
63
    }
65
    }
-
 
66
 
-
 
67
    HMesh::VertexAttributeVector<CGLA::Vec3d>& get_line_field_attrib_vector() {
-
 
68
        return line_field;
-
 
69
    }
64
    
70
    
65
    const std::string& file_name() const {return file;}
71
    const std::string& file_name() const {return file;}
66
    
72
    
67
    float get_bsphere_radius() const { return bsphere_radius;}
73
    float get_bsphere_radius() const { return bsphere_radius;}
68
    
74
    
69
    HMesh::Manifold& mesh() {return mani;}
75
    HMesh::Manifold& mesh() {return mani;}
70
    const HMesh::Manifold& mesh_old() const {return old_mani;}
76
    const HMesh::Manifold& mesh_old() const {return old_mani;}
71
    
77
    
72
    void save_old() {old_mani = mani;}
78
    void save_old() {old_mani = mani;}
73
    void restore_old() {mani = old_mani;}
79
    void restore_old() {mani = old_mani;}
74
    
80
    
75
    GLGraphics::GLViewController& view_control() {return view_ctrl;}
81
    GLGraphics::GLViewController& view_control() {return view_ctrl;}
76
    
82
    
77
    void refit();
83
    void refit();
78
    
84
    
79
    bool reload(std::string _file);
85
    bool reload(std::string _file);
80
    
86
    
81
    bool add_mesh(std::string _file);
87
    bool add_mesh(std::string _file);
82
    
88
    
83
    void display(const std::string& display_method , GLGraphics::Console& cs, bool smooth, float gamma);
89
    void display(const std::string& display_method , GLGraphics::Console& cs, bool smooth, float gamma);
84
    
90
    
85
    void post_create_display_list()
91
    void post_create_display_list()
86
    {
92
    {
87
        create_display_list = true;
93
        create_display_list = true;
88
    }
94
    }
89
    
95
    
90
    void harmonics_analyze() {
96
    void harmonics_analyze() {
91
        harm = new HMesh::Harmonics(mani);
97
        harm = new HMesh::Harmonics(mani);
92
    }
98
    }
-
 
99
 
-
 
100
    void harmonics_reset_shape() {
-
 
101
        harm->reset_shape();
93
    
102
    }
-
 
103
 
-
 
104
    void harmonics_partial_reconstruct(int E0, int E1, float scale) {
-
 
105
        harm->partial_reconstruct(E0,E1, scale);
-
 
106
    }
-
 
107
 
94
};
108
};
95
 
109
 
96
}
110
}
97
#endif
111
#endif
98
 
112