Subversion Repositories gelsvn

Rev

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

Rev 656 Rev 657
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;
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
    
-
 
37
    GLGraphics::ManifoldRenderer* renderer = nullptr;
-
 
38
    
-
 
39
    bool active_selection = false;
-
 
40
    HMesh::VertexAttributeVector<int> vertex_selection;
-
 
41
    
36
    HMesh::Harmonics* harm;
42
    HMesh::Harmonics* harm;
37
    GLGraphics::ManifoldRenderer* renderer;
-
 
38
    CGLA::Vec3d bsphere_center;
43
    CGLA::Vec3d bsphere_center;
39
    float bsphere_radius;
44
    float bsphere_radius;
-
 
45
    
-
 
46
    void produce_renderer(const std::string& display_method , Console& cs, bool smooth, float gamma);
-
 
47
    void draw_selection();
40
public:
48
public:
41
    
49
    
42
    VisObj()
50
    VisObj(): view_ctrl(WINX,WINY, CGLA::Vec3f(0), 1.0) {}
43
    {
51
    
-
 
52
    HMesh::VertexAttributeVector<int>& get_vertex_selection() {
44
        file = "";
53
        return vertex_selection;
-
 
54
    }
45
        view_ctrl = GLGraphics::GLViewController(WINX,WINY, CGLA::Vec3f(0), 1.0);
55
    bool select_vertex(const CGLA::Vec2i& pos);
46
        create_display_list =true;
56
    void clear_selection() {
47
        renderer = nullptr;
57
        for(auto vid : mani.vertices()) vertex_selection[vid] = 0;
48
        
58
        active_selection = false;
49
    }
59
    }
50
    
60
    
51
    const std::string& file_name() const {return file;}
61
    const std::string& file_name() const {return file;}
52
    
62
    
53
    float get_bsphere_radius() const { return bsphere_radius;}
63
    float get_bsphere_radius() const { return bsphere_radius;}
54
    
64
    
55
    HMesh::Manifold& mesh() {return mani;}
65
    HMesh::Manifold& mesh() {return mani;}
56
    const HMesh::Manifold& mesh_old() const {return old_mani;}
66
    const HMesh::Manifold& mesh_old() const {return old_mani;}
57
    
67
    
58
    void save_old() {old_mani = mani;}
68
    void save_old() {old_mani = mani;}
59
    void restore_old() {mani = old_mani;}
69
    void restore_old() {mani = old_mani;}
60
    
70
    
61
    GLGraphics::GLViewController& view_control() {return view_ctrl;}
71
    GLGraphics::GLViewController& view_control() {return view_ctrl;}
62
    
72
    
63
    void refit();
73
    void refit();
64
    
74
    
65
    bool reload(std::string _file);
75
    bool reload(std::string _file);
66
    
76
    
67
    bool add_mesh(std::string _file);
77
    bool add_mesh(std::string _file);
68
    
78
    
69
    void display(const std::string& display_method , GLGraphics::Console& cs, bool smooth, float gamma);
79
    void display(const std::string& display_method , GLGraphics::Console& cs, bool smooth, float gamma);
70
    
80
    
71
    void post_create_display_list()
81
    void post_create_display_list()
72
    {
82
    {
73
        create_display_list = true;
83
        create_display_list = true;
74
    }
84
    }
75
    
85
    
76
    void harmonics_analyze() {
86
    void harmonics_analyze() {
77
        harm = new HMesh::Harmonics(mani);
87
        harm = new HMesh::Harmonics(mani);
78
    }
88
    }
79
    
89
    
80
};
90
};
81
 
91
 
82
}
92
}
83
#endif
93
#endif
84
 
94