Changeset 393 for applications
- Timestamp:
- 06/19/09 17:57:54 (16 years ago)
- Location:
- applications/bdmtoolbox/mex
- Files:
-
- 1 added
- 2 modified
Legend:
- Unmodified
- Added
- Removed
-
applications/bdmtoolbox/mex/CMakeLists.txt
r391 r393 13 13 14 14 MEX(merger_mx) 15 EXEC(merger) 15 16 MEX(config2mxstruct) 16 17 MEX(mxstruct2config) -
applications/bdmtoolbox/mex/merger_mx.cpp
r391 r393 25 25 26 26 // LOAD CONFIG 27 UImxArray Src; 28 Src.addList(input[0],"Sources"); 27 UImxArray Cfg; 28 Cfg.addList(input[0],"Sources"); 29 Cfg.addGroup(input[1],"Support"); 30 Cfg.addGroup(input[2],"Merger"); 31 32 //DBG 33 Cfg.writeFile("merger_mx.cfg"); 29 34 30 UImxArray Sup (input[1]);31 UImxArray Mer (input[2]);32 35 // Sources 33 36 Array<mpdf*> Sources; 34 37 //abuse Mer to store sources 35 36 Setting& _Sources=Src.lookup("Sources"); 38 Setting& _Sources=Cfg.lookup("Sources"); 37 39 int Slen=_Sources.getLength(); 38 40 Sources.set_size(Slen); 39 41 for (int i=0; i<Slen; i++){ 40 mpdf* mtmp = UI::build<mpdf>(_Sources,i);41 if (mtmp) {42 try{ 43 mpdf* mtmp = UI::build<mpdf>(_Sources,i); 42 44 Sources(i)=mtmp; 43 } else{ // source is not mpdf 44 epdf* etmp = UI::build<epdf>(_Sources,i); 45 if (etmp){ 46 Sources(i) = new mepdf(etmp, true); 45 } 46 catch (UIbuildException e){ 47 // it is not mpdf - see if it is epdf 48 try { 49 epdf* etmp = UI::build<epdf>(_Sources,i); 50 if (etmp){ 51 Sources(i) = new mepdf(etmp, true); 52 } 53 47 54 } 55 catch (...) {it_error("no mpdfs or epdfs found!");} 48 56 } 49 57 50 58 } 51 59 52 merger_base* Merger=UI::build<merger_base>( Mer.getRoot());60 merger_base* Merger=UI::build<merger_base>(Cfg,"Merger"); 53 61 54 62 // Support 55 Setting & _Supp= Sup.getRoot();63 Setting & _Supp=Cfg.lookup("Support"); 56 64 65 if (_Supp.exists("grid") && _Supp.exists("nbins")) { 57 66 Array<vec> bounds (0); 58 67 UI::get (bounds, _Supp, "grid"); 59 68 ivec nbins(0); 60 69 UI::get (nbins, _Supp, "nbins"); 70 Merger->set_support (bounds,nbins); 61 71 62 epdf *g0=UI::build<epdf> (_Supp, "pdf"); 63 int npoints=100; 64 _Supp.lookupValue("nsamples",npoints); 65 72 }else { 73 if (_Supp.exists("pdf") && _Supp.exists("nsamples")){ 74 epdf *g0=UI::build<epdf> (_Supp, "pdf"); 75 int npoints=100; 76 _Supp.lookupValue("nsamples",npoints); 77 Merger->set_support (*g0,npoints); 78 delete g0; 79 } 80 else it_error("Use either [grid,nbins] or [pdf,nsamples]."); 81 } 66 82 // COMPUTE RESULTS 67 83 Merger->set_sources(Sources,true); // takes care of deletion of sources 68 if (bounds.length() > 0 && nbins.length()>0) {69 Merger->set_support (bounds,nbins);70 } else {71 if (g0) {72 Merger->set_support (*g0,npoints);73 delete g0;74 }75 }76 84 Merger->merge(); 77 85