<commit_before>﻿#include "simplesp.h"
#include "spex/spgl.h"

using namespace sp;

class VoxelGUI : public BaseWindow{

    // camera
    CamParam m_cam;

    // model
    Mem1<Mesh> m_model;

    // voxel
    Voxel m_voxel;

    // pose
    Pose m_pose;

    int m_mode;

private:

    void help() {
        printf("'s' key : switch mode (voxel <-> mesh)\n");
        printf("'ESC' key : exit\n");
        printf("\n");
    }

    virtual void init(){
        help();
        
        m_mode = 0;

        m_cam = getCamParam(640, 480);

        if (loadBunny(m_model, SP_DATA_DIR "/stanford/bun_zipper.ply") == false){

            // if could not find stanford bunny, load dummy model
            loadGeodesicDorm(m_model, 100.0, 1);
        }

        const double radius = getModelRadius(m_model);
        const double distance = getModelDistance(m_model, m_cam);

        cnvModelToVoxel(m_voxel, m_model, 4.0);

        // Marching cubes
        cnvVoxelToModel(m_model, m_voxel);

        m_pose = getPose(getVec(0.0, 0.0, distance));
    }

    virtual void keyFun(int key, int scancode, int action, int mods) {

        if (m_keyAction[GLFW_KEY_S] == 1) {
            m_mode ^= 1;
        }
    }

    virtual void display(){

        // render model
        {
            glLoadView3D(m_cam, m_viewPos, m_viewScale);

            glClear(GL_DEPTH_BUFFER_BIT);
            {
                glLoadMatrix(m_pose);

                if (m_mode == 0) {
                    glRenderVoxel(m_voxel);
                }
                else{ 
                    glRenderSurface(m_model);
                }
                //glRenderOutline(m_model);

            }
        }

    }

    virtual void mousePos(double x, double y) {
        controlPose(m_pose, m_mouse, m_wcam, m_viewScale);
    }

    virtual void mouseScroll(double x, double y) {
        controlPose(m_pose, m_mouse, m_wcam, m_viewScale);
    }

};
<commit_msg>refactoring<commit_after>﻿#include "simplesp.h"
#include "spex/spgl.h"

using namespace sp;

class VoxelGUI : public BaseWindow{

    // camera
    CamParam m_cam;

    // model
    Mem1<Mesh> m_model;

    // voxel
    Voxel m_voxel;

    // pose
    Pose m_pose;

    int m_mode;

private:

    void help() {
        printf("'s' key : switch mode (voxel <-> mesh)\n");
        printf("'ESC' key : exit\n");
        printf("\n");
    }

    virtual void init(){
        help();
        
        m_mode = 0;

        m_cam = getCamParam(640, 480);

        if (loadBunny(m_model, SP_DATA_DIR "/stanford/bun_zipper.ply") == false){

            // if could not find stanford bunny, load dummy model
            loadGeodesicDorm(m_model, 100.0, 1);
        }

        const double radius = getModelRadius(m_model);
        const double distance = getModelDistance(m_model, m_cam);

        cnvModelToVoxel(m_voxel, m_model, 4.0);

        // Marching cubes
        cnvVoxelToModel(m_model, m_voxel);

        m_pose = getPose(getVec(0.0, 0.0, distance));
    }

    virtual void keyFun(int key, int scancode, int action, int mods) {

        if (m_keyAction[GLFW_KEY_S] == 1) {
            m_mode ^= 1;
        }
    }

    virtual void display(){

        // render model
        {
            glLoadView3D(m_cam, m_viewPos, m_viewScale);

            glClear(GL_DEPTH_BUFFER_BIT);
            {
                glLoadMatrix(m_pose);

                if (m_mode == 0) {
                    glRenderVoxel(m_voxel);
                }
                else{ 
                    glRenderSurface(m_model);
                }
                //glRenderOutline(m_model);
            }
        }

    }

    virtual void mousePos(double x, double y) {
        controlPose(m_pose, m_mouse, m_wcam, m_viewScale);
    }

    virtual void mouseScroll(double x, double y) {
        controlPose(m_pose, m_mouse, m_wcam, m_viewScale);
    }

};

{'fraction_non_alphanumeric': 0.111427831044312, 'fraction_numerical': 0.011920186576833377, 'mean_word_length': 1.691771269177127, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1967801', 'n_tokens_mistral': 1404, 'n_tokens_neox': 1298, 'n_words': 272}