Example #1
0
//--------------------------------------------------------------
void testApp::update(){

    bool press = ofGetKeyPressed();
    voro::container con(-containerSize,containerSize,
                  -containerSize,containerSize,
                  -containerSize,containerSize,
                  1, 1, 1, press, press, press, 8);
    
    for(int i = 0; i < boids.size();i++){
        boids[i]->update( boids );
        if ( insideContainer( con, *boids[i])){
            addCellSeed( con, boids[i], i);
            boids[i]->color.set(50, 200,200);
        } else {
            boids[i]->color.set(255,0,0);
        }
    }
    
    cellMeshes.clear();
    cellMeshes = getCellsFromContainer(con,0);
	cellMeshWireframes.clear();
	cellMeshWireframes = getCellsFromContainer(con,0,true);
    
    ofSetWindowTitle(ofToString(ofGetFrameRate()));
}
void VoroNode::split(int _nCells, bool overFlowX, bool overFlowY, bool overFlowZ) {
    nCells = _nCells;
    
    isSplit = true;
    bDraw = false;
    
    
    voro::container con(minBounds.x,maxBounds.x,
                        minBounds.y,maxBounds.y,
                        minBounds.z,maxBounds.z,
                        1,1,1,
                        overFlowX,overFlowY,overFlowZ, // set true to flow beyond box
                        8);
    
    vector<voro::wall_plane*> wallsToDeleteAfterGettingCells;
    
    for(ofMeshFace f : mesh.getUniqueFaces()){
        
        ofVec3f fNormal = f.getFaceNormal();
        ofVec3f fOrigin = ofVec3f(0,0,0);
        
        float sb, sn, sd;
        
        sn = -fNormal.dot(fOrigin - f.getVertex(1));
        sd = fNormal.dot(fNormal);
        sb = sn / sd;
        
        ofVec3f basePointOnPlane(fOrigin + sb * fNormal);
        
        float distance = fOrigin.distance(basePointOnPlane);
        
        voro::wall_plane * planeWall = new voro::wall_plane(-fNormal.x, -fNormal.y, -fNormal.z, distance);
        wallsToDeleteAfterGettingCells.push_back(planeWall);
        con.add_wall(planeWall);
    }
    
    for(int i = 0; i < nCells;i++){
        ofPoint newCell = ofPoint(ofRandom(minBounds.x,maxBounds.x),
                                  ofRandom(minBounds.y,maxBounds.y),
                                  ofRandom(minBounds.z,maxBounds.z));
        if(insideContainer(con, newCell))
            addCellSeed(con, newCell, i, true);
        else
            i--;
    }
    
    vector<ofVboMesh> cellMeshes;
    getCellsFromContainerParallel(con, 0, cellMeshes, false);
    
    for (auto w : wallsToDeleteAfterGettingCells){
        delete(w);
    }
    
    clearChildren();
    
    for(auto && m : cellMeshes) {
        VoroNode * sub = new VoroNode(m, *this);
    }
};
Example #3
0
void addCellsSeeds(voro::container &_con, ofPoint *_pnts, int _nSize, bool _checkInside){
    for (int i = 0; i < _nSize; i++) {
        addCellSeed(_con, _pnts[i], i, _checkInside);
    }
}
Example #4
0
void addCellsSeeds(voro::container &_con, vector<ofPoint*> &_pnts, bool _checkInside){
    for (int i = 0; i < _pnts.size(); i++) {
        addCellSeed(_con, _pnts[i], i, _checkInside);
    }
}