35#include "ramCanvas.hpp"
38typedef mjr::ramCanvas3c8b::coordFltType drT;
42void drawLevelCurves(
int numBand, drT bandWidth, drT zMin, drT zMax, drT minRealX, drT maxRealX, drT minRealY, drT maxRealY,
const char *file);
46 std::chrono::time_point<std::chrono::system_clock> startTime = std::chrono::system_clock::now();
47 drawLevelCurves(10, 0.0, 0, 0, -20, 20, -20, 20,
"level_curves_l.tiff");
48 drawLevelCurves( 0, 0.0, 0, 0, -20, 20, -20, 20,
"level_curves_c.tiff");
49 std::chrono::duration<double> runTime = std::chrono::system_clock::now() - startTime;
50 std::cout <<
"Total Runtime " << runTime.count() <<
" sec" << std::endl;
55 return sin(x)+cos(y)+sqrt(x*x+y*y)*0.05;
59void drawLevelCurves(
int numBand, drT bandWidth, drT zMin, drT zMax, drT minRealX, drT maxRealX, drT minRealY, drT maxRealY,
const char *file) {
61 mjr::ramCanvas3c8b::csIntType clr;
62 drT fxy, bandGap, band, minDist, minBand;
64 mjr::ramCanvas3c8b theRamCanvas(1024, 1024, minRealX, maxRealX, minRealY, maxRealY);
67 if( (zMax == 0) && (zMin == 0) ) {
68 fprintf(stderr,
"Compute zMax and zMin\n");
69 zMax = zMin = f(theRamCanvas.int2realX(0), theRamCanvas.int2realY(0));
70 for(y=0;y<theRamCanvas.getNumPixY();y++) {
71 for(x=0;x<theRamCanvas.getNumPixX();x++) {
72 fxy = f(theRamCanvas.int2realX(x), theRamCanvas.int2realY(y));
73 if(fxy > zMax) zMax=fxy;
74 if(fxy < zMin) zMin=fxy;
79 bandGap = 1.0*(zMax-zMin)/numBand;
80 fprintf(stderr,
"Compute curves\n");
81 for(y=0;y<theRamCanvas.getNumPixY();y++) {
82 for(x=0;x<theRamCanvas.getNumPixX();x++) {
83 fxy = f(theRamCanvas.int2realX(x), theRamCanvas.int2realY(y));
85 theRamCanvas.setDfltColor(mjr::ramCanvas3c8b::colorType(255, 0, 0));
88 theRamCanvas.setDfltColor(mjr::ramCanvas3c8b::colorType(0, 255, 0));
91 clr =
static_cast<mjr::ramCanvas3c8b::csIntType
>(mjr::math::linm::gen_map(fxy, zMin, zMax, (drT)0, (drT)(255*4+1)));
92 theRamCanvas.setDfltColor(mjr::ramCanvas3c8b::colorType::csCColdeIceToWaterToHot::c(clr));
95 theRamCanvas.setDfltColor(mjr::ramCanvas3c8b::colorType(0, 0, 255));
97 minDist = (zMax-zMin+1);
99 for(band=zMax; band>zMin; band=band-bandGap) {
100 if(fabs(band-fxy) < minDist) {
101 minDist = fabs(band-fxy);
107 clr =
static_cast<mjr::ramCanvas3c8b::csIntType
>(mjr::math::linm::gen_map(minBand, zMin, zMax, (drT)0, (drT)(255*4+1)));
108 theRamCanvas.setDfltColor(mjr::ramCanvas3c8b::colorType::csCColdeIceToWaterToHot::c(clr));
111 theRamCanvas.setDfltColor(mjr::ramCanvas3c8b::colorType(0, 0, 255));
113 for(band=zMax; band>zMin; band=band-bandGap) {
114 if(fabs(band-fxy) < bandWidth) {
115 clr = (int)((zMax-fxy)/(zMax-zMin)*250);
116 theRamCanvas.setDfltColor(mjr::ramCanvas3c8b::colorType(255, 255, 255));
125 theRamCanvas.drawPoint(x, y);
129 theRamCanvas.writeTIFFfile(file);
int main(int argc, char *argv[])