Subversion Repositories gelsvn

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

/*
 *  VisObj.h
 *  GEL
 *
 *  Created by J. Andreas Bærentzen on 20/09/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */
#ifndef __MESHEDIT_VISOBJ_H__
#define __MESHEDIT_VISOBJ_H__


#include <string>
#include "../GL/glew.h"
#include "../HMesh/Manifold.h"
#include "../CGLA/Vec3d.h"
#include "../GLGraphics/draw.h"
#include "../GLGraphics/Console.h"
#include "../GLGraphics/GLViewController.h"
#include "../GLGraphics/ManifoldRenderer.h"
#include "../HMesh/harmonics.h"

extern int WINX;
extern int WINY;

namespace GLGraphics {

class VisObj
{
    std::string file;
    GLGraphics::GLViewController view_ctrl;
    bool create_display_list;
    
    HMesh::Manifold mani;
    HMesh::Manifold old_mani;
    
    GLGraphics::ManifoldRenderer* renderer;
    
    bool active_selection;
    HMesh::VertexAttributeVector<int> vertex_selection;
    
    HMesh::Harmonics* harm;
    CGLA::Vec3d bsphere_center;
    float bsphere_radius;
    
    void produce_renderer(const std::string& display_method , Console& cs, bool smooth, float gamma);
    void draw_selection();
public:
    
    VisObj(): file(""), create_display_list(true), renderer(nullptr), active_selection(false), view_ctrl(WINX,WINY, CGLA::Vec3f(0), 1.0) {}
    
    HMesh::VertexAttributeVector<int>& get_vertex_selection() {
        return vertex_selection;
    }
    bool select_vertex(const CGLA::Vec2i& pos);
    void clear_selection() {
        for(auto vid : mani.vertices()) vertex_selection[vid] = 0;
        active_selection = false;
    }
    
    const std::string& file_name() const {return file;}
    
    float get_bsphere_radius() const { return bsphere_radius;}
    
    HMesh::Manifold& mesh() {return mani;}
    const HMesh::Manifold& mesh_old() const {return old_mani;}
    
    void save_old() {old_mani = mani;}
    void restore_old() {mani = old_mani;}
    
    GLGraphics::GLViewController& view_control() {return view_ctrl;}
    
    void refit();
    
    bool reload(std::string _file);
    
    bool add_mesh(std::string _file);
    
    void display(const std::string& display_method , GLGraphics::Console& cs, bool smooth, float gamma);
    
    void post_create_display_list()
    {
        create_display_list = true;
    }
    
    void harmonics_analyze() {
        harm = new HMesh::Harmonics(mani);
    }
    
};

}
#endif