<commit_before>#include "ofxBezierSurface.h"

void ofxBezierSurface::setup(int w, int h, int dim, int res) {
    width = w;
    height = h;
    cx = dim-1;
    cy = dim-1;
    rx = res;
    ry = res;
    
    int i,j;
    
    // create point vectors
    for (i=0; i<=cx; i++) {
        inp.push_back(vector<ofVec3f>());
        for (j=0; j<=cy; j++) {
            inp[i].push_back(ofVec3f());
        }
    }
    for (i=0; i<rx; i++) {
        outp.push_back(vector<ofVec3f>());
        for (j=0; j<ry; j++) {
            outp[i].push_back(ofVec3f());
        }
    }
    
    // load default points
    for (i=0;i<=cx;i++) {
        for (j=0;j<=cy;j++) {
            inp[i][j].x = ofMap(i, 0, cx, 0, width);
            inp[i][j].y = ofMap(j, 0, cy, 0, height);
            inp[i][j].z = 0;
        }
    }
    
    // create default surface
    mesh = ofMesh::plane(width, height, rx, ry, OF_PRIMITIVE_TRIANGLES);
    createSurface();

    vector<ofVec3f> verts = mesh.getVertices();
    for (i=0; i<verts.size(); i++) {
        mesh.setTexCoord(i, ofVec2f(verts[i].x, verts[i].y));
    }
    
    // interface
    updateSurface = false;
    ctrlPntSize = 10;
    up = false;
    down = false;
    left = false;
    right = false;
    found  = false;
}

void ofxBezierSurface::draw() {
    mesh.draw();
}

void ofxBezierSurface::drawWireframe() {
    mesh.drawWireframe();
}

void ofxBezierSurface::update() {
    if (updateSurface) {
        createSurface();
        updateSurface = false;
    }
}

void ofxBezierSurface::drawControls() {
    for (int i=0;i<=cx;i++) {
        for (int j=0;j<=cy;j++) {
            
            for (int k=0;k<selectedPnts.size();k++) {
                if (selectedPnts[k].x == i && selectedPnts[k].y == j) {
                    ofSetColor(200,200,0);
                    break;
                }
                else
                    ofSetColor(200,200,200);
            }
            ofCircle(inp[i][j].x, inp[i][j].y, inp[i][j].z, ctrlPntSize);
        }
    }
}


vector<ofVec3f> ofxBezierSurface::getVertices(){
    return mesh.getVertices();
}

void ofxBezierSurface::setVertices(vector<ofVec3f> & verts){
    for (int i=0; i<verts.size(); i++) {
        mesh.setVertex(i, verts[i]);
    }
}

vector<ofVec3f> ofxBezierSurface::getControlPnts(){
    vector<ofVec3f> vec;
    for (int i=0; i<=cx; i++) {
        for (int j=0; j<=cy; j++) {
            vec.push_back(inp[i][j]);
        }
    }
    return vec;
}
void ofxBezierSurface::setControlPnts(vector<ofVec3f> vec){
    int c=0;
    for (int i=0; i<=cx; i++) {
        for (int j=0; j<=cy; j++) {
            inp[i][j] = vec[c];
            c++;
        }
    }
    createSurface();
}

int ofxBezierSurface::getControlPntDim(){
    return cx+1;
}
vector< vector<ofVec3f> > lastp;

void ofxBezierSurface::setControlPntDim(int dim){
    int oldcx = cx;
    int oldcy = cy;
    
    cx = dim-1;
    cy = dim-1;
    
    vector< vector<ofVec3f> > oldInp;
    <commit_msg>Clean up<commit_after>#include "ofxBezierSurface.h"

void ofxBezierSurface::setup(int w, int h, int dim, int res) {
    width = w;
    height = h;
    cx = dim-1;
    cy = dim-1;
    rx = res;
    ry = res;
    
    int i,j;
    
    // create point vectors
    for (i=0; i<=cx; i++) {
        inp.push_back(vector<ofVec3f>());
        for (j=0; j<=cy; j++) {
            inp[i].push_back(ofVec3f());
        }
    }
    for (i=0; i<rx; i++) {
        outp.push_back(vector<ofVec3f>());
        for (j=0; j<ry; j++) {
            outp[i].push_back(ofVec3f());
        }
    }
    
    // load default points
    for (i=0;i<=cx;i++) {
        for (j=0;j<=cy;j++) {
            inp[i][j].x = ofMap(i, 0, cx, 0, width);
            inp[i][j].y = ofMap(j, 0, cy, 0, height);
            inp[i][j].z = 0;
        }
    }
    
    // create default surface
    mesh = ofMesh::plane(width, height, rx, ry, OF_PRIMITIVE_TRIANGLES);
    createSurface();

    vector<ofVec3f> verts = mesh.getVertices();
    for (i=0; i<verts.size(); i++) {
        mesh.setTexCoord(i, ofVec2f(verts[i].x, verts[i].y));
    }
    
    // interface
    updateSurface = false;
    ctrlPntSize = 10;
    up = false;
    down = false;
    left = false;
    right = false;
    found  = false;
}

void ofxBezierSurface::draw() {
    mesh.draw();
}

void ofxBezierSurface::drawWireframe() {
    mesh.drawWireframe();
}

void ofxBezierSurface::update() {
    if (updateSurface) {
        createSurface();
        updateSurface = false;
    }
}

void ofxBezierSurface::drawControls() {
    for (int i=0;i<=cx;i++) {
        for (int j=0;j<=cy;j++) {
            
            for (int k=0;k<selectedPnts.size();k++) {
                if (selectedPnts[k].x == i && selectedPnts[k].y == j) {
                    ofSetColor(200,200,0);
                    break;
                }
                else
                    ofSetColor(200,200,200);
            }
            ofCircle(inp[i][j].x, inp[i][j].y, inp[i][j].z, ctrlPntSize);
        }
    }
}


vector<ofVec3f> ofxBezierSurface::getVertices(){
    return mesh.getVertices();
}

void ofxBezierSurface::setVertices(vector<ofVec3f> & verts){
    for (int i=0; i<verts.size(); i++) {
        mesh.setVertex(i, verts[i]);
    }
}

vector<ofVec3f> ofxBezierSurface::getControlPnts(){
    vector<ofVec3f> vec;
    for (int i=0; i<=cx; i++) {
        for (int j=0; j<=cy; j++) {
            vec.push_back(inp[i][j]);
        }
    }
    return vec;
}
void ofxBezierSurface::setControlPnts(vector<ofVec3f> vec){
    int c=0;
    for (int i=0; i<=cx; i++) {
        for (int j=0; j<=cy; j++) {
            inp[i][j] = vec[c];
            c++;
        }
    }
    createSurface();
}

int ofxBezierSurface::getControlPntDim(){
    return cx+1;
}

void ofxBezierSurface::setControlPntDim(int dim){
    int oldcx = cx;
    int oldcy = cy;
    
    cx = dim-1;
    cy = dim-1;
    
    vector< vector<ofVec3f> > oldInp;
    
{'fraction_non_alphanumeric': 0.17418588873812754, 'fraction_numerical': 0.019165535956580732, 'mean_word_length': 1.9782828282828282, 'pattern_counts': {'":': 0, '<': 55, '<?xml version=': 0, '>': 25, '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': '1326423', 'n_tokens_mistral': 2366, 'n_tokens_neox': 2289, 'n_words': 426}