|
Isis 3.0 Application Source Code Reference |
Home |
00001 #include "Isis.h" 00002 #include "ControlNet.h" 00003 #include "SerialNumberList.h" 00004 #include "ControlPointList.h" 00005 00006 using namespace std; 00007 using namespace Isis; 00008 00009 void ProcessControlPoints (std::string psFileName, ControlNet & pcCnet, bool pbDelete, Pvl & pcPvlLog, bool pbPreserve); 00010 void ProcessControlMeasures(std::string psFileName, ControlNet & pcCnet, bool pbDelete, bool pbPreserve); 00011 00012 static int giPointsDeleted=0, giMeasuresDeleted=0; 00013 00014 static bool gbLog; 00015 00016 // Main program 00017 void IsisMain() { 00018 00019 // Get user parameters 00020 UserInterface &ui = Application::GetUserInterface(); 00021 ControlNet cnet( ui.GetFilename("CNET") ); 00022 bool bDelete = ui.GetBoolean("DELETE"); 00023 bool bPreserve = ui.GetBoolean("PRESERVE"); 00024 bool bPointList=false, bCubeList=false; 00025 Pvl pvlLog; 00026 00027 gbLog=false; 00028 00029 std::string sPointsFile, sMeasuresFile, sLogfile; 00030 00031 //Get the Log file 00032 if ( ui.WasEntered("LOG") ) { 00033 sLogfile = ui.GetFilename("LOG"); 00034 gbLog=true; 00035 } 00036 00037 //List has Points Ids 00038 if ( ui.WasEntered("POINTLIST") ){ 00039 sPointsFile = ui.GetFilename("POINTLIST"); 00040 ProcessControlPoints(sPointsFile, cnet, bDelete, pvlLog, bPreserve); 00041 } 00042 00043 //List has Cube file names 00044 if ( ui.WasEntered("FROMLIST") ) { 00045 sMeasuresFile = ui.GetFilename("FROMLIST"); 00046 ProcessControlMeasures(sMeasuresFile, cnet, bDelete, bPreserve); 00047 } 00048 00049 //No List files - only Delete option was chosen 00050 if ( bDelete && !bPointList && !bCubeList ){ 00051 for ( int cp = cnet.Size()-1; cp >= 0; cp -- ) { 00052 if ( cnet[cp].Ignore() ) { 00053 giMeasuresDeleted += cnet[cp].Size(); 00054 cnet.Delete(cp); 00055 giPointsDeleted++; 00056 } 00057 else { 00058 for ( int cm = cnet[cp].Size()-1; cm >= 0; cm -- ) { 00059 if ( cnet[cp][cm].Ignore() ) { 00060 cnet[cp].Delete(cm); 00061 giMeasuresDeleted++; 00062 } 00063 // Check if the number of measures in the point is zero or 00064 // there are few measures in the point and preserve flag is false. 00065 if ( ( (cnet[cp].Size() < 2 && !bPreserve) && cnet[cp].Type() != ControlPoint::Ground ) 00066 || cnet[cp].Size() == 0 ) { 00067 giMeasuresDeleted += cnet[cp].Size(); 00068 cnet.Delete(cp); 00069 giPointsDeleted++; 00070 } 00071 00072 } 00073 } 00074 } 00075 } 00076 00077 //log statistics 00078 if ( gbLog ) { 00079 pvlLog += Isis::PvlKeyword("PointsDeleted", giPointsDeleted); 00080 pvlLog += Isis::PvlKeyword("MeasuresDeleted", giMeasuresDeleted); 00081 00082 pvlLog.Write(sLogfile); 00083 } 00084 00085 cnet.Write( ui.GetFilename("ONET") ); 00086 } 00087 00088 00089 /** 00090 * Reads the Control Points list and matches with the control 00091 * network. If match was successful, ignore the point. If 00092 * Delete option was chosen, delete the point 00093 * 00094 * @param psFileName - Filename with Control Points 00095 * @param pcCnet - holds the input Control Network 00096 * @param pbDelete - Delete option (true/false) 00097 * @param pcPvlLog - Pvl for which control points stats have 00098 * to be added 00099 * @param pbPreserve - Preserve Control Points with Measures 00100 * equal to one. (true/false) 00101 * 00102 * @return none 00103 */ 00104 void ProcessControlPoints(std::string psFileName, ControlNet & pcCnet, bool pbDelete, Pvl& pcPvlLog, bool pbPreserve) 00105 { 00106 ControlPointList cpList(psFileName); 00107 00108 for ( int cp = pcCnet.Size()-1; cp >= 0; cp -- ) { 00109 00110 // Compare each Point Id listed with the Point in the 00111 // Control Network for according exclusion 00112 if ( cpList.HasControlPoint(pcCnet[cp].Id()) ) { 00113 pcCnet[cp].SetIgnore(true); 00114 } 00115 00116 if ( pbDelete ){ 00117 //look for previously ignored control points 00118 if (pcCnet[cp].Ignore()){ 00119 giMeasuresDeleted += pcCnet[cp].Size(); 00120 pcCnet.Delete(cp); 00121 giPointsDeleted++; 00122 } 00123 else{ 00124 //look for previously ignored control measures 00125 for ( int cm = pcCnet[cp].Size()-1; cm >= 0 ; cm-- ) { 00126 if (pcCnet[cp][cm].Ignore() && pbDelete) { 00127 pcCnet[cp].Delete(cm); 00128 giMeasuresDeleted++; 00129 } 00130 } 00131 // Check if there are too few measures in the point or the point was previously ignored 00132 if (( (pcCnet[cp].Size() < 2 && !pbPreserve) && pcCnet[cp].Type() != ControlPoint::Ground ) 00133 || pcCnet[cp].Size() == 0 || (pcCnet[cp].Ignore() && pbDelete)) { 00134 giMeasuresDeleted += pcCnet[cp].Size(); 00135 pcCnet.Delete(cp); 00136 giPointsDeleted++; 00137 } 00138 } 00139 } 00140 } 00141 if ( gbLog ) { 00142 cpList.RegisterStatistics(pcPvlLog); 00143 } 00144 } 00145 00146 /** 00147 * Reads the Cube file list and creates the serial number of the 00148 * Cubes. If Control Measure serial# matches with the control 00149 * network,ignore the point. If Delete option was chosen, delete 00150 * the Measure 00151 * 00152 * @param psFileName - Filename with Cube File names 00153 * @param pcCnet - holds the input Control Network 00154 * @param pbDelete - Delete option (true/false) 00155 * @param pbPreserve - Preserve Control Points with Measures 00156 * equal to one. (true/false) 00157 * 00158 * @return none 00159 */ 00160 void ProcessControlMeasures(std::string psFileName, ControlNet & pcCnet, bool pbDelete, bool pbPreserve) 00161 { 00162 SerialNumberList snl = psFileName; 00163 00164 for ( int cp = pcCnet.Size()-1; cp >= 0; cp -- ) { 00165 00166 // Compare each Serial Number listed with the serial number in the 00167 // Control Measure for according exclusion 00168 for ( int cm = pcCnet[cp].Size()-1; cm >= 0 ; cm-- ) { 00169 if ( snl.HasSerialNumber(pcCnet[cp][cm].CubeSerialNumber()) ) { 00170 pcCnet[cp][cm].SetIgnore( true ); 00171 } 00172 //also look for previously ignored control measures 00173 if ( pbDelete && pcCnet[cp][cm].Ignore() ) { 00174 pcCnet[cp].Delete(cm); 00175 giMeasuresDeleted++; 00176 } 00177 } 00178 // Check if there are too few measures in the point or the point was previously ignored 00179 if (( (pcCnet[cp].Size() < 2 && !pbPreserve) && pcCnet[cp].Type() != ControlPoint::Ground ) 00180 || pcCnet[cp].Size() == 0 || (pcCnet[cp].Ignore() && pbDelete)) { 00181 giMeasuresDeleted += pcCnet[cp].Size(); 00182 pcCnet.Delete(cp); 00183 giPointsDeleted++; 00184 } 00185 } 00186 } 00187