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