EMAN2
emdata_modular.cpp
Go to the documentation of this file.
00001 
00005 /*
00006  * Author: Steven Ludtke, 04/10/2003 (sludtke@bcm.edu)
00007  * Copyright (c) 2000-2006 Baylor College of Medicine
00008  *
00009  * This software is issued under a joint BSD/GNU license. You may use the
00010  * source code in this file under either license. However, note that the
00011  * complete EMAN2 and SPARX software packages have some GPL dependencies,
00012  * so you are responsible for compliance with the licenses of these packages
00013  * if you opt to use BSD licensing. The warranty disclaimer below holds
00014  * in either instance.
00015  *
00016  * This complete copyright notice must be included in any revised version of the
00017  * source code. Additional authorship citations may be added, but existing
00018  * author citations must be preserved.
00019  *
00020  * This program is free software; you can redistribute it and/or modify
00021  * it under the terms of the GNU General Public License as published by
00022  * the Free Software Foundation; either version 2 of the License, or
00023  * (at your option) any later version.
00024  *
00025  * This program is distributed in the hope that it will be useful,
00026  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00027  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00028  * GNU General Public License for more details.
00029  *
00030  * You should have received a copy of the GNU General Public License
00031  * along with this program; if not, write to the Free Software
00032  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
00033  *
00034  * */
00035 
00036 #include "emdata.h"
00037 #include "processor.h"
00038 #include "cmp.h"
00039 #include "aligner.h"
00040 #include "projector.h"
00041 #include "analyzer.h"
00042 
00043 using namespace EMAN;
00044 
00045 void EMData::process_inplace(const string & processorname, const Dict & params)
00046 {
00047         ENTERFUNC;
00048         Processor *f = Factory < Processor >::get(processorname, params);
00049         if (f) {
00050                 f->process_inplace(this);
00051                 if( f )
00052                 {
00053                         delete f;
00054                         f = 0;
00055                 }
00056         }
00057         EXITFUNC;
00058 }
00059 
00060 void EMData::process_inplace(Processor * p)
00061 {
00062         ENTERFUNC;
00063         if(p) {
00064                 p->process_inplace(this);
00065         }
00066         EXITFUNC;
00067 }
00068 
00069 EMData* EMData::process(const string & processorname, const Dict & params) const
00070 {
00071         ENTERFUNC;
00072         Processor *f = Factory < Processor >::get(processorname, params);
00073         EMData * result = 0;
00074         if (f) {
00075                 result = f->process(this);
00076                 if( f )
00077                 {
00078                         delete f;
00079                         f = 0;
00080                 }
00081         }
00082         return result;
00083         EXITFUNC;
00084 }
00085 
00086 EMData * EMData::process(Processor * p) const
00087 {
00088         ENTERFUNC;
00089         EMData * result = 0;
00090         if(p) {
00091                 result = p->process(this);
00092         }
00093         return result;
00094         EXITFUNC;
00095 }
00096 
00097 float EMData::cmp(const string & cmpname, EMData * with, const Dict & params)
00098 {
00099         ENTERFUNC;
00100         float result = 0;
00101         Cmp *c = Factory < Cmp >::get(cmpname, params);
00102         if (c) {
00103                 result = c->cmp(this, with);
00104                 if( c )
00105                 {
00106                         delete c;
00107                         c = 0;
00108                 }
00109         }
00110 
00111         EXITFUNC;
00112         return result;
00113 }
00114 
00115 
00116 EMData *EMData::align(const string & aligner_name, EMData * to_img,
00117                                           const Dict & params, const string & cmp_name, const Dict& cmp_params)
00118 {
00119         ENTERFUNC;
00120         EMData *result = 0;
00121         Aligner *a = Factory < Aligner >::get(aligner_name, params);
00122         if (a) {
00123                 if (cmp_name == "") {
00124                         result = a->align(this, to_img);
00125                 }
00126                 else {
00127                         result = a->align(this, to_img, cmp_name, cmp_params);
00128                 }
00129                 if( a )
00130                 {
00131                         delete a;
00132                         a = 0;
00133                 }
00134         }
00135 
00136         EXITFUNC;
00137         return result;
00138 }
00139 
00140 vector<Dict> EMData::xform_align_nbest(const string & aligner_name, EMData * to_img,
00141                                                                 const Dict & params, const unsigned int nsoln, const string & cmp_name,
00142                                                                                 const Dict& cmp_params)
00143 {
00144         ENTERFUNC;
00145         Aligner *a = Factory < Aligner >::get(aligner_name, params);
00146         vector<Dict> result;
00147         if (a) {
00148                 result = a->xform_align_nbest(this,to_img,nsoln,cmp_name,cmp_params);
00149         }
00150 
00151         return result;
00152 }
00153 
00154 EMData *EMData::project(const string & projector_name, const Dict & params)
00155 {
00156         ENTERFUNC;
00157         EMData *result = 0;
00158         Projector *p = Factory < Projector >::get(projector_name, params);
00159         if (p) {
00160                 result = p->project3d(this);
00161                 if( p )
00162                 {
00163                         delete p;
00164                         p = 0;
00165                 }
00166         }
00167 
00168         EXITFUNC;
00169         return result;
00170 }
00171 
00172 
00173 EMData *EMData::project(const string & projector_name, const Transform & t3d)
00174 {
00175         ENTERFUNC;
00176         EMData *result = 0;
00177         Dict params;
00178         params["transform"] = (Transform*) &t3d;
00179         Projector *p = Factory < Projector >::get(projector_name, params);
00180         if (p) {
00181                 result = p->project3d(this);
00182                 if( p )
00183                 {
00184                         delete p;
00185                         p = 0;
00186                 }
00187         }
00188 
00189         EXITFUNC;
00190         return result;
00191 }
00192 
00193 EMData *EMData::backproject(const string & projector_name, const Dict & params)
00194 {
00195         ENTERFUNC;
00196         EMData *result = 0;
00197         Projector *p = Factory < Projector >::get(projector_name, params);
00198         if (p) {
00199                 result = p->backproject3d(this);
00200                 if( p )
00201                 {
00202                         delete p;
00203                         p = 0;
00204                 }
00205         }
00206 
00207         EXITFUNC;
00208         return result;
00209 }