コード例 #1
0
ファイル: ofxVoro.cpp プロジェクト: arthurhunt7/ofxVoro
void addCellSeed(voro::container &_con, ofPoint &_pnt, int _i, bool _checkInside){
    if (_checkInside){
        if ( insideContainer(_con, _pnt ))
            _con.put(_i, _pnt.x, _pnt.y, _pnt.z);
    } else {
        _con.put(_i, _pnt.x, _pnt.y, _pnt.z);
    }
}
コード例 #2
0
ファイル: ofxVoro.cpp プロジェクト: arthurhunt7/ofxVoro
void addCellSeed(voro::container &_con, ofPoint *_pnt, int _i, bool _checkInside){
    if (_checkInside){
        if ( insideContainer(_con, *_pnt));
        _con.put(_i, _pnt->x, _pnt->y, _pnt->z);
    } else {
        _con.put(_i, _pnt->x, _pnt->y, _pnt->z);
    }
}
コード例 #3
0
void getCellsFromContainer(voro::container &_con, float _wallsThikness, vector<ofMesh>& cells){
    
	cells.clear();
	
    voro::c_loop_all vl( _con );
    int i = 0;
	if( vl.start() ){
        
        do {
            voro::voronoicell c;
            if( !_con.compute_cell(c, vl) ) {
                return;
            } else {
                double *pp = _con.p[vl.ijk] + _con.ps * vl.q;
				ofMesh cellMesh;
                getCellMesh(c, ofPoint(pp[0],pp[1],pp[2])*(float)(1.0+_wallsThikness), cellMesh);
                cells.push_back( cellMesh );
                i++;
            }
            
        } while( vl.inc() );
    }
    
    return;
}
コード例 #4
0
ファイル: ofxVoro.cpp プロジェクト: arthurhunt7/ofxVoro
vector< vector<ofPoint> > getCellsVertices(voro::container &_con){
    vector< vector<ofPoint> > cells;
    
    ofPoint pos;
    
    voro::c_loop_all vl( _con );
    int i = 0;
	if( vl.start() ){
        
        do {
            voro::voronoicell c;
            if( !_con.compute_cell(c, vl) ) {
                return cells;
            } else {
                double *pp = _con.p[vl.ijk] + _con.ps * vl.q;
                vector< ofPoint > cell = getCellVerteces(c, ofPoint(pp[0],pp[1],pp[2]) );
                cells.push_back( cell );
                i++;
            }
            
        } while( vl.inc() );
    }
    
    return cells;
}
コード例 #5
0
ファイル: ofxVoro.cpp プロジェクト: arthurhunt7/ofxVoro
vector< ofPolyline > getCellsPolylines(voro::container &_con){
    vector< ofPolyline > cells;
    
    ofPoint pos;
    
    voro::c_loop_all vl( _con );
    
	if( vl.start() ){
        
        do {
            voro::voronoicell c;
            int k = 0;
            if( !_con.compute_cell(c, vl) ) {
                return cells;
            } else {
                
                double *pp = _con.p[vl.ijk] + _con.ps * vl.q;
                ofPoint pos = ofPoint(pp[0],pp[1],pp[2]);
                
                ofPolyline cell;
                
                double *ptsp= c.pts;
                vector<ofPoint> points;
                
                //  Index
                //
                for(int i = 0; i < c.p; i++){
                    for(int j = 0; j < c.nu[i]; j++) {
                        int k = c.ed[i][0];
                        
                        ofPoint newPoint;
                        newPoint.x = pos.x + c.pts[3*k]*0.5;
                        newPoint.y = pos.y + c.pts[3*k+1]*0.5;
                        newPoint.z = pos.z + c.pts[3*k+2]*0.5;
                        cell.addVertex(newPoint);
                    }
                }
                
                cells.push_back( cell );
                
            }
            
        } while( vl.inc() );
    }
    
    return cells;
}
コード例 #6
0
ファイル: ofxVoro.cpp プロジェクト: arthurhunt7/ofxVoro
vector<ofPoint> getCellsCentroids(voro::container &_con){
    vector<ofPoint> centroids;
    
    voro::c_loop_all vl( _con );
    int i = 0;
	if( vl.start() ){
        
        do {
            voro::voronoicell c;
            if( !_con.compute_cell(c, vl) ) {
                return centroids;
            } else {
                double *pp = _con.p[vl.ijk] + _con.ps * vl.q;
                centroids.push_back( getCellCentroid(c) + ofPoint(pp[0],pp[1],pp[2]) );
                i++;
            }
            
        } while( vl.inc() );
    }
    
    return centroids;
}
コード例 #7
0
ファイル: ofxVoro.cpp プロジェクト: arthurhunt7/ofxVoro
void getCellsFromContainer(voro::container &_con, vector<ofVboMesh>& cells, bool bWireframe){
    cells.clear();
	
    voro::c_loop_all vl( _con );
    int i = 0;
	if( vl.start() ){
        
        do {
            voro::voronoicell c;
            if( !_con.compute_cell(c, vl) ) {
                return;
            } else {
                double *pp = _con.p[vl.ijk] + _con.ps * vl.q;
				ofVboMesh cellMesh;
                getCellMesh(c, cellMesh, bWireframe);
                cells.push_back( cellMesh );
                i++;
            }
            
        } while( vl.inc() );
    }
}
コード例 #8
0
ファイル: ofxVoro.cpp プロジェクト: arthurhunt7/ofxVoro
vector<float> getCellsRadius(voro::container &_con){
    vector<float> radius;
    
    voro::c_loop_all vl( _con );
    int i = 0;
	if( vl.start() ){
        
        do {
            voro::voronoicell c;
            if( !_con.compute_cell(c, vl) ) {
                return radius;
            } else {
                double *pp = _con.p[vl.ijk] + _con.ps * vl.q;
                float rad = getCellRadius(c);
                radius.push_back( rad );
                i++;
            }
            
        } while( vl.inc() );
    }
    
    return radius;
}
コード例 #9
0
ファイル: ofxVoro.cpp プロジェクト: arthurhunt7/ofxVoro
vector<ofVboMesh>  getCellsFromContainer(voro::container &_con, float _wallsThikness, float _maxRadius, bool bWireframe){
    vector<ofVboMesh> cells;
    
    voro::c_loop_all vl( _con );
    int i = 0;
	if( vl.start() ){
        do {
            voro::voronoicell c;
            if( !_con.compute_cell(c, vl) ) {
                return cells;
            } else {
                if(getCellRadius(c)<_maxRadius){
                    double *pp = _con.p[vl.ijk] + _con.ps * vl.q;
                    ofVboMesh cellMesh = getCellMesh(c, ofPoint(pp[0],pp[1],pp[2])*(float)(1.0+_wallsThikness), bWireframe);
                    cells.push_back( cellMesh );
                }
                i++;
            }
            
        } while( vl.inc() );
    }
    
    return cells;
}
コード例 #10
0
void VoroNode::getCellsFromContainerParallel(voro::container &_con, float _wallsThikness, vector<ofVboMesh>& cells, bool bWireframe){
    
    cells.clear();
    
    voro::c_loop_all vl( _con );
    if( vl.start() ){
        
        do {
            //                dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
            voro::voronoicell c;
            if( !_con.compute_cell(c, vl) ) {
                return;
            } else {
                double *pp = _con.p[vl.ijk] + _con.ps * vl.q;
                ofVboMesh cellMesh;
                getCellMesh(c, ofPoint(pp[0],pp[1],pp[2])*(float)(1.0+_wallsThikness), cellMesh, bWireframe);
                cells.push_back( cellMesh );
            }
            
            //                });
            
        } while( vl.inc() );
    }
}
コード例 #11
0
ファイル: ofxVoro.cpp プロジェクト: arthurhunt7/ofxVoro
bool insideContainer(voro::container &_con, ofPoint _pos){
    return _con.point_inside(_pos.x, _pos.y, _pos.z);
}