Subversion Repositories gelsvn

Rev

Rev 399 | Rev 457 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

/*
 *  harmonics.h
 *  GEL
 *
 *  Created by J. Andreas Bærentzen on 01/09/08.
 *  Copyright 2008 __MyCompanyName__. All rights reserved.
 *
 */

#ifndef __MESHEDIT_HARMONICS_H__
#define __MESHEDIT_HARMONICS_H__

#include <CGLA/Vec3d.h>
#include <HMesh/Manifold.h>
#include <LinAlg/Matrix.h>
#include <LinAlg/Vector.h>
#include "Renderer.h"


class Harmonics
{
        HMesh::Manifold& mani;
        
        int maximum_eigenvalue;

        static bool is_initialized;
        static GLuint prog_P0;
        
        std::vector<CGLA::Vec3d> proj;
        
        LinAlg::CMatrix Q;
        LinAlg::CVector V;
        std::vector<float> max_eig_values;

        void make_laplace_operator();

public:
        
        /// Initialize API (must be called first)
        static void init();
        
        /// Initial analysis of harmonics (must be called second)
        Harmonics(HMesh::Manifold& mani);
        
        /// Add a frequency to mesh reconstruction
        void add_frequency(int f, float scale = 1.0f);
        
        /// Reset the shape to use 0 eigenvalues
        void reset_shape();
        
        /// Do a partial reconstruct with an interval of eigenvalues
        void partial_reconstruct(int E0, int E1, float scale=1.0f);
        
        /// Parse keystrokes that would influence the interactive display
        void parse_key(unsigned char key);
        
        /// Draw with eigenvalues
        void draw();
        
};


class HarmonicsRenderer: public ManifoldRenderer
        {
                
        public:
                HarmonicsRenderer(Harmonics* h)
                {
                        glNewList(display_list,GL_COMPILE);
                        if(h) h->draw();
                        glEndList();
                }
        };


#endif