Subversion Repositories gelsvn

Rev

Rev 657 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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