diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2019-03-16 18:04:12 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2019-03-16 18:04:12 (GMT) |
commit | 4d175d7ff042262896c31c01911926209a78d38a (patch) | |
tree | ca473f342751105d5078239d3c95a6e597908392 /tksao/frame | |
parent | 05feae0692243293baac74ee38aa54a0eb52891e (diff) | |
download | blt-4d175d7ff042262896c31c01911926209a78d38a.zip blt-4d175d7ff042262896c31c01911926209a78d38a.tar.gz blt-4d175d7ff042262896c31c01911926209a78d38a.tar.bz2 |
thread contour
Diffstat (limited to 'tksao/frame')
-rw-r--r-- | tksao/frame/basecommand.C | 6 | ||||
-rw-r--r-- | tksao/frame/fvcontour.C | 44 | ||||
-rw-r--r-- | tksao/frame/fvcontour.h | 20 |
3 files changed, 39 insertions, 31 deletions
diff --git a/tksao/frame/basecommand.C b/tksao/frame/basecommand.C index 7f5615a..ed7734f 100644 --- a/tksao/frame/basecommand.C +++ b/tksao/frame/basecommand.C @@ -1310,12 +1310,12 @@ void Base::getContourClipScopeCmd() void Base::getContourColorNameCmd() { - Tcl_AppendResult(interp, currentContext->fvcontour().getColorName(), NULL); + Tcl_AppendResult(interp, currentContext->fvcontour().colorName(), NULL); } void Base::getContourDashCmd() { - if (currentContext->fvcontour().getDash()) + if (currentContext->fvcontour().dash()) Tcl_AppendResult(interp, "1", NULL); else Tcl_AppendResult(interp, "0", NULL); @@ -1329,7 +1329,7 @@ void Base::getContourLevelCmd() void Base::getContourLineWidthCmd() { ostringstream str; - str << currentContext->fvcontour().getLineWidth() << ends; + str << currentContext->fvcontour().lineWidth() << ends; Tcl_AppendResult(interp, str.str().c_str(), NULL); } diff --git a/tksao/frame/fvcontour.C b/tksao/frame/fvcontour.C index 218b16e..40d4eb5 100644 --- a/tksao/frame/fvcontour.C +++ b/tksao/frame/fvcontour.C @@ -22,14 +22,12 @@ static const char* methodName_[] = { enum Edge {TOP, RIGHT, BOTTOM, LEFT, NONE}; -static void build(long xdim, long ydim, double *image, Matrix& mx, - Base* parent, List<ContourLevel>* lcontourlevel, - InverseScale* scale, - char* colorName, int lineWidth, int dash, int* dlist); +static void build(long xdim, long ydim, double *image, Matrix* mx, + FVContour* fv); static void trace(long xdim, long ydim, double cntr, long xCell, long yCell, int side, double** rows, char* usedGrid, - Matrix& mx, ContourLevel* cl); + Matrix* mx, ContourLevel* cl); // It is a modified version of contour code found in Fv 2.4 // Fv may be obtained from the HEASARC (High Energy Astrophysics Science @@ -189,6 +187,7 @@ void FVContour::unity(FitsImage* fits) fits->getDataParams(((Base*)parent_)->currentContext->secMode()); long width = fits->width(); long height = fits->height(); + Matrix mm = fits->dataToRef; // blank img long size = width*height; @@ -214,8 +213,7 @@ void FVContour::unity(FitsImage* fits) CLEARSIGBUS // contours - build(width, height, img, fits->dataToRef, parent_, &lcontourlevel_, scale_, - colorName_, lineWidth_, dash_, dlist_); + build(width, height, img, &mm, this); delete [] img; } @@ -225,6 +223,7 @@ void FVContour::nobin(FitsImage* fits, pthread_t* thread, void* targ) fits->getDataParams(((Base*)parent_)->currentContext->secMode()); long width = fits->width(); long height = fits->height(); + Matrix mm = fits->dataToRef; // blank img long size = width*height; @@ -270,8 +269,11 @@ void FVContour::nobin(FitsImage* fits, pthread_t* thread, void* targ) tt->ymin = params->ymin; tt->ymax = params->ymax; tt->width = width; + tt->height = height; tt->r = r; + tt->mm = &mm; + tt->fv = this; // int result = pthread_create(thread, NULL, FVContourThread, targ); // if (result) // internalError("Unable to Create Thread"); @@ -279,8 +281,7 @@ void FVContour::nobin(FitsImage* fits, pthread_t* thread, void* targ) convolve(tt->kernel, tt->src, tt->dest, tt->xmin, tt->ymin, tt->xmax, tt->ymax, tt->width, tt->r); - build(width, height, img, fits->dataToRef, parent_, &lcontourlevel_, scale_, - colorName_, lineWidth_, dash_, dlist_); + build(tt->width, tt->height, tt->dest, tt->mm, tt->fv); delete [] src; delete [] img; @@ -355,16 +356,12 @@ void FVContour::bin(FitsImage* fits) // contours Matrix w = n * fits->dataToRef; - build(w2, h2, img, w, - parent_, &lcontourlevel_, scale_, - colorName_, lineWidth_, dash_, dlist_); + build(w2, h2, img, &w, this); delete [] img; } -void build(long xdim, long ydim, double *image, Matrix& mx, - Base* parent, List<ContourLevel>* lcontourlevel, - InverseScale* scale, - char* colorName, int lineWidth, int dash, int* dlist) +void build(long xdim, long ydim, double *image, Matrix* mx, + FVContour* fv) { long nelem = xdim*ydim; char* usedGrid = new char[nelem]; @@ -373,11 +370,12 @@ void build(long xdim, long ydim, double *image, Matrix& mx, for (long jj=0; jj<ydim; jj++) rows[jj] = image + jj*xdim; - for (long c=0; c<scale->size(); c++) { - double cntour = scale->level(c); + for (long c=0; c<fv->scale()->size(); c++) { + double cntour = fv->scale()->level(c); - ContourLevel* cl =new ContourLevel(parent, cntour, colorName, lineWidth, - dash, dlist); + ContourLevel* cl =new ContourLevel(fv->parent(), cntour, + fv->colorName(), fv->lineWidth(), + fv->dash(), fv->dlist()); memset(usedGrid,0,nelem); // Search outer edge @@ -412,7 +410,7 @@ void build(long xdim, long ydim, double *image, Matrix& mx, trace(xdim, ydim, cntour, ii, jj, TOP, rows, usedGrid, mx, cl); if (!cl->lcontour().isEmpty()) - lcontourlevel->append(cl); + fv->lcontourlevel().append(cl); } delete [] usedGrid; @@ -422,7 +420,7 @@ void build(long xdim, long ydim, double *image, Matrix& mx, void trace(long xdim, long ydim, double cntr, long xCell, long yCell, int side, double** rows, char* usedGrid, - Matrix& mx, ContourLevel* cl) + Matrix* mx, ContourLevel* cl) { long ii = xCell; long jj = yCell; @@ -517,7 +515,7 @@ void trace(long xdim, long ydim, double cntr, done = 1; } - cc->lvertex().append(new Vertex(Vector(X+.5,Y+.5)*mx)); + cc->lvertex().append(new Vertex(Vector(X+.5,Y+.5) * (*mx))); } if (!cc->lvertex().isEmpty()) diff --git a/tksao/frame/fvcontour.h b/tksao/frame/fvcontour.h index ed8b879..7f37066 100644 --- a/tksao/frame/fvcontour.h +++ b/tksao/frame/fvcontour.h @@ -10,6 +10,8 @@ #include "frscale.h" #include "inversescale.h" +class FVContour; + typedef struct { double* kernel; double* src; @@ -19,7 +21,10 @@ typedef struct { int xmax; int ymax; int width; + int height; int r; + Matrix* mm; + FVContour* fv; } t_fvcontour_arg; class FVContour { @@ -59,7 +64,6 @@ public: FVContour(); ~FVContour(); - List<ContourLevel>& lcontourlevel() {return lcontourlevel_;} void create(Base*, FitsImage*, FrScale*, const char*, int, int, @@ -72,16 +76,22 @@ public: int isEmpty() {return lcontourlevel_.isEmpty();} + Base* parent() {return parent_;} + List<ContourLevel>& lcontourlevel() {return lcontourlevel_;} + + const char* colorName() {return colorName_;} + int lineWidth() {return lineWidth_;} + int dash() {return dash_;} + int* dlist() {return dlist_;} + const char* methodName(); - char* level() {return level_;} int numLevel() {return numLevel_;} int smooth() {return smooth_;} FrScale* frScale() {return &frScale_;} - const char* getColorName() {return colorName_;} - int getDash() {return dash_;} - int getLineWidth() {return lineWidth_;} + InverseScale* scale() {return scale_;} + char* level() {return level_;} }; #endif |