diff options
author | William Joye <wjoye@cfa.harvard.edu> | 2017-02-06 20:21:49 (GMT) |
---|---|---|
committer | William Joye <wjoye@cfa.harvard.edu> | 2017-02-06 20:21:49 (GMT) |
commit | b969f5d1d30f809ccc662dd8afd8ce8cd5d27eae (patch) | |
tree | 4c1e8ac359c1690b50e053a35955630e62decf56 /tksao/frame | |
parent | 0f8701b357b302f6aed7c07e3355ce6cd0b3cd32 (diff) | |
download | blt-b969f5d1d30f809ccc662dd8afd8ce8cd5d27eae.zip blt-b969f5d1d30f809ccc662dd8afd8ce8cd5d27eae.tar.gz blt-b969f5d1d30f809ccc662dd8afd8ce8cd5d27eae.tar.bz2 |
enabled threads for win32
Diffstat (limited to 'tksao/frame')
-rw-r--r-- | tksao/frame/context.C | 270 | ||||
-rw-r--r-- | tksao/frame/context.h | 6 | ||||
-rw-r--r-- | tksao/frame/fitsanalysis.C | 97 | ||||
-rw-r--r-- | tksao/frame/fitsblock.C | 4 | ||||
-rw-r--r-- | tksao/frame/fitsimage.C | 6 | ||||
-rw-r--r-- | tksao/frame/fitsimage.h | 12 | ||||
-rw-r--r-- | tksao/frame/frame3d.C | 132 | ||||
-rw-r--r-- | tksao/frame/frame3d.h | 8 |
8 files changed, 0 insertions, 535 deletions
diff --git a/tksao/frame/context.C b/tksao/frame/context.C index b21ca09..8b23ddd 100644 --- a/tksao/frame/context.C +++ b/tksao/frame/context.C @@ -92,38 +92,13 @@ Context::Context() smoothFunction_ =GAUSSIAN; smoothRadius_ =3; -#ifndef __WIN32 thread_ =NULL; -#endif } Context::~Context() { } -#ifdef __WIN32 - -void Context::analysis() -{ - if (DebugPerf) - cerr << "Context::analysis()" << endl; - - FitsImage* ptr = fits; - while (ptr) { - FitsImage* sptr = ptr; - while (sptr) { - sptr->analysis(doSmooth_); - sptr = sptr->nextSlice(); - } - ptr = ptr->nextMosaic(); - } - - clearHist(); - updateClip(); -} - -#else - void Context::analysis() { if (DebugPerf) @@ -183,8 +158,6 @@ void Context::analysis() updateClip(); } -#endif - Matrix Context::bin(const Vector& vv) { Matrix mm; @@ -266,94 +239,6 @@ void Context::binFinish() loadFinish(); } -#ifdef __WIN32 - -int Context::block() -{ - if (DebugPerf) - cerr << "Context::block()" << endl; - - // primary - FitsImage* ptr = fits; - while (ptr) { - FitsImage* sptr = ptr; - while (sptr) { - sptr->block(); - sptr = sptr->nextSlice(); - } - ptr = ptr->nextMosaic(); - } - - resetSecMode(); - - int rr =1; - switch (mosaicType) { - case Base::IRAF: - case Base::WCSMOSAIC: - rr = processMosaicKeywords(fits); - break; - default: - break; - } - - FitsMask* msk = mask.head(); - if (msk) { - FitsImage* ptr = msk->mask(); - while (ptr) { - FitsImage* sptr = ptr; - while (sptr) { - sptr->block(); - - switch (mosaicType) { - case Base::IRAF: - case Base::WCSMOSAIC: - rr &= processMosaicKeywords(ptr); - break; - default: - break; - } - sptr = sptr->nextSlice(); - } - ptr = ptr->nextMosaic(); - } - msk = msk->next(); - } - - return rr & blockMask(); -} - -int Context::blockMask() -{ - int rr =1; - - FitsMask* msk = mask.head(); - if (msk) { - FitsImage* ptr = msk->mask(); - while (ptr) { - FitsImage* sptr = ptr; - while (sptr) { - sptr->block(); - - switch (mosaicType) { - case Base::IRAF: - case Base::WCSMOSAIC: - rr &= processMosaicKeywords(ptr); - break; - default: - break; - } - sptr = sptr->nextSlice(); - } - ptr = ptr->nextMosaic(); - } - msk = msk->next(); - } - - return rr; -} - -#else - int Context::block() { if (DebugPerf) @@ -495,8 +380,6 @@ int Context::blockMask() return rr; } -#endif - void Context::bltHist(char* xname, char* yname, int num) { if (!fits) @@ -1922,62 +1805,6 @@ void* reorder321(void* tt) return NULL; } -#ifdef __WIN32 - -void Context::reorderAxis(char* data, char** sjv, int ww, int hh, int dd, - size_t bz) -{ - t_reorder_arg targ; - - targ.sjv = sjv; - targ.ww = ww; - targ.hh = hh; - targ.dd = dd; - targ.bz = bz; - - for (int mm=0; mm<naxis_[2]; mm++) { - targ.dest = data + (size_t)naxis_[0]*naxis_[1]*mm*targ.bz; - targ.mm = mm; - - switch (axesOrder_) { - case 123: - return; - case 132: - naxis_[0] =ww; - naxis_[1] =dd; - naxis_[2] =hh; - reorder132(&targ); - break; - case 213: - naxis_[0] =hh; - naxis_[1] =ww; - naxis_[2] =dd; - reorder213(&targ); - break; - case 231: - naxis_[0] =hh; - naxis_[1] =dd; - naxis_[2] =ww; - reorder231(&targ); - break; - case 312: - naxis_[0] =dd; - naxis_[1] =ww; - naxis_[2] =hh; - reorder312(&targ); - break; - case 321: - naxis_[0] =dd; - naxis_[1] =hh; - naxis_[2] =ww; - reorder321(&targ); - break; - } - } -} - -#else - void Context::reorderThread(void* tt, char* data, void* proc(void*), int* cnt) { t_reorder_arg* targ = (t_reorder_arg*)tt; @@ -2060,8 +1887,6 @@ void Context::reorderAxis(char* data, char** sjv, int ww, int hh, int dd, thread_ =NULL; } -#endif - void Context::reorderAxes() { if (DebugPerf) @@ -2753,99 +2578,6 @@ void Context::updateClip(FrScale* fr) cerr << *fr << endl; } -#ifdef __WIN32 - -void Context::updateClipGlobal(FrScale* fr) -{ - FitsImage* ptr = fits; - while (ptr) { - FitsImage* sptr = ptr; - while (sptr) { - sptr->updateClip(fr); - sptr = sptr->nextSlice(); - } - ptr = ptr->nextMosaic(); - } - - // set min/max low/high - ptr = fits; - while (ptr) { - FitsImage* sptr = ptr; - while (sptr) { - if (fr->min() > sptr->min()) - fr->setMin(sptr->min(), sptr->minXY()); - if (fr->max() < sptr->max()) - fr->setMax(sptr->max(), sptr->maxXY()); - - if (fr->low() > sptr->low()) - fr->setLow(sptr->low()); - if (fr->high() < sptr->high()) - fr->setHigh(sptr->high()); - - sptr = sptr->nextSlice(); - } - - ptr = ptr->nextMosaic(); - } - - // sanity check - if (fr->min() == DBL_MAX && fr->max() == -DBL_MAX) { - fr->setMin(NAN, Vector()); - fr->setMax(NAN, Vector()); - } - if (fr->low() == DBL_MAX && fr->high() == -DBL_MAX) { - fr->setLow(NAN); - fr->setHigh(NAN); - } - - ptr = fits; - while (ptr) { - FitsImage* sptr = ptr; - while (sptr) { - sptr->setClip(fr->low(), fr->high()); - sptr = sptr->nextSlice(); - } - ptr = ptr->nextMosaic(); - } -} - -void Context::updateClipLocal(FrScale* fr) -{ - FitsImage* ptr = cfits; - while (ptr) { - ptr->updateClip(fr); - ptr = ptr->nextMosaic(); - } - - // set min/max low/high - ptr = cfits; - while (ptr) { - if (fr->min() > ptr->min()) - fr->setMin(ptr->min(), ptr->minXY()); - if (fr->max() < ptr->max()) - fr->setMax(ptr->max(), ptr->maxXY()); - - if (fr->low() > ptr->low()) - fr->setLow(ptr->low()); - if (fr->high() < ptr->high()) - fr->setHigh(ptr->high()); - - ptr = ptr->nextMosaic(); - } - - // sanity check - if (fr->min() == DBL_MAX && fr->max() == -DBL_MAX) { - fr->setMin(NAN, Vector()); - fr->setMax(NAN, Vector()); - } - if (fr->low() == DBL_MAX && fr->high() == -DBL_MAX) { - fr->setLow(NAN); - fr->setHigh(NAN); - } -} - -#else - void Context::updateClipGlobal(FrScale* fr) { if (thread_) @@ -2986,8 +2718,6 @@ void Context::updateClipLocal(FrScale* fr) } } -#endif - void Context::updateContours() { fvcontour_.update(cfits); diff --git a/tksao/frame/context.h b/tksao/frame/context.h index d03bfa1..eb39de5 100644 --- a/tksao/frame/context.h +++ b/tksao/frame/context.h @@ -5,9 +5,7 @@ #ifndef __context_h__ #define __context_h__ -#ifndef __WIN32 #include <pthread.h> -#endif #include "base.h" #include "colorscale.h" @@ -88,13 +86,9 @@ class Context { List<ContourLevel>&); void reorderAxis(char*, char**, int, int, int, size_t); -#ifndef __WIN32 void reorderThread(void*, char*, void* (void*), int*); -#endif -#ifndef __WIN32 pthread_t* thread_; -#endif public: FitsImage* bfits_; diff --git a/tksao/frame/fitsanalysis.C b/tksao/frame/fitsanalysis.C index d3bc830..69366d0 100644 --- a/tksao/frame/fitsanalysis.C +++ b/tksao/frame/fitsanalysis.C @@ -2,9 +2,7 @@ // Smithsonian Astrophysical Observatory, Cambridge, MA, USA // For conditions of distribution and use, see copyright notice in "copyright" -#ifndef __WIN32 #include <pthread.h> -#endif #include "fitsimage.h" #include "analysis.h" @@ -13,99 +11,6 @@ void* convolve(void* tt); -#ifdef __WIN32 - -void FitsImage::analysis(int which) -{ - if (DebugPerf) - cerr << "FitsImage::analysis()" << endl; - - if (manageAnalysis_) { - if (analysis_) - delete analysis_; - if (analysisdata_) - delete analysisdata_; - } - manageAnalysis_ =0; - analysis_ = block_; - analysisdata_ = blockdata_; - - if (which) { - analysis_ = new FitsAnalysis(block_); - if (analysis_->isValid()) { - analysisdata_ = new FitsDatam<double>(analysis_, interp_); - - smooth(); - manageAnalysis_ =1; - } - else { - delete analysis_; - analysis_ = block_; - } - } - - image_ = analysis_; - data_ = analysisdata_; -} - -void FitsImage::smooth() -{ - // radius - int r = context_->smoothRadius(); - - int ww = analysis_->head()->naxis(0); - int hh = analysis_->head()->naxis(1); - - // src - double* src = new double[ww*hh]; - double* ptr = src; - for (long jj=0; jj<hh; jj++) - for (long ii=0; ii<ww; ii++, ptr++) - *ptr = blockdata_->getValueDouble(jj*ww+ii); - - // dest - double* dest = (double*)analysis_->data(); - - // kernel - // create kernel - int rr = 2*r+1; - double* kernel = new double[rr*rr]; - memset(kernel, 0, rr*rr*sizeof(double)); - - switch (context_->smoothFunction()) { - case Context::BOXCAR: - boxcar(kernel,r); - break; - case Context::TOPHAT: - tophat(kernel,r); - break; - case Context::GAUSSIAN: - gaussian(kernel,r); - break; - } - - // convolve - t_smooth_arg* targ = new t_smooth_arg; - targ->kernel = kernel; - targ->src = src; - targ->dest = dest; - targ->width = ww; - targ->height = hh; - targ->radius = r; - - convolve(targ); - - // clean up - if (targ->kernel) - delete [] targ->kernel; - if (targ->src) - delete [] targ->src; - if (targ) - delete targ; -} - -#else - void FitsImage::analysis(int which, pthread_t* thread, t_smooth_arg* targ) { if (DebugPerf) @@ -195,8 +100,6 @@ void FitsImage::smooth(pthread_t* thread, t_smooth_arg* targ) internalError("Unable to Create Thread"); } -#endif - void* convolve(void* tt) { t_smooth_arg* targ = (t_smooth_arg*)tt; diff --git a/tksao/frame/fitsblock.C b/tksao/frame/fitsblock.C index 19812b8..44ce059 100644 --- a/tksao/frame/fitsblock.C +++ b/tksao/frame/fitsblock.C @@ -73,8 +73,6 @@ void FitsImage::block() processKeywordsParams(); } -#ifndef __WIN32 - void FitsImage::block(pthread_t* thread) { if (DebugPerf) @@ -142,8 +140,6 @@ void FitsImage::block(pthread_t* thread) processKeywordsParams(); } -#endif - void* blockproc(void* tt) { t_block_arg* targ = (t_block_arg*)tt; diff --git a/tksao/frame/fitsimage.C b/tksao/frame/fitsimage.C index 465363d..4e73214 100644 --- a/tksao/frame/fitsimage.C +++ b/tksao/frame/fitsimage.C @@ -2,9 +2,7 @@ // Smithsonian Astrophysical Observatory, Cambridge, MA, USA // For conditions of distribution and use, see copyright notice in "copyright" -#ifndef __WIN32 #include <pthread.h> -#endif #include "fitsimage.h" #include "framebase.h" @@ -2336,8 +2334,6 @@ void FitsImage::updateClip(FrScale* fr) data_->updateClip(fr,getDataParams(fr->secMode())); } -#ifndef __WIN32 - void* clipproc(void* tt) { t_clip_arg* targ = (t_clip_arg*)tt; @@ -2359,8 +2355,6 @@ void FitsImage::updateClip(FrScale* fr, pthread_t* thread, t_clip_arg* targ) internalError("Unable to Create Thread"); } -#endif - const char* FitsImage::getFileName(Base::FileNameType type) { switch (type) { diff --git a/tksao/frame/fitsimage.h b/tksao/frame/fitsimage.h index 8d90280..29f0de5 100644 --- a/tksao/frame/fitsimage.h +++ b/tksao/frame/fitsimage.h @@ -135,11 +135,7 @@ class FitsImage { char* root(const char*); char* strip(const char*); -#ifdef __WIN32 - void smooth(); -#else void smooth(pthread_t*, t_smooth_arg*); -#endif void wcsShow(WorldCoor*); void astinit(int, FitsHead*, FitsHead*); @@ -244,15 +240,9 @@ class FitsImage { void setContext(Context* cx) {context_ = cx;} void load(); -#ifdef __WIN32 - void analysis(int); -#else void analysis(int, pthread_t*, t_smooth_arg*); -#endif void block(); -#ifndef __WIN32 void block(pthread_t*); -#endif Matrix bin(const Vector&); Matrix binCenter(); @@ -471,9 +461,7 @@ class FitsImage { double high() {return data_ ? data_->high() : 0;} void updateClip(FrScale*); -#ifndef __WIN32 void updateClip(FrScale* fr, pthread_t* thread, t_clip_arg* targ); -#endif int hasDATAMIN() {return data_ ? data_->hasDATAMIN() : 0;} int hasDATASEC() {return keyDATASEC;} diff --git a/tksao/frame/frame3d.C b/tksao/frame/frame3d.C index de2a299..c3bb143 100644 --- a/tksao/frame/frame3d.C +++ b/tksao/frame/frame3d.C @@ -7,11 +7,8 @@ #include "ps.h" #include "sigbus.h" -#ifndef __WIN32 #include <pthread.h> -#endif -#ifndef __WIN32 void render3dTimer(void* ptr) { int rr = ((Frame3d*)ptr)->processDetach(); if (rr) { @@ -21,7 +18,6 @@ void render3dTimer(void* ptr) { else ((Frame3d*)ptr)->setTimer(0); } -#endif Frame3d::Frame3d(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) : Frame3dBase(i,c,item) @@ -43,9 +39,7 @@ Frame3d::Frame3d(Tcl_Interp* i, Tk_Canvas c, Tk_Item* item) colorScale = NULL; colorCells = NULL; -#ifndef __WIN32 thread_ =NULL; -#endif targ_ =NULL; status_ = 0; @@ -76,10 +70,8 @@ Frame3d::~Frame3d() if (colorCells) delete [] colorCells; -#ifndef __WIN32 if (thread_) delete [] thread_; -#endif if (targ_) delete [] targ_; @@ -95,62 +87,6 @@ Frame3d::~Frame3d() delete rtb_; } -#ifdef __WIN32 - -unsigned char* Frame3d::fillImage(int width, int height, - Coord::InternalSystem sys) -{ - unsigned char* img =NULL; - Matrix3d mm = context->fits->matrixToData3d(sys); - - switch (sys) { - case Coord::WIDGET: - { - RayTrace* rt = findInCache(cache_, az_, el_); - if (!rt) { - BBox3d bb = imageBounds(width, height, mm); - rt = new RayTrace(az_, el_, width, height, mm, bb); - if (!fillImageJoin(rt)) - return NULL; - cacheIt(cache_, rt); - } - img = fillImageColor(rt); - } - break; - case Coord::PANNER: - { - RayTrace* rt = findInCache(pannerCache_, az_, el_); - if (!rt) { - BBox3d bb = imageBounds(width, height, mm); - rt = new RayTrace(az_, el_, width, height, mm, bb); - if (!fillImageJoin(rt)) - return NULL; - cacheIt(pannerCache_, rt); - } - img = fillImageColor(rt); - } - break; - case Coord::PS: - { - BBox3d bb = imageBounds(width, height, mm); - RayTrace* rt = new RayTrace(az_, el_, width, height, mm, bb); - if (!fillImageJoin(rt)) - return NULL; - img = fillImageColor(rt); - if (rt) - delete rt; - } - break; - default: - // na - break; - } - - return img; -} - -#else - unsigned char* Frame3d::fillImage(int width, int height, Coord::InternalSystem sys) { @@ -270,8 +206,6 @@ unsigned char* Frame3d::fillImage(int width, int height, return img; } -#endif - void* raytrace(void* arg) { t_arg* targ = (t_arg*)arg; @@ -387,70 +321,6 @@ void* raytrace(void* arg) return NULL; } -#ifdef __WIN32 - -int Frame3d::fillImageJoin(RayTrace* rt) -{ - BBox3d& bb = rt->bb_; - - Vector3d dd=bb.size(); - int ww = dd[0]; - int hh = dd[1]; - int zz = dd[2]; - - // sanity check - if (!ww || !hh || !zz) - return 1; - - // local var overide - int nrays = ww*hh; - int* xid = new int[nrays]; - int* yid = new int[nrays]; - int x=bb.ll[0]+.5; // don't know why; - int y=bb.ll[1]+.5; // don't know why - - // init array - for (int jj=0; jj<hh; jj++) { - for (int ii=0; ii<ww; ii++) { - xid[jj*ww+ii] = ii+x; - yid[jj*ww+ii] = jj+y; - } - } - - // local var overide - t_arg targ; - - targ.renderMethod = renderMethod_; - targ.width = rt->width_; - targ.zbuf = rt->zbuf_; - targ.mkzbuf = rt->mkzbuf_; - targ.context = context; - - targ.matrix = rt->mm_; - - targ.xid = xid; - targ.yid = yid; - targ.start = 0; - targ.stop = nrays-1; - targ.zstart = bb.ll[2]; - targ.zstop = bb.ur[2]; - - targ.rays =0; - targ.abort =0; - targ.done =0; - - raytrace(&targ); - - if (xid) - delete [] xid; - if (yid) - delete [] yid; - - return 1; -} - -#else - int Frame3d::fillImageJoin(RayTrace* rt) { BBox3d& bb = rt->bb_; @@ -921,8 +791,6 @@ int Frame3d::bkgDetach(double az, double el) { return 0; } -#endif - void Frame3d::cacheIt(List<RayTrace>& cache, RayTrace* rt) { // hard coded diff --git a/tksao/frame/frame3d.h b/tksao/frame/frame3d.h index 9b97b42..feaebdc 100644 --- a/tksao/frame/frame3d.h +++ b/tksao/frame/frame3d.h @@ -42,9 +42,7 @@ class Frame3d : public Frame3dBase { ColorScale* colorScale; // current color scale unsigned char* colorCells; // current color values -#ifndef __WIN32 pthread_t* thread_; -#endif int status_; t_arg* targ_; @@ -57,13 +55,9 @@ class Frame3d : public Frame3dBase { int rtbcnt_; private: -#ifndef __WIN32 void cancelDetach(); void fillImageDetach(RayTrace*); int bkgDetach(double az, double el); -#else - void cancelDetach() {} -#endif BBox3d imageBounds(int, int, Matrix3d); void ibv3d(Vector3d, Matrix3d&, int, int, double*, double*); @@ -97,9 +91,7 @@ class Frame3d : public Frame3dBase { virtual ~Frame3d(); void setTimer(Tcl_TimerToken tt) {timer_ = tt;} -#ifndef __WIN32 int processDetach(); -#endif void getColorbarCmd(); void getRGBChannelCmd(); |