int main(int argc, char **argv) { if(argc < 4) { std:: cerr << "Usage: " << argv[0] << " inputmesh inputvol outputMesh [range]\n"; return 1; } try { geometry geom; cvcraw_geometry::read(geom, string(argv[1])); VolMagick::Volume inputVol; VolMagick::readVolumeFile(inputVol,argv[2]); ///input volume double range = 0; bool gotRange = false; if( argc > 4 ) { range = atof( argv[4] ); gotRange = true; std::cout << "got range: " << range << std::endl; } float x,y,z; float value; color_t color; COLOUR c; if( !gotRange ) { // compute range, max absolute value for(int i=0; i< geom.points.size(); i++) { x = geom.points[i][0]; y = geom.points[i][1]; z = geom.points[i][2]; value = inputVol.interpolate(x,y,z); if( range < fabs( value ) ) range = fabs( value ); } } std::cout<<"range: "<< range << std::endl; for(int i=0; i< geom.points.size(); i++) { x = geom.points[i][0]; y = geom.points[i][1]; z = geom.points[i][2]; value = inputVol.interpolate(x,y,z); c=GetColour(value, range); color[0] = c.r; color[1] = c.g; color[2] = c.b; geom.colors.push_back(color); } cvcraw_geometry::write(geom, string(argv[3])); std::cout<< "done. "<< std::endl; } catch(VolMagick::Exception &e) { std:: cerr << e.what() << std::endl; } catch(std::exception &e) { std::cerr << e.what() << std::endl; } return 0; }