From 5234e88e54383e74f08bc69ab1d93bc8518e862c Mon Sep 17 00:00:00 2001 From: Steven Lambright Date: Sat, 3 Jul 2010 01:34:37 +0000 Subject: [PATCH] Formatted git-svn-id: http://subversion.wr.usgs.gov/repos/prog/isis3/trunk@110 41f8697f-d340-4b68-9986-7bafba869bb8 --- .../ApolloMetricCamera/ApolloMetricCamera.cpp | 16 +- .../ApolloMetricCamera/ApolloMetricCamera.h | 22 +- .../ApolloMetricDistortionMap.cpp | 74 +- .../ApolloMetricDistortionMap.h | 10 +- .../objs/ApolloMetricCamera/unitTest.cpp | 15 +- isis/src/base/apps/algebra/algebra.cpp | 112 +- .../apps/appjit/LineScanCameraRotation.cpp | 106 +- .../base/apps/appjit/LineScanCameraRotation.h | 18 +- isis/src/base/apps/appjit/PixelOffset.cpp | 172 +- isis/src/base/apps/appjit/PixelOffset.h | 40 +- isis/src/base/apps/appjit/appjit.cpp | 64 +- isis/src/base/apps/ascii2isis/ascii2isis.cpp | 65 +- isis/src/base/apps/automos/automos.cpp | 160 +- .../apps/autoregtemplate/autoregtemplate.cpp | 154 +- isis/src/base/apps/bandnorm/bandnorm.cpp | 91 +- isis/src/base/apps/bandtrim/bandtrim.cpp | 23 +- .../src/base/apps/butterworth/butterworth.cpp | 138 +- isis/src/base/apps/cam2cam/cam2cam.cpp | 62 +- isis/src/base/apps/cam2cam/cam2cam.h | 16 +- isis/src/base/apps/cam2map/cam2map.cpp | 338 +- isis/src/base/apps/cam2map/cam2map.h | 18 +- isis/src/base/apps/caminfo/CamTools.cpp | 1183 +++---- isis/src/base/apps/caminfo/CamTools.h | 402 +-- isis/src/base/apps/caminfo/caminfo.cpp | 121 +- isis/src/base/apps/campt/campt.cpp | 62 +- isis/src/base/apps/camrange/camrange.cpp | 92 +- isis/src/base/apps/camstats/camstats.cpp | 378 +-- isis/src/base/apps/camtrim/camtrim.cpp | 40 +- isis/src/base/apps/cathist/cathist.cpp | 28 +- isis/src/base/apps/catlab/catlab.cpp | 6 +- isis/src/base/apps/catoriglab/catoriglab.cpp | 2 +- isis/src/base/apps/circle/circle.cpp | 28 +- isis/src/base/apps/circle2/circle2.cpp | 54 +- isis/src/base/apps/cnet2mat/cnet2mat.cpp | 44 +- isis/src/base/apps/cnetadd/cnetadd.cpp | 172 +- isis/src/base/apps/cnetcheck/cnetcheck.cpp | 195 +- isis/src/base/apps/cnetedit/cnetedit.cpp | 198 +- isis/src/base/apps/cnetmerge/cnetmerge.cpp | 155 +- .../base/apps/cnetnewradii/cnetnewradii.cpp | 40 +- isis/src/base/apps/cnettable/cnettable.cpp | 66 +- isis/src/base/apps/coreg/coreg.cpp | 114 +- isis/src/base/apps/cosi/cosi.cpp | 12 +- isis/src/base/apps/crop/crop.cpp | 76 +- .../src/base/apps/cropspecial/cropspecial.cpp | 86 +- isis/src/base/apps/cubeatt/cubeatt.cpp | 11 +- isis/src/base/apps/cubeavg/cubeavg.cpp | 78 +- isis/src/base/apps/cubediff/Column.cpp | 64 +- isis/src/base/apps/cubediff/Column.h | 74 +- isis/src/base/apps/cubediff/WriteTabular.cpp | 114 +- isis/src/base/apps/cubediff/WriteTabular.h | 26 +- isis/src/base/apps/cubediff/cubediff.cpp | 135 +- isis/src/base/apps/cubefunc/cubefunc.cpp | 123 +- isis/src/base/apps/cubeit/cubeit.cpp | 66 +- isis/src/base/apps/cubenorm/cubenorm.cpp | 208 +- isis/src/base/apps/cubenorm/staticStats.cpp | 82 +- isis/src/base/apps/cubenorm/staticStats.h | 259 +- isis/src/base/apps/ddd2isis/ddd2isis.cpp | 48 +- .../base/apps/decorstretch/decorstretch.cpp | 45 +- isis/src/base/apps/deltack/deltack.cpp | 42 +- isis/src/base/apps/deriv/deriv.cpp | 28 +- isis/src/base/apps/desmear/desmear.cpp | 36 +- isis/src/base/apps/divfilter/divfilter.cpp | 22 +- isis/src/base/apps/dstripe/dstripe.cpp | 38 +- isis/src/base/apps/editlab/editlab.cpp | 56 +- isis/src/base/apps/edrget/edrget.cpp | 118 +- isis/src/base/apps/edrget/ftpget.cpp | 148 +- isis/src/base/apps/edrget/ftpget.h | 29 +- isis/src/base/apps/edrget/httpget.cpp | 167 +- isis/src/base/apps/edrget/httpget.h | 29 +- isis/src/base/apps/enlarge/enlarge.cpp | 52 +- isis/src/base/apps/enlarge/enlarge.h | 16 +- isis/src/base/apps/equalizer/equalizer.cpp | 436 +-- isis/src/base/apps/errors/errors.cpp | 21 +- isis/src/base/apps/explode/explode.cpp | 28 +- isis/src/base/apps/fakecube/fakecube.cpp | 58 +- isis/src/base/apps/fft/fft.cpp | 46 +- isis/src/base/apps/fillgap/fillgap.cpp | 66 +- isis/src/base/apps/findgaps/findgaps.cpp | 46 +- .../findimageoverlaps/findimageoverlaps.cpp | 6 +- isis/src/base/apps/findrx/findrx.cpp | 176 +- isis/src/base/apps/fits2isis/fits2isis.cpp | 60 +- isis/src/base/apps/flip/flip.cpp | 12 +- .../base/apps/footprintinit/footprintinit.cpp | 93 +- .../apps/footprintmerge/footprintmerge.cpp | 88 +- isis/src/base/apps/fx/fx.cpp | 64 +- isis/src/base/apps/gauss/gauss.cpp | 68 +- .../base/apps/gaussstretch/gaussstretch.cpp | 23 +- isis/src/base/apps/getkey/getkey.cpp | 62 +- isis/src/base/apps/getsn/getsn.cpp | 22 +- isis/src/base/apps/gradient/gradient.cpp | 54 +- isis/src/base/apps/greyscale/greyscale.cpp | 34 +- isis/src/base/apps/grid/grid.cpp | 540 ++-- isis/src/base/apps/handmos/handmos.cpp | 140 +- isis/src/base/apps/highpass/highpass.cpp | 28 +- isis/src/base/apps/hist/hist.cpp | 86 +- isis/src/base/apps/histeq/histeq.cpp | 92 +- isis/src/base/apps/histmatch/histmatch.cpp | 90 +- isis/src/base/apps/hsv2rgb/hsv2rgb.cpp | 46 +- isis/src/base/apps/ifft/ifft.cpp | 30 +- .../base/apps/interestcube/interestcube.cpp | 24 +- isis/src/base/apps/isis2ascii/isis2ascii.cpp | 38 +- isis/src/base/apps/isis2fits/isis2fits.cpp | 172 +- isis/src/base/apps/isis2gml/isis2gml.cpp | 6 +- isis/src/base/apps/isis2pds/isis2pds.cpp | 102 +- isis/src/base/apps/isis2raw/isis2raw.cpp | 128 +- isis/src/base/apps/isis2std/isis2std.cpp | 381 +-- isis/src/base/apps/isisui/isisui.cpp | 12 +- isis/src/base/apps/jigsaw/jigsaw.cpp | 72 +- isis/src/base/apps/kernfilter/kernfilter.cpp | 66 +- isis/src/base/apps/kuwahara/kuwahara.cpp | 52 +- isis/src/base/apps/lineeq/lineeq.cpp | 10 +- isis/src/base/apps/lowpass/lowpass.cpp | 136 +- isis/src/base/apps/makecube/makecube.cpp | 30 +- isis/src/base/apps/makeflat/makeflat.cpp | 182 +- isis/src/base/apps/map2cam/map2cam.cpp | 78 +- isis/src/base/apps/map2cam/map2cam.h | 16 +- isis/src/base/apps/map2map/map2map.cpp | 157 +- isis/src/base/apps/map2map/map2map.h | 18 +- isis/src/base/apps/mapgrid/mapgrid.cpp | 90 +- isis/src/base/apps/maplab/maplab.cpp | 100 +- isis/src/base/apps/mapmos/mapmos.cpp | 114 +- isis/src/base/apps/mappt/mappt.cpp | 132 +- isis/src/base/apps/mapsize/mapsize.cpp | 34 +- .../src/base/apps/maptemplate/maptemplate.cpp | 330 +- isis/src/base/apps/maptrim/maptrim.cpp | 68 +- isis/src/base/apps/mask/mask.cpp | 113 +- isis/src/base/apps/mat2cnet/mat2cnet.cpp | 244 +- isis/src/base/apps/median/median.cpp | 164 +- isis/src/base/apps/minmax/minmax.cpp | 74 +- isis/src/base/apps/mirror/mirror.cpp | 12 +- isis/src/base/apps/mode/mode.cpp | 130 +- isis/src/base/apps/mosrange/mosrange.cpp | 152 +- isis/src/base/apps/mvstats/mvstats.cpp | 71 +- isis/src/base/apps/nocam2map/nocam2map.cpp | 418 +-- isis/src/base/apps/nocam2map/nocam2map.h | 24 +- .../src/base/apps/noisefilter/noisefilter.cpp | 72 +- isis/src/base/apps/noproj/noproj.cpp | 204 +- isis/src/base/apps/noseam/noseam.cpp | 76 +- isis/src/base/apps/outline/outline.cpp | 45 +- .../base/apps/overlapstats/overlapstats.cpp | 177 +- isis/src/base/apps/pad/pad.cpp | 38 +- isis/src/base/apps/pca/pca.cpp | 73 +- isis/src/base/apps/pds2isis/pds2isis.cpp | 49 +- isis/src/base/apps/percent/percent.cpp | 28 +- isis/src/base/apps/phocube/phocube.cpp | 118 +- isis/src/base/apps/phohillier/Hillier.cpp | 266 +- isis/src/base/apps/phohillier/Hillier.h | 138 +- isis/src/base/apps/phohillier/phohillier.cpp | 26 +- .../src/base/apps/photemplate/photemplate.cpp | 34 +- isis/src/base/apps/photomet/photomet.cpp | 55 +- isis/src/base/apps/photrim/photrim.cpp | 40 +- isis/src/base/apps/pointreg/pointreg.cpp | 174 +- isis/src/base/apps/poly/poly.cpp | 46 +- isis/src/base/apps/pvldiff/pvldiff.cpp | 85 +- isis/src/base/apps/ratio/ratio.cpp | 22 +- isis/src/base/apps/raw2isis/raw2isis.cpp | 29 +- isis/src/base/apps/reduce/reduce.cpp | 146 +- isis/src/base/apps/remrx/remrx.cpp | 124 +- isis/src/base/apps/rgb2hsv/rgb2hsv.cpp | 75 +- isis/src/base/apps/rotate/rotate.cpp | 16 +- isis/src/base/apps/rotate/rotate.h | 68 +- isis/src/base/apps/seedgrid/seedgrid.cpp | 112 +- isis/src/base/apps/segment/segment.cpp | 22 +- isis/src/base/apps/shade/shade.cpp | 123 +- isis/src/base/apps/sharpen/sharpen.cpp | 18 +- isis/src/base/apps/skymap/skymap.cpp | 274 +- isis/src/base/apps/skypt/skypt.cpp | 60 +- isis/src/base/apps/skyrange/skyrange.cpp | 50 +- isis/src/base/apps/slither/ControlByRow.h | 515 ++-- .../base/apps/slither/SlitherTransform.cpp | 134 +- isis/src/base/apps/slither/SlitherTransform.h | 164 +- isis/src/base/apps/slither/slither.cpp | 30 +- isis/src/base/apps/slpmap/slpmap.cpp | 88 +- isis/src/base/apps/specadd/specadd.cpp | 13 +- .../base/apps/specdivfilter/specdivfilter.cpp | 24 +- .../base/apps/spechighpass/spechighpass.cpp | 24 +- .../src/base/apps/speclowpass/speclowpass.cpp | 24 +- isis/src/base/apps/specpix/specpix.cpp | 102 +- isis/src/base/apps/spicefit/spicefit.cpp | 14 +- isis/src/base/apps/spiceinit/spiceinit.cpp | 189 +- isis/src/base/apps/stats/stats.cpp | 70 +- isis/src/base/apps/std2isis/std2isis.cpp | 142 +- isis/src/base/apps/stretch/stretch.cpp | 50 +- isis/src/base/apps/svfilter/svfilter.cpp | 22 +- isis/src/base/apps/table2cube/table2cube.cpp | 16 +- isis/src/base/apps/tabledump/tabledump.cpp | 76 +- isis/src/base/apps/tonematch/tonematch.cpp | 40 +- isis/src/base/apps/translate/translate.cpp | 18 +- isis/src/base/apps/translate/translate.h | 14 +- isis/src/base/apps/trim/trim.cpp | 39 +- isis/src/base/apps/trimfilter/trimfilter.cpp | 18 +- isis/src/base/apps/uncrop/uncrop.cpp | 16 +- isis/src/base/apps/vicar2isis/vicar2isis.cpp | 25 +- isis/src/base/apps/warp/WarpTransform.cpp | 116 +- isis/src/base/apps/warp/WarpTransform.h | 30 +- isis/src/base/apps/warp/warp.cpp | 48 +- .../base/objs/AdaptiveGruen/AdaptiveGruen.cpp | 42 +- .../base/objs/AdaptiveGruen/AdaptiveGruen.h | 84 +- isis/src/base/objs/AdaptiveGruen/unitTest.cpp | 72 +- isis/src/base/objs/Affine/Affine.cpp | 188 +- isis/src/base/objs/Affine/Affine.h | 172 +- isis/src/base/objs/Affine/unitTest.cpp | 34 +- isis/src/base/objs/Albedo/Albedo.cpp | 71 +- isis/src/base/objs/Albedo/Albedo.h | 92 +- isis/src/base/objs/Albedo/unitTest.cpp | 22 +- isis/src/base/objs/AlbedoAtm/AlbedoAtm.cpp | 99 +- isis/src/base/objs/AlbedoAtm/AlbedoAtm.h | 84 +- isis/src/base/objs/AlbedoAtm/unitTest.cpp | 52 +- isis/src/base/objs/AlphaCube/AlphaCube.cpp | 170 +- isis/src/base/objs/AlphaCube/AlphaCube.h | 152 +- isis/src/base/objs/AlphaCube/unitTest.cpp | 40 +- .../base/objs/Anisotropic1/Anisotropic1.cpp | 159 +- .../src/base/objs/Anisotropic1/Anisotropic1.h | 82 +- isis/src/base/objs/Anisotropic1/unitTest.cpp | 24 +- .../base/objs/Anisotropic2/Anisotropic2.cpp | 217 +- .../src/base/objs/Anisotropic2/Anisotropic2.h | 114 +- isis/src/base/objs/Anisotropic2/unitTest.cpp | 18 +- isis/src/base/objs/Application/Application.h | 2 +- isis/src/base/objs/AtmosModel/AtmosModel.cpp | 646 ++-- isis/src/base/objs/AtmosModel/AtmosModel.h | 298 +- .../objs/AtmosModel/NumericalAtmosApprox.cpp | 262 +- .../objs/AtmosModel/NumericalAtmosApprox.h | 66 +- isis/src/base/objs/AtmosModel/unitTest.cpp | 295 +- .../AtmosModelFactory/AtmosModelFactory.cpp | 68 +- .../AtmosModelFactory/AtmosModelFactory.h | 58 +- .../base/objs/AtmosModelFactory/unitTest.cpp | 2 +- isis/src/base/objs/AutoReg/AutoReg.cpp | 514 ++-- isis/src/base/objs/AutoReg/AutoReg.h | 232 +- isis/src/base/objs/AutoReg/unitTest.cpp | 62 +- .../objs/AutoRegFactory/AutoRegFactory.cpp | 60 +- .../base/objs/AutoRegFactory/AutoRegFactory.h | 52 +- .../src/base/objs/AutoRegFactory/unitTest.cpp | 2 +- .../src/base/objs/BandManager/BandManager.cpp | 94 +- isis/src/base/objs/BandManager/BandManager.h | 78 +- isis/src/base/objs/BandManager/unitTest.cpp | 38 +- .../Basis1VariableFunction.cpp | 60 +- .../Basis1VariableFunction.h | 108 +- .../objs/Basis1VariableFunction/unitTest.cpp | 5 +- .../base/objs/BasisFunction/BasisFunction.cpp | 144 +- .../base/objs/BasisFunction/BasisFunction.h | 196 +- isis/src/base/objs/BasisFunction/unitTest.cpp | 14 +- isis/src/base/objs/Blobber/Blobber.cpp | 420 +-- isis/src/base/objs/Blobber/Blobber.h | 188 +- isis/src/base/objs/Blobber/unitTest.cpp | 232 +- .../base/objs/BoxcarManager/BoxcarManager.cpp | 74 +- .../base/objs/BoxcarManager/BoxcarManager.h | 112 +- isis/src/base/objs/BoxcarManager/unitTest.cpp | 56 +- isis/src/base/objs/Brick/Brick.cpp | 76 +- isis/src/base/objs/Brick/Brick.h | 229 +- isis/src/base/objs/Brick/unitTest.cpp | 15 +- isis/src/base/objs/Buffer/Buffer.cpp | 2 +- .../base/objs/BufferManager/BufferManager.cpp | 325 +- .../base/objs/BufferManager/BufferManager.h | 238 +- isis/src/base/objs/BufferManager/unitTest.cpp | 24 +- .../base/objs/BundleAdjust/BundleAdjust.cpp | 585 ++-- .../src/base/objs/BundleAdjust/BundleAdjust.h | 72 +- isis/src/base/objs/BundleAdjust/unitTest.cpp | 3 +- isis/src/base/objs/CSVReader/CSVReader.cpp | 820 ++--- isis/src/base/objs/CSVReader/CSVReader.h | 602 ++-- isis/src/base/objs/CSVReader/unitTest.cpp | 48 +- isis/src/base/objs/Calculator/Calculator.cpp | 383 +-- isis/src/base/objs/Calculator/Calculator.h | 68 +- isis/src/base/objs/Calculator/unitTest.cpp | 15 +- .../CameraDetectorMap/CameraDetectorMap.cpp | 2 +- .../CameraDetectorMap/CameraDetectorMap.h | 34 +- .../base/objs/CameraDetectorMap/unitTest.cpp | 2 +- .../CameraDistortionMap.cpp | 19 +- .../CameraDistortionMap/CameraDistortionMap.h | 23 +- .../objs/CameraDistortionMap/unitTest.cpp | 2 +- .../base/objs/CameraFactory/CameraFactory.cpp | 108 +- .../base/objs/CameraFactory/CameraFactory.h | 92 +- isis/src/base/objs/CameraFactory/unitTest.cpp | 14 +- .../CameraFocalPlaneMap.cpp | 66 +- .../CameraFocalPlaneMap/CameraFocalPlaneMap.h | 144 +- .../objs/CameraFocalPlaneMap/unitTest.cpp | 2 +- .../objs/CameraGroundMap/CameraGroundMap.cpp | 194 +- .../objs/CameraGroundMap/CameraGroundMap.h | 78 +- .../base/objs/CameraGroundMap/unitTest.cpp | 2 +- .../objs/CameraPointInfo/CameraPointInfo.cpp | 256 +- .../objs/CameraPointInfo/CameraPointInfo.h | 82 +- .../base/objs/CameraPointInfo/unitTest.cpp | 4 +- .../base/objs/CameraSkyMap/CameraSkyMap.cpp | 58 +- .../src/base/objs/CameraSkyMap/CameraSkyMap.h | 66 +- isis/src/base/objs/CameraSkyMap/unitTest.cpp | 2 +- isis/src/base/objs/Chip/Chip.cpp | 695 ++--- isis/src/base/objs/Chip/Chip.h | 302 +- isis/src/base/objs/Chip/unitTest.cpp | 172 +- .../src/base/objs/CollectorMap/CollectorMap.h | 1364 ++++---- isis/src/base/objs/CollectorMap/unitTest.cpp | 206 +- isis/src/base/objs/Column/Column.cpp | 68 +- isis/src/base/objs/Column/Column.h | 146 +- isis/src/base/objs/Column/unitTest.cpp | 5 +- .../base/objs/ControlGraph/ControlGraph.cpp | 348 +-- .../src/base/objs/ControlGraph/ControlGraph.h | 61 +- isis/src/base/objs/ControlGraph/unitTest.cpp | 52 +- .../src/base/objs/ControlMeasure/unitTest.cpp | 10 +- isis/src/base/objs/ControlNet/ControlNet.cpp | 365 +-- isis/src/base/objs/ControlNet/ControlNet.h | 168 +- isis/src/base/objs/ControlNet/unitTest.cpp | 36 +- .../base/objs/ControlPoint/ControlPoint.cpp | 516 ++-- .../src/base/objs/ControlPoint/ControlPoint.h | 102 +- isis/src/base/objs/ControlPoint/unitTest.cpp | 18 +- .../objs/ControlPointList/ControlPointList.h | 2 +- isis/src/base/objs/Cube/Cube.cpp | 1048 +++---- isis/src/base/objs/Cube/Cube.h | 520 ++-- isis/src/base/objs/Cube/CubeBsqHandler.cpp | 238 +- isis/src/base/objs/Cube/CubeBsqHandler.h | 114 +- isis/src/base/objs/Cube/CubeDef.h | 42 +- isis/src/base/objs/Cube/CubeFormat.h | 54 +- isis/src/base/objs/Cube/CubeIoHandler.cpp | 212 +- isis/src/base/objs/Cube/CubeIoHandler.h | 92 +- isis/src/base/objs/Cube/CubeTileHandler.cpp | 204 +- isis/src/base/objs/Cube/CubeTileHandler.h | 96 +- isis/src/base/objs/Cube/unitTest.cpp | 653 ++-- .../base/objs/CubeAttribute/CubeAttribute.cpp | 194 +- .../base/objs/CubeAttribute/CubeAttribute.h | 324 +- isis/src/base/objs/CubeAttribute/unitTest.cpp | 122 +- .../objs/CubeCalculator/CubeCalculator.cpp | 202 +- .../base/objs/CubeCalculator/CubeCalculator.h | 74 +- .../src/base/objs/CubeCalculator/unitTest.cpp | 3 +- .../objs/CubeDataThread/CubeDataThread.cpp | 242 +- .../base/objs/CubeDataThread/CubeDataThread.h | 76 +- .../CubeDataThread/CubeDataThreadTester.cpp | 72 +- .../CubeDataThread/CubeDataThreadTester.h | 22 +- .../src/base/objs/CubeDataThread/unitTest.cpp | 16 +- .../CubeInfixToPostfix/CubeInfixToPostfix.cpp | 38 +- .../CubeInfixToPostfix/CubeInfixToPostfix.h | 26 +- .../base/objs/CubeInfixToPostfix/unitTest.cpp | 5 +- .../src/base/objs/CubeManager/CubeManager.cpp | 32 +- isis/src/base/objs/CubeManager/CubeManager.h | 78 +- isis/src/base/objs/CubeManager/unitTest.cpp | 14 +- isis/src/base/objs/Endian/Endian.h | 84 +- isis/src/base/objs/Endian/unitTest.cpp | 6 +- .../base/objs/EndianSwapper/EndianSwapper.cpp | 218 +- .../base/objs/EndianSwapper/EndianSwapper.h | 124 +- isis/src/base/objs/EndianSwapper/unitTest.cpp | 111 +- .../objs/Equirectangular/Equirectangular.cpp | 246 +- .../objs/Equirectangular/Equirectangular.h | 138 +- .../base/objs/Equirectangular/unitTest.cpp | 50 +- isis/src/base/objs/FileList/FileList.cpp | 205 +- isis/src/base/objs/FileList/FileList.h | 118 +- isis/src/base/objs/FileList/unitTest.cpp | 4 +- isis/src/base/objs/Filename/Filename.cpp | 417 +-- isis/src/base/objs/Filename/Filename.h | 150 +- isis/src/base/objs/Filename/unitTest.cpp | 162 +- .../ForstnerOperator/ForstnerOperator.cpp | 58 +- .../objs/ForstnerOperator/ForstnerOperator.h | 48 +- .../base/objs/ForstnerOperator/unitTest.cpp | 46 +- .../FourierTransform/FourierTransform.cpp | 148 +- .../objs/FourierTransform/FourierTransform.h | 80 +- .../base/objs/FourierTransform/unitTest.cpp | 45 +- .../base/objs/FramingCamera/FramingCamera.cpp | 2 +- .../base/objs/FramingCamera/FramingCamera.h | 66 +- isis/src/base/objs/FramingCamera/unitTest.cpp | 2 +- isis/src/base/objs/GSLUtility/GSLUtility.cpp | 609 ++-- isis/src/base/objs/GSLUtility/GSLUtility.h | 194 +- isis/src/base/objs/GSLUtility/unitTest.cpp | 44 +- .../GaussianDistribution.cpp | 182 +- .../GaussianDistribution.h | 144 +- .../objs/GaussianDistribution/unitTest.cpp | 15 +- .../objs/GaussianStretch/GaussianStretch.cpp | 14 +- .../objs/GaussianStretch/GaussianStretch.h | 90 +- .../base/objs/GaussianStretch/unitTest.cpp | 9 +- .../objs/GradientOperator/GradientOperator.h | 6 +- .../base/objs/GradientOperator/unitTest.cpp | 46 +- .../GridPolygonSeeder/GridPolygonSeeder.cpp | 188 +- .../GridPolygonSeeder/GridPolygonSeeder.h | 66 +- .../base/objs/GridPolygonSeeder/unitTest.cpp | 140 +- isis/src/base/objs/GroundGrid/GroundGrid.h | 2 +- .../GroupedStatistics/GroupedStatistics.cpp | 77 +- .../GroupedStatistics/GroupedStatistics.h | 22 +- .../base/objs/GroupedStatistics/unitTest.cpp | 19 +- isis/src/base/objs/Gruen/Gruen.cpp | 805 ++--- isis/src/base/objs/Gruen/Gruen.h | 281 +- isis/src/base/objs/Gruen/GruenResult.h | 475 +-- isis/src/base/objs/Gruen/unitTest.cpp | 72 +- isis/src/base/objs/Gui/Gui.cpp | 377 ++- isis/src/base/objs/Gui/Gui.h | 92 +- .../src/base/objs/Gui/GuiBooleanParameter.cpp | 54 +- isis/src/base/objs/Gui/GuiBooleanParameter.h | 12 +- isis/src/base/objs/Gui/GuiCubeParameter.cpp | 139 +- isis/src/base/objs/Gui/GuiCubeParameter.h | 72 +- isis/src/base/objs/Gui/GuiDoubleParameter.cpp | 18 +- isis/src/base/objs/Gui/GuiDoubleParameter.h | 12 +- .../base/objs/Gui/GuiFilenameParameter.cpp | 95 +- isis/src/base/objs/Gui/GuiFilenameParameter.h | 76 +- isis/src/base/objs/Gui/GuiHelperAction.cpp | 2 +- isis/src/base/objs/Gui/GuiHelperAction.h | 20 +- isis/src/base/objs/Gui/GuiInputAttribute.cpp | 40 +- isis/src/base/objs/Gui/GuiInputAttribute.h | 18 +- .../src/base/objs/Gui/GuiIntegerParameter.cpp | 18 +- isis/src/base/objs/Gui/GuiIntegerParameter.h | 12 +- isis/src/base/objs/Gui/GuiListParameter.cpp | 38 +- isis/src/base/objs/Gui/GuiListParameter.h | 12 +- isis/src/base/objs/Gui/GuiLog.cpp | 6 +- isis/src/base/objs/Gui/GuiLog.h | 6 +- isis/src/base/objs/Gui/GuiOutputAttribute.cpp | 94 +- isis/src/base/objs/Gui/GuiOutputAttribute.h | 20 +- isis/src/base/objs/Gui/GuiParameter.cpp | 300 +- isis/src/base/objs/Gui/GuiParameter.h | 91 +- .../src/base/objs/Gui/GuiParameterFactory.cpp | 36 +- isis/src/base/objs/Gui/GuiParameterFactory.h | 10 +- isis/src/base/objs/Gui/GuiStringParameter.cpp | 18 +- isis/src/base/objs/Gui/GuiStringParameter.h | 12 +- isis/src/base/objs/Gui/unitTest.cpp | 3 +- isis/src/base/objs/HapkeAtm1/HapkeAtm1.cpp | 156 +- isis/src/base/objs/HapkeAtm1/HapkeAtm1.h | 94 +- isis/src/base/objs/HapkeAtm1/unitTest.cpp | 26 +- isis/src/base/objs/HapkeAtm2/HapkeAtm2.cpp | 226 +- isis/src/base/objs/HapkeAtm2/HapkeAtm2.h | 104 +- isis/src/base/objs/HapkeAtm2/unitTest.cpp | 18 +- isis/src/base/objs/HapkeHen/HapkeHen.cpp | 166 +- isis/src/base/objs/HapkeHen/HapkeHen.h | 100 +- isis/src/base/objs/HapkeHen/unitTest.cpp | 40 +- .../objs/HapkePhotoModel/HapkePhotoModel.cpp | 102 +- .../objs/HapkePhotoModel/HapkePhotoModel.h | 96 +- .../base/objs/HapkePhotoModel/unitTest.cpp | 30 +- isis/src/base/objs/Histogram/Histogram.cpp | 180 +- isis/src/base/objs/Histogram/Histogram.h | 106 +- isis/src/base/objs/Histogram/unitTest.cpp | 175 +- isis/src/base/objs/ID/ID.cpp | 52 +- isis/src/base/objs/ID/ID.h | 38 +- isis/src/base/objs/ID/unitTest.cpp | 28 +- .../src/base/objs/IdealCamera/IdealCamera.cpp | 130 +- isis/src/base/objs/IdealCamera/IdealCamera.h | 6 +- isis/src/base/objs/IdealCamera/unitTest.cpp | 29 +- .../objs/ImageOverlapSet/ImageOverlapSet.cpp | 381 +-- .../objs/ImageOverlapSet/ImageOverlapSet.h | 96 +- .../base/objs/ImageOverlapSet/unitTest.cpp | 158 +- .../objs/InfixToPostfix/InfixToPostfix.cpp | 138 +- .../base/objs/InfixToPostfix/InfixToPostfix.h | 60 +- .../src/base/objs/InfixToPostfix/unitTest.cpp | 5 +- .../InterestOperator/InterestOperator.cpp | 35 +- .../objs/InterestOperator/InterestOperator.h | 2 +- .../objs/InterestOperatorFactory/unitTest.cpp | 2 +- .../base/objs/Interpolator/Interpolator.cpp | 460 +-- .../src/base/objs/Interpolator/Interpolator.h | 148 +- isis/src/base/objs/Interpolator/unitTest.cpp | 53 +- isis/src/base/objs/Isis/Isis.h | 84 +- isis/src/base/objs/Isis/IsisDebug.h | 126 +- isis/src/base/objs/Isis/unitTest.cpp | 18 +- isis/src/base/objs/IsisAml/IsisAml.cpp | 2296 +++++++------- isis/src/base/objs/IsisAml/IsisAml.h | 398 +-- isis/src/base/objs/IsisAml/IsisAmlData.cpp | 194 +- isis/src/base/objs/IsisAml/IsisAmlData.h | 62 +- .../base/objs/IsisAml/IsisXMLApplication.cpp | 218 +- .../base/objs/IsisAml/IsisXMLApplication.h | 106 +- isis/src/base/objs/IsisAml/IsisXMLChTrans.h | 82 +- isis/src/base/objs/IsisAml/IsisXMLGroup.cpp | 170 +- isis/src/base/objs/IsisAml/IsisXMLGroup.h | 90 +- isis/src/base/objs/IsisAml/IsisXMLGroups.cpp | 158 +- isis/src/base/objs/IsisAml/IsisXMLGroups.h | 98 +- isis/src/base/objs/IsisAml/IsisXMLHandler.cpp | 236 +- isis/src/base/objs/IsisAml/IsisXMLHandler.h | 114 +- isis/src/base/objs/IsisAml/IsisXMLHelper.cpp | 198 +- isis/src/base/objs/IsisAml/IsisXMLHelper.h | 90 +- isis/src/base/objs/IsisAml/IsisXMLHelpers.cpp | 158 +- isis/src/base/objs/IsisAml/IsisXMLHelpers.h | 98 +- isis/src/base/objs/IsisAml/IsisXMLHistory.cpp | 164 +- isis/src/base/objs/IsisAml/IsisXMLHistory.h | 84 +- isis/src/base/objs/IsisAml/IsisXMLIgnore.cpp | 106 +- isis/src/base/objs/IsisAml/IsisXMLIgnore.h | 94 +- isis/src/base/objs/IsisAml/IsisXMLList.cpp | 210 +- isis/src/base/objs/IsisAml/IsisXMLList.h | 92 +- .../objs/IsisAml/IsisXMLMultipleValues.cpp | 166 +- .../base/objs/IsisAml/IsisXMLMultipleValues.h | 100 +- .../base/objs/IsisAml/IsisXMLParameter.cpp | 480 +-- isis/src/base/objs/IsisAml/IsisXMLParameter.h | 104 +- isis/src/base/objs/IsisAml/unitTest.cpp | 683 ++-- isis/src/base/objs/Isotropic1/Isotropic1.cpp | 127 +- isis/src/base/objs/Isotropic1/Isotropic1.h | 92 +- isis/src/base/objs/Isotropic1/unitTest.cpp | 28 +- isis/src/base/objs/Isotropic2/Isotropic2.cpp | 185 +- isis/src/base/objs/Isotropic2/Isotropic2.h | 104 +- isis/src/base/objs/Isotropic2/unitTest.cpp | 28 +- isis/src/base/objs/JP2Decoder/JP2Decoder.cpp | 174 +- isis/src/base/objs/JP2Decoder/JP2Decoder.h | 262 +- isis/src/base/objs/JP2Decoder/unitTest.cpp | 6 +- isis/src/base/objs/JP2Encoder/JP2Encoder.cpp | 190 +- isis/src/base/objs/JP2Encoder/JP2Encoder.h | 194 +- isis/src/base/objs/JP2Encoder/unitTest.cpp | 6 +- isis/src/base/objs/JP2Error/JP2Error.cpp | 78 +- isis/src/base/objs/JP2Error/JP2Error.h | 78 +- isis/src/base/objs/JP2Error/unitTest.cpp | 6 +- isis/src/base/objs/Lambert/Lambert.cpp | 11 +- isis/src/base/objs/Lambert/Lambert.h | 44 +- isis/src/base/objs/Lambert/unitTest.cpp | 56 +- .../LambertConformal/LambertConformal.cpp | 298 +- .../objs/LambertConformal/LambertConformal.h | 122 +- .../base/objs/LambertConformal/unitTest.cpp | 76 +- .../base/objs/LeastSquares/LeastSquares.cpp | 516 ++-- .../src/base/objs/LeastSquares/LeastSquares.h | 266 +- isis/src/base/objs/LeastSquares/unitTest.cpp | 202 +- .../LimitPolygonSeeder/LimitPolygonSeeder.cpp | 150 +- .../LimitPolygonSeeder/LimitPolygonSeeder.h | 68 +- .../base/objs/LimitPolygonSeeder/unitTest.cpp | 104 +- .../base/objs/LineEquation/LineEquation.cpp | 78 +- .../src/base/objs/LineEquation/LineEquation.h | 52 +- isis/src/base/objs/LineEquation/unitTest.cpp | 8 +- .../src/base/objs/LineManager/LineManager.cpp | 96 +- isis/src/base/objs/LineManager/LineManager.h | 92 +- isis/src/base/objs/LineManager/unitTest.cpp | 38 +- .../objs/LineScanCamera/LineScanCamera.cpp | 2 +- .../base/objs/LineScanCamera/LineScanCamera.h | 110 +- .../src/base/objs/LineScanCamera/unitTest.cpp | 2 +- .../LineScanCameraDetectorMap.cpp | 66 +- .../LineScanCameraDetectorMap.h | 14 +- .../LineScanCameraDetectorMap/unitTest.cpp | 4 +- .../LineScanCameraGroundMap.h | 2 +- .../LineScanCameraSkyMap.cpp | 86 +- .../LineScanCameraSkyMap.h | 58 +- .../objs/LineScanCameraSkyMap/unitTest.cpp | 4 +- .../objs/LommelSeeliger/LommelSeeliger.cpp | 11 +- .../base/objs/LommelSeeliger/LommelSeeliger.h | 44 +- .../src/base/objs/LommelSeeliger/unitTest.cpp | 56 +- .../LunarAzimuthalEqualArea.cpp | 175 +- .../LunarAzimuthalEqualArea.h | 78 +- .../objs/LunarAzimuthalEqualArea/unitTest.cpp | 68 +- .../base/objs/LunarLambert/LunarLambert.cpp | 27 +- .../src/base/objs/LunarLambert/LunarLambert.h | 84 +- isis/src/base/objs/LunarLambert/unitTest.cpp | 138 +- .../LunarLambertMcEwen/LunarLambertMcEwen.cpp | 23 +- .../LunarLambertMcEwen/LunarLambertMcEwen.h | 68 +- .../base/objs/LunarLambertMcEwen/unitTest.cpp | 32 +- isis/src/base/objs/Matrix/Matrix.cpp | 200 +- isis/src/base/objs/Matrix/Matrix.h | 140 +- isis/src/base/objs/Matrix/unitTest.cpp | 22 +- .../MaximumCorrelation/MaximumCorrelation.cpp | 30 +- .../MaximumCorrelation/MaximumCorrelation.h | 54 +- .../base/objs/MaximumCorrelation/unitTest.cpp | 78 +- isis/src/base/objs/Mercator/Mercator.cpp | 232 +- isis/src/base/objs/Mercator/Mercator.h | 124 +- isis/src/base/objs/Mercator/unitTest.cpp | 60 +- .../objs/Message/ArraySubscriptNotInRange.cpp | 38 +- isis/src/base/objs/Message/FileCreate.cpp | 40 +- isis/src/base/objs/Message/FileOpen.cpp | 40 +- isis/src/base/objs/Message/FileRead.cpp | 40 +- isis/src/base/objs/Message/FileWrite.cpp | 40 +- .../base/objs/Message/KeywordAmbiguous.cpp | 40 +- .../objs/Message/KeywordBlockEndMissing.cpp | 42 +- .../base/objs/Message/KeywordBlockInvalid.cpp | 40 +- .../objs/Message/KeywordBlockStartMissing.cpp | 42 +- .../base/objs/Message/KeywordDuplicated.cpp | 40 +- .../src/base/objs/Message/KeywordNotArray.cpp | 40 +- .../src/base/objs/Message/KeywordNotFound.cpp | 40 +- .../base/objs/Message/KeywordUnrecognized.cpp | 40 +- .../src/base/objs/Message/KeywordValueBad.cpp | 48 +- .../objs/Message/KeywordValueExpected.cpp | 40 +- .../objs/Message/KeywordValueNotInList.cpp | 46 +- .../objs/Message/KeywordValueNotInRange.cpp | 44 +- .../objs/Message/MemoryAllocationFailed.cpp | 2 +- isis/src/base/objs/Message/Message.h | 202 +- .../base/objs/Message/MissingDelimiter.cpp | 12 +- isis/src/base/objs/Message/unitTest.cpp | 84 +- .../MinimumDifference/MinimumDifference.cpp | 98 +- .../MinimumDifference/MinimumDifference.h | 70 +- .../base/objs/MinimumDifference/unitTest.cpp | 80 +- isis/src/base/objs/Minnaert/Minnaert.cpp | 48 +- isis/src/base/objs/Minnaert/Minnaert.h | 104 +- isis/src/base/objs/Minnaert/unitTest.cpp | 156 +- isis/src/base/objs/Mixed/Mixed.cpp | 81 +- isis/src/base/objs/Mixed/Mixed.h | 100 +- isis/src/base/objs/Mixed/unitTest.cpp | 15 +- isis/src/base/objs/MoonAlbedo/MoonAlbedo.cpp | 329 +- isis/src/base/objs/MoonAlbedo/MoonAlbedo.h | 64 +- isis/src/base/objs/MoonAlbedo/unitTest.cpp | 44 +- .../base/objs/MoravecOperator/unitTest.cpp | 62 +- .../MultivariateStatistics.cpp | 300 +- .../MultivariateStatistics.h | 142 +- .../objs/MultivariateStatistics/unitTest.cpp | 13 +- isis/src/base/objs/NaifStatus/NaifStatus.cpp | 30 +- isis/src/base/objs/NaifStatus/NaifStatus.h | 18 +- isis/src/base/objs/NaifStatus/unitTest.cpp | 2 +- .../objs/NoNormalization/NoNormalization.cpp | 13 +- .../objs/NoNormalization/NoNormalization.h | 76 +- .../base/objs/NoNormalization/unitTest.cpp | 30 +- isis/src/base/objs/NoOperator/NoOperator.cpp | 10 +- isis/src/base/objs/NoOperator/NoOperator.h | 50 +- isis/src/base/objs/NoOperator/unitTest.cpp | 62 +- isis/src/base/objs/NormModel/NormModel.cpp | 34 +- isis/src/base/objs/NormModel/NormModel.h | 110 +- isis/src/base/objs/NormModel/unitTest.cpp | 58 +- .../NormModelFactory/NormModelFactory.cpp | 84 +- .../objs/NormModelFactory/NormModelFactory.h | 56 +- .../base/objs/NormModelFactory/unitTest.cpp | 2 +- .../NumericalApproximation.cpp | 2741 +++++++++-------- .../NumericalApproximation.h | 470 +-- .../objs/NumericalApproximation/unitTest.cpp | 598 ++-- .../ObliqueCylindrical/ObliqueCylindrical.cpp | 310 +- .../ObliqueCylindrical/ObliqueCylindrical.h | 118 +- .../base/objs/ObliqueCylindrical/unitTest.cpp | 68 +- .../ObservationNumber/ObservationNumber.cpp | 76 +- .../ObservationNumber/ObservationNumber.h | 94 +- .../base/objs/ObservationNumber/unitTest.cpp | 2 +- .../ObservationNumberList.cpp | 194 +- .../ObservationNumberList.h | 30 +- .../objs/ObservationNumberList/unitTest.cpp | 20 +- .../base/objs/Orthographic/Orthographic.cpp | 270 +- .../src/base/objs/Orthographic/Orthographic.h | 120 +- isis/src/base/objs/Orthographic/unitTest.cpp | 62 +- .../OverlapNormalization.cpp | 370 +-- .../OverlapNormalization.h | 356 +-- .../objs/OverlapNormalization/unitTest.cpp | 30 +- .../OverlapStatistics/OverlapStatistics.cpp | 340 +- .../OverlapStatistics/OverlapStatistics.h | 436 +-- .../base/objs/OverlapStatistics/unitTest.cpp | 18 +- isis/src/base/objs/Parabola/Parabola.cpp | 54 +- isis/src/base/objs/Parabola/Parabola.h | 84 +- isis/src/base/objs/Parabola/unitTest.cpp | 8 +- isis/src/base/objs/PhotoModel/PhotoModel.cpp | 114 +- isis/src/base/objs/PhotoModel/PhotoModel.h | 104 +- isis/src/base/objs/PhotoModel/unitTest.cpp | 60 +- .../PhotoModelFactory/PhotoModelFactory.cpp | 56 +- .../PhotoModelFactory/PhotoModelFactory.h | 58 +- .../base/objs/PhotoModelFactory/unitTest.cpp | 2 +- isis/src/base/objs/Photometry/Photometry.cpp | 33 +- isis/src/base/objs/Photometry/Photometry.h | 64 +- isis/src/base/objs/Photometry/unitTest.cpp | 116 +- isis/src/base/objs/Pipeline/Pipeline.cpp | 232 +- isis/src/base/objs/Pipeline/Pipeline.h | 192 +- .../objs/Pipeline/PipelineApplication.cpp | 186 +- .../base/objs/Pipeline/PipelineApplication.h | 230 +- isis/src/base/objs/Pipeline/unitTest.cpp | 6 +- isis/src/base/objs/Pixel/Pixel.cpp | 200 +- isis/src/base/objs/Pixel/Pixel.h | 234 +- isis/src/base/objs/Pixel/unitTest.cpp | 6 +- isis/src/base/objs/PixelType/PixelType.h | 152 +- isis/src/base/objs/PixelType/unitTest.cpp | 2 +- isis/src/base/objs/Plugin/Plugin.cpp | 42 +- isis/src/base/objs/Plugin/Plugin.h | 128 +- isis/src/base/objs/Plugin/unitTest.cpp | 26 +- .../PointPerspective/PointPerspective.cpp | 274 +- .../objs/PointPerspective/PointPerspective.h | 112 +- .../base/objs/PointPerspective/unitTest.cpp | 64 +- .../PolarStereographic/PolarStereographic.cpp | 274 +- .../PolarStereographic/PolarStereographic.h | 120 +- .../base/objs/PolarStereographic/unitTest.cpp | 70 +- .../base/objs/PolygonSeeder/PolygonSeeder.cpp | 66 +- .../base/objs/PolygonSeeder/PolygonSeeder.h | 60 +- isis/src/base/objs/PolygonSeeder/unitTest.cpp | 6 +- .../PolygonSeederFactory.cpp | 58 +- .../PolygonSeederFactory.h | 58 +- .../objs/PolygonSeederFactory/unitTest.cpp | 2 +- .../base/objs/PolygonTools/PolygonTools.cpp | 874 +++--- .../src/base/objs/PolygonTools/PolygonTools.h | 222 +- isis/src/base/objs/PolygonTools/unitTest.cpp | 206 +- .../PolynomialBivariate.cpp | 78 +- .../PolynomialBivariate/PolynomialBivariate.h | 84 +- .../objs/PolynomialBivariate/unitTest.cpp | 10 +- .../PolynomialUnivariate.cpp | 100 +- .../PolynomialUnivariate.h | 86 +- .../objs/PolynomialUnivariate/unitTest.cpp | 12 +- isis/src/base/objs/Portal/Portal.h | 200 +- isis/src/base/objs/Portal/unitTest.cpp | 54 +- .../PrincipalComponentAnalysis.cpp | 111 +- .../PrincipalComponentAnalysis.h | 82 +- .../PrincipalComponentAnalysis/unitTest.cpp | 35 +- isis/src/base/objs/Process/Process.cpp | 720 ++--- isis/src/base/objs/Process/Process.h | 366 +-- isis/src/base/objs/Process/unitTest.cpp | 130 +- .../objs/ProcessByBoxcar/ProcessByBoxcar.cpp | 144 +- .../objs/ProcessByBoxcar/ProcessByBoxcar.h | 106 +- .../base/objs/ProcessByBoxcar/unitTest.cpp | 70 +- .../objs/ProcessByBrick/ProcessByBrick.cpp | 401 +-- .../base/objs/ProcessByBrick/ProcessByBrick.h | 142 +- .../src/base/objs/ProcessByBrick/unitTest.cpp | 22 +- .../base/objs/ProcessByLine/ProcessByLine.cpp | 242 +- .../base/objs/ProcessByLine/ProcessByLine.h | 164 +- isis/src/base/objs/ProcessByLine/unitTest.cpp | 128 +- .../ProcessByQuickFilter.cpp | 198 +- .../ProcessByQuickFilter.h | 134 +- .../objs/ProcessByQuickFilter/unitTest.cpp | 58 +- .../objs/ProcessBySample/ProcessBySample.cpp | 232 +- .../objs/ProcessBySample/ProcessBySample.h | 82 +- .../base/objs/ProcessBySample/unitTest.cpp | 84 +- .../ProcessBySpectra/ProcessBySpectra.cpp | 207 +- .../objs/ProcessBySpectra/ProcessBySpectra.h | 96 +- .../base/objs/ProcessBySpectra/unitTest.cpp | 58 +- .../base/objs/ProcessByTile/ProcessByTile.cpp | 180 +- .../base/objs/ProcessByTile/ProcessByTile.h | 98 +- isis/src/base/objs/ProcessByTile/unitTest.cpp | 26 +- .../base/objs/ProcessExport/ProcessExport.cpp | 928 +++--- .../base/objs/ProcessExport/ProcessExport.h | 268 +- isis/src/base/objs/ProcessExport/unitTest.cpp | 6 +- .../ProcessExportPds/ProcessExportPds.cpp | 632 ++-- .../objs/ProcessExportPds/ProcessExportPds.h | 124 +- .../base/objs/ProcessExportPds/unitTest.cpp | 6 +- .../ProcessGroundPolygons.cpp | 201 +- .../ProcessGroundPolygons.h | 58 +- .../objs/ProcessGroundPolygons/unitTest.cpp | 134 +- .../base/objs/ProcessImport/ProcessImport.cpp | 2048 ++++++------ .../base/objs/ProcessImport/ProcessImport.h | 538 ++-- isis/src/base/objs/ProcessImport/unitTest.cpp | 50 +- .../ProcessImportPds/ProcessImportPds.cpp | 776 ++--- .../objs/ProcessImportPds/ProcessImportPds.h | 316 +- .../base/objs/ProcessImportPds/unitTest.cpp | 16 +- .../ProcessImportVicar/ProcessImportVicar.cpp | 130 +- .../ProcessImportVicar/ProcessImportVicar.h | 102 +- .../base/objs/ProcessImportVicar/unitTest.cpp | 6 +- .../objs/ProcessPolygons/ProcessPolygons.cpp | 275 +- .../objs/ProcessPolygons/ProcessPolygons.h | 54 +- .../base/objs/ProcessPolygons/unitTest.cpp | 52 +- .../ProcessRubberSheet/ProcessRubberSheet.cpp | 1290 ++++---- .../ProcessRubberSheet/ProcessRubberSheet.h | 194 +- .../base/objs/ProcessRubberSheet/unitTest.cpp | 46 +- isis/src/base/objs/Progress/Progress.cpp | 180 +- isis/src/base/objs/Progress/Progress.h | 104 +- isis/src/base/objs/Progress/unitTest.cpp | 16 +- isis/src/base/objs/Projection/Projection.cpp | 1168 +++---- isis/src/base/objs/Projection/Projection.h | 530 ++-- isis/src/base/objs/Projection/unitTest.cpp | 134 +- .../ProjectionFactory/ProjectionFactory.cpp | 456 +-- .../ProjectionFactory/ProjectionFactory.h | 106 +- .../base/objs/ProjectionFactory/unitTest.cpp | 186 +- .../objs/PushFrameCamera/PushFrameCamera.cpp | 2 +- .../objs/PushFrameCamera/PushFrameCamera.h | 94 +- .../base/objs/PushFrameCamera/unitTest.cpp | 2 +- .../PushFrameCameraDetectorMap.cpp | 18 +- .../PushFrameCameraDetectorMap.h | 419 +-- .../PushFrameCameraDetectorMap/unitTest.cpp | 2 +- .../PushFrameCameraGroundMap.cpp | 42 +- .../PushFrameCameraGroundMap.h | 62 +- .../PushFrameCameraGroundMap/unitTest.cpp | 2 +- .../base/objs/PvlContainer/PvlContainer.cpp | 220 +- .../src/base/objs/PvlContainer/PvlContainer.h | 256 +- isis/src/base/objs/PvlContainer/unitTest.cpp | 6 +- .../base/objs/PvlEditDialog/PvlEditDialog.cpp | 158 +- .../base/objs/PvlEditDialog/PvlEditDialog.h | 18 +- isis/src/base/objs/PvlEditDialog/unitTest.cpp | 4 +- isis/src/base/objs/PvlFormat/PvlFormat.cpp | 100 +- isis/src/base/objs/PvlFormat/PvlFormat.h | 183 +- isis/src/base/objs/PvlFormat/unitTest.cpp | 32 +- .../base/objs/PvlFormatPds/PvlFormatPds.cpp | 241 +- .../src/base/objs/PvlFormatPds/PvlFormatPds.h | 106 +- isis/src/base/objs/PvlFormatPds/unitTest.cpp | 309 +- isis/src/base/objs/PvlObject/PvlObject.cpp | 528 ++-- isis/src/base/objs/PvlObject/PvlObject.h | 182 +- isis/src/base/objs/PvlObject/unitTest.cpp | 50 +- .../src/base/objs/PvlSequence/PvlSequence.cpp | 106 +- isis/src/base/objs/PvlSequence/PvlSequence.h | 116 +- isis/src/base/objs/PvlSequence/unitTest.cpp | 8 +- isis/src/base/objs/PvlToken/PvlToken.cpp | 186 +- isis/src/base/objs/PvlToken/PvlToken.h | 96 +- isis/src/base/objs/PvlToken/unitTest.cpp | 47 +- .../base/objs/PvlTokenizer/PvlTokenizer.cpp | 553 ++-- .../src/base/objs/PvlTokenizer/PvlTokenizer.h | 180 +- isis/src/base/objs/PvlTokenizer/unitTest.cpp | 62 +- .../PvlTranslationManager.cpp | 290 +- .../PvlTranslationManager.h | 152 +- .../objs/PvlTranslationManager/unitTest.cpp | 36 +- .../PvlTranslationTable.cpp | 406 +-- .../PvlTranslationTable/PvlTranslationTable.h | 246 +- .../objs/PvlTranslationTable/unitTest.cpp | 70 +- isis/src/base/objs/Quaternion/Quaternion.cpp | 176 +- isis/src/base/objs/Quaternion/Quaternion.h | 126 +- isis/src/base/objs/Quaternion/unitTest.cpp | 92 +- .../src/base/objs/QuickFilter/QuickFilter.cpp | 496 +-- isis/src/base/objs/QuickFilter/QuickFilter.h | 272 +- isis/src/base/objs/QuickFilter/unitTest.cpp | 91 +- .../src/base/objs/RadarCamera/RadarCamera.cpp | 2 +- isis/src/base/objs/RadarCamera/RadarCamera.h | 68 +- isis/src/base/objs/RadarCamera/unitTest.cpp | 2 +- .../objs/RadarGroundMap/RadarGroundMap.cpp | 230 +- .../base/objs/RadarGroundMap/RadarGroundMap.h | 38 +- .../src/base/objs/RadarGroundMap/unitTest.cpp | 2 +- .../RadarGroundRangeMap.cpp | 10 +- .../RadarGroundRangeMap/RadarGroundRangeMap.h | 6 +- .../objs/RadarGroundRangeMap/unitTest.cpp | 2 +- .../base/objs/RadarPulseMap/RadarPulseMap.cpp | 4 +- .../base/objs/RadarPulseMap/RadarPulseMap.h | 14 +- isis/src/base/objs/RadarPulseMap/unitTest.cpp | 2 +- .../src/base/objs/RadarSkyMap/RadarSkyMap.cpp | 2 +- isis/src/base/objs/RadarSkyMap/unitTest.cpp | 2 +- .../RadarSlantRangeMap/RadarSlantRangeMap.cpp | 90 +- .../RadarSlantRangeMap/RadarSlantRangeMap.h | 8 +- .../base/objs/RadarSlantRangeMap/unitTest.cpp | 2 +- .../RadialDistortionMap.cpp | 35 +- .../RadialDistortionMap/RadialDistortionMap.h | 10 +- .../ReseauDistortionMap.cpp | 248 +- .../ReseauDistortionMap/ReseauDistortionMap.h | 64 +- .../base/objs/SampleManager/SampleManager.cpp | 96 +- .../base/objs/SampleManager/SampleManager.h | 80 +- isis/src/base/objs/SampleManager/unitTest.cpp | 38 +- .../base/objs/SerialNumber/SerialNumber.cpp | 88 +- .../src/base/objs/SerialNumber/SerialNumber.h | 150 +- isis/src/base/objs/SerialNumber/unitTest.cpp | 4 +- .../SerialNumberList/SerialNumberList.cpp | 166 +- .../objs/SerialNumberList/SerialNumberList.h | 116 +- .../base/objs/SerialNumberList/unitTest.cpp | 14 +- isis/src/base/objs/SessionLog/SessionLog.cpp | 70 +- isis/src/base/objs/SessionLog/SessionLog.h | 60 +- isis/src/base/objs/SessionLog/unitTest.cpp | 32 +- isis/src/base/objs/Shade/Shade.cpp | 55 +- isis/src/base/objs/Shade/Shade.h | 50 +- isis/src/base/objs/Shade/unitTest.cpp | 14 +- isis/src/base/objs/ShadeAtm/ShadeAtm.cpp | 81 +- isis/src/base/objs/ShadeAtm/ShadeAtm.h | 50 +- isis/src/base/objs/ShadeAtm/unitTest.cpp | 26 +- .../SimpleCylindrical/SimpleCylindrical.cpp | 178 +- .../SimpleCylindrical/SimpleCylindrical.h | 120 +- .../base/objs/SimpleCylindrical/unitTest.cpp | 56 +- isis/src/base/objs/Sinusoidal/Sinusoidal.cpp | 222 +- isis/src/base/objs/Sinusoidal/Sinusoidal.h | 116 +- isis/src/base/objs/Sinusoidal/unitTest.cpp | 58 +- .../src/base/objs/SpecialPixel/SpecialPixel.h | 316 +- isis/src/base/objs/SpecialPixel/unitTest.cpp | 92 +- isis/src/base/objs/Spice/Spice.cpp | 654 ++-- isis/src/base/objs/Spice/Spice.h | 348 ++- isis/src/base/objs/Spice/unitTest.cpp | 86 +- .../base/objs/SpicePosition/SpicePosition.cpp | 570 ++-- .../base/objs/SpicePosition/SpicePosition.h | 70 +- isis/src/base/objs/SpicePosition/unitTest.cpp | 20 +- .../base/objs/SpiceRotation/SpiceRotation.cpp | 987 +++--- .../base/objs/SpiceRotation/SpiceRotation.h | 185 +- isis/src/base/objs/SpiceRotation/ck3sdn.cpp | 873 +++--- isis/src/base/objs/SpiceRotation/qmini.cpp | 386 +-- isis/src/base/objs/SpiceRotation/unitTest.cpp | 186 +- .../StandardDeviationOperator.h | 4 +- .../StandardDeviationOperator/unitTest.cpp | 62 +- isis/src/base/objs/Statistics/Statistics.cpp | 159 +- isis/src/base/objs/Statistics/Statistics.h | 235 +- isis/src/base/objs/Statistics/unitTest.cpp | 41 +- isis/src/base/objs/Stretch/Stretch.cpp | 286 +- isis/src/base/objs/Stretch/Stretch.h | 262 +- isis/src/base/objs/Stretch/unitTest.cpp | 80 +- .../StripPolygonSeeder/StripPolygonSeeder.cpp | 122 +- .../StripPolygonSeeder/StripPolygonSeeder.h | 62 +- .../base/objs/StripPolygonSeeder/unitTest.cpp | 104 +- isis/src/base/objs/SubArea/SubArea.cpp | 212 +- isis/src/base/objs/SubArea/SubArea.h | 88 +- isis/src/base/objs/SubArea/unitTest.cpp | 452 +-- .../base/objs/SurfaceModel/SurfaceModel.cpp | 64 +- .../src/base/objs/SurfaceModel/SurfaceModel.h | 76 +- isis/src/base/objs/SurfaceModel/unitTest.cpp | 64 +- isis/src/base/objs/System/System.cpp | 218 +- isis/src/base/objs/System/System.h | 70 +- isis/src/base/objs/System/unitTest.cpp | 8 +- isis/src/base/objs/TableField/TableField.cpp | 468 +-- isis/src/base/objs/TableField/TableField.h | 158 +- isis/src/base/objs/TableField/unitTest.cpp | 129 +- .../src/base/objs/TableRecord/TableRecord.cpp | 186 +- isis/src/base/objs/TableRecord/TableRecord.h | 106 +- isis/src/base/objs/TableRecord/unitTest.cpp | 24 +- isis/src/base/objs/TextFile/TextFile.cpp | 868 +++--- isis/src/base/objs/TextFile/TextFile.h | 150 +- isis/src/base/objs/TextFile/unitTest.cpp | 324 +- .../src/base/objs/TileManager/TileManager.cpp | 114 +- isis/src/base/objs/TileManager/TileManager.h | 112 +- isis/src/base/objs/TileManager/unitTest.cpp | 18 +- isis/src/base/objs/Topo/Topo.cpp | 73 +- isis/src/base/objs/Topo/Topo.h | 70 +- isis/src/base/objs/Topo/unitTest.cpp | 26 +- isis/src/base/objs/TopoAtm/TopoAtm.cpp | 91 +- isis/src/base/objs/TopoAtm/TopoAtm.h | 50 +- isis/src/base/objs/TopoAtm/unitTest.cpp | 20 +- isis/src/base/objs/Transform/Transform.h | 238 +- isis/src/base/objs/Transform/unitTest.cpp | 5 +- .../TransverseMercator/TransverseMercator.cpp | 358 +-- .../TransverseMercator/TransverseMercator.h | 110 +- .../base/objs/TransverseMercator/unitTest.cpp | 100 +- .../UniversalGroundMap/UniversalGroundMap.cpp | 173 +- .../UniversalGroundMap/UniversalGroundMap.h | 122 +- .../base/objs/UniversalGroundMap/unitTest.cpp | 26 +- .../VariableLineScanCameraDetectorMap.cpp | 80 +- .../VariableLineScanCameraDetectorMap.h | 22 +- .../unitTest.cpp | 4 +- isis/src/base/objs/VecFilter/VecFilter.cpp | 58 +- isis/src/base/objs/VecFilter/VecFilter.h | 34 +- isis/src/base/objs/VecFilter/unitTest.cpp | 36 +- isis/src/base/objs/WorldMapper/WorldMapper.h | 208 +- isis/src/base/objs/WorldMapper/unitTest.cpp | 22 +- isis/src/base/objs/iException/iException.cpp | 134 +- isis/src/base/objs/iException/iException.h | 72 +- isis/src/base/objs/iException/unitTest.cpp | 32 +- isis/src/base/objs/iString/iString.cpp | 659 ++-- isis/src/base/objs/iString/iString.h | 388 +-- isis/src/base/objs/iString/unitTest.cpp | 112 +- isis/src/base/objs/iTime/iTime.cpp | 538 ++-- isis/src/base/objs/iTime/iTime.h | 176 +- isis/src/base/objs/iTime/unitTest.cpp | 84 +- isis/src/cassini/apps/ciss2isis/ciss2isis.cpp | 225 +- isis/src/cassini/apps/cisscal/DarkCurrent.cpp | 1410 +++++---- isis/src/cassini/apps/cisscal/DarkCurrent.h | 128 +- isis/src/cassini/apps/cisscal/cisscal.cpp | 1054 ++++--- isis/src/cassini/apps/vims2isis/vims2isis.cpp | 250 +- isis/src/cassini/apps/vims2map/vims2map.cpp | 191 +- isis/src/cassini/apps/vims2map/vims2map.h | 10 +- isis/src/cassini/apps/vimscal/vimscal.cpp | 186 +- .../cassini/objs/CissLabels/CissLabels.cpp | 158 +- isis/src/cassini/objs/CissLabels/CissLabels.h | 362 ++- isis/src/cassini/objs/CissLabels/unitTest.cpp | 6 +- .../cassini/objs/CisscalFile/CisscalFile.cpp | 188 +- .../cassini/objs/CisscalFile/CisscalFile.h | 60 +- .../src/cassini/objs/CisscalFile/unitTest.cpp | 46 +- .../cassini/objs/IssNACamera/IssNACamera.cpp | 30 +- .../cassini/objs/IssNACamera/IssNACamera.h | 8 +- .../src/cassini/objs/IssNACamera/unitTest.cpp | 21 +- .../cassini/objs/IssWACamera/IssWACamera.cpp | 32 +- .../cassini/objs/IssWACamera/IssWACamera.h | 8 +- .../src/cassini/objs/IssWACamera/unitTest.cpp | 21 +- .../cassini/objs/VimsCamera/VimsCamera.cpp | 96 +- isis/src/cassini/objs/VimsCamera/VimsCamera.h | 60 +- .../cassini/objs/VimsCamera/VimsGroundMap.cpp | 246 +- .../cassini/objs/VimsCamera/VimsGroundMap.h | 136 +- .../cassini/objs/VimsCamera/VimsSkyMap.cpp | 244 +- isis/src/cassini/objs/VimsCamera/VimsSkyMap.h | 112 +- isis/src/cassini/objs/VimsCamera/unitTest.cpp | 86 +- .../src/clementine/apps/clem2isis/bitstrm.cpp | 237 +- .../clementine/apps/clem2isis/clem2isis.cpp | 86 +- isis/src/clementine/apps/clem2isis/decomp.cpp | 1512 ++++----- .../src/clementine/apps/clem2isis/huffman.cpp | 266 +- isis/src/clementine/apps/clem2isis/jpeg_c.h | 32 +- isis/src/clementine/apps/clem2isis/pds.cpp | 833 ++--- isis/src/clementine/apps/clem2isis/pds.h | 16 +- .../apps/clemhirescal/clemhirescal.cpp | 50 +- .../clementine/apps/clemnircal/clemnircal.cpp | 105 +- .../apps/clemnirclean/clemnirclean.cpp | 44 +- .../apps/clemnirnoise/clemnirnoise.cpp | 40 +- .../apps/clemuvviscal/clemuvviscal.cpp | 132 +- .../objs/HiresCamera/HiresCamera.cpp | 28 +- .../clementine/objs/HiresCamera/HiresCamera.h | 8 +- .../clementine/objs/HiresCamera/unitTest.cpp | 17 +- .../clementine/objs/LwirCamera/LwirCamera.cpp | 32 +- .../clementine/objs/LwirCamera/LwirCamera.h | 12 +- .../clementine/objs/LwirCamera/unitTest.cpp | 17 +- .../clementine/objs/NirCamera/NirCamera.cpp | 32 +- .../src/clementine/objs/NirCamera/NirCamera.h | 8 +- .../clementine/objs/NirCamera/unitTest.cpp | 17 +- .../objs/UvvisCamera/UvvisCamera.cpp | 16 +- .../clementine/objs/UvvisCamera/UvvisCamera.h | 12 +- .../clementine/objs/UvvisCamera/unitTest.cpp | 17 +- isis/src/database/objs/Database/Database.cpp | 1000 +++--- isis/src/database/objs/Database/Database.h | 146 +- isis/src/database/objs/Database/unitTest.cpp | 6 +- .../objs/DatabaseFactory/DatabaseFactory.cpp | 1005 +++--- .../objs/DatabaseFactory/DatabaseFactory.h | 512 +-- .../objs/DatabaseFactory/unitTest.cpp | 28 +- isis/src/database/objs/DbAccess/DbAccess.cpp | 354 +-- isis/src/database/objs/DbAccess/DbAccess.h | 90 +- isis/src/database/objs/DbAccess/unitTest.cpp | 2 +- .../src/database/objs/DbProfile/DbProfile.cpp | 367 +-- isis/src/database/objs/DbProfile/DbProfile.h | 184 +- isis/src/database/objs/DbProfile/unitTest.cpp | 5 +- isis/src/database/objs/SqlQuery/SqlQuery.cpp | 514 ++-- isis/src/database/objs/SqlQuery/SqlQuery.h | 286 +- isis/src/database/objs/SqlQuery/unitTest.cpp | 8 +- .../src/database/objs/SqlRecord/SqlRecord.cpp | 354 +-- isis/src/database/objs/SqlRecord/SqlRecord.h | 92 +- isis/src/database/objs/SqlRecord/unitTest.cpp | 18 +- .../src/dawn/apps/dawnfc2isis/dawnfc2isis.cpp | 119 +- .../dawn/objs/DawnFcCamera/DawnFcCamera.cpp | 24 +- .../src/dawn/objs/DawnFcCamera/DawnFcCamera.h | 8 +- isis/src/dawn/objs/DawnFcCamera/unitTest.cpp | 17 +- .../documents/DocStyle/assets/Statistics.cpp | 138 +- .../documents/DocStyle/assets/Statistics.h | 130 +- .../galileo/apps/gllssi2isis/gllssi2isis.cpp | 94 +- isis/src/galileo/apps/gllssical/gllssical.cpp | 86 +- isis/src/galileo/objs/SsiCamera/SsiCamera.cpp | 26 +- isis/src/galileo/objs/SsiCamera/SsiCamera.h | 8 +- isis/src/galileo/objs/SsiCamera/unitTest.cpp | 17 +- isis/src/lo/apps/lo2isis/lo2isis.cpp | 95 +- isis/src/lo/apps/lopdsgen/lopdsgen.cpp | 146 +- .../LoCameraFiducialMap.cpp | 36 +- .../LoCameraFiducialMap/LoCameraFiducialMap.h | 74 +- .../lo/objs/LoCameraFiducialMap/unitTest.cpp | 55 +- .../src/lo/objs/LoHighCamera/LoHighCamera.cpp | 24 +- isis/src/lo/objs/LoHighCamera/LoHighCamera.h | 8 +- .../objs/LoHighCamera/LoHighDistortionMap.cpp | 204 +- .../objs/LoHighCamera/LoHighDistortionMap.h | 28 +- isis/src/lo/objs/LoHighCamera/unitTest.cpp | 17 +- .../lo/objs/LoMediumCamera/LoMediumCamera.cpp | 34 +- .../lo/objs/LoMediumCamera/LoMediumCamera.h | 12 +- .../LoMediumCamera/LoMediumDistortionMap.cpp | 202 +- .../LoMediumCamera/LoMediumDistortionMap.h | 30 +- isis/src/lo/objs/LoMediumCamera/unitTest.cpp | 17 +- isis/src/local/apps/basemapmos/basemapmos.cpp | 124 +- isis/src/local/apps/camcoeffs/camcoeffs.cpp | 60 +- isis/src/local/apps/camtest/camtest.cpp | 10 +- .../local/apps/cissua2isis/cissua2isis.cpp | 131 +- isis/src/local/apps/demwrap/demwrap.cpp | 22 +- isis/src/local/apps/polytool/polytool.cpp | 68 +- isis/src/local/apps/qmos/qmos.cpp | 39 +- isis/src/lro/apps/lronac2isis/lronac2isis.cpp | 390 +-- isis/src/lro/apps/lronac2pds/lronac2pds.cpp | 376 +-- isis/src/lro/apps/lronac2pds/md5.cpp | 363 ++- isis/src/lro/apps/lronac2pds/md5.h | 52 +- isis/src/lro/apps/lronac2pds/md5wrapper.cpp | 143 +- isis/src/lro/apps/lronac2pds/md5wrapper.h | 69 +- isis/src/lro/apps/lronaccal/lronaccal.cpp | 768 ++--- isis/src/lro/apps/lrowac2isis/lrowac2isis.cpp | 220 +- isis/src/lro/apps/lrowac2pds/lrowac2pds.cpp | 656 ++-- isis/src/lro/apps/lrowac2pds/md5.cpp | 363 ++- isis/src/lro/apps/lrowac2pds/md5.h | 52 +- isis/src/lro/apps/lrowac2pds/md5wrapper.cpp | 143 +- isis/src/lro/apps/lrowac2pds/md5wrapper.h | 69 +- isis/src/lro/apps/lrowaccal/lrowaccal.cpp | 516 ++-- isis/src/lro/apps/lrowacpho/Exponential.cpp | 466 +-- isis/src/lro/apps/lrowacpho/Exponential.h | 116 +- isis/src/lro/apps/lrowacpho/Hillier.cpp | 478 +-- isis/src/lro/apps/lrowacpho/Hillier.h | 18 +- .../apps/lrowacpho/PhotometricFunction.cpp | 86 +- .../lro/apps/lrowacpho/PhotometricFunction.h | 274 +- isis/src/lro/apps/lrowacpho/lrowacpho.cpp | 118 +- isis/src/lro/apps/mrf2isis/mrf2isis.cpp | 95 +- .../LroNarrowAngleCamera.cpp | 20 +- .../LroNarrowAngleCamera.h | 4 +- .../LroNarrowAngleDistortionMap.cpp | 18 +- .../LroNarrowAngleDistortionMap.h | 18 +- .../objs/LroNarrowAngleCamera/unitTest.cpp | 15 +- .../LroWideAngleCamera/LroWideAngleCamera.cpp | 118 +- .../LroWideAngleCamera/LroWideAngleCamera.h | 58 +- .../LroWideAngleCameraDistortionMap.cpp | 28 +- .../LroWideAngleCameraDistortionMap.h | 28 +- .../lro/objs/LroWideAngleCamera/unitTest.cpp | 22 +- isis/src/lro/objs/MiniRF/MiniRF.cpp | 64 +- isis/src/lro/objs/MiniRF/MiniRF.h | 6 +- isis/src/lro/objs/MiniRF/unitTest.cpp | 17 +- .../mariner/apps/mar102isis/mar102isis.cpp | 240 +- .../mariner/apps/mar10clean/mar10clean.cpp | 4 +- .../apps/mar10nonoise/mar10nonoise.cpp | 16 +- .../apps/mar10restore/mar10restore.cpp | 12 +- isis/src/mer/apps/mer2isis/mer2isis.cpp | 58 +- isis/src/mer/apps/mical/MiCalibration.cpp | 40 +- isis/src/mer/apps/mical/MiCalibration.h | 184 +- isis/src/mer/apps/mical/mical.cpp | 138 +- .../messenger/apps/mdis2isis/mdis2isis.cpp | 306 +- isis/src/messenger/apps/mdis2pds/mdis2pds.cpp | 205 +- .../messenger/apps/mdiscal/DarkModelPixel.h | 230 +- .../src/messenger/apps/mdiscal/MdisCalUtils.h | 388 +-- isis/src/messenger/apps/mdiscal/mdiscal.cpp | 169 +- isis/src/messenger/apps/mdisddr/Kernels.cpp | 178 +- isis/src/messenger/apps/mdisddr/Kernels.h | 218 +- isis/src/messenger/apps/mdisddr/mdisddr.cpp | 220 +- .../messenger/apps/mdisedrinfo/MdisEdrKeys.h | 191 +- .../apps/mdisedrinfo/MdisGeometry.cpp | 428 +-- .../messenger/apps/mdisedrinfo/MdisGeometry.h | 154 +- .../apps/mdisedrinfo/SpiceManager.cpp | 178 +- .../messenger/apps/mdisedrinfo/SpiceManager.h | 66 +- .../apps/mdisedrinfo/mdisedrinfo.cpp | 77 +- isis/src/messenger/apps/mdisproc/mdisproc.cpp | 46 +- .../messenger/objs/MdisCamera/MdisCamera.cpp | 87 +- .../messenger/objs/MdisCamera/MdisCamera.h | 50 +- .../MdisCamera/TaylorCameraDistortionMap.cpp | 192 +- .../MdisCamera/TaylorCameraDistortionMap.h | 106 +- .../messenger/objs/MdisCamera/unitTest.cpp | 17 +- isis/src/mex/objs/HrscCamera/HrscCamera.cpp | 58 +- isis/src/mex/objs/HrscCamera/HrscCamera.h | 76 +- isis/src/mex/objs/HrscCamera/unitTest.cpp | 21 +- isis/src/mgs/apps/moc2isis/moc2isis.cpp | 241 +- isis/src/mgs/apps/moccal/moccal.cpp | 170 +- isis/src/mgs/apps/mocevenodd/mocevenodd.cpp | 48 +- isis/src/mgs/apps/mocgap/mocgap.cpp | 34 +- isis/src/mgs/apps/mocnoise50/mocnoise50.cpp | 168 +- isis/src/mgs/apps/mocproc/mocproc.cpp | 22 +- isis/src/mgs/apps/mocuncompress/CheckSum.c | 750 ++--- isis/src/mgs/apps/mocuncompress/CheckSum.h | 6 +- isis/src/mgs/apps/mocuncompress/array.c | 90 +- isis/src/mgs/apps/mocuncompress/array.h | 14 +- isis/src/mgs/apps/mocuncompress/bitsOut.h | 12 +- isis/src/mgs/apps/mocuncompress/decompNONE.c | 275 +- isis/src/mgs/apps/mocuncompress/decompNONE.h | 6 +- isis/src/mgs/apps/mocuncompress/decompSYNC.c | 184 +- isis/src/mgs/apps/mocuncompress/decompSYNC.h | 6 +- isis/src/mgs/apps/mocuncompress/decompXPRED.c | 307 +- isis/src/mgs/apps/mocuncompress/decompXPRED.h | 6 +- .../mgs/apps/mocuncompress/decompXPREDYPRED.c | 323 +- .../mgs/apps/mocuncompress/decompXPREDYPRED.h | 6 +- isis/src/mgs/apps/mocuncompress/decompYPRED.c | 299 +- isis/src/mgs/apps/mocuncompress/decompYPRED.h | 6 +- .../apps/mocuncompress/encodeCoefs.static.h | 864 +++--- isis/src/mgs/apps/mocuncompress/findsync.c | 42 +- isis/src/mgs/apps/mocuncompress/fs.h | 6 +- isis/src/mgs/apps/mocuncompress/getdecode.c | 268 +- isis/src/mgs/apps/mocuncompress/header.c | 152 +- isis/src/mgs/apps/mocuncompress/image_io.c | 164 +- isis/src/mgs/apps/mocuncompress/image_io.h | 14 +- isis/src/mgs/apps/mocuncompress/initBlock.c | 238 +- isis/src/mgs/apps/mocuncompress/initBlock.h | 14 +- .../src/mgs/apps/mocuncompress/invFdct16x16.c | 400 +-- .../src/mgs/apps/mocuncompress/invFdct16x16.h | 6 +- .../src/mgs/apps/mocuncompress/invFwht16x16.c | 307 +- .../src/mgs/apps/mocuncompress/invFwht16x16.h | 6 +- isis/src/mgs/apps/mocuncompress/limits.h | 6 +- isis/src/mgs/apps/mocuncompress/msdp.h | 45 +- isis/src/mgs/apps/mocuncompress/nextValue.c | 201 +- isis/src/mgs/apps/mocuncompress/nextValue.h | 6 +- isis/src/mgs/apps/mocuncompress/pmain.c | 44 +- .../mgs/apps/mocuncompress/predCompCommon.h | 6 +- .../mgs/apps/mocuncompress/predDecompCommon.h | 6 +- isis/src/mgs/apps/mocuncompress/predcode.h | 847 ++--- .../mocuncompress/predictiveDecompressor.c | 159 +- .../mocuncompress/predictiveDecompressor.h | 6 +- isis/src/mgs/apps/mocuncompress/readBits.c | 165 +- isis/src/mgs/apps/mocuncompress/readBits.h | 20 +- isis/src/mgs/apps/mocuncompress/readBlock.c | 88 +- isis/src/mgs/apps/mocuncompress/readBlock.h | 6 +- isis/src/mgs/apps/mocuncompress/readCoef.c | 53 +- isis/src/mgs/apps/mocuncompress/readCoef.h | 6 +- isis/src/mgs/apps/mocuncompress/readGroups.c | 34 +- isis/src/mgs/apps/mocuncompress/readGroups.h | 6 +- isis/src/mgs/apps/mocuncompress/readmocisis.c | 258 +- isis/src/mgs/apps/mocuncompress/reorder.c | 99 +- isis/src/mgs/apps/mocuncompress/reorder.h | 6 +- .../mgs/apps/mocuncompress/reorder.static.h | 68 +- isis/src/mgs/apps/mocuncompress/types.h | 26 +- isis/src/mgs/apps/mocuncompress/xmain.c | 199 +- isis/src/mgs/objs/MocLabels/MocLabels.cpp | 332 +- isis/src/mgs/objs/MocLabels/MocLabels.h | 150 +- isis/src/mgs/objs/MocLabels/mocxtrack.h | 6 +- isis/src/mgs/objs/MocLabels/unitTest.cpp | 4 +- .../MocNarrowAngleCamera.cpp | 16 +- .../MocNarrowAngleCamera.h | 4 +- .../objs/MocNarrowAngleCamera/unitTest.cpp | 19 +- .../MocNarrowAngleSumming.h | 20 +- .../objs/MocNarrowAngleSumming/unitTest.cpp | 8 +- .../MocWideAngleCamera/MocWideAngleCamera.cpp | 32 +- .../MocWideAngleCamera/MocWideAngleCamera.h | 14 +- .../MocWideAngleDetectorMap.cpp | 40 +- .../MocWideAngleDetectorMap.h | 28 +- .../MocWideAngleDistortionMap.cpp | 34 +- .../MocWideAngleDistortionMap.h | 24 +- .../mgs/objs/MocWideAngleCamera/unitTest.cpp | 23 +- isis/src/mro/apps/crism2isis/crism2isis.cpp | 59 +- isis/src/mro/apps/ctxcal/ctxcal.cpp | 94 +- isis/src/mro/apps/ctxevenodd/ctxevenodd.cpp | 54 +- isis/src/mro/apps/hi2isis/hi2isis.cpp | 217 +- isis/src/mro/apps/hi2isis/hiAncillary.cpp | 18 +- isis/src/mro/apps/hi2isis/hiCalibration.cpp | 62 +- isis/src/mro/apps/hical/Component.h | 110 +- isis/src/mro/apps/hical/DarkSubtractComp.h | 114 +- isis/src/mro/apps/hical/DriftBuffer.h | 84 +- isis/src/mro/apps/hical/DriftCorrect.cpp | 174 +- isis/src/mro/apps/hical/DriftCorrect.h | 276 +- isis/src/mro/apps/hical/FlatFieldComp.h | 66 +- isis/src/mro/apps/hical/GainVLineComp.h | 84 +- isis/src/mro/apps/hical/HiBlob.h | 88 +- isis/src/mro/apps/hical/HiCalConf.cpp | 552 ++-- isis/src/mro/apps/hical/HiCalConf.h | 84 +- isis/src/mro/apps/hical/HiCalData.h | 120 +- isis/src/mro/apps/hical/HiCalTypes.h | 116 +- isis/src/mro/apps/hical/HiCalUtil.h | 822 ++--- isis/src/mro/apps/hical/LowPassFilterComp.h | 72 +- isis/src/mro/apps/hical/NonLinearLSQ.cpp | 307 +- isis/src/mro/apps/hical/NonLinearLSQ.h | 112 +- isis/src/mro/apps/hical/OffsetCorrect.h | 188 +- isis/src/mro/apps/hical/SplineFillComp.h | 72 +- isis/src/mro/apps/hical/TempGainCorrect.h | 80 +- isis/src/mro/apps/hical/hical.cpp | 166 +- isis/src/mro/apps/hicalbeta/Component.h | 110 +- .../src/mro/apps/hicalbeta/DarkSubtractComp.h | 114 +- isis/src/mro/apps/hicalbeta/DriftBuffer.h | 84 +- isis/src/mro/apps/hicalbeta/DriftCorrect.cpp | 174 +- isis/src/mro/apps/hicalbeta/DriftCorrect.h | 276 +- isis/src/mro/apps/hicalbeta/FlatFieldComp.h | 66 +- isis/src/mro/apps/hicalbeta/GainVLineComp.h | 84 +- isis/src/mro/apps/hicalbeta/HiBlob.h | 88 +- isis/src/mro/apps/hicalbeta/HiCalConf.cpp | 552 ++-- isis/src/mro/apps/hicalbeta/HiCalConf.h | 84 +- isis/src/mro/apps/hicalbeta/HiCalData.h | 120 +- isis/src/mro/apps/hicalbeta/HiCalTypes.h | 116 +- isis/src/mro/apps/hicalbeta/HiCalUtil.h | 822 ++--- .../mro/apps/hicalbeta/LowPassFilterComp.h | 72 +- isis/src/mro/apps/hicalbeta/NonLinearLSQ.cpp | 307 +- isis/src/mro/apps/hicalbeta/NonLinearLSQ.h | 112 +- isis/src/mro/apps/hicalbeta/OffsetCorrect.h | 188 +- isis/src/mro/apps/hicalbeta/SplineFillComp.h | 72 +- isis/src/mro/apps/hicalbeta/TempGainCorrect.h | 80 +- isis/src/mro/apps/hicalbeta/hicalbeta.cpp | 166 +- isis/src/mro/apps/hiccdstitch/hiccdstitch.cpp | 300 +- .../apps/hiccdstitch/template/genTemplate.cpp | 45 +- isis/src/mro/apps/hicolormos/hicolormos.cpp | 140 +- isis/src/mro/apps/hicubeit/hicubeit.cpp | 70 +- isis/src/mro/apps/hicubenorm/hicubenorm.cpp | 258 +- isis/src/mro/apps/hidestripe/hidestripe.cpp | 284 +- isis/src/mro/apps/hiequal/hiequal.cpp | 188 +- isis/src/mro/apps/hifringe/hifringe.cpp | 196 +- isis/src/mro/apps/hifurrows/hifurrows.cpp | 48 +- isis/src/mro/apps/higlob/higlob.cpp | 48 +- isis/src/mro/apps/hijitreg/Exceptions.cpp | 178 +- isis/src/mro/apps/hijitreg/HiJitCube.cpp | 597 ++-- isis/src/mro/apps/hijitreg/HiJitCube.h | 188 +- isis/src/mro/apps/hijitreg/Instrument.cpp | 745 +++-- isis/src/mro/apps/hijitreg/hijitreg.cpp | 180 +- isis/src/mro/apps/hijitter/hijitter.cpp | 70 +- isis/src/mro/apps/himos/himos.cpp | 146 +- isis/src/mro/apps/hinoise/hinoise.cpp | 163 +- isis/src/mro/apps/hirdr2isis/hirdr2isis.cpp | 45 +- isis/src/mro/apps/hirdrgen/hirdrgen.cpp | 249 +- isis/src/mro/apps/hisharpen/hisharpen.cpp | 40 +- isis/src/mro/apps/histat/histat.cpp | 276 +- isis/src/mro/apps/histitch/histitch.cpp | 125 +- isis/src/mro/apps/marci2isis/marci2isis.cpp | 138 +- isis/src/mro/apps/marcical/marcical.cpp | 50 +- isis/src/mro/apps/marciflip/marciflip.cpp | 4 +- isis/src/mro/apps/mroctx2isis/mroctx2isis.cpp | 144 +- isis/src/mro/objs/CTXCamera/CTXCamera.cpp | 14 +- isis/src/mro/objs/CTXCamera/CTXCamera.h | 4 +- isis/src/mro/objs/CTXCamera/unitTest.cpp | 34 +- isis/src/mro/objs/HiLab/HiLab.cpp | 66 +- isis/src/mro/objs/HiLab/HiLab.h | 52 +- isis/src/mro/objs/HiLab/unitTest.cpp | 6 +- .../mro/objs/HiriseCamera/HiriseCamera.cpp | 82 +- isis/src/mro/objs/HiriseCamera/HiriseCamera.h | 50 +- isis/src/mro/objs/HiriseCamera/unitTest.cpp | 17 +- isis/src/mro/objs/MarciCamera/MarciCamera.cpp | 90 +- isis/src/mro/objs/MarciCamera/MarciCamera.h | 22 +- .../objs/MarciCamera/MarciDistortionMap.cpp | 26 +- .../mro/objs/MarciCamera/MarciDistortionMap.h | 6 +- isis/src/mro/objs/MarciCamera/unitTest.cpp | 15 +- isis/src/odyssey/apps/thm2isis/thm2isis.cpp | 60 +- .../odyssey/apps/thmdriftcor/thmdriftcor.cpp | 18 +- isis/src/odyssey/apps/thmproc/thmproc.cpp | 12 +- .../odyssey/apps/thmvisflat/thmvisflat.cpp | 22 +- .../odyssey/apps/thmvistrim/thmvistrim.cpp | 28 +- .../objs/ThemisIrCamera/ThemisIrCamera.cpp | 55 +- .../objs/ThemisIrCamera/ThemisIrCamera.h | 20 +- .../ThemisIrCamera/ThemisIrDistortionMap.cpp | 25 +- .../ThemisIrCamera/ThemisIrDistortionMap.h | 2 +- .../odyssey/objs/ThemisIrCamera/unitTest.cpp | 17 +- .../objs/ThemisVisCamera/ThemisVisCamera.cpp | 60 +- .../objs/ThemisVisCamera/ThemisVisCamera.h | 20 +- .../ThemisVisDistortionMap.cpp | 70 +- .../ThemisVisCamera/ThemisVisDistortionMap.h | 26 +- .../odyssey/objs/ThemisVisCamera/unitTest.cpp | 17 +- .../apps/qnet/QnetCubeDistanceFilter.cpp | 118 +- .../qisis/apps/qnet/QnetCubeDistanceFilter.h | 16 +- .../qisis/apps/qnet/QnetCubeNameFilter.cpp | 26 +- isis/src/qisis/apps/qnet/QnetCubeNameFilter.h | 18 +- .../qisis/apps/qnet/QnetCubePointsFilter.cpp | 60 +- .../qisis/apps/qnet/QnetCubePointsFilter.h | 22 +- .../qisis/apps/qnet/QnetDeletePointDialog.cpp | 2 +- .../qisis/apps/qnet/QnetDeletePointDialog.h | 4 +- isis/src/qisis/apps/qnet/QnetFileTool.cpp | 146 +- isis/src/qisis/apps/qnet/QnetFileTool.h | 64 +- isis/src/qisis/apps/qnet/QnetFilter.cpp | 2 +- isis/src/qisis/apps/qnet/QnetFilter.h | 10 +- .../qisis/apps/qnet/QnetHoldPointDialog.cpp | 52 +- .../src/qisis/apps/qnet/QnetHoldPointDialog.h | 22 +- isis/src/qisis/apps/qnet/QnetNavTool.cpp | 538 ++-- isis/src/qisis/apps/qnet/QnetNavTool.h | 12 +- .../qisis/apps/qnet/QnetNewMeasureDialog.cpp | 28 +- .../qisis/apps/qnet/QnetNewMeasureDialog.h | 16 +- .../qisis/apps/qnet/QnetNewPointDialog.cpp | 42 +- isis/src/qisis/apps/qnet/QnetNewPointDialog.h | 6 +- .../apps/qnet/QnetPointCubeNameFilter.cpp | 68 +- .../qisis/apps/qnet/QnetPointCubeNameFilter.h | 12 +- .../apps/qnet/QnetPointDistanceFilter.cpp | 88 +- .../qisis/apps/qnet/QnetPointDistanceFilter.h | 20 +- .../qisis/apps/qnet/QnetPointErrorFilter.cpp | 108 +- .../qisis/apps/qnet/QnetPointErrorFilter.h | 22 +- .../apps/qnet/QnetPointGoodnessFilter.cpp | 88 +- .../qisis/apps/qnet/QnetPointGoodnessFilter.h | 20 +- .../src/qisis/apps/qnet/QnetPointIdFilter.cpp | 28 +- isis/src/qisis/apps/qnet/QnetPointIdFilter.h | 20 +- .../qisis/apps/qnet/QnetPointImagesFilter.cpp | 54 +- .../qisis/apps/qnet/QnetPointImagesFilter.h | 18 +- .../apps/qnet/QnetPointMeasureFilter.cpp | 146 +- .../qisis/apps/qnet/QnetPointMeasureFilter.h | 36 +- .../qisis/apps/qnet/QnetPointRangeFilter.cpp | 80 +- .../qisis/apps/qnet/QnetPointRangeFilter.h | 18 +- .../qisis/apps/qnet/QnetPointTypeFilter.cpp | 66 +- .../src/qisis/apps/qnet/QnetPointTypeFilter.h | 16 +- isis/src/qisis/apps/qnet/QnetTool.cpp | 739 ++--- isis/src/qisis/apps/qnet/QnetTool.h | 60 +- isis/src/qisis/apps/qnet/qnet.cpp | 77 +- isis/src/qisis/apps/qtie/QtieFileTool.cpp | 98 +- isis/src/qisis/apps/qtie/QtieFileTool.h | 32 +- isis/src/qisis/apps/qtie/QtieTool.cpp | 433 +-- isis/src/qisis/apps/qtie/QtieTool.h | 54 +- isis/src/qisis/apps/qtie/qtie.cpp | 12 +- isis/src/qisis/apps/qview/qview.cpp | 83 +- .../AdvancedTrackTool/AdvancedTrackTool.cpp | 468 +-- .../AdvancedTrackTool/AdvancedTrackTool.h | 50 +- .../qisis/objs/BandSpinBox/BandSpinBox.cpp | 155 +- isis/src/qisis/objs/BandSpinBox/BandSpinBox.h | 12 +- isis/src/qisis/objs/BandTool/BandTool.cpp | 289 +- isis/src/qisis/objs/BandTool/BandTool.h | 18 +- isis/src/qisis/objs/BlinkTool/BlinkTool.cpp | 194 +- isis/src/qisis/objs/BlinkTool/BlinkTool.h | 24 +- .../qisis/objs/BrowseDialog/BrowseDialog.cpp | 55 +- .../qisis/objs/BrowseDialog/BrowseDialog.h | 14 +- .../qisis/objs/ChipViewport/ChipViewport.cpp | 256 +- .../qisis/objs/ChipViewport/ChipViewport.h | 86 +- .../ControlPointEdit/ControlPointEdit.cpp | 510 +-- .../objs/ControlPointEdit/ControlPointEdit.h | 126 +- .../qisis/objs/CubeViewport/CubeViewport.cpp | 422 +-- isis/src/qisis/objs/EditTool/EditTool.cpp | 512 +-- isis/src/qisis/objs/EditTool/EditTool.h | 16 +- isis/src/qisis/objs/FileDialog/FileDialog.cpp | 141 +- isis/src/qisis/objs/FileDialog/FileDialog.h | 18 +- isis/src/qisis/objs/FileTool/FileTool.cpp | 262 +- isis/src/qisis/objs/FileTool/FileTool.h | 56 +- isis/src/qisis/objs/FindTool/FindTool.cpp | 1189 ++++--- isis/src/qisis/objs/FindTool/FindTool.h | 323 +- isis/src/qisis/objs/HelpTool/HelpTool.cpp | 26 +- isis/src/qisis/objs/HelpTool/HelpTool.h | 34 +- .../objs/HistogramTool/HistogramItem.cpp | 300 +- .../qisis/objs/HistogramTool/HistogramItem.h | 91 +- .../objs/HistogramTool/HistogramTool.cpp | 185 +- .../qisis/objs/HistogramTool/HistogramTool.h | 14 +- .../HistogramToolWindow.cpp | 46 +- .../HistogramToolWindow/HistogramToolWindow.h | 22 +- isis/src/qisis/objs/MainWindow/MainWindow.cpp | 96 +- isis/src/qisis/objs/MainWindow/MainWindow.h | 10 +- .../objs/MdiCubeViewport/MdiCubeViewport.cpp | 78 +- .../objs/MdiCubeViewport/MdiCubeViewport.h | 20 +- .../qisis/objs/MeasureTool/MeasureTool.cpp | 555 ++-- isis/src/qisis/objs/MeasureTool/MeasureTool.h | 24 +- .../MosaicControlNetTool.cpp | 85 +- .../MosaicControlNetTool.h | 14 +- .../objs/MosaicFindTool/MosaicFindTool.cpp | 144 +- .../objs/MosaicFindTool/MosaicFindTool.h | 14 +- .../MosaicMainWindow/MosaicMainWindow.cpp | 255 +- .../objs/MosaicMainWindow/MosaicMainWindow.h | 52 +- .../objs/MosaicPanTool/MosaicPanTool.cpp | 59 +- .../qisis/objs/MosaicPanTool/MosaicPanTool.h | 10 +- .../MosaicSelectTool/MosaicSelectTool.cpp | 57 +- .../objs/MosaicSelectTool/MosaicSelectTool.h | 14 +- isis/src/qisis/objs/MosaicTool/MosaicTool.cpp | 82 +- isis/src/qisis/objs/MosaicTool/MosaicTool.h | 130 +- .../objs/MosaicTrackTool/MosaicTrackTool.cpp | 51 +- .../objs/MosaicTrackTool/MosaicTrackTool.h | 8 +- .../MosaicTreeWidget/MosaicTreeWidget.cpp | 10 +- .../objs/MosaicTreeWidget/MosaicTreeWidget.h | 12 +- .../qisis/objs/MosaicWidget/MosaicWidget.cpp | 2114 ++++++------- .../qisis/objs/MosaicWidget/MosaicWidget.h | 168 +- .../objs/MosaicZoomTool/MosaicZoomTool.cpp | 199 +- .../objs/MosaicZoomTool/MosaicZoomTool.h | 24 +- .../objs/PaletteWindow/PaletteWindow.cpp | 72 +- .../qisis/objs/PaletteWindow/PaletteWindow.h | 8 +- isis/src/qisis/objs/PanTool/PanTool.cpp | 166 +- isis/src/qisis/objs/PanTool/PanTool.h | 28 +- isis/src/qisis/objs/PlotCurve/PlotCurve.cpp | 88 +- isis/src/qisis/objs/PlotCurve/PlotCurve.h | 46 +- isis/src/qisis/objs/PlotTool/PlotTool.cpp | 550 ++-- isis/src/qisis/objs/PlotTool/PlotTool.h | 64 +- .../src/qisis/objs/PlotTool/PlotToolCurve.cpp | 46 +- isis/src/qisis/objs/PlotTool/PlotToolCurve.h | 52 +- .../objs/PlotToolWindow/PlotToolWindow.cpp | 166 +- .../objs/PlotToolWindow/PlotToolWindow.h | 29 +- isis/src/qisis/objs/PlotWindow/PlotWindow.cpp | 951 +++--- isis/src/qisis/objs/PlotWindow/PlotWindow.h | 124 +- isis/src/qisis/objs/QHistogram/QHistogram.cpp | 116 +- isis/src/qisis/objs/QHistogram/QHistogram.h | 90 +- .../RubberBandComboBox/RubberBandComboBox.cpp | 152 +- .../RubberBandComboBox/RubberBandComboBox.h | 50 +- .../objs/ScatterPlotTool/ScatterPlotData.cpp | 300 +- .../objs/ScatterPlotTool/ScatterPlotData.h | 88 +- .../objs/ScatterPlotTool/ScatterPlotTool.cpp | 53 +- .../objs/ScatterPlotTool/ScatterPlotTool.h | 34 +- .../ScatterPlotWindow/ScatterPlotWindow.cpp | 282 +- .../ScatterPlotWindow/ScatterPlotWindow.h | 36 +- .../qisis/objs/SocketThread/SocketThread.cpp | 40 +- .../qisis/objs/SocketThread/SocketThread.h | 36 +- .../SpecialPixelTool/SpecialPixelTool.cpp | 176 +- .../objs/SpecialPixelTool/SpecialPixelTool.h | 12 +- .../objs/StatisticsTool/StatisticsTool.cpp | 242 +- .../objs/StatisticsTool/StatisticsTool.h | 38 +- .../qisis/objs/StretchTool/StretchTool.cpp | 410 +-- isis/src/qisis/objs/StretchTool/StretchTool.h | 17 +- isis/src/qisis/objs/Tab/Tab.cpp | 34 +- isis/src/qisis/objs/Tab/Tab.h | 38 +- isis/src/qisis/objs/TabBar/TabBar.cpp | 96 +- isis/src/qisis/objs/TabBar/TabBar.h | 40 +- .../objs/TableMainWindow/TableMainWindow.cpp | 669 ++-- .../objs/TableMainWindow/TableMainWindow.h | 106 +- isis/src/qisis/objs/Tool/Tool.cpp | 36 +- isis/src/qisis/objs/ToolPad/ToolPad.h | 22 +- isis/src/qisis/objs/TrackTool/TrackTool.cpp | 170 +- isis/src/qisis/objs/TrackTool/TrackTool.h | 14 +- .../ViewportMainWindow/ViewportMainWindow.cpp | 136 +- .../ViewportMainWindow/ViewportMainWindow.h | 46 +- isis/src/qisis/objs/WindowTool/WindowTool.cpp | 68 +- isis/src/qisis/objs/WindowTool/WindowTool.h | 19 +- isis/src/qisis/objs/Workspace/Workspace.cpp | 68 +- isis/src/qisis/objs/Workspace/Workspace.h | 19 +- isis/src/qisis/objs/ZoomTool/ZoomTool.cpp | 325 +- isis/src/qisis/objs/ZoomTool/ZoomTool.h | 22 +- isis/src/rolo/apps/rolo2isis/rolo2isis.cpp | 39 +- isis/src/system/apps/blobdump/blobdump.cpp | 38 +- .../src/system/apps/csspck2spk/csspck2spk.cpp | 32 +- .../system/apps/isiscomplete/isiscomplete.cpp | 10 +- .../system/apps/kerneldbgen/SpiceDbGen.cpp | 160 +- isis/src/system/apps/kerneldbgen/SpiceDbGen.h | 86 +- .../system/apps/kerneldbgen/kerneldbgen.cpp | 101 +- isis/src/system/objs/KernelDb/KernelDb.cpp | 157 +- isis/src/system/objs/KernelDb/KernelDb.h | 116 +- isis/src/system/objs/KernelDb/unitTest.cpp | 39 +- isis/src/viking/apps/vdcomp/vdcomp.c | 977 +++--- isis/src/viking/apps/vikcal/CalParameters.cpp | 370 +-- isis/src/viking/apps/vikcal/CalParameters.h | 368 ++- isis/src/viking/apps/vikcal/vikcal.cpp | 68 +- isis/src/viking/apps/vikclean/vikclean.cpp | 4 +- isis/src/viking/apps/vikfixtrx/vikfixtrx.cpp | 52 +- .../viking/apps/viknobutter/viknobutter.cpp | 78 +- .../viking/apps/viknonoodle/viknonoodle.cpp | 73 +- .../viking/apps/viknopepper/viknopepper.cpp | 46 +- isis/src/viking/apps/viknosalt/viknosalt.cpp | 60 +- .../viking/objs/VikingCamera/VikingCamera.cpp | 104 +- .../viking/objs/VikingCamera/VikingCamera.h | 64 +- .../src/viking/objs/VikingCamera/unitTest.cpp | 19 +- isis/templates/gui/defaulttemplate.cpp | 4 +- 1402 files changed, 96850 insertions(+), 94147 deletions(-) diff --git a/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricCamera.cpp b/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricCamera.cpp index b7e12fc4a5..ff621c3ed8 100644 --- a/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricCamera.cpp +++ b/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricCamera.cpp @@ -15,9 +15,9 @@ using namespace std; namespace Isis { namespace Apollo { // constructors - ApolloMetricCamera::ApolloMetricCamera (Isis::Pvl &lab) : Isis::FramingCamera(lab) { + ApolloMetricCamera::ApolloMetricCamera(Isis::Pvl &lab) : Isis::FramingCamera(lab) { NaifStatus::CheckErrors(); - + // Get the camera characteristics SetFocalLength(); SetPixelPitch(); @@ -27,7 +27,7 @@ namespace Isis { // Setup focal plane map CameraFocalPlaneMap *focalMap = new CameraFocalPlaneMap(this, NaifIkCode()); - focalMap->SetDetectorOrigin(ParentSamples()/2.0, ParentLines()/2.0); + focalMap->SetDetectorOrigin(ParentSamples() / 2.0, ParentLines() / 2.0); const PvlGroup &inst = lab.FindGroup("Instrument", Pvl::Traverse); @@ -35,10 +35,10 @@ namespace Isis { iString odkKey("INS" + iString((int)NaifIkCode()) + "_OD_K"); iString decenterKey("INS" + iString((int)NaifIkCode()) + "_DECENTER"); - new ApolloMetricDistortionMap(this, GetDouble(ppKey, 0), - GetDouble(ppKey, 1), GetDouble(odkKey, 0), GetDouble(odkKey, 1), - GetDouble(odkKey, 2), GetDouble(decenterKey, 0), - GetDouble(decenterKey, 1), GetDouble(decenterKey, 2)); + new ApolloMetricDistortionMap(this, GetDouble(ppKey, 0), + GetDouble(ppKey, 1), GetDouble(odkKey, 0), GetDouble(odkKey, 1), + GetDouble(odkKey, 2), GetDouble(decenterKey, 0), + GetDouble(decenterKey, 1), GetDouble(decenterKey, 2)); // Setup the ground and sky map new CameraGroundMap(this); @@ -58,6 +58,6 @@ namespace Isis { } } -extern "C" Isis::Camera *ApolloMetricCameraPlugin (Isis::Pvl &lab) { +extern "C" Isis::Camera *ApolloMetricCameraPlugin(Isis::Pvl &lab) { return new Isis::Apollo::ApolloMetricCamera(lab); } diff --git a/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricCamera.h b/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricCamera.h index 861c278e86..40f9b3f021 100644 --- a/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricCamera.h +++ b/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricCamera.h @@ -2,27 +2,27 @@ #define ApolloMetricCamera_h #include "FramingCamera.h" -/** - * @brief Apollo Metric Camera Model - * +/** + * @brief Apollo Metric Camera Model + * * This is the camera model for the Apollo metric camera. - * - * @ingroup Camera - * + * + * @ingroup Camera + * * @author 2006-11-14 Jacob Danton - * - * @internal + * + * @internal * @history 2006-11-14 Jacob Danton - Original Version * @history 2009-08-28 Steven Lambright - Changed inheritance to no longer * inherit directly from Camera - */ + */ namespace Isis { namespace Apollo { class ApolloMetricCamera : public FramingCamera { public: - ApolloMetricCamera (Isis::Pvl &lab); + ApolloMetricCamera(Isis::Pvl &lab); - ~ApolloMetricCamera () {}; + ~ApolloMetricCamera() {}; }; }; }; diff --git a/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricDistortionMap.cpp b/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricDistortionMap.cpp index 50686480ab..9803f40590 100644 --- a/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricDistortionMap.cpp +++ b/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricDistortionMap.cpp @@ -4,12 +4,12 @@ using namespace std; namespace Isis { - ApolloMetricDistortionMap::ApolloMetricDistortionMap (Camera *parent, - double xp, double yp, - double k1,double k2, - double k3, double j1, - double j2, double t0) : - CameraDistortionMap(parent) { + ApolloMetricDistortionMap::ApolloMetricDistortionMap(Camera *parent, + double xp, double yp, + double k1, double k2, + double k3, double j1, + double j2, double t0) : + CameraDistortionMap(parent) { p_xp = xp; p_yp = yp; @@ -21,7 +21,7 @@ namespace Isis { p_t0 = t0; } - /** + /** * Compute undistorted focal plane x/y * * Compute undistorted focal plane x/y given a distorted focal plane x/y. @@ -42,27 +42,27 @@ namespace Isis { double y = dy - p_yp; // r is the distance between the principal point and the measured point on the image - double rr = x*x + y*y; - double rrrr = rr*rr; + double rr = x * x + y * y; + double rrrr = rr * rr; // dr is the radial distortion contribution // -dt*sin(p_t0) is the decentering distortion contribution in the x-direction // dt*cos(p_t0) is the decentering distortion contribution in the y-direction - double dr = 1 + p_k1*rr + p_k2*rrrr + p_k3*rr*rrrr; - double dt = p_j1*rr + p_j2*rrrr; + double dr = 1 + p_k1 * rr + p_k2 * rrrr + p_k3 * rr * rrrr; + double dt = p_j1 * rr + p_j2 * rrrr; // image coordinates corrected for principal point, radial and decentering distortion - p_undistortedFocalPlaneX = dr*x - dt*sin(p_t0); - p_undistortedFocalPlaneY = dr*y + dt*cos(p_t0); + p_undistortedFocalPlaneX = dr * x - dt * sin(p_t0); + p_undistortedFocalPlaneY = dr * y + dt * cos(p_t0); return true; } - /** + /** * Compute distorted focal plane x/y * - * Compute distorted focal plane x/y given an undistorted focal plane x/y. + * Compute distorted focal plane x/y given an undistorted focal plane x/y. * After calling this method, you can obtain the distorted x/y via the * FocalPlaneX and FocalPlaneY methods * @@ -79,10 +79,10 @@ namespace Isis { double xt = ux; double yt = uy; - double xx,yy,rr,rrrr,dr; - double xdistortion,ydistortion; - double xdistorted,ydistorted; - double xprevious,yprevious; + double xx, yy, rr, rrrr, dr; + double xdistortion, ydistortion; + double xdistorted, ydistorted; + double xprevious, yprevious; // dr is the radial distortion contribution // -dt*sin(p_t0) is the decentering distortion contribution in the x-direction // dt*cos(p_t0) is the decentering distortion contribution in the y-direction @@ -98,43 +98,43 @@ namespace Isis { // iterating to introduce distortion... // we stop when the difference between distorted coordinates // in successive iterations is at or below the given tolerance - for( int i = 0; i < 50; i++ ) { - xx = xt*xt; - yy = yt*yt; + for(int i = 0; i < 50; i++) { + xx = xt * xt; + yy = yt * yt; rr = xx + yy; - rrrr = rr *rr; - + rrrr = rr * rr; + // radial distortion // dr is the radial distortion contribution // -dt*sin(p_t0) is the decentering distortion contribution in the x-direction // dt*cos(p_t0) is the decentering distortion contribution in the y-direction - dr = p_k1*rr + p_k2*rrrr + p_k3*rr*rrrr; - - dt = p_j1*rr + p_j2*rrrr; - + dr = p_k1 * rr + p_k2 * rrrr + p_k3 * rr * rrrr; + + dt = p_j1 * rr + p_j2 * rrrr; + // distortion at the current point location - xdistortion = xt*dr - dt*sin(p_t0); - ydistortion = yt*dr + dt*cos(p_t0); - + xdistortion = xt * dr - dt * sin(p_t0); + ydistortion = yt * dr + dt * cos(p_t0); + // updated image coordinates xt = ux - xdistortion; yt = uy - ydistortion; - + // distorted point corrected for principal point xdistorted = xt + p_xp; ydistorted = yt + p_yp; - + // check for convergence - if( (fabs(xt - xprevious) <= tolerance) && (fabs(yt - yprevious) <= tolerance) ) { + if((fabs(xt - xprevious) <= tolerance) && (fabs(yt - yprevious) <= tolerance)) { bConverged = true; break; } - + xprevious = xt; yprevious = yt; } - - if( bConverged ) { + + if(bConverged) { p_focalPlaneX = xdistorted; p_focalPlaneY = ydistorted; } diff --git a/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricDistortionMap.h b/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricDistortionMap.h index 09103a2adf..54bbbc19f5 100644 --- a/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricDistortionMap.h +++ b/isis/src/apollo/objs/ApolloMetricCamera/ApolloMetricDistortionMap.h @@ -7,18 +7,18 @@ namespace Isis { class ApolloMetricDistortionMap : public CameraDistortionMap { public: - ApolloMetricDistortionMap (Camera *parent, double xp, double yp, double k1, double k2, double k3, double j1, double j2, double t0); - ~ApolloMetricDistortionMap () {}; + ApolloMetricDistortionMap(Camera *parent, double xp, double yp, double k1, double k2, double k3, double j1, double j2, double t0); + ~ApolloMetricDistortionMap() {}; - bool SetFocalPlane (const double dx, const double dy); - bool SetUndistortedFocalPlane (const double ux, const double uy); + bool SetFocalPlane(const double dx, const double dy); + bool SetUndistortedFocalPlane(const double ux, const double uy); private: // parameters below are from camera calibration report double p_xp, p_yp; //!< principal point coordinates double p_k1, p_k2, p_k3; //!< coefficients of radial distortion double p_j1, p_j2; //!< coefficients of decentering distortion double p_t0; //!< angle between positive x-axis of image and vector to imaged point - //!< used in computation of decentering distortion + //!< used in computation of decentering distortion }; }; #endif diff --git a/isis/src/apollo/objs/ApolloMetricCamera/unitTest.cpp b/isis/src/apollo/objs/ApolloMetricCamera/unitTest.cpp index f477ef93cb..b647014712 100644 --- a/isis/src/apollo/objs/ApolloMetricCamera/unitTest.cpp +++ b/isis/src/apollo/objs/ApolloMetricCamera/unitTest.cpp @@ -10,12 +10,11 @@ using namespace std; void TestLineSamp(Isis::Camera *cam, double samp, double line); -int main (void) -{ +int main(void) { Isis::Preference::Preferences(true); cout << "Unit Test for ApolloCamera..." << endl; - try{ + try { // These should be lat/lon at center of image. To obtain these numbers for a new cube/camera, // set both the known lat and known lon to zero and copy the unit test output "Latitude off by: " // and "Longitude off by: " values directly into these variables. @@ -45,7 +44,7 @@ int main (void) double line = cam->Lines() / 2; cout << "For center pixel position ..." << endl; - if(!cam->SetImage(samp,line)) { + if(!cam->SetImage(samp, line)) { std::cout << "ERROR" << std::endl; return 0; } @@ -64,13 +63,13 @@ int main (void) cout << setprecision(16) << "Longitude off by: " << cam->UniversalLongitude() - knownLon << endl; } } - catch (Isis::iException &e) { + catch(Isis::iException &e) { e.Report(); } } void TestLineSamp(Isis::Camera *cam, double samp, double line) { - bool success = cam->SetImage(samp,line); + bool success = cam->SetImage(samp, line); if(success) { success = cam->SetUniversalGround(cam->UniversalLatitude(), cam->UniversalLongitude()); @@ -79,8 +78,8 @@ void TestLineSamp(Isis::Camera *cam, double samp, double line) { if(success) { double deltaSamp = samp - cam->Sample(); double deltaLine = line - cam->Line(); - if (fabs(deltaSamp) < 0.01) deltaSamp = 0; - if (fabs(deltaLine) < 0.01) deltaLine = 0; + if(fabs(deltaSamp) < 0.01) deltaSamp = 0; + if(fabs(deltaLine) < 0.01) deltaLine = 0; cout << "DeltaSample = " << deltaSamp << endl; cout << "DeltaLine = " << deltaLine << endl << endl; } diff --git a/isis/src/base/apps/algebra/algebra.cpp b/isis/src/base/apps/algebra/algebra.cpp index 3088484f7c..b79f1766a9 100644 --- a/isis/src/base/apps/algebra/algebra.cpp +++ b/isis/src/base/apps/algebra/algebra.cpp @@ -3,63 +3,63 @@ #include "SpecialPixel.h" #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; -void add (vector &in, +void add(vector &in, + vector &out); +void sub(vector &in, + vector &out); +void mult(vector &in, vector &out); -void sub (vector &in, - vector &out); -void mult (vector &in, - vector &out); -void div (vector &in, - vector &out); -void unary (Buffer &in, Buffer &out); +void div(vector &in, + vector &out); +void unary(Buffer &in, Buffer &out); -double Isisa,Isisb,Isisc,Isisd,Isise; +double Isisa, Isisb, Isisc, Isisd, Isise; void IsisMain() { // We will be processing by line ProcessByLine p; // Setup the input and output files - UserInterface &ui = Application::GetUserInterface(); + UserInterface &ui = Application::GetUserInterface(); // Setup the input and output cubes p.SetInputCube("FROM1"); - if (ui.WasEntered ("FROM2")) p.SetInputCube("FROM2"); - p.SetOutputCube ("TO"); + if(ui.WasEntered("FROM2")) p.SetInputCube("FROM2"); + p.SetOutputCube("TO"); // Get the coefficients - Isisa = ui.GetDouble ("A"); - Isisb = ui.GetDouble ("B"); - Isisc = ui.GetDouble ("C"); - Isisd = ui.GetDouble ("D"); - Isise = ui.GetDouble ("E"); - + Isisa = ui.GetDouble("A"); + Isisb = ui.GetDouble("B"); + Isisc = ui.GetDouble("C"); + Isisd = ui.GetDouble("D"); + Isise = ui.GetDouble("E"); + // Start the processing based on the operator - string op = ui.GetString ("OPERATOR"); - if (op == "ADD" ) p.StartProcess(add); - if (op == "SUBTRACT") p.StartProcess(sub); - if (op == "MULTIPLY") p.StartProcess(mult); - if (op == "DIVIDE") p.StartProcess(div); - if (op == "UNARY") p.StartProcess(unary); + string op = ui.GetString("OPERATOR"); + if(op == "ADD") p.StartProcess(add); + if(op == "SUBTRACT") p.StartProcess(sub); + if(op == "MULTIPLY") p.StartProcess(mult); + if(op == "DIVIDE") p.StartProcess(div); + if(op == "UNARY") p.StartProcess(unary); // Cleanup p.EndProcess(); } -// Add routine -void add (vector &in, vector &out) { +// Add routine +void add(vector &in, vector &out) { Buffer &inp1 = *in[0]; Buffer &inp2 = *in[1]; Buffer &outp = *out[0]; - // Loop for each pixel in the line. - for (int i=0; i &in, vector &out) { } } -// Sub routine -void sub (vector &in, vector &out) { +// Sub routine +void sub(vector &in, vector &out) { Buffer &inp1 = *in[0]; Buffer &inp2 = *in[1]; Buffer &outp = *out[0]; - // Loop for each pixel in the line. - for (int i=0; i &in, vector &out) { } } -// Sub routine -void mult (vector &in, vector &out) { +// Sub routine +void mult(vector &in, vector &out) { Buffer &inp1 = *in[0]; Buffer &inp2 = *in[1]; Buffer &outp = *out[0]; - // Loop for each pixel in the line. - for (int i=0; i &in, vector &out) { } } -// Div routine -void div (vector &in, vector &out) { +// Div routine +void div(vector &in, vector &out) { Buffer &inp1 = *in[0]; Buffer &inp2 = *in[1]; Buffer &outp = *out[0]; - // Loop for each pixel in the line. - for (int i=0; i &in, vector &out) { } } -// Unary routine -void unary (Buffer &in, Buffer &out) { - // Loop for each pixel in the line. - for (int i=0; i timeCache, double tol ) : SpiceRotation ( frameCode ) { + LineScanCameraRotation::LineScanCameraRotation(int frameCode, Isis::Pvl &lab, std::vector timeCache, double tol) : SpiceRotation(frameCode) { // Initialize optional paramters; p_pitchRate = 0.; p_yaw = 0.; @@ -40,35 +40,35 @@ namespace Isis { p_spi = new Isis::Spice(lab); // Make sure the kernels are written to the labels and not just the tables (blobs) - if (!p_spi->HasKernels(lab)) { + if(!p_spi->HasKernels(lab)) { std::string msg = "The master file must contain the kernel files. Rerun spiceinit with attach=no"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_cacheTime = timeCache; // std::cout<InstrumentRotation()->SetFrame(frameCode); p_crot = p_spi->InstrumentRotation(); p_prot = p_spi->BodyRotation(); p_spos = p_spi->InstrumentPosition(); - // Load the line scan specific rotation matrix caches before loading the regular Spice caches because + // Load the line scan specific rotation matrix caches before loading the regular Spice caches because // the CreateCache method will unload all the kernels after the caches are created LoadCache(); - p_spi->CreateCache(timeCache[0],timeCache[timeCache.size()-1],timeCache.size(), tol); - } + p_spi->CreateCache(timeCache[0], timeCache[timeCache.size()-1], timeCache.size(), tol); + } /** * Destroys the LineScanComeraRotation object */ - LineScanCameraRotation::~LineScanCameraRotation () { - if (p_spi != 0) delete p_spi; + LineScanCameraRotation::~LineScanCameraRotation() { + if(p_spi != 0) delete p_spi; } @@ -82,7 +82,7 @@ namespace Isis { * system. * */ - void LineScanCameraRotation::LoadCache () { + void LineScanCameraRotation::LoadCache() { NaifStatus::CheckErrors(); double startTime = p_cacheTime[0]; @@ -98,7 +98,7 @@ namespace Isis { // Loop and load the cache double cacheSlope = 0.0; - if (size > 1) cacheSlope = (endTime - startTime) / (double) (size - 1); + if(size > 1) cacheSlope = (endTime - startTime) / (double)(size - 1); double state[6]; double lt; NaifStatus::CheckErrors(); @@ -108,45 +108,45 @@ namespace Isis { double I[3]; // Direction of in-track axis double *velocity; std::vector IB(9); - std::vector CI(9); + std::vector CI(9); SpiceRotation *prot = p_spi->BodyRotation(); SpiceRotation *crot = p_spi->InstrumentRotation(); - for (std::vector::iterator i=p_cacheTime.begin(); i::iterator i = p_cacheTime.begin(); i < p_cacheTime.end(); i++) { double et = *i; prot->SetEphemerisTime(et); crot->SetEphemerisTime(et); // The following code will be put into method LoadIBcache() - spkezr_c ("MRO", et, "IAU_MARS", "NONE", "MARS", state, <); + spkezr_c("MRO", et, "IAU_MARS", "NONE", "MARS", state, <); NaifStatus::CheckErrors(); - // Compute the direction of the radial axis (3) of the line scan camera - vscl_c(1./vnorm_c(state), state, R); // vscl and vnorm only operate on first 3 members of state + // Compute the direction of the radial axis (3) of the line scan camera + vscl_c(1. / vnorm_c(state), state, R); // vscl and vnorm only operate on first 3 members of state // Compute the direction of the cross-track axis (2) of the line scan camera velocity = state + 3; - vscl_c(1./vnorm_c(velocity), velocity, C); + vscl_c(1. / vnorm_c(velocity), velocity, C); vcrss_c(R, C, C); // Compute the direction of the in-track axis (1) of the line scan camera vcrss_c(C, R, I); // Load the matrix IB and enter it into the cache - vequ_c (I, (SpiceDouble (*)) &IB[0]); - vequ_c (C, (SpiceDouble (*)) &IB[3]); - vequ_c (R, (SpiceDouble (*)) &IB[6]); + vequ_c(I, (SpiceDouble( *)) &IB[0]); + vequ_c(C, (SpiceDouble( *)) &IB[3]); + vequ_c(R, (SpiceDouble( *)) &IB[6]); p_cacheIB.push_back(IB); // end IB code - // Compute the CIcr matrix - in-track, cross-track, radial frame to constant frame - mxmt_c((SpiceDouble (*)[3]) &(crot->TimeBasedMatrix())[0], (SpiceDouble (*)[3]) &(prot->Matrix())[0], - (SpiceDouble (*)[3]) &CI[0]); + // Compute the CIcr matrix - in-track, cross-track, radial frame to constant frame + mxmt_c((SpiceDouble( *)[3]) & (crot->TimeBasedMatrix())[0], (SpiceDouble( *)[3]) & (prot->Matrix())[0], + (SpiceDouble( *)[3]) &CI[0]); // Put CI into parent cache to use the parent class methods on it - mxmt_c((SpiceDouble (*)[3]) &CI[0], (SpiceDouble (*)[3]) &IB[0], (SpiceDouble (*)[3]) &CI[0]); - p_cache.push_back( CI ); + mxmt_c((SpiceDouble( *)[3]) &CI[0], (SpiceDouble( *)[3]) &IB[0], (SpiceDouble( *)[3]) &CI[0]); + p_cache.push_back(CI); } p_cachesLoaded = true; SetSource(Memcache); @@ -167,40 +167,40 @@ namespace Isis { * @param function3 The third polynomial function used to * find the rotation angles */ - void LineScanCameraRotation::ReloadCache (){ + void LineScanCameraRotation::ReloadCache() { NaifStatus::CheckErrors(); - // Make sure caches are already loaded - if ( !p_cachesLoaded) { + // Make sure caches are already loaded + if(!p_cachesLoaded) { std::string msg = "A LineScanCameraRotation cache has not been loaded yet"; - throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Programmer, msg, _FILEINFO_); } - // Clear existing matrices from cache + // Clear existing matrices from cache p_cache.clear(); // Create polynomials fit to angles & use to reload cache - Isis::PolynomialUnivariate function1( p_degree ); - Isis::PolynomialUnivariate function2( p_degree ); - Isis::PolynomialUnivariate function3( p_degree ); + Isis::PolynomialUnivariate function1(p_degree); + Isis::PolynomialUnivariate function2(p_degree); + Isis::PolynomialUnivariate function3(p_degree); // Get the coefficients of the polynomials already fit to the angles of rotation defining [CI] std::vector coeffAng1; std::vector coeffAng2; std::vector coeffAng3; - GetPolynomial ( coeffAng1, coeffAng2, coeffAng3 ); + GetPolynomial(coeffAng1, coeffAng2, coeffAng3); // Reset linear term to center around zero -- what works best is either roll-avg & pitchavg+ or pitchavg+ & yawavg- // coeffAng1[1] -= 0.0000158661225; // coeffAng2[1] = 0.0000308433; // coeffAng3[0] = -0.001517547; - if (p_pitchRate) coeffAng2[1] = p_pitchRate; - if (p_yaw) coeffAng3[0] = p_yaw; + if(p_pitchRate) coeffAng2[1] = p_pitchRate; + if(p_yaw) coeffAng3[0] = p_yaw; // Load the functions with the coefficients - function1.SetCoefficients ( coeffAng1 ); - function2.SetCoefficients ( coeffAng2 ); - function3.SetCoefficients ( coeffAng3 ); + function1.SetCoefficients(coeffAng1); + function2.SetCoefficients(coeffAng2); + function3.SetCoefficients(coeffAng3); double CI[3][3]; double IJ[3][3]; @@ -209,32 +209,32 @@ namespace Isis { std::vector CJ; CJ.resize(9); - for (std::vector::size_type pos=0;pos < p_cacheTime.size();pos++) { + for(std::vector::size_type pos = 0; pos < p_cacheTime.size(); pos++) { double et = p_cacheTime.at(pos); - rtime.push_back((et - GetBaseTime() ) / GetTimeScale() ); - double angle1 = function1.Evaluate (rtime); - double angle2 = function2.Evaluate (rtime); - double angle3 = function3.Evaluate (rtime); + rtime.push_back((et - GetBaseTime()) / GetTimeScale()); + double angle1 = function1.Evaluate(rtime); + double angle2 = function2.Evaluate(rtime); + double angle3 = function3.Evaluate(rtime); rtime.clear(); // Get the first angle back into the range Naif expects [180.,180.] - if (angle1 < -1*pi_c() ) { + if(angle1 < -1 * pi_c()) { angle1 += twopi_c(); } - else if (angle1 > pi_c()) { + else if(angle1 > pi_c()) { angle1 -= twopi_c(); } - eul2m_c ( (SpiceDouble) angle3, (SpiceDouble) angle2, (SpiceDouble) angle1, - p_axis3, p_axis2, p_axis1, - CI); - mxm_c ( (SpiceDouble (*)[3]) &(p_jitter->SetEphemerisTimeHPF(et))[0], CI, CI); + eul2m_c((SpiceDouble) angle3, (SpiceDouble) angle2, (SpiceDouble) angle1, + p_axis3, p_axis2, p_axis1, + CI); + mxm_c((SpiceDouble( *)[3]) & (p_jitter->SetEphemerisTimeHPF(et))[0], CI, CI); prot->SetEphemerisTime(et); - mxm_c ( (SpiceDouble (*)[3]) &(p_cacheIB.at(pos))[0], (SpiceDouble (*)[3]) &(prot->Matrix())[0], IJ); - mxm_c (CI, IJ, (SpiceDouble (*)[3]) &CJ[0]); + mxm_c((SpiceDouble( *)[3]) & (p_cacheIB.at(pos))[0], (SpiceDouble( *)[3]) & (prot->Matrix())[0], IJ); + mxm_c(CI, IJ, (SpiceDouble( *)[3]) &CJ[0]); - p_cache.push_back( CJ ); // J2000 to constant frame + p_cache.push_back(CJ); // J2000 to constant frame } // Set source to cache to get updated values diff --git a/isis/src/base/apps/appjit/LineScanCameraRotation.h b/isis/src/base/apps/appjit/LineScanCameraRotation.h index 65ee5e086a..b8bc5f9376 100644 --- a/isis/src/base/apps/appjit/LineScanCameraRotation.h +++ b/isis/src/base/apps/appjit/LineScanCameraRotation.h @@ -69,8 +69,8 @@ namespace Isis { * if the time did not change to improve speed. * @history 2006-10-18 Debbie A. Cook Added method, WrapAngle, to wrap * angles around 2 pi - * @history 2007-12-05 Debbie A. Cook added method SetPolynomialDegree to - * allow the degree of the polynomials fit to the + * @history 2007-12-05 Debbie A. Cook added method SetPolynomialDegree to + * allow the degree of the polynomials fit to the * camera angles to be changed. Also changed the * polynomial from a fixed 2nd order polynomial to * an nth degree polynomial with one independent @@ -100,17 +100,23 @@ namespace Isis { public: //! Constructors // LineScanCameraRotation( int frameCode, SpiceRotation *crot, SpiceRotation *prot, SpicePosition *spos ); - LineScanCameraRotation( int frameCode, Isis::Pvl &lab, std::vector timeCache, double tol); + LineScanCameraRotation(int frameCode, Isis::Pvl &lab, std::vector timeCache, double tol); //! Destructor // virtual ~LineScanCameraRotation() { }; virtual ~LineScanCameraRotation(); void LoadCache(); - void SetJitter( PixelOffset *jitter) { p_jitter = jitter; }; + void SetJitter(PixelOffset *jitter) { + p_jitter = jitter; + }; void ReloadCache(); - void ResetPitchRate( double pitchRate ) { p_pitchRate = pitchRate; }; - void ResetYaw( double yaw ) { p_yaw = yaw; }; + void ResetPitchRate(double pitchRate) { + p_pitchRate = pitchRate; + }; + void ResetYaw(double yaw) { + p_yaw = yaw; + }; private: Isis::Spice *p_spi; diff --git a/isis/src/base/apps/appjit/PixelOffset.cpp b/isis/src/base/apps/appjit/PixelOffset.cpp index 74122347f0..fda11f8e0a 100644 --- a/isis/src/base/apps/appjit/PixelOffset.cpp +++ b/isis/src/base/apps/appjit/PixelOffset.cpp @@ -25,8 +25,8 @@ namespace Isis { * @param fl Focal length of instrument in mm. * @param pixpitch Pixel pitch of instrument in mm/pixel. */ - PixelOffset::PixelOffset( const std::string &tableList, double fl, double pixPitch, double baseTime, - double timeScale, int degree ) { + PixelOffset::PixelOffset(const std::string &tableList, double fl, double pixPitch, double baseTime, + double timeScale, int degree) { p_focalLen = fl; p_pixPitch = pixPitch; // p_RJ.resize(9); @@ -34,7 +34,7 @@ namespace Isis { p_degree = degree; p_baseTime = baseTime; p_timeScale = timeScale; - p_angleScale = p_pixPitch/p_focalLen; + p_angleScale = p_pixPitch / p_focalLen; std::vector lines; Isis::TextFile inputFile(tableList, "input", lines); std::vector fields; @@ -58,38 +58,38 @@ namespace Isis { p_times.push_back(0.); - for (size_t iline=0; ilinesMax) sMax = p_samples[i]; - if (p_lines[i]lMax) lMax = p_lines[i]; + // Compute scalers + double sMin = p_samples[0]; + double sMax = p_samples[0]; + double lMin = p_lines[0]; + double lMax = p_lines[0]; + + for(int i = 1; i < (int) p_samples.size(); i++) { + if(p_samples[i] < sMin) sMin = p_samples[i]; + if(p_samples[i] > sMax) sMax = p_samples[i]; + if(p_lines[i] < lMin) lMin = p_lines[i]; + if(p_lines[i] > lMax) lMax = p_lines[i]; } - p_sampScale = (sMax - sMin)/2.; + p_sampScale = (sMax - sMin) / 2.; p_sampOff = sMax - p_sampScale; - p_lineScale = (lMax - lMin)/2.; + p_lineScale = (lMax - lMin) / 2.; p_lineOff = lMax - p_lineScale; } /** Compute the angular equivalents for the offsets at a given time. * - * This method computes the angular equivalents in radians for the offsets + * This method computes the angular equivalents in radians for the offsets * at a given et in seconds. The pixel offsets are interpolated from the * offsets input in the table using a cubic interpolation and converted to * angles based on the focal length and the pixel pitch. @@ -98,22 +98,22 @@ namespace Isis { */ void PixelOffset::SetEphemerisTime(double et) { // Save the time - if (p_et == et) return; + if(p_et == et) return; p_et = et; // Otherwise determine the interval to interpolate. p_times, p_samples, and p_lines // have been filled to the image begin and end times and beyond with an additional entry // on each end so that the cubic interpolation will work for all image times std::vector::iterator pos; - pos = upper_bound(p_times.begin(),p_times.end(),p_et); // returns the nearest endpoint if outside range - if (pos > p_times.end()-2) pos = p_times.end()-2; // Take care of time for last line of observation - - int index=0; + pos = upper_bound(p_times.begin(), p_times.end(), p_et); // returns the nearest endpoint if outside range + if(pos > p_times.end() - 2) pos = p_times.end() - 2; // Take care of time for last line of observation + + int index = 0; double soc0, soc1, soc2, soc3, loc0, loc1, loc2, loc3; - soc0=soc1=soc2=soc3=loc0=loc1=loc2=loc3=0.; + soc0 = soc1 = soc2 = soc3 = loc0 = loc1 = loc2 = loc3 = 0.; // Check to make sure the vectors are padded sufficiently to cover the image - if (pos >= p_times.begin()+2 ) { - index = distance(p_times.begin(),pos); + if(pos >= p_times.begin() + 2) { + index = distance(p_times.begin(), pos); index--; //lower bound soc3 = p_samples[index+2] - p_samples[index+1] - p_samples[index-1] + p_samples[index]; soc2 = p_samples[index-1] - p_samples[index] - soc3; @@ -127,17 +127,17 @@ namespace Isis { else { std::string msg; msg = "Error in extrapolation code"; - throw iException::Message(Isis::iException::Programmer,msg,_FILEINFO_); + throw iException::Message(Isis::iException::Programmer, msg, _FILEINFO_); } - if (index < 0) index = 0; + if(index < 0) index = 0; // Interpolate the offsets double mult = (p_et - p_times[index]) / - (p_times[index+1] - p_times[index]); - double mult2 = mult*mult; - double sampleOff = soc3*mult*mult2 + soc2*mult2 + soc1*mult + soc0; - double lineOff = loc3*mult*mult2 + loc2*mult2 + loc1*mult + loc0; + (p_times[index+1] - p_times[index]); + double mult2 = mult * mult; + double sampleOff = soc3 * mult * mult2 + soc2 * mult2 + soc1 * mult + soc0; + double lineOff = loc3 * mult * mult2 + loc2 * mult2 + loc1 * mult + loc0; // std::cout<<" "< cacheTime ) { + void PixelOffset::LoadAngles(std::vector cacheTime) { p_cacheTime = cacheTime; // Make sure angles aren't already loaded TBD -/* if () { - std::string msg = "An angle cache has already been created"; - throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_); - } */ + /* if () { + std::string msg = "An angle cache has already been created"; + throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_); + } */ // Fill in extended sample/line/time jitter offset vectors for extrapolation - // Two extra at beginning -- added 05-15-2010 + // Two extra at beginning -- added 05-15-2010 double slope = (p_samples[3] - p_samples[2]) / (p_times[3] - p_times[2]); p_times[1] = p_cacheTime[0]; - p_times[0] = p_times[1] - .01*(p_times[2] - p_times[1]); - p_samples[1] = slope*(p_times[1] - p_times[2]) + p_samples[2]; + p_times[0] = p_times[1] - .01 * (p_times[2] - p_times[1]); + p_samples[1] = slope * (p_times[1] - p_times[2]) + p_samples[2]; // Alternative extrapolation to try if problems with current code // set p_samples[0] = p_samples[1] // Likewise for the end and for lines. - p_samples[0] = slope*(p_times[0] - p_times[2]) + p_samples[2]; + p_samples[0] = slope * (p_times[0] - p_times[2]) + p_samples[2]; slope = (p_lines[3] - p_lines[2]) / (p_times[3] - p_times[2]); - p_lines[1] = slope*(p_times[1] - p_times[2]) + p_lines[2]; - p_lines[0] = slope*(p_times[0] - p_times[2]) + p_lines[2]; + p_lines[1] = slope * (p_times[1] - p_times[2]) + p_lines[2]; + p_lines[0] = slope * (p_times[0] - p_times[2]) + p_lines[2]; // Two extra at ending int end = p_times.size() - 1; slope = (p_samples[end] - p_samples[end-1]) / (p_times[end] - p_times[end-1]); p_times.push_back(p_cacheTime[p_cacheTime.size()-1]); - p_times.push_back(p_times[end+1] + .01*(p_times[end+1] - p_cacheTime[end])); - p_samples.push_back(slope*(p_times[end+1] - p_times[end]) + p_samples[end]); - p_samples.push_back(slope*(p_times[end+2] - p_times[end]) + p_samples[end]); + p_times.push_back(p_times[end+1] + .01 * (p_times[end+1] - p_cacheTime[end])); + p_samples.push_back(slope * (p_times[end+1] - p_times[end]) + p_samples[end]); + p_samples.push_back(slope * (p_times[end+2] - p_times[end]) + p_samples[end]); slope = (p_lines[end] - p_lines[end-1]) / (p_times[end] - p_times[end-1]); - p_lines.push_back(slope*(p_times[end+1] - p_times[end]) + p_lines[end]); - p_lines.push_back(slope*(p_times[end+2] - p_times[end]) + p_lines[end]); + p_lines.push_back(slope * (p_times[end+1] - p_times[end]) + p_lines[end]); + p_lines.push_back(slope * (p_times[end+2] - p_times[end]) + p_lines[end]); // Loop and load the angle caches // std::cout< time; // Load the known values to compute the fit equation - for (std::vector::size_type pos=0;pos < p_cacheTime.size();pos++) { + for(std::vector::size_type pos = 0; pos < p_cacheTime.size(); pos++) { double t = p_cacheTime.at(pos); // Base fit on extent of coverage in the input offset file - if (t >= p_times[0] && t <= p_times[p_times.size()-1]) { - time.push_back( (t - p_baseTime) / p_timeScale ); - SetEphemerisTime( t ); - fitAng1->AddKnown ( time, p_cacheAngle1[pos] ); - fitAng2->AddKnown ( time, p_cacheAngle2[pos] ); + if(t >= p_times[0] && t <= p_times[p_times.size()-1]) { + time.push_back((t - p_baseTime) / p_timeScale); + SetEphemerisTime(t); + fitAng1->AddKnown(time, p_cacheAngle1[pos]); + fitAng2->AddKnown(time, p_cacheAngle2[pos]); time.clear(); } } - if (fitAng1->Knowns() == 0) { + if(fitAng1->Knowns() == 0) { std::string msg; msg = "Cube time range is not covered by jitter file"; - throw iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw iException::Message(Isis::iException::User, msg, _FILEINFO_); } //Solve the equations for the coefficients @@ -254,15 +254,15 @@ namespace Isis { // each be fit to a unique basis function. // Fill the coefficient vectors - for ( int i = 0; i < function1.Coefficients(); i++) { - p_ang1Coefficients.push_back( function1.Coefficient( i ) ); - p_ang2Coefficients.push_back( function2.Coefficient( i ) ); + for(int i = 0; i < function1.Coefficients(); i++) { + p_ang1Coefficients.push_back(function1.Coefficient(i)); + p_ang2Coefficients.push_back(function2.Coefficient(i)); } // std::cout<<"Angle1 coeff="< PixelOffset::SetEphemerisTimeHPF ( const double et ) { + std::vector PixelOffset::SetEphemerisTimeHPF(const double et) { - Isis::PolynomialUnivariate function1( p_degree ); - Isis::PolynomialUnivariate function2( p_degree ); + Isis::PolynomialUnivariate function1(p_degree); + Isis::PolynomialUnivariate function2(p_degree); //If outside the range of the offsets just return the identity matrix - if (et < p_times[0] || et > p_times[p_times.size()-1]) { + if(et < p_times[0] || et > p_times[p_times.size()-1]) { return (p_I); } // Load the functions with the coefficients - function1.SetCoefficients ( p_ang1Coefficients ); - function2.SetCoefficients ( p_ang2Coefficients ); + function1.SetCoefficients(p_ang1Coefficients); + function2.SetCoefficients(p_ang2Coefficients); // Compute polynomial approximations to angles, pangle1 and pangle2 std::vector rtime; rtime.push_back((et - p_baseTime) / p_timeScale); - double pangle1 = p_sampOff + p_sampScale*function1.Evaluate (rtime); - double pangle2 = p_lineOff + p_lineScale*function2.Evaluate (rtime); + double pangle1 = p_sampOff + p_sampScale * function1.Evaluate(rtime); + double pangle2 = p_lineOff + p_lineScale * function2.Evaluate(rtime); // Compute p_angles for this time SetEphemerisTime(et); - double angle1 = p_angleScale*(p_angle1 - pangle1); - double angle2 = p_angleScale*(p_angle2 - pangle2); + double angle1 = p_angleScale * (p_angle1 - pangle1); + double angle2 = p_angleScale * (p_angle2 - pangle2); // std::cout<<" "< TC(9); - eul2m_c ( (SpiceDouble) 0., (SpiceDouble) angle2, (SpiceDouble) angle1, - 3, 2, 1, - (SpiceDouble(*) [3]) &TC[0]); + eul2m_c((SpiceDouble) 0., (SpiceDouble) angle2, (SpiceDouble) angle1, + 3, 2, 1, + (SpiceDouble( *) [3]) &TC[0]); return (TC); } @@ -326,10 +326,10 @@ namespace Isis { double PixelOffset::WrapAngle(double compareAngle, double angle) { double diff1 = compareAngle - angle; - if ( diff1 < -1*pi_c() ){ + if(diff1 < -1 * pi_c()) { angle -= twopi_c(); - } - else if (diff1 > pi_c() ) { + } + else if(diff1 > pi_c()) { angle += twopi_c(); } return angle; diff --git a/isis/src/base/apps/appjit/PixelOffset.h b/isis/src/base/apps/appjit/PixelOffset.h index f75c9bb167..02a781a0ee 100644 --- a/isis/src/base/apps/appjit/PixelOffset.h +++ b/isis/src/base/apps/appjit/PixelOffset.h @@ -35,11 +35,11 @@ namespace Isis { * @brief Obtain rotation angles for a line scan camera pixel offsets * * This class will obtain the rotation from existing camera pointing to - * "corrected" camera pointing calculated from a table of pixel offsets - * and time (sample line et) + * "corrected" camera pointing calculated from a table of pixel offsets + * and time (sample line et) * - * This class was created to calculate the rotation matrix needed to - * remove jitter from a hirise image based on the table of offsets. + * This class was created to calculate the rotation matrix needed to + * remove jitter from a hirise image based on the table of offsets. * * @ingroup SpiceInstrumentsAndCameras * @@ -50,39 +50,39 @@ namespace Isis { * @history 2008-12-19 Debbie A. Cook Removed couts to prepare for commiting * @history 2009-10-01 Debbie A. Cook Cleaned up extrapolation code * @history 2010-05-17 Debbie A. Cook Recoded extrapolation to add 2 - * extra points on each end of the input data. The first point + * extra points on each end of the input data. The first point * added on each end should be the start and end time of the * observation. The added points are linearly interpolated from - * the beginning and final 2 points of input data. + * the beginning and final 2 points of input data. */ class PixelOffset { public: //! Constructors - PixelOffset( const std::string &tableList, double fl, double pixPitch, double baseTime, - double timeScale, int degree ); + PixelOffset(const std::string &tableList, double fl, double pixPitch, double baseTime, + double timeScale, int degree); //! Destructor virtual ~PixelOffset() { } //! Load the angles by interpolating the pixel offsets and converting to angles - void LoadAngles ( std::vector cacheTime ); + void LoadAngles(std::vector cacheTime); //! Compute cubic interpolation for current time et - void Interp (); + void Interp(); //! Compute coefficients for a polynomial fit to each angle based on scaled time - void SetPolynomial (); + void SetPolynomial(); - void SetEphemerisTime(const double et ); + void SetEphemerisTime(const double et); - std::vector SetEphemerisTimeHPF(const double et ); + std::vector SetEphemerisTimeHPF(const double et); - double WrapAngle (double compareAngle, double angle); + double WrapAngle(double compareAngle, double angle); // std::vector &Matrix() { return p_TC; }; - - private: + + private: std::vector p_samples; std::vector p_lines; std::vector p_times; @@ -91,16 +91,16 @@ namespace Isis { double p_pixPitch; //!< Pixel pitch of instrument in mm/pixel double p_et; //!< Current ephemeris time - std::vector p_cacheAngle1; //! + std::vector p_cacheAngle1; //! std::vector p_cacheAngle2; std::vector p_cacheTime; - // rotation at et + // rotation at et double p_baseTime; //!< Base time used in fit equations double p_timeScale; //!< Time scale used in fit equations std::vector p_ang1Coefficients; std::vector p_ang2Coefficients; - //!< Coefficients of polynomials fit to - // each of three rotation angles + //!< Coefficients of polynomials fit to + // each of three rotation angles int p_degree; //!< Degree of fit polynomial for angles double p_angle1; //!< Angle1 for current et in radians double p_angle2; //!< Angle2 for current et in radians diff --git a/isis/src/base/apps/appjit/appjit.cpp b/isis/src/base/apps/appjit/appjit.cpp index 6afaad3bc3..e1b8c9d88c 100644 --- a/isis/src/base/apps/appjit/appjit.cpp +++ b/isis/src/base/apps/appjit/appjit.cpp @@ -30,21 +30,21 @@ void IsisMain() { FileList list; list.Read(ui.GetFilename("FROMLIST")); - if (list.size() < 1) { + if(list.size() < 1) { string msg = "The input list file [" + ui.GetFilename("FROMLIST") + "is empty"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } int ifile = 0; // Make sure the master file is included in the input file list - while (ifile < (int) list.size() && Filename(list[ifile]).Expanded() != Filename(ui.GetFilename("MASTER")).Expanded()) { + while(ifile < (int) list.size() && Filename(list[ifile]).Expanded() != Filename(ui.GetFilename("MASTER")).Expanded()) { ifile++; } - if (ifile >= (int) list.size()) { - string msg = "The master file, [" + Filename(ui.GetFilename("MASTER")).Expanded() + " is not included in " + - "the input list file " + ui.GetFilename("FROMLIST") + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + if(ifile >= (int) list.size()) { + string msg = "The master file, [" + Filename(ui.GetFilename("MASTER")).Expanded() + " is not included in " + + "the input list file " + ui.GetFilename("FROMLIST") + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } bool step2 = false; @@ -55,34 +55,34 @@ void IsisMain() { try { // Open the master cube Cube cube; - cube.Open(ui.GetFilename("MASTER"),"rw"); - + cube.Open(ui.GetFilename("MASTER"), "rw"); + //check for existing polygon, if exists delete it - if (cube.Label()->HasObject("Polygon")){ + if(cube.Label()->HasObject("Polygon")) { cube.Label()->DeleteObject("Polygon"); } // Get the camera Camera *cam = cube.Camera(); - if (cam->DetectorMap()->LineRate() == 0.0) { + if(cam->DetectorMap()->LineRate() == 0.0) { string msg = "[" + ui.GetFilename("MASTER") + "] is not a line scan camera image"; - throw iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw iException::Message(Isis::iException::User, msg, _FILEINFO_); } - // Create the master rotation to be corrected + // Create the master rotation to be corrected int frameCode = cam->InstrumentRotation()->Frame(); - cam->SetImage(int(cube.Samples()/2), int(cube.Lines()/2) ); + cam->SetImage(int(cube.Samples() / 2), int(cube.Lines() / 2)); double tol = cam->PixelResolution(); - if (tol < 0.) { + if(tol < 0.) { // Alternative calculation of .01*ground resolution of a pixel - tol = cam->PixelPitch()*cam->SpacecraftAltitude()*1000./cam->FocalLength()/100.; + tol = cam->PixelPitch() * cam->SpacecraftAltitude() * 1000. / cam->FocalLength() / 100.; } - LineScanCameraRotation crot(frameCode, *(cube.Label()), cam->InstrumentRotation()->GetFullCacheTime(), tol ); + LineScanCameraRotation crot(frameCode, *(cube.Label()), cam->InstrumentRotation()->GetFullCacheTime(), tol); crot.SetPolynomialDegree(ui.GetInteger("DEGREE")); crot.SetAxes(1, 2, 3); - if (ui.WasEntered("PITCHRATE")) crot.ResetPitchRate(ui.GetDouble("PITCHRATE")); - if (ui.WasEntered("YAW")) crot.ResetYaw(ui.GetDouble("YAW")); + if(ui.WasEntered("PITCHRATE")) crot.ResetPitchRate(ui.GetDouble("PITCHRATE")); + if(ui.WasEntered("YAW")) crot.ResetYaw(ui.GetDouble("YAW")); crot.SetPolynomial(); double baseTime = crot.GetBaseTime(); double timeScale = crot.GetTimeScale(); @@ -96,7 +96,7 @@ void IsisMain() { jitter.SetPolynomial(); // Set the jitter and apply to the instrument rotation - crot.SetJitter( &jitter ); + crot.SetJitter(&jitter); crot.ReloadCache(); // Pull out the pointing cache as a table and write it @@ -105,30 +105,30 @@ void IsisMain() { cube.Write(cmatrix); // Write out the instrument position table - Isis::PvlGroup kernels = cube.Label()->FindGroup("Kernels",Isis::Pvl::Traverse); + Isis::PvlGroup kernels = cube.Label()->FindGroup("Kernels", Isis::Pvl::Traverse); // Write out the "Table" label to the tabled kernels in the kernels group kernels["InstrumentPointing"] = "Table"; // kernels["InstrumentPosition"] = "Table"; cube.PutGroup(kernels); cube.Close(); - gp += PvlKeyword("StatusMaster",ui.GetFilename("MASTER") + ": camera pointing updated"); + gp += PvlKeyword("StatusMaster", ui.GetFilename("MASTER") + ": camera pointing updated"); // Apply the dejittered pointing to the rest of the files step2 = true; - for (int ifile = 0; ifile < (int) list.size(); ifile++) { - if (list[ifile] != ui.GetFilename("MASTER")) { + for(int ifile = 0; ifile < (int) list.size(); ifile++) { + if(list[ifile] != ui.GetFilename("MASTER")) { // Open the cube - cube.Open(list[ifile],"rw"); + cube.Open(list[ifile], "rw"); //check for existing polygon, if exists delete it - if (cube.Label()->HasObject("Polygon")){ + if(cube.Label()->HasObject("Polygon")) { cube.Label()->DeleteObject("Polygon"); } // Get the camera and make sure it is a line scan camera Camera *cam = cube.Camera(); - if (cam->DetectorMap()->LineRate() == 0.0) { + if(cam->DetectorMap()->LineRate() == 0.0) { string msg = "[" + ui.GetFilename("FROM") + "] is not a line scan camera"; - throw iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Pull out the pointing cache as a table and write it cube.Write(cmatrix); @@ -137,16 +137,16 @@ void IsisMain() { gp += PvlKeyword("Status" + iString(ifile), list[ifile] + ": camera pointing updated"); } } - Application::Log( gp ); + Application::Log(gp); } - catch (iException &e) { + catch(iException &e) { string msg; - if (!step2) { + if(!step2) { msg = "Unable to fit pointing for [" + ui.GetFilename("MASTER") + "]"; } else { msg = "Unable to update pointing for nonMaster file(s)"; } - throw iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw iException::Message(Isis::iException::User, msg, _FILEINFO_); } } diff --git a/isis/src/base/apps/ascii2isis/ascii2isis.cpp b/isis/src/base/apps/ascii2isis/ascii2isis.cpp index 41b79c3c2d..f17ca09204 100644 --- a/isis/src/base/apps/ascii2isis/ascii2isis.cpp +++ b/isis/src/base/apps/ascii2isis/ascii2isis.cpp @@ -7,12 +7,12 @@ #include "ProcessByLine.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; // Global declarations double TestSpecial(const double pixel); -void ascii2isis (Buffer &out); +void ascii2isis(Buffer &out); ifstream fin; string order; //Initialize values to make special pixels invalid @@ -41,87 +41,90 @@ void IsisMain() { CubeAttributeOutput &att = ui.GetOutputAttribute("TO"); // Set special pixel ranges - if (ui.GetBoolean("SETNULLRANGE")) { + if(ui.GetBoolean("SETNULLRANGE")) { null_min = ui.GetDouble("NULLMIN"); null_max = ui.GetDouble("NULLMAX"); } - if (ui.GetBoolean("SETHRSRANGE")) { + if(ui.GetBoolean("SETHRSRANGE")) { hrs_min = ui.GetDouble("HRSMIN"); hrs_max = ui.GetDouble("HRSMAX"); } - if (ui.GetBoolean("SETLRSRANGE")) { + if(ui.GetBoolean("SETLRSRANGE")) { lrs_min = ui.GetDouble("LRSMIN"); lrs_max = ui.GetDouble("LRSMAX"); } - fin.open (from.c_str(),std::ios::in); - if (!fin.is_open()) { + fin.open(from.c_str(), std::ios::in); + if(!fin.is_open()) { string msg = "Cannot open input file [" + from + "]"; - throw Isis::iException::Message(Isis::iException::Io,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Io, msg, _FILEINFO_); } // Skip header information if it exists - fin.seekg(skip,std::ios::beg); + fin.seekg(skip, std::ios::beg); // Set up process depending on order - if (order == "BSQ") { + if(order == "BSQ") { ProcessByLine p; - p.SetOutputCube (ui.GetFilename("TO"),att,ns,nl,nb); + p.SetOutputCube(ui.GetFilename("TO"), att, ns, nl, nb); p.StartProcess(ascii2isis); p.EndProcess(); } - if (order == "BIL") { + if(order == "BIL") { ProcessBySpectra p(Isis::ProcessBySpectra::ByLine); // Set Special Pixel ranges - p.SetOutputCube (ui.GetFilename("TO"),att,ns,nl,nb); + p.SetOutputCube(ui.GetFilename("TO"), att, ns, nl, nb); p.StartProcess(ascii2isis); p.EndProcess(); } - if (order == "BIP") { + if(order == "BIP") { ProcessBySpectra p(Isis::ProcessBySpectra::PerPixel); - p.SetOutputCube (ui.GetFilename("TO"),att,ns,nl,nb); + p.SetOutputCube(ui.GetFilename("TO"), att, ns, nl, nb); p.StartProcess(ascii2isis); p.EndProcess(); } - fin.close (); + fin.close(); } -void ascii2isis (Buffer &out) { +void ascii2isis(Buffer &out) { //Define all legal characters for the beginning of a number const string legal = ".0123456789+-"; - for (int i=0; i> out[i]; out[i] = TestSpecial(out[i]); //Discard all nonlegal characters - while ((legal.find(fin.peek())== string::npos) && !fin.eof()) { + while((legal.find(fin.peek()) == string::npos) && !fin.eof()) { fin.ignore(); } } } -/** +/** * Tests the pixel. If it is valid it will return the dn value, * otherwise it will return the Isis special pixel value that * corresponds to it - * + * * @param pixel The double precision value that represents a * pixel. * @return double The double precision value representing the * pixel will return as a valid dn or changed to an isis * special pixel. */ - double TestSpecial(const double pixel){ - if (pixel <= null_max && pixel >= null_min){ - return Isis::NULL8; - } else if (pixel <= hrs_max && pixel >= hrs_min){ - return Isis::HIGH_REPR_SAT8; - } else if (pixel <= lrs_max && pixel >= lrs_min){ - return Isis::LOW_REPR_SAT8; - } else { - return pixel; - } +double TestSpecial(const double pixel) { + if(pixel <= null_max && pixel >= null_min) { + return Isis::NULL8; + } + else if(pixel <= hrs_max && pixel >= hrs_min) { + return Isis::HIGH_REPR_SAT8; + } + else if(pixel <= lrs_max && pixel >= lrs_min) { + return Isis::LOW_REPR_SAT8; } + else { + return pixel; + } +} diff --git a/isis/src/base/apps/automos/automos.cpp b/isis/src/base/apps/automos/automos.cpp index 5dc7ae7d2c..317fa61c07 100644 --- a/isis/src/base/apps/automos/automos.cpp +++ b/isis/src/base/apps/automos/automos.cpp @@ -7,43 +7,41 @@ #include "SpecialPixel.h" #include "ProjectionFactory.h" -using namespace std; +using namespace std; using namespace Isis; void calcRange(double &minLat, double &maxLat, double &minLon, double &maxLon); -void helperButtonCalcRange (); +void helperButtonCalcRange(); -map GuiHelpers() -{ - map helper; - helper ["helperButtonCalcRange"] = (void*) helperButtonCalcRange; +map GuiHelpers() { + map helper; + helper ["helperButtonCalcRange"] = (void *) helperButtonCalcRange; return helper; } -void IsisMain() -{ +void IsisMain() { FileList list; - UserInterface &ui = Application::GetUserInterface(); + UserInterface &ui = Application::GetUserInterface(); - // Get the list of cubes to mosaic + // Get the list of cubes to mosaic list.Read(ui.GetFilename("FROMLIST")); - if (list.size() < 1) { + if(list.size() < 1) { string msg = "The list file [" + ui.GetFilename("FROMLIST") + "does not contain any data"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - ProcessMapMosaic m; + ProcessMapMosaic m; // Set the create flag-mosaic is always created in automos m.SetCreateFlag(true); - // Get the Track Flag + // Get the Track Flag bool bTrack = ui.GetBoolean("TRACK"); m.SetTrackFlag(bTrack); CubeAttributeOutput &oAtt = ui.GetOutputAttribute("MOSAIC"); - if (ui.GetString("GRANGE") == "USER") { - m.SetOutputCube(list, + if(ui.GetString("GRANGE") == "USER") { + m.SetOutputCube(list, ui.GetDouble("MINLAT"), ui.GetDouble("MAXLAT"), ui.GetDouble("MINLON"), ui.GetDouble("MAXLON"), oAtt, ui.GetFilename("MOSAIC")); @@ -56,115 +54,113 @@ void IsisMain() // placed ontop of each other in the mosaic or beneath each other or // placed based on band with "Lesser" or "Greater" criteria // Set up the mosaic priority, either the input cube will be - // placed ontop of the mosaic or beneath it + // placed ontop of the mosaic or beneath it MosaicPriority priority; - string sType; - if (ui.GetString("PRIORITY") == "BENEATH") { + string sType; + if(ui.GetString("PRIORITY") == "BENEATH") { priority = mosaic; } - else if (ui.GetString("PRIORITY") == "ONTOP") { - priority = input; + else if(ui.GetString("PRIORITY") == "ONTOP") { + priority = input; } - else { - priority = band; - sType = ui.GetString("TYPE"); - if (sType=="BANDNUMBER") { - m.SetBandNumber(ui.GetInteger("NUMBER")); - } - else { - // Key name & value - m.SetBandKeyWord(ui.GetString("KEYNAME"), ui.GetString("KEYVALUE")); - } - // Band Criteria - BandCriteria eCriteria = Lesser; - if (ui.GetString("CRITERIA") == "GREATER") - eCriteria = Greater; - m.SetBandCriteria(eCriteria); + else { + priority = band; + sType = ui.GetString("TYPE"); + if(sType == "BANDNUMBER") { + m.SetBandNumber(ui.GetInteger("NUMBER")); + } + else { + // Key name & value + m.SetBandKeyWord(ui.GetString("KEYNAME"), ui.GetString("KEYVALUE")); + } + // Band Criteria + BandCriteria eCriteria = Lesser; + if(ui.GetString("CRITERIA") == "GREATER") + eCriteria = Greater; + m.SetBandCriteria(eCriteria); } - + // Priority m.SetPriority(priority); - m.SetHighSaturationFlag(ui.GetBoolean("HIGHSATURATION")); - m.SetLowSaturationFlag (ui.GetBoolean("LOWSATURATION")); - m.SetNullFlag(ui.GetBoolean("NULL")); + m.SetHighSaturationFlag(ui.GetBoolean("HIGHSATURATION")); + m.SetLowSaturationFlag(ui.GetBoolean("LOWSATURATION")); + m.SetNullFlag(ui.GetBoolean("NULL")); // Loop for each input file and place it in the output mosaic - + m.SetBandBinMatch(ui.GetBoolean("MATCHBANDBIN")); - for (unsigned int i=0; i nbands) nbands = cube.Bands(); + if(cube.Bands() > nbands) nbands = cube.Bands(); // See if the cube has a projection and make sure it matches // previous input cubes Projection *proj = Isis::ProjectionFactory::CreateFromCube(*(cube.Label())); - if (firstProj == NULL) { + if(firstProj == NULL) { firstProj = proj; } - else if (*proj != *firstProj) { + else if(*proj != *firstProj) { string msg = "Mapping groups do not match between cubes [" + list[0] + "] and [" + list[i] + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - if (proj->HasGroundRange()) { - if (proj->MinimumLatitude() < minLat) minLat = proj->MinimumLatitude(); - if (proj->MaximumLatitude() > maxLat) maxLat = proj->MaximumLatitude(); - if (proj->MinimumLongitude() < minLon) minLon = proj->MinimumLongitude(); - if (proj->MaximumLongitude() > maxLon) maxLon = proj->MaximumLongitude(); + if(proj->HasGroundRange()) { + if(proj->MinimumLatitude() < minLat) minLat = proj->MinimumLatitude(); + if(proj->MaximumLatitude() > maxLat) maxLat = proj->MaximumLatitude(); + if(proj->MinimumLongitude() < minLon) minLon = proj->MinimumLongitude(); + if(proj->MaximumLongitude() > maxLon) maxLon = proj->MaximumLongitude(); } // Cleanup cube.Close(); - if (proj != firstProj) - delete proj; + if(proj != firstProj) + delete proj; } } // Helper function to run calcRange function. -void helperButtonCalcRange () -{ +void helperButtonCalcRange() { UserInterface &ui = Application::GetUserInterface(); double minLat; double maxLat; @@ -172,18 +168,18 @@ void helperButtonCalcRange () double maxLon; // Run the function calcRange of calculate range info - calcRange(minLat,maxLat,minLon,maxLon); + calcRange(minLat, maxLat, minLon, maxLon); // Write ranges to the GUI string use = "USER"; ui.Clear("GRANGE"); - ui.PutAsString("GRANGE",use); + ui.PutAsString("GRANGE", use); ui.Clear("MINLAT"); - ui.PutDouble("MINLAT",minLat); + ui.PutDouble("MINLAT", minLat); ui.Clear("MAXLAT"); - ui.PutDouble("MAXLAT",maxLat); + ui.PutDouble("MAXLAT", maxLat); ui.Clear("MINLON"); - ui.PutDouble("MINLON",minLon); + ui.PutDouble("MINLON", minLon); ui.Clear("MAXLON"); - ui.PutDouble("MAXLON",maxLon); + ui.PutDouble("MAXLON", maxLon); } diff --git a/isis/src/base/apps/autoregtemplate/autoregtemplate.cpp b/isis/src/base/apps/autoregtemplate/autoregtemplate.cpp index 99cbd1c39a..990b282758 100644 --- a/isis/src/base/apps/autoregtemplate/autoregtemplate.cpp +++ b/isis/src/base/apps/autoregtemplate/autoregtemplate.cpp @@ -15,182 +15,182 @@ void IsisMain() { Pvl p; // Begin creating the mapping group - PvlObject autoreg("AutoRegistration"); - + PvlObject autoreg("AutoRegistration"); + // Make sure the entered algorithm name is valid string algoName = ui.GetString("ALGORITHM"); - if (!algos.HasGroup(algoName)) { - // Give the user a list of possible algorithms - string msg = "Invalid Algorithm Name [" + algoName + "] " + - "Possible Algorithms are: "; - for (int i=0; i ssamp || pline + 2 > sline) { + if(psamp + 2 > ssamp || pline + 2 > sline) { string msg = "The Pattern Chip must span at least a 3x3 window in the "; msg += "Search Chip"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } - + // Set up the pattern chip group PvlGroup patternChip("PatternChip"); - patternChip += PvlKeyword("Samples",iString(psamp)); - patternChip += PvlKeyword("Lines",iString(pline)); - if (ui.WasEntered("PMIN")) { - patternChip += PvlKeyword("ValidMinimum",iString(ui.GetInteger("PMIN"))); + patternChip += PvlKeyword("Samples", iString(psamp)); + patternChip += PvlKeyword("Lines", iString(pline)); + if(ui.WasEntered("PMIN")) { + patternChip += PvlKeyword("ValidMinimum", iString(ui.GetInteger("PMIN"))); } - if (ui.WasEntered("PMAX")) { - patternChip += PvlKeyword("ValidMaximum",iString(ui.GetInteger("PMAX"))); + if(ui.WasEntered("PMAX")) { + patternChip += PvlKeyword("ValidMaximum", iString(ui.GetInteger("PMAX"))); } - if (ui.WasEntered("MINIMUMZSCORE")) { + if(ui.WasEntered("MINIMUMZSCORE")) { double minimum = ui.GetDouble("MINIMUMZSCORE"); - patternChip += PvlKeyword("MinimumZScore",iString(minimum)); + patternChip += PvlKeyword("MinimumZScore", iString(minimum)); if(minimum <= 0.0) { string msg = "MINIMUMZSCORE must be greater than 0.0 (Default = 1.0)"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } } - + // Set up the search chip group PvlGroup searchChip("SearchChip"); - searchChip += PvlKeyword("Samples",iString(ssamp)); - searchChip += PvlKeyword("Lines",iString(sline)); - if (ui.WasEntered("SMIN")) { - searchChip += PvlKeyword("ValidMinimum",iString(ui.GetInteger("SMIN"))); + searchChip += PvlKeyword("Samples", iString(ssamp)); + searchChip += PvlKeyword("Lines", iString(sline)); + if(ui.WasEntered("SMIN")) { + searchChip += PvlKeyword("ValidMinimum", iString(ui.GetInteger("SMIN"))); } - if (ui.WasEntered("SMAX")) { - searchChip += PvlKeyword("ValidMaximum",iString(ui.GetInteger("SMAX"))); + if(ui.WasEntered("SMAX")) { + searchChip += PvlKeyword("ValidMaximum", iString(ui.GetInteger("SMAX"))); } - if (ui.WasEntered("VALIDPERCENT")) { + if(ui.WasEntered("VALIDPERCENT")) { double percent = ui.GetDouble("VALIDPERCENT"); - searchChip += PvlKeyword("ValidPercent",iString(percent)); + searchChip += PvlKeyword("ValidPercent", iString(percent)); - if ((percent <= 0.0) || (percent > 100.0)) { + if((percent <= 0.0) || (percent > 100.0)) { string msg = "VALIDPERCENT must be between 0.0 and 100.0 (Default = 50.0)"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } } - + // Add groups to the autoreg object autoreg.AddGroup(patternChip); autoreg.AddGroup(searchChip); - + // Set up the surface model testing group - if (subPixelAccuracy) { + if(subPixelAccuracy) { PvlGroup surfaceModel("SurfaceModel"); - + double distanceTol = ui.GetDouble("DISTANCETOLERANCE"); - surfaceModel += PvlKeyword("DistanceTolerance",iString(distanceTol)); + surfaceModel += PvlKeyword("DistanceTolerance", iString(distanceTol)); - if (distanceTol <= 0.0) { + if(distanceTol <= 0.0) { string msg = "DISTANCETOLERANCE must be greater than 0.0 (Default = 1.5)"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - + int winSize = ui.GetInteger("WINDOWSIZE"); - surfaceModel += PvlKeyword("WindowSize",iString(winSize)); - + surfaceModel += PvlKeyword("WindowSize", iString(winSize)); + // Make sure the window size is at least 3 - if (winSize < 3) { + if(winSize < 3) { string msg = "WINDOWSIZE must be greater than or equal to 3 (Default = 5)"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Make sure the window size is odd - if (winSize % 2 == 0) { + if(winSize % 2 == 0) { string msg = "WINDOWSIZE must be an odd number (Default = 5)"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } - if (ui.GetBoolean("ECCENTRICITYTESTING")) { + if(ui.GetBoolean("ECCENTRICITYTESTING")) { double eccRatio = ui.GetDouble("ECCENTRICITYRATIO"); - surfaceModel += PvlKeyword("EccentricityRatio",iString(eccRatio)); + surfaceModel += PvlKeyword("EccentricityRatio", iString(eccRatio)); - if (eccRatio < 1) { + if(eccRatio < 1) { string msg = "ECCENTRICITYRATIO must be 1.0 or larger (Default = 2.0)"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } } - if (ui.GetBoolean("RESIDUALTESTING")) { + if(ui.GetBoolean("RESIDUALTESTING")) { double residualTol = ui.GetDouble("RESIDUALTOLERANCE"); - surfaceModel += PvlKeyword("ResidualTolerance",iString(residualTol)); + surfaceModel += PvlKeyword("ResidualTolerance", iString(residualTol)); - if (residualTol < 0){ + if(residualTol < 0) { string msg = "RESIDUALTOLERANCE must be 0.0 or larger (Default = 0.1)"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } } autoreg.AddGroup(surfaceModel); } - + // Add autoreg group to Pvl p.AddObject(autoreg); diff --git a/isis/src/base/apps/bandnorm/bandnorm.cpp b/isis/src/base/apps/bandnorm/bandnorm.cpp index 0b8395ff83..508d16cda8 100644 --- a/isis/src/base/apps/bandnorm/bandnorm.cpp +++ b/isis/src/base/apps/bandnorm/bandnorm.cpp @@ -25,9 +25,9 @@ static vector normalizer; // function prototypes void getStats(Buffer &in); void normalize(Buffer &in, Buffer &out); -void Tokenize( const string& str, - vector & tokens, - const string& delimiters = " " ); +void Tokenize(const string &str, + vector & tokens, + const string &delimiters = " "); void IsisMain() { // We will be processing by line @@ -40,67 +40,67 @@ void IsisMain() { // Now get the statistics for each band or the entire cube string avg = ui.GetString("AVERAGE"); p.StartProcess(getStats); - if (avg == "BAND") { + if(avg == "BAND") { int b = 0; - Statistics stats; - for (int i=0; i<(int)average.size(); i++) { - if (b == band[i]) { - stats.AddData(&average[i],(unsigned int)1); + Statistics stats; + for(int i = 0; i < (int)average.size(); i++) { + if(b == band[i]) { + stats.AddData(&average[i], (unsigned int)1); } else { normalizer.push_back(stats.Average()); b++; stats.Reset(); - } + } } normalizer.push_back(stats.Average()); } - else if( avg == "PENCIL" ) { + else if(avg == "PENCIL") { TextFile pencil; - pencil.Open( ui.GetFilename("SPECTRUM") ); - if( pencil.LineCount()-1 < icube->Bands()) { - string msg = "The spectral pencil file [" + ui.GetAsString("SPECTRUM") + - "] does not contain enough data for all bands."; - throw iException::Message(iException::User,msg,_FILEINFO_); + pencil.Open(ui.GetFilename("SPECTRUM")); + if(pencil.LineCount() - 1 < icube->Bands()) { + string msg = "The spectral pencil file [" + ui.GetAsString("SPECTRUM") + + "] does not contain enough data for all bands."; + throw iException::Message(iException::User, msg, _FILEINFO_); } string st; - int column=-1; + int column = -1; vector tokens; - pencil.GetLine( st ); //Takes care of title line - Tokenize( st, tokens, ", \"-+" ); - if( ui.GetAsString("METHOD") == "number" ) { + pencil.GetLine(st); //Takes care of title line + Tokenize(st, tokens, ", \"-+"); + if(ui.GetAsString("METHOD") == "number") { column = ui.GetInteger("NUMBER"); } else { - for( unsigned i=0; i tokens.size() ) { - string msg = "The column specified in file ["+ ui.GetFilename("SPECTRUM") + if(column < 0 || (unsigned)column > tokens.size()) { + string msg = "The column specified in file [" + ui.GetFilename("SPECTRUM") + "] was not found."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Add the correct column of data to normalizer - for( int i=0; iBands(); i++ ) { + for(int i = 0; i < icube->Bands(); i++) { tokens.clear(); - pencil.GetLine( st ); - Tokenize( st, tokens, ", \"" ); - normalizer.push_back( Isis::iString(tokens[column]).ToDouble() ); + pencil.GetLine(st); + Tokenize(st, tokens, ", \""); + normalizer.push_back(Isis::iString(tokens[column]).ToDouble()); } } else { // avg == "CUBE" Statistics stats; - for (int i=0; i<(int)average.size(); i++) { - stats.AddData(&average[i],(unsigned int)1); + for(int i = 0; i < (int)average.size(); i++) { + stats.AddData(&average[i], (unsigned int)1); } - for (int b=0; bBands(); b++) { + for(int b = 0; b < icube->Bands(); b++) { normalizer.push_back(stats.Average()); } - } + } // Setup the output file and apply the correction p.SetOutputCube("TO"); @@ -117,45 +117,44 @@ void IsisMain() { //********************************************************** void getStats(Buffer &in) { Statistics stats; - stats.AddData(in.DoubleBuffer(),in.size()); + stats.AddData(in.DoubleBuffer(), in.size()); average.push_back(stats.Average()); - band.push_back(in.Band()-1); + band.push_back(in.Band() - 1); } // Apply coefficients void normalize(Buffer &in, Buffer &out) { - int index = in.Band()-1; + int index = in.Band() - 1; double coeff = normalizer[index]; // Now loop and apply the coefficents - for (int i=0; i & tokens, - const string& delimiters ) -{ +void Tokenize(const string &str, + vector & tokens, + const string &delimiters) { //Skip delimiters at the beginning string::size_type lastPos = str.find_first_not_of(delimiters, 0); // Find first "non-delimiter". string::size_type pos = str.find_first_of(delimiters, lastPos); - while( string::npos != pos || string::npos != lastPos ) { + while(string::npos != pos || string::npos != lastPos) { // Found a token, add it to the vector - tokens.push_back( str.substr( lastPos, pos - lastPos ) ); + tokens.push_back(str.substr(lastPos, pos - lastPos)); // Skip delimiters - lastPos = str.find_first_not_of( delimiters, pos); + lastPos = str.find_first_not_of(delimiters, pos); // Find next "non-delimiter" pos = str.find_first_of(delimiters, lastPos); } diff --git a/isis/src/base/apps/bandtrim/bandtrim.cpp b/isis/src/base/apps/bandtrim/bandtrim.cpp index 4043b8a62f..69e3da7e5e 100644 --- a/isis/src/base/apps/bandtrim/bandtrim.cpp +++ b/isis/src/base/apps/bandtrim/bandtrim.cpp @@ -2,34 +2,33 @@ #include "ProcessByBrick.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void BandTrim (Buffer &in, Buffer &out); +void BandTrim(Buffer &in, Buffer &out); -void IsisMain() -{ +void IsisMain() { ProcessByBrick p; Cube *icube = p.SetInputCube("FROM"); p.SetBrickSize(1, 1, icube->Bands()); - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); p.StartProcess(BandTrim); p.EndProcess(); } // Trim spectral pixels if anyone of them is null -void BandTrim (Buffer &in, Buffer &out){ +void BandTrim(Buffer &in, Buffer &out) { // Copy input to output and check to see if we should null bool nullPixels = false; - for (int i=0; iSamples()+1)/2; - y = (icube->Lines()+1)/2; + x = (icube->Samples() + 1) / 2; + y = (icube->Lines() + 1) / 2; - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); // Get the input values - d = ui.GetDouble ("CUTOFF"); + d = ui.GetDouble("CUTOFF"); dw = ui.GetDouble("BANDWIDTH"); - g = ui.GetInteger ("ORDER"); + g = ui.GetInteger("ORDER"); // checks the type and runs the appropriate filter - if (ui.GetString("TYPE") == "LOWPASS") { - p.StartProcess(lowpass); + if(ui.GetString("TYPE") == "LOWPASS") { + p.StartProcess(lowpass); } - else if (ui.GetString("TYPE") == "HIGHPASS") { - p.StartProcess(highpass); + else if(ui.GetString("TYPE") == "HIGHPASS") { + p.StartProcess(highpass); } - else if (ui.GetString("TYPE") == "BANDPASS") { - p.StartProcess(bandpass); + else if(ui.GetString("TYPE") == "BANDPASS") { + p.StartProcess(bandpass); } - else if (ui.GetString("TYPE") == "BANDSTOP") { - p.StartProcess(bandstop); + else if(ui.GetString("TYPE") == "BANDSTOP") { + p.StartProcess(bandstop); } else { string msg = "Unknow value for TYPE [" + ui.GetString("TYPE") + "]"; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } p.EndProcess(); } // Applies a lowpass filter to an image in the frequency domain. -void lowpass (Buffer &in, Buffer &out) -{ - double dist = 0.0; - double B = 0.0; - - for (int i=0; iGetGroup("Instrument"); - if (!outcam->IsBandIndependent()) { - PvlKeyword rBand("ReferenceBand",referenceBand); + if(!outcam->IsBandIndependent()) { + PvlKeyword rBand("ReferenceBand", referenceBand); rBand.AddComment("# All bands are aligned to reference band"); instgrp += rBand; mcube->PutGroup(instgrp); @@ -48,23 +48,23 @@ void IsisMain() { } // Only recreate the output camera if it was band dependent - if (outcam == NULL) outcam = CameraFactory::Create(*(mcube->Label())); + if(outcam == NULL) outcam = CameraFactory::Create(*(mcube->Label())); // We might need the instrument group later, so get a copy before clearing the input // cubes. m.ClearInputCubes(); - Cube *icube = m.SetInputCube ("FROM"); + Cube *icube = m.SetInputCube("FROM"); incam = icube->Camera(); // Set up the transform object which will simply map // output line/samps -> output lat/lons -> input line/samps - Transform *transform = new cam2cam (icube->Samples(), - icube->Lines(), - incam, - ocube->Samples(), - ocube->Lines(), - outcam); + Transform *transform = new cam2cam(icube->Samples(), + icube->Lines(), + incam, + ocube->Samples(), + ocube->Lines(), + outcam); // Add the reference band to the output if necessary @@ -72,18 +72,18 @@ void IsisMain() { // Set up the interpolator Interpolator *interp = NULL; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } // See if we need to deal with band dependent camera models - if (!incam->IsBandIndependent()) { + if(!incam->IsBandIndependent()) { m.BandChange(BandChange); } @@ -97,9 +97,9 @@ void IsisMain() { } // Transform object constructor -cam2cam::cam2cam (const int inputSamples, const int inputLines, - Camera *incam, const int outputSamples, - const int outputLines, Camera *outcam) { +cam2cam::cam2cam(const int inputSamples, const int inputLines, + Camera *incam, const int outputSamples, + const int outputLines, Camera *outcam) { p_inputSamples = inputSamples; p_inputLines = inputLines; p_incam = incam; @@ -110,21 +110,21 @@ cam2cam::cam2cam (const int inputSamples, const int inputLines, } // Transform method mapping output line/samps to lat/lons to input line/samps -bool cam2cam::Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { +bool cam2cam::Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { // See if the output image coordinate converts to lat/lon - if (!p_outcam->SetImage(outSample,outLine)) return false; + if(!p_outcam->SetImage(outSample, outLine)) return false; // Get the universal lat/lon and see if it can be converted to input line/samp double lat = p_outcam->UniversalLatitude(); double lon = p_outcam->UniversalLongitude(); - if (!p_incam->SetUniversalGround(lat,lon)) return false; + if(!p_incam->SetUniversalGround(lat, lon)) return false; // Make sure the point is inside the input image - if (p_incam->Sample() < 0.5) return false; - if (p_incam->Line() < 0.5) return false; - if (p_incam->Sample() > p_inputSamples + 0.5) return false; - if (p_incam->Line() > p_inputLines + 0.5) return false; + if(p_incam->Sample() < 0.5) return false; + if(p_incam->Line() < 0.5) return false; + if(p_incam->Sample() > p_inputSamples + 0.5) return false; + if(p_incam->Line() > p_inputLines + 0.5) return false; // Everything is good inSample = p_incam->Sample(); @@ -132,14 +132,14 @@ bool cam2cam::Xform (double &inSample, double &inLine, return true; } -int cam2cam::OutputSamples () const { +int cam2cam::OutputSamples() const { return p_outputSamples; } -int cam2cam::OutputLines () const { +int cam2cam::OutputLines() const { return p_outputLines; } -void BandChange (const int band) { +void BandChange(const int band) { incam->SetBand(band); } diff --git a/isis/src/base/apps/cam2cam/cam2cam.h b/isis/src/base/apps/cam2cam/cam2cam.h index bd78ccbb43..c81314800e 100644 --- a/isis/src/base/apps/cam2cam/cam2cam.h +++ b/isis/src/base/apps/cam2cam/cam2cam.h @@ -14,17 +14,17 @@ class cam2cam : public Isis::Transform { public: // constructor - cam2cam (const int inputSamples, const int inputLines, Isis::Camera *incam, - const int outputSamples, const int outputLines, Isis::Camera *outcam); - + cam2cam(const int inputSamples, const int inputLines, Isis::Camera *incam, + const int outputSamples, const int outputLines, Isis::Camera *outcam); + // destructor - ~cam2cam () {}; + ~cam2cam() {}; // Implementations for parent's pure virtual members - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine); - int OutputSamples () const; - int OutputLines () const; + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine); + int OutputSamples() const; + int OutputLines() const; }; #endif diff --git a/isis/src/base/apps/cam2map/cam2map.cpp b/isis/src/base/apps/cam2map/cam2map.cpp index cb213054f8..384bb6f108 100644 --- a/isis/src/base/apps/cam2map/cam2map.cpp +++ b/isis/src/base/apps/cam2map/cam2map.cpp @@ -10,25 +10,25 @@ using namespace std; using namespace Isis; -void PrintMap (); -void LoadMapRes (); -void LoadCameraRes (); -void LoadMapRange (); -void LoadCameraRange (); - -map GuiHelpers(){ - map helper; - helper ["PrintMap"] = (void*) PrintMap; - helper ["LoadMapRes"] = (void*) LoadMapRes; - helper ["LoadCameraRes"] = (void*) LoadCameraRes; - helper ["LoadMapRange"] = (void*) LoadMapRange; - helper ["LoadCameraRange"] = (void*) LoadCameraRange; +void PrintMap(); +void LoadMapRes(); +void LoadCameraRes(); +void LoadMapRange(); +void LoadCameraRange(); + +map GuiHelpers() { + map helper; + helper ["PrintMap"] = (void *) PrintMap; + helper ["LoadMapRes"] = (void *) LoadMapRes; + helper ["LoadCameraRes"] = (void *) LoadCameraRes; + helper ["LoadMapRange"] = (void *) LoadMapRange; + helper ["LoadCameraRange"] = (void *) LoadCameraRange; return helper; } // Global variables -void BandChange (const int band); +void BandChange(const int band); Cube *icube; Camera *incam; @@ -40,17 +40,17 @@ void IsisMain() { UserInterface &ui = Application::GetUserInterface(); Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); // Open the input cube and get the camera - icube = p.SetInputCube ("FROM"); + icube = p.SetInputCube("FROM"); incam = icube->Camera(); // Make sure it is not the sky - if (incam->IsSky()) { + if(incam->IsSky()) { string msg = "The image [" + ui.GetFilename("FROM") + "] is targeting the sky, use skymap instead."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Get the mapping grop @@ -60,18 +60,18 @@ void IsisMain() { // Make the target info match the user mapfile - double minlat,maxlat,minlon,maxlon; - incam->GroundRange(minlat,maxlat,minlon,maxlon,userMap); - camGrp.AddKeyword(PvlKeyword("MinimumLatitude",minlat),Pvl::Replace); - camGrp.AddKeyword(PvlKeyword("MaximumLatitude",maxlat),Pvl::Replace); - camGrp.AddKeyword(PvlKeyword("MinimumLongitude",minlon),Pvl::Replace); - camGrp.AddKeyword(PvlKeyword("MaximumLongitude",maxlon),Pvl::Replace); + double minlat, maxlat, minlon, maxlon; + incam->GroundRange(minlat, maxlat, minlon, maxlon, userMap); + camGrp.AddKeyword(PvlKeyword("MinimumLatitude", minlat), Pvl::Replace); + camGrp.AddKeyword(PvlKeyword("MaximumLatitude", maxlat), Pvl::Replace); + camGrp.AddKeyword(PvlKeyword("MinimumLongitude", minlon), Pvl::Replace); + camGrp.AddKeyword(PvlKeyword("MaximumLongitude", maxlon), Pvl::Replace); // We want to delete the keywords we just added if the user wants the range // out of the mapfile, otherwise they will replace any keywords not in the // mapfile - if (ui.GetString("DEFAULTRANGE") == "MAP" || ui.GetBoolean("MATCHMAP")) { + if(ui.GetString("DEFAULTRANGE") == "MAP" || ui.GetBoolean("MATCHMAP")) { camGrp.DeleteKeyword("MinimumLatitude"); camGrp.DeleteKeyword("MaximumLatitude"); camGrp.DeleteKeyword("MinimumLongitude"); @@ -80,149 +80,149 @@ void IsisMain() { // Otherwise, remove the keywords from the map file so the camera keywords // will be propogated correctly else { - while (userGrp.HasKeyword("MinimumLatitude")) { + while(userGrp.HasKeyword("MinimumLatitude")) { userGrp.DeleteKeyword("MinimumLatitude"); } - while (userGrp.HasKeyword("MinimumLongitude")) { + while(userGrp.HasKeyword("MinimumLongitude")) { userGrp.DeleteKeyword("MinimumLongitude"); } - while (userGrp.HasKeyword("MaximumLatitude")) { + while(userGrp.HasKeyword("MaximumLatitude")) { userGrp.DeleteKeyword("MaximumLatitude"); } - while (userGrp.HasKeyword("MaximumLongitude")) { + while(userGrp.HasKeyword("MaximumLongitude")) { userGrp.DeleteKeyword("MaximumLongitude"); } } // If the user decided to enter a ground range then override - if (ui.WasEntered("MINLON") && !ui.GetBoolean("MATCHMAP")) { + if(ui.WasEntered("MINLON") && !ui.GetBoolean("MATCHMAP")) { userGrp.AddKeyword(PvlKeyword("MinimumLongitude", - ui.GetDouble("MINLON")),Pvl::Replace); + ui.GetDouble("MINLON")), Pvl::Replace); } - if (ui.WasEntered("MAXLON") && !ui.GetBoolean("MATCHMAP")) { + if(ui.WasEntered("MAXLON") && !ui.GetBoolean("MATCHMAP")) { userGrp.AddKeyword(PvlKeyword("MaximumLongitude", - ui.GetDouble("MAXLON")),Pvl::Replace); + ui.GetDouble("MAXLON")), Pvl::Replace); } - if (ui.WasEntered("MINLAT") && !ui.GetBoolean("MATCHMAP")) { + if(ui.WasEntered("MINLAT") && !ui.GetBoolean("MATCHMAP")) { userGrp.AddKeyword(PvlKeyword("MinimumLatitude", - ui.GetDouble("MINLAT")),Pvl::Replace); + ui.GetDouble("MINLAT")), Pvl::Replace); } - if (ui.WasEntered("MAXLAT") && !ui.GetBoolean("MATCHMAP")) { + if(ui.WasEntered("MAXLAT") && !ui.GetBoolean("MATCHMAP")) { userGrp.AddKeyword(PvlKeyword("MaximumLatitude", - ui.GetDouble("MAXLAT")),Pvl::Replace); + ui.GetDouble("MAXLAT")), Pvl::Replace); } // If they want the res. from the mapfile, delete it from the camera so // nothing gets overriden - if (ui.GetString("PIXRES") == "MAP" || ui.GetBoolean("MATCHMAP")) { + if(ui.GetString("PIXRES") == "MAP" || ui.GetBoolean("MATCHMAP")) { camGrp.DeleteKeyword("PixelResolution"); } // Otherwise, delete any resolution keywords from the mapfile so the camera // info is propogated over - else if (ui.GetString("PIXRES") == "CAMERA") { - if (userGrp.HasKeyword("Scale")) { + else if(ui.GetString("PIXRES") == "CAMERA") { + if(userGrp.HasKeyword("Scale")) { userGrp.DeleteKeyword("Scale"); } - if (userGrp.HasKeyword("PixelResolution")) { + if(userGrp.HasKeyword("PixelResolution")) { userGrp.DeleteKeyword("PixelResolution"); } } // Copy any defaults that are not in the user map from the camera map file - for (int k=0; kIntersectsLongitudeDomain(userMap)) { - if (ui.GetString("LONSEAM") == "AUTO") { - if ((int) userGrp["LongitudeDomain"] == 360) { - userGrp.AddKeyword(PvlKeyword("LongitudeDomain",180), - Pvl::Replace); - if (incam->IntersectsLongitudeDomain(userMap)) { + if(incam->IntersectsLongitudeDomain(userMap)) { + if(ui.GetString("LONSEAM") == "AUTO") { + if((int) userGrp["LongitudeDomain"] == 360) { + userGrp.AddKeyword(PvlKeyword("LongitudeDomain", 180), + Pvl::Replace); + if(incam->IntersectsLongitudeDomain(userMap)) { // Its looks like a global image so switch back to the // users preference - userGrp.AddKeyword(PvlKeyword("LongitudeDomain",360), - Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("LongitudeDomain", 360), + Pvl::Replace); } } else { - userGrp.AddKeyword(PvlKeyword("LongitudeDomain",360), - Pvl::Replace); - if (incam->IntersectsLongitudeDomain(userMap)) { + userGrp.AddKeyword(PvlKeyword("LongitudeDomain", 360), + Pvl::Replace); + if(incam->IntersectsLongitudeDomain(userMap)) { // Its looks like a global image so switch back to the // users preference - userGrp.AddKeyword(PvlKeyword("LongitudeDomain",180), - Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("LongitudeDomain", 180), + Pvl::Replace); } } // Make the target info match the new longitude domain - double minlat,maxlat,minlon,maxlon; - incam->GroundRange(minlat,maxlat,minlon,maxlon,userMap); - if( !ui.WasEntered("MINLAT") ) { - userGrp.AddKeyword(PvlKeyword("MinimumLatitude",minlat),Pvl::Replace); + double minlat, maxlat, minlon, maxlon; + incam->GroundRange(minlat, maxlat, minlon, maxlon, userMap); + if(!ui.WasEntered("MINLAT")) { + userGrp.AddKeyword(PvlKeyword("MinimumLatitude", minlat), Pvl::Replace); } - if( !ui.WasEntered("MAXLAT") ) { - userGrp.AddKeyword(PvlKeyword("MaximumLatitude",maxlat),Pvl::Replace); + if(!ui.WasEntered("MAXLAT")) { + userGrp.AddKeyword(PvlKeyword("MaximumLatitude", maxlat), Pvl::Replace); } - if( !ui.WasEntered("MINLON") ) { - userGrp.AddKeyword(PvlKeyword("MinimumLongitude",minlon),Pvl::Replace); + if(!ui.WasEntered("MINLON")) { + userGrp.AddKeyword(PvlKeyword("MinimumLongitude", minlon), Pvl::Replace); } - if( !ui.WasEntered("MAXLON") ) { - userGrp.AddKeyword(PvlKeyword("MaximumLongitude",maxlon),Pvl::Replace); + if(!ui.WasEntered("MAXLON")) { + userGrp.AddKeyword(PvlKeyword("MaximumLongitude", maxlon), Pvl::Replace); } } - else if (ui.GetString("LONSEAM") == "ERROR") { + else if(ui.GetString("LONSEAM") == "ERROR") { string msg = "The image [" + ui.GetFilename("FROM") + "] crosses the " + - "longitude seam"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + "longitude seam"; + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } } // Use the updated label to create the output projection - int samples,lines; + int samples, lines; Projection *outmap; bool trim; // Determine the image size - if (ui.GetString("DEFAULTRANGE") == "MINIMIZE" && !ui.GetBoolean("MATCHMAP")) { - outmap = ProjectionFactory::CreateForCube(userMap,samples,lines,*incam); + if(ui.GetString("DEFAULTRANGE") == "MINIMIZE" && !ui.GetBoolean("MATCHMAP")) { + outmap = ProjectionFactory::CreateForCube(userMap, samples, lines, *incam); trim = false; } - else if (ui.GetString("DEFAULTRANGE") == "CAMERA" && !ui.GetBoolean("MATCHMAP")) { - outmap = ProjectionFactory::CreateForCube(userMap,samples,lines,false); + else if(ui.GetString("DEFAULTRANGE") == "CAMERA" && !ui.GetBoolean("MATCHMAP")) { + outmap = ProjectionFactory::CreateForCube(userMap, samples, lines, false); trim = ui.GetBoolean("TRIM"); } else { // DEFAULTRANGE = MAP - outmap = ProjectionFactory::CreateForCube(userMap,samples,lines, - ui.GetBoolean("MATCHMAP")); + outmap = ProjectionFactory::CreateForCube(userMap, samples, lines, + ui.GetBoolean("MATCHMAP")); trim = ui.GetBoolean("TRIM"); } @@ -235,58 +235,58 @@ void IsisMain() { // Set up the transform object which will simply map // output line/samps -> output lat/lons -> input line/samps - Transform *transform = new cam2map (icube->Samples(), - icube->Lines(), - incam, - samples, - lines, - outmap, - trim); + Transform *transform = new cam2map(icube->Samples(), + icube->Lines(), + incam, + samples, + lines, + outmap, + trim); // Allocate the output cube and add the mapping labels - Cube *ocube = p.SetOutputCube ("TO", transform->OutputSamples(), - transform->OutputLines(), - icube->Bands()); + Cube *ocube = p.SetOutputCube("TO", transform->OutputSamples(), + transform->OutputLines(), + icube->Bands()); ocube->PutGroup(userGrp); // Set up the interpolator Interpolator *interp = NULL; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } // See if we need to deal with band dependent camera models - if (!incam->IsBandIndependent()) { + if(!incam->IsBandIndependent()) { p.BandChange(BandChange); } // See if center of input image projects. If it does, force tile // containing this center to be processed in ProcessRubberSheet. - double centerSamp = icube->Samples () / 2.; - double centerLine = icube->Lines () / 2.; - if (incam->SetImage(centerSamp,centerLine)) { - if (outmap->SetUniversalGround(incam->UniversalLatitude(), - incam->UniversalLongitude())) { - p.ForceTile (outmap->WorldX(),outmap->WorldY ()); + double centerSamp = icube->Samples() / 2.; + double centerLine = icube->Lines() / 2.; + if(incam->SetImage(centerSamp, centerLine)) { + if(outmap->SetUniversalGround(incam->UniversalLatitude(), + incam->UniversalLongitude())) { + p.ForceTile(outmap->WorldX(), outmap->WorldY()); } } // Create an alpha cube group for the output cube - if (!ocube->HasGroup("AlphaCube")) { + if(!ocube->HasGroup("AlphaCube")) { PvlGroup alpha("AlphaCube"); - alpha += PvlKeyword("AlphaSamples",icube->Samples()); - alpha += PvlKeyword("AlphaLines",icube->Lines()); - alpha += PvlKeyword("AlphaStartingSample",0.5); - alpha += PvlKeyword("AlphaStartingLine",0.5); - alpha += PvlKeyword("AlphaEndingSample",icube->Samples()+0.5); - alpha += PvlKeyword("AlphaEndingLine",icube->Lines()+0.5); - alpha += PvlKeyword("BetaSamples",icube->Samples()); - alpha += PvlKeyword("BetaLines",icube->Lines()); + alpha += PvlKeyword("AlphaSamples", icube->Samples()); + alpha += PvlKeyword("AlphaLines", icube->Lines()); + alpha += PvlKeyword("AlphaStartingSample", 0.5); + alpha += PvlKeyword("AlphaStartingLine", 0.5); + alpha += PvlKeyword("AlphaEndingSample", icube->Samples() + 0.5); + alpha += PvlKeyword("AlphaEndingLine", icube->Lines() + 0.5); + alpha += PvlKeyword("BetaSamples", icube->Samples()); + alpha += PvlKeyword("BetaLines", icube->Lines()); ocube->PutGroup(alpha); } @@ -295,8 +295,8 @@ void IsisMain() { p.EndProcess(); // add mapping to print.prt - PvlGroup mapping = outmap->Mapping(); - Application::Log(mapping); + PvlGroup mapping = outmap->Mapping(); + Application::Log(mapping); // Cleanup delete outmap; @@ -305,10 +305,10 @@ void IsisMain() { } // Transform object constructor -cam2map::cam2map (const int inputSamples, const int inputLines, - Camera *incam, const int outputSamples, - const int outputLines, Projection *outmap, - bool trim) { +cam2map::cam2map(const int inputSamples, const int inputLines, + Camera *incam, const int outputSamples, + const int outputLines, Projection *outmap, + bool trim) { p_inputSamples = inputSamples; p_inputLines = inputLines; p_incam = incam; @@ -321,30 +321,30 @@ cam2map::cam2map (const int inputSamples, const int inputLines, } // Transform method mapping output line/samps to lat/lons to input line/samps -bool cam2map::Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { +bool cam2map::Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { // See if the output image coordinate converts to lat/lon - if (!p_outmap->SetWorld(outSample,outLine)) return false; + if(!p_outmap->SetWorld(outSample, outLine)) return false; // See if we should trim - if ((p_trim) && (p_outmap->HasGroundRange())) { - if (p_outmap->Latitude() < p_outmap->MinimumLatitude()) return false; - if (p_outmap->Latitude() > p_outmap->MaximumLatitude()) return false; - if (p_outmap->Longitude() < p_outmap->MinimumLongitude()) return false; - if (p_outmap->Longitude() > p_outmap->MaximumLongitude()) return false; + if((p_trim) && (p_outmap->HasGroundRange())) { + if(p_outmap->Latitude() < p_outmap->MinimumLatitude()) return false; + if(p_outmap->Latitude() > p_outmap->MaximumLatitude()) return false; + if(p_outmap->Longitude() < p_outmap->MinimumLongitude()) return false; + if(p_outmap->Longitude() > p_outmap->MaximumLongitude()) return false; } // Get the universal lat/lon and see if it can be converted to input line/samp double lat = p_outmap->UniversalLatitude(); double lon = p_outmap->UniversalLongitude(); - if (!p_incam->SetUniversalGround(lat,lon)) return false; + if(!p_incam->SetUniversalGround(lat, lon)) return false; // Make sure the point is inside the input image - if (p_incam->Sample() < 0.5) return false; - if (p_incam->Line() < 0.5) return false; - if (p_incam->Sample() > p_inputSamples + 0.5) return false; - if (p_incam->Line() > p_inputLines + 0.5) return false; + if(p_incam->Sample() < 0.5) return false; + if(p_incam->Line() < 0.5) return false; + if(p_incam->Sample() > p_inputSamples + 0.5) return false; + if(p_incam->Line() > p_inputLines + 0.5) return false; // Everything is good inSample = p_incam->Sample(); @@ -353,15 +353,15 @@ bool cam2map::Xform (double &inSample, double &inLine, return true; } -int cam2map::OutputSamples () const { +int cam2map::OutputSamples() const { return p_outputSamples; } -int cam2map::OutputLines () const { +int cam2map::OutputLines() const { return p_outputLines; } -void BandChange (const int band) { +void BandChange(const int band) { incam->SetBand(band); } @@ -372,42 +372,42 @@ void PrintMap() { // Get mapping group from map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); //Write map file out to the log Isis::Application::GuiLog(userGrp); } // Helper function to get mapping resolution. -void LoadMapRes () { +void LoadMapRes() { UserInterface &ui = Application::GetUserInterface(); // Get mapping group from map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); // Set resolution - if (userGrp.HasKeyword("Scale")) { + if(userGrp.HasKeyword("Scale")) { ui.Clear("RESOLUTION"); - ui.PutDouble("RESOLUTION",userGrp["Scale"]); + ui.PutDouble("RESOLUTION", userGrp["Scale"]); ui.Clear("PIXRES"); - ui.PutAsString("PIXRES","PPD"); + ui.PutAsString("PIXRES", "PPD"); } - else if (userGrp.HasKeyword("PixelResolution")) { + else if(userGrp.HasKeyword("PixelResolution")) { ui.Clear("RESOLUTION"); - ui.PutDouble("RESOLUTION",userGrp["PixelResolution"]); + ui.PutDouble("RESOLUTION", userGrp["PixelResolution"]); ui.Clear("PIXRES"); - ui.PutAsString("PIXRES","MPP"); + ui.PutAsString("PIXRES", "MPP"); } else { string msg = "No resolution value found in [" + ui.GetFilename("MAP") + "]"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } //Helper function to get camera resolution. -void LoadCameraRes () { +void LoadCameraRes() { UserInterface &ui = Application::GetUserInterface(); string file = ui.GetFilename("FROM"); @@ -420,10 +420,10 @@ void LoadCameraRes () { PvlGroup &camGrp = camMap.FindGroup("Mapping"); ui.Clear("RESOLUTION"); - ui.PutDouble("RESOLUTION",camGrp["PixelResolution"]); + ui.PutDouble("RESOLUTION", camGrp["PixelResolution"]); ui.Clear("PIXRES"); - ui.PutAsString("PIXRES","MPP"); + ui.PutAsString("PIXRES", "MPP"); } //Helper function to get ground range from map file. @@ -433,7 +433,7 @@ void LoadMapRange() { // Get map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); // Set ground range keywords that are found in mapfile int count = 0; @@ -441,36 +441,36 @@ void LoadMapRange() { ui.Clear("MAXLAT"); ui.Clear("MINLON"); ui.Clear("MAXLON"); - if (userGrp.HasKeyword("MinimumLatitude")) { - ui.PutDouble("MINLAT",userGrp["MinimumLatitude"]); + if(userGrp.HasKeyword("MinimumLatitude")) { + ui.PutDouble("MINLAT", userGrp["MinimumLatitude"]); count++; } - if (userGrp.HasKeyword("MaximumLatitude")) { - ui.PutDouble("MAXLAT",userGrp["MaximumLatitude"]); + if(userGrp.HasKeyword("MaximumLatitude")) { + ui.PutDouble("MAXLAT", userGrp["MaximumLatitude"]); count++; } - if (userGrp.HasKeyword("MinimumLongitude")) { - ui.PutDouble("MINLON",userGrp["MinimumLongitude"]); + if(userGrp.HasKeyword("MinimumLongitude")) { + ui.PutDouble("MINLON", userGrp["MinimumLongitude"]); count++; } - if (userGrp.HasKeyword("MaximumLongitude")) { - ui.PutDouble("MAXLON",userGrp["MaximumLongitude"]); + if(userGrp.HasKeyword("MaximumLongitude")) { + ui.PutDouble("MAXLON", userGrp["MaximumLongitude"]); count++; } // Set default ground range param to map ui.Clear("DEFAULTRANGE"); - ui.PutAsString("DEFAULTRANGE","MAP"); + ui.PutAsString("DEFAULTRANGE", "MAP"); - if (count < 4) { + if(count < 4) { string msg = "One or more of the values for the ground range was not found"; msg += " in [" + ui.GetFilename("MAP") + "]"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } //Helper function to load camera range. -void LoadCameraRange () { +void LoadCameraRange() { UserInterface &ui = Application::GetUserInterface(); string file = ui.GetFilename("FROM"); @@ -484,21 +484,21 @@ void LoadCameraRange () { Camera *cam = c.Camera(); // Make the target info match the user mapfile - double minlat,maxlat,minlon,maxlon; - cam->GroundRange(minlat,maxlat,minlon,maxlon,userMap); + double minlat, maxlat, minlon, maxlon; + cam->GroundRange(minlat, maxlat, minlon, maxlon, userMap); // Set ground range parameters in UI ui.Clear("MINLAT"); - ui.PutDouble("MINLAT",minlat); + ui.PutDouble("MINLAT", minlat); ui.Clear("MAXLAT"); - ui.PutDouble("MAXLAT",maxlat); + ui.PutDouble("MAXLAT", maxlat); ui.Clear("MINLON"); - ui.PutDouble("MINLON",minlon); + ui.PutDouble("MINLON", minlon); ui.Clear("MAXLON"); - ui.PutDouble("MAXLON",maxlon); + ui.PutDouble("MAXLON", maxlon); // Set default ground range param to camera ui.Clear("DEFAULTRANGE"); - ui.PutAsString("DEFAULTRANGE","CAMERA"); + ui.PutAsString("DEFAULTRANGE", "CAMERA"); } diff --git a/isis/src/base/apps/cam2map/cam2map.h b/isis/src/base/apps/cam2map/cam2map.h index ecd2bca6c9..020f7cd06f 100644 --- a/isis/src/base/apps/cam2map/cam2map.h +++ b/isis/src/base/apps/cam2map/cam2map.h @@ -15,18 +15,18 @@ class cam2map : public Isis::Transform { public: // constructor - cam2map (const int inputSamples, const int inputLines, Isis::Camera *incam, - const int outputSamples, const int outputLines, Isis::Projection *outmap, - bool trim); - + cam2map(const int inputSamples, const int inputLines, Isis::Camera *incam, + const int outputSamples, const int outputLines, Isis::Projection *outmap, + bool trim); + // destructor - ~cam2map () {}; + ~cam2map() {}; // Implementations for parent's pure virtual members - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine); - int OutputSamples () const; - int OutputLines () const; + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine); + int OutputSamples() const; + int OutputLines() const; }; #endif diff --git a/isis/src/base/apps/caminfo/CamTools.cpp b/isis/src/base/apps/caminfo/CamTools.cpp index 1805d9128e..2aa2248cbd 100644 --- a/isis/src/base/apps/caminfo/CamTools.cpp +++ b/isis/src/base/apps/caminfo/CamTools.cpp @@ -1,25 +1,25 @@ -/* @file +/* @file * $Revision: 1.16 $ * $Date: 2009/12/29 23:03:47 $ * $Id: CamTools.cpp,v 1.16 2009/12/29 23:03:47 ehyer Exp $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privdacy.html. - */ + * http://www.usgs.gov/privdacy.html. + */ #include #include #include @@ -52,662 +52,663 @@ using namespace std; namespace Isis { -/** - * @brief Round values to specified precision - * - * @param value Value to round - * @param precision Precision to round value to - * - * @return double Rounded value - */ -inline double SetRound(double value, const int precision) { + /** + * @brief Round values to specified precision + * + * @param value Value to round + * @param precision Precision to round value to + * + * @return double Rounded value + */ + inline double SetRound(double value, const int precision) { double scale = pow(10.0, precision); value = round(value * scale) / scale; return (value); -} - -/** - * @brief Helper function to convert values to doubles - * - * @param T Type of value to convert - * @param value Value to convert - * - * @return double Converted value - */ -template double ToDouble(const T &value) { + } + + /** + * @brief Helper function to convert values to doubles + * + * @param T Type of value to convert + * @param value Value to convert + * + * @return double Converted value + */ + template double ToDouble(const T &value) { return (iString(value).Trim(" \r\t\n").ToDouble()); -} - -/** - * @brief Helper function to convert values to strings - * - * @param T Type of value to convert - * @param value Value to convert - * - * @return string Converted value - */ -template std::string ToString(const T &value) { + } + + /** + * @brief Helper function to convert values to strings + * + * @param T Type of value to convert + * @param value Value to convert + * + * @return string Converted value + */ + template std::string ToString(const T &value) { return (iString(value).Trim(" \r\t\n")); -} - - - -bool BandGeometry::isPointValid(const double &sample, const double &line, - const Camera *camera) const { - int nl(_nLines), ns(_nSamps); - if ( camera != 0 ) { - nl = camera->Lines(); - ns = camera->Samples(); - } - - if (line < 0.5) return (false); - if (line > (nl+0.5)) return (false); - if (sample < 0.5) return (false); - if (sample > (ns+0.5)) return (false); - return (true); -} - -bool BandGeometry::hasCenterGeometry() const { - BandPropertiesListConstIter b; - for ( b = _gBandList.begin() ; b != _gBandList.end() ; ++b ) { - if ( !IsSpecial(b->centerLatitude) ) return (true); - } - // No valid center exists - return (false); -} - -/** - * @brief Check geometry for presence of limb - * - * This method checks corner geometry coordinates for the presence of a planet - * limb. This is a simple check for validity of the latitude coordinate at each - * image corner. If any of them are invalid (Nulls), then it is deamed to have - * a limb in the image. - * - * Note that this check is only valid if the determination of the geometry has - * been performed. So care should be used as to when this check is made. - * - * - * @return bool True if one of the corner latitude coordinates is NULL. - */ -bool BandGeometry::hasLimb() const { - BandPropertiesListConstIter b; - for ( b = _gBandList.begin() ; b != _gBandList.end() ; ++b ) { - if ( IsSpecial(b->upperLeftLatitude) ) return (true); - if ( IsSpecial(b->upperRightLatitude) ) return (true); - if ( IsSpecial(b->lowerRightLatitude) ) return (true); - if ( IsSpecial(b->lowerLeftLatitude) ) return (true); - } - // All outer geometry points are defined - return (false); -} - - -void BandGeometry::destruct() { - // Ensure this can be applied for reentrant operations - _gBandList.clear(); - for_each(_polys.begin(), _polys.end(), DeleteObject()); - delete _combined; - _combined = 0; - _radius = 1.0; -} - -void BandGeometry::collect(Camera &camera, Cube &cube, bool doGeometry, - bool doPolygon) { - destruct(); - - _nLines = cube.Lines(); - _nSamps = cube.Samples(); - _nBands = cube.Bands(); - - // Compute average planetary radius in meters. This is used as a fallback - // to compute surface area if no geoemetry has a center intersect point. - double radii[3]; - camera.Radii(radii); - _radius = (radii[0] + radii[1] + radii[2]) / 3.0 * 1000.0; - - double cLine = _nLines; - double cSamp = _nSamps; - double centerLine = cLine / 2.0; - double centerSamp = cSamp / 2.0; - - // Check to determine if geometry is band independant - _isBandIndependent = camera.IsBandIndependent(); - _hasCenterGeom = false; - int nbands = (_isBandIndependent ? 1 : _nBands); - for ( int band = 0 ; band < nbands ; band++ ) { - // Compute band geometry properties - GProperties g; - g.lines = _nLines; - g.samples = _nSamps; - g.bands = _nBands; - g.band = band + 1; - camera.SetBand(band+1); - g.realBand = cube.PhysicalBand(band+1); - - - g.target = camera.Target(); - - iTime t1(camera.CacheStartTime()); - g.startTime = t1.UTC(); - iTime t2(camera.CacheEndTime()); - g.endTime = t2.UTC(); - - g.centerLine = centerLine; - g.centerSamp = centerSamp; - - // Now compute elements for the center pixel - if (camera.SetImage(centerSamp,centerLine)) { - _hasCenterGeom = true; - g.centerLatitude = camera.UniversalLatitude(); - g.centerLongitude = camera.UniversalLongitude(); - g.radius = camera.LocalRadius(); - - g.rightAscension = camera.RightAscension(); - g.declination = camera.Declination(); - - g.sampRes = camera.SampleResolution(); - g.lineRes = camera.LineResolution(); - - g.solarLongitude = camera.SolarLongitude(); - g.northAzimuth = camera.NorthAzimuth(); - g.offNader = camera.OffNadirAngle(); - g.subSolarAzimuth = camera.SunAzimuth(); - g.subSpacecraftAzimuth = camera.SpacecraftAzimuth(); - g.localSolartime = camera.LocalSolarTime(); - g.targetCenterDistance = camera.TargetCenterDistance(); - g.slantDistance = camera.SlantDistance(); - - camera.SubSolarPoint(g.subSolarLatitude,g.subSolarLongitude); - g.subSolarGroundAzimuth = camera.GroundAzimuth(g.centerLatitude, - g.centerLongitude, - g.subSolarLatitude, - g.subSolarLongitude); - camera.SubSpacecraftPoint(g.subSpacecraftLatitude,g.subSpacecraftLongitude); - g.subSpacecraftGroundAzimuth = camera.GroundAzimuth(g.centerLatitude, - g.centerLongitude, - g.subSpacecraftLatitude, - g.subSpacecraftLongitude); + } - // solve for the parallax and shadow stuff - g.phase = camera.PhaseAngle(); - g.emi = camera.EmissionAngle(); - g.inc = camera.IncidenceAngle(); - - // Need some radian values - if ( !IsSpecial(g.emi) && !IsSpecial(g.subSpacecraftAzimuth) ) { - double emi_r = DegToRad(g.emi); - g.parallaxx = RadToDeg(-tan(emi_r)*cos(DegToRad(g.subSpacecraftAzimuth))); - g.parallaxy = RadToDeg(tan(emi_r)*sin(DegToRad(g.subSpacecraftAzimuth))); } - - if ( !IsSpecial(g.inc) && !IsSpecial(g.subSolarAzimuth) ) { - double inc_r = DegToRad(g.inc); - g.shadowx = RadToDeg(-tan(inc_r)*cos(DegToRad(g.subSolarAzimuth))); - g.shadowy = RadToDeg(tan(inc_r)*sin(DegToRad(g.subSolarAzimuth))); - } - } - // OK...now get corner pixel geometry. NOTE this resets image - // pixel location from center!!! - if ( camera.SetImage(1.0, 1.0) ) { - g.upperLeftLongitude = camera.UniversalLongitude(); - g.upperLeftLatitude = camera.UniversalLatitude(); - } - if ( camera.SetImage(1.0, cLine) ) { - g.lowerLeftLongitude = camera.UniversalLongitude(); - g.lowerLeftLatitude = camera.UniversalLatitude(); + bool BandGeometry::isPointValid(const double &sample, const double &line, + const Camera *camera) const { + int nl(_nLines), ns(_nSamps); + if(camera != 0) { + nl = camera->Lines(); + ns = camera->Samples(); } - if ( camera.SetImage(cSamp, cLine) ) { - g.lowerRightLongitude = camera.UniversalLongitude(); - g.lowerRightLatitude = camera.UniversalLatitude(); - } + if(line < 0.5) return (false); + if(line > (nl + 0.5)) return (false); + if(sample < 0.5) return (false); + if(sample > (ns + 0.5)) return (false); + return (true); + } - if ( camera.SetImage(cSamp, 1.0) ) { - g.upperRightLongitude = camera.UniversalLongitude(); - g.upperRightLatitude = camera.UniversalLatitude(); + bool BandGeometry::hasCenterGeometry() const { + BandPropertiesListConstIter b; + for(b = _gBandList.begin() ; b != _gBandList.end() ; ++b) { + if(!IsSpecial(b->centerLatitude)) return (true); } + // No valid center exists + return (false); + } - double minRes = camera.LowestImageResolution(); - double maxRes = camera.HighestImageResolution(); - if ( !(IsSpecial(minRes) || IsSpecial(maxRes)) ) { - g.grRes = (minRes+maxRes)/2.0; + /** + * @brief Check geometry for presence of limb + * + * This method checks corner geometry coordinates for the presence of a planet + * limb. This is a simple check for validity of the latitude coordinate at each + * image corner. If any of them are invalid (Nulls), then it is deamed to have + * a limb in the image. + * + * Note that this check is only valid if the determination of the geometry has + * been performed. So care should be used as to when this check is made. + * + * + * @return bool True if one of the corner latitude coordinates is NULL. + */ + bool BandGeometry::hasLimb() const { + BandPropertiesListConstIter b; + for(b = _gBandList.begin() ; b != _gBandList.end() ; ++b) { + if(IsSpecial(b->upperLeftLatitude)) return (true); + if(IsSpecial(b->upperRightLatitude)) return (true); + if(IsSpecial(b->lowerRightLatitude)) return (true); + if(IsSpecial(b->lowerLeftLatitude)) return (true); } + // All outer geometry points are defined + return (false); + } + - Pvl camMap; - camera.BasicMapping(camMap); - _mapping = camMap; + void BandGeometry::destruct() { + // Ensure this can be applied for reentrant operations + _gBandList.clear(); + for_each(_polys.begin(), _polys.end(), DeleteObject()); + delete _combined; + _combined = 0; + _radius = 1.0; + } - // Test for interesting intersections - if (camera.IntersectsLongitudeDomain(camMap)) g.hasLongitudeBoundary = true; - camera.SetBand(band+1); - if (camera.SetUniversalGround(90.0, 0.0)) { - if ( isPointValid(camera.Sample(), camera.Line(), &camera) ) { - g.hasNorthPole = true; + void BandGeometry::collect(Camera &camera, Cube &cube, bool doGeometry, + bool doPolygon) { + destruct(); + + _nLines = cube.Lines(); + _nSamps = cube.Samples(); + _nBands = cube.Bands(); + + // Compute average planetary radius in meters. This is used as a fallback + // to compute surface area if no geoemetry has a center intersect point. + double radii[3]; + camera.Radii(radii); + _radius = (radii[0] + radii[1] + radii[2]) / 3.0 * 1000.0; + + double cLine = _nLines; + double cSamp = _nSamps; + double centerLine = cLine / 2.0; + double centerSamp = cSamp / 2.0; + + // Check to determine if geometry is band independant + _isBandIndependent = camera.IsBandIndependent(); + _hasCenterGeom = false; + int nbands = (_isBandIndependent ? 1 : _nBands); + for(int band = 0 ; band < nbands ; band++) { + // Compute band geometry properties + GProperties g; + g.lines = _nLines; + g.samples = _nSamps; + g.bands = _nBands; + g.band = band + 1; + camera.SetBand(band + 1); + g.realBand = cube.PhysicalBand(band + 1); + + + g.target = camera.Target(); + + iTime t1(camera.CacheStartTime()); + g.startTime = t1.UTC(); + iTime t2(camera.CacheEndTime()); + g.endTime = t2.UTC(); + + g.centerLine = centerLine; + g.centerSamp = centerSamp; + + // Now compute elements for the center pixel + if(camera.SetImage(centerSamp, centerLine)) { + _hasCenterGeom = true; + g.centerLatitude = camera.UniversalLatitude(); + g.centerLongitude = camera.UniversalLongitude(); + g.radius = camera.LocalRadius(); + + g.rightAscension = camera.RightAscension(); + g.declination = camera.Declination(); + + g.sampRes = camera.SampleResolution(); + g.lineRes = camera.LineResolution(); + + g.solarLongitude = camera.SolarLongitude(); + g.northAzimuth = camera.NorthAzimuth(); + g.offNader = camera.OffNadirAngle(); + g.subSolarAzimuth = camera.SunAzimuth(); + g.subSpacecraftAzimuth = camera.SpacecraftAzimuth(); + g.localSolartime = camera.LocalSolarTime(); + g.targetCenterDistance = camera.TargetCenterDistance(); + g.slantDistance = camera.SlantDistance(); + + camera.SubSolarPoint(g.subSolarLatitude, g.subSolarLongitude); + g.subSolarGroundAzimuth = camera.GroundAzimuth(g.centerLatitude, + g.centerLongitude, + g.subSolarLatitude, + g.subSolarLongitude); + camera.SubSpacecraftPoint(g.subSpacecraftLatitude, g.subSpacecraftLongitude); + g.subSpacecraftGroundAzimuth = camera.GroundAzimuth(g.centerLatitude, + g.centerLongitude, + g.subSpacecraftLatitude, + g.subSpacecraftLongitude); + + + // solve for the parallax and shadow stuff + g.phase = camera.PhaseAngle(); + g.emi = camera.EmissionAngle(); + g.inc = camera.IncidenceAngle(); + + // Need some radian values + if(!IsSpecial(g.emi) && !IsSpecial(g.subSpacecraftAzimuth)) { + double emi_r = DegToRad(g.emi); + g.parallaxx = RadToDeg(-tan(emi_r) * cos(DegToRad(g.subSpacecraftAzimuth))); + g.parallaxy = RadToDeg(tan(emi_r) * sin(DegToRad(g.subSpacecraftAzimuth))); + } + + if(!IsSpecial(g.inc) && !IsSpecial(g.subSolarAzimuth)) { + double inc_r = DegToRad(g.inc); + g.shadowx = RadToDeg(-tan(inc_r) * cos(DegToRad(g.subSolarAzimuth))); + g.shadowy = RadToDeg(tan(inc_r) * sin(DegToRad(g.subSolarAzimuth))); + } } - } - if (camera.SetUniversalGround(-90.0, 0.0)) { - if ( isPointValid(camera.Sample(), camera.Line(), &camera) ) { - g.hasSouthPole = true; + // OK...now get corner pixel geometry. NOTE this resets image + // pixel location from center!!! + if(camera.SetImage(1.0, 1.0)) { + g.upperLeftLongitude = camera.UniversalLongitude(); + g.upperLeftLatitude = camera.UniversalLatitude(); } - } - if ( doPolygon ) { - // Now compute the the image polygon - ImagePolygon poly; - poly.Incidence(_maxIncidence); - poly.Emission(_maxEmission); - poly.EllipsoidLimb(true); // Allow disabling of shape model for limbs - poly.Create(cube,_pixinc,_pixinc,1,1,0,0,band+1); - geos::geom::MultiPolygon *multiP = poly.Polys(); - _polys.push_back(multiP->clone()); - if (_combined == 0) { - _combined = multiP->clone(); + if(camera.SetImage(1.0, cLine)) { + g.lowerLeftLongitude = camera.UniversalLongitude(); + g.lowerLeftLatitude = camera.UniversalLatitude(); } - else { - // Construct composite (union) polygon - geos::geom::Geometry *old(_combined); - _combined = old->Union(multiP); - delete old; + + if(camera.SetImage(cSamp, cLine)) { + g.lowerRightLongitude = camera.UniversalLongitude(); + g.lowerRightLatitude = camera.UniversalLatitude(); } - - // multiP is freed by ImagePolygon object - _mapping = getProjGeometry(camera, multiP, g); - } - // Save off this band geometry property - _gBandList.push_back(g); - } + if(camera.SetImage(cSamp, 1.0)) { + g.upperRightLongitude = camera.UniversalLongitude(); + g.upperRightLatitude = camera.UniversalLatitude(); + } - // Compute the remainder of the summary bands since some of the operations - // need the camera model - _summary = getGeometrySummary(); - if ( (size() != 1) && (doPolygon)) { - geos::geom::MultiPolygon *multiP = makeMultiPolygon(_combined); - _mapping = getProjGeometry(camera, multiP, _summary); - delete multiP; - } + double minRes = camera.LowestImageResolution(); + double maxRes = camera.HighestImageResolution(); + if(!(IsSpecial(minRes) || IsSpecial(maxRes))) { + g.grRes = (minRes + maxRes) / 2.0; + } - return; -} + Pvl camMap; + camera.BasicMapping(camMap); + _mapping = camMap; + + // Test for interesting intersections + if(camera.IntersectsLongitudeDomain(camMap)) g.hasLongitudeBoundary = true; + camera.SetBand(band + 1); + if(camera.SetUniversalGround(90.0, 0.0)) { + if(isPointValid(camera.Sample(), camera.Line(), &camera)) { + g.hasNorthPole = true; + } + } + if(camera.SetUniversalGround(-90.0, 0.0)) { + if(isPointValid(camera.Sample(), camera.Line(), &camera)) { + g.hasSouthPole = true; + } + } + if(doPolygon) { + // Now compute the the image polygon + ImagePolygon poly; + poly.Incidence(_maxIncidence); + poly.Emission(_maxEmission); + poly.EllipsoidLimb(true); // Allow disabling of shape model for limbs + poly.Create(cube, _pixinc, _pixinc, 1, 1, 0, 0, band + 1); + geos::geom::MultiPolygon *multiP = poly.Polys(); + _polys.push_back(multiP->clone()); + if(_combined == 0) { + _combined = multiP->clone(); + } + else { + // Construct composite (union) polygon + geos::geom::Geometry *old(_combined); + _combined = old->Union(multiP); + delete old; + } + + // multiP is freed by ImagePolygon object + _mapping = getProjGeometry(camera, multiP, g); + } -void BandGeometry::generateGeometryKeys(PvlObject &pband) { - if ( size() <= 0 ) { - std::string mess = "No Band geometry available!"; - iException::Message(iException::Programmer, mess, _FILEINFO_); - } + // Save off this band geometry property + _gBandList.push_back(g); + } - GProperties g = getGeometrySummary(); + // Compute the remainder of the summary bands since some of the operations + // need the camera model + _summary = getGeometrySummary(); + if((size() != 1) && (doPolygon)) { + geos::geom::MultiPolygon *multiP = makeMultiPolygon(_combined); + _mapping = getProjGeometry(camera, multiP, _summary); + delete multiP; + } -//geometry keywords for band output - pband += PvlKeyword("BandsUsed", size()); - pband += PvlKeyword("ReferenceBand", g.band); - pband += PvlKeyword("OriginalBand", g.realBand); - - pband += PvlKeyword("Target", g.target); - - pband += PvlKeyword("StartTime",g.startTime); - pband += PvlKeyword("EndTime",g.endTime); - - pband += ValidateKey("CenterLine",g.centerLine); - pband += ValidateKey("CenterSample",g.centerSamp); - pband += ValidateKey("CenterLatitude",g.centerLatitude); - pband += ValidateKey("CenterLongitude",g.centerLongitude); - pband += ValidateKey("CenterRadius",g.radius); - - pband += ValidateKey("RightAscension",g.rightAscension); - pband += ValidateKey("Declination",g.declination); - - pband += ValidateKey("UpperLeftLongitude",g.upperLeftLongitude); - pband += ValidateKey("UpperLeftLatitude",g.upperLeftLatitude); - pband += ValidateKey("LowerLeftLongitude",g.lowerLeftLongitude); - pband += ValidateKey("LowerLeftLatitude",g.lowerLeftLatitude); - pband += ValidateKey("LowerRightLongitude",g.lowerRightLongitude); - pband += ValidateKey("LowerRightLatitude",g.lowerRightLatitude); - pband += ValidateKey("UpperRightLongitude",g.upperRightLongitude); - pband += ValidateKey("UpperRightLatitude",g.upperRightLatitude); - - pband += ValidateKey("PhaseAngle",g.phase); - pband += ValidateKey("EmissionAngle",g.emi); - pband += ValidateKey("IncidenceAngle",g.inc); - - pband += ValidateKey("NorthAzimuth",g.northAzimuth); - pband += ValidateKey("OffNadir",g.offNader); - pband += ValidateKey("SolarLongitude",g.solarLongitude); - pband += ValidateKey("LocalTime",g.localSolartime); - pband += ValidateKey("TargetCenterDistance",g.targetCenterDistance); - pband += ValidateKey("SlantDistance",g.slantDistance); - - double aveRes(Null); - if (!IsSpecial(g.sampRes) && !IsSpecial(g.lineRes)) { - aveRes = (g.sampRes + g.lineRes) / 2.0; + return; } - pband += ValidateKey("SampleResolution",g.sampRes); - pband += ValidateKey("LineResolution",g.lineRes); - pband += ValidateKey("PixelResolution",aveRes); - pband += ValidateKey("MeanGroundResolution",g.grRes); - pband += ValidateKey("SubSolarAzimuth",g.subSolarAzimuth); - pband += ValidateKey("SubSolarGroundAzimuth",g.subSolarGroundAzimuth); - pband += ValidateKey("SubSolarLatitude", g.subSolarLatitude); - pband += ValidateKey("SubSolarLongitude",g.subSolarLongitude); + void BandGeometry::generateGeometryKeys(PvlObject &pband) { + if(size() <= 0) { + std::string mess = "No Band geometry available!"; + iException::Message(iException::Programmer, mess, _FILEINFO_); + } - pband += ValidateKey("SubSpacecraftAzimuth", g.subSpacecraftAzimuth); - pband += ValidateKey("SubSpacecraftGroundAzimuth", g.subSpacecraftGroundAzimuth); - pband += ValidateKey("SubSpacecraftLatitude",g.subSpacecraftLatitude); - pband += ValidateKey("SubSpacecraftLongitude",g.subSpacecraftLongitude); + GProperties g = getGeometrySummary(); - pband += ValidateKey("ParallaxX",g.parallaxx); - pband += ValidateKey("ParallaxY",g.parallaxy); +//geometry keywords for band output + pband += PvlKeyword("BandsUsed", size()); + pband += PvlKeyword("ReferenceBand", g.band); + pband += PvlKeyword("OriginalBand", g.realBand); + + pband += PvlKeyword("Target", g.target); + + pband += PvlKeyword("StartTime", g.startTime); + pband += PvlKeyword("EndTime", g.endTime); + + pband += ValidateKey("CenterLine", g.centerLine); + pband += ValidateKey("CenterSample", g.centerSamp); + pband += ValidateKey("CenterLatitude", g.centerLatitude); + pband += ValidateKey("CenterLongitude", g.centerLongitude); + pband += ValidateKey("CenterRadius", g.radius); + + pband += ValidateKey("RightAscension", g.rightAscension); + pband += ValidateKey("Declination", g.declination); + + pband += ValidateKey("UpperLeftLongitude", g.upperLeftLongitude); + pband += ValidateKey("UpperLeftLatitude", g.upperLeftLatitude); + pband += ValidateKey("LowerLeftLongitude", g.lowerLeftLongitude); + pband += ValidateKey("LowerLeftLatitude", g.lowerLeftLatitude); + pband += ValidateKey("LowerRightLongitude", g.lowerRightLongitude); + pband += ValidateKey("LowerRightLatitude", g.lowerRightLatitude); + pband += ValidateKey("UpperRightLongitude", g.upperRightLongitude); + pband += ValidateKey("UpperRightLatitude", g.upperRightLatitude); + + pband += ValidateKey("PhaseAngle", g.phase); + pband += ValidateKey("EmissionAngle", g.emi); + pband += ValidateKey("IncidenceAngle", g.inc); + + pband += ValidateKey("NorthAzimuth", g.northAzimuth); + pband += ValidateKey("OffNadir", g.offNader); + pband += ValidateKey("SolarLongitude", g.solarLongitude); + pband += ValidateKey("LocalTime", g.localSolartime); + pband += ValidateKey("TargetCenterDistance", g.targetCenterDistance); + pband += ValidateKey("SlantDistance", g.slantDistance); + + double aveRes(Null); + if(!IsSpecial(g.sampRes) && !IsSpecial(g.lineRes)) { + aveRes = (g.sampRes + g.lineRes) / 2.0; + } - pband += ValidateKey("ShadowX",g.shadowx); - pband += ValidateKey("ShadowY",g.shadowy); + pband += ValidateKey("SampleResolution", g.sampRes); + pband += ValidateKey("LineResolution", g.lineRes); + pband += ValidateKey("PixelResolution", aveRes); + pband += ValidateKey("MeanGroundResolution", g.grRes); - // Determine if image crosses Longitude domain - if ( g.hasLongitudeBoundary ) { - pband += PvlKeyword("HasLongitudeBoundary","TRUE"); - } - else { - pband += PvlKeyword("HasLongitudeBoundary","FALSE"); - } + pband += ValidateKey("SubSolarAzimuth", g.subSolarAzimuth); + pband += ValidateKey("SubSolarGroundAzimuth", g.subSolarGroundAzimuth); + pband += ValidateKey("SubSolarLatitude", g.subSolarLatitude); + pband += ValidateKey("SubSolarLongitude", g.subSolarLongitude); - // Add test for North pole in image - if (g.hasNorthPole) { - pband += PvlKeyword("HasNorthPole", "TRUE"); - } - else { - pband += PvlKeyword("HasNorthPole", "FALSE"); - } + pband += ValidateKey("SubSpacecraftAzimuth", g.subSpacecraftAzimuth); + pband += ValidateKey("SubSpacecraftGroundAzimuth", g.subSpacecraftGroundAzimuth); + pband += ValidateKey("SubSpacecraftLatitude", g.subSpacecraftLatitude); + pband += ValidateKey("SubSpacecraftLongitude", g.subSpacecraftLongitude); - // Add test for South pole in image - if (g.hasSouthPole) { - pband += PvlKeyword("HasSouthPole", "TRUE"); - } - else { - pband += PvlKeyword("HasSouthPole", "FALSE"); - } + pband += ValidateKey("ParallaxX", g.parallaxx); + pband += ValidateKey("ParallaxY", g.parallaxy); - return; -} + pband += ValidateKey("ShadowX", g.shadowx); + pband += ValidateKey("ShadowY", g.shadowy); -BandGeometry::GProperties BandGeometry::getGeometrySummary() const { - if ( _isBandIndependent || (size() == 1)) { - return (_gBandList[0]); - } + // Determine if image crosses Longitude domain + if(g.hasLongitudeBoundary) { + pband += PvlKeyword("HasLongitudeBoundary", "TRUE"); + } + else { + pband += PvlKeyword("HasLongitudeBoundary", "FALSE"); + } - // Get the centroid point of the union polygon - double plon(Null), plat(Null); - if ( _combined != 0 ) { - geos::geom::Point *center = _combined->getCentroid(); - plon = center->getX(); - plat = center->getY(); - delete center; + // Add test for North pole in image + if(g.hasNorthPole) { + pband += PvlKeyword("HasNorthPole", "TRUE"); + } + else { + pband += PvlKeyword("HasNorthPole", "FALSE"); + } + + // Add test for South pole in image + if(g.hasSouthPole) { + pband += PvlKeyword("HasSouthPole", "TRUE"); + } + else { + pband += PvlKeyword("HasSouthPole", "FALSE"); + } + + return; } - GProperties bestBand; - double centerDistance(DBL_MAX); + BandGeometry::GProperties BandGeometry::getGeometrySummary() const { + if(_isBandIndependent || (size() == 1)) { + return (_gBandList[0]); + } - GProperties corners; - double ulDist(DBL_MIN), urDist(DBL_MIN), - lrDist(DBL_MIN), llDist(DBL_MIN); + // Get the centroid point of the union polygon + double plon(Null), plat(Null); + if(_combined != 0) { + geos::geom::Point *center = _combined->getCentroid(); + plon = center->getX(); + plat = center->getY(); + delete center; + } - double radius = getRadius(); + GProperties bestBand; + double centerDistance(DBL_MAX); - BandPropertiesListConstIter b; - for ( b = _gBandList.begin() ; b != _gBandList.end() ; ++b ) { - double thisDist; + GProperties corners; + double ulDist(DBL_MIN), urDist(DBL_MIN), + lrDist(DBL_MIN), llDist(DBL_MIN); - // Ensure the center latitude/logitude is defined (typically occurs when - // no polygon data is available). This scheme uses the first one defined. - if ( IsSpecial(plat) || IsSpecial(plon) ) { - plat = b->centerLatitude; - plon = b->centerLongitude; - } + double radius = getRadius(); - // Now check all data - bool isCloser = isDistShorter(centerDistance, plat, plon, - b->centerLatitude,b->centerLongitude, - radius, thisDist) ; - if (isCloser) { + BandPropertiesListConstIter b; + for(b = _gBandList.begin() ; b != _gBandList.end() ; ++b) { + double thisDist; + + // Ensure the center latitude/logitude is defined (typically occurs when + // no polygon data is available). This scheme uses the first one defined. + if(IsSpecial(plat) || IsSpecial(plon)) { + plat = b->centerLatitude; + plon = b->centerLongitude; + } + + // Now check all data + bool isCloser = isDistShorter(centerDistance, plat, plon, + b->centerLatitude, b->centerLongitude, + radius, thisDist) ; + if(isCloser) { bestBand = *b; centerDistance = thisDist; } - // Do upper left and right corners - isCloser = isDistShorter(ulDist, plat, plon, - b->upperLeftLatitude, b->upperLeftLongitude, - radius, thisDist); - if ( !isCloser ) { - corners.upperLeftLatitude = b->upperLeftLatitude; - corners.upperLeftLongitude = b->upperLeftLongitude; - ulDist = thisDist; - } + // Do upper left and right corners + isCloser = isDistShorter(ulDist, plat, plon, + b->upperLeftLatitude, b->upperLeftLongitude, + radius, thisDist); + if(!isCloser) { + corners.upperLeftLatitude = b->upperLeftLatitude; + corners.upperLeftLongitude = b->upperLeftLongitude; + ulDist = thisDist; + } - isCloser = isDistShorter(urDist, plat, plon, - b->upperRightLatitude, b->upperRightLongitude, - radius, thisDist); - if ( !isCloser ) { - corners.upperRightLatitude = b->upperRightLatitude; - corners.upperRightLongitude = b->upperRightLongitude; - urDist = thisDist; - } + isCloser = isDistShorter(urDist, plat, plon, + b->upperRightLatitude, b->upperRightLongitude, + radius, thisDist); + if(!isCloser) { + corners.upperRightLatitude = b->upperRightLatitude; + corners.upperRightLongitude = b->upperRightLongitude; + urDist = thisDist; + } - // Do lower left and right corners - isCloser = isDistShorter(llDist, plat, plon, - b->lowerLeftLatitude, b->lowerLeftLongitude, - radius, thisDist); - if ( !isCloser ) { - corners.lowerLeftLatitude = b->lowerLeftLatitude; - corners.lowerLeftLongitude = b->lowerLeftLongitude; - llDist = thisDist; - } + // Do lower left and right corners + isCloser = isDistShorter(llDist, plat, plon, + b->lowerLeftLatitude, b->lowerLeftLongitude, + radius, thisDist); + if(!isCloser) { + corners.lowerLeftLatitude = b->lowerLeftLatitude; + corners.lowerLeftLongitude = b->lowerLeftLongitude; + llDist = thisDist; + } - isCloser = isDistShorter(lrDist, plat, plon, - b->lowerRightLatitude, b->lowerRightLongitude, - radius, thisDist); - if ( !isCloser ) { - corners.lowerRightLatitude = b->lowerRightLatitude; - corners.lowerRightLongitude = b->lowerRightLongitude; - lrDist = thisDist; + isCloser = isDistShorter(lrDist, plat, plon, + b->lowerRightLatitude, b->lowerRightLongitude, + radius, thisDist); + if(!isCloser) { + corners.lowerRightLatitude = b->lowerRightLatitude; + corners.lowerRightLongitude = b->lowerRightLongitude; + lrDist = thisDist; + } } - } - // Add the corners to the returning property - bestBand.upperLeftLatitude = corners.upperLeftLatitude; - bestBand.upperLeftLongitude = corners.upperLeftLongitude; - bestBand.upperRightLatitude = corners.upperRightLatitude; - bestBand.upperRightLongitude = corners.upperRightLongitude; - bestBand.lowerLeftLatitude = corners.lowerLeftLatitude; - bestBand.lowerLeftLongitude = corners.lowerLeftLongitude; - bestBand.lowerRightLatitude = corners.lowerRightLatitude; - bestBand.lowerRightLongitude = corners.lowerRightLongitude; - return (bestBand); -} + // Add the corners to the returning property + bestBand.upperLeftLatitude = corners.upperLeftLatitude; + bestBand.upperLeftLongitude = corners.upperLeftLongitude; + bestBand.upperRightLatitude = corners.upperRightLatitude; + bestBand.upperRightLongitude = corners.upperRightLongitude; + bestBand.lowerLeftLatitude = corners.lowerLeftLatitude; + bestBand.lowerLeftLongitude = corners.lowerLeftLongitude; + bestBand.lowerRightLatitude = corners.lowerRightLatitude; + bestBand.lowerRightLongitude = corners.lowerRightLongitude; + return (bestBand); + } -Pvl BandGeometry::getProjGeometry(Camera &camera, - geos::geom::MultiPolygon *footprint, - GProperties &g) { + Pvl BandGeometry::getProjGeometry(Camera &camera, + geos::geom::MultiPolygon *footprint, + GProperties &g) { #if defined(DEBUG) - std::ofstream fp("footprint.gml"); - fp << PolygonTools::ToGML(footprint, "Footprint"); - fp.close(); + std::ofstream fp("footprint.gml"); + fp << PolygonTools::ToGML(footprint, "Footprint"); + fp.close(); #endif - // Get basic projection information. Assumes a Sinusoidal projection with - // East 360 longitude domain and planetocentric laitudes. - Pvl sinuMap; - camera.BasicMapping(sinuMap); - PvlGroup &mapping = sinuMap.FindGroup("Mapping"); - - double clon = g.centerLongitude; - double minLon = (double) mapping["MinimumLongitude"]; - double maxLon = (double) mapping["MaximumLongitude"]; - if ( IsSpecial(clon) ) clon = (minLon + maxLon)/2.0; - - // Make adjustments for center projection type/ranges. - // To be consistant with other implementations, do not - // convert poles to 180 domain. - geos::geom::MultiPolygon *poly180(0), *poly(footprint); - if ( g.hasLongitudeBoundary ) { - if ( !(g.hasNorthPole || g.hasSouthPole) ) { - // Convert the mapping group contents to 180 Longitude domain - PvlKeyword &ldkey = mapping["LongitudeDomain"]; - ldkey.SetValue("180"); - - PvlKeyword &minkey = mapping["MinimumLongitude"]; - PvlKeyword &maxkey = mapping["MaximumLongitude"]; - minkey.SetValue("-180.0"); - maxkey.SetValue("180.0"); - - // Compute new ranges - double minLat180, maxLat180, minLon180, maxLon180; - camera.GroundRange(minLat180, maxLat180, minLon180, maxLon180, sinuMap); - minkey.SetValue(ToString(minLon180)); - maxkey.SetValue(ToString(maxLon180)); - clon = (minLon180 + maxLon180) / 2.0; - - // Convert the polygon to 180 domain - poly = poly180 = PolygonTools::To180(footprint); + // Get basic projection information. Assumes a Sinusoidal projection with + // East 360 longitude domain and planetocentric laitudes. + Pvl sinuMap; + camera.BasicMapping(sinuMap); + PvlGroup &mapping = sinuMap.FindGroup("Mapping"); + + double clon = g.centerLongitude; + double minLon = (double) mapping["MinimumLongitude"]; + double maxLon = (double) mapping["MaximumLongitude"]; + if(IsSpecial(clon)) clon = (minLon + maxLon) / 2.0; + + // Make adjustments for center projection type/ranges. + // To be consistant with other implementations, do not + // convert poles to 180 domain. + geos::geom::MultiPolygon *poly180(0), *poly(footprint); + if(g.hasLongitudeBoundary) { + if(!(g.hasNorthPole || g.hasSouthPole)) { + // Convert the mapping group contents to 180 Longitude domain + PvlKeyword &ldkey = mapping["LongitudeDomain"]; + ldkey.SetValue("180"); + + PvlKeyword &minkey = mapping["MinimumLongitude"]; + PvlKeyword &maxkey = mapping["MaximumLongitude"]; + minkey.SetValue("-180.0"); + maxkey.SetValue("180.0"); + + // Compute new ranges + double minLat180, maxLat180, minLon180, maxLon180; + camera.GroundRange(minLat180, maxLat180, minLon180, maxLon180, sinuMap); + minkey.SetValue(ToString(minLon180)); + maxkey.SetValue(ToString(maxLon180)); + clon = (minLon180 + maxLon180) / 2.0; + + // Convert the polygon to 180 domain + poly = poly180 = PolygonTools::To180(footprint); #if defined(DEBUG) - std::ofstream p180("poly180.gml"); - p180 << PolygonTools::ToGML(poly180, "180Domain"); - p180.close(); + std::ofstream p180("poly180.gml"); + p180 << PolygonTools::ToGML(poly180, "180Domain"); + p180.close(); #endif + } } - } - mapping += PvlKeyword("CenterLongitude", clon); + mapping += PvlKeyword("CenterLongitude", clon); - Projection *sinu = ProjectionFactory::Create(sinuMap, true); - geos::geom::MultiPolygon *sPoly = PolygonTools::LatLonToXY(*poly, sinu); + Projection *sinu = ProjectionFactory::Create(sinuMap, true); + geos::geom::MultiPolygon *sPoly = PolygonTools::LatLonToXY(*poly, sinu); #if defined(DEBUG) - std::ofstream ll("sinuprojxy.gml"); - ll << PolygonTools::ToGML(sPoly, "SinuProjectedXY"); - ll.close(); + std::ofstream ll("sinuprojxy.gml"); + ll << PolygonTools::ToGML(sPoly, "SinuProjectedXY"); + ll.close(); #endif - geos::geom::Point *center = sPoly->getCentroid(); - - sinu->SetCoordinate(center->getX(), center->getY()); - g.centroidLongitude = Projection::To360Domain(sinu->UniversalLongitude()); - g.centroidLatitude = sinu->UniversalLatitude(); - g.surfaceArea = sPoly->getArea() / (1000.0 * 1000.0); - delete center; - delete sPoly; - delete sinu; - delete poly180; - - if (camera.SetUniversalGround(g.centroidLatitude, g.centroidLongitude)) { - g.centroidLine = camera.Line(); - g.centroidSample = camera.Sample(); - g.centroidRadius = camera.LocalRadius(); - } + geos::geom::Point *center = sPoly->getCentroid(); - return (sinuMap); -} + sinu->SetCoordinate(center->getX(), center->getY()); + g.centroidLongitude = Projection::To360Domain(sinu->UniversalLongitude()); + g.centroidLatitude = sinu->UniversalLatitude(); + g.surfaceArea = sPoly->getArea() / (1000.0 * 1000.0); + delete center; + delete sPoly; + delete sinu; + delete poly180; + + if(camera.SetUniversalGround(g.centroidLatitude, g.centroidLongitude)) { + g.centroidLine = camera.Line(); + g.centroidSample = camera.Sample(); + g.centroidRadius = camera.LocalRadius(); + } -void BandGeometry::generatePolygonKeys(PvlObject &pband) { - if ( size() <= 0 ) { - std::string mess = "No Band geometry available!"; - iException::Message(iException::Programmer, mess, _FILEINFO_); + return (sinuMap); } - // Compute surface area - already done in collection phase - double radius = getRadius(); - double globalCoverage(Null); - if ( !IsSpecial(radius) ) { - double globalArea = 4.0 * pi_c() * (radius * radius) / (1000.0*1000.0); - globalCoverage = _summary.surfaceArea / globalArea * 100.0; - globalCoverage = SetRound(globalCoverage, 6); - } + void BandGeometry::generatePolygonKeys(PvlObject &pband) { + if(size() <= 0) { + std::string mess = "No Band geometry available!"; + iException::Message(iException::Programmer, mess, _FILEINFO_); + } - pband += ValidateKey("CentroidLine",_summary.centroidLine); - pband += ValidateKey("CentroidSample",_summary.centroidSample); - pband += ValidateKey("CentroidLatitude",_summary.centroidLatitude); - pband += ValidateKey("CentroidLongitude",_summary.centroidLongitude); - pband += ValidateKey("CentroidRadius",_summary.centroidRadius, "meters"); - pband += ValidateKey("SurfaceArea",_summary.surfaceArea,"km^2"); - pband += ValidateKey("GlobalCoverage",globalCoverage,"percent"); - if ( _combined != 0 ) { - pband += PvlKeyword("PixelIncrement", _pixinc); - if ( _combined->getGeometryTypeId() != geos::geom::GEOS_MULTIPOLYGON ) { - geos::geom::MultiPolygon *geom = makeMultiPolygon(_combined); - pband += PvlKeyword("GisFootprint", geom->toString()); - delete geom; + // Compute surface area - already done in collection phase + double radius = getRadius(); + double globalCoverage(Null); + if(!IsSpecial(radius)) { + double globalArea = 4.0 * pi_c() * (radius * radius) / (1000.0 * 1000.0); + globalCoverage = _summary.surfaceArea / globalArea * 100.0; + globalCoverage = SetRound(globalCoverage, 6); + } + + pband += ValidateKey("CentroidLine", _summary.centroidLine); + pband += ValidateKey("CentroidSample", _summary.centroidSample); + pband += ValidateKey("CentroidLatitude", _summary.centroidLatitude); + pband += ValidateKey("CentroidLongitude", _summary.centroidLongitude); + pband += ValidateKey("CentroidRadius", _summary.centroidRadius, "meters"); + pband += ValidateKey("SurfaceArea", _summary.surfaceArea, "km^2"); + pband += ValidateKey("GlobalCoverage", globalCoverage, "percent"); + if(_combined != 0) { + pband += PvlKeyword("PixelIncrement", _pixinc); + if(_combined->getGeometryTypeId() != geos::geom::GEOS_MULTIPOLYGON) { + geos::geom::MultiPolygon *geom = makeMultiPolygon(_combined); + pband += PvlKeyword("GisFootprint", geom->toString()); + delete geom; + } + else { + pband += PvlKeyword("GisFootprint", _combined->toString()); + } } else { - pband += PvlKeyword("GisFootprint", _combined->toString()); + pband += PvlKeyword("GisFootprint", Null); } + + // Add the mapping group used to project polygon + pband.AddGroup(_mapping.FindGroup("Mapping")); + return; } - else { - pband += PvlKeyword("GisFootprint", Null); + + double BandGeometry::getRadius() const { + Statistics polyRadius, centRadius; + BandPropertiesListConstIter b; + for(b = _gBandList.begin() ; b != _gBandList.end() ; ++b) { + polyRadius.AddData(b->centroidRadius); + centRadius.AddData(b->radius); + } + double radius = polyRadius.Average(); + if(IsSpecial(radius)) radius = centRadius.Average(); + if(IsSpecial(radius)) radius = _radius; + return (radius); + } + + double BandGeometry::getPixelResolution() const { + Statistics groundRes, pixelRes; + BandPropertiesListConstIter b; + for(b = _gBandList.begin() ; b != _gBandList.end() ; ++b) { + pixelRes.AddData(b->sampRes); + pixelRes.AddData(b->lineRes); + groundRes.AddData(b->grRes); + } + + double res = groundRes.Average(); + if(IsSpecial(res)) res = pixelRes.Average(); + return (res); + } + + double BandGeometry::getPixelsPerDegree(double pixres, + double radius) const { + double circumference = 2.0 * pi_c() * radius; + double metersPerDegree = circumference / 360.0; + double pixelsPerDegree = metersPerDegree / pixres; + return (pixelsPerDegree); + } + + + bool BandGeometry::isDistShorter(double bestDist, double lat1, double lon1, + double lat2, double lon2, double radius, + double &thisDist) const { + if(IsSpecial(lat1)) return (false); + if(IsSpecial(lon1)) return (false); + if(IsSpecial(lat2)) return (false); + if(IsSpecial(lon2)) return (false); + if(IsSpecial(radius)) return (false); + + thisDist = Camera::Distance(lat1, lon1, lat2, lon2, radius); + return (thisDist < bestDist); } - // Add the mapping group used to project polygon - pband.AddGroup(_mapping.FindGroup("Mapping")); - return; -} - -double BandGeometry::getRadius() const { - Statistics polyRadius, centRadius; - BandPropertiesListConstIter b; - for ( b = _gBandList.begin() ; b != _gBandList.end() ; ++b ) { - polyRadius.AddData(b->centroidRadius); - centRadius.AddData(b->radius); + geos::geom::MultiPolygon *BandGeometry::makeMultiPolygon( + geos::geom::Geometry *g) const { + vector polys; + polys.push_back(g); + const geos::geom::GeometryFactory *gfactory = geos::geom::GeometryFactory::getDefaultInstance(); + return (gfactory->createMultiPolygon(polys)); } - double radius = polyRadius.Average(); - if ( IsSpecial(radius) ) radius = centRadius.Average(); - if ( IsSpecial(radius) ) radius = _radius; - return (radius); -} - -double BandGeometry::getPixelResolution() const { - Statistics groundRes, pixelRes; - BandPropertiesListConstIter b; - for ( b = _gBandList.begin() ; b != _gBandList.end() ; ++b ) { - pixelRes.AddData(b->sampRes); - pixelRes.AddData(b->lineRes); - groundRes.AddData(b->grRes); - } - - double res = groundRes.Average(); - if ( IsSpecial(res) ) res = pixelRes.Average(); - return (res); -} - -double BandGeometry::getPixelsPerDegree(double pixres, - double radius) const { - double circumference = 2.0 * pi_c() * radius; - double metersPerDegree = circumference / 360.0; - double pixelsPerDegree = metersPerDegree / pixres; - return (pixelsPerDegree); -} - - -bool BandGeometry::isDistShorter(double bestDist, double lat1, double lon1, - double lat2, double lon2, double radius, - double &thisDist) const { - if ( IsSpecial(lat1) ) return (false); - if ( IsSpecial(lon1) ) return (false); - if ( IsSpecial(lat2) ) return (false); - if ( IsSpecial(lon2) ) return (false); - if ( IsSpecial(radius) ) return (false); - - thisDist = Camera::Distance(lat1, lon1, lat2, lon2, radius); - return (thisDist < bestDist); -} - -geos::geom::MultiPolygon *BandGeometry::makeMultiPolygon( - geos::geom::Geometry *g) const { - vector polys; - polys.push_back(g); - const geos::geom::GeometryFactory *gfactory = geos::geom::GeometryFactory::getDefaultInstance(); - return (gfactory->createMultiPolygon(polys)); -} } // namespace Isis diff --git a/isis/src/base/apps/caminfo/CamTools.h b/isis/src/base/apps/caminfo/CamTools.h index 378d32bd01..811147a1c1 100644 --- a/isis/src/base/apps/caminfo/CamTools.h +++ b/isis/src/base/apps/caminfo/CamTools.h @@ -1,27 +1,27 @@ #if !defined(CamTools_h) #define CamTools_h -/** - * @file +/** + * @file * $Revision: 1.10 $ * $Date: 2009/08/25 01:37:55 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include #include @@ -37,212 +37,230 @@ namespace Isis { -/** - * @brief Checks value of key, produces appropriate value - * - * This function checks the value of the keyword for specialness - * and will create the appropriate keyword if it is special. - * - * @param keyname Name of keyword to create - * @param value Keyword value - * @param unit Optional unit qualifer with value - * - * @return PvlKeyword Returns newly created keyword/value - */ -inline PvlKeyword ValidateKey(const std::string keyname, - const double &value, - const std::string &unit = "") { - if (IsSpecial(value)) { - return (PvlKeyword(keyname,"NULL")); - } - else { - return (PvlKeyword(keyname,value,unit)); + /** + * @brief Checks value of key, produces appropriate value + * + * This function checks the value of the keyword for specialness + * and will create the appropriate keyword if it is special. + * + * @param keyname Name of keyword to create + * @param value Keyword value + * @param unit Optional unit qualifer with value + * + * @return PvlKeyword Returns newly created keyword/value + */ + inline PvlKeyword ValidateKey(const std::string keyname, + const double &value, + const std::string &unit = "") { + if(IsSpecial(value)) { + return (PvlKeyword(keyname, "NULL")); + } + else { + return (PvlKeyword(keyname, value, unit)); + } } -} -/** - * @brief Checks proper value of a NULLed keyword - * - * If the keyword is a NULL keyword, ensure it has proper value. - * - * @param keyname Name of keyword to create - * @param key Keyword/value set - * @param unit Optional unit qualifer with value - * - * @return PvlKeyword Returns newly created keyword/value - */ + /** + * @brief Checks proper value of a NULLed keyword + * + * If the keyword is a NULL keyword, ensure it has proper value. + * + * @param keyname Name of keyword to create + * @param key Keyword/value set + * @param unit Optional unit qualifer with value + * + * @return PvlKeyword Returns newly created keyword/value + */ -inline PvlKeyword ValidateKey(const std::string keyname, PvlKeyword &key, - const std::string &unit = "") { - if (key.IsNull()) { - return (PvlKeyword(keyname,"NULL")); - } - else { - return (ValidateKey(keyname,(double) key,unit)); + inline PvlKeyword ValidateKey(const std::string keyname, PvlKeyword &key, + const std::string &unit = "") { + if(key.IsNull()) { + return (PvlKeyword(keyname, "NULL")); + } + else { + return (ValidateKey(keyname, (double) key, unit)); + } } -} -/** Returns degree to radian conversion factor */ -inline double DegToRad(const double ang) { return (ang * rpd_c()); } -/** Returns radians to degrees conversion factor */ -inline double RadToDeg(const double ang) { return (ang * dpr_c()); } + /** Returns degree to radian conversion factor */ + inline double DegToRad(const double ang) { + return (ang * rpd_c()); + } + /** Returns radians to degrees conversion factor */ + inline double RadToDeg(const double ang) { + return (ang * dpr_c()); + } -/** A very useful, typesafe way to delete pointers in STL container - * Courtesy Scott Meyers, "Effective STL", Item 7, pg 37-40 */ -struct DeleteObject { - template - void operator()(const T* ptr) const { + /** A very useful, typesafe way to delete pointers in STL container + * Courtesy Scott Meyers, "Effective STL", Item 7, pg 37-40 */ + struct DeleteObject { + template + void operator()(const T *ptr) const { delete ptr; } -}; + }; /** - * @brief Collect Band geometry - * - * This produces the geometry and polygon information from an image cube. It - * has some special processing that accounts for band independant geometrical - * image cubes. It processes each band and creates unique geometry and - * ploygon values consider this situation. The resulting polygon is a union - * of all bands, which is a (usually) slightly better footprint of the acutal - * footprint for the product. - * - * The other major advantage to this class is the corner latitude/longitude - * points are based upon the extents of each independant band data as the - * furthest point from the center of the polygon location (if requested by the - * user). - * + * @brief Collect Band geometry + * + * This produces the geometry and polygon information from an image cube. It + * has some special processing that accounts for band independant geometrical + * image cubes. It processes each band and creates unique geometry and + * ploygon values consider this situation. The resulting polygon is a union + * of all bands, which is a (usually) slightly better footprint of the acutal + * footprint for the product. + * + * The other major advantage to this class is the corner latitude/longitude + * points are based upon the extents of each independant band data as the + * furthest point from the center of the polygon location (if requested by the + * user). + * * @ingroup Utility - * @author 2008-09-10 Kris Becker - * @history 2009-02-26 Kris Becker - Removed unconditional computation of + * @author 2008-09-10 Kris Becker + * @history 2009-02-26 Kris Becker - Removed unconditional computation of * polygon even when the user did not request it. Reorganized some * keywords to their relevant group locations. - * @history 2009-05-29 Kris Becker - Added _pixinx parameter - * @history 2009-06-22 Kris Becker - Added hasLimb() method to check for the + * @history 2009-05-29 Kris Becker - Added _pixinx parameter + * @history 2009-06-22 Kris Becker - Added hasLimb() method to check for the * presence of a planet limb; Added getProjGeometry() method. - * @history 2009-08-04 Christopher Austin - fixed ImagePolygon::Create call for + * @history 2009-08-04 Christopher Austin - fixed ImagePolygon::Create call for * the updated sampinc/lineinc implementation - * @history 2009-08-12 Kris Becker - Modified so that images that include + * @history 2009-08-12 Kris Becker - Modified so that images that include * poles are not converted to 180 domain when projected - * @history 2009-08-24 Kris Becker - Added ability to disable use of shape + * @history 2009-08-24 Kris Becker - Added ability to disable use of shape * model when creating polygons that contains a limb */ -class BandGeometry { - - public: - BandGeometry() : _nLines(0), _nSamps(0), _nBands(0), _pixinc(1), - _radius(1.0), _isBandIndependent(true), - _hasCenterGeom(false), _gBandList(), _polys(), - _combined(0), _mapping() { } - ~BandGeometry() { destruct(); } - - void setPixInc(const int pixinc) { _pixinc = pixinc; } - int getPixInc() const { return (_pixinc); } - void setMaxIncidence(const double maxinc) { _maxIncidence = maxinc; } - void setMaxEmission(const double maxema) { _maxEmission = maxema; } - int size() const { return (_gBandList.size()); } - bool isPointValid(const double &sample, const double &line, const Camera *camera = 0) const; - bool isBandIndependent() const { return (_isBandIndependent); } - bool hasCenterGeometry() const; - bool hasLimb() const; - void collect(Camera &camera, Cube &cube, bool doGeometry, bool doPolygon); - void generateGeometryKeys(PvlObject &pband); - void generatePolygonKeys(PvlObject &pband); - - private: - // Internal structure to contain geometric properties - struct GProperties { - GProperties() : lines(0), samples(0), bands(0), + class BandGeometry { + + public: + BandGeometry() : _nLines(0), _nSamps(0), _nBands(0), _pixinc(1), + _radius(1.0), _isBandIndependent(true), + _hasCenterGeom(false), _gBandList(), _polys(), + _combined(0), _mapping() { } + ~BandGeometry() { + destruct(); + } + + void setPixInc(const int pixinc) { + _pixinc = pixinc; + } + int getPixInc() const { + return (_pixinc); + } + void setMaxIncidence(const double maxinc) { + _maxIncidence = maxinc; + } + void setMaxEmission(const double maxema) { + _maxEmission = maxema; + } + int size() const { + return (_gBandList.size()); + } + bool isPointValid(const double &sample, const double &line, const Camera *camera = 0) const; + bool isBandIndependent() const { + return (_isBandIndependent); + } + bool hasCenterGeometry() const; + bool hasLimb() const; + void collect(Camera &camera, Cube &cube, bool doGeometry, bool doPolygon); + void generateGeometryKeys(PvlObject &pband); + void generatePolygonKeys(PvlObject &pband); + + private: + // Internal structure to contain geometric properties + struct GProperties { + GProperties() : lines(0), samples(0), bands(0), band(0), realBand(0), target(""), - centerLine(0.0), centerSamp(0.0), + centerLine(0.0), centerSamp(0.0), centerLatitude(Null), centerLongitude(Null), radius(Null), rightAscension(Null), declination(Null), - centroidLatitude(Null), centroidLongitude(Null), + centroidLatitude(Null), centroidLongitude(Null), centroidLine(Null), centroidSample(Null), centroidRadius(Null), surfaceArea(Null), phase(Null), emi(Null), inc(Null), sampRes(Null), lineRes(Null), grRes(Null), - solarLongitude(Null), northAzimuth(Null), offNader(Null), - subSolarAzimuth(Null), subSolarGroundAzimuth(Null), + solarLongitude(Null), northAzimuth(Null), offNader(Null), + subSolarAzimuth(Null), subSolarGroundAzimuth(Null), subSpacecraftAzimuth(Null), subSpacecraftGroundAzimuth(Null), - localSolartime (Null), targetCenterDistance(Null), slantDistance(Null), + localSolartime(Null), targetCenterDistance(Null), slantDistance(Null), subSolarLatitude(Null), subSolarLongitude(Null), subSpacecraftLatitude(Null), subSpacecraftLongitude(Null), startTime(""), endTime(""), parallaxx(Null), parallaxy(Null), - shadowx(Null), shadowy(Null), - upperLeftLongitude(Null), upperLeftLatitude(Null), - lowerLeftLongitude(Null), lowerLeftLatitude(Null), - lowerRightLongitude(Null), lowerRightLatitude(Null), - upperRightLongitude(Null),upperRightLatitude(Null), + shadowx(Null), shadowy(Null), + upperLeftLongitude(Null), upperLeftLatitude(Null), + lowerLeftLongitude(Null), lowerLeftLatitude(Null), + lowerRightLongitude(Null), lowerRightLatitude(Null), + upperRightLongitude(Null), upperRightLatitude(Null), hasLongitudeBoundary(false), hasNorthPole(false), hasSouthPole(false) { } - ~GProperties() { } - - int lines, samples, bands; - int band, realBand; - std::string target; - double centerLine, centerSamp; - double centerLatitude, centerLongitude; - double radius; - double rightAscension, declination; - double centroidLatitude, centroidLongitude; - double centroidLine, centroidSample; - double centroidRadius, surfaceArea; - double phase, emi, inc; - double sampRes, lineRes, grRes; - double solarLongitude, northAzimuth, offNader; - double subSolarAzimuth, subSolarGroundAzimuth; - double subSpacecraftAzimuth, subSpacecraftGroundAzimuth; - double localSolartime, targetCenterDistance, slantDistance; - double subSolarLatitude, subSolarLongitude; - double subSpacecraftLatitude, subSpacecraftLongitude; - std::string startTime, endTime; - double parallaxx, parallaxy, shadowx, shadowy; - double upperLeftLongitude, upperLeftLatitude; - double lowerLeftLongitude, lowerLeftLatitude; - double lowerRightLongitude, lowerRightLatitude; - double upperRightLongitude, upperRightLatitude; - bool hasLongitudeBoundary, hasNorthPole, hasSouthPole; - }; - - typedef std::vector BandPropertiesList; - typedef BandPropertiesList::iterator BandPropertiesListIter; - typedef BandPropertiesList::const_iterator BandPropertiesListConstIter; - - // Internal structure to contain geometric properties - typedef std::vector BandPolygonList; - typedef BandPolygonList::iterator BandPolygonListIter; - typedef BandPolygonList::const_iterator BandPolygonListConstIter; - - - int _nLines; - int _nSamps; - int _nBands; - int _pixinc; - double _maxEmission; - double _maxIncidence; - double _radius; - bool _isBandIndependent; - bool _hasCenterGeom; - BandPropertiesList _gBandList; - BandPolygonList _polys; - geos::geom::Geometry *_combined; - GProperties _summary; - Pvl _mapping; - - void destruct(); - GProperties getGeometrySummary() const; - Pvl getProjGeometry(Camera &camera, geos::geom::MultiPolygon *footprint, - GProperties &g); - double getRadius() const; - double getPixelResolution() const; - double getPixelsPerDegree(double pixres, double radius) const; - bool isDistShorter(double bestDist, double lat1, double lon1, - double lat2, double lon2, double radius, - double &thisDist) const; - geos::geom::MultiPolygon *makeMultiPolygon(geos::geom::Geometry *g) const; - - -}; + ~GProperties() { } + + int lines, samples, bands; + int band, realBand; + std::string target; + double centerLine, centerSamp; + double centerLatitude, centerLongitude; + double radius; + double rightAscension, declination; + double centroidLatitude, centroidLongitude; + double centroidLine, centroidSample; + double centroidRadius, surfaceArea; + double phase, emi, inc; + double sampRes, lineRes, grRes; + double solarLongitude, northAzimuth, offNader; + double subSolarAzimuth, subSolarGroundAzimuth; + double subSpacecraftAzimuth, subSpacecraftGroundAzimuth; + double localSolartime, targetCenterDistance, slantDistance; + double subSolarLatitude, subSolarLongitude; + double subSpacecraftLatitude, subSpacecraftLongitude; + std::string startTime, endTime; + double parallaxx, parallaxy, shadowx, shadowy; + double upperLeftLongitude, upperLeftLatitude; + double lowerLeftLongitude, lowerLeftLatitude; + double lowerRightLongitude, lowerRightLatitude; + double upperRightLongitude, upperRightLatitude; + bool hasLongitudeBoundary, hasNorthPole, hasSouthPole; + }; + + typedef std::vector BandPropertiesList; + typedef BandPropertiesList::iterator BandPropertiesListIter; + typedef BandPropertiesList::const_iterator BandPropertiesListConstIter; + + // Internal structure to contain geometric properties + typedef std::vector BandPolygonList; + typedef BandPolygonList::iterator BandPolygonListIter; + typedef BandPolygonList::const_iterator BandPolygonListConstIter; + + + int _nLines; + int _nSamps; + int _nBands; + int _pixinc; + double _maxEmission; + double _maxIncidence; + double _radius; + bool _isBandIndependent; + bool _hasCenterGeom; + BandPropertiesList _gBandList; + BandPolygonList _polys; + geos::geom::Geometry *_combined; + GProperties _summary; + Pvl _mapping; + + void destruct(); + GProperties getGeometrySummary() const; + Pvl getProjGeometry(Camera &camera, geos::geom::MultiPolygon *footprint, + GProperties &g); + double getRadius() const; + double getPixelResolution() const; + double getPixelsPerDegree(double pixres, double radius) const; + bool isDistShorter(double bestDist, double lat1, double lon1, + double lat2, double lon2, double radius, + double &thisDist) const; + geos::geom::MultiPolygon *makeMultiPolygon(geos::geom::Geometry *g) const; + + + }; } // Namespace Isis diff --git a/isis/src/base/apps/caminfo/caminfo.cpp b/isis/src/base/apps/caminfo/caminfo.cpp index fabdd7dfb6..1c18ae22cb 100644 --- a/isis/src/base/apps/caminfo/caminfo.cpp +++ b/isis/src/base/apps/caminfo/caminfo.cpp @@ -20,11 +20,10 @@ #include "Statistics.h" #include "UserInterface.h" -using namespace std; +using namespace std; using namespace Isis; -void IsisMain () -{ +void IsisMain() { const string caminfo_program = "caminfo"; const string caminfo_version = "2.2"; const string caminfo_revision = "$Revision: 1.20 $"; @@ -40,9 +39,9 @@ void IsisMain () Pvl pout; // if true then run spiceinit, xml default is FALSE //spiceinit will use system kernels - if (ui.GetBoolean("SPICE")) { + if(ui.GetBoolean("SPICE")) { string parameters = "FROM=" + in.Expanded(); - Isis::iApp->Exec("spiceinit",parameters); + Isis::iApp->Exec("spiceinit", parameters); } Cube *icube = p.SetInputCube("FROM"); @@ -54,70 +53,70 @@ void IsisMain () common += PvlKeyword("Version", caminfo_version); common += PvlKeyword("IsisVersion", version); common += PvlKeyword("RunDate", caminfo_runtime); - common += PvlKeyword("IsisId",SerialNumber::Compose(*icube)); - common += PvlKeyword("From",icube->Filename()); - common += PvlKeyword("Lines",icube->Lines()); - common += PvlKeyword("Samples",icube->Samples()); - common += PvlKeyword("Bands",icube->Bands()); + common += PvlKeyword("IsisId", SerialNumber::Compose(*icube)); + common += PvlKeyword("From", icube->Filename()); + common += PvlKeyword("Lines", icube->Lines()); + common += PvlKeyword("Samples", icube->Samples()); + common += PvlKeyword("Bands", icube->Bands()); params.AddObject(common); // Run camstats on the entire image (all bands) // another camstats will be run for each band and output // for each band. Pvl camPvl; // This becomes useful if there is only one band, which is - // frequent! Used below if single band image. - if (doCamstat) { + // frequent! Used below if single band image. + if(doCamstat) { int linc = ui.GetInteger("LINC"); int sinc = ui.GetInteger("SINC"); Filename tempCamPvl; - tempCamPvl.Temporary(in.Basename()+"_", "pvl"); + tempCamPvl.Temporary(in.Basename() + "_", "pvl"); string pvlOut = tempCamPvl.Expanded(); PvlObject pcband("Camstats"); //set up camstats run and execute - string parameters = "FROM=" + from + + string parameters = "FROM=" + from + " TO=" + pvlOut + " LINC=" + iString(linc) + " SINC=" + iString(sinc); - Isis::iApp->Exec("camstats",parameters); + Isis::iApp->Exec("camstats", parameters); //out put to common object of the PVL camPvl.Read(pvlOut); remove(pvlOut.c_str()); - PvlGroup cg = camPvl.FindGroup("Latitude",Pvl::Traverse); - pcband += ValidateKey("MinimumLatitude",cg["latitudeminimum"]); - pcband += ValidateKey("MaximumLatitude",cg["latitudemaximum"]); - cg = camPvl.FindGroup("Longitude",Pvl::Traverse); - pcband += ValidateKey("MinimumLongitude",cg["longitudeminimum"]); - pcband += ValidateKey("MaximumLongitude",cg["longitudemaximum"]); - cg = camPvl.FindGroup("Resolution",Pvl::Traverse); - pcband += ValidateKey("MinimumResolution",cg["resolutionminimum"]); - pcband += ValidateKey("MaximumResolution",cg["resolutionmaximum"]); - cg = camPvl.FindGroup("PhaseAngle",Pvl::Traverse); - pcband += ValidateKey("MinimumPhase",cg["phaseminimum"]); - pcband += ValidateKey("MaximumPhase",cg["phasemaximum"]); - cg = camPvl.FindGroup("EmissionAngle",Pvl::Traverse); - pcband += ValidateKey("MinimumEmission",cg["emissionminimum"]); - pcband += ValidateKey("MaximumEmission",cg["emissionmaximum"]); - cg = camPvl.FindGroup("IncidenceAngle",Pvl::Traverse); - pcband += ValidateKey("MinimumIncidence",cg["incidenceminimum"]); - pcband += ValidateKey("MaximumIncidence",cg["incidencemaximum"]); - cg = camPvl.FindGroup("LocalSolarTime",Pvl::Traverse); - pcband += ValidateKey("LocalTimeMinimum",cg["localsolartimeMinimum"]); - pcband += ValidateKey("LocalTimeMaximum",cg["localsolartimeMaximum"]); + PvlGroup cg = camPvl.FindGroup("Latitude", Pvl::Traverse); + pcband += ValidateKey("MinimumLatitude", cg["latitudeminimum"]); + pcband += ValidateKey("MaximumLatitude", cg["latitudemaximum"]); + cg = camPvl.FindGroup("Longitude", Pvl::Traverse); + pcband += ValidateKey("MinimumLongitude", cg["longitudeminimum"]); + pcband += ValidateKey("MaximumLongitude", cg["longitudemaximum"]); + cg = camPvl.FindGroup("Resolution", Pvl::Traverse); + pcband += ValidateKey("MinimumResolution", cg["resolutionminimum"]); + pcband += ValidateKey("MaximumResolution", cg["resolutionmaximum"]); + cg = camPvl.FindGroup("PhaseAngle", Pvl::Traverse); + pcband += ValidateKey("MinimumPhase", cg["phaseminimum"]); + pcband += ValidateKey("MaximumPhase", cg["phasemaximum"]); + cg = camPvl.FindGroup("EmissionAngle", Pvl::Traverse); + pcband += ValidateKey("MinimumEmission", cg["emissionminimum"]); + pcband += ValidateKey("MaximumEmission", cg["emissionmaximum"]); + cg = camPvl.FindGroup("IncidenceAngle", Pvl::Traverse); + pcband += ValidateKey("MinimumIncidence", cg["incidenceminimum"]); + pcband += ValidateKey("MaximumIncidence", cg["incidencemaximum"]); + cg = camPvl.FindGroup("LocalSolarTime", Pvl::Traverse); + pcband += ValidateKey("LocalTimeMinimum", cg["localsolartimeMinimum"]); + pcband += ValidateKey("LocalTimeMaximum", cg["localsolartimeMaximum"]); params.AddObject(pcband); } // Add the input ISIS label if requested - if ( ui.GetBoolean("ISISLABEL") ) { + if(ui.GetBoolean("ISISLABEL")) { Pvl label = *(icube->Label()); label.SetName("IsisLabel"); params.AddObject(label); } // write out the orginal label blob - if (ui.GetBoolean("ORIGINALLABEL")) { + if(ui.GetBoolean("ORIGINALLABEL")) { OriginalLabel orig; icube->Read(orig); Pvl p = orig.ReturnLabels(); @@ -127,7 +126,7 @@ void IsisMain () // Compute statistics for entire cube - if ( ui.GetBoolean("STATISTICS") ) { + if(ui.GetBoolean("STATISTICS")) { LineManager iline(*icube); Statistics stats; Progress progress; @@ -135,7 +134,7 @@ void IsisMain () progress.SetMaximumSteps(icube->Lines()*icube->Bands()); progress.CheckStatus(); iline.SetLine(1); - for ( ; !iline.end() ; iline.next()) { + for(; !iline.end() ; iline.next()) { icube->Read(iline); stats.AddData(iline.DoubleBuffer(), iline.size()); progress.CheckStatus(); @@ -143,24 +142,24 @@ void IsisMain () // Compute stats of entire cube double nPixels = stats.TotalPixels(); - double nullpercent = (stats.NullPixels()/(nPixels))*100; - double hispercent = (stats.HisPixels()/(nPixels))*100; - double hrspercent = (stats.HrsPixels()/(nPixels))*100; - double lispercent = (stats.LisPixels()/(nPixels))*100; - double lrspercent = (stats.LrsPixels()/(nPixels))*100; + double nullpercent = (stats.NullPixels() / (nPixels)) * 100; + double hispercent = (stats.HisPixels() / (nPixels)) * 100; + double hrspercent = (stats.HrsPixels() / (nPixels)) * 100; + double lispercent = (stats.LisPixels() / (nPixels)) * 100; + double lrspercent = (stats.LrsPixels() / (nPixels)) * 100; //statitics keyword output for band PvlObject sgroup("Statistics"); - sgroup += ValidateKey("MeanValue",stats.Average()); - sgroup += ValidateKey("StandardDeviation",stats.StandardDeviation()); - sgroup += ValidateKey("MinimumValue",stats.Minimum()); - sgroup += ValidateKey("MaximumValue",stats.Maximum()); - sgroup += PvlKeyword("PercentHIS",hispercent); - sgroup += PvlKeyword("PercentHRS",hrspercent); - sgroup += PvlKeyword("PercentLIS",lispercent); - sgroup += PvlKeyword("PercentLRS",lrspercent); - sgroup += PvlKeyword("PercentNull",nullpercent); - sgroup += PvlKeyword("TotalPixels",stats.TotalPixels()); + sgroup += ValidateKey("MeanValue", stats.Average()); + sgroup += ValidateKey("StandardDeviation", stats.StandardDeviation()); + sgroup += ValidateKey("MinimumValue", stats.Minimum()); + sgroup += ValidateKey("MaximumValue", stats.Maximum()); + sgroup += PvlKeyword("PercentHIS", hispercent); + sgroup += PvlKeyword("PercentHRS", hrspercent); + sgroup += PvlKeyword("PercentLIS", lispercent); + sgroup += PvlKeyword("PercentLRS", lrspercent); + sgroup += PvlKeyword("PercentNull", nullpercent); + sgroup += PvlKeyword("TotalPixels", stats.TotalPixels()); params.AddObject(sgroup); } @@ -171,9 +170,9 @@ void IsisMain () BandGeometry bandGeom; bool doGeometry = ui.GetBoolean("GEOMETRY"); bool doPolygon = ui.GetBoolean("POLYGON"); - if (doGeometry || doPolygon) { + if(doGeometry || doPolygon) { int pixinc = ui.GetInteger("PIXINC"); - if (pixinc <= 0) pixinc = 100; + if(pixinc <= 0) pixinc = 100; bandGeom.setPixInc(pixinc); bandGeom.setMaxIncidence(ui.GetDouble("MAXINCIDENCE")); bandGeom.setMaxEmission(ui.GetDouble("MAXEMISSION")); @@ -181,20 +180,20 @@ void IsisMain () // Check if the user requires valid image center geometry - if (ui.GetBoolean("VCAMERA") && (!bandGeom.hasCenterGeometry())) { + if(ui.GetBoolean("VCAMERA") && (!bandGeom.hasCenterGeometry())) { string msg = "Image center does not project in camera model"; - throw iException::Message(iException::Camera,msg,_FILEINFO_); + throw iException::Message(iException::Camera, msg, _FILEINFO_); } // Write geometry data if requested - if (doGeometry) { + if(doGeometry) { PvlObject ggroup("Geometry"); bandGeom.generateGeometryKeys(ggroup); params.AddObject(ggroup); } // Write polygon group if requested - if (doPolygon) { + if(doPolygon) { PvlObject ggroup("Polygon"); bandGeom.generatePolygonKeys(ggroup); params.AddObject(ggroup); diff --git a/isis/src/base/apps/campt/campt.cpp b/isis/src/base/apps/campt/campt.cpp index f0ed78d165..3aa5a48697 100644 --- a/isis/src/base/apps/campt/campt.cpp +++ b/isis/src/base/apps/campt/campt.cpp @@ -1,8 +1,8 @@ #include "Isis.h" #include -#include - +#include + #include "Brick.h" #include "Camera.h" #include "CameraPointInfo.h" @@ -11,7 +11,7 @@ #include "Progress.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { @@ -27,103 +27,103 @@ void IsisMain() { // Depending on what type is selected, set values accordingly PvlGroup *point = NULL; - if (ui.GetString("TYPE") == "IMAGE") { + if(ui.GetString("TYPE") == "IMAGE") { double sample = 0.0; double line = 0.0; - if (ui.WasEntered("SAMPLE") && ui.WasEntered("LINE")) { + if(ui.WasEntered("SAMPLE") && ui.WasEntered("LINE")) { sample = ui.GetDouble("SAMPLE"); line = ui.GetDouble("LINE"); point = campt.SetImage(sample, line, outsideAllowed); } else { - if (ui.WasEntered("SAMPLE")) { + if(ui.WasEntered("SAMPLE")) { sample = ui.GetDouble("SAMPLE"); point = campt.SetSample(sample, outsideAllowed); } - else if (ui.WasEntered("LINE")) { + else if(ui.WasEntered("LINE")) { line = ui.GetDouble("LINE"); point = campt.SetLine(line, outsideAllowed); } else { point = campt.SetCenter(outsideAllowed); } - } + } } else { double lat = ui.GetDouble("LATITUDE"); double lon = ui.GetDouble("LONGITUDE"); - point = campt.SetGround(lat,lon, outsideAllowed); - } - + point = campt.SetGround(lat, lon, outsideAllowed); + } + prog.CheckStatus(); // Log it Application::Log((*point)); - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { // Get user params from ui string outFile = Filename(ui.GetFilename("TO")).Expanded(); bool exists = Filename(outFile).Exists(); bool append = ui.GetBoolean("APPEND"); // Write the pvl group out to the file - if (ui.GetString("FORMAT") == "PVL") { + if(ui.GetString("FORMAT") == "PVL") { Pvl temp; temp.SetTerminator(""); temp.AddGroup((*point)); - if (append) { + if(append) { temp.Append(outFile); } else { temp.Write(outFile); } - } - + } + // Create a flatfile from PVL data // The flatfile is comma delimited and can be imported into Excel else { ofstream os; bool writeHeader = false; - if (append) { - os.open(outFile.c_str(),ios::app); - if (!exists) { + if(append) { + os.open(outFile.c_str(), ios::app); + if(!exists) { writeHeader = true; } } else { - os.open(outFile.c_str(),ios::out); + os.open(outFile.c_str(), ios::out); writeHeader = true; - } + } if(writeHeader) { for(int i = 0; i < (*point).Keywords(); i++) { if((*point)[i].Size() == 3) { - os << (*point)[i].Name() << "X," - << (*point)[i].Name() << "Y," + os << (*point)[i].Name() << "X," + << (*point)[i].Name() << "Y," << (*point)[i].Name() << "Z"; } else { os << (*point)[i].Name(); } - if(i < point->Keywords()-1) { + if(i < point->Keywords() - 1) { os << ","; } } os << endl; } - + for(int i = 0; i < (*point).Keywords(); i++) { if((*point)[i].Size() == 3) { - os << (string)(*point)[i][0] << "," - << (string)(*point)[i][1] << "," + os << (string)(*point)[i][0] << "," + << (string)(*point)[i][1] << "," << (string)(*point)[i][2]; } else { os << (string)(*point)[i]; } - - if(i < (*point).Keywords()-1) { + + if(i < (*point).Keywords() - 1) { os << ","; } } @@ -131,9 +131,9 @@ void IsisMain() { } } else { - if (ui.GetString("FORMAT") == "FLAT") { + if(ui.GetString("FORMAT") == "FLAT") { string msg = "Flat file must have a name."; - throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_ ); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } delete point; diff --git a/isis/src/base/apps/camrange/camrange.cpp b/isis/src/base/apps/camrange/camrange.cpp index 8336d66444..a6b5f533d6 100644 --- a/isis/src/base/apps/camrange/camrange.cpp +++ b/isis/src/base/apps/camrange/camrange.cpp @@ -3,12 +3,12 @@ #include "Camera.h" #include "Pvl.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { Process p; - + // Set the input image, get the camera model, and a basic mapping // group Cube *icube = p.SetInputCube("FROM"); @@ -16,7 +16,7 @@ void IsisMain() { Pvl mapping; cam->BasicMapping(mapping); PvlGroup &mapgrp = mapping.FindGroup("Mapping"); - + // Setup the output results by first adding the filename UserInterface &ui = Application::GetUserInterface(); @@ -24,71 +24,71 @@ void IsisMain() { double radii[3]; cam->Radii(radii); PvlGroup target("Target"); - target += PvlKeyword("From",ui.GetFilename("FROM")); - target += PvlKeyword("TargetName",cam->Target()); - target += PvlKeyword("RadiusA",radii[0]*1000.0,"meters"); - target += PvlKeyword("RadiusB",radii[1]*1000.0,"meters"); - target += PvlKeyword("RadiusC",radii[2]*1000.0,"meters"); + target += PvlKeyword("From", ui.GetFilename("FROM")); + target += PvlKeyword("TargetName", cam->Target()); + target += PvlKeyword("RadiusA", radii[0] * 1000.0, "meters"); + target += PvlKeyword("RadiusB", radii[1] * 1000.0, "meters"); + target += PvlKeyword("RadiusC", radii[2] * 1000.0, "meters"); // Get resolution PvlGroup res("PixelResolution"); double lowres = cam->LowestImageResolution(); double hires = cam->HighestImageResolution(); - res += PvlKeyword("Lowest",lowres,"meters"); - res += PvlKeyword("Highest",hires,"meters"); + res += PvlKeyword("Lowest", lowres, "meters"); + res += PvlKeyword("Highest", hires, "meters"); // Get the universal ground range PvlGroup ugr("UniversalGroundRange"); - double minlat,maxlat,minlon,maxlon; - cam->GroundRange(minlat,maxlat,minlon,maxlon,mapping); - ugr += PvlKeyword("LatitudeType","Planetocentric"); - ugr += PvlKeyword("LongitudeDirection","PositiveEast"); - ugr += PvlKeyword("LongitudeDomain",360); - ugr += PvlKeyword("MinimumLatitude",minlat); - ugr += PvlKeyword("MaximumLatitude",maxlat); - ugr += PvlKeyword("MinimumLongitude",minlon); - ugr += PvlKeyword("MaximumLongitude",maxlon); + double minlat, maxlat, minlon, maxlon; + cam->GroundRange(minlat, maxlat, minlon, maxlon, mapping); + ugr += PvlKeyword("LatitudeType", "Planetocentric"); + ugr += PvlKeyword("LongitudeDirection", "PositiveEast"); + ugr += PvlKeyword("LongitudeDomain", 360); + ugr += PvlKeyword("MinimumLatitude", minlat); + ugr += PvlKeyword("MaximumLatitude", maxlat); + ugr += PvlKeyword("MinimumLongitude", minlon); + ugr += PvlKeyword("MaximumLongitude", maxlon); // Get the ographic latitude range - mapgrp.AddKeyword(PvlKeyword("LatitudeType","Planetographic"), + mapgrp.AddKeyword(PvlKeyword("LatitudeType", "Planetographic"), Pvl::Replace); - cam->GroundRange(minlat,maxlat,minlon,maxlon,mapping); + cam->GroundRange(minlat, maxlat, minlon, maxlon, mapping); PvlGroup ogr("LatitudeRange"); - ogr += PvlKeyword("LatitudeType","Planetographic"); - ogr += PvlKeyword("MinimumLatitude",minlat); - ogr += PvlKeyword("MaximumLatitude",maxlat); + ogr += PvlKeyword("LatitudeType", "Planetographic"); + ogr += PvlKeyword("MinimumLatitude", minlat); + ogr += PvlKeyword("MaximumLatitude", maxlat); // Get positive west longitude coordinates in 360 domain - mapgrp.AddKeyword(PvlKeyword("LongitudeDirection","PositiveWest"), + mapgrp.AddKeyword(PvlKeyword("LongitudeDirection", "PositiveWest"), Pvl::Replace); - cam->GroundRange(minlat,maxlat,minlon,maxlon,mapping); + cam->GroundRange(minlat, maxlat, minlon, maxlon, mapping); PvlGroup pos360("PositiveWest360"); - pos360 += PvlKeyword("LongitudeDirection","PositiveWest"); - pos360 += PvlKeyword("LongitudeDomain",360); - pos360 += PvlKeyword("MinimumLongitude",minlon); - pos360 += PvlKeyword("MaximumLongitude",maxlon); + pos360 += PvlKeyword("LongitudeDirection", "PositiveWest"); + pos360 += PvlKeyword("LongitudeDomain", 360); + pos360 += PvlKeyword("MinimumLongitude", minlon); + pos360 += PvlKeyword("MaximumLongitude", maxlon); // Get positive east longitude coordinates in 180 domain - mapgrp.AddKeyword(PvlKeyword("LongitudeDirection","PositiveEast"), + mapgrp.AddKeyword(PvlKeyword("LongitudeDirection", "PositiveEast"), Pvl::Replace); - mapgrp.AddKeyword(PvlKeyword("LongitudeDomain","180"), + mapgrp.AddKeyword(PvlKeyword("LongitudeDomain", "180"), Pvl::Replace); - cam->GroundRange(minlat,maxlat,minlon,maxlon,mapping); + cam->GroundRange(minlat, maxlat, minlon, maxlon, mapping); PvlGroup pos180("PositiveEast180"); - pos180 += PvlKeyword("LongitudeDirection","PositiveEast"); - pos180 += PvlKeyword("LongitudeDomain",180); - pos180 += PvlKeyword("MinimumLongitude",minlon); - pos180 += PvlKeyword("MaximumLongitude",maxlon); + pos180 += PvlKeyword("LongitudeDirection", "PositiveEast"); + pos180 += PvlKeyword("LongitudeDomain", 180); + pos180 += PvlKeyword("MinimumLongitude", minlon); + pos180 += PvlKeyword("MaximumLongitude", maxlon); // Get positive west longitude coordinates in 180 domain - mapgrp.AddKeyword(PvlKeyword("LongitudeDirection","PositiveWest"), + mapgrp.AddKeyword(PvlKeyword("LongitudeDirection", "PositiveWest"), Pvl::Replace); - cam->GroundRange(minlat,maxlat,minlon,maxlon,mapping); + cam->GroundRange(minlat, maxlat, minlon, maxlon, mapping); PvlGroup neg180("PositiveWest180"); - neg180 += PvlKeyword("LongitudeDirection","PositiveWest"); - neg180 += PvlKeyword("LongitudeDomain",180); - neg180 += PvlKeyword("MinimumLongitude",minlon); - neg180 += PvlKeyword("MaximumLongitude",maxlon); + neg180 += PvlKeyword("LongitudeDirection", "PositiveWest"); + neg180 += PvlKeyword("LongitudeDomain", 180); + neg180 += PvlKeyword("MinimumLongitude", minlon); + neg180 += PvlKeyword("MaximumLongitude", maxlon); // Write it to the log Application::Log(target); @@ -98,9 +98,9 @@ void IsisMain() { Application::Log(pos360); Application::Log(pos180); Application::Log(neg180); - + // Write the output file if requested - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { Pvl temp; temp.AddGroup(target); temp.AddGroup(res); @@ -109,7 +109,7 @@ void IsisMain() { temp.AddGroup(pos360); temp.AddGroup(pos180); temp.AddGroup(neg180); - temp.Write(ui.GetFilename("TO","txt")); + temp.Write(ui.GetFilename("TO", "txt")); } p.EndProcess(); diff --git a/isis/src/base/apps/camstats/camstats.cpp b/isis/src/base/apps/camstats/camstats.cpp index fdfbc21f8a..da3d771685 100644 --- a/isis/src/base/apps/camstats/camstats.cpp +++ b/isis/src/base/apps/camstats/camstats.cpp @@ -12,29 +12,29 @@ using namespace std; using namespace Isis; //function to build stats data -void buildStats (Camera *cam, int &sample, int &line); -void writeFlat (ofstream &os, Statistics &s); +void buildStats(Camera *cam, int &sample, int &line); +void writeFlat(ofstream &os, Statistics &s); /** Produces NULL values for special pixels - * + * * @param keyname Name of keyword to generate * @param value Value to write to keyword * @param unit Optional units for keywords - * + * * @return PvlKeyword Newly created keyword */ -static inline PvlKeyword ValidateKey(const std::string keyname, const double - &value, const std::string &unit = "") { - if (IsSpecial(value)) { +static inline PvlKeyword ValidateKey(const std::string keyname, const double + &value, const std::string &unit = "") { + if(IsSpecial(value)) { return (PvlKeyword(keyname, "NULL")); } else { - return (PvlKeyword(keyname,value,unit)); + return (PvlKeyword(keyname, value, unit)); } } -//global stats opjects that will be used by function +//global stats opjects that will be used by function Statistics latStat; Statistics lonStat; Statistics resStat; @@ -48,7 +48,7 @@ Statistics localSolarTimeStat; Statistics localRaduisStat; Statistics northAzimuthStat; -void IsisMain(){ +void IsisMain() { Process p; @@ -77,19 +77,19 @@ void IsisMain(){ int eband = cam->Bands(); // if the camera is band independent that only run one band - if (cam->IsBandIndependent()) eband = 1; + if(cam->IsBandIndependent()) eband = 1; int linc = ui.GetInteger("LINC"); int sinc = ui.GetInteger("SINC"); - int pTotal = eband * ((cam->Lines()-2) / linc + 2) ; + int pTotal = eband * ((cam->Lines() - 2) / linc + 2) ; Progress progress; progress.SetMaximumSteps(pTotal); progress.CheckStatus(); - for (int band=1; band<=eband; band++) { + for(int band = 1; band <= eband; band++) { cam->SetBand(band); - for (int line=1; line<(int)cam->Lines(); line=line+linc) { - for (int sample=1; sample< cam->Samples(); sample=sample+sinc) { + for(int line = 1; line < (int)cam->Lines(); line = line + linc) { + for(int sample = 1; sample < cam->Samples(); sample = sample + sinc) { buildStats(cam, sample, line); } //set the sample value to the last sample and run buildstats @@ -99,7 +99,7 @@ void IsisMain(){ } //set the line value to the last line and run on all samples(sample + sinc) int line = cam->Lines(); - for (int sample=1; sample< cam->Samples(); sample=sample+sinc) { + for(int sample = 1; sample < cam->Samples(); sample = sample + sinc) { buildStats(cam, sample, line); } //set last sample and run with last line @@ -108,104 +108,104 @@ void IsisMain(){ progress.CheckStatus(); } - //Set up the Pvl groups and get min, max, avg, and sd for each statstics object + //Set up the Pvl groups and get min, max, avg, and sd for each statstics object PvlGroup pUser("User Parameters"); - pUser += PvlKeyword("Filename",ui.GetFilename("FROM")); - pUser += PvlKeyword("Linc",ui.GetInteger("LINC")); - pUser += PvlKeyword("Sinc",ui.GetInteger("SINC")); + pUser += PvlKeyword("Filename", ui.GetFilename("FROM")); + pUser += PvlKeyword("Linc", ui.GetInteger("LINC")); + pUser += PvlKeyword("Sinc", ui.GetInteger("SINC")); PvlGroup pLat("Latitude"); - pLat += ValidateKey("LatitudeMinimum",latStat.Minimum()); - pLat += ValidateKey("LatitudeMaximum",latStat.Maximum()); - pLat += ValidateKey("LatitudeAverage",latStat.Average()); - pLat += ValidateKey("LatitudeStandardDeviation",latStat.StandardDeviation()); + pLat += ValidateKey("LatitudeMinimum", latStat.Minimum()); + pLat += ValidateKey("LatitudeMaximum", latStat.Maximum()); + pLat += ValidateKey("LatitudeAverage", latStat.Average()); + pLat += ValidateKey("LatitudeStandardDeviation", latStat.StandardDeviation()); PvlGroup pLon("Longitude"); - pLon += ValidateKey("LongitudeMinimum",lonStat.Minimum()); - pLon += ValidateKey("LongitudeMaximum",lonStat.Maximum()); - pLon += ValidateKey("LongitudeAverage",lonStat.Average()); - pLon += ValidateKey("LongitudeStandardDeviation",lonStat.StandardDeviation()); + pLon += ValidateKey("LongitudeMinimum", lonStat.Minimum()); + pLon += ValidateKey("LongitudeMaximum", lonStat.Maximum()); + pLon += ValidateKey("LongitudeAverage", lonStat.Average()); + pLon += ValidateKey("LongitudeStandardDeviation", lonStat.StandardDeviation()); PvlGroup pSampleRes("SampleResolution"); - pSampleRes += ValidateKey("SampleResolutionMinimum",sampleResStat.Minimum(), - "meters/pixel"); - pSampleRes += ValidateKey("SampleResolutionMaximum",sampleResStat.Maximum(), - "meters/pixel"); - pSampleRes += ValidateKey("SampleResolutionAverage",sampleResStat.Average(), - "meters/pixel"); + pSampleRes += ValidateKey("SampleResolutionMinimum", sampleResStat.Minimum(), + "meters/pixel"); + pSampleRes += ValidateKey("SampleResolutionMaximum", sampleResStat.Maximum(), + "meters/pixel"); + pSampleRes += ValidateKey("SampleResolutionAverage", sampleResStat.Average(), + "meters/pixel"); pSampleRes += ValidateKey("SampleResolutionStandardDeviation", - sampleResStat.StandardDeviation(),"meters/pixel"); + sampleResStat.StandardDeviation(), "meters/pixel"); PvlGroup pLineRes("LineResolution"); - pLineRes += ValidateKey("LineResolutionMinimum",lineResStat.Minimum(), - "meters/pixel"); - pLineRes += ValidateKey("LineResolutionMaximum",lineResStat.Maximum(), - "meters/pixel"); - pLineRes += ValidateKey("LineResolutionAverage",lineResStat.Average(), - "meters/pixel"); + pLineRes += ValidateKey("LineResolutionMinimum", lineResStat.Minimum(), + "meters/pixel"); + pLineRes += ValidateKey("LineResolutionMaximum", lineResStat.Maximum(), + "meters/pixel"); + pLineRes += ValidateKey("LineResolutionAverage", lineResStat.Average(), + "meters/pixel"); pLineRes += ValidateKey("LineResolutionStandardDeviation", - lineResStat.StandardDeviation(),"meters/pixel"); + lineResStat.StandardDeviation(), "meters/pixel"); PvlGroup pResolution("Resolution"); - pResolution += ValidateKey("ResolutionMinimum",resStat.Minimum(), - "meters/pixel"); - pResolution += ValidateKey("ResolutionMaximum",resStat.Maximum(), - "meters/pixel"); - pResolution += ValidateKey("ResolutionAverage",resStat.Average(), - "meters/pixel"); + pResolution += ValidateKey("ResolutionMinimum", resStat.Minimum(), + "meters/pixel"); + pResolution += ValidateKey("ResolutionMaximum", resStat.Maximum(), + "meters/pixel"); + pResolution += ValidateKey("ResolutionAverage", resStat.Average(), + "meters/pixel"); pResolution += ValidateKey("ResolutionStandardDeviation", - resStat.StandardDeviation(),"meters/pixel"); + resStat.StandardDeviation(), "meters/pixel"); PvlGroup pAspectRatio("AspectRatio"); - pAspectRatio += ValidateKey("AspectRatioMinimum",aspectRatioStat.Minimum()); - pAspectRatio += ValidateKey("AspectRatioMaximun",aspectRatioStat.Maximum()); - pAspectRatio += ValidateKey("AspectRatioAverage",aspectRatioStat.Average()); + pAspectRatio += ValidateKey("AspectRatioMinimum", aspectRatioStat.Minimum()); + pAspectRatio += ValidateKey("AspectRatioMaximun", aspectRatioStat.Maximum()); + pAspectRatio += ValidateKey("AspectRatioAverage", aspectRatioStat.Average()); pAspectRatio += ValidateKey("AspectRatioStandardDeviation", - aspectRatioStat.StandardDeviation()); + aspectRatioStat.StandardDeviation()); PvlGroup pPhase("PhaseAngle"); - pPhase += ValidateKey("PhaseMinimum",phaseStat.Minimum()); - pPhase += ValidateKey("PhaseMaximum",phaseStat.Maximum()); - pPhase += ValidateKey("PhaseAverage",phaseStat.Average()); - pPhase += ValidateKey("PhaseStandardDeviation",phaseStat.StandardDeviation()); + pPhase += ValidateKey("PhaseMinimum", phaseStat.Minimum()); + pPhase += ValidateKey("PhaseMaximum", phaseStat.Maximum()); + pPhase += ValidateKey("PhaseAverage", phaseStat.Average()); + pPhase += ValidateKey("PhaseStandardDeviation", phaseStat.StandardDeviation()); PvlGroup pEmission("EmissionAngle"); - pEmission += ValidateKey("EmissionMinimum",emissionStat.Minimum()); - pEmission += ValidateKey("EmissionMaximum",emissionStat.Maximum()); - pEmission += ValidateKey("EmissionAverage",emissionStat.Average()); + pEmission += ValidateKey("EmissionMinimum", emissionStat.Minimum()); + pEmission += ValidateKey("EmissionMaximum", emissionStat.Maximum()); + pEmission += ValidateKey("EmissionAverage", emissionStat.Average()); pEmission += ValidateKey("EmissionStandardDeviation", - emissionStat.StandardDeviation()); + emissionStat.StandardDeviation()); PvlGroup pIncidence("IncidenceAngle"); - pIncidence += ValidateKey("IncidenceMinimum",incidenceStat.Minimum()); - pIncidence += ValidateKey("IncidenceMaximum",incidenceStat.Maximum()); - pIncidence += ValidateKey("IncidenceAverage",incidenceStat.Average()); + pIncidence += ValidateKey("IncidenceMinimum", incidenceStat.Minimum()); + pIncidence += ValidateKey("IncidenceMaximum", incidenceStat.Maximum()); + pIncidence += ValidateKey("IncidenceAverage", incidenceStat.Average()); pIncidence += ValidateKey("IncidenceStandardDeviation", - incidenceStat.StandardDeviation()); + incidenceStat.StandardDeviation()); PvlGroup pTime("LocalSolarTime"); - pTime += ValidateKey("LocalSolarTimeMinimum",localSolarTimeStat.Minimum(), - "hours"); - pTime += ValidateKey("LocalSolarTimeMaximum",localSolarTimeStat.Maximum(), - "hours"); - pTime += ValidateKey("LocalSolarTimeAverage",localSolarTimeStat.Average(), - "hours"); + pTime += ValidateKey("LocalSolarTimeMinimum", localSolarTimeStat.Minimum(), + "hours"); + pTime += ValidateKey("LocalSolarTimeMaximum", localSolarTimeStat.Maximum(), + "hours"); + pTime += ValidateKey("LocalSolarTimeAverage", localSolarTimeStat.Average(), + "hours"); pTime += ValidateKey("LocalSolarTimeStandardDeviation", - localSolarTimeStat.StandardDeviation(),"hours"); + localSolarTimeStat.StandardDeviation(), "hours"); PvlGroup pLocalRadius("LocalRadius"); - pLocalRadius += ValidateKey("LocalRadiusMinimum",localRaduisStat.Minimum()); - pLocalRadius += ValidateKey("LocalRadiusMaximum",localRaduisStat.Maximum()); - pLocalRadius += ValidateKey("LocalRadiusAverage",localRaduisStat.Average()); + pLocalRadius += ValidateKey("LocalRadiusMinimum", localRaduisStat.Minimum()); + pLocalRadius += ValidateKey("LocalRadiusMaximum", localRaduisStat.Maximum()); + pLocalRadius += ValidateKey("LocalRadiusAverage", localRaduisStat.Average()); pLocalRadius += ValidateKey("LocalRadiusStandardDeviation", - localRaduisStat.StandardDeviation()); + localRaduisStat.StandardDeviation()); PvlGroup pNorthAzimuth("NorthAzimuth"); - pNorthAzimuth += ValidateKey("NorthAzimuthMinimum",northAzimuthStat.Minimum()); - pNorthAzimuth += ValidateKey("NorthAzimuthMaximum",northAzimuthStat.Maximum()); - pNorthAzimuth += ValidateKey("NorthAzimuthAverage",northAzimuthStat.Average()); + pNorthAzimuth += ValidateKey("NorthAzimuthMinimum", northAzimuthStat.Minimum()); + pNorthAzimuth += ValidateKey("NorthAzimuthMaximum", northAzimuthStat.Maximum()); + pNorthAzimuth += ValidateKey("NorthAzimuthAverage", northAzimuthStat.Average()); pNorthAzimuth += ValidateKey("NorthAzimuthStandardDeviation", - northAzimuthStat.StandardDeviation()); + northAzimuthStat.StandardDeviation()); // Send the Output to the log area Application::Log(pUser); @@ -222,14 +222,14 @@ void IsisMain(){ Application::Log(pLocalRadius); Application::Log(pNorthAzimuth); - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { string from = ui.GetFilename("FROM"); string outfile = Filename(ui.GetFilename("TO")).Expanded(); bool exists = Filename(outfile).Exists(); bool append = ui.GetBoolean("APPEND"); //If the user chooses a fromat of PVL then write to the output file ("TO") - if (ui.GetString("FORMAT") == "PVL") { + if(ui.GetString("FORMAT") == "PVL") { Pvl temp; temp.SetTerminator(""); temp.AddGroup(pUser); @@ -246,7 +246,7 @@ void IsisMain(){ temp.AddGroup(pLocalRadius); temp.AddGroup(pNorthAzimuth); - if (append) { + if(append) { temp.Append(outfile); } else { @@ -254,101 +254,101 @@ void IsisMain(){ } } - //Create a flatfile of the data with columhn headings + //Create a flatfile of the data with columhn headings // the flatfile is comma delimited and can be imported in to spreadsheets else { ofstream os; bool writeHeader = true; - if (append) { - os.open(outfile.c_str(),ios::app); - if (exists) { + if(append) { + os.open(outfile.c_str(), ios::app); + if(exists) { writeHeader = false; } } else { - os.open(outfile.c_str(),ios::out); + os.open(outfile.c_str(), ios::out); } // if new file or append and no file exists then write header - if(writeHeader){ - os << "Filename,"<< - "LatitudeMinimum,"<< - "LatitudeMaximum,"<< - "LatitudeAverage,"<< - "LatitudeStandardDeviation,"<< - "LongitudeMinimum,"<< - "LongitudeMaximum,"<< - "LongitudeAverage,"<< - "LongitudeStandardDeviation,"<< - "SampleResolutionMinimum,"<< - "SampleResolutionMaximum,"<< - "SampleResolutionAverage,"<< - "SampleResolutionStandardDeviation,"<< - "LineResolutionMinimum,"<< - "LineResolutionMaximum,"<< - "LineResolutionAverage,"<< - "LineResolutionStandardDeviation,"<< - "ResolutionMinimum,"<< - "ResolutionMaximum,"<< - "ResolutionAverage,"<< - "ResolutionStandardDeviation,"<< - "AspectRatioMinimum,"<< - "AspectRatioMaximum,"<< - "AspectRatioAverage,"<< - "AspectRatioStandardDeviation,"<< - "PhaseMinimum,"<< - "PhaseMaximum,"<< - "PhaseAverage,"<< - "PhaseStandardDeviation,"<< - "EmissionMinimum,"<< - "EmissionMaximum,"<< - "EmissionAverage,"<< - "EmissionStandardDeviation,"<< - "IncidenceMinimum,"<< - "IncidenceMaximum,"<< - "IncidenceAverage,"<< - "IncidenceStandardDeviation,"<< - "LocalSolarTimeMinimum,"<< - "LocalSolarTimeMaximum,"<< - "LocalSolarTimeAverage,"<< - "LocalSolarTimeStandardDeviation,"<< - "LocalRadiusMaximum,"<< - "LocalRadiusMaximum,"<< - "LocalRadiusAverage,"<< - "LocalRadiusStandardDeviation,"<< - "NorthAzimuthMinimum,"<< - "NorthAzimuthMaximum,"<< - "NorthAzimuthAverage,"<< - "NorthAzimuthStandardDeviation,"< grps; - grps.push_back( pLat ); - grps.push_back( pLon ); - grps.push_back( pSampleRes ); - grps.push_back( pLineRes ); - grps.push_back( pResolution ); - grps.push_back( pAspectRatio ); - grps.push_back( pPhase ); - grps.push_back( pEmission ); - grps.push_back( pIncidence ); - grps.push_back( pTime ); - grps.push_back( pLocalRadius ); - grps.push_back( pNorthAzimuth ); - - for( vector::iterator g = grps.begin(); g != grps.end(); g++ ) { + grps.push_back(pLat); + grps.push_back(pLon); + grps.push_back(pSampleRes); + grps.push_back(pLineRes); + grps.push_back(pResolution); + grps.push_back(pAspectRatio); + grps.push_back(pPhase); + grps.push_back(pEmission); + grps.push_back(pIncidence); + grps.push_back(pTime); + grps.push_back(pLocalRadius); + grps.push_back(pNorthAzimuth); + + for(vector::iterator g = grps.begin(); g != grps.end(); g++) { int i = 0; record[i++] = g->Name(); - record[i++] = (double) (*g)[0][0]; - record[i++] = (double) (*g)[1][0]; - record[i++] = (double) (*g)[2][0]; - record[i++] = (double) (*g)[3][0]; + record[i++] = (double)(*g)[0][0]; + record[i++] = (double)(*g)[1][0]; + record[i++] = (double)(*g)[2][0]; + record[i++] = (double)(*g)[3][0]; table += record; } - icube->ReOpen( "rw" ); - icube->Write( table ); + icube->ReOpen("rw"); + icube->Write(table); p.WriteHistory(*icube); icube->Close(); @@ -394,9 +394,9 @@ void IsisMain(){ //function to add stats data to the stats object. //also tests if the line and samp are valid -void buildStats (Camera *cam, int &sample, int &line){ +void buildStats(Camera *cam, int &sample, int &line) { cam->SetImage(sample, line); - if (cam->HasSurfaceIntersection()) { + if(cam->HasSurfaceIntersection()) { latStat.AddData(cam->UniversalLatitude()); lonStat.AddData(cam->UniversalLongitude()); resStat.AddData(cam->PixelResolution()); @@ -410,12 +410,12 @@ void buildStats (Camera *cam, int &sample, int &line){ northAzimuthStat.AddData(cam->NorthAzimuth()); double Aratio = cam->LineResolution() / cam->SampleResolution(); - aspectRatioStat.AddData(Aratio); + aspectRatioStat.AddData(Aratio); } } static inline string ValidateValue(const double &value) { - if ( IsSpecial(value) ) { + if(IsSpecial(value)) { return (string("NULL")); } else { @@ -424,9 +424,9 @@ static inline string ValidateValue(const double &value) { } //function to write the stats values to flat file -void writeFlat (ofstream &os, Statistics &s){ - os << ValidateValue(s.Minimum())<<","<< - ValidateValue(s.Maximum())<<","<< - ValidateValue(s.Average())<<","<< - ValidateValue(s.StandardDeviation())<<","; +void writeFlat(ofstream &os, Statistics &s) { + os << ValidateValue(s.Minimum()) << "," << + ValidateValue(s.Maximum()) << "," << + ValidateValue(s.Average()) << "," << + ValidateValue(s.StandardDeviation()) << ","; } diff --git a/isis/src/base/apps/camtrim/camtrim.cpp b/isis/src/base/apps/camtrim/camtrim.cpp index 58fe72c7fb..a6eb947d48 100644 --- a/isis/src/base/apps/camtrim/camtrim.cpp +++ b/isis/src/base/apps/camtrim/camtrim.cpp @@ -4,20 +4,20 @@ #include "SpecialPixel.h" #include "ProjectionFactory.h" -using namespace std; +using namespace std; using namespace Isis; // Global variables Cube *icube; Camera *cam; Projection *proj; -double minlat; -double maxlat; +double minlat; +double maxlat; double minlon; double maxlon; int lastBand; -void camtrim (Buffer &in, Buffer &out); +void camtrim(Buffer &in, Buffer &out); void IsisMain() { // We will be processing by line @@ -28,7 +28,7 @@ void IsisMain() { cam = icube->Camera(); // Create the output cube - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); // Get the lat/lon range to trim UserInterface &ui = Application::GetUserInterface(); @@ -36,17 +36,17 @@ void IsisMain() { maxlat = ui.GetDouble("MAXLAT"); minlon = ui.GetDouble("MINLON"); maxlon = ui.GetDouble("MAXLON"); - - // Get map projection to determine what type of + + // Get map projection to determine what type of // lat/lons the user wants - if (ui.WasEntered("MAP")) { + if(ui.WasEntered("MAP")) { Pvl lab; lab.Read(ui.GetFilename("MAP")); proj = ProjectionFactory::Create(lab); // add mapping to print.prt - PvlGroup mapping = proj->Mapping(); - Application::Log(mapping); + PvlGroup mapping = proj->Mapping(); + Application::Log(mapping); } else { proj = NULL; @@ -59,29 +59,29 @@ void IsisMain() { } // Line processing routine -void camtrim (Buffer &in, Buffer &out) { +void camtrim(Buffer &in, Buffer &out) { // See if there is a change in band which would change the camera model - if (in.Band() != lastBand) { + if(in.Band() != lastBand) { lastBand = in.Band(); cam->SetBand(icube->PhysicalBand(lastBand)); } - // Loop for each pixel in the line. - double samp,lat,lon; + // Loop for each pixel in the line. + double samp, lat, lon; double line = in.Line(); - for (int i=0; iSetImage(samp,line); - if (cam->HasSurfaceIntersection()) { + cam->SetImage(samp, line); + if(cam->HasSurfaceIntersection()) { lat = cam->UniversalLatitude(); lon = cam->UniversalLongitude(); - if (proj != NULL) { - proj->SetUniversalGround(lat,lon); + if(proj != NULL) { + proj->SetUniversalGround(lat, lon); lat = proj->Latitude(); lon = proj->Longitude(); } // Pixel is outside range - if ((lat < minlat) || (lat > maxlat) || + if((lat < minlat) || (lat > maxlat) || (lon < minlon) || (lon > maxlon)) { out[i] = NULL8; } diff --git a/isis/src/base/apps/cathist/cathist.cpp b/isis/src/base/apps/cathist/cathist.cpp index d63b344f7a..d121afeed6 100644 --- a/isis/src/base/apps/cathist/cathist.cpp +++ b/isis/src/base/apps/cathist/cathist.cpp @@ -9,9 +9,9 @@ using namespace Isis; using namespace std; -void IsisMain(){ +void IsisMain() { - // Get user entered file name & mode + // Get user entered file name & mode UserInterface &ui = Application::GetUserInterface(); string file = ui.GetFilename("FROM"); string mode = ui.GetString("MODE"); @@ -21,9 +21,9 @@ void IsisMain(){ Pvl pvl = hist.ReturnHist(); // Print full history - if(mode=="FULL"){ - if (ui.IsInteractive()) { - Application::GuiLog(pvl); + if(mode == "FULL") { + if(ui.IsInteractive()) { + Application::GuiLog(pvl); } else { cout << pvl << endl; @@ -31,25 +31,25 @@ void IsisMain(){ } // Print brief history in command line form - else if(mode=="BRIEF"){ - for(int i=0; iLines() / 2; csamp = icube->Samples() / 2; @@ -23,9 +23,9 @@ void IsisMain() { // Override the defaults if the user entered a value UserInterface &ui = Application::GetUserInterface(); - if (ui.WasEntered ("LINE")) cline = ui.GetDouble ("LINE"); - if (ui.WasEntered ("SAMPLE")) csamp = ui.GetDouble ("SAMPLE"); - if (ui.WasEntered ("RADIUS")) radius = ui.GetDouble ("RADIUS"); + if(ui.WasEntered("LINE")) cline = ui.GetDouble("LINE"); + if(ui.WasEntered("SAMPLE")) csamp = ui.GetDouble("SAMPLE"); + if(ui.WasEntered("RADIUS")) radius = ui.GetDouble("RADIUS"); // Start the processing p.StartProcess(circle); @@ -33,23 +33,23 @@ void IsisMain() { } // Line processing routine -void circle (Buffer &in, Buffer &out) { +void circle(Buffer &in, Buffer &out) { // Compute part of the distance (doesn't vary since the line is constant) double dist, partA, partB; partA = cline - (double) in.Line(); - partA *= partA; + partA *= partA; - // Loop for each pixel in the line. - for (int i=0; i fscMap; - std::map snMap; + std::map fscMap; + std::map snMap; UserInterface &ui = Application::GetUserInterface(); FileList list2(ui.GetFilename("LIST2")); SerialNumberList snl(ui.GetFilename("LIST3")); - for (unsigned int f=0; f(f,fsc)); - snMap.insert(std::pair(sn,f)); + iString sn(snl.SerialNumber(f)); + fscMap.insert(std::pair(f, fsc)); + snMap.insert(std::pair(sn, f)); } ControlNet cnet(ui.GetFilename("CONTROL")); int mpTotal = 0; - for (int i=0; i > p_pointLatLon; +std::map< std::string, std::pair > p_pointLatLon; std::map< int, set > p_modifiedMeasures; void IsisMain() { UserInterface &ui = Application::GetUserInterface(); - FileList list2 (ui.GetFilename("ADDLIST")); + FileList list2(ui.GetFilename("ADDLIST")); bool hasDuplicateSerialNumbers = false; bool log = false; Filename logFile; - if (ui.WasEntered("LOG")) { + if(ui.WasEntered("LOG")) { log = true; logFile = ui.GetFilename("LOG"); } Pvl results; results.SetName("cnetadd_Results"); - PvlKeyword added ("FilesAdded"); - PvlKeyword omitted ("FilesOmitted"); - PvlKeyword pointsModified ("PointsModified"); + PvlKeyword added("FilesAdded"); + PvlKeyword omitted("FilesOmitted"); + PvlKeyword pointsModified("PointsModified"); string retrievalOpt = ui.GetString("RETRIEVAL"); - PvlKeyword duplicates ("DupSerialNumbers"); - if (retrievalOpt == "REFERENCE") { - FileList list1 (ui.GetFilename("FROMLIST")); - SerialNumberList addSerials (ui.GetFilename("ADDLIST")); - SerialNumberList fromSerials (ui.GetFilename("FROMLIST")); + PvlKeyword duplicates("DupSerialNumbers"); + if(retrievalOpt == "REFERENCE") { + FileList list1(ui.GetFilename("FROMLIST")); + SerialNumberList addSerials(ui.GetFilename("ADDLIST")); + SerialNumberList fromSerials(ui.GetFilename("FROMLIST")); //Check for duplicate files in the lists by serial number - for (int i = 0; i < addSerials.Size(); i++) { + for(int i = 0; i < addSerials.Size(); i++) { // Check for duplicate SNs accross the lists - if (fromSerials.HasSerialNumber(addSerials.SerialNumber(i))) { + if(fromSerials.HasSerialNumber(addSerials.SerialNumber(i))) { duplicates.AddValue(addSerials.Filename(i)); } // Check for duplicate SNs within the addlist - for (int j = i+1; j < addSerials.Size(); j++) { - if (addSerials.SerialNumber(i) == addSerials.SerialNumber(j)) { + for(int j = i + 1; j < addSerials.Size(); j++) { + if(addSerials.SerialNumber(i) == addSerials.SerialNumber(j)) { string msg = "Add list files [" + addSerials.Filename(i) + "] and ["; msg += addSerials.Filename(j) + "] share the same serial number."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } } - + // If duplicates throw error - if (duplicates.Size() > 0) { + if(duplicates.Size() > 0) { hasDuplicateSerialNumbers = true; } - - SetControlPointLatLon( ui.GetFilename("FROMLIST"), ui.GetFilename("INNET") ); + + SetControlPointLatLon(ui.GetFilename("FROMLIST"), ui.GetFilename("INNET")); } Filename outNet(ui.GetFilename("OUTNET")); - + ControlNet inNet = ControlNet(ui.GetFilename("INNET")); - inNet.SetUserName( Isis::Application::UserName() ); + inNet.SetUserName(Isis::Application::UserName()); //inNet.SetCreatedDate( Isis::Application::DateTime() ); //This should be done in ControlNet's Write fn - inNet.SetModifiedDate( Isis::iTime::CurrentLocalTime() ); - + inNet.SetModifiedDate(Isis::iTime::CurrentLocalTime()); + Progress progress; progress.SetText("Adding Images"); progress.SetMaximumSteps(list2.size()); progress.CheckStatus(); - + // loop through all the images vector modPoints; - for (unsigned int img = 0; img < list2.size(); img++) { + for(unsigned int img = 0; img < list2.size(); img++) { Pvl cubepvl; bool imageAdded = false; cubepvl.Read(list2[img]); Camera *cam = CameraFactory::Create(cubepvl); - + //loop through all the control points - for (int cp = 0; cp < inNet.Size(); cp++) { - ControlPoint point( inNet[cp] ); - + for(int cp = 0; cp < inNet.Size(); cp++) { + ControlPoint point(inNet[cp]); + double latitude; double longitude; - if (retrievalOpt == "REFERENCE") { + if(retrievalOpt == "REFERENCE") { // Get the lat/long coords from the existing reference measure latitude = p_pointLatLon[point.Id()].first; longitude = p_pointLatLon[point.Id()].second; @@ -113,56 +113,58 @@ void IsisMain() { // Get the lat/long coords from the current control point latitude = point.UniversalLatitude(); longitude = point.UniversalLongitude(); - if( latitude == Isis::Null || longitude == Isis::Null ) { + if(latitude == Isis::Null || longitude == Isis::Null) { std::string msg = "Unable to retreive lat/lon from Control Point ["; msg += point.Id() + "]. RETREIVAL=POINT cannot be used unless all Control "; msg += "Points have Latitude/Longitude keywords."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } - if (cam->SetUniversalGround(latitude, longitude)) { - + if(cam->SetUniversalGround(latitude, longitude)) { + // Make sure the samp & line are inside the image - if (cam->InCube()) { + if(cam->InCube()) { // If there are duplicate serial numbers in the addlist, prevent double adding - if( hasDuplicateSerialNumbers ) { - std::string sn = SerialNumber::Compose( cubepvl ); + if(hasDuplicateSerialNumbers) { + std::string sn = SerialNumber::Compose(cubepvl); bool hasSerialNumber = false; - for( int cm = 0; cm < point.Size() && !hasSerialNumber; cm ++ ) { - if( sn == point[cm].CubeSerialNumber() ) { + for(int cm = 0; cm < point.Size() && !hasSerialNumber; cm ++) { + if(sn == point[cm].CubeSerialNumber()) { hasSerialNumber = true; } } - if( hasSerialNumber ) { continue; } + if(hasSerialNumber) { + continue; + } } ControlMeasure newCm; - newCm.SetCoordinate(cam->Sample(),cam->Line(),ControlMeasure::Estimated); + newCm.SetCoordinate(cam->Sample(), cam->Line(), ControlMeasure::Estimated); newCm.SetCubeSerialNumber(SerialNumber::Compose(cubepvl)); newCm.SetDateTime(); newCm.SetChooserName("Application cnetadd"); inNet[cp].Add(newCm); // Record the modified Point and Measure p_modifiedMeasures[cp].insert(newCm.CubeSerialNumber()); - - if (retrievalOpt == "POINT" && inNet[cp].Size() == 1) { + + if(retrievalOpt == "POINT" && inNet[cp].Size() == 1) { inNet[cp].SetIgnore(false); } - if (log) { + if(log) { // If we can't find this control point in the list of control points // that have already been modified, then add it to the list bool doesntContainPoint = true; - for (unsigned int i = 0; i < modPoints.size() && doesntContainPoint; i++) { - if (modPoints[i] == cp) doesntContainPoint = false; + for(unsigned int i = 0; i < modPoints.size() && doesntContainPoint; i++) { + if(modPoints[i] == cp) doesntContainPoint = false; } - if (doesntContainPoint) { + if(doesntContainPoint) { modPoints.push_back(cp); } @@ -175,58 +177,59 @@ void IsisMain() { delete cam; cam = NULL; - if (log) { - if (imageAdded) added.AddValue(Isis::Filename(list2[img]).Basename()); + if(log) { + if(imageAdded) added.AddValue(Isis::Filename(list2[img]).Basename()); else omitted.AddValue(Isis::Filename(list2[img]).Basename()); } progress.CheckStatus(); } - if (log) { + if(log) { // Shell sort the list of modified control points int increments[] = { 1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, - 861, 336, 112, 48, 21, 7, 3, 1 }; - for (unsigned int k = 0; k < 16; k++) { + 861, 336, 112, 48, 21, 7, 3, 1 + }; + for(unsigned int k = 0; k < 16; k++) { int inc = increments[k]; - for (unsigned int i = inc; i < modPoints.size(); i++) { + for(unsigned int i = inc; i < modPoints.size(); i++) { int temp = modPoints[i]; int j = i; - while (j >= inc && modPoints[j - inc] > temp) { + while(j >= inc && modPoints[j - inc] > temp) { modPoints[j] = modPoints[j - inc]; j -= inc; } modPoints[j] = temp; } } - + // Add the list of modified points to the output log file - for (unsigned int i = 0; i < modPoints.size(); i++) { + for(unsigned int i = 0; i < modPoints.size(); i++) { pointsModified += inNet[modPoints[i]].Id(); } - + results.AddKeyword(added); results.AddKeyword(omitted); results.AddKeyword(pointsModified); - if( duplicates.Size() > 0 ) { + if(duplicates.Size() > 0) { results.AddKeyword(duplicates); } - + results.Write(logFile.Expanded()); } // List the modified points - if( ui.WasEntered("MODIFIEDPOINTS") ) { - Filename pointList( ui.GetFilename("MODIFIEDPOINTS") ); + if(ui.WasEntered("MODIFIEDPOINTS")) { + Filename pointList(ui.GetFilename("MODIFIEDPOINTS")); // Set up the output file for writing ofstream out_stream; out_stream.open(pointList.Expanded().c_str(), std::ios::out); - out_stream.seekp(0,std::ios::beg); //Start writing from beginning of file + out_stream.seekp(0, std::ios::beg); //Start writing from beginning of file - for( std::map< int, std::set >::iterator it = p_modifiedMeasures.begin(); - it != p_modifiedMeasures.end(); it ++ ) { + for(std::map< int, std::set >::iterator it = p_modifiedMeasures.begin(); + it != p_modifiedMeasures.end(); it ++) { out_stream << inNet[it->first].Id() << std::endl; } @@ -234,18 +237,18 @@ void IsisMain() { } // Modify the inNet to only have modified points/measures - if( ui.GetString("EXTRACT") == "MODIFIED" ) { - for( int cp = inNet.Size()-1; cp >= 0; cp -- ) { + if(ui.GetString("EXTRACT") == "MODIFIED") { + for(int cp = inNet.Size() - 1; cp >= 0; cp --) { std::map< int, set >::iterator it = p_modifiedMeasures.find(cp); // If the point was not modified, delete - if( it == p_modifiedMeasures.end() ) { + if(it == p_modifiedMeasures.end()) { inNet.Delete(cp); } // Else, remove the unwanted measures from the modified point else { - for( int cm = inNet[cp].Size()-1; cm >= 0; cm -- ) { - if( !inNet[cp][cm].IsReference() && - it->second.find(inNet[cp][cm].CubeSerialNumber()) == it->second.end() ) { + for(int cm = inNet[cp].Size() - 1; cm >= 0; cm --) { + if(!inNet[cp][cm].IsReference() && + it->second.find(inNet[cp][cm].CubeSerialNumber()) == it->second.end()) { inNet[cp].Delete(cm); } } @@ -260,13 +263,13 @@ void IsisMain() { /** * Calculates the lat/lon of the ControlNet. - * + * * @param incubes The filename of the list of cubes in the ControlNet * @param cnet The filename of the ControlNet */ -void SetControlPointLatLon( const std::string &incubes, const std::string &cnet ) { - SerialNumberList snl( incubes ); - ControlNet net( cnet ); +void SetControlPointLatLon(const std::string &incubes, const std::string &cnet) { + SerialNumberList snl(incubes); + ControlNet net(cnet); CubeManager manager; manager.SetNumOpenCubes(50); //Should keep memory usage to around 1GB @@ -276,19 +279,20 @@ void SetControlPointLatLon( const std::string &incubes, const std::string &cnet progress.SetMaximumSteps(net.Size()); progress.CheckStatus(); - for (int cp = 0; cp < net.Size(); cp++) { - ControlPoint point( net[cp] ); - ControlMeasure cm( point[ net[cp].ReferenceIndex() ] ); + for(int cp = 0; cp < net.Size(); cp++) { + ControlPoint point(net[cp]); + ControlMeasure cm(point[ net[cp].ReferenceIndex() ]); - Cube *cube = manager.OpenCube( snl.Filename( cm.CubeSerialNumber() ) ); + Cube *cube = manager.OpenCube(snl.Filename(cm.CubeSerialNumber())); try { - cube->Camera()->SetImage( cm.Sample(), cm.Line() ); + cube->Camera()->SetImage(cm.Sample(), cm.Line()); p_pointLatLon[point.Id()].first = cube->Camera()->UniversalLatitude(); p_pointLatLon[point.Id()].second = cube->Camera()->UniversalLongitude(); - } catch (Isis::iException &e) { + } + catch(Isis::iException &e) { std::string msg = "Unable to create camera for cube file ["; - msg += snl.Filename( cm.CubeSerialNumber() ) + "]"; - throw Isis::iException::Message(Isis::iException::System,msg,_FILEINFO_); + msg += snl.Filename(cm.CubeSerialNumber()) + "]"; + throw Isis::iException::Message(Isis::iException::System, msg, _FILEINFO_); } cube = NULL; //Do not delete, manager still has ownership diff --git a/isis/src/base/apps/cnetcheck/cnetcheck.cpp b/isis/src/base/apps/cnetcheck/cnetcheck.cpp index aa62f1e618..797cb6b5fa 100644 --- a/isis/src/base/apps/cnetcheck/cnetcheck.cpp +++ b/isis/src/base/apps/cnetcheck/cnetcheck.cpp @@ -19,33 +19,33 @@ #include "SerialNumberList.h" #include "UserInterface.h" -using namespace std; +using namespace std; using namespace Isis; map< string, set > constructPointSets(set &index, - ControlNet &innet); -vector< set > findIslands(set &index, map< string, - set > &adjCubes); -void WriteOutput( SerialNumberList num2cube, string suffix, - set &sns, map< string, set > &cps ); + ControlNet &innet); +vector< set > findIslands(set &index, map < string, + set > &adjCubes); +void WriteOutput(SerialNumberList num2cube, string suffix, + set &sns, map< string, set > &cps); // Main program void IsisMain() { Progress progress; UserInterface &ui = Application::GetUserInterface(); - ControlNet innet( ui.GetFilename("CNET"), NULL, true ); + ControlNet innet(ui.GetFilename("CNET"), NULL, true); iString prefix(ui.GetString("PREFIX")); bool ignore = ui.GetBoolean("IGNORE"); // Sets up the list of serial numbers for FileList inlist(ui.GetFilename("FROMLIST")); set inListNums; - map netSerialNumCount; + map netSerialNumCount; vector listedSerialNumbers; SerialNumberList num2cube; - if (inlist.size() > 0) { + if(inlist.size() > 0) { progress.SetText("Initializing"); progress.SetMaximumSteps(inlist.size()); progress.CheckStatus(); @@ -74,7 +74,7 @@ void IsisMain() { map< string, int > cubeMeasureCount; // Set calculating progress - if (innet.Size() > 0) { + if(innet.Size() > 0) { progress.SetText("Calculating"); progress.SetMaximumSteps(innet.Size()); progress.CheckStatus(); @@ -90,23 +90,24 @@ void IsisMain() { ControlPoint controlpt(innet[cp]); // Checks for lat/Lon production - if( ui.GetBoolean("NOLATLON") ) { + if(ui.GetBoolean("NOLATLON")) { // Loop through all control measures in control points - for (int cm = 0; cm < controlpt.Size(); cm ++) { + for(int cm = 0; cm < controlpt.Size(); cm ++) { ControlMeasure controlms = controlpt[cm]; // If we have the cube, check it out - if (num2cube.HasSerialNumber(controlms.CubeSerialNumber())) { - Cube * cube = cbman.OpenCube(num2cube.Filename(controlms.CubeSerialNumber())); - Camera * cam = NULL; + if(num2cube.HasSerialNumber(controlms.CubeSerialNumber())) { + Cube *cube = cbman.OpenCube(num2cube.Filename(controlms.CubeSerialNumber())); + Camera *cam = NULL; bool createFail = false; bool setPassed = true; // Try to create try { cam = cube->Camera(); - } catch(iException &e) { + } + catch(iException &e) { createFail = true; e.Clear(); } @@ -119,7 +120,7 @@ void IsisMain() { // Record it if it failed at anything if(createFail || !setPassed) { noLatLonSerialNumbers.insert(controlms.CubeSerialNumber()); - noLatLonControlPoints[controlms.CubeSerialNumber()].insert( controlpt.Id() ); + noLatLonControlPoints[controlms.CubeSerialNumber()].insert(controlpt.Id()); } } } @@ -128,7 +129,7 @@ void IsisMain() { if(controlpt.NumValidMeasures() == 1) { string sn = controlpt[0].CubeSerialNumber(); singleMeasureSerialNumbers.insert(sn); - singleMeasureControlPoints[sn].insert( controlpt.Id() ); + singleMeasureControlPoints[sn].insert(controlpt.Id()); // Records how many times a cube is in the ControlNet cubeMeasureCount[sn] ++; @@ -137,7 +138,7 @@ void IsisMain() { // Checks for duplicate Measures for the same SerialNumber vector controlMeasures; for(int cm = 0; cm < controlpt.Size(); cm ++) { - if( ignore && controlpt[cm].Ignore() ) continue; + if(ignore && controlpt[cm].Ignore()) continue; controlMeasures.push_back(controlpt[cm]); iString currentsn = controlpt[cm].CubeSerialNumber(); @@ -146,15 +147,15 @@ void IsisMain() { cubeMeasureCount[currentsn] ++; // Compares previous ControlMeasure SerialNumbers with the current - for(int pre_cm = controlMeasures.size()-1-1; pre_cm >= 0; pre_cm --) { - if( controlMeasures[pre_cm].CubeSerialNumber() == currentsn ) { + for(int pre_cm = controlMeasures.size() - 1 - 1; pre_cm >= 0; pre_cm --) { + if(controlMeasures[pre_cm].CubeSerialNumber() == currentsn) { duplicateSerialNumbers.insert(currentsn); //serial number duplication - duplicateControlPoints[currentsn].insert( controlpt.Id() ); + duplicateControlPoints[currentsn].insert(controlpt.Id()); } } // Removes from the serial number list, cubes that are included in the cnet - inListNums.erase( currentsn ); + inListNums.erase(currentsn); netSerialNumCount[currentsn] ++; // Records if the currentsnum is not in the input cube list @@ -189,16 +190,16 @@ void IsisMain() { // Output islands in the file-by-file format // Islands that have no cubes listed in the input list will // not be shown. - for(int i=0; i < (int)islands.size(); i++) { - string name(Filename(prefix + "Island." + iString(i+1)).Expanded()); + for(int i = 0; i < (int)islands.size(); i++) { + string name(Filename(prefix + "Island." + iString(i + 1)).Expanded()); ofstream out_stream; out_stream.open(name.c_str(), std::ios::out); - out_stream.seekp(0,std::ios::beg); //Start writing from beginning of file + out_stream.seekp(0, std::ios::beg); //Start writing from beginning of file bool hasList = false; for(set::iterator island = islands[i].begin(); - island != islands[i].end(); island++) { - if (num2cube.HasSerialNumber(*island)) { + island != islands[i].end(); island++) { + if(num2cube.HasSerialNumber(*island)) { out_stream << (num2cube.HasSerialNumber(*island) ? Filename(num2cube.Filename(*island)).Name() : "") << " " << *island; out_stream << "\n"; @@ -208,7 +209,7 @@ void IsisMain() { out_stream.close(); - if (!hasList) { + if(!hasList) { remove(name.c_str()); } } @@ -218,11 +219,11 @@ void IsisMain() { PvlGroup results("Results"); - stringstream ss (stringstream::in | stringstream::out); + stringstream ss(stringstream::in | stringstream::out); - results.AddKeyword( PvlKeyword("Islands",iString((BigInt)islands.size())) ); + results.AddKeyword(PvlKeyword("Islands", iString((BigInt)islands.size()))); ss << endl << "----------------------------------------" \ - "----------------------------------------" << endl; + "----------------------------------------" << endl; if(islands.size() == 1) { ss << "The cubes are fully connected by the Control Network." << endl; } @@ -236,16 +237,16 @@ void IsisMain() { } if(ui.GetBoolean("SINGLEMEASURE") && singleMeasureSerialNumbers.size() > 0) { - results.AddKeyword( - PvlKeyword("SingleMeasure",iString((BigInt)singleMeasureSerialNumbers.size())) ); + results.AddKeyword( + PvlKeyword("SingleMeasure", iString((BigInt)singleMeasureSerialNumbers.size()))); string name(Filename(prefix + "SinglePointCubes.txt").Expanded()); - WriteOutput( num2cube, name, - singleMeasureSerialNumbers, singleMeasureControlPoints ); + WriteOutput(num2cube, name, + singleMeasureSerialNumbers, singleMeasureControlPoints); int serials = singleMeasureSerialNumbers.size(); ss << "----------------------------------------" \ - "----------------------------------------" << endl; + "----------------------------------------" << endl; ss << "There " << ((serials == 1) ? "is " : "are ") << singleMeasureSerialNumbers.size(); ss << ((serials == 1) ? " cube" : " cubes") << " in Control Points with only a single"; ss << " Control Measure." << endl; @@ -255,14 +256,14 @@ void IsisMain() { if(ui.GetBoolean("DUPLICATE") && duplicateSerialNumbers.size() > 0) { results.AddKeyword( - PvlKeyword("DuplicateMeasures",iString((BigInt)duplicateSerialNumbers.size())) ); + PvlKeyword("DuplicateMeasures", iString((BigInt)duplicateSerialNumbers.size()))); string name(Filename(prefix + "DuplicateMeasures.txt").Expanded()); - WriteOutput( num2cube, name, - duplicateSerialNumbers, duplicateControlPoints ); + WriteOutput(num2cube, name, + duplicateSerialNumbers, duplicateControlPoints); ss << "----------------------------------------" \ - "----------------------------------------" << endl; + "----------------------------------------" << endl; ss << "There are " << duplicateSerialNumbers.size(); ss << " duplicate Control Measures in the"; ss << " Control Net." << endl; @@ -272,14 +273,14 @@ void IsisMain() { if(ui.GetBoolean("NOLATLON") && noLatLonSerialNumbers.size() > 0) { results.AddKeyword( - PvlKeyword("NoLatLonCubes",iString((BigInt)noLatLonSerialNumbers.size())) ); + PvlKeyword("NoLatLonCubes", iString((BigInt)noLatLonSerialNumbers.size()))); string name(Filename(prefix + "NoLatLon.txt").Expanded()); - WriteOutput( num2cube, name, - noLatLonSerialNumbers, noLatLonControlPoints ); + WriteOutput(num2cube, name, + noLatLonSerialNumbers, noLatLonControlPoints); ss << "----------------------------------------" \ - "----------------------------------------" << endl; + "----------------------------------------" << endl; ss << "There are " << noLatLonSerialNumbers.size(); ss << " serial numbers in the Control Network which are listed in the"; ss << " input list and cannot compute latitude and longitudes." << endl; @@ -289,25 +290,25 @@ void IsisMain() { // At this point, inListNums is the list of cubes NOT included in the // ControlNet, and inListNums are their those cube's serial numbers. - if(ui.GetBoolean("NOCONTROL") && !inListNums.empty() ) { - results.AddKeyword( PvlKeyword("NoControl",iString((BigInt)inListNums.size())) ); + if(ui.GetBoolean("NOCONTROL") && !inListNums.empty()) { + results.AddKeyword(PvlKeyword("NoControl", iString((BigInt)inListNums.size()))); string name(Filename(prefix + "NoControl.txt").Expanded()); ofstream out_stream; out_stream.open(name.c_str(), std::ios::out); - out_stream.seekp(0,std::ios::beg); //Start writing from beginning of file - - for( set::iterator sn = inListNums.begin(); - sn != inListNums.end(); - sn ++) { + out_stream.seekp(0, std::ios::beg); //Start writing from beginning of file + + for(set::iterator sn = inListNums.begin(); + sn != inListNums.end(); + sn ++) { out_stream << (*sn); out_stream << "\t" << (num2cube.HasSerialNumber(*sn) ? Filename(num2cube.Filename(*sn)).Name() : ""); - out_stream << "\n"; + out_stream << "\n"; } out_stream.close(); - + ss << "----------------------------------------" \ - "----------------------------------------" << endl; + "----------------------------------------" << endl; ss << "There are " << inListNums.size(); ss << " cubes in the input list [" << Filename(ui.GetFilename("FROMLIST")).Name(); ss << "] which do not exist or are ignored in the Control Network ["; @@ -320,14 +321,14 @@ void IsisMain() { // cube in the input list. if(ui.GetBoolean("NOCUBE") && nonListedSerialNumbers.size() > 0) { results.AddKeyword( - PvlKeyword("NoCube",iString((BigInt)nonListedSerialNumbers.size())) ); + PvlKeyword("NoCube", iString((BigInt)nonListedSerialNumbers.size()))); string name(Filename(prefix + "NoCube.txt").Expanded()); ofstream out_stream; out_stream.open(name.c_str(), std::ios::out); - out_stream.seekp(0,std::ios::beg); //Start writing from beginning of file + out_stream.seekp(0, std::ios::beg); //Start writing from beginning of file - for(int sn=0; sn < (int)nonListedSerialNumbers.size(); sn++) { + for(int sn = 0; sn < (int)nonListedSerialNumbers.size(); sn++) { out_stream << nonListedSerialNumbers[sn]; out_stream << "\n"; } @@ -335,7 +336,7 @@ void IsisMain() { out_stream.close(); ss << "----------------------------------------" \ - "----------------------------------------" << endl; + "----------------------------------------" << endl; ss << "There are " << nonListedSerialNumbers.size(); ss << " serial numbers in the Control Net ["; ss << Filename(ui.GetFilename("CNET")).Basename(); @@ -347,26 +348,28 @@ void IsisMain() { // At this point cubeMeasureCount should be equal to the number of // ControlMeasures associated with each serial number. - if( ui.GetBoolean("SINGLECUBE") ) { + if(ui.GetBoolean("SINGLECUBE")) { set singleMeasureCubes; - for( map::iterator cube = cubeMeasureCount.begin(); - cube != cubeMeasureCount.end(); - cube ++ ) { - if( cube->second == 1 ) { singleMeasureCubes.insert( cube->first ); } + for(map::iterator cube = cubeMeasureCount.begin(); + cube != cubeMeasureCount.end(); + cube ++) { + if(cube->second == 1) { + singleMeasureCubes.insert(cube->first); + } } - if( singleMeasureCubes.size() > 0 ) { + if(singleMeasureCubes.size() > 0) { results.AddKeyword( - PvlKeyword("SingleCube",iString((BigInt)singleMeasureCubes.size())) ); + PvlKeyword("SingleCube", iString((BigInt)singleMeasureCubes.size()))); string name(Filename(prefix + "SingleCube.txt").Expanded()); ofstream out_stream; out_stream.open(name.c_str(), std::ios::out); - out_stream.seekp(0,std::ios::beg); //Start writing from beginning of file + out_stream.seekp(0, std::ios::beg); //Start writing from beginning of file - for( set::iterator sn = singleMeasureCubes.begin(); - sn != singleMeasureCubes.end(); - sn ++ ) { + for(set::iterator sn = singleMeasureCubes.begin(); + sn != singleMeasureCubes.end(); + sn ++) { out_stream << (*sn); out_stream << "\t" << (num2cube.HasSerialNumber(*sn) ? Filename(num2cube.Filename(*sn)).Name() : ""); out_stream << "\n"; @@ -375,7 +378,7 @@ void IsisMain() { out_stream.close(); ss << "----------------------------------------" \ - "----------------------------------------" << endl; + "----------------------------------------" << endl; ss << "There are " << singleMeasureCubes.size(); ss << " serial numbers in the Control Net ["; ss << Filename(ui.GetFilename("CNET")).Basename(); @@ -386,11 +389,11 @@ void IsisMain() { } ss << "----------------------------------------" \ - "----------------------------------------" << endl << endl; + "----------------------------------------" << endl << endl; std::string log = ss.str(); Application::Log(results); - if (ui.IsInteractive()) { + if(ui.IsInteractive()) { Application::GuiLog(log); } else { @@ -402,11 +405,11 @@ void IsisMain() { // Links cubes to other cubes it shares control points with map< string, set > constructPointSets(set &index, - ControlNet &innet) { + ControlNet &innet) { map< string, set > adjPoints; bool ignore = Application::GetUserInterface().GetBoolean("IGNORE"); - for(int cp=0; cp < innet.Size(); cp++) { + for(int cp = 0; cp < innet.Size(); cp++) { if(ignore && innet[cp].Ignore()) continue; @@ -414,16 +417,16 @@ map< string, set > constructPointSets(set &index, ControlPoint controlpt = innet[cp]; // Map SerialNumbers together based on ControlMeasures - for(int cm1=0; cm1 < controlpt.Size(); cm1++) { + for(int cm1 = 0; cm1 < controlpt.Size(); cm1++) { if(ignore && controlpt.Ignore()) continue; std::string sn = controlpt[cm1].CubeSerialNumber(); index.insert(sn); - for(int cm2=0; cm2 < controlpt.Size(); cm2++) { + for(int cm2 = 0; cm2 < controlpt.Size(); cm2++) { if(ignore && controlpt[cm2].Ignore()) continue; if(cm1 != cm2) { - adjPoints[ sn ].insert( controlpt[cm2].CubeSerialNumber() ); + adjPoints[ sn ].insert(controlpt[cm2].CubeSerialNumber()); } } } @@ -436,7 +439,7 @@ map< string, set > constructPointSets(set &index, // Uses a depth-first search to construct the islands vector< set > findIslands(set &index, - map< string, set > &adjCubes) { + map< string, set > &adjCubes) { vector< set > islands; while(index.size() != 0) { @@ -450,18 +453,18 @@ vector< set > findIslands(set &index, while(true) { index.erase(str_stack.top()); connectedSet.insert(str_stack.top()); - + // Find the first connected unvisited node std::string nextNode = ""; set neighbors = adjCubes[str_stack.top()]; - for (set::iterator i = neighbors.begin(); i != neighbors.end(); i++) { - if (index.count(*i) == 1) { + for(set::iterator i = neighbors.begin(); i != neighbors.end(); i++) { + if(index.count(*i) == 1) { nextNode = *i; break; } } - - if (nextNode != "") { + + if(nextNode != "") { // Push the unvisited node str_stack.push(nextNode); } @@ -469,7 +472,7 @@ vector< set > findIslands(set &index, // Pop the visited node str_stack.pop(); - if (str_stack.size() == 0) break; + if(str_stack.size() == 0) break; } } @@ -481,20 +484,20 @@ vector< set > findIslands(set &index, // Writes the list of cubes [ SerialNumber, Filename, ControlPoints ] to the output file -void WriteOutput( SerialNumberList num2cube, string filename, - set &sns, map< string, set > &cps ) { +void WriteOutput(SerialNumberList num2cube, string filename, + set &sns, map< string, set > &cps) { UserInterface &ui = Application::GetUserInterface(); // Set the character to separate the entries string delimit; - if (ui.GetString("DELIMIT") == "TAB") { + if(ui.GetString("DELIMIT") == "TAB") { delimit = "\t"; } - else if (ui.GetString("DELIMIT") == "COMMA") { + else if(ui.GetString("DELIMIT") == "COMMA") { delimit = ","; } - else if (ui.GetString("DELIMIT") == "SPACE") { + else if(ui.GetString("DELIMIT") == "SPACE") { delimit = " "; } else { @@ -504,15 +507,15 @@ void WriteOutput( SerialNumberList num2cube, string filename, // Set up the output file for writing ofstream out_stream; out_stream.open(filename.c_str(), std::ios::out); - out_stream.seekp(0,std::ios::beg); //Start writing from beginning of file + out_stream.seekp(0, std::ios::beg); //Start writing from beginning of file - for( set::iterator sn = sns.begin(); - sn != sns.end(); sn++ ) { + for(set::iterator sn = sns.begin(); + sn != sns.end(); sn++) { // Serial Number of cube out_stream << *sn; // Filename of cube if given - if( num2cube.HasSerialNumber(*sn) ) { + if(num2cube.HasSerialNumber(*sn)) { out_stream << delimit << Filename(num2cube.Filename(*sn)).Name(); } else { @@ -520,8 +523,8 @@ void WriteOutput( SerialNumberList num2cube, string filename, } // Control Points where the cube was found to have the issue - for( set::iterator cp = cps[*sn].begin(); - cp != cps[*sn].end(); cp++ ) { + for(set::iterator cp = cps[*sn].begin(); + cp != cps[*sn].end(); cp++) { out_stream << "\t" << *cp; } diff --git a/isis/src/base/apps/cnetedit/cnetedit.cpp b/isis/src/base/apps/cnetedit/cnetedit.cpp index f5ac6b6d90..98a67efb83 100644 --- a/isis/src/base/apps/cnetedit/cnetedit.cpp +++ b/isis/src/base/apps/cnetedit/cnetedit.cpp @@ -6,10 +6,10 @@ using namespace std; using namespace Isis; -void ProcessControlPoints (std::string psFileName, ControlNet & pcCnet, bool pbDelete, Pvl & pcPvlLog, bool pbPreserve); -void ProcessControlMeasures(std::string psFileName, ControlNet & pcCnet, bool pbDelete, bool pbPreserve); +void ProcessControlPoints(std::string psFileName, ControlNet &pcCnet, bool pbDelete, Pvl &pcPvlLog, bool pbPreserve); +void ProcessControlMeasures(std::string psFileName, ControlNet &pcCnet, bool pbDelete, bool pbPreserve); -static int giPointsDeleted=0, giMeasuresDeleted=0; +static int giPointsDeleted = 0, giMeasuresDeleted = 0; static bool gbLog; @@ -18,52 +18,52 @@ void IsisMain() { // Get user parameters UserInterface &ui = Application::GetUserInterface(); - ControlNet cnet( ui.GetFilename("CNET") ); + ControlNet cnet(ui.GetFilename("CNET")); bool bDelete = ui.GetBoolean("DELETE"); bool bPreserve = ui.GetBoolean("PRESERVE"); - bool bPointList=false, bCubeList=false; + bool bPointList = false, bCubeList = false; Pvl pvlLog; - gbLog=false; - + gbLog = false; + std::string sPointsFile, sMeasuresFile, sLogfile; //Get the Log file - if ( ui.WasEntered("LOG") ) { + if(ui.WasEntered("LOG")) { sLogfile = ui.GetFilename("LOG"); - gbLog=true; + gbLog = true; } - + //List has Points Ids - if ( ui.WasEntered("POINTLIST") ){ - sPointsFile = ui.GetFilename("POINTLIST"); - ProcessControlPoints(sPointsFile, cnet, bDelete, pvlLog, bPreserve); - } + if(ui.WasEntered("POINTLIST")) { + sPointsFile = ui.GetFilename("POINTLIST"); + ProcessControlPoints(sPointsFile, cnet, bDelete, pvlLog, bPreserve); + } //List has Cube file names - if ( ui.WasEntered("FROMLIST") ) { - sMeasuresFile = ui.GetFilename("FROMLIST"); - ProcessControlMeasures(sMeasuresFile, cnet, bDelete, bPreserve); - } - - //No List files - only Delete option was chosen - if ( bDelete && !bPointList && !bCubeList ){ - for ( int cp = cnet.Size()-1; cp >= 0; cp -- ) { - if ( cnet[cp].Ignore() ) { + if(ui.WasEntered("FROMLIST")) { + sMeasuresFile = ui.GetFilename("FROMLIST"); + ProcessControlMeasures(sMeasuresFile, cnet, bDelete, bPreserve); + } + + //No List files - only Delete option was chosen + if(bDelete && !bPointList && !bCubeList) { + for(int cp = cnet.Size() - 1; cp >= 0; cp --) { + if(cnet[cp].Ignore()) { giMeasuresDeleted += cnet[cp].Size(); cnet.Delete(cp); giPointsDeleted++; } - else { - for ( int cm = cnet[cp].Size()-1; cm >= 0; cm -- ) { - if ( cnet[cp][cm].Ignore() ) { + else { + for(int cm = cnet[cp].Size() - 1; cm >= 0; cm --) { + if(cnet[cp][cm].Ignore()) { cnet[cp].Delete(cm); giMeasuresDeleted++; } - // Check if the number of measures in the point is zero or - // there are few measures in the point and preserve flag is false. - if ( ( (cnet[cp].Size() < 2 && !bPreserve) && cnet[cp].Type() != ControlPoint::Ground ) - || cnet[cp].Size() == 0 ) { + // Check if the number of measures in the point is zero or + // there are few measures in the point and preserve flag is false. + if(((cnet[cp].Size() < 2 && !bPreserve) && cnet[cp].Type() != ControlPoint::Ground) + || cnet[cp].Size() == 0) { giMeasuresDeleted += cnet[cp].Size(); cnet.Delete(cp); giPointsDeleted++; @@ -75,113 +75,111 @@ void IsisMain() { } //log statistics - if ( gbLog ) { + if(gbLog) { pvlLog += Isis::PvlKeyword("PointsDeleted", giPointsDeleted); - pvlLog += Isis::PvlKeyword("MeasuresDeleted", giMeasuresDeleted); + pvlLog += Isis::PvlKeyword("MeasuresDeleted", giMeasuresDeleted); pvlLog.Write(sLogfile); } - - cnet.Write( ui.GetFilename("ONET") ); + + cnet.Write(ui.GetFilename("ONET")); } - /** - * Reads the Control Points list and matches with the control - * network. If match was successful, ignore the point. If - * Delete option was chosen, delete the point - * - * @param psFileName - Filename with Control Points - * @param pcCnet - holds the input Control Network - * @param pbDelete - Delete option (true/false) - * @param pcPvlLog - Pvl for which control points stats have - * to be added - * @param pbPreserve - Preserve Control Points with Measures - * equal to one. (true/false) - * - * @return none - */ -void ProcessControlPoints(std::string psFileName, ControlNet & pcCnet, bool pbDelete, Pvl& pcPvlLog, bool pbPreserve) -{ - ControlPointList cpList(psFileName); - - for ( int cp = pcCnet.Size()-1; cp >= 0; cp -- ) { - +/** + * Reads the Control Points list and matches with the control + * network. If match was successful, ignore the point. If + * Delete option was chosen, delete the point + * + * @param psFileName - Filename with Control Points + * @param pcCnet - holds the input Control Network + * @param pbDelete - Delete option (true/false) + * @param pcPvlLog - Pvl for which control points stats have + * to be added + * @param pbPreserve - Preserve Control Points with Measures + * equal to one. (true/false) + * + * @return none + */ +void ProcessControlPoints(std::string psFileName, ControlNet &pcCnet, bool pbDelete, Pvl &pcPvlLog, bool pbPreserve) { + ControlPointList cpList(psFileName); + + for(int cp = pcCnet.Size() - 1; cp >= 0; cp --) { + // Compare each Point Id listed with the Point in the - // Control Network for according exclusion - if ( cpList.HasControlPoint(pcCnet[cp].Id()) ) { - pcCnet[cp].SetIgnore(true); + // Control Network for according exclusion + if(cpList.HasControlPoint(pcCnet[cp].Id())) { + pcCnet[cp].SetIgnore(true); } - - if ( pbDelete ){ + + if(pbDelete) { //look for previously ignored control points - if (pcCnet[cp].Ignore()){ + if(pcCnet[cp].Ignore()) { giMeasuresDeleted += pcCnet[cp].Size(); pcCnet.Delete(cp); giPointsDeleted++; } - else{ + else { //look for previously ignored control measures - for ( int cm = pcCnet[cp].Size()-1; cm >= 0 ; cm-- ) { - if (pcCnet[cp][cm].Ignore() && pbDelete) { + for(int cm = pcCnet[cp].Size() - 1; cm >= 0 ; cm--) { + if(pcCnet[cp][cm].Ignore() && pbDelete) { pcCnet[cp].Delete(cm); giMeasuresDeleted++; } } // Check if there are too few measures in the point or the point was previously ignored - if (( (pcCnet[cp].Size() < 2 && !pbPreserve) && pcCnet[cp].Type() != ControlPoint::Ground ) - || pcCnet[cp].Size() == 0 || (pcCnet[cp].Ignore() && pbDelete)) { - giMeasuresDeleted += pcCnet[cp].Size(); - pcCnet.Delete(cp); - giPointsDeleted++; + if(((pcCnet[cp].Size() < 2 && !pbPreserve) && pcCnet[cp].Type() != ControlPoint::Ground) + || pcCnet[cp].Size() == 0 || (pcCnet[cp].Ignore() && pbDelete)) { + giMeasuresDeleted += pcCnet[cp].Size(); + pcCnet.Delete(cp); + giPointsDeleted++; } } } } - if ( gbLog ) { - cpList.RegisterStatistics(pcPvlLog); + if(gbLog) { + cpList.RegisterStatistics(pcPvlLog); } } - /** - * Reads the Cube file list and creates the serial number of the - * Cubes. If Control Measure serial# matches with the control - * network,ignore the point. If Delete option was chosen, delete - * the Measure - * - * @param psFileName - Filename with Cube File names - * @param pcCnet - holds the input Control Network - * @param pbDelete - Delete option (true/false) - * @param pbPreserve - Preserve Control Points with Measures - * equal to one. (true/false) - * - * @return none - */ -void ProcessControlMeasures(std::string psFileName, ControlNet & pcCnet, bool pbDelete, bool pbPreserve) -{ +/** + * Reads the Cube file list and creates the serial number of the + * Cubes. If Control Measure serial# matches with the control + * network,ignore the point. If Delete option was chosen, delete + * the Measure + * + * @param psFileName - Filename with Cube File names + * @param pcCnet - holds the input Control Network + * @param pbDelete - Delete option (true/false) + * @param pbPreserve - Preserve Control Points with Measures + * equal to one. (true/false) + * + * @return none + */ +void ProcessControlMeasures(std::string psFileName, ControlNet &pcCnet, bool pbDelete, bool pbPreserve) { SerialNumberList snl = psFileName; - - for ( int cp = pcCnet.Size()-1; cp >= 0; cp -- ) { + + for(int cp = pcCnet.Size() - 1; cp >= 0; cp --) { // Compare each Serial Number listed with the serial number in the - // Control Measure for according exclusion - for ( int cm = pcCnet[cp].Size()-1; cm >= 0 ; cm-- ) { - if ( snl.HasSerialNumber(pcCnet[cp][cm].CubeSerialNumber()) ) { - pcCnet[cp][cm].SetIgnore( true ); + // Control Measure for according exclusion + for(int cm = pcCnet[cp].Size() - 1; cm >= 0 ; cm--) { + if(snl.HasSerialNumber(pcCnet[cp][cm].CubeSerialNumber())) { + pcCnet[cp][cm].SetIgnore(true); } //also look for previously ignored control measures - if ( pbDelete && pcCnet[cp][cm].Ignore() ) { + if(pbDelete && pcCnet[cp][cm].Ignore()) { pcCnet[cp].Delete(cm); giMeasuresDeleted++; } } // Check if there are too few measures in the point or the point was previously ignored - if (( (pcCnet[cp].Size() < 2 && !pbPreserve) && pcCnet[cp].Type() != ControlPoint::Ground ) - || pcCnet[cp].Size() == 0 || (pcCnet[cp].Ignore() && pbDelete)) { - giMeasuresDeleted += pcCnet[cp].Size(); - pcCnet.Delete(cp); - giPointsDeleted++; - } + if(((pcCnet[cp].Size() < 2 && !pbPreserve) && pcCnet[cp].Type() != ControlPoint::Ground) + || pcCnet[cp].Size() == 0 || (pcCnet[cp].Ignore() && pbDelete)) { + giMeasuresDeleted += pcCnet[cp].Size(); + pcCnet.Delete(cp); + giPointsDeleted++; + } } } diff --git a/isis/src/base/apps/cnetmerge/cnetmerge.cpp b/isis/src/base/apps/cnetmerge/cnetmerge.cpp index 6ba0e95fe6..1262fd2c3a 100644 --- a/isis/src/base/apps/cnetmerge/cnetmerge.cpp +++ b/isis/src/base/apps/cnetmerge/cnetmerge.cpp @@ -11,89 +11,89 @@ using namespace std; using namespace Isis; -ControlPoint MergePoints( ControlPoint master, ControlPoint mergee, bool allowReferenceOverride, bool & needsReport ); +ControlPoint MergePoints(ControlPoint master, ControlPoint mergee, bool allowReferenceOverride, bool &needsReport); // Main program void IsisMain() { // Get user parameters UserInterface &ui = Application::GetUserInterface(); FileList filelist; - if( ui.GetString("INPUTTYPE") == "LIST" ) { + if(ui.GetString("INPUTTYPE") == "LIST") { filelist = ui.GetFilename("FROMLIST"); } - else if ( ui.GetString("INPUTTYPE") == "CNETS" ) { - filelist.push_back( ui.GetFilename("FROM1") ); - filelist.push_back( ui.GetFilename("FROM2") ); + else if(ui.GetString("INPUTTYPE") == "CNETS") { + filelist.push_back(ui.GetFilename("FROM1")); + filelist.push_back(ui.GetFilename("FROM2")); } - Filename outfile( ui.GetFilename("TO") ); + Filename outfile(ui.GetFilename("TO")); bool allowPointOverride = false; bool allowMeasureOverride = false; - if ( ui.GetString("DUPLICATEPOINTS") == "MERGE" ) { + if(ui.GetString("DUPLICATEPOINTS") == "MERGE") { allowPointOverride = ui.GetBoolean("OVERWRITEPOINTS"); allowMeasureOverride = ui.GetBoolean("OVERWRITEMEASURES"); } // Creates a Progress Progress progress; - progress.SetMaximumSteps( filelist.size() ); + progress.SetMaximumSteps(filelist.size()); progress.CheckStatus(); // Set up the output ControlNet with the first Control Net in the list - ControlNet cnet( Filename(filelist[0]).Expanded() ); - cnet.SetNetworkId( ui.GetString("ID") ); - cnet.SetUserName( Isis::Application::UserName() ); - cnet.SetCreatedDate( Isis::Application::DateTime() ); - cnet.SetModifiedDate( Isis::iTime::CurrentLocalTime() ); - cnet.SetDescription( ui.GetString("DESCRIPTION") ); + ControlNet cnet(Filename(filelist[0]).Expanded()); + cnet.SetNetworkId(ui.GetString("ID")); + cnet.SetUserName(Isis::Application::UserName()); + cnet.SetCreatedDate(Isis::Application::DateTime()); + cnet.SetModifiedDate(Isis::iTime::CurrentLocalTime()); + cnet.SetDescription(ui.GetString("DESCRIPTION")); progress.CheckStatus(); ofstream ss; bool report = false; - if( ui.WasEntered("REPORT") ) { + if(ui.WasEntered("REPORT")) { report = true; string report = ui.GetFilename("REPORT"); - ss.open(report.c_str(),ios::out); + ss.open(report.c_str(), ios::out); } - for ( int f = 1; f < (int)filelist.size(); f ++ ) { + for(int f = 1; f < (int)filelist.size(); f ++) { - ControlNet currentnet( Filename(filelist[f]).Expanded() ); + ControlNet currentnet(Filename(filelist[f]).Expanded()); // Checks to make sure the ControlNets are valid to merge - if ( cnet.Target() != currentnet.Target() ) { + if(cnet.Target() != currentnet.Target()) { string msg = "Input [" + currentnet.NetworkId() + "] does not target the "; msg += "same target as other Control Nets."; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // ERROR - if ( ui.GetString("DUPLICATEPOINTS") == "ERROR" ) { + if(ui.GetString("DUPLICATEPOINTS") == "ERROR") { // Throws an error if there is a duplicate Control Point - for ( int cp=0; cpType() == ControlPoint::Ground && currentnet[cp].Type() == ControlPoint::Tie) - || (dupPoint->Held() && !currentnet[cp].Held()) ) { - ControlPoint mergedPoint = MergePoints( *dupPoint, currentnet[cp], !allowMeasureOverride, needsReport ); + if((dupPoint->Type() == ControlPoint::Ground && currentnet[cp].Type() == ControlPoint::Tie) + || (dupPoint->Held() && !currentnet[cp].Held())) { + ControlPoint mergedPoint = MergePoints(*dupPoint, currentnet[cp], !allowMeasureOverride, needsReport); - if( report && needsReport ) { + if(report && needsReport) { ss << " Control Measures from " << currentnet[cp].Id() << " were not merged due to conflicts." << endl; } - cnet.Delete( currentnet[cp].Id() ); - cnet.Add( mergedPoint ); + cnet.Delete(currentnet[cp].Id()); + cnet.Add(mergedPoint); } - else if ( (dupPoint->Type() == ControlPoint::Ground && currentnet[cp].Type() == ControlPoint::Ground) - || (dupPoint->Held() && currentnet[cp].Held()) ) { + else if((dupPoint->Type() == ControlPoint::Ground && currentnet[cp].Type() == ControlPoint::Ground) + || (dupPoint->Held() && currentnet[cp].Held())) { // See if there are conflicts in merging the 2 points bool hasPointConflict = false; - if ( dupPoint->UniversalLatitude() > DBL_MIN && - dupPoint->UniversalLongitude() > DBL_MIN && - dupPoint->UniversalLatitude() == currentnet[cp].UniversalLatitude() && - dupPoint->UniversalLongitude() == currentnet[cp].UniversalLongitude() ) { + if(dupPoint->UniversalLatitude() > DBL_MIN && + dupPoint->UniversalLongitude() > DBL_MIN && + dupPoint->UniversalLatitude() == currentnet[cp].UniversalLatitude() && + dupPoint->UniversalLongitude() == currentnet[cp].UniversalLongitude()) { hasPointConflict = true; } // Merge the Control Points correctly - if ( hasPointConflict ) { - if ( allowPointOverride ) { - ControlPoint mergedPoint = MergePoints( currentnet[cp], *dupPoint, allowMeasureOverride, needsReport ); + if(hasPointConflict) { + if(allowPointOverride) { + ControlPoint mergedPoint = MergePoints(currentnet[cp], *dupPoint, allowMeasureOverride, needsReport); - if( report && needsReport ) { + if(report && needsReport) { ss << " Control Measures from " << currentnet[cp].Id() << " were not merged due to conflicts." << endl; } - cnet.Delete( currentnet[cp].Id() ); - cnet.Add( mergedPoint ); + cnet.Delete(currentnet[cp].Id()); + cnet.Add(mergedPoint); } else { - if( report ) { + if(report) { ss << " The merge of Control Point " << currentnet[cp].Id() << " was canceled due to conflicts." << endl; } // These 3 lines keep cnet's points in order with an "unnecessary" delete ControlPoint copyPoint = (*dupPoint); - cnet.Delete( currentnet[cp].Id() ); - cnet.Add( copyPoint ); + cnet.Delete(currentnet[cp].Id()); + cnet.Add(copyPoint); } } else { - ControlPoint mergedPoint = MergePoints( currentnet[cp], *dupPoint, allowMeasureOverride, needsReport ); + ControlPoint mergedPoint = MergePoints(currentnet[cp], *dupPoint, allowMeasureOverride, needsReport); - if( report && needsReport ) { + if(report && needsReport) { ss << " Control Measures from " << currentnet[cp].Id() << " were not merged due to conflicts." << endl; } - cnet.Delete( currentnet[cp].Id() ); - cnet.Add( mergedPoint ); + cnet.Delete(currentnet[cp].Id()); + cnet.Add(mergedPoint); } } else { - ControlPoint mergedPoint = MergePoints( currentnet[cp], *dupPoint, allowMeasureOverride, needsReport ); + ControlPoint mergedPoint = MergePoints(currentnet[cp], *dupPoint, allowMeasureOverride, needsReport); - if( report && needsReport ) { + if(report && needsReport) { ss << " Control Measures from " << currentnet[cp].Id() << " were not merged due to conflicts." << endl; } - cnet.Delete( currentnet[cp].Id() ); - cnet.Add( mergedPoint ); + cnet.Delete(currentnet[cp].Id()); + cnet.Add(mergedPoint); } dupPoint = NULL; - } catch ( iException &e ) { + } + catch(iException &e) { e.Clear(); //then currentnet[i] was not found and was not deleted so: //Add the point to the output ControlNet - cnet.Add( currentnet[cp] ); + cnet.Add(currentnet[cp]); } } @@ -185,27 +186,27 @@ void IsisMain() { } // Writes out the final Control Net - cnet.Write( outfile.Expanded() ); + cnet.Write(outfile.Expanded()); } -ControlPoint MergePoints( ControlPoint master, ControlPoint mergee, bool allowReferenceOverride, bool & needsReport ) { +ControlPoint MergePoints(ControlPoint master, ControlPoint mergee, bool allowReferenceOverride, bool &needsReport) { ControlPoint newPoint = master; // Merge mergee measures into newPoint - for ( int cm = 0; cm < mergee.Size(); cm ++ ) { + for(int cm = 0; cm < mergee.Size(); cm ++) { bool merged = false; // Check for duplicate measures to know when to keep "older" measures - for ( int newcm = 0; newcm < newPoint.Size() && !merged; newcm ++ ) { - if ( mergee[cm].CubeSerialNumber() == newPoint[newcm].CubeSerialNumber() ) { + for(int newcm = 0; newcm < newPoint.Size() && !merged; newcm ++) { + if(mergee[cm].CubeSerialNumber() == newPoint[newcm].CubeSerialNumber()) { - if ( (mergee.Type() == ControlPoint::Ground || newPoint.Held()) ) { - if ( !allowReferenceOverride ) { + if((mergee.Type() == ControlPoint::Ground || newPoint.Held())) { + if(!allowReferenceOverride) { // Remove new measure, pull old measure, and Report that the new wasn't merged - if (mergee[cm].IsReference() && !newPoint[newcm].IsReference() && newPoint.HasReference() ) { - newPoint[newPoint.ReferenceIndex()].SetReference( false ); + if(mergee[cm].IsReference() && !newPoint[newcm].IsReference() && newPoint.HasReference()) { + newPoint[newPoint.ReferenceIndex()].SetReference(false); } newPoint[newcm] = mergee[cm]; needsReport |= true; @@ -217,22 +218,22 @@ ControlPoint MergePoints( ControlPoint master, ControlPoint mergee, bool allowRe } // If no duplicate measure was found - if( !merged ) { - if ( newPoint.HasReference() && mergee[cm].IsReference() ) { - if ( allowReferenceOverride ) { + if(!merged) { + if(newPoint.HasReference() && mergee[cm].IsReference()) { + if(allowReferenceOverride) { // Remove reference to old Measure and pull it over - mergee[cm].SetReference( false ); - newPoint.Add( mergee[cm] ); + mergee[cm].SetReference(false); + newPoint.Add(mergee[cm]); } else { // Remove Reference from new measure and Report that it wasn't allowed - newPoint[newPoint.ReferenceIndex()].SetReference( false ); - newPoint.Add( mergee[cm] ); + newPoint[newPoint.ReferenceIndex()].SetReference(false); + newPoint.Add(mergee[cm]); needsReport |= true; } } else { - newPoint.Add( mergee[cm] ); + newPoint.Add(mergee[cm]); } } } diff --git a/isis/src/base/apps/cnetnewradii/cnetnewradii.cpp b/isis/src/base/apps/cnetnewradii/cnetnewradii.cpp index 74fd38a541..43236b6e1c 100644 --- a/isis/src/base/apps/cnetnewradii/cnetnewradii.cpp +++ b/isis/src/base/apps/cnetnewradii/cnetnewradii.cpp @@ -15,49 +15,49 @@ using namespace Isis; void IsisMain() { UserInterface &ui = Application::GetUserInterface(); - - ControlNet cnet_in (ui.GetFilename("CNET")); + + ControlNet cnet_in(ui.GetFilename("CNET")); ControlNet cnet_out; - // Get input cube and get camera model for it + // Get input cube and get camera model for it string from = ui.GetFilename("DEM"); Cube cube; cube.Open(from); // TODO: need empty constructor to declare ugm outside try/catch // try { - UniversalGroundMap ugm(cube); + UniversalGroundMap ugm(cube); // } catch (iException e){ // std::string msg = "Cannot initalize UniversalGroundMap for cube [" + from + "]"; // throw iException::Message(iException::User,msg,_FILEINFO_); // } - + int numSuccesses = 0; int numFailures = 0; string failedIDs = ""; - for (int i=0; i < cnet_in.Size() ; i++) { + for(int i = 0; i < cnet_in.Size() ; i++) { ControlPoint temp_cp = cnet_in[i]; if(temp_cp.Type() == ControlPoint::Ground) { // Create Brick on samp, line to get the dn value of the pixel - Brick b(1,1,1,cube.PixelType()); + Brick b(1, 1, 1, cube.PixelType()); bool ugSuccess = ugm.SetUniversalGround(temp_cp.UniversalLatitude(), temp_cp.UniversalLongitude()); - b.SetBasePosition((int)ugm.Sample(),(int)ugm.Line(),1); + b.SetBasePosition((int)ugm.Sample(), (int)ugm.Line(), 1); cube.Read(b); double newRadius = b[0]; - // if we are unable to calculate a valid Radius value for a point, + // if we are unable to calculate a valid Radius value for a point, // we will ignore this point and keep track of it - if (IsSpecial(newRadius) || ugSuccess == false){ + if(IsSpecial(newRadius) || ugSuccess == false) { numFailures++; - if (numFailures > 1) { + if(numFailures > 1) { failedIDs = failedIDs + ", "; } failedIDs = failedIDs + temp_cp.Id(); temp_cp.SetIgnore(true); } // otherwise, we will replace the computed radius value to the output control net - else{ + else { numSuccesses++; temp_cp.SetUniversalGround(temp_cp.UniversalLatitude(), temp_cp.UniversalLongitude(), newRadius); } @@ -65,14 +65,14 @@ void IsisMain() { cnet_out.Add(temp_cp); } - if (numSuccesses == 0) { + if(numSuccesses == 0) { string msg = "No valid radii can be calculated. Verify that the DEM [" + ui.GetAsString("DEM") + "] is valid."; throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Propogate and Create Labels cnet_out.SetType(cnet_in.Type()); - cnet_out.SetTarget (cnet_in.Target()); + cnet_out.SetTarget(cnet_in.Target()); cnet_out.SetNetworkId(ui.GetString("NETWORKID")); cnet_out.SetUserName(Isis::Application::UserName()); cnet_out.SetDescription(cnet_in.Description()); @@ -80,7 +80,7 @@ void IsisMain() { cnet_out.Write(ui.GetFilename("TO")); - // Write results to Logs + // Write results to Logs // Summary group is created with the counts of successes and failures PvlGroup summaryGroup = PvlGroup("Summary"); summaryGroup.AddKeyword(PvlKeyword("Successes", numSuccesses)); @@ -89,13 +89,13 @@ void IsisMain() { bool errorlog; Filename errorlogFile; // if a filename was entered, use it to create the log - if (ui.WasEntered("ERRORS")) { + if(ui.WasEntered("ERRORS")) { errorlog = true; errorlogFile = ui.GetFilename("ERRORS"); } // if no filename was entered, but there were some failures, // create an error log named "failures" in the current directory - else if (numFailures > 0) { + else if(numFailures > 0) { errorlog = true; errorlogFile = "failures.log"; } @@ -105,14 +105,14 @@ void IsisMain() { errorlog = false; } - if (errorlog) { + if(errorlog) { // Write details in error log Pvl results; results.SetName("Results"); results.AddGroup(summaryGroup); - if (numFailures > 0) { + if(numFailures > 0) { // if there are any failures, add comment to the summary log to alert user - summaryGroup.AddComment("Unable to calculate radius for all points. Point IDs for failures contained in ["+errorlogFile.Name()+"]."); + summaryGroup.AddComment("Unable to calculate radius for all points. Point IDs for failures contained in [" + errorlogFile.Name() + "]."); PvlGroup failGroup = PvlGroup("Failures"); failGroup.AddComment("A point fails if we are unable to set universal ground or if the radius calculated is a special pixel value."); failGroup.AddKeyword(PvlKeyword("PointIDs", failedIDs)); diff --git a/isis/src/base/apps/cnettable/cnettable.cpp b/isis/src/base/apps/cnettable/cnettable.cpp index b89027e235..24d9e7154e 100644 --- a/isis/src/base/apps/cnettable/cnettable.cpp +++ b/isis/src/base/apps/cnettable/cnettable.cpp @@ -23,13 +23,13 @@ using namespace std; using namespace Isis; -void Write(PvlGroup * point, ControlMeasure & cm); +void Write(PvlGroup *point, ControlMeasure &cm); // Allows for column names to be written on the first pass bool isFirst; bool append; -TextFile * txt = NULL; +TextFile *txt = NULL; // For control measure related data and labels QString measureInfo; @@ -51,7 +51,7 @@ void IsisMain() { SerialNumberList serials(ui.GetFilename("FROMLIST")); append = ui.GetBoolean("APPEND"); - if (cnet.Size() == 0) { + if(cnet.Size() == 0) { string msg = "Your control network must contain at least one point"; throw iException::Message(iException::User, msg, _FILEINFO_); } @@ -59,32 +59,32 @@ void IsisMain() { prog.SetMaximumSteps(cnet.Size()); // If append is true, output will be appended or a new file created - if (append) { + if(append) { // Check to see if its a new file or we open an existing file Filename file(ui.GetFilename("TO")); - if (!file.Exists()) { + if(!file.Exists()) { // It is new, so we aren't appending append = false; } txt = new TextFile(ui.GetFilename("TO"), "append"); } - // Without append, if the files exists it will be overwritten + // Without append, if the files exists it will be overwritten else { txt = new TextFile(ui.GetFilename("TO"), "overwrite"); } - PvlGroup * grp = NULL; + PvlGroup *grp = NULL; CameraPointInfo camPoint; outside = ui.GetBoolean("ALLOWOUTSIDE"); errors = ui.GetBoolean("ALLOWERRORS"); // Loop through all points in controlnet - for (int i = 0; i < cnet.Size(); i++) { - ControlPoint & cpoint = cnet[i]; - - if (isFirst && !append) { - measureLabels += "ControlPointId,"; + for(int i = 0; i < cnet.Size(); i++) { + ControlPoint &cpoint = cnet[i]; + + if(isFirst && !append) { + measureLabels += "ControlPointId,"; measureLabels += "PointType,"; measureLabels += "Ignored,"; measureLabels += "Held,"; @@ -104,18 +104,18 @@ void IsisMain() { measureInfo += iString(cpoint.UniversalLatitude()).ToQt() + ","; measureInfo += iString(cpoint.UniversalLongitude()).ToQt() + ","; measureInfo += iString(cpoint.Radius()).ToQt() + ","; - + // Loop through all measures in controlpoint - for (int j = 0; j < cpoint.Size(); j++) { + for(int j = 0; j < cpoint.Size(); j++) { - ControlMeasure & cmeasure = cpoint[j]; + ControlMeasure &cmeasure = cpoint[j]; // Set and then get CameraPointInfo information camPoint.SetCube(serials.Filename(cmeasure.CubeSerialNumber())); grp = camPoint.SetImage(cmeasure.Sample(), cmeasure.Line(), outside, errors); // Shouldn't ever happen, but, being safe... - if (grp == NULL) { + if(grp == NULL) { string msg = "You shouldn't have gotten here. Errors in CameraPointInfo class"; throw iException::Message(iException::Programmer, msg, _FILEINFO_); } @@ -130,14 +130,14 @@ void IsisMain() { // All done, clean up prog.CheckStatus(); - if (txt != NULL) { + if(txt != NULL) { delete txt; txt = NULL; } } // Write each PvlGroup out to file -void Write(PvlGroup * point, ControlMeasure & cm) { +void Write(PvlGroup *point, ControlMeasure &cm) { // QStrings are used QString here because of ControlMeasure returning // QStrings. There is some monkey motion involving ingesting doubles, @@ -145,11 +145,11 @@ void Write(PvlGroup * point, ControlMeasure & cm) { QString output = ""; QVector < QString > dataNames; - + // Do we have errors? int maxCount = 0; bool errors = point->HasKeyword("Error"); - if (errors) { + if(errors) { maxCount = point->Keywords() - 1; } else { @@ -157,10 +157,10 @@ void Write(PvlGroup * point, ControlMeasure & cm) { } // If its first and not appending, write the column labels - if (isFirst && !append) { + if(isFirst && !append) { // point information - for (int i = 0; i < maxCount; i++) { - if ((*point)[i].Size() == 3) { + for(int i = 0; i < maxCount; i++) { + if((*point)[i].Size() == 3) { output += QString((*point)[i].Name().c_str()) + "X,"; output += QString((*point)[i].Name().c_str()) + "Y,"; output += QString((*point)[i].Name().c_str()) + "Z,"; @@ -172,12 +172,12 @@ void Write(PvlGroup * point, ControlMeasure & cm) { // control measure information dataNames = cm.GetMeasureDataNames(); - for (int i = 0; i < dataNames.size(); i++) { + for(int i = 0; i < dataNames.size(); i++) { output += dataNames[i] + ","; } - if (errors) output += QString((*point)[maxCount].Name().c_str()); + if(errors) output += QString((*point)[maxCount].Name().c_str()); isFirst = false; - measureLabels += output; + measureLabels += output; txt->PutLine(measureLabels.toStdString()); } output.clear(); @@ -185,8 +185,8 @@ void Write(PvlGroup * point, ControlMeasure & cm) { // Write out date values // point information - for (int i = 0; i < maxCount; i++) { - if ((*point)[i].Size() == 3) { + for(int i = 0; i < maxCount; i++) { + if((*point)[i].Size() == 3) { output += QString((*point)[i][0]) + ","; output += QString((*point)[i][1]) + ","; output += QString((*point)[i][2]) + ","; @@ -196,17 +196,17 @@ void Write(PvlGroup * point, ControlMeasure & cm) { } } - dataNames = cm.GetMeasureDataNames(); - for (int i = 0; i < dataNames.size(); i++) { - output += iString(cm.GetMeasureData(dataNames[i])).ToQt() + ","; + dataNames = cm.GetMeasureDataNames(); + for(int i = 0; i < dataNames.size(); i++) { + output += iString(cm.GetMeasureData(dataNames[i])).ToQt() + ","; } - if (errors) output += QString((*point)[maxCount][0]); + if(errors) output += QString((*point)[maxCount][0]); // Meseaure info comes first QString pri = ""; pri += measureInfo; - pri += output; + pri += output; txt->PutLine(pri.toStdString()); diff --git a/isis/src/base/apps/coreg/coreg.cpp b/isis/src/base/apps/coreg/coreg.cpp index 8c1c45a4d2..d27419c855 100644 --- a/isis/src/base/apps/coreg/coreg.cpp +++ b/isis/src/base/apps/coreg/coreg.cpp @@ -14,16 +14,16 @@ #include "SerialNumber.h" #include "ControlMeasure.h" #include "iTime.h" - + using namespace std; using namespace Isis; //helper button functins in the code void helperButtonLog(); -map GuiHelpers(){ - map helper; - helper ["helperButtonLog"] = (void*) helperButtonLog; +map GuiHelpers() { + map helper; + helper ["helperButtonLog"] = (void *) helperButtonLog; return helper; } @@ -32,12 +32,12 @@ void IsisMain() { UserInterface &ui = Application::GetUserInterface(); // Make sure the correct parameters are entered - if (ui.WasEntered("TO")) { - if (ui.GetString("TRANSFORM") == "WARP") { - if (!ui.WasEntered("CNETFILE")) { + if(ui.WasEntered("TO")) { + if(ui.GetString("TRANSFORM") == "WARP") { + if(!ui.WasEntered("CNETFILE")) { string msg = "A Control Net file must be entered if the TO parameter is "; msg += "entered"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } } @@ -47,7 +47,7 @@ void IsisMain() { CubeAttributeInput &attTrans = ui.GetInputAttribute("FROM"); vector bandTrans = attTrans.Bands(); trans.SetVirtualBands(bandTrans); - trans.Open(ui.GetFilename("FROM"),"r"); + trans.Open(ui.GetFilename("FROM"), "r"); // Open the second cube, it is held in place. We will be matching the @@ -56,19 +56,19 @@ void IsisMain() { CubeAttributeInput &attMatch = ui.GetInputAttribute("MATCH"); vector bandMatch = attMatch.Bands(); match.SetVirtualBands(bandMatch); - match.Open(ui.GetFilename("MATCH"),"r"); + match.Open(ui.GetFilename("MATCH"), "r"); // Input cube Lines and Samples must be the same and each must have only // one band - if ((trans.Lines() != match.Lines()) || + if((trans.Lines() != match.Lines()) || (trans.Samples() != match.Samples())) { string msg = "Input Cube Lines and Samples must be equal!"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } - if (trans.Bands() != 1 || match.Bands() != 1) { + if(trans.Bands() != 1 || match.Bands() != 1) { string msg = "Input Cubes must have only one band!"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Get serial number @@ -76,17 +76,17 @@ void IsisMain() { string serialMatch = SerialNumber::Compose(match, true); // This still precludes band to band registrations. - if (serialTrans == serialMatch) { + if(serialTrans == serialMatch) { string sTrans = Filename(trans.Filename()).Name(); string sMatch = Filename(match.Filename()).Name(); - if (sTrans == sMatch) { + if(sTrans == sMatch) { string msg = "Cube Serial Numbers must be unique - FROM=" + serialTrans + ", MATCH=" + serialMatch; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } serialTrans = sTrans; serialMatch = sMatch; - } + } // We need to get a user definition of how to auto correlate around each @@ -99,13 +99,13 @@ void IsisMain() { // Get row and column variables, if not entered, default to 1% of the input // image size int rows, cols; - if (ui.WasEntered("ROWS")) { + if(ui.WasEntered("ROWS")) { rows = ui.GetInteger("ROWS"); } else { rows = (int)((trans.Lines() - 1) / ar->SearchChip()->Lines() + 1); } - if (ui.WasEntered("COLUMNS")) { + if(ui.WasEntered("COLUMNS")) { cols = ui.GetInteger("COLUMNS"); } else { @@ -130,8 +130,8 @@ void IsisMain() { // Loop through grid of points and get statistics to compute // translation values Statistics sStats, lStats; - for (int r=0; rPatternChip()->TackCube(samp, line); @@ -143,10 +143,10 @@ void IsisMain() { ControlMeasure cmTrans; cmTrans.SetCubeSerialNumber(serialTrans); cmTrans.SetCoordinate(samp, line, ControlMeasure::Unmeasured); - cmTrans.SetChooserName("coreg"); + cmTrans.SetChooserName("coreg"); cmTrans.SetReference(false); - // Set up ControlMeasure for the pattern/Match cube + // Set up ControlMeasure for the pattern/Match cube ControlMeasure cmMatch; cmMatch.SetCubeSerialNumber(serialMatch); cmMatch.SetCoordinate(samp, line, ControlMeasure::Automatic); @@ -154,13 +154,13 @@ void IsisMain() { cmMatch.SetReference(true); // Match found - if (ar->Register()==AutoReg::Success) { + if(ar->Register() == AutoReg::Success) { double sDiff = samp - ar->CubeSample(); double lDiff = line - ar->CubeLine(); - sStats.AddData(&sDiff,(unsigned int)1); - lStats.AddData(&lDiff,(unsigned int)1); + sStats.AddData(&sDiff, (unsigned int)1); + lStats.AddData(&lDiff, (unsigned int)1); cmTrans.SetCoordinate(ar->CubeSample(), ar->CubeLine(), - ControlMeasure::Automatic); + ControlMeasure::Automatic); cmTrans.SetError(sDiff, lDiff); cmTrans.SetGoodnessOfFit(ar->GoodnessOfFit()); } @@ -171,12 +171,12 @@ void IsisMain() { cp.SetType(ControlPoint::Tie); cp.Add(cmTrans); cp.Add(cmMatch); - if (!cmTrans.IsMeasured()) cp.SetIgnore(true); + if(!cmTrans.IsMeasured()) cp.SetIgnore(true); cn.Add(cp); prog.CheckStatus(); } } - + // Write translation to log PvlGroup results("Translation"); double sMin = (int)(sStats.Minimum() * 100.0) / 100.0; @@ -188,14 +188,14 @@ void IsisMain() { double lMax = (int)(lStats.Maximum() * 100.0) / 100.0; double lDev = (int)(lStats.StandardDeviation() * 100.0) / 100.0; - results += PvlKeyword ("SampleMinimum", sMin); - results += PvlKeyword ("SampleAverage", sTrans); - results += PvlKeyword ("SampleMaximum", sMax); - results += PvlKeyword ("SampleStandardDeviation", sDev); - results += PvlKeyword ("LineMinimum", lMin); - results += PvlKeyword ("LineAverage", lTrans); - results += PvlKeyword ("LineMaximum", lMax); - results += PvlKeyword ("LineStandardDeviation", lDev); + results += PvlKeyword("SampleMinimum", sMin); + results += PvlKeyword("SampleAverage", sTrans); + results += PvlKeyword("SampleMaximum", sMax); + results += PvlKeyword("SampleStandardDeviation", sDev); + results += PvlKeyword("LineMinimum", lMin); + results += PvlKeyword("LineAverage", lTrans); + results += PvlKeyword("LineMaximum", lMax); + results += PvlKeyword("LineStandardDeviation", lDev); Application::Log(results); Pvl arPvl = ar->RegistrationStatistics(); @@ -205,13 +205,13 @@ void IsisMain() { } // add the auto registration information to print.prt - PvlGroup autoRegTemplate = ar->RegTemplate(); + PvlGroup autoRegTemplate = ar->RegTemplate(); Application::Log(autoRegTemplate); // If none of the points registered, throw an error - if (sStats.TotalPixels() < 1) { + if(sStats.TotalPixels() < 1) { string msg = "Coreg was unable to register any points. Check your algorithm definition."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Don't need the cubes opened anymore @@ -219,22 +219,22 @@ void IsisMain() { match.Close(); // If a cnet file was entered, write the ControlNet pvl to the file - if (ui.WasEntered("CNETFILE")) { + if(ui.WasEntered("CNETFILE")) { cn.Write(ui.GetFilename("CNETFILE")); } // If flatfile was entered, create the flatfile // The flatfile is comma seperated and can be imported into an excel // spreadsheet - if (ui.WasEntered("FLATFILE")) { + if(ui.WasEntered("FLATFILE")) { string fFile = Filename(ui.GetFilename("FLATFILE")).Expanded(); ofstream os; - os.open(fFile.c_str(),ios::out); + os.open(fFile.c_str(), ios::out); os << "Sample,Line,TranslatedSample,TranslatedLine," << - "SampleDifference,LineDifference,GoodnessOfFit" << endl; - for (int i=0; iExec("translate",params); + ui.GetFilename("TO") + " strans=" + iString(sTrans) + " ltrans=" + + iString(lTrans) + " interp=" + ui.GetString("INTERP"); + iApp->Exec("translate", params); } else { string params = "from=" + ui.GetFilename("FROM") + " to=" + - ui.GetFilename("TO") + " cube=" + ui.GetFilename("MATCH") + " control=" + - ui.GetFilename("CNETFILE") + " interp=" + ui.GetString("INTERP") + - " degree=" + iString(ui.GetInteger("DEGREE")); - iApp->Exec("warp",params); + ui.GetFilename("TO") + " cube=" + ui.GetFilename("MATCH") + " control=" + + ui.GetFilename("CNETFILE") + " interp=" + ui.GetString("INTERP") + + " degree=" + iString(ui.GetInteger("DEGREE")); + iApp->Exec("warp", params); } } } //Helper function to output the regdeft file to log. -void helperButtonLog () { +void helperButtonLog() { UserInterface &ui = Application::GetUserInterface(); string file(ui.GetFilename("REGDEF")); Pvl p; diff --git a/isis/src/base/apps/cosi/cosi.cpp b/isis/src/base/apps/cosi/cosi.cpp index 41aaad73c9..2b9a613f37 100644 --- a/isis/src/base/apps/cosi/cosi.cpp +++ b/isis/src/base/apps/cosi/cosi.cpp @@ -12,7 +12,7 @@ Camera *cam; double maxinc; void divide(Buffer &in, Buffer &out); -void IsisMain () { +void IsisMain() { ProcessByLine p; Cube *icube = p.SetInputCube("FROM"); @@ -24,18 +24,18 @@ void IsisMain () { } void divide(Buffer &in, Buffer &out) { - for (int i=0; iSetImage(i+1,in.Line())) { - if (IsSpecial(in[i])) { + for(int i = 0; i < in.size(); i++) { + if(cam->SetImage(i + 1, in.Line())) { + if(IsSpecial(in[i])) { out[i] = in[i]; } else { double incidence = cam->IncidenceAngle(); - if (abs(incidence) >= maxinc) { + if(abs(incidence) >= maxinc) { out[i] = Isis::Null; } else { - out[i] = in[i] / cos(incidence*Isis::PI/180.0); + out[i] = in[i] / cos(incidence * Isis::PI / 180.0); } } } diff --git a/isis/src/base/apps/crop/crop.cpp b/isis/src/base/apps/crop/crop.cpp index ddb7e6f50b..24e798acf7 100644 --- a/isis/src/base/apps/crop/crop.cpp +++ b/isis/src/base/apps/crop/crop.cpp @@ -10,17 +10,17 @@ #include "Table.h" #include "SubArea.h" -using namespace std; +using namespace std; using namespace Isis; // Globals and prototypes -int ss,sl,sb; -int ns,nl,nb; -int sinc,linc; +int ss, sl, sb; +int ns, nl, nb; +int sinc, linc; Cube cube; LineManager *in = NULL; -void crop (Buffer &out); +void crop(Buffer &out); void IsisMain() { ProcessByLine p; @@ -41,55 +41,55 @@ void IsisMain() { int origns = cube.Samples(); int orignl = cube.Lines(); int es = cube.Samples(); - if (ui.WasEntered("NSAMPLES")) es = ui.GetInteger("NSAMPLES") + ss - 1; + if(ui.WasEntered("NSAMPLES")) es = ui.GetInteger("NSAMPLES") + ss - 1; int el = cube.Lines(); - if (ui.WasEntered("NLINES")) el = ui.GetInteger("NLINES") + sl - 1; + if(ui.WasEntered("NLINES")) el = ui.GetInteger("NLINES") + sl - 1; int eb = cube.Bands(); sinc = ui.GetInteger("SINC"); linc = ui.GetInteger("LINC"); // Make sure starting positions fall within the cube - if (ss > cube.Samples()) { + if(ss > cube.Samples()) { cube.Close(); string msg = "[SAMPLE] exceeds number of samples in the [FROM] cube"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - if (sl > cube.Lines()) { + if(sl > cube.Lines()) { cube.Close(); string msg = "[LINE] exceeds number of lines in the [FROM] cube"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // Make sure the number of elements do not fall outside the cube - if (es > cube.Samples()) { + if(es > cube.Samples()) { cube.Close(); string msg = "[SAMPLE+NSAMPLES-1] exceeds number of "; msg += "samples in the [FROM] cube"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - if (el > cube.Lines()) { + if(el > cube.Lines()) { cube.Close(); string msg = "[LINE+NLINES-1] exceeds number of "; msg += "lines in the [FROM] cube"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // Determine the size of the output cube and then update the image size ns = (es - ss + 1) / sinc; nl = (el - sl + 1) / linc; nb = eb; - if (ns == 0) ns = 1; - if (nl == 0) nl = 1; + if(ns == 0) ns = 1; + if(nl == 0) nl = 1; es = ss + (ns - 1) * sinc; el = sl + (nl - 1) * linc; // Allocate the output file and make sure things get propogated nicely p.SetInputCube("FROM"); p.PropagateTables(false); - Cube *ocube = p.SetOutputCube ("TO",ns,nl,nb); + Cube *ocube = p.SetOutputCube("TO", ns, nl, nb); p.ClearInputCubes(); // propagate tables manually @@ -120,7 +120,7 @@ void IsisMain() { if(table.IsSampleAssociated()) { int numDeleted = 0; for(int samp = 0; samp < cube.Samples(); samp++) { - // This tests checks to see if we would include this sample. + // This tests checks to see if we would include this sample. // samp - (ss-1)) / sinc must be a whole number less than ns. if((samp - (ss-1)) % sinc != 0 || (samp - (ss-1)) / sinc >= ns || (samp - (ss-1)) < 0) { table.Delete(samp-numDeleted); @@ -133,7 +133,7 @@ void IsisMain() { if(table.IsLineAssociated()) { int numDeleted = 0; for(int line = 0; line < cube.Lines(); line++) { - // This tests checks to see if we would include this line. + // This tests checks to see if we would include this line. // line - (sl-1)) / linc must be a whole number less than nl. if((line - (sl-1)) % linc != 0 || (line - (sl-1)) / linc >= nl || (line - (sl-1)) < 0) { table.Delete(line-numDeleted); @@ -173,42 +173,42 @@ void IsisMain() { // Construct a label with the results PvlGroup results("Results"); - results += PvlKeyword ("InputLines", orignl); - results += PvlKeyword ("InputSamples", origns); - results += PvlKeyword ("StartingLine", sl); - results += PvlKeyword ("StartingSample", ss); - results += PvlKeyword ("EndingLine", el); - results += PvlKeyword ("EndingSample", es); - results += PvlKeyword ("LineIncrement", linc); - results += PvlKeyword ("SampleIncrement", sinc); - results += PvlKeyword ("OutputLines", nl); - results += PvlKeyword ("OutputSamples", ns); + results += PvlKeyword("InputLines", orignl); + results += PvlKeyword("InputSamples", origns); + results += PvlKeyword("StartingLine", sl); + results += PvlKeyword("StartingSample", ss); + results += PvlKeyword("EndingLine", el); + results += PvlKeyword("EndingSample", es); + results += PvlKeyword("LineIncrement", linc); + results += PvlKeyword("SampleIncrement", sinc); + results += PvlKeyword("OutputLines", nl); + results += PvlKeyword("OutputSamples", ns); // Update the Mapping, Instrument, and AlphaCube groups in the output - // cube label + // cube label SubArea s; - s.SetSubArea(orignl,origns,sl,ss,el,es,linc,sinc); - s.UpdateLabel(&cube,ocube,results); + s.SetSubArea(orignl, origns, sl, ss, el, es, linc, sinc); + s.UpdateLabel(&cube, ocube, results); // Cleanup p.EndProcess(); cube.Close(); - + // Write the results to the log Application::Log(results); } // Line processing routine -void crop (Buffer &out) { +void crop(Buffer &out) { // Read the input line int iline = sl + (out.Line() - 1) * linc; - in->SetLine(iline,sb); + in->SetLine(iline, sb); cube.Read(*in); // Loop and move appropriate samples - for (int i=0; iSetText("Finding Perimeter"); - + // Start the first pass p1.StartProcess(FindPerimeter); p1.EndProcess(); - if (minSample == cube.Samples() + 1) { + if(minSample == cube.Samples() + 1) { cube.Close(); string msg = "There are no valid pixels in the [FROM] cube"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } numSamples = maxSample - (minSample - 1); numLines = maxLine - (minLine - 1); - + // Setup the output cube ProcessByLine p2; p2.SetInputCube("FROM"); p2.PropagateTables(false); p2.Progress()->SetText("Removing Special Pixels"); Cube *ocube = p2.SetOutputCube("TO", numSamples, numLines, numBands); - p2.ClearInputCubes(); - + p2.ClearInputCubes(); + // propagate tables manually Pvl &inLabels = *cube.Label(); - + // Loop through the labels looking for object = Table for(int labelObj = 0; labelObj < inLabels.Objects(); labelObj++) { PvlObject &obj = inLabels.Object(labelObj); - + if(obj.Name() != "Table") continue; - + // Read the table into a table object Table table(obj["Name"], from); - + ocube->Write(table); } // Construct a label with the results PvlGroup results("Results"); - results += PvlKeyword ("InputLines", cube.Lines()); - results += PvlKeyword ("InputSamples", cube.Samples()); - results += PvlKeyword ("StartingLine", minLine); - results += PvlKeyword ("StartingSample", minSample); - results += PvlKeyword ("EndingLine", maxLine); - results += PvlKeyword ("EndingSample", maxSample); - results += PvlKeyword ("OutputLines", numLines); - results += PvlKeyword ("OutputSamples", numSamples); - + results += PvlKeyword("InputLines", cube.Lines()); + results += PvlKeyword("InputSamples", cube.Samples()); + results += PvlKeyword("StartingLine", minLine); + results += PvlKeyword("StartingSample", minSample); + results += PvlKeyword("EndingLine", maxLine); + results += PvlKeyword("EndingSample", maxSample); + results += PvlKeyword("OutputLines", numLines); + results += PvlKeyword("OutputSamples", numSamples); + // Create a buffer for reading the input cube in = new LineManager(cube); - + // Start the second pass p2.StartProcess(SpecialRemoval); // Update the Mapping, Instrument, and AlphaCube groups in the output // cube label SubArea s; - s.SetSubArea(cube.Lines(),cube.Samples(),minLine,minSample,minLine+numLines-1, - minSample+numSamples-1,1.0,1.0); - s.UpdateLabel(&cube,ocube,results); + s.SetSubArea(cube.Lines(), cube.Samples(), minLine, minSample, minLine + numLines - 1, + minSample + numSamples - 1, 1.0, 1.0); + s.UpdateLabel(&cube, ocube, results); - p2.EndProcess(); - cube.Close(); + p2.EndProcess(); + cube.Close(); delete in; in = NULL; @@ -122,39 +122,39 @@ void IsisMain() { } // Process each line to find the min and max lines and samples -void FindPerimeter (Buffer &in) { - for (int i = 0; i < in.size(); i++) { +void FindPerimeter(Buffer &in) { + for(int i = 0; i < in.size(); i++) { // Do nothing until we find a valid pixel, or a pixel we do not want to crop off - if ((Pixel::IsValid(in[i])) || (Pixel::IsNull(in[i]) && !cropNulls) || - (Pixel::IsHrs(in[i]) && !cropHrs) || (Pixel::IsLrs(in[i]) && !cropLrs) || + if((Pixel::IsValid(in[i])) || (Pixel::IsNull(in[i]) && !cropNulls) || + (Pixel::IsHrs(in[i]) && !cropHrs) || (Pixel::IsLrs(in[i]) && !cropLrs) || (Pixel::IsHis(in[i]) && !cropHis) || (Pixel::IsLis(in[i]) && !cropLis)) { // The current line has a valid pixel and is greater than max, so make it the new max line - if (in.Line() > maxLine) maxLine = in.Line(); + if(in.Line() > maxLine) maxLine = in.Line(); // This is the first line to contain a valid pixel, so it's the min line - if (in.Line() < minLine) minLine = in.Line(); + if(in.Line() < minLine) minLine = in.Line(); int cur_sample = i + 1; // We process by line, so the min sample is the valid pixel with the lowest index in all line arrays - if (cur_sample < minSample) minSample = cur_sample; + if(cur_sample < minSample) minSample = cur_sample; // Conversely, the max sample is the valid pixel with the highest index - if (cur_sample > maxSample) maxSample = cur_sample; - } + if(cur_sample > maxSample) maxSample = cur_sample; + } } } // Using the min and max values, create a new cube without the extra specials -void SpecialRemoval (Buffer &out) { +void SpecialRemoval(Buffer &out) { int iline = minLine + (out.Line() - 1); in->SetLine(iline, curBand); cube.Read(*in); // Loop and move appropriate samples - for (int i = 0; i < out.size(); i++) { + for(int i = 0; i < out.size(); i++) { out[i] = (*in)[(minSample - 1) + i]; } - if (out.Line() == numLines) curBand++; + if(out.Line() == numLines) curBand++; } diff --git a/isis/src/base/apps/cubeatt/cubeatt.cpp b/isis/src/base/apps/cubeatt/cubeatt.cpp index 39916ae38d..e57dfeb0e6 100644 --- a/isis/src/base/apps/cubeatt/cubeatt.cpp +++ b/isis/src/base/apps/cubeatt/cubeatt.cpp @@ -4,30 +4,29 @@ using namespace std; using namespace Isis; -void cubeatt (Buffer &in, Buffer &out); +void cubeatt(Buffer &in, Buffer &out); void IsisMain() { // We will be processing by line ProcessByLine p; // Should we propagate tables - if (!Application::GetUserInterface().GetBoolean("PROPTABLES")) { + if(!Application::GetUserInterface().GetBoolean("PROPTABLES")) { p.PropagateTables(false); } // Setup the input and output cubes p.SetInputCube("FROM"); - p.SetOutputCube ("TO" ); + p.SetOutputCube("TO"); p.StartProcess(cubeatt); p.EndProcess(); } // Line processing routine -void cubeatt (Buffer &in, Buffer &out) -{ +void cubeatt(Buffer &in, Buffer &out) { // Loop and copy pixels in the line. - for (int i=0; i &in, - vector &out); +void cubeavg(vector &in, + vector &out); -void removekeywords ( PvlGroup & pvlg ); +void removekeywords(PvlGroup &pvlg); -void compute (vector centers, - vector widths, - Cube *ocube ); +void compute(vector centers, + vector widths, + Cube *ocube); void IsisMain() { ProcessBySpectra p; - p.SetType( ProcessBySpectra::PerPixel ); + p.SetType(ProcessBySpectra::PerPixel); Cube *icube = p.SetInputCube("FROM"); Cube *ocube = p.SetOutputCube("TO", icube->Samples(), icube->Lines(), 1); //Get user parameters and sets outputcube's BandBin UserInterface &ui = Application::GetUserInterface(); if(ui.GetString("BANDBIN") == "COMPUTE") { - if( icube->HasGroup("BandBin") ) { + if(icube->HasGroup("BandBin")) { PvlGroup &pvlg = icube->GetGroup("BandBin"); - removekeywords( pvlg ); + removekeywords(pvlg); if(pvlg.HasKeyword("Center")) { bool hasWidth = pvlg.HasKeyword("Width"); PvlKeyword &pvlCenter = pvlg.FindKeyword("Center"); - PvlKeyword * pvlWidth = NULL; + PvlKeyword *pvlWidth = NULL; if(hasWidth) { pvlWidth = & pvlg.FindKeyword("Width"); } @@ -40,9 +40,9 @@ void IsisMain() { centers.resize(icube->Bands()); std::vector widths; widths.resize(icube->Bands()); - for( int i=0; iHasGroup("BandBin") ) { + if(ocube->HasGroup("BandBin")) { ocube->DeleteGroup("BandBin"); } ocube->PutGroup(pvlg); @@ -109,52 +109,52 @@ void IsisMain() { } // Band processing routine -void cubeavg ( vector &in, vector &out ) { +void cubeavg(vector &in, vector &out) { Statistics sts; - sts.AddData( (*in[0]).DoubleBuffer() , (*in[0]).size() ); + sts.AddData((*in[0]).DoubleBuffer() , (*in[0]).size()); (*out[0]) = sts.Average(); } -/** +/** * Removes the PvlKeywords that can't be processed - * + * * @param pvlg the group from which the keywords are removed */ -void removekeywords ( PvlGroup & pvlg ) { - if( pvlg.HasKeyword("OriginalBand") ) { +void removekeywords(PvlGroup &pvlg) { + if(pvlg.HasKeyword("OriginalBand")) { pvlg.DeleteKeyword("OriginalBand"); } - if( pvlg.HasKeyword("Name") ) { + if(pvlg.HasKeyword("Name")) { pvlg.DeleteKeyword("Name"); } } //BandBin Computeing -void compute( vector centers, vector widths, - Cube *ocube ) { +void compute(vector centers, vector widths, + Cube *ocube) { PvlGroup &pvlg = ocube->GetGroup("BandBin"); PvlKeyword &pvlCenter = pvlg.FindKeyword("Center"); string centerUnit = pvlCenter.Unit(); bool hasWidth = pvlg.HasKeyword("Width"); - double large = centers[0] + widths[0]/2; - double small = centers[0] - widths[0]/2; - for( int i=1; i (double)centers[i] - (double)widths[i]/2.0 ) { - small = (double)centers[i] - (double)widths[i]/2.0; + if(small > (double)centers[i] - (double)widths[i] / 2.0) { + small = (double)centers[i] - (double)widths[i] / 2.0; } } - pvlCenter.SetValue( iString( (large-small)/2 + small ), centerUnit ); - if( hasWidth ) { + pvlCenter.SetValue(iString((large - small) / 2 + small), centerUnit); + if(hasWidth) { PvlKeyword &pvlWidth = pvlg.FindKeyword("Width"); - pvlWidth.SetValue( large-small, pvlWidth.Unit() ); + pvlWidth.SetValue(large - small, pvlWidth.Unit()); } else { PvlKeyword pvlWidth = PvlKeyword("Width"); - pvlWidth.SetValue( large-small, centerUnit ); + pvlWidth.SetValue(large - small, centerUnit); pvlg.AddKeyword(pvlWidth); } - + } diff --git a/isis/src/base/apps/cubediff/Column.cpp b/isis/src/base/apps/cubediff/Column.cpp index dd56b10891..8cb0645411 100644 --- a/isis/src/base/apps/cubediff/Column.cpp +++ b/isis/src/base/apps/cubediff/Column.cpp @@ -26,12 +26,12 @@ #include "Column.h" #include "iException.h" -namespace Isis{ +namespace Isis { /** * Constructor. Sets the precision for decimal-aligned columns to 4 */ - Column::Column(){ + Column::Column() { p_precision = 4; p_width = 0; p_name = ""; @@ -41,13 +41,13 @@ namespace Isis{ /** * Constructor with parameter - * + * * @param name The name of the column, used as the header * @param width The width (in characters) to make the column * @param type The type of information the column is to represent * @param align The alignment, within the column, the data is to conform to */ - Column::Column( std::string name, int width, Column::Type type, Column::Align align) { + Column::Column(std::string name, int width, Column::Type type, Column::Align align) { //Set the parameters with function calls, to make use of pre-existing error checks SetWidth(width); SetName(name); @@ -59,92 +59,92 @@ namespace Isis{ /** * Sets the Column name, or header - * + * * @param name The name of the Column */ - void Column::SetName (std::string name) { - if (p_width != 0 && name.length() > p_width) { + void Column::SetName(std::string name) { + if(p_width != 0 && name.length() > p_width) { std::string message = "Name[" + name + "] is wider than width"; - throw iException::Message(iException::User,message,_FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } p_name = name; } /** * Sets the width of the Column, in text columns - * + * * @param width The number of text columns the Column will hold */ - void Column::SetWidth (unsigned int width) { - if (p_name.size() > 0 && p_name.size() > width) { + void Column::SetWidth(unsigned int width) { + if(p_name.size() > 0 && p_name.size() > width) { std::string message = "Width is insufficient to contain name["; message += p_name + "]"; - throw iException::Message(iException::User,message,_FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } p_width = width; } /** * Sets the data type of the Column - * + * * @param type The data type for the Column */ - void Column::SetType (Column::Type type) { - if (p_align == Column::Decimal && + void Column::SetType(Column::Type type) { + if(p_align == Column::Decimal && (type == Column::Integer || type == Column::String)) { - std::string message = "Integer or string type is not sensible if "; - message += "alignment is Decimal."; - throw iException::Message(iException::User,message,_FILEINFO_); + std::string message = "Integer or string type is not sensible if "; + message += "alignment is Decimal."; + throw iException::Message(iException::User, message, _FILEINFO_); } p_type = type; } /** * Sets the alignment of the Column - * + * * The text in the Column will be aligned according to this parameter, * which is Right, Left, or, possible only with real-number values, * aligned by the decimal point - * + * * @param alignment The alignment of the text in the Column */ - void Column::SetAlignment (Column::Align alignment) { - if (alignment == Column::Decimal && + void Column::SetAlignment(Column::Align alignment) { + if(alignment == Column::Decimal && (p_type == Column::Integer || p_type == Column::String)) { - std::string message = "Decimal alignment does not make sense for "; - message += "integer or string values."; - throw iException::Message(iException::Programmer,message,_FILEINFO_); + std::string message = "Decimal alignment does not make sense for "; + message += "integer or string values."; + throw iException::Message(iException::Programmer, message, _FILEINFO_); } p_align = alignment; } /** * Sets the precision of the Column, for real number values - * + * * This sets the number of digits after the decimal point, for decimal aligned * values. If the Column's alignment is anything else, an error is thrown. - * + * * @param precision The number of digits after the decimal point to be shown */ void Column::SetPrecision(unsigned int precision) { - if (DataType() != Column::Real && + if(DataType() != Column::Real && DataType() != Column::Pixel) { std::string message = "Setting precision only makes sense for Decimal Alignment"; - throw iException::Message(iException::User,message,_FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } p_precision = precision; } /** * Returns the type of data this column will contain - * + * * @return Column::Type The data type of this column */ Column::Type Column::DataType() { - if (p_type == 0) { + if(p_type == 0) { std::string message = "Type has not been set yet!"; - throw iException::Message(iException::User,message,_FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } return p_type; diff --git a/isis/src/base/apps/cubediff/Column.h b/isis/src/base/apps/cubediff/Column.h index 35f5c87c0d..d69d274a9f 100644 --- a/isis/src/base/apps/cubediff/Column.h +++ b/isis/src/base/apps/cubediff/Column.h @@ -28,50 +28,60 @@ namespace Isis { /** * @brief Format ascii tables - * + * * This class takes in a series of string vectors and writes them out to a * file as a table. Formatting options are up to the user. - * + * * @ingroup Utility - * + * * @author 2007-05-01 Brendan George - * + * * @internal * @history 2007-06-18 Brendan George Fixed error message outputs and * unitTest */ class Column { - public: + public: - enum Align { NoAlign = 0, - Right = 1, - Left = 2, - Decimal = 3 }; - enum Type { NoType = 0, - Integer = 1, - Real = 2, - String = 3, - Pixel = 4 }; - Column (); - Column (std::string name, int width, Column::Type type, Align align=Column::Right); - void SetName (std::string name); - void SetWidth (unsigned int width); - void SetType (Column::Type type); - void SetAlignment (Column::Align alignment); - void SetPrecision (unsigned int precision); + enum Align { NoAlign = 0, + Right = 1, + Left = 2, + Decimal = 3 + }; + enum Type { NoType = 0, + Integer = 1, + Real = 2, + String = 3, + Pixel = 4 + }; + Column(); + Column(std::string name, int width, Column::Type type, Align align = Column::Right); + void SetName(std::string name); + void SetWidth(unsigned int width); + void SetType(Column::Type type); + void SetAlignment(Column::Align alignment); + void SetPrecision(unsigned int precision); - std::string Name () {return p_name;}; - unsigned int Width (){return p_width;}; - Column::Type DataType (); - Column::Align Alignment (){return p_align;}; - unsigned int Precision (){return p_precision;}; + std::string Name() { + return p_name; + }; + unsigned int Width() { + return p_width; + }; + Column::Type DataType(); + Column::Align Alignment() { + return p_align; + }; + unsigned int Precision() { + return p_precision; + }; - private: - std::string p_name; - unsigned int p_width; - Column::Type p_type; - Column::Align p_align; - unsigned int p_precision; + private: + std::string p_name; + unsigned int p_width; + Column::Type p_type; + Column::Align p_align; + unsigned int p_precision; }; }; diff --git a/isis/src/base/apps/cubediff/WriteTabular.cpp b/isis/src/base/apps/cubediff/WriteTabular.cpp index 4a27202436..2d6cea9d11 100644 --- a/isis/src/base/apps/cubediff/WriteTabular.cpp +++ b/isis/src/base/apps/cubediff/WriteTabular.cpp @@ -37,7 +37,7 @@ namespace Isis { * Constructor * @param filename The name of the file where the table will be written */ - WriteTabular::WriteTabular( std::ostream &strm ) : p_outfile (strm) { + WriteTabular::WriteTabular(std::ostream &strm) : p_outfile(strm) { p_rows = 0; p_delimiter = ","; p_curCol = 0; @@ -49,48 +49,48 @@ namespace Isis { * formatted * @param cols The Column headers, containing information about the Columns */ - WriteTabular::WriteTabular( std::ostream &strm, std::vector cols) : p_outfile(strm) { + WriteTabular::WriteTabular(std::ostream &strm, std::vector cols) : p_outfile(strm) { p_rows = 0; p_delimiter = ","; p_curCol = 0; - SetColumns (cols); + SetColumns(cols); } /** * Sets the vector of Columns and writes out the first row of the file. - * + * * @param cols A vector of Columns, setting the format of the table */ - void WriteTabular::SetColumns(std::vector cols ){ - for (unsigned int index=0; index < cols.size(); index++) { + void WriteTabular::SetColumns(std::vector cols) { + for(unsigned int index = 0; index < cols.size(); index++) { Column thisCol = cols[index]; std::string thisTitle = thisCol.Name(); - if (thisTitle.length() > thisCol.Width()) { + if(thisTitle.length() > thisCol.Width()) { std::string message = "Column header [" + thisTitle + "] is wider " + - "than the set width for column [" + iString((int)index) + "]"; - throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_); + "than the set width for column [" + iString((int)index) + "]"; + throw Isis::iException::Message(Isis::iException::User, message, _FILEINFO_); } int iteration = 0; - while (thisTitle.length() < thisCol.Width()) { - if (thisCol.Alignment() == Column::Left) { + while(thisTitle.length() < thisCol.Width()) { + if(thisCol.Alignment() == Column::Left) { thisTitle += " "; } - else if (thisCol.Alignment() == Column::Right || - thisCol.Alignment() == Column::Decimal) { + else if(thisCol.Alignment() == Column::Right || + thisCol.Alignment() == Column::Decimal) { thisTitle = " " + thisTitle; } else { std::string message = "Alignment is improperly set"; - throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, message, _FILEINFO_); } iteration++; }//end while p_cols.push_back(thisCol); p_outfile << thisTitle; - if (index < (cols.size()-1)) { + if(index < (cols.size() - 1)) { p_outfile << p_delimiter; } }//end for @@ -111,11 +111,11 @@ namespace Isis { tempStream << item; item = tempStream.str(); - if (p_curCol == 0) { + if(p_curCol == 0) { p_rows++; } - if (p_curCol < (p_cols.size()-1)) { + if(p_curCol < (p_cols.size() - 1)) { item += p_delimiter; p_curCol++; } @@ -128,25 +128,25 @@ namespace Isis { /** * Add an integer value to the next column in this row - * + * * @param item The integer value to put in this column. */ - void WriteTabular::Write(int item){ + void WriteTabular::Write(int item) { Column thisCol = p_cols[p_curCol]; - if (thisCol.DataType() != Column::Integer && + if(thisCol.DataType() != Column::Integer && thisCol.DataType() != Column::Pixel) { - if (thisCol.DataType() == Column::Real || + if(thisCol.DataType() == Column::Real || thisCol.DataType() == Column::Pixel) { Write((double)item); return; } std::string message = "Wrong data type for this Column"; - throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, message, _FILEINFO_); } iString thisItem(item); - if (thisItem.length() > thisCol.Width()) { + if(thisItem.length() > thisCol.Width()) { thisItem = "*"; - while (thisItem.length() < thisCol.Width()) { + while(thisItem.length() < thisCol.Width()) { thisItem += "*"; } } @@ -154,7 +154,7 @@ namespace Isis { tempStream.width(thisCol.Width()); tempStream.fill(' '); - if (thisCol.Alignment() == Column::Left) { + if(thisCol.Alignment() == Column::Left) { tempStream.setf(std::ios::left); } else tempStream.setf(std::ios::right); @@ -162,11 +162,11 @@ namespace Isis { tempStream << thisItem; thisItem = tempStream.str(); - if (p_curCol == 0) { + if(p_curCol == 0) { p_rows++; } - if (p_curCol < (p_cols.size()-1)) { + if(p_curCol < (p_cols.size() - 1)) { thisItem += p_delimiter; p_curCol++; } @@ -179,19 +179,19 @@ namespace Isis { /** * Writes a string to the next column in the current row - * + * * @param item The string to write out */ - void WriteTabular::Write(std::string item){ + void WriteTabular::Write(std::string item) { Column thisCol = p_cols[p_curCol]; - if (thisCol.DataType() != Column::String && + if(thisCol.DataType() != Column::String && thisCol.DataType() != Column::Pixel) { std::string message = "Wrong data type for this Column"; - throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, message, _FILEINFO_); } - if (item.length() > thisCol.Width()) { + if(item.length() > thisCol.Width()) { item = "*"; - while (item.length() < thisCol.Width()) { + while(item.length() < thisCol.Width()) { item += "*"; } } @@ -199,7 +199,7 @@ namespace Isis { tempStream.width(thisCol.Width()); tempStream.fill(' '); - if (thisCol.Alignment() == Column::Left) { + if(thisCol.Alignment() == Column::Left) { tempStream.setf(std::ios::left); } else tempStream.setf(std::ios::right); @@ -207,11 +207,11 @@ namespace Isis { tempStream << item; item = tempStream.str(); - if (p_curCol == 0) { + if(p_curCol == 0) { p_rows++; } - if (p_curCol < (p_cols.size()-1)) { + if(p_curCol < (p_cols.size() - 1)) { item += p_delimiter; p_curCol++; } @@ -224,36 +224,36 @@ namespace Isis { /** * Writes a floating-point value out to the next column in the current row - * + * * @param item The value to be printed out */ - void WriteTabular::Write(double item){ + void WriteTabular::Write(double item) { Column thisCol = p_cols[p_curCol]; - if (thisCol.DataType() != Column::Real && + if(thisCol.DataType() != Column::Real && thisCol.DataType() != Column::Pixel) { std::string message = "Wrong data type for this Column"; - throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, message, _FILEINFO_); } //Check for special pixels, if it's a pixel column - if (thisCol.DataType() == Column::Pixel && IsSpecial(item)) { - if (IsNullPixel(item)) { + if(thisCol.DataType() == Column::Pixel && IsSpecial(item)) { + if(IsNullPixel(item)) { Write("Null"); return; } - if (IsHisPixel(item)) { + if(IsHisPixel(item)) { Write("His"); return; } - if (IsHrsPixel(item)) { + if(IsHrsPixel(item)) { Write("Hrs"); return; } - if (IsLisPixel(item)) { + if(IsLisPixel(item)) { Write("Lis"); return; } - if (IsLrsPixel(item)) { + if(IsLrsPixel(item)) { Write("Lrs"); return; } @@ -262,7 +262,7 @@ namespace Isis { iString thisItem(item); - if (thisCol.Alignment() == Column::Decimal) { + if(thisCol.Alignment() == Column::Decimal) { //Format and round the number @@ -271,7 +271,7 @@ namespace Isis { iString intPart = tempString.Token("."); //Make the fractional portion appear as such, so the iomanipulators //handle it properly - if (tempString != "") { + if(tempString != "") { tempString = "0." + tempString; } else tempString = "0.0"; @@ -285,7 +285,7 @@ namespace Isis { //if the rounding causes a rollover (i.e. the decimal portion is greater //than 0.95) increment the integer portion - if (iString(b.str()).ToDouble() >= 1) { + if(iString(b.str()).ToDouble() >= 1) { intPart = iString(intPart.ToInteger() + 1); } @@ -293,7 +293,7 @@ namespace Isis { tempString = b.str(); tempString.Token("."); //Add any zeros necessary to pad the number - while (tempString.size() < thisCol.Precision()) { + while(tempString.size() < thisCol.Precision()) { tempString += "0"; } @@ -304,7 +304,7 @@ namespace Isis { tempStream.width(thisCol.Width()); tempStream.fill(' '); - if (thisCol.Alignment() == Column::Left) { + if(thisCol.Alignment() == Column::Left) { tempStream.setf(std::ios::left); } else tempStream.setf(std::ios::right); @@ -312,19 +312,19 @@ namespace Isis { tempStream << thisItem; thisItem = tempStream.str(); - if (p_curCol == 0) { + if(p_curCol == 0) { p_rows++; } //If the number is too wide for the column, replace with a string of stars - if (thisItem.length() > thisCol.Width()) { + if(thisItem.length() > thisCol.Width()) { thisItem = "*"; - while (thisItem.length() < thisCol.Width()) { + while(thisItem.length() < thisCol.Width()) { thisItem += "*"; } } - if (p_curCol < (p_cols.size()-1)) { + if(p_curCol < (p_cols.size() - 1)) { thisItem += p_delimiter; p_curCol++; } @@ -338,10 +338,10 @@ namespace Isis { /** * Sets the string to be put between columns for this table - * + * * @param delim The string to separate columns */ - void WriteTabular::SetDelimiter( std::string delim ) { + void WriteTabular::SetDelimiter(std::string delim) { p_delimiter = delim; } diff --git a/isis/src/base/apps/cubediff/WriteTabular.h b/isis/src/base/apps/cubediff/WriteTabular.h index c5d435cdb4..b5d6681789 100644 --- a/isis/src/base/apps/cubediff/WriteTabular.h +++ b/isis/src/base/apps/cubediff/WriteTabular.h @@ -29,29 +29,33 @@ namespace Isis { /** * @brief Format ascii tables - * + * * This class takes in a series of string vectors and writes them out to a * file as a table. Formatting options are up to the user. - * + * * @ingroup Utility - * + * * @author 2007-05-01 Brendan George */ class WriteTabular { public: // Constructor and Destructor - WriteTabular(std::ostream &strm, std::vector cols ); - WriteTabular(std::ostream &strm ); + WriteTabular(std::ostream &strm, std::vector cols); + WriteTabular(std::ostream &strm); - void SetColumns( std::vector cols ); + void SetColumns(std::vector cols); void Write(); - void Write (int item); - void Write (std::string item); - void Write (double item); + void Write(int item); + void Write(std::string item); + void Write(double item); void SetDelimiter(std::string delim); - int Columns() {return p_cols.size();}; - int Rows() {return p_rows;}; + int Columns() { + return p_cols.size(); + }; + int Rows() { + return p_rows; + }; private: std::string p_delimiter; diff --git a/isis/src/base/apps/cubediff/cubediff.cpp b/isis/src/base/apps/cubediff/cubediff.cpp index a6dc21a3ef..3fa053c8d9 100644 --- a/isis/src/base/apps/cubediff/cubediff.cpp +++ b/isis/src/base/apps/cubediff/cubediff.cpp @@ -14,12 +14,12 @@ #include "iString.h" #include "Pixel.h" -using namespace std; +using namespace std; using namespace Isis; -void compare (vector &in, vector &out); +void compare(vector &in, vector &out); -void diffTable (ofstream &target, int precision); +void diffTable(ofstream &target, int precision); // This is only used for the difference table struct Difference { @@ -32,7 +32,7 @@ struct Difference { double tolerance; bool filesEqual = true; bool firstDifferenceFound = false; // Set to true when first DN value difference is found -int sample,line,band,spCount,diffCount,colWidth; +int sample, line, band, spCount, diffCount, colWidth; Statistics stats; bool doTable; unsigned int sigFigAccuracy = DBL_DIG; // DBL_DIG is maximum accuracy for a double @@ -41,7 +41,7 @@ int sigFigLine = 0; int sigFigSample = 0; int sigFigBand = 0; -int gMaxDiffLine=0, gMaxDiffSample=0, gMaxDiffBand=0; +int gMaxDiffLine = 0, gMaxDiffSample = 0, gMaxDiffBand = 0; double gMaxDiff; void IsisMain() { @@ -52,20 +52,20 @@ void IsisMain() { // Read tolerance value UserInterface &ui = Application::GetUserInterface(); - if (ui.WasEntered ("TOLERANCE")) { + if(ui.WasEntered("TOLERANCE")) { tolerance = ui.GetDouble("TOLERANCE"); } else { tolerance = DBL_EPSILON; - } + } // See if we should output the difference table - if (ui.GetBoolean("OUTPUTDIFFS")){ + if(ui.GetBoolean("OUTPUTDIFFS")) { doTable = true; diffCount = ui.GetInteger("COUNT"); - if (!ui.WasEntered("TO")) { + if(!ui.WasEntered("TO")) { string message = "A target file is required for difference output"; - throw iException::Message(iException::User,message,_FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } } @@ -75,53 +75,54 @@ void IsisMain() { spCount = 0; stats.Reset(); colWidth = 0; - gMaxDiff=tolerance; + gMaxDiff = tolerance; p.StartProcess(compare); // Write to log indicating if two files are filesEqual. PvlGroup results("Results"); - if (filesEqual) { - results += PvlKeyword ("Compare","Identical"); + if(filesEqual) { + results += PvlKeyword("Compare", "Identical"); } else { - results += PvlKeyword ("Compare","Different"); - results += PvlKeyword ("Sample",sample); - results += PvlKeyword ("Line",line); - results += PvlKeyword ("Band",band); + results += PvlKeyword("Compare", "Different"); + results += PvlKeyword("Sample", sample); + results += PvlKeyword("Line", line); + results += PvlKeyword("Band", band); if(stats.TotalPixels() < 1) { - results += PvlKeyword ("AverageDifference",0); - results += PvlKeyword ("StandardDeviation",0); - results += PvlKeyword ("Variance",0); - results += PvlKeyword ("MinimumDifference",0); - results += PvlKeyword ("MaximumDifference",0); - } else { - results += PvlKeyword ("AverageDifference",(double)stats.Average()); - results += PvlKeyword ("StandardDeviation",(double)stats.StandardDeviation()); - results += PvlKeyword ("Variance",(double)stats.Variance()); - results += PvlKeyword ("MinimumDifference",(double)stats.Minimum()); - results += PvlKeyword ("MaximumDifference",(double)stats.Maximum()); - results += PvlKeyword ("MaxDifferenceSample",(int)gMaxDiffSample); - results += PvlKeyword ("MaxDifferenceLine",(int)gMaxDiffLine); - results += PvlKeyword ("MaxDifferenceBand",(int)gMaxDiffBand); + results += PvlKeyword("AverageDifference", 0); + results += PvlKeyword("StandardDeviation", 0); + results += PvlKeyword("Variance", 0); + results += PvlKeyword("MinimumDifference", 0); + results += PvlKeyword("MaximumDifference", 0); + } + else { + results += PvlKeyword("AverageDifference", (double)stats.Average()); + results += PvlKeyword("StandardDeviation", (double)stats.StandardDeviation()); + results += PvlKeyword("Variance", (double)stats.Variance()); + results += PvlKeyword("MinimumDifference", (double)stats.Minimum()); + results += PvlKeyword("MaximumDifference", (double)stats.Maximum()); + results += PvlKeyword("MaxDifferenceSample", (int)gMaxDiffSample); + results += PvlKeyword("MaxDifferenceLine", (int)gMaxDiffLine); + results += PvlKeyword("MaxDifferenceBand", (int)gMaxDiffBand); } - results += PvlKeyword ("ValidPixelDifferences",stats.TotalPixels()); - results += PvlKeyword ("SpecialPixelDifferences",spCount); - results += PvlKeyword ("SigFigAccuracy", (int)sigFigAccuracy); - results += PvlKeyword ("SigFigMaxDifferenceSample", (int)sigFigSample); - results += PvlKeyword ("SigFigMaxDifferenceLine", (int)sigFigLine); - results += PvlKeyword ("SigFigMaxDifferenceBand", (int)sigFigBand); + results += PvlKeyword("ValidPixelDifferences", stats.TotalPixels()); + results += PvlKeyword("SpecialPixelDifferences", spCount); + results += PvlKeyword("SigFigAccuracy", (int)sigFigAccuracy); + results += PvlKeyword("SigFigMaxDifferenceSample", (int)sigFigSample); + results += PvlKeyword("SigFigMaxDifferenceLine", (int)sigFigLine); + results += PvlKeyword("SigFigMaxDifferenceBand", (int)sigFigBand); } Application::Log(results); // Output a file if the user request it - if (ui.WasEntered ("TO")) { + if(ui.WasEntered("TO")) { Pvl lab; lab.AddGroup(results); - lab.Write (ui.GetFilename("TO","txt")); + lab.Write(ui.GetFilename("TO", "txt")); } - if (doTable) { - string filename = Filename(ui.GetFilename("TO","txt")).Expanded(); - ofstream ofile(filename.c_str(),ios_base::app); + if(doTable) { + string filename = Filename(ui.GetFilename("TO", "txt")).Expanded(); + ofstream ofile(filename.c_str(), ios_base::app); diffTable(ofile, ui.GetInteger("PRECISION")); } @@ -129,13 +130,13 @@ void IsisMain() { filesEqual = true; } -void compare (vector &in,vector &out) { +void compare(vector &in, vector &out) { Buffer &input1 = *in[0]; Buffer &input2 = *in[1]; int inputSize = input1.size(); double MaxDiffTemp; - - for (int index = 0; index < inputSize; index ++) { + + for(int index = 0; index < inputSize; index ++) { bool pixelDifferent = false; bool pixelSpecial = false; @@ -161,13 +162,13 @@ void compare (vector &in,vector &out) { MaxDiffTemp = abs(input1[index] - input2[index]); if(MaxDiffTemp > tolerance) { // This pixel is different. - pixelDifferent = true; - + pixelDifferent = true; + // Add the difference in dn to the stats object stats.AddData(MaxDiffTemp); - // Store line, sample and band of max difference - if (MaxDiffTemp > gMaxDiff) { + // Store line, sample and band of max difference + if(MaxDiffTemp > gMaxDiff) { gMaxDiff = MaxDiffTemp; gMaxDiffLine = input1.Line(index); gMaxDiffSample = input1.Sample(index); @@ -182,7 +183,7 @@ void compare (vector &in,vector &out) { // Check positive/negative and ensure both positive if((input1[index] < 0 && input2[index] > 0) || - (input1[index] > 0 && input2[index] < 0)) { + (input1[index] > 0 && input2[index] < 0)) { accuracy = 1; } else { @@ -216,8 +217,8 @@ void compare (vector &in,vector &out) { if(pixelDifferent) { filesEqual = false; - - if (!firstDifferenceFound) { + + if(!firstDifferenceFound) { firstDifferenceFound = true; sample = input1.Sample(index); line = input1.Line(index); @@ -225,9 +226,9 @@ void compare (vector &in,vector &out) { } } - // If the user indicated that we should make the table, add this entry - if (pixelDifferent && doTable) { - if ((int)diffset.size() < diffCount) { + // If the user indicated that we should make the table, add this entry + if(pixelDifferent && doTable) { + if((int)diffset.size() < diffCount) { Difference currDiff; currDiff.lineNum = input1.Line(index); currDiff.sampNum = input1.Sample(index); @@ -238,10 +239,10 @@ void compare (vector &in,vector &out) { // Check the character lengths of the values int val1Length = iString((int)currDiff.cube1Val).length(); int val2Length = iString((int)currDiff.cube2Val).length(); - if (val1Length < colWidth) { + if(val1Length < colWidth) { colWidth = val1Length; } - if (val2Length < colWidth) { + if(val2Length < colWidth) { colWidth = val2Length; } } @@ -249,23 +250,23 @@ void compare (vector &in,vector &out) { } } -//Function to prepare the table to append to the +//Function to prepare the table to append to the void diffTable(ofstream &target, int precision) { vector temp; //Make a list of all samples present - for (unsigned int i=0; i samps; samps.push_back(temp[0]); - for (unsigned int i=1; i (2*PI)) { + switch(Function) { + case COS: + if(in[i] < (-(2 * PI)) || in[i] > (2 * PI)) { out[i] = NULL8; bad++; } - out[i] = cos (in[i]); + out[i] = cos(in[i]); break; case SIN: - if (in[i] < (-(2*PI)) || in[i] > (2*PI)) { + if(in[i] < (-(2 * PI)) || in[i] > (2 * PI)) { out[i] = NULL8; bad++; } - out[i] = sin (in[i]); + out[i] = sin(in[i]); break; case TAN: // Check for invalid input values. Check within a certain // tolerance since the radiance value will probably never be - // exactly 90, 270, -90 or -270 degrees due to round off. + // exactly 90, 270, -90 or -270 degrees due to round off. // First convert input value from radians to degrees. - deg = in[i] * (180./PI); - if ( abs(abs(in[i]) - 90.0) <= .0001 || - abs(abs(in[i]) - 270.0) <= .0001) { + deg = in[i] * (180. / PI); + if(abs(abs(in[i]) - 90.0) <= .0001 || + abs(abs(in[i]) - 270.0) <= .0001) { out[i] = NULL8; bad++; } else { - out[i] = tan (in[i]); + out[i] = tan(in[i]); } break; case ACOS: - if (in[i] < -1.0 || in[i] > 1.0) { + if(in[i] < -1.0 || in[i] > 1.0) { out[i] = NULL8; bad++; } else { - out[i] = acos (in[i]); + out[i] = acos(in[i]); } break; case ASIN: - if (in[i] < -1.0 || in[i] > 1.0) { + if(in[i] < -1.0 || in[i] > 1.0) { out[i] = NULL8; bad++; } else { - out[i] = asin (in[i]); + out[i] = asin(in[i]); } break; case ATAN: - out[i] = atan (in[i]); + out[i] = atan(in[i]); break; case INV: - if (in[i] == 0) { + if(in[i] == 0) { out[i] = NULL8; bad++; } @@ -155,43 +154,43 @@ void cubefunc (Buffer &in, } break; case SQRT: - if (in[i] <= 0) { + if(in[i] <= 0) { out[i] = NULL8; bad++; } else { - out[i] = sqrt (in[i]); + out[i] = sqrt(in[i]); } break; case POW10: - out[i] = pow (10,in[i]); + out[i] = pow(10, in[i]); break; case EXP: - out[i] = exp (in[i]); + out[i] = exp(in[i]); break; case XTOY: - out[i] = pow (in[i],y); + out[i] = pow(in[i], y); break; case LOG10: - if (in[i] <= 0) { + if(in[i] <= 0) { out[i] = NULL8; bad++; } else { - out[i] = log10 (in[i]); + out[i] = log10(in[i]); } break; case LN: - if (in[i] <= 0) { + if(in[i] <= 0) { out[i] = NULL8; bad++; } else { - out[i] = log (in[i]); + out[i] = log(in[i]); } break; case ABS: - out[i] = abs (in[i]); + out[i] = abs(in[i]); break; } } diff --git a/isis/src/base/apps/cubeit/cubeit.cpp b/isis/src/base/apps/cubeit/cubeit.cpp index 862765c06d..6742ab1fc8 100644 --- a/isis/src/base/apps/cubeit/cubeit.cpp +++ b/isis/src/base/apps/cubeit/cubeit.cpp @@ -11,14 +11,14 @@ using namespace std; using namespace Isis; -void NullBand (Buffer &out); +void NullBand(Buffer &out); //helper button function in the code void helperButtonLog(); -map GuiHelpers(){ - map helper; - helper ["helperButtonLog"] = (void*) helperButtonLog; +map GuiHelpers() { + map helper; + helper ["helperButtonLog"] = (void *) helperButtonLog; return helper; } @@ -32,23 +32,23 @@ void IsisMain() { int nsamps(0), nlines(0), nbands(0); PvlGroup outBandBin("BandBin"); try { - for (unsigned int i=0; i bands = inatt.Bands(); cube.SetVirtualBands(bands); cube.Open(cubeList[i]); - if (i == 0) { + if(i == 0) { nsamps = cube.Samples(); nlines = cube.Lines(); nbands = cube.Bands(); } else { // Make sure they are all the same size - if ((nsamps != cube.Samples()) || (nlines != cube.Lines())) { + if((nsamps != cube.Samples()) || (nlines != cube.Lines())) { string msg = "Spatial dimensions of cube [" + cubeList[i] + "] does not match other cubes in list"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // Get the total number of bands nbands += cube.Bands(); @@ -56,17 +56,17 @@ void IsisMain() { // Build up the band bin group PvlObject &isiscube = cube.Label()->FindObject("IsisCube"); - if (isiscube.HasGroup("BandBin")) { + if(isiscube.HasGroup("BandBin")) { PvlGroup &inBandBin = isiscube.FindGroup("BandBin"); - for (int key=0; keySetText("Allocating cube"); p2.StartProcess(NullBand); // Add the band bin group if necessary - if (outBandBin.Keywords() > 0) { + if(outBandBin.Keywords() > 0) { ocube->PutGroup(outBandBin); } p2.EndProcess(); // Now loop and mosaic in each cube int sband = 1; - for (unsigned int i=0; iSetText("Adding band " + iString((int)i+1) + + prog->SetText("Adding band " + iString((int)i + 1) + " of " + iString(nbands)); m.SetOutputCube("TO"); CubeAttributeInput attrib(cubeList[i]); - Cube *icube = m.SetInputCube(cubeList[i],attrib); - m.StartProcess(1,1,sband,input); + Cube *icube = m.SetInputCube(cubeList[i], attrib); + m.StartProcess(1, 1, sband, input); sband += icube->Bands(); m.EndProcess(); } } // Line processing routine -void NullBand (Buffer &out) { - for (int i=0; i pixels; - for (int i=0; i 0) { - results += PvlKeyword("Mean",st[i].Average()); - results += PvlKeyword("Median",median[i]); - results += PvlKeyword("Std",st[i].StandardDeviation()); - results += PvlKeyword("Minimum",st[i].Minimum()); - results += PvlKeyword("Maximum",st[i].Maximum()); + PvlGroup results("Results"); + for(unsigned int i = 0; i < st.size(); i++) { + results += PvlKeyword("Band", band[i]); + results += PvlKeyword("RowCol", element[i]); + results += PvlKeyword("ValidPixels", st[i].ValidPixels()); + if(st[i].ValidPixels() > 0) { + results += PvlKeyword("Mean", st[i].Average()); + results += PvlKeyword("Median", median[i]); + results += PvlKeyword("Std", st[i].StandardDeviation()); + results += PvlKeyword("Minimum", st[i].Minimum()); + results += PvlKeyword("Maximum", st[i].Maximum()); } else { - results += PvlKeyword("Mean",0.0); - results += PvlKeyword("Median",0.0); - results += PvlKeyword("Std",0.0); - results += PvlKeyword("Minimum",0.0); - results += PvlKeyword("Maximum",0.0); + results += PvlKeyword("Mean", 0.0); + results += PvlKeyword("Median", 0.0); + results += PvlKeyword("Std", 0.0); + results += PvlKeyword("Minimum", 0.0); + results += PvlKeyword("Maximum", 0.0); } } @@ -251,7 +251,7 @@ void tableOut(const string &StatFile) { // Open output file // TODO check status and throw error ofstream out; - out.open(StatFile.c_str(),std::ios::out); + out.open(StatFile.c_str(), std::ios::out); // Output a header out << std::setw(8) << "Band"; @@ -265,15 +265,15 @@ void tableOut(const string &StatFile) { out << endl; // Print out the table results - for (unsigned int i=0; i 0) { + if(st[i].ValidPixels() > 0) { out << std::setw(15) << st[i].Average(); out << std::setw(15) << median[i]; //Make sure the table's SD is 0 for RowCols with 1 or less valid pixels - if( st[i].ValidPixels() > 1 ) { + if(st[i].ValidPixels() > 1) { out << std::setw(15) << st[i].StandardDeviation(); } else { @@ -297,14 +297,14 @@ void tableOut(const string &StatFile) { //******************************************************** // Gather statistics from a PVL input file //******************************************************* -void PVLIn(const Isis::Filename &filename){ +void PVLIn(const Isis::Filename &filename) { Pvl pvlFileIn; pvlFileIn.Read(filename.Name()); PvlGroup results = pvlFileIn.FindGroup("Results"); PvlObject::PvlKeywordIterator itr = results.Begin(); - - while (itr != results.End()){ - StaticStats newStat; + + while(itr != results.End()) { + StaticStats newStat; band.push_back((*itr)[0]); itr++; element.push_back((*itr)[0]); @@ -322,12 +322,12 @@ void PVLIn(const Isis::Filename &filename){ newStat.setMaximum((*itr)[0]); itr++; st.push_back(newStat); - - // Determine the normalizer - if (normalizeUsingAverage) { - normalizer.push_back(newStat.Average()); - } - else { + + // Determine the normalizer + if(normalizeUsingAverage) { + normalizer.push_back(newStat.Average()); + } + else { normalizer.push_back(median[median.size()-1]); } } @@ -336,30 +336,30 @@ void PVLIn(const Isis::Filename &filename){ //******************************************************** // Gather statistics from a table input file //******************************************************* -void tableIn(const Isis::Filename & filename){ +void tableIn(const Isis::Filename &filename) { ifstream in; string expanded(filename.Expanded()); - in.open(expanded.c_str(),std::ios::in); - - - if (!in){ + in.open(expanded.c_str(), std::ios::in); + + + if(!in) { string message = "Error opening " + filename.Expanded(); throw iException::Message(Isis::iException::Io, message, - _FILEINFO_); + _FILEINFO_); } - + //skip the header (106 bytes) in.seekg(106); - + //read it StaticStats newStat; iString inString; - while (in >> inString){ + while(in >> inString) { band.push_back(inString); - in>> inString; + in >> inString; element.push_back(inString); - in>> inString; + in >> inString; newStat.setValidPixels(inString); in >> inString; newStat.setMean(inString); @@ -373,11 +373,11 @@ void tableIn(const Isis::Filename & filename){ newStat.setMaximum(inString); st.push_back(newStat); //Make sure Standard Deviation is not < 0 when reading in from a table - if( newStat.StandardDeviation() < 0 ) { - newStat.setStandardDeviation( 0 ); + if(newStat.StandardDeviation() < 0) { + newStat.setStandardDeviation(0); } // Determine the normalizer - if (normalizeUsingAverage) { + if(normalizeUsingAverage) { normalizer.push_back(newStat.Average()); } else { @@ -392,12 +392,12 @@ void tableIn(const Isis::Filename & filename){ // of the output image stays the same void subSame() { // Loop for each band - for (int iband=1; iband<=totalBands; iband++) { + for(int iband = 1; iband <= totalBands; iband++) { double sumAverage = 0.0; double sumValidPixels = 0; - for (int i=0; iStaticStats instance allows the user to set statistics for a cube - - This class exists to extend the functionality of the ISIS stats class, which - can construct a Stats object, but can only gather statistics from a cube - as opposed to an input pvl or table, both of which are features of the - StaticStats class. - - The use of this class is considered somewhat limited by the author. It cannot - be emphasized enough that the contents of a cub ARE NOT CHANGED via the - mutators of this class. Rather, the class allows the user to change PERCEIVED - VALUES for the class. - - This class can only be used to impose artificial statistics. For example, - the class was created so that a user might gather statistics using the normal - statistics class, write those statistics in a table, and then use those table - values to create a StaticStats instance so that statistics from the cube would - not have to be gathered over and over again. - - @author Drew Davidson, UA/PIRL - - $Revision: 1.1 $ -*/ -class StaticStats{ -public: +namespace PIRL { + /** A StaticStats instance allows the user to set statistics for a cube -/*============================================================================== - Constants -==============================================================================*/ -//! Class identification name with source code version and date. -static const char* const - ID; - -/*============================================================================== - Constructors -==============================================================================*/ - /** Constructs a default StaticStats. - - The staticStats has no statistics, they should be set via the mutator - methods below - */ - StaticStats(){}; - - /** Constructs a StaticStats with given statistics. - - The staticStats is given an initial set of statistics. - - @param initialMean - The initial mean DN for pixels in the cub - - @param initialStandardDeviation - The initial DN standard deviation for pixels in the cub - - @param initialValidPixels - The initial number of valid pixels in the cub - - @param initialMinimum - The initial minimum DN value in the cub - - @param initialMaximum - The initial maximum DN value in the cub - */ - StaticStats(double initialMean, - double initialStandardDeviation, - int initialValidPixels, - double initialMinimum, - double initialMaximum); - -/*============================================================================== - Accessors -==============================================================================*/ - /** Gets the perceived mean pixel DN value. - - @return DN mean for the cub - */ - double Average(); - - /** Gets the perceived standard deviation for all pixel DN values. + This class exists to extend the functionality of the ISIS stats class, which + can construct a Stats object, but can only gather statistics from a cube + as opposed to an input pvl or table, both of which are features of the + StaticStats class. - @return DN standard deviaton for the cub - */ - double StandardDeviation(); + The use of this class is considered somewhat limited by the author. It cannot + be emphasized enough that the contents of a cub ARE NOT CHANGED via the + mutators of this class. Rather, the class allows the user to change PERCEIVED + VALUES for the class. - /** Gets the perceived number of valid pixels. + This class can only be used to impose artificial statistics. For example, + the class was created so that a user might gather statistics using the normal + statistics class, write those statistics in a table, and then use those table + values to create a StaticStats instance so that statistics from the cube would + not have to be gathered over and over again. - @return Number of valid pixels in the cub + @author Drew Davidson, UA/PIRL + + $Revision: 1.1 $ */ - int ValidPixels(); + class StaticStats { + public: - /** Gets the perceived minimum DN value. + /*============================================================================== + Constants + ==============================================================================*/ +//! Class identification name with source code version and date. + static const char *const + ID; - @return Lowest pixel DN in the cub - */ - double Minimum(); + /*============================================================================== + Constructors + ==============================================================================*/ + /** Constructs a default StaticStats. - /** Gets the perceived maximum DN value. + The staticStats has no statistics, they should be set via the mutator + methods below + */ + StaticStats() {}; - @return Highest pixel DN in the cub - */ - double Maximum(); + /** Constructs a StaticStats with given statistics. -/*============================================================================== - Mutators -==============================================================================*/ - /** Sets the perceived mean DN value. + The staticStats is given an initial set of statistics. - @param newMean New mean DN value - */ - void setMean(double newMean); - - /** Sets the perceived standard deviation of DN values in the cub. + @param initialMean + The initial mean DN for pixels in the cub - @param newStandardDeviation New standard deviation for the cub - */ - void setStandardDeviation(double newStandardDeviation); + @param initialStandardDeviation + The initial DN standard deviation for pixels in the cub - /** Sets the perceived count of valid pixels. + @param initialValidPixels + The initial number of valid pixels in the cub - @param newValidPixels New count of valid pixels in the cub - */ - void setValidPixels(int newValidPixelCount); + @param initialMinimum + The initial minimum DN value in the cub - /** Sets the perceived maximum DN in the cub + @param initialMaximum + The initial maximum DN value in the cub + */ + StaticStats(double initialMean, + double initialStandardDeviation, + int initialValidPixels, + double initialMinimum, + double initialMaximum); - @param newMaximum New maximum DN value - */ - void setMaximum(double newMaximum); - - /** Sets the perceived minimum DN in the cub + /*============================================================================== + Accessors + ==============================================================================*/ + /** Gets the perceived mean pixel DN value. - @param newMinimum New minimum DN value - */ - void setMinimum(double newMinimum); - -private: - //! Perceived mean DN - double myMean; + @return DN mean for the cub + */ + double Average(); + + /** Gets the perceived standard deviation for all pixel DN values. + + @return DN standard deviaton for the cub + */ + double StandardDeviation(); + + /** Gets the perceived number of valid pixels. + + @return Number of valid pixels in the cub + */ + int ValidPixels(); + + /** Gets the perceived minimum DN value. + + @return Lowest pixel DN in the cub + */ + double Minimum(); + + /** Gets the perceived maximum DN value. + + @return Highest pixel DN in the cub + */ + double Maximum(); + + /*============================================================================== + Mutators + ==============================================================================*/ + /** Sets the perceived mean DN value. + + @param newMean New mean DN value + */ + void setMean(double newMean); + + /** Sets the perceived standard deviation of DN values in the cub. + + @param newStandardDeviation New standard deviation for the cub + */ + void setStandardDeviation(double newStandardDeviation); + + /** Sets the perceived count of valid pixels. + + @param newValidPixels New count of valid pixels in the cub + */ + void setValidPixels(int newValidPixelCount); + + /** Sets the perceived maximum DN in the cub + + @param newMaximum New maximum DN value + */ + void setMaximum(double newMaximum); + + /** Sets the perceived minimum DN in the cub + + @param newMinimum New minimum DN value + */ + void setMinimum(double newMinimum); + + private: + //! Perceived mean DN + double myMean; - //! Perceived DN standard deviation - double myStandardDeviation; + //! Perceived DN standard deviation + double myStandardDeviation; - //! Perceived minimum DN - double myMinimum; + //! Perceived minimum DN + double myMinimum; - //! Perceived maximum DN - double myMaximum; + //! Perceived maximum DN + double myMaximum; - //! Perceived valid pixel count - int myValidPixels; -}; + //! Perceived valid pixel count + int myValidPixels; + }; }/* End namespace PIRL */ #endif diff --git a/isis/src/base/apps/ddd2isis/ddd2isis.cpp b/isis/src/base/apps/ddd2isis/ddd2isis.cpp index b961b8dc29..faa7e5a3f5 100644 --- a/isis/src/base/apps/ddd2isis/ddd2isis.cpp +++ b/isis/src/base/apps/ddd2isis/ddd2isis.cpp @@ -4,11 +4,11 @@ #include "SpecialPixel.h" #include "Filename.h" -using namespace std; +using namespace std; using namespace Isis; -void IsisMain () { - UserInterface &ui = Application::GetUserInterface (); +void IsisMain() { + UserInterface &ui = Application::GetUserInterface(); ProcessImport p; iString from = ui.GetFilename("FROM"); EndianSwapper swp("MSB"); @@ -22,23 +22,23 @@ void IsisMain () { ifstream fin; fin.open(from.c_str(), ios::in | ios::binary); - if (!fin.is_open()) { + if(!fin.is_open()) { string msg = "Cannot open input file [" + from + "]"; - throw Isis::iException::Message(Isis::iException::Io,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Io, msg, _FILEINFO_); } -/** - * 0-rel byte offset value - * 0 32-bit integer magic number - * 4 32-bit integer number of image lines - * 8 32-bit integer number of bytes per image line - * 12 32-bit integer number of bits per image elements - * 16 32-bit integer currently unused - * 20 32-bit integer currently unused - * 24 ASCII label up to 1000 characters long - * The label is NUL-terminated - * - */ + /** + * 0-rel byte offset value + * 0 32-bit integer magic number + * 4 32-bit integer number of image lines + * 8 32-bit integer number of bytes per image line + * 12 32-bit integer number of bits per image elements + * 16 32-bit integer currently unused + * 20 32-bit integer currently unused + * 24 ASCII label up to 1000 characters long + * The label is NUL-terminated + * + */ // Verify the magic number fin.seekg(0); @@ -47,7 +47,7 @@ void IsisMain () { if(readBytes.readLong != 0x67B) { string msg = "Input file [" + from + "] does not appear to be in ddd format"; - throw Isis::iException::Message(Isis::iException::Io,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Io, msg, _FILEINFO_); } fin.read(readBytes.readChars, 4); @@ -63,12 +63,12 @@ void IsisMain () { if(fin.fail() || fin.eof()) { string msg = "An error ocurred when reading the input file [" + from + "]"; - throw Isis::iException::Message(Isis::iException::Io,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Io, msg, _FILEINFO_); } fin.close(); - switch (readBytes.readLong) { + switch(readBytes.readLong) { case 8: p.SetPixelType(Isis::UnsignedByte); break; @@ -85,14 +85,14 @@ void IsisMain () { nsamples /= (readBytes.readLong / 8); - p.SetDimensions(nsamples,nlines,nbands); + p.SetDimensions(nsamples, nlines, nbands); p.SetFileHeaderBytes(1024); p.SetByteOrder(Isis::Msb); - p.SetInputFile (ui.GetFilename("FROM")); + p.SetInputFile(ui.GetFilename("FROM")); p.SetOutputCube("TO"); - p.StartProcess (); - p.EndProcess (); + p.StartProcess(); + p.EndProcess(); return; } diff --git a/isis/src/base/apps/decorstretch/decorstretch.cpp b/isis/src/base/apps/decorstretch/decorstretch.cpp index 36ab6524ed..3eca8f9a10 100644 --- a/isis/src/base/apps/decorstretch/decorstretch.cpp +++ b/isis/src/base/apps/decorstretch/decorstretch.cpp @@ -10,16 +10,15 @@ using namespace std; using namespace Isis; void GetData(Buffer &in); -void Transform (Buffer &in, Buffer &out); -void NormalizeAndInvert (Buffer &in, Buffer &out); +void Transform(Buffer &in, Buffer &out); +void NormalizeAndInvert(Buffer &in, Buffer &out); PrincipalComponentAnalysis pca(0); vector stretches; string tmpFilename = "Temporary_DecorrelationStretch_Transform.cub"; -void IsisMain() -{ +void IsisMain() { ProcessByBrick p; Cube *icube = p.SetInputCube("FROM"); int numDimensions = icube->Bands(); @@ -48,8 +47,8 @@ void IsisMain() Isis::CubeAttributeInput cai; Cube *icube2 = p.SetInputCube(tmpFilename, cai); - for (int i=0; iHistogram(i+1)) )); + for(int i = 0; i < numDimensions; i++) { + stretches.push_back(new GaussianStretch(*(icube2->Histogram(i + 1)))); } p.SetOutputCube("TO"); @@ -57,7 +56,7 @@ void IsisMain() p.Progress()->SetText("Stretching Cube"); p.StartProcess(NormalizeAndInvert); - for (int i=0; i pre(1, in.BandDimension()); - for (int k=0;k post = pca.Transform(pre); - for (int k=0; k pre(1, in.BandDimension()); - for (int k=0;kAverage())/bandStats[k]->StandardDeviation(); @@ -104,8 +103,8 @@ void NormalizeAndInvert (Buffer &in, Buffer &out){ TNT::Array2D post = pca.Inverse(pre); - for (int k=0; kHasObject("Polygon")){ + if(c.Label()->HasObject("Polygon")) { c.Label()->DeleteObject("Polygon"); } @@ -108,13 +108,13 @@ void IsisMain() { h.AddEntry(); c.Write(h); c.Close(); - PvlGroup gp( "DeltackResults" ); - gp += PvlKeyword("Status","Camera pointing updated"); - Application::Log( gp ); + PvlGroup gp("DeltackResults"); + gp += PvlKeyword("Status", "Camera pointing updated"); + Application::Log(gp); } - catch (iException &e) { + catch(iException &e) { string msg = "Unable to update camera pointing for [" + filename + "]"; - throw iException::Message(Isis::iException::Camera,msg,_FILEINFO_); + throw iException::Message(Isis::iException::Camera, msg, _FILEINFO_); } } @@ -123,12 +123,12 @@ void IsisMain() { double GetRadius(std::string filename, double lat, double lon) { Pvl lab(filename); Sensor sensor(lab); - sensor.SetUniversalGround(lat,lon); + sensor.SetUniversalGround(lat, lon); double radius = sensor.LocalRadius(); - if (IsSpecial(radius)) { + if(IsSpecial(radius)) { string msg = "Could not determine radius from DEM at lat/lon ["; msg += iString(lat) + "," + iString(lon) + "]"; - throw iException::Message(Isis::iException::Camera,msg,_FILEINFO_); + throw iException::Message(Isis::iException::Camera, msg, _FILEINFO_); } return radius; } diff --git a/isis/src/base/apps/deriv/deriv.cpp b/isis/src/base/apps/deriv/deriv.cpp index 4600e6319b..8156cd54e1 100644 --- a/isis/src/base/apps/deriv/deriv.cpp +++ b/isis/src/base/apps/deriv/deriv.cpp @@ -2,41 +2,41 @@ #include "ProcessByBoxcar.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void Deriv (Buffer &in, double &v); +void Deriv(Buffer &in, double &v); void IsisMain() { - + ProcessByBoxcar p; UserInterface &ui = Application::GetUserInterface(); // Open the input cube - p.SetInputCube ("FROM"); + p.SetInputCube("FROM"); // Allocate the output cube - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); // Which deriv (horizontal or vetical)? - string derivDir = ui.GetString ("DIRECTION"); + string derivDir = ui.GetString("DIRECTION"); // Set boxcar size depending on the derivative direction - if (derivDir == "HORZ") { - p.SetBoxcarSize (2,1); + if(derivDir == "HORZ") { + p.SetBoxcarSize(2, 1); } - else if (derivDir == "VERT") { - p.SetBoxcarSize (1,2); + else if(derivDir == "VERT") { + p.SetBoxcarSize(1, 2); } - p.StartProcess (Deriv); - p.EndProcess (); + p.StartProcess(Deriv); + p.EndProcess(); } // Derivative process -void Deriv (Buffer &in,double &v) { - if (IsSpecial(in[0]) || IsSpecial(in[1])) { +void Deriv(Buffer &in, double &v) { + if(IsSpecial(in[0]) || IsSpecial(in[1])) { v = Isis::Null; return; } diff --git a/isis/src/base/apps/desmear/desmear.cpp b/isis/src/base/apps/desmear/desmear.cpp index da237d45a7..e5a197fd48 100644 --- a/isis/src/base/apps/desmear/desmear.cpp +++ b/isis/src/base/apps/desmear/desmear.cpp @@ -2,10 +2,10 @@ #include "ProcessByLine.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void desmear (Buffer &in, Buffer &out); +void desmear(Buffer &in, Buffer &out); double smearScale; //Declare global variable void IsisMain() { @@ -15,23 +15,23 @@ void IsisMain() { // Setup the input and output cubes Cube *icube = p.SetInputCube("FROM"); - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); // Get exposure duration and tranfer time // Override the lable values if the user entered a value - double expTime,xferTime; + double expTime, xferTime; UserInterface &ui = Application::GetUserInterface(); - if (ui.WasEntered ("DURATION")) { - expTime = ui.GetDouble ("DURATION"); - } + if(ui.WasEntered("DURATION")) { + expTime = ui.GetDouble("DURATION"); + } else { PvlGroup grp = icube->GetGroup("ISIS_INSTRUMENT"); expTime = grp["EXPOSURE_DURATION"]; } - if (ui.WasEntered ("TRANSFER")) { - xferTime = ui.GetDouble ("TRANSFER"); - } + if(ui.WasEntered("TRANSFER")) { + xferTime = ui.GetDouble("TRANSFER"); + } else { PvlGroup grp = icube->GetGroup("ISIS_INSTRUMENT"); xferTime = grp["TRANSFER_TIME"]; @@ -46,30 +46,30 @@ void IsisMain() { } // Line processing routine -void desmear (Buffer &in, Buffer &out) { +void desmear(Buffer &in, Buffer &out) { //make an array that is size of number of samples and fill with zeros. static vector smear; - if (in.Line() == 1) { + if(in.Line() == 1) { smear.resize(in.size()); - for (int i=0; i &input, vector &output); +void difference(vector &input, vector &output); void IsisMain() { ProcessByLine p; Cube *icube = p.SetInputCube("FROM"); UserInterface &ui = Application::GetUserInterface(); int highLines, highSamples, lowLines, lowSamples; - + // Get the boxcar sizes to be used by the low and highpass filters // All numbers have to be odd. If nothing is entered into the UI, // NS and/or NL are used. if(ui.GetString("MODE") == "VERTICAL") { if(ui.WasEntered("VHNS")) { - highSamples = ui.GetInteger("VHNS"); + highSamples = ui.GetInteger("VHNS"); } else { highSamples = icube->Samples(); if(highSamples % 2 == 0) highSamples -= 1; } - + if(ui.WasEntered("VLNL")) { lowLines = ui.GetInteger("VLNL"); } @@ -35,21 +35,21 @@ void IsisMain() { } lowSamples = ui.GetInteger("VLNS"); - highLines = ui.GetInteger("VHNL"); + highLines = ui.GetInteger("VHNL"); } else { - if(ui.WasEntered("HHNL")) { - highLines = ui.GetInteger("HHNL"); + if(ui.WasEntered("HHNL")) { + highLines = ui.GetInteger("HHNL"); } - else { - highLines = icube->Lines(); + else { + highLines = icube->Lines(); if(highLines % 2 == 0) highLines -= 1; } - - if(ui.WasEntered("HLNS")) { - lowSamples = ui.GetInteger("HLNS"); + + if(ui.WasEntered("HLNS")) { + lowSamples = ui.GetInteger("HLNS"); } - else { + else { lowSamples = icube->Samples(); if(lowSamples % 2 == 0) lowSamples -= 1; } @@ -66,7 +66,7 @@ void IsisMain() { lowParams += " to= dstripe.temporary.cub "; lowParams += " samples= " + iString(lowSamples); lowParams += " lines= " + iString(lowLines); - + Isis::iApp->Exec("lowpass", lowParams); // Make a copy of the lowpass filter results if the user wants it @@ -79,7 +79,7 @@ void IsisMain() { Isis::iApp->Exec("lowpass", lowParams); } - // Run highpass filter after lowpass is done, i.e. highpass(lowpass(input)) + // Run highpass filter after lowpass is done, i.e. highpass(lowpass(input)) string highParams = ""; highParams += "from= dstripe.temporary.cub "; highParams += " to= " + ui.GetFilename("NOISE") + " "; @@ -102,9 +102,9 @@ void IsisMain() { // Subtracts noise from the input buffer, resulting in a cleaner output image void difference(vector &input, vector &output) { - Buffer& from = *input[0]; - Buffer& noise = *input[1]; - Buffer& to = *output[0]; + Buffer &from = *input[0]; + Buffer &noise = *input[1]; + Buffer &to = *output[0]; for(int i = 0; i < from.size(); i++) { if(IsSpecial(from[i]) || IsSpecial(noise[i])) { diff --git a/isis/src/base/apps/editlab/editlab.cpp b/isis/src/base/apps/editlab/editlab.cpp index e3ebc9163e..91a4118b28 100644 --- a/isis/src/base/apps/editlab/editlab.cpp +++ b/isis/src/base/apps/editlab/editlab.cpp @@ -10,8 +10,8 @@ using namespace Isis; using namespace std; -void IsisMain(){ - +void IsisMain() { + // Open the input cube UserInterface &ui = Application::GetUserInterface(); Cube cube; @@ -21,14 +21,14 @@ void IsisMain(){ Pvl *label = cube.Label(); // Get user entered option & create IsisCube Object - string option = ui.GetString("OPTION"); + string option = ui.GetString("OPTION"); PvlObject &o = label->FindObject("IsisCube"); // Add Template File - if(option=="ADDTEMP") { + if(option == "ADDTEMP") { string tempfile = ui.GetFilename("TEMPFILE"); Pvl tempobj(tempfile); - for(int i=0; iExec("edrget", parameters); + if(ui.IsInteractive()) { + string parameters = "URL=" + guiURL; + if(ui.WasEntered("TOPATH")) { + parameters += " TOPATH=" + guiPath; } - else { - - FtpGet getter; - QObject::connect(&getter, SIGNAL(done()), QCoreApplication::instance(), SLOT(quit())); - //a false getFile return means no error and we sould execute the get. - if(!getter.getFile(qurl,guiPath)) QCoreApplication::instance()->exec(); - //if error occurred throw could not acquire - if (getter.error()) { - QString localFileName; - if (ui.WasEntered("TOPATH")){ - localFileName += guiPath.c_str(); - localFileName += "/"; - } - localFileName += QFileInfo(qurl.path()).fileName(); - string localFileNameStr(localFileName.toStdString()); - remove(localFileNameStr.c_str()); - iString msg = "Could not acquire [" + guiURL + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); - } - } + iApp->Exec("edrget", parameters); } - //test is scheme is http and set port - else if (qurl.scheme().toLower() == "http") { - qurl.setPort(80); + else { - if (ui.IsInteractive()) { - string parameters = "URL=" + guiURL; - if (ui.WasEntered("TOPATH")) { - parameters += " TOPATH=" + guiPath; + FtpGet getter; + QObject::connect(&getter, SIGNAL(done()), QCoreApplication::instance(), SLOT(quit())); + //a false getFile return means no error and we sould execute the get. + if(!getter.getFile(qurl, guiPath)) QCoreApplication::instance()->exec(); + //if error occurred throw could not acquire + if(getter.error()) { + QString localFileName; + if(ui.WasEntered("TOPATH")) { + localFileName += guiPath.c_str(); + localFileName += "/"; } - iApp->Exec("edrget", parameters); + localFileName += QFileInfo(qurl.path()).fileName(); + string localFileNameStr(localFileName.toStdString()); + remove(localFileNameStr.c_str()); + iString msg = "Could not acquire [" + guiURL + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } - else { - HttpGet getter; - QObject::connect(&getter, SIGNAL(done()), QCoreApplication::instance(), SLOT(quit())); - //a false getFile return means no error and we sould execute the get. - if (!getter.getFile(qurl,guiPath)) QCoreApplication::instance()->exec(); - //if error occurred then throw could not acquire - if (getter.error()) { - QString localFileName; - if (ui.WasEntered("TOPATH")){ - localFileName += guiPath.c_str(); - localFileName += "/"; - } - string localFileNameStr(localFileName.toStdString()); - remove(localFileNameStr.c_str()); - iString msg = "Could not acquire [" + guiURL + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); - } - } } - //if scheme is not ftp or http throw error + } + //test is scheme is http and set port + else if(qurl.scheme().toLower() == "http") { + qurl.setPort(80); + + if(ui.IsInteractive()) { + string parameters = "URL=" + guiURL; + if(ui.WasEntered("TOPATH")) { + parameters += " TOPATH=" + guiPath; + } + iApp->Exec("edrget", parameters); + } else { - iString msg = "Scheme [" + qurl.scheme().toStdString() + "] not found, must be 'ftp' or 'http'"; - throw iException::Message(iException::User,msg,_FILEINFO_); + HttpGet getter; + QObject::connect(&getter, SIGNAL(done()), QCoreApplication::instance(), SLOT(quit())); + //a false getFile return means no error and we sould execute the get. + if(!getter.getFile(qurl, guiPath)) QCoreApplication::instance()->exec(); + //if error occurred then throw could not acquire + if(getter.error()) { + QString localFileName; + if(ui.WasEntered("TOPATH")) { + localFileName += guiPath.c_str(); + localFileName += "/"; + } + string localFileNameStr(localFileName.toStdString()); + remove(localFileNameStr.c_str()); + iString msg = "Could not acquire [" + guiURL + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); + } } + } + //if scheme is not ftp or http throw error + else { + iString msg = "Scheme [" + qurl.scheme().toStdString() + "] not found, must be 'ftp' or 'http'"; + throw iException::Message(iException::User, msg, _FILEINFO_); + } } diff --git a/isis/src/base/apps/edrget/ftpget.cpp b/isis/src/base/apps/edrget/ftpget.cpp index 8e0e99ff41..f8f3c024c6 100644 --- a/isis/src/base/apps/edrget/ftpget.cpp +++ b/isis/src/base/apps/edrget/ftpget.cpp @@ -13,99 +13,99 @@ using namespace std; namespace Isis { FtpGet::FtpGet(QObject *parent) : QObject(parent) { - //conncet the Qftp done signal to the ftpDone function - connect(&p_ftp, SIGNAL(done(bool)), this, SLOT(ftpDone(bool))); - //connect the Qftp progress signal to the ftpProgress function(ISIS progress) - connect(&p_ftp, SIGNAL(dataTransferProgress(qint64,qint64)), - this, SLOT(ftpProgress(qint64,qint64))); + //conncet the Qftp done signal to the ftpDone function + connect(&p_ftp, SIGNAL(done(bool)), this, SLOT(ftpDone(bool))); + //connect the Qftp progress signal to the ftpProgress function(ISIS progress) + connect(&p_ftp, SIGNAL(dataTransferProgress(qint64, qint64)), + this, SLOT(ftpProgress(qint64, qint64))); } //************************************** // getFile function will check URL, if URL is good function will connect, // login, and get the file. This function returns P_error. bool FtpGet::getFile(const QUrl &url, string topath) { - //next four if check the URL and return true is there is error. - if (!url.isValid()) { - string msg ="invalid URL"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } - if (url.scheme().toLower() != "ftp") { - string msg ="URL must start with 'ftp:'"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } - if (url.path().isEmpty()) { - string msg ="URL has no path"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } - - QString localFileName; - if (topath.size() != 0){ - localFileName += topath.c_str(); - localFileName += "/"; - } - localFileName += QFileInfo(url.path()).fileName(); - if (localFileName.isEmpty()) { - string msg ="URL has no filename"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } - // check local file. - p_file.setFileName(localFileName); - if (!p_file.open(QIODevice::WriteOnly)) { - string msg ="Cannot open output file"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } + //next four if check the URL and return true is there is error. + if(!url.isValid()) { + string msg = "invalid URL"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; + return p_error; + } + if(url.scheme().toLower() != "ftp") { + string msg = "URL must start with 'ftp:'"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; + return p_error; + } + if(url.path().isEmpty()) { + string msg = "URL has no path"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; + return p_error; + } - p_ftp.connectToHost(url.host(), url.port()); - p_ftp.login(); - p_ftp.get(url.path(), &p_file); - p_lastDone = -1; - p_error = false; + QString localFileName; + if(topath.size() != 0) { + localFileName += topath.c_str(); + localFileName += "/"; + } + localFileName += QFileInfo(url.path()).fileName(); + if(localFileName.isEmpty()) { + string msg = "URL has no filename"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; + return p_error; + } + // check local file. + p_file.setFileName(localFileName); + if(!p_file.open(QIODevice::WriteOnly)) { + string msg = "Cannot open output file"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; return p_error; + } + + p_ftp.connectToHost(url.host(), url.port()); + p_ftp.login(); + p_ftp.get(url.path(), &p_file); + p_lastDone = -1; + p_error = false; + return p_error; } void FtpGet::ftpDone(bool error) { - if (error) { - p_error = true; - iString msg =p_ftp.errorString().toStdString(); - msg.Remove("\n"); - iException::Message(iException::User,msg,_FILEINFO_); - } - else{ - p_error = false; - } - if (!p_error) { - p_file.close(); - // this was added because final size may not match progress size so - // you do not get 100% processed - if(!Application::GetUserInterface().IsInteractive()){ - cout<<"100% Processed" << endl; - } + if(error) { + p_error = true; + iString msg = p_ftp.errorString().toStdString(); + msg.Remove("\n"); + iException::Message(iException::User, msg, _FILEINFO_); + } + else { + p_error = false; + } + if(!p_error) { + p_file.close(); + // this was added because final size may not match progress size so + // you do not get 100% processed + if(!Application::GetUserInterface().IsInteractive()) { + cout << "100% Processed" << endl; } - emit done(); - return; + } + emit done(); + return; } // ftpProgress uses the ISIS progress class to track progress void FtpGet::ftpProgress(qint64 done, qint64 total) { - if (total == 0) return; - if (total == -1) return; - if (p_error) return; - if (p_lastDone < 0) { - p_progress.SetText(string("Downloading File ") + p_file.fileName().toStdString() ); + if(total == 0) return; + if(total == -1) return; + if(p_error) return; + if(p_lastDone < 0) { + p_progress.SetText(string("Downloading File ") + p_file.fileName().toStdString()); p_progress.SetMaximumSteps(total); p_progress.CheckStatus(); p_lastDone = 1; } - while (p_lastDone <= done) { + while(p_lastDone <= done) { p_progress.CheckStatus(); p_lastDone++; } diff --git a/isis/src/base/apps/edrget/ftpget.h b/isis/src/base/apps/edrget/ftpget.h index fb48951205..545ff5c1c2 100644 --- a/isis/src/base/apps/edrget/ftpget.h +++ b/isis/src/base/apps/edrget/ftpget.h @@ -6,29 +6,30 @@ #include "Progress.h" class QUrl; -namespace Isis{ +namespace Isis { - class FtpGet : public QObject - { + class FtpGet : public QObject { Q_OBJECT - - public: + + public: FtpGet(QObject *parent = 0); - + bool getFile(const QUrl &url, std::string topath); - bool error() const{return p_error;}; + bool error() const { + return p_error; + }; + - - - signals: + + signals: void done(); - - private slots: + + private slots: void ftpDone(bool error); void ftpProgress(qint64 done, qint64 total); - - private: + + private: QFtp p_ftp; QFile p_file; bool p_error; diff --git a/isis/src/base/apps/edrget/httpget.cpp b/isis/src/base/apps/edrget/httpget.cpp index b960b9d851..40db7a82de 100644 --- a/isis/src/base/apps/edrget/httpget.cpp +++ b/isis/src/base/apps/edrget/httpget.cpp @@ -13,106 +13,105 @@ using namespace std; namespace Isis { HttpGet::HttpGet(QObject *parent) : QObject(parent) { - //connect the QHttp done signal to the httpDone function - connect(&p_http, SIGNAL(done(bool)), this, SLOT(httpDone(bool))); - //connect the QHttp progress signal to the httpProgress function(Isis progress) - connect(&p_http, SIGNAL(dataReadProgress(int,int)), - this, SLOT(httpProgress(int,int))); + //connect the QHttp done signal to the httpDone function + connect(&p_http, SIGNAL(done(bool)), this, SLOT(httpDone(bool))); + //connect the QHttp progress signal to the httpProgress function(Isis progress) + connect(&p_http, SIGNAL(dataReadProgress(int, int)), + this, SLOT(httpProgress(int, int))); } //********************************************** // getFile function will check URL, if URL is good the function will connect, - // login, and get the file. This function returns p_error + // login, and get the file. This function returns p_error bool HttpGet::getFile(const QUrl &url, string topath) { - // The next four ifs will check the URL and return error is bad - if (!url.isValid()) { - string msg ="invalid URL"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } - if (url.scheme().toLower() != "http") { - string msg ="URL must start with 'http:'"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } - if (url.path().isEmpty()) { - string msg ="URL has no path"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } - - QString localFileName; - if (topath.size() != 0){ - localFileName += topath.c_str(); - localFileName += "/"; - } - localFileName += QFileInfo(url.path()).fileName(); - if (localFileName.isEmpty()) { - string msg ="URL has no filename"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } - // check the local file. - p_file.setFileName(localFileName); - if (!p_file.open(QIODevice::WriteOnly)) { - string msg ="Cannot open output file"; - iException::Message(iException::User,msg,_FILEINFO_); - p_error = true; - return p_error; - } - p_http.setHost(url.host(), url.port()); - p_http.get(url.path(), &p_file); + // The next four ifs will check the URL and return error is bad + if(!url.isValid()) { + string msg = "invalid URL"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; + return p_error; + } + if(url.scheme().toLower() != "http") { + string msg = "URL must start with 'http:'"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; + return p_error; + } + if(url.path().isEmpty()) { + string msg = "URL has no path"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; + return p_error; + } - p_lastDone = -1; - p_error = false; + QString localFileName; + if(topath.size() != 0) { + localFileName += topath.c_str(); + localFileName += "/"; + } + localFileName += QFileInfo(url.path()).fileName(); + if(localFileName.isEmpty()) { + string msg = "URL has no filename"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; return p_error; + } + // check the local file. + p_file.setFileName(localFileName); + if(!p_file.open(QIODevice::WriteOnly)) { + string msg = "Cannot open output file"; + iException::Message(iException::User, msg, _FILEINFO_); + p_error = true; + return p_error; + } + p_http.setHost(url.host(), url.port()); + p_http.get(url.path(), &p_file); + + p_lastDone = -1; + p_error = false; + return p_error; } - void HttpGet::httpDone(bool error) - { - map errLUT; - errLUT [204] = "No content"; - errLUT [301] = "Moved Permanently"; - errLUT [302] = "Moved Temporarily"; - errLUT [400] = "Bad Request"; - errLUT [401] = "Unauthorized"; - errLUT [403] = "Forbidden"; - errLUT [404] = "File Not Found"; - errLUT [500] = "Internal server Error"; - errLUT [502] = "Bad GateWay"; - errLUT [503] = "service Unavailable"; + void HttpGet::httpDone(bool error) { + map errLUT; + errLUT [204] = "No content"; + errLUT [301] = "Moved Permanently"; + errLUT [302] = "Moved Temporarily"; + errLUT [400] = "Bad Request"; + errLUT [401] = "Unauthorized"; + errLUT [403] = "Forbidden"; + errLUT [404] = "File Not Found"; + errLUT [500] = "Internal server Error"; + errLUT [502] = "Bad GateWay"; + errLUT [503] = "service Unavailable"; - if (error) { - p_error = true; - string msg =p_http.errorString().toStdString(); - iException::Message(iException::User,msg,_FILEINFO_); - } - else if (p_http.lastResponse().statusCode() != 200 && p_http.lastResponse().statusCode() != 0) { - p_error = true; - string msg ="error code: [" + errLUT[p_http.lastResponse().statusCode()] + "]"; - iException::Message(iException::User,msg,_FILEINFO_); - } - else{ - p_error = false; - } - if (!p_error) p_file.close(); - emit done(); - return; + if(error) { + p_error = true; + string msg = p_http.errorString().toStdString(); + iException::Message(iException::User, msg, _FILEINFO_); + } + else if(p_http.lastResponse().statusCode() != 200 && p_http.lastResponse().statusCode() != 0) { + p_error = true; + string msg = "error code: [" + errLUT[p_http.lastResponse().statusCode()] + "]"; + iException::Message(iException::User, msg, _FILEINFO_); + } + else { + p_error = false; + } + if(!p_error) p_file.close(); + emit done(); + return; } // This function setsup and useses Isis progress classs to track progress. void HttpGet::httpProgress(int done, int total) { - if (total == 0) return; - if (p_error) return; - if (p_lastDone < 0) { - p_progress.SetText(string("Downloading File ") + p_file.fileName().toStdString() ); + if(total == 0) return; + if(p_error) return; + if(p_lastDone < 0) { + p_progress.SetText(string("Downloading File ") + p_file.fileName().toStdString()); p_progress.SetMaximumSteps(total); p_progress.CheckStatus(); p_lastDone = 1; } - while (p_lastDone <= done) { + while(p_lastDone <= done) { p_progress.CheckStatus(); p_lastDone++; } diff --git a/isis/src/base/apps/edrget/httpget.h b/isis/src/base/apps/edrget/httpget.h index 3f868d8b71..cbfc52f273 100644 --- a/isis/src/base/apps/edrget/httpget.h +++ b/isis/src/base/apps/edrget/httpget.h @@ -6,28 +6,29 @@ #include "Progress.h" class QUrl; -namespace Isis{ +namespace Isis { - class HttpGet : public QObject - { + class HttpGet : public QObject { Q_OBJECT - - public: + + public: HttpGet(QObject *parent = 0); - + bool getFile(const QUrl &url, std::string topath); - bool error() const{return p_error;}; - - - signals: + bool error() const { + return p_error; + }; + + + signals: void done(); - - private slots: + + private slots: void httpDone(bool error); void httpProgress(int done, int total); - - private: + + private: QHttp p_http; QFile p_file; bool p_error; diff --git a/isis/src/base/apps/enlarge/enlarge.cpp b/isis/src/base/apps/enlarge/enlarge.cpp index 419129bcac..ddc470526d 100644 --- a/isis/src/base/apps/enlarge/enlarge.cpp +++ b/isis/src/base/apps/enlarge/enlarge.cpp @@ -6,7 +6,7 @@ #include "AlphaCube.h" #include "SubArea.h" -using namespace std; +using namespace std; using namespace Isis; Cube cube; @@ -15,7 +15,7 @@ void IsisMain() { ProcessRubberSheet p; // Open the input cube - Cube *icube = p.SetInputCube ("FROM"); + Cube *icube = p.SetInputCube("FROM"); // Input number of samples, lines, and bands int ins = icube->Samples(); @@ -31,14 +31,14 @@ void IsisMain() { double lscale; UserInterface &ui = Application::GetUserInterface(); - if (ui.GetString("MODE") == "SCALE") { + if(ui.GetString("MODE") == "SCALE") { // Retrieve the provided scaling factors sscale = ui.GetDouble("SSCALE"); lscale = ui.GetDouble("LSCALE"); // Calculate the output size. If there is a fractional pixel, round up - ons = (int)ceil (ins * sscale); - onl = (int)ceil (inl * lscale); + ons = (int)ceil(ins * sscale); + onl = (int)ceil(inl * lscale); } else { // Retrieve the provided sample/line dimensions in the output @@ -52,59 +52,59 @@ void IsisMain() { // Ensure that the calculated number of output samples and lines is greater // than the input - if (ons < ins || onl < inl) { + if(ons < ins || onl < inl) { string msg = "Number of output samples/lines must be greater than or equal"; msg = msg + " to the input samples/lines."; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // Set up the transform object with the calculated scale and number of // output pixels - Transform *transform = new Enlarge(sscale, lscale, ons, onl); + Transform *transform = new Enlarge(sscale, lscale, ons, onl); string from = ui.GetFilename("FROM"); cube.Open(from); // Allocate the output file, the number of bands does not change in the output - Cube *ocube = p.SetOutputCube ("TO", ons, onl, inb); + Cube *ocube = p.SetOutputCube("TO", ons, onl, inb); // Set up the interpolator Interpolator *interp; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } else { string msg = "Unknown value for INTERP [" + ui.GetString("INTERP") + "]"; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } p.StartProcess(*transform, *interp); // Construct a label with the results PvlGroup results("Results"); - results += PvlKeyword ("InputLines", inl); - results += PvlKeyword ("InputSamples", ins); - results += PvlKeyword ("StartingLine", "1"); - results += PvlKeyword ("StartingSample", "1"); - results += PvlKeyword ("EndingLine", inl); - results += PvlKeyword ("EndingSample", ins); - results += PvlKeyword ("LineIncrement", 1./lscale); - results += PvlKeyword ("SampleIncrement", 1./sscale); - results += PvlKeyword ("OutputLines", onl); - results += PvlKeyword ("OutputSamples", ons); + results += PvlKeyword("InputLines", inl); + results += PvlKeyword("InputSamples", ins); + results += PvlKeyword("StartingLine", "1"); + results += PvlKeyword("StartingSample", "1"); + results += PvlKeyword("EndingLine", inl); + results += PvlKeyword("EndingSample", ins); + results += PvlKeyword("LineIncrement", 1. / lscale); + results += PvlKeyword("SampleIncrement", 1. / sscale); + results += PvlKeyword("OutputLines", onl); + results += PvlKeyword("OutputSamples", ons); // Update the Mapping, Instrument, and AlphaCube groups in the output // cube label SubArea s; - s.SetSubArea(cube.Lines(),cube.Samples(),1,1,cube.Lines(),cube.Samples(), - 1./lscale,1./sscale); - s.UpdateLabel(&cube,ocube,results); + s.SetSubArea(cube.Lines(), cube.Samples(), 1, 1, cube.Lines(), cube.Samples(), + 1. / lscale, 1. / sscale); + s.UpdateLabel(&cube, ocube, results); p.EndProcess(); diff --git a/isis/src/base/apps/enlarge/enlarge.h b/isis/src/base/apps/enlarge/enlarge.h index 04ca31c658..bb4dff8602 100644 --- a/isis/src/base/apps/enlarge/enlarge.h +++ b/isis/src/base/apps/enlarge/enlarge.h @@ -16,8 +16,8 @@ class Enlarge : public Isis::Transform { public: // constructor - Enlarge (const double sampleScale, const double lineScale, - const int outputSamples, const int outputLines){ + Enlarge(const double sampleScale, const double lineScale, + const int outputSamples, const int outputLines) { // Save off the sample and line magnification p_sampleScale = sampleScale; @@ -28,25 +28,25 @@ class Enlarge : public Isis::Transform { } // destructor - ~Enlarge () {}; + ~Enlarge() {}; // Implementations for parent's pure virtual members // Convert the requested output samp/line to an input samp/line - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { inSample = (outSample - 0.5) / p_sampleScale + 0.5; inLine = (outLine - 0.5) / p_lineScale + 0.5; return true; } // Return the output number of samples - int OutputSamples () const { + int OutputSamples() const { return p_outputSamples; } // Return the output number of lines - int OutputLines () const { - return p_outputLines; + int OutputLines() const { + return p_outputLines; } }; diff --git a/isis/src/base/apps/equalizer/equalizer.cpp b/isis/src/base/apps/equalizer/equalizer.cpp index fe3d9cbb20..6c1486b488 100644 --- a/isis/src/base/apps/equalizer/equalizer.cpp +++ b/isis/src/base/apps/equalizer/equalizer.cpp @@ -15,13 +15,13 @@ using namespace Isis; -Isis::Statistics GatherStatistics(Cube &icube, const int band, - double sampPercent, std::string maxCubeStr); +Isis::Statistics GatherStatistics(Cube &icube, const int band, + double sampPercent, std::string maxCubeStr); void ApplyViaObject(Buffer &in, Buffer &out); void ApplyViaFile(Buffer &in, Buffer &out); std::vector g_overlapList; -std::vector g_oNormList; +std::vector g_oNormList; std::vector normIndices; std::vector gains, offsets, avgs; int g_imageIndex, g_maxCube, g_maxBand; @@ -31,38 +31,38 @@ void IsisMain() { FileList imageList; UserInterface &ui = Application::GetUserInterface(); imageList.Read(ui.GetFilename("FROMLIST")); - if (imageList.size() < 1) { + if(imageList.size() < 1) { std::string msg = "The list file [" + ui.GetFilename("FROMLIST") + - "] does not contain any data"; - throw iException::Message(iException::User,msg,_FILEINFO_); + "] does not contain any data"; + throw iException::Message(iException::User, msg, _FILEINFO_); } - // Make sure the user enters a "OUTSTATS" file if the CALCULATE option + // Make sure the user enters a "OUTSTATS" file if the CALCULATE option // is selected std::string processOpt = ui.GetString("PROCESS"); - if (processOpt == "CALCULATE") { - if (!ui.WasEntered("OUTSTATS")) { + if(processOpt == "CALCULATE") { + if(!ui.WasEntered("OUTSTATS")) { std::string msg = "If the CALCULATE option is selected, you must enter"; msg += " an OUTSTATS file"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } } // Make sure number of bands and projection parameters match for all cubes - for (unsigned int i=0; i hold; - if (ui.WasEntered("HOLD")) { + if(ui.WasEntered("HOLD")) { FileList holdList; holdList.Read(ui.GetFilename("HOLD")); // Make sure each file in the holdlist matches a file in the fromlist - for (int i=0; i<(int)holdList.size(); i++) { + for(int i = 0; i < (int)holdList.size(); i++) { bool matched = false; - for (int j=0; j<(int)imageList.size(); j++) { - if (holdList[i] == imageList[j]) { + for(int j = 0; j < (int)imageList.size(); j++) { + if(holdList[i] == imageList[j]) { matched = true; hold.push_back(j); break; } } - if (!matched) { + if(!matched) { std::string msg = "The hold list file [" + holdList[i] + - "] does not match a file in the from list"; - throw iException::Message(iException::User,msg,_FILEINFO_); + "] does not match a file in the from list"; + throw iException::Message(iException::User, msg, _FILEINFO_); } } } // Read to list if one was entered FileList outList; - if (ui.WasEntered("TOLIST")) { + if(ui.WasEntered("TOLIST")) { outList.Read(ui.GetFilename("TOLIST")); // Make sure each file in the tolist matches a file in the fromlist - if (outList.size() != imageList.size()) { + if(outList.size() != imageList.size()) { std::string msg = "Each input file in the FROM LIST must have a "; msg += "corresponding output file in the TO LIST."; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // Make sure that all output files do not have the same names as their // corresponding input files - for (unsigned i = 0; i < outList.size(); i++) { - if (outList[i].compare(imageList[i]) == 0) { + for(unsigned i = 0; i < outList.size(); i++) { + if(outList[i].compare(imageList[i]) == 0) { std::string msg = "The to list file [" + outList[i] + - "] has the same name as its corresponding from list file."; - throw iException::Message(iException::User,msg,_FILEINFO_); + "] has the same name as its corresponding from list file."; + throw iException::Message(iException::User, msg, _FILEINFO_); } } } - + // Test to ensure sampling percent in bound - double sampPercent = ui.GetDouble("PERCENT"); - if (sampPercent <= 0.0 || sampPercent > 100.0) { + double sampPercent = ui.GetDouble("PERCENT"); + if(sampPercent <= 0.0 || sampPercent > 100.0) { string msg = "The sampling percent must be a decimal (0.0, 100.0]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } int mincnt = ui.GetInteger("MINCOUNT"); bool wtopt = ui.GetBoolean("WEIGHT"); - if (processOpt != "APPLY") { - // Loop through all the input cubes, calculating statistics for each cube to use later - iString maxCubeStr ((int)imageList.size()); - for (int band=1; band<=g_maxBand; band++) { + if(processOpt != "APPLY") { + // Loop through all the input cubes, calculating statistics for each cube to use later + iString maxCubeStr((int)imageList.size()); + for(int band = 1; band <= g_maxBand; band++) { std::vector statsList; - for (int img=0; img<(int)imageList.size(); img++) { - Process p; - const CubeAttributeInput att; - const std::string inp = imageList[img]; - Cube *icube = p.SetInputCube(inp, att); - - // Add a Statistics object to the list for every band of every input cube - g_imageIndex = img; - Statistics stats = GatherStatistics(*icube, band, sampPercent, maxCubeStr); - statsList.push_back(stats); - p.EndProcess(); + for(int img = 0; img < (int)imageList.size(); img++) { + Process p; + const CubeAttributeInput att; + const std::string inp = imageList[img]; + Cube *icube = p.SetInputCube(inp, att); + + // Add a Statistics object to the list for every band of every input cube + g_imageIndex = img; + Statistics stats = GatherStatistics(*icube, band, sampPercent, maxCubeStr); + statsList.push_back(stats); + p.EndProcess(); } - + // Create a separate OverlapNormalization object for every band - OverlapNormalization *oNorm = new OverlapNormalization (statsList); - for (int h=0; h<(int)hold.size(); h++) oNorm->AddHold(hold[h]); + OverlapNormalization *oNorm = new OverlapNormalization(statsList); + for(int h = 0; h < (int)hold.size(); h++) oNorm->AddHold(hold[h]); g_oNormList.push_back(oNorm); } // A list for keeping track of which input cubes are known to overlap another std::vector doesOverlapList; - for (unsigned int i=0; i= mincnt) { - g_oNormList[band-1]->AddOverlap(oStats.GetMStats(band).X(), i, - oStats.GetMStats(band).Y(), j, weight); - doesOverlapList[i] = true; - doesOverlapList[j] = true; - } - } - } + + for(unsigned int j = (i + 1); j < imageList.size(); j++) { + Cube cube2; + cube2.Open(imageList[j]); + iString cubeStr1((int)(i + 1)); + iString cubeStr2((int)(j + 1)); + string statMsg = "Gathering Overlap Statisitcs for Cube " + + cubeStr1 + " vs " + cubeStr2 + " of " + maxCubeStr; + + // Get overlap statistics for cubes + OverlapStatistics oStats(cube1, cube2, statMsg, sampPercent); + + // Only push the stats onto the oList vector if there is an overlap in at + // least one of the bands + if(oStats.HasOverlap()) { + oStats.SetMincount(mincnt); + g_overlapList.push_back(oStats); + for(int band = 1; band <= g_maxBand; band++) { + // Fill wt vector with 1's if the overlaps are not to be weighted, or + // fill the vector with the number of valid pixels in each overlap + int weight = 1; + if(wtopt) weight = oStats.GetMStats(band).ValidPixels(); + + // Make sure overlap has at least MINCOUNT pixels and add + if(oStats.GetMStats(band).ValidPixels() >= mincnt) { + g_oNormList[band-1]->AddOverlap(oStats.GetMStats(band).X(), i, + oStats.GetMStats(band).Y(), j, weight); + doesOverlapList[i] = true; + doesOverlapList[j] = true; + } + } + } } } - + // Print an error if one or more of the images does not overlap another { std::string badFiles = ""; - for (unsigned int img=0; imgSolve(sType); } } @@ -233,41 +233,41 @@ void IsisMain() { // Print gathered statistics to the gui and the print file int validCnt = 0; int invalidCnt = 0; - if (processOpt != "APPLY") { + if(processOpt != "APPLY") { PvlGroup results("Results"); // Compute the number valid and invalid overlaps - for (unsigned int o=0; oGain(img)); - iString base (g_oNormList[band-1]->Offset(img)); - iString avg (g_oNormList[band-1]->Average(img)); - iString bandNum (band); - std::string bandStr = "Band" + bandNum; - PvlKeyword bandStats(bandStr); - bandStats += mult; - bandStats += base; - bandStats += avg; - results += bandStats; + for(int band = 1; band <= g_maxBand; band++) { + iString mult(g_oNormList[band-1]->Gain(img)); + iString base(g_oNormList[band-1]->Offset(img)); + iString avg(g_oNormList[band-1]->Average(img)); + iString bandNum(band); + std::string bandStr = "Band" + bandNum; + PvlKeyword bandStats(bandStr); + bandStats += mult; + bandStats += base; + bandStats += avg; + results += bandStats; } } @@ -276,30 +276,30 @@ void IsisMain() { } // Setup the output text file if the user requested one - if (ui.WasEntered("OUTSTATS")) { + if(ui.WasEntered("OUTSTATS")) { PvlObject equ("EqualizationInformation"); PvlGroup gen("General"); - gen += PvlKeyword("TotalOverlaps", validCnt+invalidCnt); + gen += PvlKeyword("TotalOverlaps", validCnt + invalidCnt); gen += PvlKeyword("ValidOverlaps", validCnt); gen += PvlKeyword("InvalidOverlaps", invalidCnt); std::string weightStr = "false"; - if (wtopt) weightStr = "true"; + if(wtopt) weightStr = "true"; gen += PvlKeyword("Weighted", weightStr); gen += PvlKeyword("MinCount", mincnt); equ.AddGroup(gen); - for (unsigned int img=0; imgGain(img)); - iString base (g_oNormList[band-1]->Offset(img)); - iString avg (g_oNormList[band-1]->Average(img)); - iString bandNum (band); + for(int band = 1; band <= g_maxBand; band++) { + iString mult(g_oNormList[band-1]->Gain(img)); + iString base(g_oNormList[band-1]->Offset(img)); + iString avg(g_oNormList[band-1]->Average(img)); + iString bandNum(band); std::string bandStr = "Band" + bandNum; PvlKeyword bandStats(bandStr); bandStats += mult; @@ -313,60 +313,60 @@ void IsisMain() { // Write the equalization and overlap statistics to the file std::string out = Filename(ui.GetFilename("OUTSTATS")).Expanded(); std::ofstream os; - os.open(out.c_str(),std::ios::app); + os.open(out.c_str(), std::ios::app); Pvl p; p.SetTerminator(""); p.AddObject(equ); os << p << std::endl; - for (unsigned int i=0; i (unsigned)equalInfo.Groups()-1) { + if(imageList.size() > (unsigned)equalInfo.Groups() - 1) { std::string msg = "Each input file in the FROM LIST must have a "; msg += "corresponding input file in the INPUT STATISTICS."; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // Check that each file in the FROM LIST is present in the INPUT STATISTICS - for (unsigned i = 0; i < imageList.size(); i++) { + for(unsigned i = 0; i < imageList.size(); i++) { std::string fromFile = imageList[i]; bool foundFile = false; - for (int j = 1; j < equalInfo.Groups(); j++) { - PvlGroup &normalization = equalInfo.Group(j); - std::string normFile = normalization["Filename"][0]; - if (fromFile == normFile) { - - // Store the index in INPUT STATISTICS file corresponding to the - // current FROM LIST file - normIndices.push_back(j); - foundFile = true; - } + for(int j = 1; j < equalInfo.Groups(); j++) { + PvlGroup &normalization = equalInfo.Group(j); + std::string normFile = normalization["Filename"][0]; + if(fromFile == normFile) { + + // Store the index in INPUT STATISTICS file corresponding to the + // current FROM LIST file + normIndices.push_back(j); + foundFile = true; + } } - if (!foundFile) { - std::string msg = "The from list file [" + fromFile + - "] does not have any corresponding file in the stats list."; - throw iException::Message(iException::User,msg,_FILEINFO_); + if(!foundFile) { + std::string msg = "The from list file [" + fromFile + + "] does not have any corresponding file in the stats list."; + throw iException::Message(iException::User, msg, _FILEINFO_); } } } // Apply the correction to the images if the user wants this done - if (processOpt != "CALCULATE") { - iString maxCubeStr ((int)imageList.size()); - for (int img=0; img<(int)imageList.size(); img++) { + if(processOpt != "CALCULATE") { + iString maxCubeStr((int)imageList.size()); + for(int img = 0; img < (int)imageList.size(); img++) { // Set up for progress bar ProcessByLine p; - iString curCubeStr (img+1); + iString curCubeStr(img + 1); p.Progress()->SetText("Equalizing Cube " + curCubeStr + " of " + maxCubeStr); // Open input cube @@ -377,49 +377,49 @@ void IsisMain() { // Establish the output file depending upon whether or not a to list // was entered std::string out; - if (ui.WasEntered("TOLIST")) { - out = outList[img]; + if(ui.WasEntered("TOLIST")) { + out = outList[img]; } else { - Filename file = imageList[img]; - out = file.Path() + "/" + file.Basename() + ".equ." + file.Extension(); + Filename file = imageList[img]; + out = file.Path() + "/" + file.Basename() + ".equ." + file.Extension(); } // Allocate output cube CubeAttributeOutput outAtt; - p.SetOutputCube(out,outAtt,icube->Samples(),icube->Lines(),icube->Bands()); + p.SetOutputCube(out, outAtt, icube->Samples(), icube->Lines(), icube->Bands()); // Apply gain/offset to the image g_imageIndex = img; - if (processOpt == "APPLY") { - - // Apply correction based on pre-determined statistics information - Pvl inStats (ui.GetFilename("INSTATS")); - PvlObject &equalInfo = inStats.FindObject("EqualizationInformation"); - PvlGroup &normalization = equalInfo.Group(normIndices[g_imageIndex]); - gains.clear(); - offsets.clear(); - avgs.clear(); - - // Get and store the modifiers for each band - for (int band = 1; band < normalization.Keywords(); band++) { - gains.push_back(normalization[band][0]); - offsets.push_back(normalization[band][1]); - avgs.push_back(normalization[band][2]); - } - p.StartProcess(ApplyViaFile); + if(processOpt == "APPLY") { + + // Apply correction based on pre-determined statistics information + Pvl inStats(ui.GetFilename("INSTATS")); + PvlObject &equalInfo = inStats.FindObject("EqualizationInformation"); + PvlGroup &normalization = equalInfo.Group(normIndices[g_imageIndex]); + gains.clear(); + offsets.clear(); + avgs.clear(); + + // Get and store the modifiers for each band + for(int band = 1; band < normalization.Keywords(); band++) { + gains.push_back(normalization[band][0]); + offsets.push_back(normalization[band][1]); + avgs.push_back(normalization[band][2]); + } + p.StartProcess(ApplyViaFile); } else { - // Apply correction based on the statistics gathered in this run - p.StartProcess(ApplyViaObject); + // Apply correction based on the statistics gathered in this run + p.StartProcess(ApplyViaObject); } p.EndProcess(); } } - + // Clean-up for batch list runs - for (unsigned int o=0; o icube.Bands())) { + if((band <= 0) || (band > icube.Bands())) { string msg = "Invalid band in method [GatherStatistics]"; - throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Programmer, msg, _FILEINFO_); } - + // Construct a line buffer manager and a statistics object - Isis::LineManager line (icube); - - + Isis::LineManager line(icube); + + Isis::Progress progress; progress.SetText(statMsg); - + // Calculate the number of steps for the Progress object, and add an extra // step if the total lines and incrementer do not divide evenly int maxSteps = icube.Lines() / linc; - if (icube.Lines() % linc != 0) maxSteps += 1; + if(icube.Lines() % linc != 0) maxSteps += 1; progress.SetMaximumSteps(maxSteps); progress.CheckStatus(); - + // Add data to Statistics object by line Isis::Statistics stats; - int i=1; - while (i<=icube.Lines()) { - line.SetLine(i,band); + int i = 1; + while(i <= icube.Lines()) { + line.SetLine(i, band); icube.Read(line); - stats.AddData (line.DoubleBuffer(), line.size()); - + stats.AddData(line.DoubleBuffer(), line.size()); + // Make sure we consider the last line - if (i+linc > icube.Lines() && i != icube.Lines()) { + if(i + linc > icube.Lines() && i != icube.Lines()) { i = icube.Lines(); progress.AddSteps(1); } - else i += linc; // Increment the current line by our incrementer - + else i += linc; // Increment the current line by our incrementer + progress.CheckStatus(); } - + return stats; } // Apply the equalization to the cubes with Overlap Normalization void ApplyViaObject(Buffer &in, Buffer &out) { int band = in.Band(); - for (int i=0; iEvaluate(in[i],g_imageIndex); + for(int i = 0; i < in.size(); i++) { + out[i] = g_oNormList[band-1]->Evaluate(in[i], g_imageIndex); } } @@ -502,12 +502,12 @@ void ApplyViaFile(Buffer &in, Buffer &out) { double gain = gains[band-1]; double offset = offsets[band-1]; double avg = avgs[band-1]; - for (int i=0; i -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { - + UserInterface &ui = Application::GetUserInterface(); bool append = ui.GetBoolean("APPEND"); - Pvl input (ui.GetFilename("FROM")); + Pvl input(ui.GetFilename("FROM")); Pvl output; // Check to see if output file exists Filename outFile = ui.GetFilename("TO"); - if (outFile.exists()&&!append) { + if(outFile.exists() && !append) { string msg = "Output file [" + outFile.Expanded() + "] already exists."; msg += " Append option set to False."; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } int numErrors = 0; // Search for errors and add to output - for (int i =0; i < input.Objects(); i++) { + for(int i = 0; i < input.Objects(); i++) { PvlObject o = input.Object(i); - if (o.HasGroup("Error")) { + if(o.HasGroup("Error")) { output.AddObject(o); numErrors++; } } - PvlKeyword errors("TotalErrors",numErrors); + PvlKeyword errors("TotalErrors", numErrors); output.AddKeyword(errors); // write output to file - if (!append) { + if(!append) { output.Write(outFile.Expanded()); - } else { + } + else { output.Append(outFile.Expanded()); } cout << errors << endl; diff --git a/isis/src/base/apps/explode/explode.cpp b/isis/src/base/apps/explode/explode.cpp index 818f5ab416..65fe6d92b7 100644 --- a/isis/src/base/apps/explode/explode.cpp +++ b/isis/src/base/apps/explode/explode.cpp @@ -3,10 +3,10 @@ #include "iException.h" #include "Filename.h" -using namespace std; +using namespace std; using namespace Isis; -void CopyBand (Buffer &in, Buffer &out); +void CopyBand(Buffer &in, Buffer &out); void IsisMain() { // Get the cube to explode @@ -16,36 +16,36 @@ void IsisMain() { int lines = icube->Lines(); int bands = icube->Bands(); string infile = icube->Filename(); - + // We the output filename so we can add attributes and extensions UserInterface &ui = Application::GetUserInterface(); string outbase = ui.GetFilename("TO"); CubeAttributeOutput &outatt = ui.GetOutputAttribute("TO"); // Loop and extract each band - for (int band=1; band<=bands; band++) { + for(int band = 1; band <= bands; band++) { int pband = icube->PhysicalBand(band); iString sband(pband); ProcessByLine p2; Progress *prog = p2.Progress(); - prog->SetText("Exploding band " + sband); - + prog->SetText("Exploding band " + sband); + CubeAttributeInput inatt("+" + sband); - p2.SetInputCube(infile,inatt); - + p2.SetInputCube(infile, inatt); + string outfile = outbase + ".band"; - if (pband / 1000 == 0) { + if(pband / 1000 == 0) { outfile += "0"; - if (pband / 100 == 0) { + if(pband / 100 == 0) { outfile += "0"; - if (pband / 10 == 0) { + if(pband / 10 == 0) { outfile += "0"; } } } outfile += sband + ".cub"; - p2.SetOutputCube(outfile,outatt,samps,lines,1); + p2.SetOutputCube(outfile, outatt, samps, lines, 1); p2.StartProcess(CopyBand); p2.EndProcess(); @@ -56,8 +56,8 @@ void IsisMain() { } // Line processing routine -void CopyBand (Buffer &in, Buffer &out) { - for (int i=0; i=size && in.Line()%(2*size)>=size) || - (i%(2*size)= size && in.Line() % (2 * size) >= size) || + (i % (2 * size) < size && in.Line() % (2 * size) < size)) { + out[i] = 0; } else { - out[i]=255; + out[i] = 255; } } } diff --git a/isis/src/base/apps/fft/fft.cpp b/isis/src/base/apps/fft/fft.cpp index 6f3be2186b..9bd1423fac 100644 --- a/isis/src/base/apps/fft/fft.cpp +++ b/isis/src/base/apps/fft/fft.cpp @@ -5,11 +5,11 @@ #include "Statistics.h" #include "AlphaCube.h" -using namespace std; +using namespace std; using namespace Isis; -void FFT1 (vector &in, vector &out); -void FFT2 (vector &in, vector &out); +void FFT1(vector &in, vector &out); +void FFT2(vector &in, vector &out); void getMinMax(Buffer &in); FourierTransform fft; @@ -19,8 +19,7 @@ double HPixel = 0.0, LPixel = 0.0, NPixel = 0.0; Statistics stats; -void IsisMain() -{ +void IsisMain() { // We will be processing by sample first ProcessByTile sProc; @@ -34,13 +33,13 @@ void IsisMain() // create an AlphaCube containing the resizing information // which will be used during the inverse - AlphaCube aCube(icube->Samples(),icube->Lines(), - icube->Samples(),icube->Lines()); + AlphaCube aCube(icube->Samples(), icube->Lines(), + icube->Samples(), icube->Lines()); UserInterface &ui = Application::GetUserInterface(); string replacement = ui.GetString("REPLACEMENT"); - if (replacement == "ZEROES") { + if(replacement == "ZEROES") { HPixel = 0.0; LPixel = 0.0; NPixel = 0.0; @@ -58,8 +57,8 @@ void IsisMain() Isis::CubeAttributeOutput cao; cao.PixelType(Isis::Real); - sProc.SetOutputCube (tmpMagFilename, cao, numSamples, numLines, numBands); - sProc.SetOutputCube (tmpPhaseFilename, cao, numSamples, numLines, numBands); + sProc.SetOutputCube(tmpMagFilename, cao, numSamples, numLines, numBands); + sProc.SetOutputCube(tmpPhaseFilename, cao, numSamples, numLines, numBands); // Start the sample processing sProc.StartProcess(FFT1); @@ -94,21 +93,20 @@ void IsisMain() } // Processing routine for the fft with one input cube -void FFT1 (vector &in, vector &out) -{ +void FFT1(vector &in, vector &out) { Buffer &image = *in[0]; int n = image.size(); std::vector< std::complex > input(n); // copy the input data into a complex vector - for (int i=0; i(image[i]); + else input[i] = std::complex(image[i]); } // perform the fourier transform @@ -119,7 +117,7 @@ void FFT1 (vector &in, vector &out) Buffer &imagCube = *out[1]; // copy the data into the two output cubes so that it is centered at the origin - for (int i=0; i &in, vector &out) } // Processing routine for the fft with two input cubes -void FFT2 (vector &in, vector &out) -{ +void FFT2(vector &in, vector &out) { // Set the input cubes Buffer &inReal = *in[0]; Buffer &inImag = *in[1]; @@ -139,8 +136,8 @@ void FFT2 (vector &in, vector &out) int n = inReal.size(); std::vector< std::complex > input(n); - for (int i=0; i(inReal[i], inImag[i]); + for(int i = 0; i < n; i++) { + input[i] = std::complex(inReal[i], inImag[i]); } // perform the fourier transform @@ -151,7 +148,7 @@ void FFT2 (vector &in, vector &out) Buffer &phaseCube = *out[1]; // copy the data into the two output cubes so that it is centered at the origin - for (int i=0; i &in, vector &out) } } -void getMinMax(Buffer &in) -{ +void getMinMax(Buffer &in) { stats.AddData(in.DoubleBuffer(), in.size()); } diff --git a/isis/src/base/apps/fillgap/fillgap.cpp b/isis/src/base/apps/fillgap/fillgap.cpp index 1e940de840..de9f014337 100644 --- a/isis/src/base/apps/fillgap/fillgap.cpp +++ b/isis/src/base/apps/fillgap/fillgap.cpp @@ -7,7 +7,7 @@ #include "SpecialPixel.h" #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; static NumericalApproximation::InterpType iType(NumericalApproximation::CubicNatural); @@ -25,57 +25,57 @@ void IsisMain() { // set spline interpolation to user requested type string splineType = ui.GetString("INTERP"); - if (splineType == "LINEAR") { - iType = NumericalApproximation::Linear; - } - else if (splineType == "AKIMA") { - iType = NumericalApproximation::Akima; + if(splineType == "LINEAR") { + iType = NumericalApproximation::Linear; + } + else if(splineType == "AKIMA") { + iType = NumericalApproximation::Akima; } else { - iType = NumericalApproximation::CubicNatural; + iType = NumericalApproximation::CubicNatural; } //Set null direction to the user defined direction - string Dir = ui.GetString("DIRECTION"); - if(Dir == "SAMPLE"){ + string Dir = ui.GetString("DIRECTION"); + if(Dir == "SAMPLE") { ProcessBySample p; p.SetInputCube("FROM"); - p.SetOutputCube("TO"); + p.SetOutputCube("TO"); p.StartProcess(fill); p.EndProcess(); } - else if (Dir == "LINE") { + else if(Dir == "LINE") { ProcessByLine p; p.SetInputCube("FROM"); - p.SetOutputCube("TO"); + p.SetOutputCube("TO"); p.StartProcess(fill); - p.EndProcess(); - } - else if (Dir == "BAND") { + p.EndProcess(); + } + else if(Dir == "BAND") { ProcessBySpectra p; //Check number of bands to see if this will be allowed. p.SetInputCube("FROM"); - p.SetOutputCube("TO"); + p.SetOutputCube("TO"); p.StartProcess(fill); - p.EndProcess(); + p.EndProcess(); } // if any pixels were not filled, let user know by adding message to the log - if (numSpecPixKept > 0) { + if(numSpecPixKept > 0) { PvlGroup mLog("Messages"); - mLog+=PvlKeyword("Warning", - "Unable to fill " + iString(numSpecPixKept) + " special pixels."); + mLog += PvlKeyword("Warning", + "Unable to fill " + iString(numSpecPixKept) + " special pixels."); Application::Log(mLog); } - return; + return; } /** * @brief Fill in gaps of image using an interpolation on the DN * values. - * + * * @param in Input Buffer * @param out Output Buffer - * @internal + * @internal * @history 2009-04-21 Jeannie Walldren - Added a try/catch * statement to the Evaluate() method. The only * reason for Evaluate to throw an error should be @@ -90,29 +90,29 @@ void IsisMain() { * can keep a count of how many pixels were not * filled by this app. */ -void fill(Buffer &in, Buffer &out) { +void fill(Buffer &in, Buffer &out) { // Fill the data set with valid pixel values NumericalApproximation spline(iType); - for (int i=0; i < in.size(); i++) { - if (!IsSpecial(in[i])) { - spline.AddData((double) (i+1),in[i]); + for(int i = 0; i < in.size(); i++) { + if(!IsSpecial(in[i])) { + spline.AddData((double)(i + 1), in[i]); } } // loop through output buffer - for (int j = 0 ; j < out.size() ; j++) { + for(int j = 0 ; j < out.size() ; j++) { // if the input pixel is valid, copy it - if (!IsSpecial(in[j])) { + if(!IsSpecial(in[j])) { out[j] = in[j]; } // otherwise, try to interpolate from the valid values - else{ - try{ - out[j] = spline.Evaluate((double) (j+1)); + else { + try { + out[j] = spline.Evaluate((double)(j + 1)); } // if Evaluate() fails, copy the input value and increment numSpecPixKept - catch (iException &e){ + catch(iException &e) { out[j] = in[j]; numSpecPixKept++; } diff --git a/isis/src/base/apps/findgaps/findgaps.cpp b/isis/src/base/apps/findgaps/findgaps.cpp index 2c9ac5aa5d..359009a745 100644 --- a/isis/src/base/apps/findgaps/findgaps.cpp +++ b/isis/src/base/apps/findgaps/findgaps.cpp @@ -6,10 +6,10 @@ #include "Statistics.h" #include "MultivariateStatistics.h" -using namespace std; +using namespace std; using namespace Isis; -void FindGaps ( Buffer &in ); +void FindGaps(Buffer &in); // The Correlation Tollerance variable double corTol; @@ -27,7 +27,7 @@ void IsisMain() { ProcessByLine p; // Setup the input cube and lastLine array - Cube *icube = p.SetInputCube( "FROM" ); + Cube *icube = p.SetInputCube("FROM"); previousLine.resize(icube->Samples()); lineNum = icube->Lines(); @@ -36,12 +36,12 @@ void IsisMain() { corTol = ui.GetDouble("CORTOL"); // Starts the find gaps process - p.StartProcess( FindGaps ); + p.StartProcess(FindGaps); //In case the last gap runs to the end of the cube - if ( inGap ) { - pvl.AddKeyword( PvlKeyword( "ToEndOfBand", lineNum ) ); + if(inGap) { + pvl.AddKeyword(PvlKeyword("ToEndOfBand", lineNum)); } - toDisplay.Write( ui.GetFilename("TO") ); + toDisplay.Write(ui.GetFilename("TO")); toDisplay.Clear(); inGap = false; p.EndProcess(); @@ -52,41 +52,41 @@ void IsisMain() { * accordingly, posting bad results in Log. * @param in */ -void FindGaps ( Buffer &in ) { +void FindGaps(Buffer &in) { // Copys line 1 into previousLine since it is the top of the Band - if ( in.Line() == 1 ) { - for (int i=0; iFindGroup("Reseaus",Pvl::Traverse); +void IsisMain() { + // Import cube data & PVL information + Cube cube; + UserInterface &ui = Application::GetUserInterface(); + cube.Open(ui.GetFilename("FROM"), "rw"); + Pvl *regdef; + // If regdef was supplied by the user, use it. else, use the template. + if(ui.WasEntered("REGDEF")) { + regdef = new Pvl(ui.GetFilename("REGDEF")); + } + else { + regdef = new Pvl("$base/templates/autoreg/findrx.def"); + } + PvlGroup &reseaus = cube.Label()->FindGroup("Reseaus", Pvl::Traverse); - // If the Keyword sizes don't match up, throw errors. - int nres = reseaus["Line"].Size(); - if (nres != reseaus["Sample"].Size()) { - string msg = "Sample size incorrect [Sample size " + - iString(reseaus["Sample"].Size()) + " != " + " Line size " + - iString(reseaus["Line"].Size()) + "]"; - throw Isis::iException::Message(Isis::iException::Pvl,msg, _FILEINFO_); - } - if (nres != reseaus["Type"].Size()) { - string msg = "Type size incorrect [Type size " + - iString(reseaus["Type"].Size()) + " != " + " Line size " + - iString(reseaus["Line"].Size()) + "]"; - throw Isis::iException::Message(Isis::iException::Pvl,msg, _FILEINFO_); - } - if (nres != reseaus["Valid"].Size()) { - string msg = "Valid size incorrect [Valid size " + - iString(reseaus["Valid"].Size()) + " != " + " Line size " + - iString(reseaus["Line"].Size()) + "]"; - throw Isis::iException::Message(Isis::iException::Pvl,msg, _FILEINFO_); - } + // If the Keyword sizes don't match up, throw errors. + int nres = reseaus["Line"].Size(); + if(nres != reseaus["Sample"].Size()) { + string msg = "Sample size incorrect [Sample size " + + iString(reseaus["Sample"].Size()) + " != " + " Line size " + + iString(reseaus["Line"].Size()) + "]"; + throw Isis::iException::Message(Isis::iException::Pvl, msg, _FILEINFO_); + } + if(nres != reseaus["Type"].Size()) { + string msg = "Type size incorrect [Type size " + + iString(reseaus["Type"].Size()) + " != " + " Line size " + + iString(reseaus["Line"].Size()) + "]"; + throw Isis::iException::Message(Isis::iException::Pvl, msg, _FILEINFO_); + } + if(nres != reseaus["Valid"].Size()) { + string msg = "Valid size incorrect [Valid size " + + iString(reseaus["Valid"].Size()) + " != " + " Line size " + + iString(reseaus["Line"].Size()) + "]"; + throw Isis::iException::Message(Isis::iException::Pvl, msg, _FILEINFO_); + } - // Auto Registration - AutoReg *ar = AutoRegFactory::Create(*regdef); - Cube pattern; - pattern.Open(reseaus["Template"], "r"); - ar->PatternChip()->TackCube(5.0,5.0); - - // Display the progress...10% 20% etc. - Progress prog; - prog.SetMaximumSteps(nres); - prog.CheckStatus(); - + // Auto Registration + AutoReg *ar = AutoRegFactory::Create(*regdef); + Cube pattern; + pattern.Open(reseaus["Template"], "r"); + ar->PatternChip()->TackCube(5.0, 5.0); - //If the mark reseaus option is set...then create a brick. - Brick* white = NULL; - if (ui.GetBoolean("MARK") == true) { - white = new Brick(1,1,1, Isis::UnsignedByte); - (*white)[0] = Isis::Hrs; - } + // Display the progress...10% 20% etc. + Progress prog; + prog.SetMaximumSteps(nres); + prog.CheckStatus(); - double percent = ar->PatternValidPercent(); - // And the loop... - for (int res=0; resSearchChip()->TackCube(reseaus["Sample"][res], reseaus["Line"][res]); - ar->SearchChip()->Load(cube); - ar->PatternChip()->Load(pattern, 0, 1.0, res+1); - int type = iString(reseaus["Type"][res]); - // If the reseaus is in the center (type 5) use full percent value - if (type== 5) ar->SetPatternValidPercent(percent); - // else if the reseaus is on an edge (type 2,4,6, or 8) use half percent value - else if (type%2 == 0) ar->SetPatternValidPercent(percent/2.0); - // else the reseaus on a corner (type 1,3,7, or 9) use a quarter percent value - else ar->SetPatternValidPercent(percent/4.0); - if (ar->Register()==AutoReg::Success) { - reseaus["Sample"][res] = ar->CubeSample(); - reseaus["Line"][res] = ar->CubeLine(); - reseaus["Valid"][res] = 1; - } - else { - reseaus["Valid"][res] = 0; - } + //If the mark reseaus option is set...then create a brick. + Brick *white = NULL; + if(ui.GetBoolean("MARK") == true) { + white = new Brick(1, 1, 1, Isis::UnsignedByte); + (*white)[0] = Isis::Hrs; + } - // And if the reseaus are to be marked...mark em - if (white != NULL) { - double line = reseaus["Line"][res]; - double sample = reseaus["Sample"][res]; - white->SetBasePosition(int(sample), int(line), 1); - cube.Write(*white); - } - prog.CheckStatus(); + double percent = ar->PatternValidPercent(); + // And the loop... + for(int res = 0; res < nres; ++res) { + // Output chips + ar->SearchChip()->TackCube(reseaus["Sample"][res], reseaus["Line"][res]); + ar->SearchChip()->Load(cube); + ar->PatternChip()->Load(pattern, 0, 1.0, res + 1); + int type = iString(reseaus["Type"][res]); + // If the reseaus is in the center (type 5) use full percent value + if(type == 5) ar->SetPatternValidPercent(percent); + // else if the reseaus is on an edge (type 2,4,6, or 8) use half percent value + else if(type % 2 == 0) ar->SetPatternValidPercent(percent / 2.0); + // else the reseaus on a corner (type 1,3,7, or 9) use a quarter percent value + else ar->SetPatternValidPercent(percent / 4.0); + if(ar->Register() == AutoReg::Success) { + reseaus["Sample"][res] = ar->CubeSample(); + reseaus["Line"][res] = ar->CubeLine(); + reseaus["Valid"][res] = 1; } + else { + reseaus["Valid"][res] = 0; + } + + // And if the reseaus are to be marked...mark em + if(white != NULL) { + double line = reseaus["Line"][res]; + double sample = reseaus["Sample"][res]; + white->SetBasePosition(int(sample), int(line), 1); + cube.Write(*white); + } + prog.CheckStatus(); + + } + + // Change status to "Refined", corrected! + reseaus["Status"] = "Refined"; - // Change status to "Refined", corrected! - reseaus["Status"] = "Refined"; - - pattern.Close(); - cube.Close(); + pattern.Close(); + cube.Close(); } diff --git a/isis/src/base/apps/fits2isis/fits2isis.cpp b/isis/src/base/apps/fits2isis/fits2isis.cpp index 87b1d3eab6..f0e4f9f508 100644 --- a/isis/src/base/apps/fits2isis/fits2isis.cpp +++ b/isis/src/base/apps/fits2isis/fits2isis.cpp @@ -28,7 +28,7 @@ void IsisMain() { input.open(from.c_str(), ios::in | ios::binary); // Check stream open status - if (!input.is_open()) { + if(!input.is_open()) { string msg = "Cannot open input file [" + from + "]"; throw Isis::iException::Message(Isis::iException::Io, msg, _FILEINFO_); } @@ -46,29 +46,29 @@ void IsisMain() { place += 80; // Read in and place in PvlKeywords and a PvlGroup - while (line.substr(0,3) != "END") { + while(line.substr(0, 3) != "END") { // Check for blank lines - if (line.substr(0,1) != " " && line.substr(0,1) != "/") { + if(line.substr(0, 1) != " " && line.substr(0, 1) != "/") { // Name of keyword PvlKeyword label(line.Token(" =")); // Remove up to beginning of data line.TrimHead(" ='"); line.TrimTail(" "); - if (label.Name() == "COMMENT" || label.Name() == "HISTORY") { + if(label.Name() == "COMMENT" || label.Name() == "HISTORY") { label += line; } else { // Access the data without the comment if there is one iString value = line.Token("/"); // Clear to end of data, including single quotes - value.TrimTail(" '"); + value.TrimTail(" '"); label += value; line.TrimHead(" "); // If the remaining line string has anything, it is comments. - if (line.size() > 0) { + if(line.size() > 0) { label.AddComment(line); // A possible format for units, other possiblites exist. - if (line != line.Token("[")) { + if(line != line.Token("[")) { label.SetUnits(line.Token("[").Token("]")); } } @@ -87,7 +87,7 @@ void IsisMain() { input.close(); // Its possible they could have this instead of T, in which case we won't even try - if (labels["SIMPLE"][0] == "F") { + if(labels["SIMPLE"][0] == "F") { string msg = "The file [" + ui.GetFilename("FROM") + "] does not conform to the FITS standards"; throw iException::Message(iException::User, msg, _FILEINFO_); } @@ -97,21 +97,21 @@ void IsisMain() { pfits.SetInputFile(ui.GetFilename("FROM")); // Header size will be a multiple of 2880 - int multiple = (int)((place + 2881)/2880); + int multiple = (int)((place + 2881) / 2880); pfits.SetFileHeaderBytes(multiple * 2880); pfits.SaveFileHeader(); // Find pixel type, there are several unsupported possiblites Isis::PixelType type; string msg = ""; - switch (labels["BITPIX"][0].ToInteger()) { - case 8: + switch(labels["BITPIX"][0].ToInteger()) { + case 8: type = Isis::UnsignedByte; break; - case 16: + case 16: type = Isis::SignedWord; break; - case 32: + case 32: msg = "Signed 32 bit integer (int) pixel type is not supported at this time"; throw iException::Message(iException::User, msg, _FILEINFO_); break; @@ -119,27 +119,27 @@ void IsisMain() { msg = "Signed 64 bit integer (long) pixel type is not supported at this time"; throw iException::Message(iException::User, msg, _FILEINFO_); break; - case -32: + case -32: type = Isis::Real; break; - case -64: + case -64: msg = "64 bit floating point (double) pixel type is not supported at this time"; throw iException::Message(iException::User, msg, _FILEINFO_); break; default: msg = "Unknown pixel type [" + labels["BITPIX"][0] + "] cannot be imported"; throw iException::Message(iException::User, msg, _FILEINFO_); - break; + break; } pfits.SetPixelType(type); - // It is possible to have a NAXIS value of 0 meaning no data, the file could include - // xtensions with data, however, those aren't supported as of Oct '09 - if (labels["NAXIS"][0].ToInteger() == 2) { + // It is possible to have a NAXIS value of 0 meaning no data, the file could include + // xtensions with data, however, those aren't supported as of Oct '09 + if(labels["NAXIS"][0].ToInteger() == 2) { pfits.SetDimensions(labels["NAXIS1"][0], labels["NAXIS2"][0], 1); } - else if (labels["NAXIS"][0].ToInteger() == 3) { + else if(labels["NAXIS"][0].ToInteger() == 3) { pfits.SetDimensions(labels["NAXIS1"][0], labels["NAXIS2"][0], labels["NAXIS3"][0]); } else { @@ -148,41 +148,41 @@ void IsisMain() { } // Base and multiplier - if (labels.HasKeyword("BZERO")) { + if(labels.HasKeyword("BZERO")) { pfits.SetBase(labels["BZERO"][0]); } - if (labels.HasKeyword("BSCALE")) { + if(labels.HasKeyword("BSCALE")) { pfits.SetMultiplier(labels["BSCALE"][0]); } // Byte order - pfits.SetByteOrder(Isis::Msb); + pfits.SetByteOrder(Isis::Msb); // Limited section of standardized keywords that could exist bool instGrp = false; PvlGroup inst("Instrument"); - if (labels.HasKeyword("DATE-OBS")) { + if(labels.HasKeyword("DATE-OBS")) { instGrp = true; inst += PvlKeyword("StartTime", labels["DATE-OBS"][0]); } - if (labels.HasKeyword("OBJECT")) { + if(labels.HasKeyword("OBJECT")) { instGrp = true; inst += PvlKeyword("Target", labels["OBJECT"][0]); } - if (labels.HasKeyword("INSTRUME")) { + if(labels.HasKeyword("INSTRUME")) { instGrp = true; inst += PvlKeyword("InstrumentId", labels["INSTRUME"][0]); } - if (labels.HasKeyword("OBSERVER")) { + if(labels.HasKeyword("OBSERVER")) { instGrp = true; inst += PvlKeyword("SpacecraftName", labels["OBSERVER"][0]); } - Cube * output = pfits.SetOutputCube("TO"); + Cube *output = pfits.SetOutputCube("TO"); // Add instrument group if any relevant data exists - Pvl * lbls = output->Label(); - if (instGrp) { + Pvl *lbls = output->Label(); + if(instGrp) { lbls->FindObject("IsisCube") += inst; } diff --git a/isis/src/base/apps/flip/flip.cpp b/isis/src/base/apps/flip/flip.cpp index edcf61f770..edaa1df3d9 100644 --- a/isis/src/base/apps/flip/flip.cpp +++ b/isis/src/base/apps/flip/flip.cpp @@ -2,10 +2,10 @@ #include "ProcessBySample.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void flip (Buffer &in, Buffer &out); +void flip(Buffer &in, Buffer &out); void IsisMain() { // We will be processing by line @@ -13,18 +13,18 @@ void IsisMain() { // Setup the input and output cubes p.SetInputCube("FROM"); - p.SetOutputCube ("TO"); - + p.SetOutputCube("TO"); + // Start the processing p.StartProcess(flip); p.EndProcess(); } // Line processing routine -void flip (Buffer &in, Buffer &out) { +void flip(Buffer &in, Buffer &out) { // Loop and flip pixels in the line. int index = in.size() - 1; - for (int i=0; i 1 && linc > 1 ) { + } + catch(iException &e) { + if(precision && sinc > 1 && linc > 1) { sinc = sinc * 2 / 3; linc = linc * 2 / 3; e.Clear(); @@ -64,35 +66,35 @@ void IsisMain() { } - if( ui.GetBoolean("TESTXY") ) { - Pvl cubeLab( ui.GetFilename("FROM") ); + if(ui.GetBoolean("TESTXY")) { + Pvl cubeLab(ui.GetFilename("FROM")); PvlGroup inst = cubeLab.FindGroup("Instrument", Pvl::Traverse); string target = inst["TargetName"]; PvlGroup radii = Projection::TargetRadii(target); - Pvl map( ui.GetFilename("MAP") ); - PvlGroup & mapping = map.FindGroup("MAPPING"); + Pvl map(ui.GetFilename("MAP")); + PvlGroup &mapping = map.FindGroup("MAPPING"); - if( !mapping.HasKeyword("TargetName") ) + if(!mapping.HasKeyword("TargetName")) mapping += Isis::PvlKeyword("TargetName", target); - if( !mapping.HasKeyword("EquatorialRadius") ) - mapping += Isis::PvlKeyword("EquatorialRadius",(string)radii["EquatorialRadius"]); - if( !mapping.HasKeyword("PolarRadius") ) - mapping += Isis::PvlKeyword("PolarRadius",(string)radii["PolarRadius"]); - if( !mapping.HasKeyword("LatitudeType") ) - mapping += Isis::PvlKeyword("LatitudeType","Planetocentric"); - if( !mapping.HasKeyword("LongitudeDirection") ) - mapping += Isis::PvlKeyword("LongitudeDirection","PositiveEast"); - if( !mapping.HasKeyword("LongitudeDomain") ) - mapping += Isis::PvlKeyword("LongitudeDomain",360); - if( !mapping.HasKeyword("CenterLatitude") ) - mapping += Isis::PvlKeyword("CenterLatitude",0); - if( !mapping.HasKeyword("CenterLongitude") ) - mapping += Isis::PvlKeyword("CenterLongitude",0); - - while( true ) { + if(!mapping.HasKeyword("EquatorialRadius")) + mapping += Isis::PvlKeyword("EquatorialRadius", (string)radii["EquatorialRadius"]); + if(!mapping.HasKeyword("PolarRadius")) + mapping += Isis::PvlKeyword("PolarRadius", (string)radii["PolarRadius"]); + if(!mapping.HasKeyword("LatitudeType")) + mapping += Isis::PvlKeyword("LatitudeType", "Planetocentric"); + if(!mapping.HasKeyword("LongitudeDirection")) + mapping += Isis::PvlKeyword("LongitudeDirection", "PositiveEast"); + if(!mapping.HasKeyword("LongitudeDomain")) + mapping += Isis::PvlKeyword("LongitudeDomain", 360); + if(!mapping.HasKeyword("CenterLatitude")) + mapping += Isis::PvlKeyword("CenterLatitude", 0); + if(!mapping.HasKeyword("CenterLongitude")) + mapping += Isis::PvlKeyword("CenterLongitude", 0); + + while(true) { try { - Projection *proj= ProjectionFactory::Create(map, true); + Projection *proj = ProjectionFactory::Create(map, true); geos::geom::MultiPolygon *xyPoly = PolygonTools::LatLonToXY(*poly.Polys(), proj); delete proj; @@ -101,8 +103,9 @@ void IsisMain() { xyPoly = NULL; break; - } catch( iException &e ) { - if( precision && sinc > 1 && linc > 1 ) { + } + catch(iException &e) { + if(precision && sinc > 1 && linc > 1) { sinc = sinc * 2 / 3; linc = linc * 2 / 3; poly.Create(cube, sinc, linc); @@ -119,14 +122,14 @@ void IsisMain() { - cube.BlobDelete("Polygon",sn); + cube.BlobDelete("Polygon", sn); cube.Write(poly); - if( precision ) { + if(precision) { PvlGroup results("Results"); - results.AddKeyword( PvlKeyword( "SINC", sinc ) ); - results.AddKeyword( PvlKeyword( "LINC", linc ) ); - Application::Log( results ); + results.AddKeyword(PvlKeyword("SINC", sinc)); + results.AddKeyword(PvlKeyword("LINC", linc)); + Application::Log(results); } Process p; @@ -134,5 +137,5 @@ void IsisMain() { p.WriteHistory(cube); cube.Close(); - prog.CheckStatus (); + prog.CheckStatus(); } diff --git a/isis/src/base/apps/footprintmerge/footprintmerge.cpp b/isis/src/base/apps/footprintmerge/footprintmerge.cpp index 8ade5be017..917a6fc3b1 100644 --- a/isis/src/base/apps/footprintmerge/footprintmerge.cpp +++ b/isis/src/base/apps/footprintmerge/footprintmerge.cpp @@ -14,30 +14,30 @@ #include "geos/geom/Geometry.h" #include "geos/geom/MultiPolygon.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { UserInterface &ui = Application::GetUserInterface(); FileList imageList; - imageList.Read(ui.GetFilename ("FROMLIST")); - if (imageList.size() < 1) { + imageList.Read(ui.GetFilename("FROMLIST")); + if(imageList.size() < 1) { std::string msg = "The list file [" + ui.GetFilename("FROMLIST") + - "] does not contain any data"; - throw iException::Message(iException::User,msg,_FILEINFO_); + "] does not contain any data"; + throw iException::Message(iException::User, msg, _FILEINFO_); } Progress prog; - prog.SetText ("Merging footprints"); + prog.SetText("Merging footprints"); prog.SetMaximumSteps(imageList.size()); - prog.CheckStatus (); + prog.CheckStatus(); // For this first loop union all image polygons vector allPolys; vector files; bool conv360 = false; - for (unsigned int img=0; imgPolys()->getNumGeometries() > 1) conv360 = true; + if(poly->Polys()->getNumGeometries() > 1) conv360 = true; allPolys.push_back(PolygonTools::CopyMultiPolygon(poly->Polys())); files.push_back(imageList[img]); - prog.CheckStatus (); + prog.CheckStatus(); } // If any islands are on the 0/360 boundary convert to -180/180 and merge // any polys that were split on the boundary. - if (conv360) { - for (unsigned int i=0; igetNumGeometries() > 1 || + if(m->getNumGeometries() > 1 || m->getCoordinates()->minCoordinate()->x > 180.) { geos::geom::MultiPolygon *poly = - PolygonTools::To180((geos::geom::MultiPolygon *)allPolys[i]); + PolygonTools::To180((geos::geom::MultiPolygon *)allPolys[i]); allPolys[i] = poly; } } } - + // Create union poly - geos::geom::GeometryCollection *polyCollection = - Isis::globalFactory.createGeometryCollection(allPolys); + geos::geom::GeometryCollection *polyCollection = + Isis::globalFactory.createGeometryCollection(allPolys); geos::geom::Geometry *unionPoly = polyCollection->buffer(0); // How many polygons are in unionPoly vector islandPolys; - if (unionPoly->getGeometryTypeId() == geos::geom::GEOS_POLYGON) { + if(unionPoly->getGeometryTypeId() == geos::geom::GEOS_POLYGON) { // There are no islands, all cubes are in a single cluster - std::cout<<"NO ISLANDS, ALL CUBES OVERLAP"<getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON) { + else if(unionPoly->getGeometryTypeId() == geos::geom::GEOS_MULTIPOLYGON) { geos::geom::MultiPolygon *multi = (geos::geom::MultiPolygon *) unionPoly; - for (unsigned int i=0; igetNumGeometries(); ++i) { + for(unsigned int i = 0; i < multi->getNumGeometries(); ++i) { islandPolys.push_back(multi->getGeometryN(i)->clone()); } } - + // Intersect each input poly (the first of each cube) with each poly // from the unionPoly, and keep track of which images are in each // unionPoly. - prog.SetText ("Intersecting footprints"); + prog.SetText("Intersecting footprints"); prog.SetMaximumSteps(allPolys.size()); - prog.CheckStatus (); + prog.CheckStatus(); typedef std::vector islandFiles; std::vector< islandFiles > islands; islands.resize(islandPolys.size()); - for (unsigned int i=0; iintersects(islandPolys[p])) { + for(unsigned int i = 0; i < allPolys.size(); i++) { + for(unsigned int p = 0; p < islandPolys.size(); p++) { + if(allPolys[i]->intersects(islandPolys[p])) { islands[p].push_back(files[i]); } } - prog.CheckStatus (); + prog.CheckStatus(); } - - + + string mode = ui.GetString("MODE"); // print out island statistics // Brief - if (mode=="BRIEF") { + if(mode == "BRIEF") { PvlGroup results("Results"); - results += PvlKeyword("NumberOfIslands",(int)islandPolys.size()); + results += PvlKeyword("NumberOfIslands", (int)islandPolys.size()); Application::Log(results); } - else if (mode=="FULL") { + else if(mode == "FULL") { string out = ui.GetFilename("TO"); PvlObject results("Results"); - for (unsigned int p=0; p &input, vector &output) { - Buffer& outBuffer = *output[0]; + Buffer &outBuffer = *output[0]; QVector inputCopy; @@ -94,8 +94,8 @@ void Evaluate(vector &input, vector &output) { inputCopy.push_back(input[i]); } - QVector results = c.RunCalculations(inputCopy, - outBuffer.Line(), outBuffer.Band()); + QVector results = c.RunCalculations(inputCopy, + outBuffer.Line(), outBuffer.Band()); // If final result is a scalar, set all pixels to that value. if(results.size() == 1) { diff --git a/isis/src/base/apps/gauss/gauss.cpp b/isis/src/base/apps/gauss/gauss.cpp index 48b12b54ec..79d6f6274c 100644 --- a/isis/src/base/apps/gauss/gauss.cpp +++ b/isis/src/base/apps/gauss/gauss.cpp @@ -7,72 +7,72 @@ #include "Filename.h" #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; -void useFilter (Buffer &in, double &v); -void setFilter (int size, double stdDev); +void useFilter(Buffer &in, double &v); +void setFilter(int size, double stdDev); double *coefs; void IsisMain() { ProcessByBoxcar p; - p.SetInputCube ("FROM"); - p.SetOutputCube ("TO"); - + p.SetInputCube("FROM"); + p.SetOutputCube("TO"); + //Set up the user interface UserInterface &ui = Application::GetUserInterface(); //Get the standard deviation from the user double stdDev = ui.GetDouble("STDDEV"); - + //Get the length of each side of the kernel from the user // (Note: kernel is always square) int size = ui.GetInteger("SIZE"); - + //Set the Boxcar size based on the input size - p.SetBoxcarSize (size,size); - + p.SetBoxcarSize(size, size); + //Reference a pointer to an array of kernel data values - coefs = new double[size*size]; - setFilter (size,stdDev); - - p.StartProcess(useFilter); - p.EndProcess (); - + coefs = new double[size*size]; + setFilter(size, stdDev); + + p.StartProcess(useFilter); + p.EndProcess(); + delete [] coefs; } -void setFilter (int size, double stdDev){ +void setFilter(int size, double stdDev) { //Iterate through the input kernel's data values to fill the coefs array - const double PI=3.141592653589793; - int i =0; + const double PI = 3.141592653589793; + int i = 0; cout << exp((double)1.0) << endl; - for (double y= -(size/2) ; y <= (size/2) ; y++){ - for (double x=-(size/2) ; x <= (size/2) ; x++){ + for(double y = -(size / 2) ; y <= (size / 2) ; y++) { + for(double x = -(size / 2) ; x <= (size / 2) ; x++) { /* Assign gaussian weights based on the following equation x^2+y^2 - -- ----------- + -- ----------- G(x,y) = 1 2(stdDev)^2 - --------------- e^ - 2(pi)(stdDev)^2 + --------------- e^ + 2(pi)(stdDev)^2 */ - - coefs[i] = (x * x ) + (y * y); - coefs[i] = (coefs[i] ) / (-2 * (stdDev * stdDev)); - coefs[i] = exp (coefs[i]); - coefs[i] = (1 / (2 * PI * stdDev * stdDev) ) * coefs [i]; + + coefs[i] = (x * x) + (y * y); + coefs[i] = (coefs[i]) / (-2 * (stdDev * stdDev)); + coefs[i] = exp(coefs[i]); + coefs[i] = (1 / (2 * PI * stdDev * stdDev)) * coefs [i]; i++; } } } -void useFilter (Buffer &in, double &v){ +void useFilter(Buffer &in, double &v) { v = 0; - for (int i= 0 ; i < in.size() ; i++){ - if (!IsSpecial(in[i])){ - v += in[i] * coefs[i] ; - } + for(int i = 0 ; i < in.size() ; i++) { + if(!IsSpecial(in[i])) { + v += in[i] * coefs[i] ; } + } } diff --git a/isis/src/base/apps/gaussstretch/gaussstretch.cpp b/isis/src/base/apps/gaussstretch/gaussstretch.cpp index a8fe2c0691..fdd9b7da5d 100644 --- a/isis/src/base/apps/gaussstretch/gaussstretch.cpp +++ b/isis/src/base/apps/gaussstretch/gaussstretch.cpp @@ -6,34 +6,33 @@ using namespace std; using namespace Isis; -void gauss (Buffer &in, Buffer &out); +void gauss(Buffer &in, Buffer &out); vector stretch; -void IsisMain() -{ +void IsisMain() { ProcessByLine p; Cube *icube = p.SetInputCube("FROM"); p.SetOutputCube("TO"); double gsigma = Isis::Application::GetUserInterface().GetDouble("GSIGMA"); - for (int i=0; i< icube->Bands(); i++) { - Histogram hist = *(icube->Histogram(i+1)); - double mean = (hist.Maximum() + hist.Minimum())/2.0; - double stdev = (hist.Maximum() - hist.Minimum())/(2.0*gsigma); - stretch.push_back( new GaussianStretch( hist, mean, stdev) ); + for(int i = 0; i < icube->Bands(); i++) { + Histogram hist = *(icube->Histogram(i + 1)); + double mean = (hist.Maximum() + hist.Minimum()) / 2.0; + double stdev = (hist.Maximum() - hist.Minimum()) / (2.0 * gsigma); + stretch.push_back(new GaussianStretch(hist, mean, stdev)); } p.StartProcess(gauss); - for (int i=0; i< icube->Bands(); i++) delete stretch[i]; + for(int i = 0; i < icube->Bands(); i++) delete stretch[i]; stretch.clear(); p.EndProcess(); } // Processing routine for the pca with one input cube -void gauss (Buffer &in, Buffer &out){ - for (int i=0; iMap(in[i]); } } diff --git a/isis/src/base/apps/getkey/getkey.cpp b/isis/src/base/apps/getkey/getkey.cpp index c4e3c3432d..306f84c193 100644 --- a/isis/src/base/apps/getkey/getkey.cpp +++ b/isis/src/base/apps/getkey/getkey.cpp @@ -8,15 +8,15 @@ #include "Pvl.h" #include "SessionLog.h" -using namespace std; +using namespace std; using namespace Isis; //helper button functins in the code void helperButtonLog(); -map GuiHelpers(){ - map helper; - helper ["helperButtonLog"] = (void*) helperButtonLog; +map GuiHelpers() { + map helper; + helper ["helperButtonLog"] = (void *) helperButtonLog; return helper; } void IsisMain() { @@ -26,7 +26,7 @@ void IsisMain() { // Use a regular Process Process p; - + // Get the input file from the user interface UserInterface &ui = Application::GetUserInterface(); string labelFile = ui.GetFilename("FROM"); @@ -38,56 +38,58 @@ void IsisMain() { // Set up the requested object PvlKeyword key; - if (ui.WasEntered("OBJNAME")) { + if(ui.WasEntered("OBJNAME")) { string obj = ui.GetString("OBJNAME"); // Get the keyword from the entered group - if (ui.WasEntered("GRPNAME")) { - PvlObject object = lab.FindObject(obj,Pvl::Traverse); + if(ui.WasEntered("GRPNAME")) { + PvlObject object = lab.FindObject(obj, Pvl::Traverse); string grp = ui.GetString("GRPNAME"); - key = object.FindGroup(grp,Pvl::Traverse)[ui.GetString("KEYWORD")]; + key = object.FindGroup(grp, Pvl::Traverse)[ui.GetString("KEYWORD")]; } // Find the keyword in the object else { - if(recursive){ - key = lab.FindObject(obj,Pvl::Traverse).FindKeyword(ui.GetString("KEYWORD"),Pvl::Traverse); - } else { - key = lab.FindObject(obj,Pvl::Traverse)[ui.GetString("KEYWORD")]; + if(recursive) { + key = lab.FindObject(obj, Pvl::Traverse).FindKeyword(ui.GetString("KEYWORD"), Pvl::Traverse); + } + else { + key = lab.FindObject(obj, Pvl::Traverse)[ui.GetString("KEYWORD")]; } } } // Set up the requested group - else if (ui.WasEntered("GRPNAME")) { + else if(ui.WasEntered("GRPNAME")) { string grp = ui.GetString("GRPNAME"); - key = lab.FindGroup(grp,Pvl::Traverse)[ui.GetString("KEYWORD")]; + key = lab.FindGroup(grp, Pvl::Traverse)[ui.GetString("KEYWORD")]; } // Find the keyword in the label, outside of any object or group else { - if(recursive){ - key = lab.FindKeyword(ui.GetString("KEYWORD"),Pvl::Traverse); - } else { - key = lab[ui.GetString("KEYWORD")]; - } + if(recursive) { + key = lab.FindKeyword(ui.GetString("KEYWORD"), Pvl::Traverse); + } + else { + key = lab[ui.GetString("KEYWORD")]; + } } iString value; - if (ui.WasEntered("KEYINDEX")) { + if(ui.WasEntered("KEYINDEX")) { int i = ui.GetInteger("KEYINDEX"); // Make sure they requested a value inside the range of the list - if (key.Size() < i) { + if(key.Size() < i) { string msg = "The value entered for [KEYINDEX] is out of the array "; msg += "bounds for the keyword [" + ui.GetString("KEYWORD") + "]"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Get the keyword value else value = key[i-1]; } else { // Push the whole list into a iString and clean it up before returning it - if (key.Size() > 1) { + if(key.Size() > 1) { ostringstream os; os << key; iString temp = os.str(); @@ -98,15 +100,15 @@ void IsisMain() { } // Just get the keyword value since it isnt a list else value = (string)key; - } + } - if (ui.GetBoolean("UPPER")) value.UpCase(); + if(ui.GetBoolean("UPPER")) value.UpCase(); // Construct a label with the results PvlGroup results("Results"); - results += PvlKeyword ("From", labelFile); - results += PvlKeyword (ui.GetString("KEYWORD"),value); - if (ui.IsInteractive()) { + results += PvlKeyword("From", labelFile); + results += PvlKeyword(ui.GetString("KEYWORD"), value); + if(ui.IsInteractive()) { Application::GuiLog(results); } else { @@ -117,7 +119,7 @@ void IsisMain() { } //Helper function to output the input file to log. -void helperButtonLog () { +void helperButtonLog() { UserInterface &ui = Application::GetUserInterface(); string file(ui.GetFilename("FROM")); Pvl p; diff --git a/isis/src/base/apps/getsn/getsn.cpp b/isis/src/base/apps/getsn/getsn.cpp index ed514e4776..9c699f2ca6 100644 --- a/isis/src/base/apps/getsn/getsn.cpp +++ b/isis/src/base/apps/getsn/getsn.cpp @@ -20,7 +20,7 @@ void IsisMain() { // Set Preferences to always turn off Terminal Output PvlGroup &grp = Isis::Preference::Preferences().FindGroup("SessionLog", Isis::Pvl::Traverse); grp["TerminalOutput"].SetValue("Off"); - + // Open the input cube UserInterface &ui = Application::GetUserInterface(); Cube cube; @@ -37,28 +37,28 @@ void IsisMain() { PvlGroup sn("Results"); - if(WriteFile) sn += PvlKeyword("Filename",from); - if(WriteSN) sn += PvlKeyword("SerialNumber",SerialNumber::Compose(*label,ui.GetBoolean("DEFAULT"))); - if(WriteObservation) sn += PvlKeyword("ObservationNumber",ObservationNumber::Compose(*label,ui.GetBoolean("DEFAULT"))); + if(WriteFile) sn += PvlKeyword("Filename", from); + if(WriteSN) sn += PvlKeyword("SerialNumber", SerialNumber::Compose(*label, ui.GetBoolean("DEFAULT"))); + if(WriteObservation) sn += PvlKeyword("ObservationNumber", ObservationNumber::Compose(*label, ui.GetBoolean("DEFAULT"))); if(ui.WasEntered("TO")) { // Create a serial number and observation number for this cube & put it in a pvlgroup for output Pvl pvl; - pvl.AddGroup( sn ); - if( ui.GetBoolean("APPEND") ) - pvl.Append( ui.GetFilename("TO") ); + pvl.AddGroup(sn); + if(ui.GetBoolean("APPEND")) + pvl.Append(ui.GetFilename("TO")); else - pvl.Write( ui.GetFilename("TO") ); + pvl.Write(ui.GetFilename("TO")); // Construct a label with the results - if (ui.IsInteractive()) { + if(ui.IsInteractive()) { Application::GuiLog(sn); } } else { if(WriteFile) cout << from << endl; - if(WriteSN) cout << SerialNumber::Compose(*label,ui.GetBoolean("DEFAULT")) << endl; - if(WriteObservation) cout << ObservationNumber::Compose(*label,ui.GetBoolean("DEFAULT")) << endl; + if(WriteSN) cout << SerialNumber::Compose(*label, ui.GetBoolean("DEFAULT")) << endl; + if(WriteObservation) cout << ObservationNumber::Compose(*label, ui.GetBoolean("DEFAULT")) << endl; } // Write the results to the log but not the terminal SessionLog::TheLog().AddResults(sn); diff --git a/isis/src/base/apps/gradient/gradient.cpp b/isis/src/base/apps/gradient/gradient.cpp index 38bbe11866..b41fa3dcfa 100644 --- a/isis/src/base/apps/gradient/gradient.cpp +++ b/isis/src/base/apps/gradient/gradient.cpp @@ -2,71 +2,71 @@ #include "ProcessByBoxcar.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void robertGradient (Buffer &in, double &v); -void sobelGradient (Buffer &in, double &v); +void robertGradient(Buffer &in, double &v); +void sobelGradient(Buffer &in, double &v); void IsisMain() { - + ProcessByBoxcar p; UserInterface &ui = Application::GetUserInterface(); // Open the input cube - p.SetInputCube ("FROM"); + p.SetInputCube("FROM"); // Allocate the output cube - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); // Which gradient? - string gradType = ui.GetString ("GRADTYPE"); + string gradType = ui.GetString("GRADTYPE"); // Set boxcar size depending on the gradient type - if (gradType == "SOBEL") { - p.SetBoxcarSize (3,3); - p.StartProcess (sobelGradient); + if(gradType == "SOBEL") { + p.SetBoxcarSize(3, 3); + p.StartProcess(sobelGradient); } - else if (gradType == "ROBERTS") { - p.SetBoxcarSize (2,2); - p.StartProcess (robertGradient); + else if(gradType == "ROBERTS") { + p.SetBoxcarSize(2, 2); + p.StartProcess(robertGradient); } - p.EndProcess (); + p.EndProcess(); } // Sobel gradient filter -void sobelGradient (Buffer &in,double &v) { +void sobelGradient(Buffer &in, double &v) { bool specials = false; - for (int i=0; iSetBrickSize (samps,1,1); + if(ui.GetString("DIRECTION") == "HORIZONTAL") { + p = new ProcessByLine; + // we will only process 1 line at a time + p->SetBrickSize(samps, 1, 1); } else { - p = new ProcessBySample; - // we will only process 1 sample at a time - p->SetBrickSize (1,lines,1); + p = new ProcessBySample; + // we will only process 1 sample at a time + p->SetBrickSize(1, lines, 1); } //Make the cube - p->SetOutputCube (ui.GetFilename("TO"),att,samps,lines); + p->SetOutputCube(ui.GetFilename("TO"), att, samps, lines); p->StartProcess(GreyScale); p->EndProcess(); } -void GreyScale (Buffer &out) { +void GreyScale(Buffer &out) { int size = out.size(); - for (int i=0; i - -#include "ProcessByLine.h" -#include "Projection.h" -#include "ProjectionFactory.h" -#include "Camera.h" -#include "CameraFactory.h" -#include "GroundGrid.h" -#include "UniversalGroundMap.h" - -using namespace std; -using namespace Isis; - -void imageGrid(Buffer &in, Buffer &out); -void groundGrid(Buffer &in, Buffer &out); - -void createGroundImage(Camera *cam, Projection *proj); - -bool outline, ticks, diagonalTicks; -int baseLine, baseSample, lineInc, sampleInc, tickSize; -double baseLat, baseLon, latInc, lonInc; - -int inputSamples, inputLines; -GroundGrid *latLonGrid; - -void IsisMain() { - latLonGrid = NULL; - - // We will be processing by line - ProcessByLine p; - Cube *icube = p.SetInputCube("FROM"); - - UserInterface &ui = Application::GetUserInterface(); - string mode = ui.GetString("MODE"); - - outline = ui.GetBoolean("OUTLINE"); - ticks = ui.GetBoolean("TICKS"); - - if(ticks) { - tickSize = ui.GetInteger("TICKSIZE") / 2; - diagonalTicks = ui.GetBoolean("DIAGONALTICKS"); - } - - inputSamples = icube->Samples(); - inputLines = icube->Lines(); - - // Line & sample based grid - if(mode == "IMAGE") { - p.SetOutputCube("TO"); - baseLine = ui.GetInteger("BASELINE"); - baseSample = ui.GetInteger("BASESAMPLE"); - lineInc = ui.GetInteger("LINC"); - sampleInc = ui.GetInteger("SINC"); - p.StartProcess(imageGrid); - p.EndProcess(); - } - // Lat/Lon based grid - else { - CubeAttributeOutput oatt("+32bit"); - p.SetOutputCube(ui.GetFilename("TO"), oatt, icube->Samples(), - icube->Lines(), icube->Bands()); - - baseLat = ui.GetDouble("BASELAT"); - baseLon = ui.GetDouble("BASELON"); - latInc = ui.GetDouble("LATINC"); - lonInc = ui.GetDouble("LONINC"); - - UniversalGroundMap *gmap = new UniversalGroundMap(*icube); - latLonGrid = new GroundGrid(gmap, ticks, icube->Samples(), icube->Lines()); - - Progress progress; - progress.SetText("Calculating Grid"); - - latLonGrid->CreateGrid(baseLat, baseLon, latInc, lonInc, &progress); - - p.StartProcess(groundGrid); - p.EndProcess(); - - delete latLonGrid; - latLonGrid = NULL; - - delete gmap; - gmap = NULL; - } -} - -bool imageDrawLine(int line) { - return (line % lineInc == baseLine % lineInc); -} - -bool imageDrawSample(int sample) { - return (sample % sampleInc == baseSample % sampleInc); -} - -// Line processing routine -void imageGrid(Buffer &in, Buffer &out) { - for(int samp = 1; samp <= in.size(); samp ++) { - out[samp - 1] = in[samp - 1]; - - if(!ticks) { - if(imageDrawSample(samp) || imageDrawLine(in.Line())) - out[samp - 1] = Isis::Hrs; - } - // ticks! - else { - // tickSize is the width or height divided by 2, so integer rounding - // takes care of the current sample/line while doing +/- tickSize - // creates the appropriate width and height. - - // Vertical/Horizontal Ticks - if(!diagonalTicks) { - // horizontal test - for(int sampleTest = samp - tickSize; - (sampleTest <= samp + tickSize) && (out[samp-1] != Isis::Hrs); - sampleTest ++) { - if(imageDrawLine(in.Line()) && imageDrawSample(sampleTest)) { - out[samp - 1] = Isis::Hrs; - } - } - - // vertical test - for(int lineTest = in.Line() - tickSize; - (lineTest <= in.Line() + tickSize) && (out[samp-1] != Isis::Hrs); - lineTest ++) { - if(imageDrawLine(lineTest) && imageDrawSample(samp)) { - out[samp-1] = Isis::Hrs; - } - } - } - // Diagonal Ticks - else { - // top left to bottom right - int sampleTest = samp - tickSize; - int lineTest = in.Line() - tickSize; - - while((out[samp-1] != Isis::Hrs) && - (lineTest <= in.Line() + tickSize) && - (sampleTest <= samp + tickSize)) { - if(imageDrawLine(lineTest) && imageDrawSample(sampleTest)) { - out[samp-1] = Isis::Hrs; - } - - sampleTest ++; - lineTest ++; - } - - // top right to bottom left - sampleTest = samp + tickSize; - lineTest = in.Line() - tickSize; - - while((out[samp-1] != Isis::Hrs) && - (lineTest <= in.Line() + tickSize) && - (sampleTest >= samp - tickSize)) { - if(imageDrawLine(lineTest) && imageDrawSample(sampleTest)) { - out[samp-1] = Isis::Hrs; - } - - sampleTest --; - lineTest ++; - } - } - } - } - - // draw outline - if(outline) { - if(in.Line() == 1 || in.Line() == inputLines) { - for(int i = 0; i < in.size(); i++) { - out[i] = Isis::Hrs; - } - } - else { - out[0] = Isis::Hrs; - out[out.size()-1] = Isis::Hrs; - } - } -} - -// Line processing routine -void groundGrid(Buffer &in, Buffer &out) { - for(int samp = 1; samp <= in.SampleDimension(); samp++) { - if(!ticks) { - if(latLonGrid->PixelOnGrid(samp - 1, in.Line() - 1)) { - out[samp-1] = Isis::Hrs; - } - else { - out[samp-1] = in[samp-1]; - } - } - else { - // We need to check the grids for overlaps near current point - out[samp-1] = in[samp-1]; - - // tickSize is the width or height divided by 2, so integer rounding - // takes care of the current sample/line while doing +/- tickSize - // creates the appropriate width and height. - - // Vertical/Horizontal Ticks - if(!diagonalTicks) { - // horizontal test - for(int sampleTest = samp - 1 - tickSize; - (sampleTest < samp + tickSize) && (out[samp-1] != Isis::Hrs); - sampleTest ++) { - if(latLonGrid->PixelOnGrid(sampleTest, in.Line() - 1, true) && - latLonGrid->PixelOnGrid(sampleTest, in.Line() - 1, false)) { - out[samp-1] = Isis::Hrs; - } - } - - // vertical test - for(int lineTest = in.Line() - 1 - tickSize; - (lineTest < in.Line() + tickSize) && (out[samp-1] != Isis::Hrs); - lineTest ++) { - if(latLonGrid->PixelOnGrid(samp - 1, lineTest, true) && - latLonGrid->PixelOnGrid(samp - 1, lineTest, false)) { - out[samp-1] = Isis::Hrs; - } - } - } - // Diagonal ticks - else { - // top left to bottom right - int sampleTest = samp - 1 - tickSize; - int lineTest = in.Line() - 1 - tickSize; - - - while((out[samp-1] != Isis::Hrs) && (lineTest < in.Line() + tickSize) && - (sampleTest < samp + tickSize)) { - if(latLonGrid->PixelOnGrid(sampleTest, lineTest, true) && - latLonGrid->PixelOnGrid(sampleTest, lineTest, false)) { - out[samp-1] = Isis::Hrs; - } - - sampleTest ++; - lineTest ++; - } - - // top right to bottom left - sampleTest = samp - 1 + tickSize; - lineTest = in.Line() - 1 - tickSize; - - while((out[samp-1] != Isis::Hrs) && (lineTest < in.Line() + tickSize) && - (sampleTest >= samp - 1 - tickSize)) { - if(latLonGrid->PixelOnGrid(sampleTest, lineTest, true) && - latLonGrid->PixelOnGrid(sampleTest, lineTest, false)) { - out[samp-1] = Isis::Hrs; - } - - sampleTest --; - lineTest ++; - } - } - } - } - - // draw outline - if(outline) { - if(in.Line() == 1 || in.Line() == inputLines) { - for(int i = 0; i < in.size(); i++) { - out[i] = Isis::Hrs; - } - } - else { - out[0] = Isis::Hrs; - out[out.size()-1] = Isis::Hrs; - } - } -} +#include "Isis.h" + +#include + +#include "ProcessByLine.h" +#include "Projection.h" +#include "ProjectionFactory.h" +#include "Camera.h" +#include "CameraFactory.h" +#include "GroundGrid.h" +#include "UniversalGroundMap.h" + +using namespace std; +using namespace Isis; + +void imageGrid(Buffer &in, Buffer &out); +void groundGrid(Buffer &in, Buffer &out); + +void createGroundImage(Camera *cam, Projection *proj); + +bool outline, ticks, diagonalTicks; +int baseLine, baseSample, lineInc, sampleInc, tickSize; +double baseLat, baseLon, latInc, lonInc; + +int inputSamples, inputLines; +GroundGrid *latLonGrid; + +void IsisMain() { + latLonGrid = NULL; + + // We will be processing by line + ProcessByLine p; + Cube *icube = p.SetInputCube("FROM"); + + UserInterface &ui = Application::GetUserInterface(); + string mode = ui.GetString("MODE"); + + outline = ui.GetBoolean("OUTLINE"); + ticks = ui.GetBoolean("TICKS"); + + if(ticks) { + tickSize = ui.GetInteger("TICKSIZE") / 2; + diagonalTicks = ui.GetBoolean("DIAGONALTICKS"); + } + + inputSamples = icube->Samples(); + inputLines = icube->Lines(); + + // Line & sample based grid + if(mode == "IMAGE") { + p.SetOutputCube("TO"); + baseLine = ui.GetInteger("BASELINE"); + baseSample = ui.GetInteger("BASESAMPLE"); + lineInc = ui.GetInteger("LINC"); + sampleInc = ui.GetInteger("SINC"); + p.StartProcess(imageGrid); + p.EndProcess(); + } + // Lat/Lon based grid + else { + CubeAttributeOutput oatt("+32bit"); + p.SetOutputCube(ui.GetFilename("TO"), oatt, icube->Samples(), + icube->Lines(), icube->Bands()); + + baseLat = ui.GetDouble("BASELAT"); + baseLon = ui.GetDouble("BASELON"); + latInc = ui.GetDouble("LATINC"); + lonInc = ui.GetDouble("LONINC"); + + UniversalGroundMap *gmap = new UniversalGroundMap(*icube); + latLonGrid = new GroundGrid(gmap, ticks, icube->Samples(), icube->Lines()); + + Progress progress; + progress.SetText("Calculating Grid"); + + latLonGrid->CreateGrid(baseLat, baseLon, latInc, lonInc, &progress); + + p.StartProcess(groundGrid); + p.EndProcess(); + + delete latLonGrid; + latLonGrid = NULL; + + delete gmap; + gmap = NULL; + } +} + +bool imageDrawLine(int line) { + return (line % lineInc == baseLine % lineInc); +} + +bool imageDrawSample(int sample) { + return (sample % sampleInc == baseSample % sampleInc); +} + +// Line processing routine +void imageGrid(Buffer &in, Buffer &out) { + for(int samp = 1; samp <= in.size(); samp ++) { + out[samp - 1] = in[samp - 1]; + + if(!ticks) { + if(imageDrawSample(samp) || imageDrawLine(in.Line())) + out[samp - 1] = Isis::Hrs; + } + // ticks! + else { + // tickSize is the width or height divided by 2, so integer rounding + // takes care of the current sample/line while doing +/- tickSize + // creates the appropriate width and height. + + // Vertical/Horizontal Ticks + if(!diagonalTicks) { + // horizontal test + for(int sampleTest = samp - tickSize; + (sampleTest <= samp + tickSize) && (out[samp-1] != Isis::Hrs); + sampleTest ++) { + if(imageDrawLine(in.Line()) && imageDrawSample(sampleTest)) { + out[samp - 1] = Isis::Hrs; + } + } + + // vertical test + for(int lineTest = in.Line() - tickSize; + (lineTest <= in.Line() + tickSize) && (out[samp-1] != Isis::Hrs); + lineTest ++) { + if(imageDrawLine(lineTest) && imageDrawSample(samp)) { + out[samp-1] = Isis::Hrs; + } + } + } + // Diagonal Ticks + else { + // top left to bottom right + int sampleTest = samp - tickSize; + int lineTest = in.Line() - tickSize; + + while((out[samp-1] != Isis::Hrs) && + (lineTest <= in.Line() + tickSize) && + (sampleTest <= samp + tickSize)) { + if(imageDrawLine(lineTest) && imageDrawSample(sampleTest)) { + out[samp-1] = Isis::Hrs; + } + + sampleTest ++; + lineTest ++; + } + + // top right to bottom left + sampleTest = samp + tickSize; + lineTest = in.Line() - tickSize; + + while((out[samp-1] != Isis::Hrs) && + (lineTest <= in.Line() + tickSize) && + (sampleTest >= samp - tickSize)) { + if(imageDrawLine(lineTest) && imageDrawSample(sampleTest)) { + out[samp-1] = Isis::Hrs; + } + + sampleTest --; + lineTest ++; + } + } + } + } + + // draw outline + if(outline) { + if(in.Line() == 1 || in.Line() == inputLines) { + for(int i = 0; i < in.size(); i++) { + out[i] = Isis::Hrs; + } + } + else { + out[0] = Isis::Hrs; + out[out.size()-1] = Isis::Hrs; + } + } +} + +// Line processing routine +void groundGrid(Buffer &in, Buffer &out) { + for(int samp = 1; samp <= in.SampleDimension(); samp++) { + if(!ticks) { + if(latLonGrid->PixelOnGrid(samp - 1, in.Line() - 1)) { + out[samp-1] = Isis::Hrs; + } + else { + out[samp-1] = in[samp-1]; + } + } + else { + // We need to check the grids for overlaps near current point + out[samp-1] = in[samp-1]; + + // tickSize is the width or height divided by 2, so integer rounding + // takes care of the current sample/line while doing +/- tickSize + // creates the appropriate width and height. + + // Vertical/Horizontal Ticks + if(!diagonalTicks) { + // horizontal test + for(int sampleTest = samp - 1 - tickSize; + (sampleTest < samp + tickSize) && (out[samp-1] != Isis::Hrs); + sampleTest ++) { + if(latLonGrid->PixelOnGrid(sampleTest, in.Line() - 1, true) && + latLonGrid->PixelOnGrid(sampleTest, in.Line() - 1, false)) { + out[samp-1] = Isis::Hrs; + } + } + + // vertical test + for(int lineTest = in.Line() - 1 - tickSize; + (lineTest < in.Line() + tickSize) && (out[samp-1] != Isis::Hrs); + lineTest ++) { + if(latLonGrid->PixelOnGrid(samp - 1, lineTest, true) && + latLonGrid->PixelOnGrid(samp - 1, lineTest, false)) { + out[samp-1] = Isis::Hrs; + } + } + } + // Diagonal ticks + else { + // top left to bottom right + int sampleTest = samp - 1 - tickSize; + int lineTest = in.Line() - 1 - tickSize; + + + while((out[samp-1] != Isis::Hrs) && (lineTest < in.Line() + tickSize) && + (sampleTest < samp + tickSize)) { + if(latLonGrid->PixelOnGrid(sampleTest, lineTest, true) && + latLonGrid->PixelOnGrid(sampleTest, lineTest, false)) { + out[samp-1] = Isis::Hrs; + } + + sampleTest ++; + lineTest ++; + } + + // top right to bottom left + sampleTest = samp - 1 + tickSize; + lineTest = in.Line() - 1 - tickSize; + + while((out[samp-1] != Isis::Hrs) && (lineTest < in.Line() + tickSize) && + (sampleTest >= samp - 1 - tickSize)) { + if(latLonGrid->PixelOnGrid(sampleTest, lineTest, true) && + latLonGrid->PixelOnGrid(sampleTest, lineTest, false)) { + out[samp-1] = Isis::Hrs; + } + + sampleTest --; + lineTest ++; + } + } + } + } + + // draw outline + if(outline) { + if(in.Line() == 1 || in.Line() == inputLines) { + for(int i = 0; i < in.size(); i++) { + out[i] = Isis::Hrs; + } + } + else { + out[0] = Isis::Hrs; + out[out.size()-1] = Isis::Hrs; + } + } +} diff --git a/isis/src/base/apps/handmos/handmos.cpp b/isis/src/base/apps/handmos/handmos.cpp index c81c774fb0..b08d7dd793 100644 --- a/isis/src/base/apps/handmos/handmos.cpp +++ b/isis/src/base/apps/handmos/handmos.cpp @@ -3,123 +3,123 @@ #include "ProcessByLine.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void CreateMosaic (Buffer &buf); +void CreateMosaic(Buffer &buf); /** - * Handmos Application- Allows to hand place an image on the - * mosaic with input, mosaic and band priorities. Band priority allows the - * user the option to place a pixel on the mosaic based on the pixel in the - * chosen band. The band can be specified by band number or Keyword as it - * appears in BandBin group of the PVL label. Also has the ability to track the - * origin by adding a band to mosaic at the time of creation. As input images - * are placed on the mosaic, the are stored as records in the table "InputImages" - * in the mosaic. Ability to copy HS, LS, NULL values from input onto the mosaic. + * Handmos Application- Allows to hand place an image on the + * mosaic with input, mosaic and band priorities. Band priority allows the + * user the option to place a pixel on the mosaic based on the pixel in the + * chosen band. The band can be specified by band number or Keyword as it + * appears in BandBin group of the PVL label. Also has the ability to track the + * origin by adding a band to mosaic at the time of creation. As input images + * are placed on the mosaic, the are stored as records in the table "InputImages" + * in the mosaic. Ability to copy HS, LS, NULL values from input onto the mosaic. * */ void IsisMain() { - // See if we need to create the output file + // See if we need to create the output file UserInterface &ui = Application::GetUserInterface(); - - int ns,nl,nb; - + + int ns, nl, nb; + ProcessMosaic p; bool bTrack = ui.GetBoolean("TRACK"); - p.SetTrackFlag(bTrack); + p.SetTrackFlag(bTrack); - if (ui.GetString("CREATE") == "YES") { + if(ui.GetString("CREATE") == "YES") { ns = ui.GetInteger("NSAMPLES"); nl = ui.GetInteger("NLINES"); nb = ui.GetInteger("NBANDS"); - // Create the origin band if the Track Flag is set - if (bTrack) { - nb += 1; - } - p.SetCreateFlag(true); + // Create the origin band if the Track Flag is set + if(bTrack) { + nb += 1; + } + p.SetCreateFlag(true); - ProcessByLine bl; + ProcessByLine bl; bl.Progress()->SetText("Initializing base mosaic"); bl.SetInputCube("FROM"); - bl.SetOutputCube("MOSAIC",ns,nl,nb); + bl.SetOutputCube("MOSAIC", ns, nl, nb); bl.ClearInputCubes(); bl.StartProcess(CreateMosaic); bl.EndProcess(); - } + } - // Set the input cube for the process object + // Set the input cube for the process object p.SetBandBinMatch(ui.GetBoolean("MATCHBANDBIN")); p.Progress()->SetText("Mosaicking"); // Set up the mosaic priority, either the input cube will be - // placed ontop of the mosaic or beneath it + // placed ontop of the mosaic or beneath it ui = Application::GetUserInterface(); MosaicPriority priority; - string sType; - if (ui.GetString("PRIORITY") == "BENEATH") { + string sType; + if(ui.GetString("PRIORITY") == "BENEATH") { priority = mosaic; } - else if (ui.GetString("PRIORITY") == "ONTOP") { - priority = input; + else if(ui.GetString("PRIORITY") == "ONTOP") { + priority = input; } - else { - priority = band; - sType = ui.GetString("TYPE"); - if (sType=="BANDNUMBER") { - p.SetBandNumber(ui.GetInteger("NUMBER")); - } - else { - //keyname & key value - p.SetBandKeyWord(ui.GetString("KEYNAME"), ui.GetString("KEYVALUE")); - } - // Band Criteria - BandCriteria eCriteria = Lesser; - if (ui.GetString("CRITERIA") == "GREATER") - eCriteria = Greater; - p.SetBandCriteria(eCriteria); + else { + priority = band; + sType = ui.GetString("TYPE"); + if(sType == "BANDNUMBER") { + p.SetBandNumber(ui.GetInteger("NUMBER")); + } + else { + //keyname & key value + p.SetBandKeyWord(ui.GetString("KEYNAME"), ui.GetString("KEYVALUE")); + } + // Band Criteria + BandCriteria eCriteria = Lesser; + if(ui.GetString("CRITERIA") == "GREATER") + eCriteria = Greater; + p.SetBandCriteria(eCriteria); } - + //set priority p.SetPriority(priority); - // Get the value for HS, LS, NULL flags whether to transfer the special pixels + // Get the value for HS, LS, NULL flags whether to transfer the special pixels // onto the mosaic. Holds good for "ontop" and "band" priorities only - if (priority == input || priority == band) { - p.SetHighSaturationFlag(ui.GetBoolean("HIGHSATURATION")); - p.SetLowSaturationFlag (ui.GetBoolean("LOWSATURATION")); - p.SetNullFlag(ui.GetBoolean("NULL")); - } + if(priority == input || priority == band) { + p.SetHighSaturationFlag(ui.GetBoolean("HIGHSATURATION")); + p.SetLowSaturationFlag(ui.GetBoolean("LOWSATURATION")); + p.SetNullFlag(ui.GetBoolean("NULL")); + } // Get the starting line/sample/band to place the input cube - int outSample = ui.GetInteger ("OUTSAMPLE") - ui.GetInteger ("INSAMPLE") + 1; - int outLine = ui.GetInteger ("OUTLINE") - ui.GetInteger ("INLINE") + 1; - int outBand = ui.GetInteger ("OUTBAND") - ui.GetInteger ("INBAND") + 1; + int outSample = ui.GetInteger("OUTSAMPLE") - ui.GetInteger("INSAMPLE") + 1; + int outLine = ui.GetInteger("OUTLINE") - ui.GetInteger("INLINE") + 1; + int outBand = ui.GetInteger("OUTBAND") - ui.GetInteger("INBAND") + 1; // Set the input mosaic - p.SetInputCube ("FROM"); + p.SetInputCube("FROM"); // Set the output mosaic - Cube* to = p.SetOutputCube ("MOSAIC"); - + Cube *to = p.SetOutputCube("MOSAIC"); + p.WriteHistory(*to); // Place the input in the mosaic - //p.StartProcess(outSample, outLine, outBand, priority); + //p.StartProcess(outSample, outLine, outBand, priority); p.StartProcess(outSample, outLine, outBand); - if (bTrack != p.GetTrackFlag()) { - ui.Clear("TRACK"); - ui.PutBoolean("TRACK", p.GetTrackFlag()); - } + if(bTrack != p.GetTrackFlag()) { + ui.Clear("TRACK"); + ui.PutBoolean("TRACK", p.GetTrackFlag()); + } p.EndProcess(); // Log the changes to NBANDS and to TRACK if any - PvlObject hist = Isis::iApp->History(); - Isis::iApp->Log(hist.FindGroup("UserParameters")); + PvlObject hist = Isis::iApp->History(); + Isis::iApp->Log(hist.FindGroup("UserParameters")); PvlGroup imgPosition("ImageLocation"); int iStartLine = p.GetInputStartLine(); int iStartSample = p.GetInputStartSample(); @@ -130,13 +130,13 @@ void IsisMain() { } /** * Initialize the mosaic to defaults - * + * * @author sprasad (10/14/2009) - * - * @param buf + * + * @param buf */ -void CreateMosaic (Buffer &buf) { - for (int i=0; iSetMaximumSteps(icube->Lines()); p.Progress()->CheckStatus(); LineManager line(*icube); - for (int i=1; i<=icube->Lines(); i++) { + for(int i = 1; i <= icube->Lines(); i++) { line.SetLine(i); icube->Read(line); - hist.AddData(line.DoubleBuffer(),line.size()); + hist.AddData(line.DoubleBuffer(), line.size()); p.Progress()->CheckStatus(); } if(!ui.IsInteractive() || ui.WasEntered("TO")) { // Write the results - if (!ui.WasEntered("TO")) { + if(!ui.WasEntered("TO")) { string msg = "The [TO] parameter must be entered"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } string outfile = ui.GetFilename("TO"); ofstream fout; - fout.open (outfile.c_str()); - + fout.open(outfile.c_str()); + fout << "Cube: " << ui.GetFilename("FROM") << endl; fout << "Band: " << icube->Bands() << endl; fout << "Average: " << hist.Average() << endl; @@ -72,21 +72,21 @@ void IsisMain() { fout << "Lrs Pixels: " << hist.LrsPixels() << endl; fout << "His Pixels: " << hist.HisPixels() << endl; fout << "Hrs Pixels: " << hist.HrsPixels() << endl; - + // Write histogram in tabular format fout << endl; fout << endl; fout << "DN,Pixels,CumulativePixels,Percent,CumulativePercent" << endl; - + Isis::BigInt total = 0; double cumpct = 0.0; - - for (int i=0; i 0) { + + for(int i = 0; i < hist.Bins(); i++) { + if(hist.BinCount(i) > 0) { total += hist.BinCount(i); double pct = (double)hist.BinCount(i) / hist.ValidPixels() * 100.; cumpct += pct; - + fout << hist.BinMiddle(i) << ","; fout << hist.BinCount(i) << ","; fout << total << ","; @@ -97,10 +97,10 @@ void IsisMain() { fout.close(); } // If we are in gui mode, create a histogram plot - if (ui.IsInteractive()) { + if(ui.IsInteractive()) { // Set the title for the dialog string title; - if (ui.WasEntered("TITLE")) { + if(ui.WasEntered("TITLE")) { title = ui.GetString("TITLE"); } else { @@ -112,28 +112,28 @@ void IsisMain() { Qisis::HistogramToolWindow *plot = new Qisis::HistogramToolWindow(title.c_str(), ui.TheGui()); // Set the xaxis title if they entered one - if (ui.WasEntered("XAXIS")) { + if(ui.WasEntered("XAXIS")) { string xaxis(ui.GetString("XAXIS")); - plot->setAxisLabel(QwtPlot::xBottom,xaxis.c_str()); + plot->setAxisLabel(QwtPlot::xBottom, xaxis.c_str()); } // Set the yLeft axis title if they entered one - if (ui.WasEntered("Y1AXIS")) { + if(ui.WasEntered("Y1AXIS")) { string yaxis(ui.GetString("Y1AXIS")); - plot->setAxisLabel(QwtPlot::yLeft,yaxis.c_str()); + plot->setAxisLabel(QwtPlot::yLeft, yaxis.c_str()); } // Set the yRight axis title if they entered one - if (ui.WasEntered("Y2AXIS")) { + if(ui.WasEntered("Y2AXIS")) { string y2axis(ui.GetString("Y2AXIS")); - plot->setAxisLabel(QwtPlot::yRight,y2axis.c_str()); + plot->setAxisLabel(QwtPlot::yRight, y2axis.c_str()); } //Transfer data from histogram to the plotcurve - std::vector xarray,yarray,y2array; + std::vector xarray, yarray, y2array; double cumpct = 0.0; - for (int i=0; i 0) { + for(int i = 0; i < hist.Bins(); i++) { + if(hist.BinCount(i) > 0) { xarray.push_back(hist.BinMiddle(i)); yarray.push_back(hist.BinCount(i)); @@ -163,37 +163,37 @@ void IsisMain() { QwtArray values(yarray.size()); double maxYValue = DBL_MIN; double minYValue = DBL_MAX; - // --------------------------------------------- + // --------------------------------------------- for(unsigned int y = 0; y < yarray.size(); y++) { intervals[y] = QwtDoubleInterval(xarray[y], xarray[y] + hist.BinSize()); - - values[y] = yarray[y]; - if(values[y] > maxYValue) maxYValue = values[y]; + + values[y] = yarray[y]; + if(values[y] > maxYValue) maxYValue = values[y]; if(values[y] < minYValue) minYValue = values[y]; } - + histCurve->setData(QwtIntervalData(intervals, values)); - cdfCurve->setData(&xarray[0],&y2array[0],xarray.size()); + cdfCurve->setData(&xarray[0], &y2array[0], xarray.size()); plot->add(histCurve); plot->add(cdfCurve); plot->fillTable(); - plot->setScale(QwtPlot::yLeft,0,maxYValue); - plot->setScale(QwtPlot::xBottom,hist.Minimum(),hist.Maximum()); + plot->setScale(QwtPlot::yLeft, 0, maxYValue); + plot->setScale(QwtPlot::xBottom, hist.Minimum(), hist.Maximum()); QLabel *label = new QLabel(" Average = " + QString::number(hist.Average()) + '\n' + - "\n Minimum = " + QString::number(hist.Minimum()) + '\n' + - "\n Maximum = " + QString::number(hist.Maximum()) + '\n' + - "\n Stand. Dev.= " + QString::number(hist.StandardDeviation()) + '\n' + - "\n Variance = " + QString::number(hist.Variance()) + '\n' + - "\n Median = " + QString::number(hist.Median()) + '\n' + - "\n Mode = " + QString::number(hist.Mode()) +'\n' + - "\n Skew = " + QString::number(hist.Skew()), plot); + "\n Minimum = " + QString::number(hist.Minimum()) + '\n' + + "\n Maximum = " + QString::number(hist.Maximum()) + '\n' + + "\n Stand. Dev.= " + QString::number(hist.StandardDeviation()) + '\n' + + "\n Variance = " + QString::number(hist.Variance()) + '\n' + + "\n Median = " + QString::number(hist.Median()) + '\n' + + "\n Mode = " + QString::number(hist.Mode()) + '\n' + + "\n Skew = " + QString::number(hist.Skew()), plot); plot->getDockWidget()->setWidget(label); - + plot->showWindow(); } p.EndProcess(); diff --git a/isis/src/base/apps/histeq/histeq.cpp b/isis/src/base/apps/histeq/histeq.cpp index 5bc4cad0a4..beb72d5b19 100644 --- a/isis/src/base/apps/histeq/histeq.cpp +++ b/isis/src/base/apps/histeq/histeq.cpp @@ -5,7 +5,7 @@ #include "Stretch.h" #include "Histogram.h" -using namespace std; +using namespace std; using namespace Isis; Stretch stretch; @@ -13,60 +13,60 @@ void remap(Buffer &in, Buffer &out); void IsisMain() { - // Setup the input and output cubes - ProcessByLine p; // used for getting histograms from input cubes - Cube *icube = p.SetInputCube("FROM", Isis::OneBand); - p.SetOutputCube ("TO"); + // Setup the input and output cubes + ProcessByLine p; // used for getting histograms from input cubes + Cube *icube = p.SetInputCube("FROM", Isis::OneBand); + p.SetOutputCube("TO"); - // Histogram parameters - UserInterface &ui = Application::GetUserInterface(); - double minimum = ui.GetDouble("MINPER"); - double maximum = ui.GetDouble("MAXPER"); - int increment = ui.GetInteger("INCREMENT"); + // Histogram parameters + UserInterface &ui = Application::GetUserInterface(); + double minimum = ui.GetDouble("MINPER"); + double maximum = ui.GetDouble("MAXPER"); + int increment = ui.GetInteger("INCREMENT"); - // Histograms from input cubes - Histogram *from = icube->Histogram(); - Histogram *match = icube->Histogram(); + // Histograms from input cubes + Histogram *from = icube->Histogram(); + Histogram *match = icube->Histogram(); - double fromMin = from->Percent(minimum); - double fromMax = from->Percent(maximum); - int fromBins = from->Bins(); - double data[fromBins]; - double slope = (fromMax - fromMin) / (fromBins - 1); + double fromMin = from->Percent(minimum); + double fromMax = from->Percent(maximum); + int fromBins = from->Bins(); + double data[fromBins]; + double slope = (fromMax - fromMin) / (fromBins - 1); - // Set "match" to have the same data range and number of bins as "to" - match->SetBins(fromBins); - match->SetValidRange(fromMin, fromMax); - for (int i = 0; i < fromBins; i++) { - data[i] = fromMin + (slope * i); - } - match->AddData(data, fromBins); + // Set "match" to have the same data range and number of bins as "to" + match->SetBins(fromBins); + match->SetValidRange(fromMin, fromMax); + for(int i = 0; i < fromBins; i++) { + data[i] = fromMin + (slope * i); + } + match->AddData(data, fromBins); - stretch.ClearPairs(); - double lastPer = from->Percent(minimum); - stretch.AddPair(lastPer, match->Percent(minimum)); - for (double i = increment+minimum; i < maximum; i += increment) { - double curPer = from->Percent(i); - if (lastPer < curPer) { - if(abs(lastPer - curPer) > DBL_EPSILON) { - stretch.AddPair(curPer, match->Percent(i)); - lastPer = curPer; - } - } + stretch.ClearPairs(); + double lastPer = from->Percent(minimum); + stretch.AddPair(lastPer, match->Percent(minimum)); + for(double i = increment + minimum; i < maximum; i += increment) { + double curPer = from->Percent(i); + if(lastPer < curPer) { + if(abs(lastPer - curPer) > DBL_EPSILON) { + stretch.AddPair(curPer, match->Percent(i)); + lastPer = curPer; + } } - double curPer = from->Percent(maximum); - if (lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { - stretch.AddPair(curPer, match->Percent(maximum)); - } + } + double curPer = from->Percent(maximum); + if(lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { + stretch.AddPair(curPer, match->Percent(maximum)); + } - // Start the processing - p.StartProcess(remap); - p.EndProcess(); + // Start the processing + p.StartProcess(remap); + p.EndProcess(); } // Adjust FROM cumulative distribution to be flatter void remap(Buffer &in, Buffer &out) { - for (int i = 0; i < in.size(); i++) { - out[i] = stretch.Map(in[i]); - } + for(int i = 0; i < in.size(); i++) { + out[i] = stretch.Map(in[i]); + } } // end remap . diff --git a/isis/src/base/apps/histmatch/histmatch.cpp b/isis/src/base/apps/histmatch/histmatch.cpp index 953ed0f3c9..2d58b001fc 100644 --- a/isis/src/base/apps/histmatch/histmatch.cpp +++ b/isis/src/base/apps/histmatch/histmatch.cpp @@ -5,7 +5,7 @@ #include "Stretch.h" #include "Histogram.h" -using namespace std; +using namespace std; using namespace Isis; Stretch stretch; @@ -13,58 +13,58 @@ Stretch stretch; void remap(vector &in, vector &out); void IsisMain() { - // Setup the input and output cubes along with histograms - ProcessByLine p; - Cube *mcube = p.SetInputCube("MATCH", Isis::OneBand); - Histogram *match = mcube->Histogram(); - p.ClearInputCubes(); - Cube *icube = p.SetInputCube("FROM", Isis::OneBand); - Histogram* from = icube->Histogram(); - p.SetOutputCube ("TO"); + // Setup the input and output cubes along with histograms + ProcessByLine p; + Cube *mcube = p.SetInputCube("MATCH", Isis::OneBand); + Histogram *match = mcube->Histogram(); + p.ClearInputCubes(); + Cube *icube = p.SetInputCube("FROM", Isis::OneBand); + Histogram *from = icube->Histogram(); + p.SetOutputCube("TO"); - // Histogram specifications - UserInterface &ui = Application::GetUserInterface(); - double minimum = ui.GetDouble("MINPER"); - double maximum = ui.GetDouble("MAXPER"); + // Histogram specifications + UserInterface &ui = Application::GetUserInterface(); + double minimum = ui.GetDouble("MINPER"); + double maximum = ui.GetDouble("MAXPER"); - stretch.ClearPairs(); + stretch.ClearPairs(); - // CDF mode selected - if (ui.GetString("STRETCH") == "CDF") { - int increment = ui.GetInteger("INCREMENT"); - double lastPer = from->Percent(minimum); - stretch.AddPair(lastPer, match->Percent(minimum)); - for (double i = increment+minimum; i < maximum; i += increment) { - double curPer = from->Percent(i); - if (lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { - stretch.AddPair(curPer, match->Percent(i)); - lastPer = curPer; - } - } - double curPer = from->Percent(maximum); - if (lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { - stretch.AddPair(curPer, match->Percent(maximum)); - } + // CDF mode selected + if(ui.GetString("STRETCH") == "CDF") { + int increment = ui.GetInteger("INCREMENT"); + double lastPer = from->Percent(minimum); + stretch.AddPair(lastPer, match->Percent(minimum)); + for(double i = increment + minimum; i < maximum; i += increment) { + double curPer = from->Percent(i); + if(lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { + stretch.AddPair(curPer, match->Percent(i)); + lastPer = curPer; + } } - - // Modal mode is selected - else { - stretch.AddPair(from->Percent(minimum), match->Percent(minimum)); - stretch.AddPair(from->Mode(), match->Mode()); - stretch.AddPair(from->Percent(maximum), match->Percent(maximum)); + double curPer = from->Percent(maximum); + if(lastPer < curPer && abs(lastPer - curPer) > DBL_EPSILON) { + stretch.AddPair(curPer, match->Percent(maximum)); } + } + + // Modal mode is selected + else { + stretch.AddPair(from->Percent(minimum), match->Percent(minimum)); + stretch.AddPair(from->Mode(), match->Mode()); + stretch.AddPair(from->Percent(maximum), match->Percent(maximum)); + } - // Start the processing - p.StartProcess(remap); - p.EndProcess(); + // Start the processing + p.StartProcess(remap); + p.EndProcess(); } // Adjust FROM histogram to resemble MATCH's histogram void remap(vector &in, vector &out) { - Buffer &from = *in[0]; - Buffer &to = *out[0]; - - for (int i = 0; i < from.size(); i++) { - to[i] = stretch.Map(from[i]); - } + Buffer &from = *in[0]; + Buffer &to = *out[0]; + + for(int i = 0; i < from.size(); i++) { + to[i] = stretch.Map(from[i]); + } } // end remap diff --git a/isis/src/base/apps/hsv2rgb/hsv2rgb.cpp b/isis/src/base/apps/hsv2rgb/hsv2rgb.cpp index c8aa4af925..b7678c23a7 100644 --- a/isis/src/base/apps/hsv2rgb/hsv2rgb.cpp +++ b/isis/src/base/apps/hsv2rgb/hsv2rgb.cpp @@ -6,19 +6,19 @@ #include "Histogram.h" #include "Stretch.h" -using namespace std; +using namespace std; using namespace Isis; -void convert(vector &in, +void convert(vector &in, vector &out); Stretch hueStretch, satStretch, valStretch; double valueScalar; void IsisMain() { - UserInterface &ui = Application::GetUserInterface(); - valueScalar = ui.GetDouble("SCALAR"); - + UserInterface &ui = Application::GetUserInterface(); + valueScalar = ui.GetDouble("SCALAR"); + // Clear out stretch pairs to handle multiple runs hueStretch.ClearPairs(); satStretch.ClearPairs(); @@ -42,7 +42,7 @@ void IsisMain() { valStretch.SetHis(1.0); // Start the processing - ProcessByLine p; + ProcessByLine p; p.SetInputCube("HUE", Isis::OneBand); p.SetInputCube("SATURATION", Isis::OneBand); p.SetInputCube("VALUE", Isis::OneBand); @@ -53,13 +53,13 @@ void IsisMain() { p.StartProcess(convert); p.EndProcess(); -} +} -// Line processing routine +// Line processing routine // This works by building an HSV QColor from the input buffers. This is // converted to RGB format, then the RGB data is sent to the output file buffers. -void convert (vector &in, - vector &out) { +void convert(vector &in, + vector &out) { // Input file buffers Buffer &hue = *in[0]; Buffer &saturation = *in[1]; @@ -70,18 +70,18 @@ void convert (vector &in, Buffer &green = *out[1]; Buffer &blue = *out[2]; - for (int i = 0; i < hue.size(); i++) { + for(int i = 0; i < hue.size(); i++) { // Convert range: [0, 360] -> [0, 1] /** * HSV Stores colors in terms of hue, saturation, and value. The hue determines the color, - * which is an angle around the color wheel. However, QColor::fromHsvF() in the qt library expects a - * percentage around the color wheel and not an angle. For example, 0% means the origin and - * 50% means 180 degrees around the circle. The hue is in degrees and we went it in percentages, so to convert - * this value we divide by 360 degrees. The basic colors are: 0 degrees = RED, - * 60 degrees = YELLOW, 120 degrees = GREEN, 180 degrees = CYAN, 240 degrees = BLUE and - * 300 degrees = PURPLE. - * The saturation is how much grey is in the color (intensity of the color). A saturation value of zero means it's perfect, + * which is an angle around the color wheel. However, QColor::fromHsvF() in the qt library expects a + * percentage around the color wheel and not an angle. For example, 0% means the origin and + * 50% means 180 degrees around the circle. The hue is in degrees and we went it in percentages, so to convert + * this value we divide by 360 degrees. The basic colors are: 0 degrees = RED, + * 60 degrees = YELLOW, 120 degrees = GREEN, 180 degrees = CYAN, 240 degrees = BLUE and + * 300 degrees = PURPLE. + * The saturation is how much grey is in the color (intensity of the color). A saturation value of zero means it's perfect, * while a saturation value of 1 would cause any color to become pure grey. As an example, the color RGB(255,0,0) * is pure so the saturation would be zero. The value is how bright the color is. A value of 0 is always black, * and 100 is the color (if not saturated). @@ -89,7 +89,7 @@ void convert (vector &in, * HUE = COLOR (degrees around the color wheel) * SATURATION = INTENSITY (0-1, 0 being no color/grey) * VALUE = BRIGHTNESS (0 being black) - * + * * For more information, see * http://en.wikipedia.org/wiki/Color_spaces */ @@ -102,7 +102,7 @@ void convert (vector &in, double hueVal = hueStretch.Map(hue[i]); // while hue is less than 0 degrees, increase it (example: -10 degrees would become 350 degrees) - while(hueVal < 0) { + while(hueVal < 0) { hueVal += 360; } @@ -113,7 +113,7 @@ void convert (vector &in, // QColor::fromHsvF expects a percentage around the circle and not degrees, so we divide by 360. hueVal /= 360.0; - + double sat = satStretch.Map(saturation[i]); // Saturation should be between zero and one @@ -137,10 +137,10 @@ void convert (vector &in, val *= valueScalar; QColor hsv = QColor::fromHsvF(hueVal, sat, val); - QColor rgb = hsv.toRgb(); + QColor rgb = hsv.toRgb(); red[i] = rgb.redF(); green[i] = rgb.greenF(); blue[i] = rgb.blueF(); } -} +} diff --git a/isis/src/base/apps/ifft/ifft.cpp b/isis/src/base/apps/ifft/ifft.cpp index 10753b3ee0..925a0502fd 100644 --- a/isis/src/base/apps/ifft/ifft.cpp +++ b/isis/src/base/apps/ifft/ifft.cpp @@ -4,11 +4,11 @@ #include "ProcessByTile.h" #include "AlphaCube.h" -using namespace std; +using namespace std; using namespace Isis; -void IFFT1 (vector &in, vector &out); -void IFFT2 (vector &in, vector &out); +void IFFT1(vector &in, vector &out); +void IFFT2(vector &in, vector &out); FourierTransform fft; string tmpMagFilename = "Temporary_IFFT_Magnitude.cub"; @@ -38,8 +38,8 @@ void IsisMain() { // error checking for valid input cubes // i.e. the dimensions of the magnitude and phase cubes // are the same and are powers of two - if (!fft.IsPowerOfTwo(numSamples) || !fft.IsPowerOfTwo(numLines) - || magCube->Samples()!=phaseCube->Samples() || magCube->Lines()!=phaseCube->Lines()) { + if(!fft.IsPowerOfTwo(numSamples) || !fft.IsPowerOfTwo(numLines) + || magCube->Samples() != phaseCube->Samples() || magCube->Lines() != phaseCube->Lines()) { cerr << "Invalid Cubes: the dimensions of both cubes must be equal powers of 2." << endl; return; } @@ -48,8 +48,8 @@ void IsisMain() { Isis::CubeAttributeOutput cao; - lProc.SetOutputCube (tmpMagFilename, cao, numSamples, numLines, numBands); - lProc.SetOutputCube (tmpPhaseFilename, cao, numSamples, numLines, numBands); + lProc.SetOutputCube(tmpMagFilename, cao, numSamples, numLines, numBands); + lProc.SetOutputCube(tmpPhaseFilename, cao, numSamples, numLines, numBands); // Start the line processing lProc.StartProcess(IFFT2); @@ -78,8 +78,7 @@ void IsisMain() { } // Processing routine for the inverse fft -void IFFT1 (vector &in, vector &out) -{ +void IFFT1(vector &in, vector &out) { Buffer &inReal = *in[0]; Buffer &inImag = *in[1]; @@ -88,7 +87,7 @@ void IFFT1 (vector &in, vector &out) // copy and rearrange the data to fit the algorithm // the image is centered at zero, the array begins at zero - for (int i=0; i(inReal[i+n/2], inImag[i+n/2]); input[i+n/2] = complex(inReal[i], inImag[i]); } @@ -98,14 +97,13 @@ void IFFT1 (vector &in, vector &out) Buffer &image = *out[0]; // and copy the result to the output cube - for ( int i=0; i &in, vector &out) -{ +void IFFT2(vector &in, vector &out) { Buffer &mag = *in[0]; Buffer &phase = *in[1]; @@ -114,7 +112,7 @@ void IFFT2 (vector &in, vector &out) // copy and rearrange the data to fit the algorithm // the image is centered at zero, the array begins at zero - for (int i=0; i(polar(mag[i+n/2], phase[i+n/2])); input[i+n/2] = complex(polar(mag[i], phase[i])); } @@ -125,7 +123,7 @@ void IFFT2 (vector &in, vector &out) Buffer &realCube = *out[0]; Buffer &imagCube = *out[1]; // and copy the result to the output cubes - for ( int i=0; iInterestAmount(); - } catch (iException &e) { + } + catch(iException &e) { e.Report(); } } diff --git a/isis/src/base/apps/isis2ascii/isis2ascii.cpp b/isis/src/base/apps/isis2ascii/isis2ascii.cpp index 7b19a71167..8189416494 100644 --- a/isis/src/base/apps/isis2ascii/isis2ascii.cpp +++ b/isis/src/base/apps/isis2ascii/isis2ascii.cpp @@ -3,11 +3,11 @@ #include "SpecialPixel.h" #include "Filename.h" -using namespace std; +using namespace std; using namespace Isis; // Global declarations -void isis2ascii (Buffer &in); +void isis2ascii(Buffer &in); ofstream fout; void IsisMain() { @@ -19,37 +19,37 @@ void IsisMain() { // Open output text file UserInterface &ui = Application::GetUserInterface(); - string to = ui.GetFilename("TO","txt"); - fout.open (to.c_str()); + string to = ui.GetFilename("TO", "txt"); + fout.open(to.c_str()); // Print header if needed - if (ui.GetBoolean("HEADER")) { - fout << "Input Cube: " << icube->Filename () << endl; - fout << "Samples:Lines:Bands: " << icube->Samples () << ":" << - icube->Lines () << ":" << icube->Bands () << endl; + if(ui.GetBoolean("HEADER")) { + fout << "Input Cube: " << icube->Filename() << endl; + fout << "Samples:Lines:Bands: " << icube->Samples() << ":" << + icube->Lines() << ":" << icube->Bands() << endl; } - + // List the cube p.StartProcess(isis2ascii); p.EndProcess(); - fout.close (); + fout.close(); } -void isis2ascii (Buffer &in) { - for (int i=0; iLabel()->FindObject("IsisCube").FindObject("Core").FindGroup("Pixels"); double scale = pix["Multiplier"][0].ToDouble(); double base = pix["Base"][0].ToDouble(); - if (ui.GetString("STRETCH") != "NONE" && bitpix != "-32") { - if (ui.GetString("STRETCH") == "LINEAR") { + if(ui.GetString("STRETCH") != "NONE" && bitpix != "-32") { + if(ui.GetString("STRETCH") == "LINEAR") { p.SetInputRange(); } - else if (ui.GetString("STRETCH") == "MANUAL") { - p.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM")); + else if(ui.GetString("STRETCH") == "MANUAL") { + p.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM")); } - + // create a proper scale so pixels look like 32bit data. scale = ((p.GetInputMaximum() - p.GetInputMinimum()) * - (p.GetOutputMaximum() - p.GetOutputMinimum())); + (p.GetOutputMaximum() - p.GetOutputMinimum())); // round off after 14 decimals to avoid system architecture differences scale = ((floor(scale * 1e14)) / 1e14); @@ -81,168 +81,168 @@ void IsisMain(){ base = ((floor(base * 1e14)) / 1e14); } - + ////////////////////////////////////////// // Write the minimal fits header // ////////////////////////////////////////// string header; - + // specify that this file conforms to simple fits standard - header += FitsKeyword("SIMPLE", true, "T"); - - + header += FitsKeyword("SIMPLE", true, "T"); + + // specify the bits per pixel header += FitsKeyword("BITPIX", true, bitpix); - + // specify the number of data axes (2: samples by lines) int axes = 2; - if (icube->Bands() > 1) { + if(icube->Bands() > 1) { axes = 3; } - + header += FitsKeyword("NAXIS", true, iString(axes)); - + // specify the limit on data axis 1 (number of samples) header += FitsKeyword("NAXIS1", true, iString(icube->Samples())); // specify the limit on data axis 2 (number of lines) header += FitsKeyword("NAXIS2", true, iString(icube->Lines())); - - if (axes == 3){ + + if(axes == 3) { header += FitsKeyword("NAXIS3", true, iString(icube->Bands())); } header += FitsKeyword("BZERO", true, base); header += FitsKeyword("BSCALE", true, scale); - - // Sky and All cases - if (ui.GetString("INFO") == "SKY" || ui.GetString("INFO") == "ALL") { + + // Sky and All cases + if(ui.GetString("INFO") == "SKY" || ui.GetString("INFO") == "ALL") { iString msg = "cube has not been skymapped"; PvlGroup map; - if (icube->HasGroup("mapping")) { - map = icube->GetGroup("mapping"); + if(icube->HasGroup("mapping")) { + map = icube->GetGroup("mapping"); msg = (string)map["targetname"]; } // If we have sky we want it - if (msg == "Sky") { + if(msg == "Sky") { double midRa = 0, midDec = 0; - + midRa = ((double)map["MaximumLongitude"] + - (double)map["MinimumLongitude"])/2; - + (double)map["MinimumLongitude"]) / 2; + midDec = ((double)map["MaximumLatitude"] + - (double)map["MinimumLatitude"])/2; - + (double)map["MinimumLatitude"]) / 2; + header += FitsKeyword("OBJCTRA", true, iString(midRa)); - + // Specify the Declination header += FitsKeyword("OBJCTDEC", true, iString(midDec)); - + } - if (ui.GetString("INFO") == "ALL") { - header += WritePvl("INSTRUME","Instrument","InstrumentId", icube, true); - header += WritePvl("OBSERVER","Instrument","SpacecraftName", icube, true); - header += WritePvl("OBJECT ","Instrument","TargetName", icube, true); - // StartTime is sometimes middle of the exposure and somtimes beginning, + if(ui.GetString("INFO") == "ALL") { + header += WritePvl("INSTRUME", "Instrument", "InstrumentId", icube, true); + header += WritePvl("OBSERVER", "Instrument", "SpacecraftName", icube, true); + header += WritePvl("OBJECT ", "Instrument", "TargetName", icube, true); + // StartTime is sometimes middle of the exposure and somtimes beginning, // so StopTime can't be calculated off of exposure reliably. - header += WritePvl("DATE-OBS","Instrument","StartTime", icube, true); + header += WritePvl("DATE-OBS", "Instrument", "StartTime", icube, true); // Some cameras don't have StopTime - if (icube->HasGroup("Instrument")) { + if(icube->HasGroup("Instrument")) { PvlGroup inst = icube->GetGroup("Instrument"); - if (inst.HasKeyword("StopTime")) { - header += WritePvl("TIME_END","Instrument","StopTime", icube, true); + if(inst.HasKeyword("StopTime")) { + header += WritePvl("TIME_END", "Instrument", "StopTime", icube, true); } - if (inst.HasKeyword("ExposureDuration")) { - header += WritePvl("EXPTIME","Instrument","ExposureDuration", icube, false); + if(inst.HasKeyword("ExposureDuration")) { + header += WritePvl("EXPTIME", "Instrument", "ExposureDuration", icube, false); } } - } + } // If we were set on SKY and Sky doesn't exist - else if (msg != "Sky") { - throw iException::Message(iException::User,msg,_FILEINFO_); + else if(msg != "Sky") { + throw iException::Message(iException::User, msg, _FILEINFO_); } } - + // signal the end of the header header += FitsKeyword("END", false, ""); // fill the rest of the fits header with space so to conform with the fits header // size of 2880 bytes - for (int i = header.length() % 2880 ; i < 2880 ; i++) header += " "; + for(int i = header.length() % 2880 ; i < 2880 ; i++) header += " "; // open the cube for writing - string to = ui.GetFilename("TO","fits"); - ofstream fout; - fout.open (to.c_str (), ios::out|ios::binary); - if (!fout.is_open ()) { + string to = ui.GetFilename("TO", "fits"); + ofstream fout; + fout.open(to.c_str(), ios::out | ios::binary); + if(!fout.is_open()) { string msg = "Cannot open fits output file"; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } - + fout.seekp(0); - fout.write(header.c_str(),header.length()); + fout.write(header.c_str(), header.length()); // write the raw cube data - p.StartProcess (fout); + p.StartProcess(fout); // Finish off data area to a number n % 2880 == 0 is true // 2880 is the size of the data blocks int count = 2880 - (fout.tellp() % 2880); - for (int i = 0; i < count; i++) { + for(int i = 0; i < count; i++) { // Write nul characters as needed. ascii 0, hex 00... - fout.write("\0", 1); + fout.write("\0", 1); } - fout.close(); + fout.close(); p.EndProcess(); } string FitsKeyword(string key, bool isValue, Isis::iString value, Isis::iString unit) { // pad the keyword with space - for (int i = key.length() ; i < 8 ; i++) + for(int i = key.length() ; i < 8 ; i++) key += " "; - + // add the value indicator (or lack thereof) - if (isValue) + if(isValue) key += "= "; - else + else key += " "; - + // right-justify the value - if (value.length() < 70){ + if(value.length() < 70) { // pad the left part of the value with space - for (int i = value.length() ; i < 20 ; i++) + for(int i = value.length() ; i < 20 ; i++) key += " "; - + // add the actual value key += value; - if (isValue) { + if(isValue) { key += " / "; - if (unit != "") { + if(unit != "") { key += "[" + unit + "]"; } } // finish the line by padding the rest of the space - for (int i = key.length() ; i < 80 ; i++) + for(int i = key.length() ; i < 80 ; i++) key += " "; } - + // record the total length of the header headerBytes += key.length(); return key; } string WritePvl(string fitsKey, string group, iString key, Cube *icube, bool isString) { - if(icube->HasGroup(group)){ - PvlGroup theGroup = icube->GetGroup(group); + if(icube->HasGroup(group)) { + PvlGroup theGroup = icube->GetGroup(group); iString name = (string)theGroup[key]; - if (isString) { + if(isString) { name = "'" + name + "'"; } iString unit = theGroup[key].Unit(); - return FitsKeyword(fitsKey, true, name, unit); + return FitsKeyword(fitsKey, true, name, unit); } return NULL; } diff --git a/isis/src/base/apps/isis2gml/isis2gml.cpp b/isis/src/base/apps/isis2gml/isis2gml.cpp index 03dd5cf898..66391e4b50 100644 --- a/isis/src/base/apps/isis2gml/isis2gml.cpp +++ b/isis/src/base/apps/isis2gml/isis2gml.cpp @@ -12,7 +12,7 @@ using namespace std; using namespace Isis; -void IsisMain(){ +void IsisMain() { UserInterface &ui = Application::GetUserInterface(); @@ -36,7 +36,7 @@ void IsisMain(){ string outfile; ofstream fout; - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { outfile = ui.GetFilename("TO"); } else { @@ -45,7 +45,7 @@ void IsisMain(){ inputFile.AddExtension("gml"); outfile = inputFile.Name(); } - fout.open (outfile.c_str()); + fout.open(outfile.c_str()); fout << polyString << endl; diff --git a/isis/src/base/apps/isis2pds/isis2pds.cpp b/isis/src/base/apps/isis2pds/isis2pds.cpp index a1f37388a1..678d63e5f9 100644 --- a/isis/src/base/apps/isis2pds/isis2pds.cpp +++ b/isis/src/base/apps/isis2pds/isis2pds.cpp @@ -1,50 +1,50 @@ #include "Isis.h" #include "ProcessExportPds.h" -using namespace std; -using namespace Isis; +using namespace std; +using namespace Isis; enum Pixtype { NONE, NEG, BOTH }; -void setRangeAndPixels( UserInterface &ui, ProcessExportPds &p, - double &min, double &max, Pixtype ptype ); +void setRangeAndPixels(UserInterface &ui, ProcessExportPds &p, + double &min, double &max, Pixtype ptype); void IsisMain() { // Set the processing object ProcessExportPds p; - + // Setup the input cube p.SetInputCube("FROM"); UserInterface &ui = Application::GetUserInterface(); - if (ui.GetString ("STRETCH") == "LINEAR") { - if (ui.GetString ("BITTYPE") != "32BIT") + if(ui.GetString("STRETCH") == "LINEAR") { + if(ui.GetString("BITTYPE") != "32BIT") p.SetInputRange(); } - if (ui.GetString ("STRETCH") == "MANUAL") + if(ui.GetString("STRETCH") == "MANUAL") p.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM")); double min = -DBL_MAX; double max = DBL_MAX; - if (ui.GetString("BITTYPE") == "8BIT") { + if(ui.GetString("BITTYPE") == "8BIT") { p.SetOutputType(Isis::UnsignedByte); min = 0.0; max = 255.0; - setRangeAndPixels( ui, p, min, max, BOTH ); - } - else if (ui.GetString("BITTYPE") == "S16BIT") { + setRangeAndPixels(ui, p, min, max, BOTH); + } + else if(ui.GetString("BITTYPE") == "S16BIT") { p.SetOutputType(Isis::SignedWord); min = -32768.0; max = 32767.0; - setRangeAndPixels( ui, p, min, max, NEG ); - } - else if (ui.GetString("BITTYPE") == "U16BIT") { + setRangeAndPixels(ui, p, min, max, NEG); + } + else if(ui.GetString("BITTYPE") == "U16BIT") { p.SetOutputType(Isis::UnsignedWord); min = 0.0; max = 65535.0; - setRangeAndPixels( ui, p, min, max, BOTH ); - } + setRangeAndPixels(ui, p, min, max, BOTH); + } else { p.SetOutputType(Isis::Real); p.SetOutputNull(Isis::NULL4); @@ -52,79 +52,79 @@ void IsisMain() { p.SetOutputLis(Isis::LOW_INSTR_SAT4); p.SetOutputHrs(Isis::HIGH_REPR_SAT4); p.SetOutputHis(Isis::HIGH_INSTR_SAT4); - setRangeAndPixels( ui, p, min, max, NONE ); + setRangeAndPixels(ui, p, min, max, NONE); } - if (ui.GetString("ENDIAN") == "MSB") + if(ui.GetString("ENDIAN") == "MSB") p.SetOutputEndian(Isis::Msb); - else if (ui.GetString("ENDIAN") == "LSB") + else if(ui.GetString("ENDIAN") == "LSB") p.SetOutputEndian(Isis::Lsb); - if (ui.GetString("LABTYPE") == "FIXED") - p.SetExportType ( ProcessExportPds::Fixed ); + if(ui.GetString("LABTYPE") == "FIXED") + p.SetExportType(ProcessExportPds::Fixed); + + //Set the resolution to Kilometers + p.SetPdsResolution(ProcessExportPds::Kilometer); - //Set the resolution to Kilometers - p.SetPdsResolution( ProcessExportPds::Kilometer ); + p.StandardPdsLabel(ProcessExportPds::Image); - p.StandardPdsLabel( ProcessExportPds::Image); - Filename outFile(ui.GetFilename("TO", "img")); string outFilename(outFile.Expanded()); ofstream oCube(outFilename.c_str()); - p.OutputLabel(oCube); - p.StartProcess(oCube); + p.OutputLabel(oCube); + p.StartProcess(oCube); oCube.close(); p.EndProcess(); //Records what it did to the print.prt file - PvlGroup results( "DNs Used" ); - results += PvlKeyword( "Null", p.OutputNull() ); - results += PvlKeyword( "LRS", p.OutputLrs() ); - results += PvlKeyword( "LIS", p.OutputLis() ); - results += PvlKeyword( "HIS", p.OutputHis() ); - results += PvlKeyword( "HRS", p.OutputHrs() ); - results += PvlKeyword( "ValidMin", min ); - results += PvlKeyword( "ValidMax", max ); - Application::Log( results ); + PvlGroup results("DNs Used"); + results += PvlKeyword("Null", p.OutputNull()); + results += PvlKeyword("LRS", p.OutputLrs()); + results += PvlKeyword("LIS", p.OutputLis()); + results += PvlKeyword("HIS", p.OutputHis()); + results += PvlKeyword("HRS", p.OutputHrs()); + results += PvlKeyword("ValidMin", min); + results += PvlKeyword("ValidMax", max); + Application::Log(results); return; } //Sets up special pixels and valid pixel ranges -void setRangeAndPixels( UserInterface &ui, ProcessExportPds &p, double &min, double &max, Pixtype ptype ) { - if( ptype == NEG ) { - if ( ui.GetBoolean("NULL") ) { +void setRangeAndPixels(UserInterface &ui, ProcessExportPds &p, double &min, double &max, Pixtype ptype) { + if(ptype == NEG) { + if(ui.GetBoolean("NULL")) { p.SetOutputNull(min++); } - if ( ui.GetBoolean("LRS") ) { + if(ui.GetBoolean("LRS")) { p.SetOutputLrs(min++); } - if ( ui.GetBoolean("LIS") ) { + if(ui.GetBoolean("LIS")) { p.SetOutputLis(min++); } - if ( ui.GetBoolean("HIS") ) { + if(ui.GetBoolean("HIS")) { p.SetOutputHis(min++); } - if ( ui.GetBoolean("HRS") ) { + if(ui.GetBoolean("HRS")) { p.SetOutputHrs(min++); } } - else if( ptype == BOTH ) { - if ( ui.GetBoolean("NULL") ) { + else if(ptype == BOTH) { + if(ui.GetBoolean("NULL")) { p.SetOutputNull(min++); } - if ( ui.GetBoolean("LRS") ) { + if(ui.GetBoolean("LRS")) { p.SetOutputLrs(min++); } - if ( ui.GetBoolean("LIS") ) { + if(ui.GetBoolean("LIS")) { p.SetOutputLis(min++); } - if ( ui.GetBoolean("HRS") ) { + if(ui.GetBoolean("HRS")) { p.SetOutputHrs(max--); } - if ( ui.GetBoolean("HIS") ) { + if(ui.GetBoolean("HIS")) { p.SetOutputHis(max--); } } - p.SetOutputRange(min,max); + p.SetOutputRange(min, max); } diff --git a/isis/src/base/apps/isis2raw/isis2raw.cpp b/isis/src/base/apps/isis2raw/isis2raw.cpp index f388869ea7..9fdf937857 100644 --- a/isis/src/base/apps/isis2raw/isis2raw.cpp +++ b/isis/src/base/apps/isis2raw/isis2raw.cpp @@ -11,14 +11,14 @@ #include "UserInterface.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; enum Pixtype { NONE, NEG, BOTH }; -void checkRange( UserInterface &ui, double &min, double &max ); -void setRangeAndPixels( UserInterface &ui, ProcessExport &p, - double &min, double &max, Pixtype ptype ); +void checkRange(UserInterface &ui, double &min, double &max); +void setRangeAndPixels(UserInterface &ui, ProcessExport &p, + double &min, double &max, Pixtype ptype); // Main program void IsisMain() { @@ -31,151 +31,151 @@ void IsisMain() { UserInterface &ui = Application::GetUserInterface(); // Applies the input to output stretch options - if (ui.GetString ("STRETCH") == "LINEAR") { - if (ui.GetString ("BITTYPE") != "32BIT") + if(ui.GetString("STRETCH") == "LINEAR") { + if(ui.GetString("BITTYPE") != "32BIT") p.SetInputRange(); } - if (ui.GetString ("STRETCH") == "MANUAL") + if(ui.GetString("STRETCH") == "MANUAL") p.SetInputRange(ui.GetDouble("MINIMUM"), ui.GetDouble("MAXIMUM")); // Determine bit size, output range, and calculate number of bytes to write // for each line. double min = -DBL_MAX; double max = DBL_MAX; - if (ui.GetString ("BITTYPE") == "8BIT") { + if(ui.GetString("BITTYPE") == "8BIT") { p.SetOutputType(Isis::UnsignedByte); min = 0.0; max = 255.0; - checkRange( ui, min, max ); - setRangeAndPixels( ui, p, min, max, BOTH ); + checkRange(ui, min, max); + setRangeAndPixels(ui, p, min, max, BOTH); } - else if (ui.GetString ("BITTYPE") == "S16BIT") { + else if(ui.GetString("BITTYPE") == "S16BIT") { p.SetOutputType(Isis::SignedWord); min = -32768.0; max = 32767.0; - checkRange( ui, min, max ); - setRangeAndPixels( ui, p, min, max, NEG ); + checkRange(ui, min, max); + setRangeAndPixels(ui, p, min, max, NEG); } - else if (ui.GetString ("BITTYPE") == "U16BIT") { + else if(ui.GetString("BITTYPE") == "U16BIT") { p.SetOutputType(Isis::UnsignedWord); min = 0.0; max = 65535.0; - checkRange( ui, min, max ); - setRangeAndPixels( ui, p, min, max, BOTH ); + checkRange(ui, min, max); + setRangeAndPixels(ui, p, min, max, BOTH); } - else if (ui.GetString ("BITTYPE") == "32BIT") { + else if(ui.GetString("BITTYPE") == "32BIT") { p.SetOutputType(Isis::Real); - checkRange( ui, min, max ); - setRangeAndPixels( ui, p, min, max, NONE ); + checkRange(ui, min, max); + setRangeAndPixels(ui, p, min, max, NONE); } // Set the output endianness - if (ui.GetString("ENDIAN") == "MSB") + if(ui.GetString("ENDIAN") == "MSB") p.SetOutputEndian(Isis::Msb); - else if (ui.GetString("ENDIAN") == "LSB") + else if(ui.GetString("ENDIAN") == "LSB") p.SetOutputEndian(Isis::Lsb); // Open the cube for writing - string to = ui.GetFilename("TO","raw"); - ofstream fout; - fout.open (to.c_str (),ios::out|ios::binary); - if (!fout.is_open ()) { + string to = ui.GetFilename("TO", "raw"); + ofstream fout; + fout.open(to.c_str(), ios::out | ios::binary); + if(!fout.is_open()) { string msg = "Cannot open raw output file"; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } // Set the Output Storage Format - if ( Isis::iString( ui.GetString("STORAGEORDER") ).DownCase() == "bil" ) { - p.SetFormat( ProcessExport::BIL ); + if(Isis::iString(ui.GetString("STORAGEORDER")).DownCase() == "bil") { + p.SetFormat(ProcessExport::BIL); } - else if ( Isis::iString( ui.GetString("STORAGEORDER") ).DownCase() == "bip" ) { - p.SetFormat( ProcessExport::BIP ); + else if(Isis::iString(ui.GetString("STORAGEORDER")).DownCase() == "bip") { + p.SetFormat(ProcessExport::BIP); } // Write the raw cube data - p.StartProcess (fout); + p.StartProcess(fout); - fout.close(); + fout.close(); p.EndProcess(); // Records what output values were used, then sends it to the print.prt file // as well as the terminal. - PvlGroup results( "DNs Used" ); - results += PvlKeyword( "Null", p.OutputNull() ); - results += PvlKeyword( "LRS", p.OutputLrs() ); - results += PvlKeyword( "LIS", p.OutputLis() ); - results += PvlKeyword( "HIS", p.OutputHis() ); - results += PvlKeyword( "HRS", p.OutputHrs() ); - results += PvlKeyword( "ValidMin", min ); - results += PvlKeyword( "ValidMax", max ); - Application::Log( results ); + PvlGroup results("DNs Used"); + results += PvlKeyword("Null", p.OutputNull()); + results += PvlKeyword("LRS", p.OutputLrs()); + results += PvlKeyword("LIS", p.OutputLis()); + results += PvlKeyword("HIS", p.OutputHis()); + results += PvlKeyword("HRS", p.OutputHrs()); + results += PvlKeyword("ValidMin", min); + results += PvlKeyword("ValidMax", max); + Application::Log(results); return; } // Validates provided range -void checkRange( UserInterface &ui, double &min, double &max ) { - if ( ui.WasEntered("OMIN") ) { - if ( ui.GetDouble("OMIN") < min ) { +void checkRange(UserInterface &ui, double &min, double &max) { + if(ui.WasEntered("OMIN")) { + if(ui.GetDouble("OMIN") < min) { string message = "OMIN [" + iString(min) + "] is too small for the provided BITTYPE ["; message += ui.GetString("BITTYPE") + "]"; - throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, message, _FILEINFO_); } else { min = ui.GetDouble("OMIN"); } } - if ( ui.WasEntered("OMAX") ) { - if ( ui.GetDouble("OMAX") > max ) { + if(ui.WasEntered("OMAX")) { + if(ui.GetDouble("OMAX") > max) { string message = "OMAX [" + iString(max) + "] is too large for the provided BITTYPE ["; message += ui.GetString("BITTYPE") + "]"; - throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, message, _FILEINFO_); } else { max = ui.GetDouble("OMAX"); } } - if( min >= max ) { + if(min >= max) { string message = "OMIN [" + iString(min) + "] cannot be greater than or equal to OMAX ["; message += iString(max) + "]"; - throw Isis::iException::Message(Isis::iException::User,message,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, message, _FILEINFO_); } } // Sets up special pixels and valid pixel ranges -void setRangeAndPixels( UserInterface &ui, ProcessExport &p, double &min, double &max, Pixtype ptype ) { - if( ptype == NEG ) { - if ( ui.GetBoolean("NULL") ) { +void setRangeAndPixels(UserInterface &ui, ProcessExport &p, double &min, double &max, Pixtype ptype) { + if(ptype == NEG) { + if(ui.GetBoolean("NULL")) { p.SetOutputNull(min++); } - if ( ui.GetBoolean("LRS") ) { + if(ui.GetBoolean("LRS")) { p.SetOutputLrs(min++); } - if ( ui.GetBoolean("LIS") ) { + if(ui.GetBoolean("LIS")) { p.SetOutputLis(min++); } - if ( ui.GetBoolean("HIS") ) { + if(ui.GetBoolean("HIS")) { p.SetOutputHis(min++); } - if ( ui.GetBoolean("HRS") ) { + if(ui.GetBoolean("HRS")) { p.SetOutputHrs(min++); } } - else if( ptype == BOTH ) { - if ( ui.GetBoolean("NULL") ) { + else if(ptype == BOTH) { + if(ui.GetBoolean("NULL")) { p.SetOutputNull(min++); } - if ( ui.GetBoolean("LRS") ) { + if(ui.GetBoolean("LRS")) { p.SetOutputLrs(min++); } - if ( ui.GetBoolean("LIS") ) { + if(ui.GetBoolean("LIS")) { p.SetOutputLis(min++); } - if ( ui.GetBoolean("HRS") ) { + if(ui.GetBoolean("HRS")) { p.SetOutputHrs(max--); } - if ( ui.GetBoolean("HIS") ) { + if(ui.GetBoolean("HIS")) { p.SetOutputHis(max--); } } - p.SetOutputRange(min,max); + p.SetOutputRange(min, max); } diff --git a/isis/src/base/apps/isis2std/isis2std.cpp b/isis/src/base/apps/isis2std/isis2std.cpp index 98bfd5c3e9..746b5f7c9b 100644 --- a/isis/src/base/apps/isis2std/isis2std.cpp +++ b/isis/src/base/apps/isis2std/isis2std.cpp @@ -18,13 +18,13 @@ int datamin; int datamax; // Line-by-Line qimage output prototype -void checkDataSize (Isis::BigInt line, Isis::BigInt samp, iString mode); -void toGreyscaleImage (Buffer &in); -void toRGBImage (vector &in); -void toARGBImage (vector &in); -void toJP2 (Buffer &in); -void toJP2RGB (vector &in); -void toJP2ARGB (vector &in); +void checkDataSize(Isis::BigInt line, Isis::BigInt samp, iString mode); +void toGreyscaleImage(Buffer &in); +void toRGBImage(vector &in); +void toARGBImage(vector &in); +void toJP2(Buffer &in); +void toJP2RGB(vector &in); +void toJP2ARGB(vector &in); // Main program void IsisMain() { @@ -39,55 +39,57 @@ void IsisMain() { // Create an object for exporting image data ProcessExport p; - if (format.Equal("jp2")) { + if(format.Equal("jp2")) { // Setup the required extension and world file - string extension(""),world(""); + string extension(""), world(""); extension = "jp2"; world = "j2w"; // Single band cubes will be greyscale - if (mode == "GRAYSCALE") { + if(mode == "GRAYSCALE") { // Open the input cube - icube = p.SetInputCube("FROM",Isis::OneBand); + icube = p.SetInputCube("FROM", Isis::OneBand); // Apply the input to output stretch options p.SetInputRange(); p.SetFormat(ProcessExport::BIL); - + jp2buf = new char* [1]; - // Determine bit size and output range - if (ui.GetString("BITTYPE") == "8BIT") { + // Determine bit size and output range + if(ui.GetString("BITTYPE") == "8BIT") { jp2type = Isis::UnsignedByte; jp2buf[0] = new char[icube->Samples()]; p.SetOutputType(Isis::UnsignedByte); - p.SetOutputRange(1.0,255.0); + p.SetOutputRange(1.0, 255.0); p.SetOutputNull(0.0); - JP2_encoder = new JP2Encoder(ui.GetFilename("TO"),icube->Samples(), - icube->Lines(),icube->Bands(),Isis::UnsignedByte); + JP2_encoder = new JP2Encoder(ui.GetFilename("TO"), icube->Samples(), + icube->Lines(), icube->Bands(), Isis::UnsignedByte); datamin = 0; datamax = 255; - } else if (ui.GetString("BITTYPE") == "S16BIT") { + } + else if(ui.GetString("BITTYPE") == "S16BIT") { jp2type = Isis::SignedWord; - for (int i=0; iBands(); i++) { + for(int i = 0; i < icube->Bands(); i++) { jp2buf[i] = new char[icube->Samples()*2]; } p.SetOutputType(Isis::SignedWord); p.SetOutputNull(-32768.0); - p.SetOutputRange(-32752.0,32767.0); - JP2_encoder = new JP2Encoder(ui.GetFilename("TO"),icube->Samples(), - icube->Lines(),icube->Bands(),Isis::SignedWord); + p.SetOutputRange(-32752.0, 32767.0); + JP2_encoder = new JP2Encoder(ui.GetFilename("TO"), icube->Samples(), + icube->Lines(), icube->Bands(), Isis::SignedWord); datamin = -32752; datamax = 32767; - } else if (ui.GetString("BITTYPE") == "U16BIT") { + } + else if(ui.GetString("BITTYPE") == "U16BIT") { jp2type = Isis::UnsignedWord; - for (int i=0; iBands(); i++) { + for(int i = 0; i < icube->Bands(); i++) { jp2buf[i] = new char[icube->Samples()*2]; } p.SetOutputType(Isis::UnsignedWord); p.SetOutputNull(0.0); - p.SetOutputRange(3.0,65522.0); - JP2_encoder = new JP2Encoder(ui.GetFilename("TO"),icube->Samples(), - icube->Lines(),icube->Bands(),Isis::UnsignedWord); + p.SetOutputRange(3.0, 65522.0); + JP2_encoder = new JP2Encoder(ui.GetFilename("TO"), icube->Samples(), + icube->Lines(), icube->Bands(), Isis::UnsignedWord); datamin = 3; datamax = 65522; } @@ -96,11 +98,11 @@ void IsisMain() { } // If RGB, create a 24-bit color image // (1st band -> red, 2nd band -> green, 3rd band -> blue) - else if (mode == "RGB") { + else if(mode == "RGB") { Cube *redcube = p.SetInputCube("RED", Isis::OneBand); p.SetInputCube("GREEN", Isis::OneBand); p.SetInputCube("BLUE", Isis::OneBand); - if (ui.GetString("STRETCH") == "MANUAL") { + if(ui.GetString("STRETCH") == "MANUAL") { p.SetInputRange(ui.GetDouble("RMIN"), ui.GetDouble("RMAX"), 0); p.SetInputRange(ui.GetDouble("GMIN"), ui.GetDouble("GMAX"), 1); p.SetInputRange(ui.GetDouble("BMIN"), ui.GetDouble("BMAX"), 2); @@ -118,52 +120,55 @@ void IsisMain() { } p.SetFormat(ProcessExport::BIL); jp2buf = new char* [3]; - // Determine bit size and output range - if (ui.GetString("BITTYPE") == "8BIT") { + // Determine bit size and output range + if(ui.GetString("BITTYPE") == "8BIT") { jp2type = Isis::UnsignedByte; - for (int i=0; i<3; i++) { + for(int i = 0; i < 3; i++) { jp2buf[i] = new char[redcube->Samples()]; } p.SetOutputType(Isis::UnsignedByte); - p.SetOutputRange(1.0,255.0); + p.SetOutputRange(1.0, 255.0); p.SetOutputNull(0.0); - JP2_encoder = new JP2Encoder(ui.GetFilename("TO"),redcube->Samples(), - redcube->Lines(),3,Isis::UnsignedByte); + JP2_encoder = new JP2Encoder(ui.GetFilename("TO"), redcube->Samples(), + redcube->Lines(), 3, Isis::UnsignedByte); datamin = 0; datamax = 255; - } else if (ui.GetString("BITTYPE") == "S16BIT") { + } + else if(ui.GetString("BITTYPE") == "S16BIT") { jp2type = Isis::SignedWord; - for (int i=0; i<3; i++) { + for(int i = 0; i < 3; i++) { jp2buf[i] = new char[redcube->Samples()*2]; } p.SetOutputType(Isis::SignedWord); p.SetOutputNull(-32768.0); - p.SetOutputRange(-32752.0,32767.0); - JP2_encoder = new JP2Encoder(ui.GetFilename("TO"),redcube->Samples(), - redcube->Lines(),3,Isis::SignedWord); + p.SetOutputRange(-32752.0, 32767.0); + JP2_encoder = new JP2Encoder(ui.GetFilename("TO"), redcube->Samples(), + redcube->Lines(), 3, Isis::SignedWord); datamin = -32752; datamax = 32767; - } else if (ui.GetString("BITTYPE") == "U16BIT") { + } + else if(ui.GetString("BITTYPE") == "U16BIT") { jp2type = Isis::UnsignedWord; - for (int i=0; i<3; i++) { + for(int i = 0; i < 3; i++) { jp2buf[i] = new char[redcube->Samples()*2]; } p.SetOutputType(Isis::UnsignedWord); p.SetOutputNull(0.0); - p.SetOutputRange(3.0,65522.0); - JP2_encoder = new JP2Encoder(ui.GetFilename("TO"),redcube->Samples(), - redcube->Lines(),3,Isis::UnsignedWord); + p.SetOutputRange(3.0, 65522.0); + JP2_encoder = new JP2Encoder(ui.GetFilename("TO"), redcube->Samples(), + redcube->Lines(), 3, Isis::UnsignedWord); datamin = 3; datamax = 65522; } JP2_encoder->OpenFile(); p.StartProcess(toJP2RGB); - } else if (mode == "ARGB") { + } + else if(mode == "ARGB") { Cube *alphacube = p.SetInputCube("ALPHA", Isis::OneBand); p.SetInputCube("RED", Isis::OneBand); p.SetInputCube("GREEN", Isis::OneBand); p.SetInputCube("BLUE", Isis::OneBand); - if (ui.GetString("STRETCH") == "MANUAL") { + if(ui.GetString("STRETCH") == "MANUAL") { p.SetInputRange(ui.GetDouble("AMIN"), ui.GetDouble("AMAX"), 0); p.SetInputRange(ui.GetDouble("RMIN"), ui.GetDouble("RMAX"), 1); p.SetInputRange(ui.GetDouble("GMIN"), ui.GetDouble("GMAX"), 2); @@ -184,41 +189,43 @@ void IsisMain() { } p.SetFormat(ProcessExport::BIL); jp2buf = new char* [4]; - // Determine bit size and output range - if (ui.GetString("BITTYPE") == "8BIT") { + // Determine bit size and output range + if(ui.GetString("BITTYPE") == "8BIT") { jp2type = Isis::UnsignedByte; - for (int i=0; i<4; i++) { + for(int i = 0; i < 4; i++) { jp2buf[i] = new char[alphacube->Samples()]; } p.SetOutputType(Isis::UnsignedByte); - p.SetOutputRange(1.0,255.0); + p.SetOutputRange(1.0, 255.0); p.SetOutputNull(0.0); - JP2_encoder = new JP2Encoder(ui.GetFilename("TO"),alphacube->Samples(), - alphacube->Lines(),4,Isis::UnsignedByte); + JP2_encoder = new JP2Encoder(ui.GetFilename("TO"), alphacube->Samples(), + alphacube->Lines(), 4, Isis::UnsignedByte); datamin = 0; datamax = 255; - } else if (ui.GetString("BITTYPE") == "S16BIT") { + } + else if(ui.GetString("BITTYPE") == "S16BIT") { jp2type = Isis::SignedWord; - for (int i=0; i<4; i++) { + for(int i = 0; i < 4; i++) { jp2buf[i] = new char[alphacube->Samples()*2]; } p.SetOutputType(Isis::SignedWord); p.SetOutputNull(-32768.0); - p.SetOutputRange(-32752.0,32767.0); - JP2_encoder = new JP2Encoder(ui.GetFilename("TO"),alphacube->Samples(), - alphacube->Lines(),4,Isis::SignedWord); + p.SetOutputRange(-32752.0, 32767.0); + JP2_encoder = new JP2Encoder(ui.GetFilename("TO"), alphacube->Samples(), + alphacube->Lines(), 4, Isis::SignedWord); datamin = -32752; datamax = 32767; - } else if (ui.GetString("BITTYPE") == "U16BIT") { + } + else if(ui.GetString("BITTYPE") == "U16BIT") { jp2type = Isis::UnsignedWord; - for (int i=0; i<4; i++) { + for(int i = 0; i < 4; i++) { jp2buf[i] = new char[alphacube->Samples()*2]; } p.SetOutputType(Isis::UnsignedWord); p.SetOutputNull(0.0); - p.SetOutputRange(3.0,65522.0); - JP2_encoder = new JP2Encoder(ui.GetFilename("TO"),alphacube->Samples(), - alphacube->Lines(),4,Isis::UnsignedWord); + p.SetOutputRange(3.0, 65522.0); + JP2_encoder = new JP2Encoder(ui.GetFilename("TO"), alphacube->Samples(), + alphacube->Lines(), 4, Isis::UnsignedWord); datamin = 3; datamax = 65522; } @@ -233,70 +240,71 @@ void IsisMain() { p.EndProcess(); delete JP2_encoder; - } else { + } + else { QList list = QImageWriter::supportedImageFormats(); QList::Iterator it = list.begin(); bool supported = false; - while (it != list.end()) { - if (*it == QString(format.c_str())) supported = true; + while(it != list.end()) { + if(*it == QString(format.c_str())) supported = true; ++it; } - if (!supported) { + if(!supported) { string msg = "The installation of Trolltech/Qt does not support "; - msg += "your selected format ["+format+"]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + msg += "your selected format [" + format + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } // Setup the required extension and world file - string extension(""),world(""); - if (format == "png") { + string extension(""), world(""); + if(format == "png") { extension = "png"; world = "pgw"; } - else if (format == "jpeg") { + else if(format == "jpeg") { extension = "jpg"; world = "jgw"; } - else if (format == "tiff") { + else if(format == "tiff") { extension = "tif"; world = "tfw"; } - else if (format == "gif") { + else if(format == "gif") { extension = "gif"; world = "gfw"; } - else if (format == "bmp") { + else if(format == "bmp") { extension = "bmp"; world = "bpw"; } // Cubes with less than three bands will be greyscale - if (mode == "GRAYSCALE") { + if(mode == "GRAYSCALE") { Cube *icube = p.SetInputCube("FROM", Isis::OneBand); - checkDataSize(icube->Lines(),icube->Samples(),mode); - qimage = new QImage(icube->Samples(),icube->Lines(), QImage::Format_Indexed8); + checkDataSize(icube->Lines(), icube->Samples(), mode); + qimage = new QImage(icube->Samples(), icube->Lines(), QImage::Format_Indexed8); qimage->setNumColors(256); QVector colors; // create the color table (black = 0 to white = 255) - for (int i = 0; i<256; i++) { - colors.push_back(qRgb(i,i,i)); + for(int i = 0; i < 256; i++) { + colors.push_back(qRgb(i, i, i)); } qimage->setColorTable(colors); p.SetInputRange(); - p.SetOutputRange(1.0,255.0); + p.SetOutputRange(1.0, 255.0); p.SetOutputNull(0.0); p.StartProcess(toGreyscaleImage); } // If RGB, create a 24-bit color image // (1st band -> red, 2nd band -> green, 3rd band -> blue) - else if (mode == "RGB") { + else if(mode == "RGB") { Cube *redcube = p.SetInputCube("RED", Isis::OneBand); - checkDataSize(redcube->Lines(),redcube->Samples(),mode); + checkDataSize(redcube->Lines(), redcube->Samples(), mode); p.SetInputCube("GREEN", Isis::OneBand); p.SetInputCube("BLUE", Isis::OneBand); - qimage = new QImage(redcube->Samples(),redcube->Lines(),QImage::Format_RGB32); - if (ui.GetString("STRETCH") == "MANUAL") { + qimage = new QImage(redcube->Samples(), redcube->Lines(), QImage::Format_RGB32); + if(ui.GetString("STRETCH") == "MANUAL") { p.SetInputRange(ui.GetDouble("RMIN"), ui.GetDouble("RMAX"), 0); p.SetInputRange(ui.GetDouble("GMIN"), ui.GetDouble("GMAX"), 1); p.SetInputRange(ui.GetDouble("BMIN"), ui.GetDouble("BMAX"), 2); @@ -312,18 +320,18 @@ void IsisMain() { ui.PutDouble("BMIN", p.GetInputMinimum(2)); ui.PutDouble("BMAX", p.GetInputMaximum(2)); } - p.SetOutputRange(1.0,255.0); + p.SetOutputRange(1.0, 255.0); p.SetOutputNull(0.0); p.StartProcess(toRGBImage); } - else if (mode == "ARGB") { + else if(mode == "ARGB") { Cube *alpha = p.SetInputCube("ALPHA", Isis::OneBand); - checkDataSize(alpha->Lines(),alpha->Samples(),mode); + checkDataSize(alpha->Lines(), alpha->Samples(), mode); p.SetInputCube("RED", Isis::OneBand); p.SetInputCube("GREEN", Isis::OneBand); p.SetInputCube("BLUE", Isis::OneBand); - qimage = new QImage(alpha->Samples(),alpha->Lines(),QImage::Format_ARGB32); - if (ui.GetString("STRETCH") == "MANUAL") { + qimage = new QImage(alpha->Samples(), alpha->Lines(), QImage::Format_ARGB32); + if(ui.GetString("STRETCH") == "MANUAL") { p.SetInputRange(ui.GetDouble("AMIN"), ui.GetDouble("AMAX"), 0); p.SetInputRange(ui.GetDouble("RMIN"), ui.GetDouble("RMAX"), 1); p.SetInputRange(ui.GetDouble("GMIN"), ui.GetDouble("GMAX"), 2); @@ -342,7 +350,7 @@ void IsisMain() { ui.PutDouble("BMIN", p.GetInputMinimum(3)); ui.PutDouble("BMAX", p.GetInputMaximum(3)); } - p.SetOutputRange(1.0,255.0); + p.SetOutputRange(1.0, 255.0); p.SetOutputNull(0.0); p.StartProcess(toARGBImage); } @@ -354,7 +362,7 @@ void IsisMain() { // The return status is wrong for JPEG images, so the code will always // continue. - if(!qimage->save(filename.c_str(),format.c_str(),quality)) { + if(!qimage->save(filename.c_str(), format.c_str(), quality)) { delete qimage; iString err = "Unable to save ["; err += filename.c_str(); @@ -373,130 +381,135 @@ void IsisMain() { } // Write a line of data to the greyscale qimage object -void toGreyscaleImage (Buffer &in) { +void toGreyscaleImage(Buffer &in) { // Loop for each column and load the pixel from in[i] which will // be in the range of [0,255] - for (int i=0; i 255) dn = 255; - qimage->setPixel(i, in.Line()-1, dn); + if(dn < 0) dn = 0; + if(dn > 255) dn = 255; + qimage->setPixel(i, in.Line() - 1, dn); // Since the plausable "exception" thrown by setPixel cannot be caught, // the following if statement does it informally. - if( !qimage->valid(i,in.Line()-1) ) { + if(!qimage->valid(i, in.Line() - 1)) { string msg = "QT has detected your file size as exceeding 2GB."; msg += " While your image might be under 2GB, your image labels are more"; msg += " than likely pushing the file size over 2GB."; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } } } // Check to see if the QImage will be larger than 2GB // error if it will be -void checkDataSize (Isis::BigInt line, Isis::BigInt samp, iString mode){ - Isis::BigInt maxSize = (Isis::BigInt)2*1024*1024*1024; //2GB limit +void checkDataSize(Isis::BigInt line, Isis::BigInt samp, iString mode) { + Isis::BigInt maxSize = (Isis::BigInt)2 * 1024 * 1024 * 1024; //2GB limit Isis::BigInt size = 0; if(mode == "GRAYSCALE") { - size = line*samp; - } else if(mode == "RGB") { - size = (line*samp)*3; - } else if(mode == "ARGB") { - size = (line*samp)*4; + size = line * samp; + } + else if(mode == "RGB") { + size = (line * samp) * 3; } - if (size >= maxSize) { - double inGB = (double)size / (1024*1024*1024); + else if(mode == "ARGB") { + size = (line * samp) * 4; + } + if(size >= maxSize) { + double inGB = (double)size / (1024 * 1024 * 1024); string msg = "Cube exceeds max size of 2GB. Qimage cannot support "; - msg += "that much raw data. Your cube is "+(iString)inGB+" GB."; - throw iException::Message(iException::User,msg,_FILEINFO_); + msg += "that much raw data. Your cube is " + (iString)inGB + " GB."; + throw iException::Message(iException::User, msg, _FILEINFO_); } return; } // Write a line of data to the rgb qimage object -void toRGBImage (vector &in) { +void toRGBImage(vector &in) { Buffer &red = *in[0]; Buffer &green = *in[1]; Buffer &blue = *in[2]; // Set magick pointer to the desired row and construct a Color - QRgb *line = (QRgb *) qimage->scanLine(red.Line()-1); + QRgb *line = (QRgb *) qimage->scanLine(red.Line() - 1); // Loop for each column and load the pixel from in[i] which will // be in the range of [0,255] - for (int i=0; i 255) redDN = 255; + if(redDN < 0) redDN = 0; + else if(redDN > 255) redDN = 255; int greenDN = (int)green[i]; - if (greenDN < 0) greenDN = 0; - else if (greenDN > 255) greenDN = 255; + if(greenDN < 0) greenDN = 0; + else if(greenDN > 255) greenDN = 255; int blueDN = (int)blue[i]; - if (blueDN < 0) blueDN = 0; - else if (blueDN > 255) blueDN = 255; + if(blueDN < 0) blueDN = 0; + else if(blueDN > 255) blueDN = 255; line[i] = qRgb(redDN, greenDN, blueDN); } } // Write a line of data to the argb qimage object -void toARGBImage (vector &in) { +void toARGBImage(vector &in) { Buffer &alpha = *in[0]; Buffer &red = *in[1]; Buffer &green = *in[2]; Buffer &blue = *in[3]; // Set magick pointer to the desired row and construct a Color - QRgb *line = (QRgb *) qimage->scanLine(red.Line()-1); + QRgb *line = (QRgb *) qimage->scanLine(red.Line() - 1); // Loop for each column and load the pixel from in[i] which will // be in the range of [0,255] - for (int i=0; i 255) redDN = 255; + if(redDN < 0) redDN = 0; + else if(redDN > 255) redDN = 255; int greenDN = (int)green[i]; - if (greenDN < 0) greenDN = 0; - else if (greenDN > 255) greenDN = 255; + if(greenDN < 0) greenDN = 0; + else if(greenDN > 255) greenDN = 255; int blueDN = (int)blue[i]; - if (blueDN < 0) blueDN = 0; - else if (blueDN > 255) blueDN = 255; + if(blueDN < 0) blueDN = 0; + else if(blueDN > 255) blueDN = 255; int alphaDN = (int)alpha[i]; - if (alphaDN < 0) alphaDN = 0; - else if (alphaDN > 255) alphaDN = 255; + if(alphaDN < 0) alphaDN = 0; + else if(alphaDN > 255) alphaDN = 255; line[i] = qRgba(redDN, greenDN, blueDN, alphaDN); } } // Write a line of data to the JP2 object -void toJP2 (Buffer &in) { +void toJP2(Buffer &in) { int dn; - for (int i=0; iSamples(); i++) { + for(int i = 0; i < icube->Samples(); i++) { dn = ((int)in[i] < datamin) ? datamin : (int)in[i]; dn = ((int)in[i] > datamax) ? datamax : (int)in[i]; - if (jp2type == Isis::UnsignedByte) { - ((unsigned char*)jp2buf[0])[i] = (unsigned char)dn; - } else if (jp2type == Isis::SignedWord) { - ((short int*)jp2buf[0])[i] = (short int)dn; - } else if (jp2type == Isis::UnsignedWord) { - ((short unsigned int*)jp2buf[0])[i] = (short unsigned int)dn; + if(jp2type == Isis::UnsignedByte) { + ((unsigned char *)jp2buf[0])[i] = (unsigned char)dn; + } + else if(jp2type == Isis::SignedWord) { + ((short int *)jp2buf[0])[i] = (short int)dn; + } + else if(jp2type == Isis::UnsignedWord) { + ((short unsigned int *)jp2buf[0])[i] = (short unsigned int)dn; } } - if (jp2type == Isis::UnsignedByte) { - JP2_encoder->Write((unsigned char**)jp2buf); - } else { - JP2_encoder->Write((short int**)jp2buf); + if(jp2type == Isis::UnsignedByte) { + JP2_encoder->Write((unsigned char **)jp2buf); + } + else { + JP2_encoder->Write((short int **)jp2buf); } } // Write a line of data to the JP2 RGB object -void toJP2RGB (vector &in) { +void toJP2RGB(vector &in) { Buffer &red = *in[0]; Buffer &green = *in[1]; Buffer &blue = *in[2]; @@ -504,36 +517,39 @@ void toJP2RGB (vector &in) { int reddn; int greendn; int bluedn; - for (int i=0; i datamax) ? datamax : (int)red[i]; greendn = ((int)green[i] < datamin) ? datamin : (int)green[i]; greendn = ((int)green[i] > datamax) ? datamax : (int)green[i]; bluedn = ((int)blue[i] < datamin) ? datamin : (int)blue[i]; bluedn = ((int)blue[i] > datamax) ? datamax : (int)blue[i]; - if (jp2type == Isis::UnsignedByte) { - ((unsigned char*)jp2buf[0])[i] = (unsigned char)reddn; - ((unsigned char*)jp2buf[1])[i] = (unsigned char)greendn; - ((unsigned char*)jp2buf[2])[i] = (unsigned char)bluedn; - } else if (jp2type == Isis::SignedWord) { - ((short int*)jp2buf[0])[i] = (short int)reddn; - ((short int*)jp2buf[1])[i] = (short int)greendn; - ((short int*)jp2buf[2])[i] = (short int)bluedn; - } else if (jp2type == Isis::UnsignedWord) { - ((short unsigned int*)jp2buf[0])[i] = (short unsigned int)reddn; - ((short unsigned int*)jp2buf[1])[i] = (short unsigned int)greendn; - ((short unsigned int*)jp2buf[2])[i] = (short unsigned int)bluedn; + if(jp2type == Isis::UnsignedByte) { + ((unsigned char *)jp2buf[0])[i] = (unsigned char)reddn; + ((unsigned char *)jp2buf[1])[i] = (unsigned char)greendn; + ((unsigned char *)jp2buf[2])[i] = (unsigned char)bluedn; + } + else if(jp2type == Isis::SignedWord) { + ((short int *)jp2buf[0])[i] = (short int)reddn; + ((short int *)jp2buf[1])[i] = (short int)greendn; + ((short int *)jp2buf[2])[i] = (short int)bluedn; } + else if(jp2type == Isis::UnsignedWord) { + ((short unsigned int *)jp2buf[0])[i] = (short unsigned int)reddn; + ((short unsigned int *)jp2buf[1])[i] = (short unsigned int)greendn; + ((short unsigned int *)jp2buf[2])[i] = (short unsigned int)bluedn; + } + } + if(jp2type == Isis::UnsignedByte) { + JP2_encoder->Write((unsigned char **)jp2buf); } - if (jp2type == Isis::UnsignedByte) { - JP2_encoder->Write((unsigned char**)jp2buf); - } else { - JP2_encoder->Write((short int**)jp2buf); + else { + JP2_encoder->Write((short int **)jp2buf); } } // Write a line of data to the JP2 ARGB object -void toJP2ARGB (vector &in) { +void toJP2ARGB(vector &in) { Buffer &alpha = *in[0]; Buffer &red = *in[1]; Buffer &green = *in[2]; @@ -543,7 +559,7 @@ void toJP2ARGB (vector &in) { int greendn; int bluedn; int alphadn; - for (int i=0; i datamax) ? datamax : (int)red[i]; greendn = ((int)green[i] < datamin) ? datamin : (int)green[i]; @@ -552,26 +568,29 @@ void toJP2ARGB (vector &in) { bluedn = ((int)blue[i] > datamax) ? datamax : (int)blue[i]; alphadn = ((int)alpha[i] < datamin) ? datamin : (int)alpha[i]; alphadn = ((int)alpha[i] > datamax) ? datamax : (int)alpha[i]; - if (jp2type == Isis::UnsignedByte) { - ((unsigned char*)jp2buf[0])[i] = (unsigned char)reddn; - ((unsigned char*)jp2buf[1])[i] = (unsigned char)greendn; - ((unsigned char*)jp2buf[2])[i] = (unsigned char)bluedn; - ((unsigned char*)jp2buf[3])[i] = (unsigned char)alphadn; - } else if (jp2type == Isis::SignedWord) { - ((short int*)jp2buf[0])[i] = (short int)reddn; - ((short int*)jp2buf[1])[i] = (short int)greendn; - ((short int*)jp2buf[2])[i] = (short int)bluedn; - ((short int*)jp2buf[3])[i] = (short int)alphadn; - } else if (jp2type == Isis::UnsignedWord) { - ((short unsigned int*)jp2buf[0])[i] = (short unsigned int)reddn; - ((short unsigned int*)jp2buf[1])[i] = (short unsigned int)greendn; - ((short unsigned int*)jp2buf[2])[i] = (short unsigned int)bluedn; - ((short unsigned int*)jp2buf[3])[i] = (short unsigned int)alphadn; + if(jp2type == Isis::UnsignedByte) { + ((unsigned char *)jp2buf[0])[i] = (unsigned char)reddn; + ((unsigned char *)jp2buf[1])[i] = (unsigned char)greendn; + ((unsigned char *)jp2buf[2])[i] = (unsigned char)bluedn; + ((unsigned char *)jp2buf[3])[i] = (unsigned char)alphadn; + } + else if(jp2type == Isis::SignedWord) { + ((short int *)jp2buf[0])[i] = (short int)reddn; + ((short int *)jp2buf[1])[i] = (short int)greendn; + ((short int *)jp2buf[2])[i] = (short int)bluedn; + ((short int *)jp2buf[3])[i] = (short int)alphadn; } + else if(jp2type == Isis::UnsignedWord) { + ((short unsigned int *)jp2buf[0])[i] = (short unsigned int)reddn; + ((short unsigned int *)jp2buf[1])[i] = (short unsigned int)greendn; + ((short unsigned int *)jp2buf[2])[i] = (short unsigned int)bluedn; + ((short unsigned int *)jp2buf[3])[i] = (short unsigned int)alphadn; + } + } + if(jp2type == Isis::UnsignedByte) { + JP2_encoder->Write((unsigned char **)jp2buf); } - if (jp2type == Isis::UnsignedByte) { - JP2_encoder->Write((unsigned char**)jp2buf); - } else { - JP2_encoder->Write((short int**)jp2buf); + else { + JP2_encoder->Write((short int **)jp2buf); } } diff --git a/isis/src/base/apps/isisui/isisui.cpp b/isis/src/base/apps/isisui/isisui.cpp index 1670155d1f..6c202aca23 100644 --- a/isis/src/base/apps/isisui/isisui.cpp +++ b/isis/src/base/apps/isisui/isisui.cpp @@ -1,18 +1,18 @@ #include "Application.h" #include "UserInterface.h" -using namespace std; +using namespace std; using namespace Isis; -void interface (); +void interface(); -int main (int argc, char *argv[]) { - int i_argc(argc-1); - Application app(i_argc,&argv[1]); +int main(int argc, char *argv[]) { + int i_argc(argc - 1); + Application app(i_argc, &argv[1]); return app.Exec(interface); } -void interface () { +void interface() { PvlObject hist = Isis::iApp->History(); PvlGroup up = hist.FindGroup("UserParameters"); Pvl pvl; diff --git a/isis/src/base/apps/jigsaw/jigsaw.cpp b/isis/src/base/apps/jigsaw/jigsaw.cpp index 3c89984411..879e2fb9b2 100644 --- a/isis/src/base/apps/jigsaw/jigsaw.cpp +++ b/isis/src/base/apps/jigsaw/jigsaw.cpp @@ -10,7 +10,7 @@ using namespace std; using namespace Isis; void IsisMain() { - + // Get the control network and image list UserInterface &ui = Application::GetUserInterface(); std::string cnetFile = ui.GetFilename("CNET"); @@ -19,12 +19,12 @@ void IsisMain() { // Get the held list if entered and prep for bundle adjustment BundleAdjust *b = NULL; - if (ui.WasEntered("HELDLIST")) { + if(ui.WasEntered("HELDLIST")) { std::string heldList = ui.GetFilename("HELDLIST"); - b = new BundleAdjust(cnetFile,cubeList,heldList); + b = new BundleAdjust(cnetFile, cubeList, heldList); } else { - b = new BundleAdjust(cnetFile,cubeList); + b = new BundleAdjust(cnetFile, cubeList); } b->SetObservationMode(ui.GetBoolean("OBSERVATIONS")); @@ -34,42 +34,42 @@ void IsisMain() { b->SetCkDegree(ui.GetInteger("CKDEGREE")); b->SetSolveCamDegree(ui.GetInteger("SOLVEDEGREE")); std::string camsolve = ui.GetString("CAMSOLVE"); - if (camsolve == "NONE") { - b->SetSolveCmatrix ( BundleAdjust::None ); + if(camsolve == "NONE") { + b->SetSolveCmatrix(BundleAdjust::None); } - else if (camsolve == "ANGLES") { - b->SetSolveCmatrix ( BundleAdjust::AnglesOnly ); + else if(camsolve == "ANGLES") { + b->SetSolveCmatrix(BundleAdjust::AnglesOnly); } - else if (camsolve == "VELOCITIES") { - b->SetSolveCmatrix ( BundleAdjust::AnglesVelocity ); + else if(camsolve == "VELOCITIES") { + b->SetSolveCmatrix(BundleAdjust::AnglesVelocity); } - else if (camsolve == "ACCELERATIONS") { - b->SetSolveCmatrix ( BundleAdjust::AnglesVelocityAcceleration ); + else if(camsolve == "ACCELERATIONS") { + b->SetSolveCmatrix(BundleAdjust::AnglesVelocityAcceleration); } else { - b->SetSolveCmatrix ( BundleAdjust::All ); + b->SetSolveCmatrix(BundleAdjust::All); } - b->SetSolveTwist( ui.GetBoolean("TWIST")); - + b->SetSolveTwist(ui.GetBoolean("TWIST")); + std::string spsolve = ui.GetString("SPSOLVE"); - if (spsolve == "NONE") { - b->SetSolveSpacecraftPosition( BundleAdjust::Nothing ); + if(spsolve == "NONE") { + b->SetSolveSpacecraftPosition(BundleAdjust::Nothing); } - else if (spsolve == "POSITION") { - b->SetSolveSpacecraftPosition ( BundleAdjust::PositionOnly ); + else if(spsolve == "POSITION") { + b->SetSolveSpacecraftPosition(BundleAdjust::PositionOnly); } - else if (spsolve == "VELOCITIES") { - b->SetSolveSpacecraftPosition ( BundleAdjust::PositionVelocity ); + else if(spsolve == "VELOCITIES") { + b->SetSolveSpacecraftPosition(BundleAdjust::PositionVelocity); } else { - b->SetSolveSpacecraftPosition ( BundleAdjust::PositionVelocityAcceleration ); + b->SetSolveSpacecraftPosition(BundleAdjust::PositionVelocityAcceleration); } // Check to make sure user entered something to adjust... Or can just points be in solution? - if (camsolve == "NONE" && spsolve == "NONE") { + if(camsolve == "NONE" && spsolve == "NONE") { string msg = "Must either solve for camera pointing or spacecraft position"; - throw iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw iException::Message(Isis::iException::User, msg, _FILEINFO_); } double tol = ui.GetDouble("TOL"); @@ -77,27 +77,27 @@ void IsisMain() { // Bundle adjust the network try { - b->Solve(tol,maxIterations); + b->Solve(tol, maxIterations); b->ControlNet()->Write(ui.GetFilename("ONET")); - PvlGroup gp( "JigsawResults" ); + PvlGroup gp("JigsawResults"); // Update the cube pointing if requested - if (ui.GetBoolean("UPDATE")) { + if(ui.GetBoolean("UPDATE")) { - for (int i=0; iImages(); i++) { + for(int i = 0; i < b->Images(); i++) { Process p; CubeAttributeInput inAtt; Cube *c = p.SetInputCube(b->Filename(i), inAtt, ReadWrite); //check for existing polygon, if exists delete it - if (c->Label()->HasObject("Polygon")) { + if(c->Label()->HasObject("Polygon")) { c->Label()->DeleteObject("Polygon"); } //check for CameraStatistics Table, if exists, delete - for (int iobj=0; iobjLabel()->Objects(); iobj++) { + for(int iobj = 0; iobj < c->Label()->Objects(); iobj++) { PvlObject obj = c->Label()->Object(iobj); - if (obj.Name() != "Table") continue; - if (obj["Name"][0] != iString("CameraStatistics")) continue; + if(obj.Name() != "Table") continue; + if(obj["Name"][0] != iString("CameraStatistics")) continue; c->Label()->DeleteObject(iobj); break; } @@ -105,7 +105,7 @@ void IsisMain() { // Get Kernel group and add or replace LastModifiedInstrumentPointing // keyword. Table cmatrix = b->Cmatrix(i); - std::string jigComment = "Jigged = "+ Isis::iTime::CurrentLocalTime(); + std::string jigComment = "Jigged = " + Isis::iTime::CurrentLocalTime(); cmatrix.Label().AddComment(jigComment); Table spvector = b->SpVector(i); spvector.Label().AddComment(jigComment); @@ -118,14 +118,14 @@ void IsisMain() { else { gp += PvlKeyword("Status", "Camera pointing NOT updated"); } - Application::Log( gp ); + Application::Log(gp); } - catch (iException &e) { + catch(iException &e) { b->ControlNet()->Write(ui.GetFilename("ONET")); string msg = "Unable to bundle adjust network [" + cnetFile + "]"; - throw iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw iException::Message(Isis::iException::User, msg, _FILEINFO_); } delete b; diff --git a/isis/src/base/apps/kernfilter/kernfilter.cpp b/isis/src/base/apps/kernfilter/kernfilter.cpp index 290bb03c66..e8e26ba791 100644 --- a/isis/src/base/apps/kernfilter/kernfilter.cpp +++ b/isis/src/base/apps/kernfilter/kernfilter.cpp @@ -9,10 +9,10 @@ #include -using namespace std; +using namespace std; using namespace Isis; -void filter (Buffer &in, double &v); +void filter(Buffer &in, double &v); vector coefs; double weight; @@ -25,63 +25,63 @@ void IsisMain() { // Access the Kernel group section of the input file const PvlGroup &kern = pvl.FindGroup("KERNEL"); - int lines = kern["lines"]; + int lines = kern["lines"]; int samples = kern["samples"]; - + // Error check kernel input for impossible boxcar sizes - if (lines <= 0) { + if(lines <= 0) { iString msg = "Your kernel must specify lines count greater than 0"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - if (samples <= 0) { + if(samples <= 0) { iString msg = "Your kernel must specify samples count greater than 0"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // Error check kernel for proper amount of data - lines*samples - if (lines*samples != kern["data"].Size()) { - iString msg = "Your kernel does not specify the correct amount of data, must"; - msg += " be equal to lines * samples ["; - msg += iString(lines * samples); - msg += "] pieces of data"; - throw iException::Message(iException::User,msg,_FILEINFO_); + if(lines *samples != kern["data"].Size()) { + iString msg = "Your kernel does not specify the correct amount of data, must"; + msg += " be equal to lines * samples ["; + msg += iString(lines * samples); + msg += "] pieces of data"; + throw iException::Message(iException::User, msg, _FILEINFO_); } - + ProcessByBoxcar p; // Allocate cubes - p.SetInputCube ("FROM"); - p.SetOutputCube ("TO"); - p.SetBoxcarSize (samples,lines); + p.SetInputCube("FROM"); + p.SetOutputCube("TO"); + p.SetBoxcarSize(samples, lines); // Iterate through the input kernel's data values to fill the coefs array - for (int i = 0 ; i < kern["data"].Size() ; i ++) { - coefs.push_back(kern["data"][i]); + for(int i = 0 ; i < kern["data"].Size() ; i ++) { + coefs.push_back(kern["data"][i]); } - - // Weight for multiplication of resultant immidately before completion + + // Weight for multiplication of resultant immidately before completion weight = kern["weight"]; - p.StartProcess(filter); - p.EndProcess (); + p.StartProcess(filter); + p.EndProcess(); } //! The filter depends on the user input kernel -void filter (Buffer &in, double &result) { +void filter(Buffer &in, double &result) { result = 0.0; - for (int i= 0; i < in.size() && result != Isis::Null; i++) { - if (!IsSpecial(in[i])) { + for(int i = 0; i < in.size() && result != Isis::Null; i++) { + if(!IsSpecial(in[i])) { result += in[i] * coefs[i] ; - } - else { + } + else { // If a special pixel is encountered with the boxcar, resultant pixel is nulled - result = Isis::Null; - } + result = Isis::Null; + } } // If the result isn't null, finish the processing - if (result != Isis::Null) { + if(result != Isis::Null) { result *= weight; - } + } } diff --git a/isis/src/base/apps/kuwahara/kuwahara.cpp b/isis/src/base/apps/kuwahara/kuwahara.cpp index fbb129df99..00c26e12f6 100644 --- a/isis/src/base/apps/kuwahara/kuwahara.cpp +++ b/isis/src/base/apps/kuwahara/kuwahara.cpp @@ -5,77 +5,77 @@ using namespace std; using namespace Isis; -void kuwahara (Buffer &in, double &v); +void kuwahara(Buffer &in, double &v); // Filter size int g_samples; int g_lines; -void IsisMain () { +void IsisMain() { // Get parameters from user ProcessByBoxcar p; - p.SetInputCube ("FROM"); - p.SetOutputCube ("TO"); + p.SetInputCube("FROM"); + p.SetOutputCube("TO"); // Get user input boxcar size UserInterface &ui = Application::GetUserInterface(); g_samples = ui.GetInteger("SAMPLES"); g_lines = ui.GetInteger("LINES"); p.SetBoxcarSize(g_samples, g_lines); - + // Start processing p.StartProcess(kuwahara); p.EndProcess(); } -void kuwahara (Buffer &in, double &result) { - +void kuwahara(Buffer &in, double &result) { + // Find subunit size - int subSamp = 1 + (int) (g_samples / 2); - int subLine = 1 + (int) (g_lines / 2); + int subSamp = 1 + (int)(g_samples / 2); + int subLine = 1 + (int)(g_lines / 2); const int numStats = 4; Statistics stats[ numStats ]; - + // Load up statistics from each subunit grouping int indexTop = 0; // indexTop leads the upper two quadrants int indexBottom = (g_samples * (subLine - 1)); // indexBottom leads the bottom two quadrants - for (int i = 0 ; i < subLine ; i ++ ) { + for(int i = 0 ; i < subLine ; i ++) { stats[0].AddData(&in[ indexTop ], subSamp); // Upper left - stats[1].AddData(&in[ (indexTop + (subSamp - 1)) ], subSamp); // Upper right + stats[1].AddData(&in[(indexTop + (subSamp - 1)) ], subSamp); // Upper right stats[2].AddData(&in[ indexBottom ], subSamp); // Lower left - stats[3].AddData(&in[ (indexBottom + (subSamp - 1)) ], subSamp); // Lower right + stats[3].AddData(&in[(indexBottom + (subSamp - 1)) ], subSamp); // Lower right indexTop += g_samples; indexBottom += g_samples; } // Set first information to results by defualt - double minimum = stats[0].Variance(); + double minimum = stats[0].Variance(); result = stats[0].Average(); // Find subgroup with smallest variance, set its mean to result - for (int i = 1; i < numStats; i ++) { - if (IsSpecial(minimum)) { + for(int i = 1; i < numStats; i ++) { + if(IsSpecial(minimum)) { minimum = stats[i].Variance(); result = stats[i].Average(); - } + } else { - if (IsValidPixel(stats[i].Variance())) { - - // Problems caused in this if between computers because of rounding errors. + if(IsValidPixel(stats[i].Variance())) { + + // Problems caused in this if between computers because of rounding errors. // Cases where there are two equal variances will cause this and can be fixed // by checking equality of the doubles with a powerful methods along with && < - if (stats[i].Variance() < minimum) { - minimum = stats[i].Variance(); - result = stats[i].Average(); + if(stats[i].Variance() < minimum) { + minimum = stats[i].Variance(); + result = stats[i].Average(); } } } } - - // If the program is through without a valid output, its probabaly null, + + // If the program is through without a valid output, its probabaly null, // make sure its null - if (IsSpecial(minimum)) { + if(IsSpecial(minimum)) { result = Isis::Null; } } diff --git a/isis/src/base/apps/lineeq/lineeq.cpp b/isis/src/base/apps/lineeq/lineeq.cpp index 22f8a62119..c4437c001c 100644 --- a/isis/src/base/apps/lineeq/lineeq.cpp +++ b/isis/src/base/apps/lineeq/lineeq.cpp @@ -23,8 +23,8 @@ void IsisMain() { lineAverages.resize(icube->Bands()); for(int i = 0; i < icube->Bands(); i++) { - cubeAverage[i] = 0; - lineAverages[i] = NULL; + cubeAverage[i] = 0; + lineAverages[i] = NULL; } int boxcarSize; @@ -71,7 +71,7 @@ void IsisMain() { QuickFilter filter(icube->Lines(), boxcarSize, 1); if(icube->Lines() <= numIgnoredLines) { - throw iException::Message(iException::User, "Image does not contain any valid data.", _FILEINFO_); + throw iException::Message(iException::User, "Image does not contain any valid data.", _FILEINFO_); } for(int band = 0; band < icube->Bands(); band ++) { @@ -81,7 +81,7 @@ void IsisMain() { for(int line = 0; line < icube->Lines(); line ++) { p.Progress()->CheckStatus(); - double filteredLine = filter.Average(line); + double filteredLine = filter.Average(line); if(csvOutput != NULL) { csvOutput->PutLine((iString)lineAverages[band][line] + (iString)"," + (iString)filteredLine); @@ -123,7 +123,7 @@ void gatherAverages(Buffer &in) { cubeAverage[in.Band() - 1] += average; } else { - numIgnoredLines ++; + numIgnoredLines ++; } } diff --git a/isis/src/base/apps/lowpass/lowpass.cpp b/isis/src/base/apps/lowpass/lowpass.cpp index 9fc187605f..9e3920a53c 100644 --- a/isis/src/base/apps/lowpass/lowpass.cpp +++ b/isis/src/base/apps/lowpass/lowpass.cpp @@ -2,7 +2,7 @@ #include "ProcessByQuickFilter.h" #include "UserInterface.h" -using namespace std; +using namespace std; using namespace Isis; // Which pixel types to filter @@ -14,9 +14,9 @@ bool filterHrs; bool propagate; // Prototype -void FilterAll (Buffer &in, Buffer &out, QuickFilter &filter); -void FilterValid (Buffer &in, Buffer &out, QuickFilter &filter); -void FilterInvalid (Buffer &in, Buffer &out, QuickFilter &filter); +void FilterAll(Buffer &in, Buffer &out, QuickFilter &filter); +void FilterValid(Buffer &in, Buffer &out, QuickFilter &filter); +void FilterInvalid(Buffer &in, Buffer &out, QuickFilter &filter); void IsisMain() { //Set up ProcessByQuickFilter @@ -28,11 +28,11 @@ void IsisMain() { // Find out which special pixels are to be filtered UserInterface &ui = Application::GetUserInterface(); - filterNull = ui.GetBoolean ("NULL"); - filterLis = ui.GetBoolean ("LIS"); - filterLrs = ui.GetBoolean ("LRS"); - filterHis = ui.GetBoolean ("HIS"); - filterHrs = ui.GetBoolean ("HRS"); + filterNull = ui.GetBoolean("NULL"); + filterLis = ui.GetBoolean("LIS"); + filterLrs = ui.GetBoolean("LRS"); + filterHis = ui.GetBoolean("HIS"); + filterHrs = ui.GetBoolean("HRS"); propagate = (ui.GetString("REPLACEMENT") == "CENTER"); //Set the Boxcar Parameters @@ -41,16 +41,16 @@ void IsisMain() { double low = -DBL_MAX; double high = DBL_MAX; int minimum; - if (ui.WasEntered("LOW")) { + if(ui.WasEntered("LOW")) { low = ui.GetDouble("LOW"); } - if (ui.WasEntered("HIGH")) { + if(ui.WasEntered("HIGH")) { high = ui.GetDouble("HIGH"); } - if (ui.GetString("MINOPT") == "PERCENTAGE") { + if(ui.GetString("MINOPT") == "PERCENTAGE") { int size = lines * samples; double perc = ui.GetDouble("MINIMUM") / 100; - minimum = (int) (size * perc); + minimum = (int)(size * perc); } else { minimum = (int)ui.GetDouble("MINIMUM"); @@ -59,7 +59,7 @@ void IsisMain() { p.SetFilterParameters(samples, lines, low, high, minimum); //Start the appropriate filter method - if (ui.GetString("FILTER") == "ALL"){ + if(ui.GetString("FILTER") == "ALL") { p.StartProcess(FilterAll); p.EndProcess(); } @@ -67,7 +67,7 @@ void IsisMain() { p.StartProcess(FilterValid); p.EndProcess(); } - else if (ui.GetString("FILTER") == "OUTSIDE") { + else if(ui.GetString("FILTER") == "OUTSIDE") { p.StartProcess(FilterInvalid); p.EndProcess(); } @@ -76,50 +76,50 @@ void IsisMain() { //Function to loop through the line, and determine the //average value of the pixels around each valid pixel, writing that //average to the output at the pixel index -void FilterValid (Buffer &in, Buffer &out, QuickFilter &filter) { +void FilterValid(Buffer &in, Buffer &out, QuickFilter &filter) { //Loop through each pixel in the line - for (int i=0; i=filter.MinimumPixels() || !propagate){ + if(IsSpecial(in[i])) { + if((IsNullPixel(in[i])) && (filterNull)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); - if (in.Line()==57 && i==60) { - cout<< "Count: " << filter.Count(i) << "Average:" <=filter.MinimumPixels() || !propagate){ + else if((IsLisPixel(in[i])) && (filterLis)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsLrsPixel(in[i])) && (filterLrs)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsLrsPixel(in[i])) && (filterLrs)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsHisPixel(in[i])) && (filterHis)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsHisPixel(in[i])) && (filterHis)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsHrsPixel(in[i])) && (filterHrs)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsHrsPixel(in[i])) && (filterHrs)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { @@ -132,12 +132,12 @@ void FilterValid (Buffer &in, Buffer &out, QuickFilter &filter) { } //If the pixel is Non-Special, run the filter, unless the //center is not valid, as determined by Low and High - else{ - if (in[i]filter.High()){ + else { + if(in[i] < filter.Low() || in[i] > filter.High()) { out[i] = in[i]; } - else{ - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { @@ -149,48 +149,48 @@ void FilterValid (Buffer &in, Buffer &out, QuickFilter &filter) { } //Function to loop through each pixel in a line and find the average -//of the surrounding pixels, and write it to the output, if the +//of the surrounding pixels, and write it to the output, if the //center pixel does not meet the requirements for validity -void FilterInvalid (Buffer &in, Buffer &out, QuickFilter &filter) { - for (int i=0; i=filter.MinimumPixels() || !propagate){ + if(IsSpecial(in[i])) { + if((IsNullPixel(in[i])) && (filterNull)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsLisPixel(in[i])) && (filterLis)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsLisPixel(in[i])) && (filterLis)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsLrsPixel(in[i])) && (filterLrs)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsLrsPixel(in[i])) && (filterLrs)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsHisPixel(in[i])) && (filterHis)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsHisPixel(in[i])) && (filterHis)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsHrsPixel(in[i])) && (filterHrs)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsHrsPixel(in[i])) && (filterHrs)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { @@ -205,11 +205,11 @@ void FilterInvalid (Buffer &in, Buffer &out, QuickFilter &filter) { //valid range, as determined by Low and High, if so, run the //average filter else { - if (in[i]>=filter.Low() && in[i]<=filter.High()){ + if(in[i] >= filter.Low() && in[i] <= filter.High()) { out[i] = in[i]; } - else{ - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { @@ -222,46 +222,46 @@ void FilterInvalid (Buffer &in, Buffer &out, QuickFilter &filter) { //Function to run the Average filter on all pixels, regardless //of their value -void FilterAll (Buffer &in, Buffer &out, QuickFilter &filter) { - for (int i=0; i=filter.MinimumPixels() || !propagate){ + if(IsSpecial(in[i])) { + if((IsNullPixel(in[i])) && (filterNull)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsLisPixel(in[i])) && (filterLis)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsLisPixel(in[i])) && (filterLis)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsLrsPixel(in[i])) && (filterLrs)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsLrsPixel(in[i])) && (filterLrs)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsHisPixel(in[i])) && (filterHis)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsHisPixel(in[i])) && (filterHis)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { out[i] = in[i]; } } - else if ((IsHrsPixel(in[i])) && (filterHrs)) { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + else if((IsHrsPixel(in[i])) && (filterHrs)) { + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { @@ -276,7 +276,7 @@ void FilterAll (Buffer &in, Buffer &out, QuickFilter &filter) { //aren't enough valid pixels for filtering and the center pixel value // is to be propagated else { - if (filter.Count(i)>=filter.MinimumPixels() || !propagate){ + if(filter.Count(i) >= filter.MinimumPixels() || !propagate) { out[i] = filter.Average(i); } else { diff --git a/isis/src/base/apps/makecube/makecube.cpp b/isis/src/base/apps/makecube/makecube.cpp index 7c82ed280d..f104fc2a0f 100644 --- a/isis/src/base/apps/makecube/makecube.cpp +++ b/isis/src/base/apps/makecube/makecube.cpp @@ -2,11 +2,11 @@ #include "ProcessByLine.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; // Glocal declarations -void makecube (Buffer &out); +void makecube(Buffer &out); double value; void IsisMain() { @@ -16,19 +16,19 @@ void IsisMain() { // Get the value to put in the cube UserInterface &ui = Application::GetUserInterface(); string pixels = ui.GetString("PIXELS"); - if (pixels == "NULL") { + if(pixels == "NULL") { value = NULL8; } - else if (pixels == "LIS") { + else if(pixels == "LIS") { value = LOW_INSTR_SAT8; } - else if (pixels == "LRS") { + else if(pixels == "LRS") { value = LOW_REPR_SAT8; } - else if (pixels == "HIS") { + else if(pixels == "HIS") { value = HIGH_INSTR_SAT8; } - else if (pixels == "HRS") { + else if(pixels == "HRS") { value = HIGH_REPR_SAT8; } else { @@ -38,12 +38,12 @@ void IsisMain() { // Need to pick good min/maxs to ensure the user's value // doesn't get saturated CubeAttributeOutput &att = ui.GetOutputAttribute("TO"); - if (IsValidPixel(value)) { - if (value == 0.0) { + if(IsValidPixel(value)) { + if(value == 0.0) { att.Minimum(value); - att.Maximum(value+1.0); - } - if (value < 0.0) { + att.Maximum(value + 1.0); + } + if(value < 0.0) { att.Minimum(value); att.Maximum(-value); } @@ -61,15 +61,15 @@ void IsisMain() { int samps = ui.GetInteger("SAMPLES"); int lines = ui.GetInteger("LINES"); int bands = ui.GetInteger("BANDS"); - p.SetOutputCube (ui.GetFilename("TO"),att,samps,lines,bands); + p.SetOutputCube(ui.GetFilename("TO"), att, samps, lines, bands); // Make the cube p.StartProcess(makecube); p.EndProcess(); } -void makecube (Buffer &out) { - for (int i=0; i excludedFiles; -/** +/** * This will keep track of which framelets are excluded. The * pair is the key, the first number being the file * in the input list (0 = first), the second being the framelet * in the file (0 = first). The double is the standard deviation - * of the framelet. Framelets that arent excluded will not be added + * of the framelet. Framelets that arent excluded will not be added * to this map in order to increase efficiency. */ -map, double> excludedFramelets; +map, double> excludedFramelets; -/** - * This object will be used to keep track of exclusions found during +/** + * This object will be used to keep track of exclusions found during * the creating of the temporary file. The main method will add an object - * onto this list for every pass, with basic keywords such as filename, and + * onto this list for every pass, with basic keywords such as filename, and * the CreateTemporaryData will add a group for every exclusion found. The main * method will trim objects with no exclusion groups. */ vector excludedDetails; -/** +/** * This is used for the line scan camera temporary data. Because * the line scan temporary data creation is done by frame column, * the data in the previous columns of data needs to be stored until @@ -90,13 +90,13 @@ vector excludedDetails; */ vector outputTmpAverages; -/** +/** * This is closely tied with outputTmpAverages, except it keeps track * of valid pixel counts used in the averages. */ vector outputTmpCounts; -/** +/** * This keeps track of the averages of the input framelets for framing * and push frame cameras. For framing cameras, the average is in framelet * zero. This is necessary in order to normalize the temporary data (second pass) @@ -104,7 +104,7 @@ vector outputTmpCounts; */ vector< vector > inputFrameletAverages; -/** +/** * This keeps the statistics for each frame in a line scan camera. This is collected * during the second pass of the data because in a line scan camera, all of the frame * DNs are read before being written to the temporary file (which is possible because @@ -112,7 +112,7 @@ vector< vector > inputFrameletAverages; */ Statistics inputFrameStats; -/** +/** * This is the standard deviation tolerance. For framing cameras, this is the maximum * standard deviation of an image before it is excluded. For push frame cameras, this is * the maximum standard deviation of a framelet. For framing cameras, this is the maximum @@ -121,25 +121,25 @@ Statistics inputFrameStats; */ double maxStdev; -/** +/** * This variable is used in two ways. During pass 2, where the temporary file is being * created, this is the temporary file. During pass 3, where the final output is being * created, this is the final output. */ Cube *ocube = NULL; -/** +/** * This is a line manager that is always associated with ocube. */ LineManager *oLineMgr = NULL; -/** +/** * This is the number of samples in the input images, temporary file,and final output * cubes (one in the same!). */ int numOutputSamples; -/** +/** * This is the number of lines per frame. For line scans, this is how many lines * that are combined into one section for the standard deviation tolerance. For * push frame cameras, this is the number of lines per framelet. For framing @@ -147,7 +147,7 @@ int numOutputSamples; */ int numFrameLines; -/** +/** * This keeps track of special pixel counts for pass 3 of line scan cameras. * This is the count of total valid input DNs for each column of data that is * in the temporary data (sum in the line direction of band 2 of the temporary @@ -155,29 +155,29 @@ int numFrameLines; */ vector numInputDns; -/** +/** * This keeps track of which camera type we're processing. See CameraType. */ CameraType cameraType; -/** +/** * Since in framing and push frame cameras we don't know if the temporary cube has been - * initialized, and the operations all depend on both the input data and current + * initialized, and the operations all depend on both the input data and current * temporary data, this boolean keeps track of whether or not the temporary cube has been * initialized. */ bool cubeInitialized; -/** +/** * This is the image that is currently being processed. This is necessary in order for * the processing methods to determine exclusions and pre-calculated statistics of each * image. */ unsigned int currImage; -/** +/** * This is the main method. Makeflat runs in three steps: - * + * * 1) Calculate statistics * - For all cameras, this checks for one band and matching * sample counts. @@ -185,14 +185,14 @@ unsigned int currImage; * the images and records the averages of each image * - For push frame cameras, this calls CheckFramelets for each * image. - * + * * 2) Create the temporary file, collect more detailed statistics * - For all cameras, this generates the temporary file and calculates * the final exclusion list - * - For framing/push frame cameras, the temporary file is + * - For framing/push frame cameras, the temporary file is * 2 bands, where the first is a sum of DNs from each image/framelet * and the second band is a count of valid DNs that went into each sum - * + * * 3) Create the final flat field file * - For all cameras, this processes the temporary file to create the final flat * field file. @@ -268,7 +268,7 @@ void IsisMain() { /** * Try and validate the image, quick tests first! - * + * * (imageValid &= means imageValid = imageValid && ...) */ bool imageValid = true; @@ -281,7 +281,7 @@ void IsisMain() { // For push frame cameras, there must be valid all framelets if(cameraType == PushFrame) { - imageValid &= (tmp.Lines() % numFrameLines == 0); + imageValid &= (tmp.Lines() % numFrameLines == 0); } // For framing cameras, we need to figure out the size... @@ -303,14 +303,14 @@ void IsisMain() { // entire images, and push frame framelet exclusion stats can not be collected // during pass 2 cleanly if((cameraType == Framing || cameraType == PushFrame) && imageValid) { - string prog = "Calculating Standard Deviation " + iString((int)currImage+1) + "/"; + string prog = "Calculating Standard Deviation " + iString((int)currImage + 1) + "/"; prog += iString((int)inList.size()) + " (" + Filename(inList[currImage]).Name() + ")"; if(cameraType == Framing) { Statistics *stats = tmp.Statistics(1, prog); imageValid &= !IsSpecial(stats->StandardDeviation()); imageValid &= !IsSpecial(stats->Average()); - imageValid &= stats->StandardDeviation() <= maxStdev; + imageValid &= stats->StandardDeviation() <= maxStdev; vector fileStats; fileStats.push_back(stats->Average()); @@ -356,7 +356,7 @@ void IsisMain() { */ if(numOutputSamples <= 0) { string msg = "No valid input cubes were found"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } /** @@ -365,7 +365,7 @@ void IsisMain() { */ if(tempFileLength <= 0) { string msg = "No valid input data was found"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } /** @@ -421,7 +421,7 @@ void IsisMain() { } p.SetInputCube(inList[currImage], inAtt); - iString progText = "Calculating Averages " + iString((int)currImage+1); + iString progText = "Calculating Averages " + iString((int)currImage + 1); progText += "/" + iString((int)inList.size()); progText += " (" + Filename(inList[currImage]).Name() + ")"; p.Progress()->SetText(progText); @@ -431,7 +431,7 @@ void IsisMain() { p.ClearInputCubes(); if(excludedDetails[excludedDetails.size()-1].Groups() == 0) { - excludedDetails.resize(excludedDetails.size()-1); + excludedDetails.resize(excludedDetails.size() - 1); } } @@ -524,7 +524,7 @@ void IsisMain() { ResetGlobals(); } -/** +/** * This method initializes all of the global variables */ void ResetGlobals() { @@ -556,13 +556,13 @@ void ResetGlobals() { } } -/** +/** * This method performs pass1 on one image. It analyzes each framelet's * statistics and populates the necessary global variable. - * + * * @param progress Progress message * @param theCube Current cube that needs processing - * + * * @return bool True if the file contains a valid framelet */ bool CheckFramelets(string progress, Cube &theCube) { @@ -575,13 +575,13 @@ bool CheckFramelets(string progress, Cube &theCube) { vector frameletAvgs; // We need to store off the framelet information, because if no good - // framelets were found then no data should be added to the - // global variable for framelets, just files. - vector< pair > excludedFrameletsTmp; + // framelets were found then no data should be added to the + // global variable for framelets, just files. + vector< pair > excludedFrameletsTmp; Statistics frameletStats; for(int line = 1; line <= theCube.Lines(); line++) { - if((line-1) % numFrameLines == 0) { + if((line - 1) % numFrameLines == 0) { frameletStats.Reset(); } @@ -589,12 +589,12 @@ bool CheckFramelets(string progress, Cube &theCube) { theCube.Read(mgr); frameletStats.AddData(mgr.DoubleBuffer(), mgr.size()); - if((line-1) % numFrameLines == numFrameLines-1) { + if((line - 1) % numFrameLines == numFrameLines - 1) { if(IsSpecial(frameletStats.StandardDeviation()) || - frameletStats.StandardDeviation() > maxStdev) { + frameletStats.StandardDeviation() > maxStdev) { excludedFrameletsTmp.push_back( - pair((line-1)/numFrameLines, frameletStats.StandardDeviation()) - ); + pair((line - 1) / numFrameLines, frameletStats.StandardDeviation()) + ); } else { foundValidFramelet = true; @@ -610,24 +610,24 @@ bool CheckFramelets(string progress, Cube &theCube) { if(foundValidFramelet) { for(unsigned int i = 0; i < excludedFrameletsTmp.size(); i++) { - excludedFramelets.insert(pair< pair, double>( - pair(currImage, excludedFrameletsTmp[i].first), - excludedFrameletsTmp[i].second - ) - ); + excludedFramelets.insert(pair< pair, double>( + pair(currImage, excludedFrameletsTmp[i].first), + excludedFrameletsTmp[i].second + ) + ); } - + } return foundValidFramelet; } -/** +/** * This method is the pass 2 processing routine. A ProcessByBrick - * will call this method for sets of data (depending on the camera + * will call this method for sets of data (depending on the camera * type) and this method is responsible for writing the entire output * temporary cube. - * + * * @param in Input raw image data, not including excluded files */ void CreateTemporaryData(Buffer &in) { @@ -657,7 +657,7 @@ void CreateTemporaryData(Buffer &in) { if(in.Sample() == numOutputSamples) { // Decide if we want this data if(IsSpecial(inputFrameStats.StandardDeviation()) || - inputFrameStats.StandardDeviation() > maxStdev) { + inputFrameStats.StandardDeviation() > maxStdev) { // We don't want this data... // CreateNullData is a helper method for this case that // nulls out the stats @@ -667,18 +667,18 @@ void CreateTemporaryData(Buffer &in) { PvlGroup currExclusion("ExcludedLines"); currExclusion += PvlKeyword("FrameStartLine", iString(in.Line())); currExclusion += PvlKeyword("ValidPixels", iString(inputFrameStats.ValidPixels())); - + if(!IsSpecial(inputFrameStats.StandardDeviation())) currExclusion += PvlKeyword("StandardDeviation", inputFrameStats.StandardDeviation()); else currExclusion += PvlKeyword("StandardDeviation", "N/A"); - + excludedDetails[excludedDetails.size()-1].AddGroup(currExclusion); } // Let's write our data... CreateNullData took care of nulls for us // Band 1 is our normalized average - oLineMgr->SetLine(oLineMgr->Line(),1); + oLineMgr->SetLine(oLineMgr->Line(), 1); for(int i = 0; i < (int)outputTmpAverages.size(); i++) { if(!IsSpecial(outputTmpAverages[i])) { (*oLineMgr)[i] = outputTmpAverages[i] / inputFrameStats.Average(); @@ -687,16 +687,16 @@ void CreateTemporaryData(Buffer &in) { (*oLineMgr)[i] = Isis::Null; } } - + ocube->Write(*oLineMgr); - oLineMgr->SetLine(oLineMgr->Line(),2); + oLineMgr->SetLine(oLineMgr->Line(), 2); // band 2 is our valid dn counts for(int i = 0; i < (int)outputTmpCounts.size(); i++) { (*oLineMgr)[i] = outputTmpCounts[i]; numInputDns[i] += (int)(outputTmpCounts[i] + 0.5); } - + ocube->Write(*oLineMgr); (*oLineMgr) ++; @@ -707,28 +707,28 @@ void CreateTemporaryData(Buffer &in) { // Framing cameras and push frames are treated identically; // the framelet size for a framelet in the framing camera // is the entire image! - int framelet = (in.Line()-1) / numFrameLines; + int framelet = (in.Line() - 1) / numFrameLines; double stdev; bool excluded = Excluded(currImage, framelet, stdev); - if(excluded && ((in.Line()-1) % numFrameLines == 0)) { + if(excluded && ((in.Line() - 1) % numFrameLines == 0)) { PvlGroup currExclusion("ExcludedFramelet"); currExclusion += PvlKeyword("FrameletStartLine", iString(in.Line())); - currExclusion += PvlKeyword("FrameletNumber", (in.Line()-1) / numFrameLines); + currExclusion += PvlKeyword("FrameletNumber", (in.Line() - 1) / numFrameLines); if(!IsSpecial(stdev)) { - currExclusion += PvlKeyword("StandardDeviation", + currExclusion += PvlKeyword("StandardDeviation", stdev); } else { - currExclusion += PvlKeyword("StandardDeviation", + currExclusion += PvlKeyword("StandardDeviation", "N/A"); } excludedDetails[excludedDetails.size()-1].AddGroup(currExclusion); } - // Since this is a line by line iterative process, we need to get the current + // Since this is a line by line iterative process, we need to get the current // data in the temp file oLineMgr->SetLine(((in.Line() - 1) % numFrameLines) + 1, 1); @@ -746,12 +746,12 @@ void CreateTemporaryData(Buffer &in) { if(!excluded || !cubeInitialized) { isValidData.resize(in.size()); - + for(int samp = 0; samp < in.size(); samp++) { if(IsSpecial((*oLineMgr)[samp]) && !IsSpecial(in[samp])) { (*oLineMgr)[samp] = 0.0; } - + if(!IsSpecial(in[samp])) { isValidData[samp] = true; (*oLineMgr)[samp] += in[samp] / inputFrameletAverages[currImage][framelet]; @@ -786,7 +786,7 @@ void CreateTemporaryData(Buffer &in) { if(IsSpecial((*oLineMgr)[i])) { (*oLineMgr)[i] = 0.0; } - + if(isValidData[i]) { (*oLineMgr)[i] ++; } @@ -799,11 +799,11 @@ void CreateTemporaryData(Buffer &in) { } } -/** +/** * This method is the pass 3 processing routine. This compresses * the temporary file into the final flat file. ocube is the final * out file, the Buffer argument is the temp file. - * + * * @param in Line of data in the temporary file generated in pass 2 */ void ProcessTemporaryData(Buffer &in) { @@ -817,14 +817,14 @@ void ProcessTemporaryData(Buffer &in) { cubeInitialized = true; for(int i = 0; i < (*oLineMgr).size(); i++) { - int avgIndex = in.Index(i+1, in.Line(), 1); - int validIndex = in.Index(i+1, in.Line(), 2); - + int avgIndex = in.Index(i + 1, in.Line(), 1); + int validIndex = in.Index(i + 1, in.Line(), 2); + if(!IsSpecial(in[avgIndex]) && !IsSpecial(in[validIndex])) { if(IsSpecial((*oLineMgr)[i])) { (*oLineMgr)[i] = 0.0; } - + (*oLineMgr)[i] += in[avgIndex] * (int)(in[validIndex] + 0.5) / (double)numInputDns[i]; } } @@ -833,8 +833,8 @@ void ProcessTemporaryData(Buffer &in) { oLineMgr->SetLine(((in.Line() - 1) % numFrameLines) + 1); for(int i = 0; i < (*oLineMgr).size(); i++) { - int sumIndex = in.Index(i+1, in.Line(), 1); - int validIndex = in.Index(i+1, in.Line(), 2); + int sumIndex = in.Index(i + 1, in.Line(), 1); + int validIndex = in.Index(i + 1, in.Line(), 2); if(!IsSpecial(in[sumIndex]) && !IsSpecial(in[validIndex])) { (*oLineMgr)[i] = in[sumIndex] / in[validIndex]; @@ -848,7 +848,7 @@ void ProcessTemporaryData(Buffer &in) { } } -/** +/** * This is a helper method for line scan cameras. It removes the * statistics from the global variables that contain the current * frame's data. @@ -860,11 +860,11 @@ void CreateNullData() { } } -/** +/** * This method tests if a file was excluded. - * + * * @param fileNum Zero-indexed file from the FROMLIST (often just currFile) - * + * * @return bool True if file was excluded */ bool Excluded(int fileNum) { @@ -878,20 +878,20 @@ bool Excluded(int fileNum) { } } -/** +/** * This method tests if a framelet in a file was excluded. - * + * * @param fileNum Zero-indexed file from the FROMLIST (often just currFile) * @param frameletNum Framelet to test in the current file * @param stdev This will be set to the standard deviation of the framelet * if the framelet was excluded - * + * * @return bool True if the framelet was excluded */ bool Excluded(int fileNum, int frameletNum, double &stdev) { if(Excluded(fileNum)) return true; - map< pair, double>::iterator it = excludedFramelets.find(pair(fileNum,frameletNum)); + map< pair, double>::iterator it = excludedFramelets.find(pair(fileNum, frameletNum)); if(it == excludedFramelets.end()) { return false; diff --git a/isis/src/base/apps/map2cam/map2cam.cpp b/isis/src/base/apps/map2cam/map2cam.cpp index efdc63c4b1..834d10a528 100644 --- a/isis/src/base/apps/map2cam/map2cam.cpp +++ b/isis/src/base/apps/map2cam/map2cam.cpp @@ -5,13 +5,13 @@ #include "map2cam.h" -using namespace std; +using namespace std; using namespace Isis; // Global variables Cube *mcube; Camera *outcam; -void BandChange (const int band); +void BandChange(const int band); void IsisMain() { // Open the input camera cube that we will be matching and create @@ -19,43 +19,43 @@ void IsisMain() { Process p; mcube = p.SetInputCube("MATCH"); outcam = mcube->Camera(); - + // Open the input projection cube and get the projection information ProcessRubberSheet rub; Cube *icube = rub.SetInputCube("FROM"); Projection *inmap = icube->Projection(); - // Set up for rubbersheeting - Transform *transform = new map2cam (icube->Samples(), - icube->Lines(), - inmap, - mcube->Samples(), - mcube->Lines(), - outcam); - + // Set up for rubbersheeting + Transform *transform = new map2cam(icube->Samples(), + icube->Lines(), + inmap, + mcube->Samples(), + mcube->Lines(), + outcam); + // Allocate the output cube but don't propogate any labels from the map // file. Instead propagate from the camera file rub.PropagateLabels(false); - rub.SetOutputCube ("TO", transform->OutputSamples(), - transform->OutputLines(), - icube->Bands()); + rub.SetOutputCube("TO", transform->OutputSamples(), + transform->OutputLines(), + icube->Bands()); UserInterface &ui = Application::GetUserInterface(); rub.PropagateLabels(ui.GetFilename("MATCH")); - + // Set up the interpolator Interpolator *interp = NULL; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } // See if the camera is band dependent and account for it - if (!outcam->IsBandIndependent()) { + if(!outcam->IsBandIndependent()) { rub.BandChange(BandChange); } @@ -69,10 +69,10 @@ void IsisMain() { } // Transform object constructor -map2cam::map2cam (const int inputSamples, const int inputLines, - Projection *inmap, - const int outputSamples, const int outputLines, - Camera *outcam) { +map2cam::map2cam(const int inputSamples, const int inputLines, + Projection *inmap, + const int outputSamples, const int outputLines, + Camera *outcam) { p_inputSamples = inputSamples; p_inputLines = inputLines; p_inmap = inmap; @@ -80,39 +80,39 @@ map2cam::map2cam (const int inputSamples, const int inputLines, p_outputSamples = outputSamples; p_outputLines = outputLines; p_outcam = outcam; -} +} // Transform method mapping output line/samps to lat/lons to input line/samps -bool map2cam::Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { +bool map2cam::Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { // See if the output image coordinate converts to lat/lon - if (!p_outcam->SetImage(outSample,outLine)) return false; - + if(!p_outcam->SetImage(outSample, outLine)) return false; + // Get the universal lat/lon and see if it can be converted to input line/samp double lat = p_outcam->UniversalLatitude(); double lon = p_outcam->UniversalLongitude(); - if (!p_inmap->SetUniversalGround(lat,lon)) return false; - + if(!p_inmap->SetUniversalGround(lat, lon)) return false; + // Make sure the point is inside the input image - if (p_inmap->WorldX() < 0.5) return false; - if (p_inmap->WorldX() < 0.5) return false; - if (p_inmap->WorldY() > p_inputSamples + 0.5) return false; - if (p_inmap->WorldY() > p_inputLines + 0.5) return false; - + if(p_inmap->WorldX() < 0.5) return false; + if(p_inmap->WorldX() < 0.5) return false; + if(p_inmap->WorldY() > p_inputSamples + 0.5) return false; + if(p_inmap->WorldY() > p_inputLines + 0.5) return false; + // Everything is good inSample = p_inmap->WorldX(); inLine = p_inmap->WorldY(); return true; } - -int map2cam::OutputSamples () const { + +int map2cam::OutputSamples() const { return p_outputSamples; } -int map2cam::OutputLines () const { +int map2cam::OutputLines() const { return p_outputLines; } -void BandChange (const int band) { +void BandChange(const int band) { outcam->SetBand(mcube->PhysicalBand(band)); } diff --git a/isis/src/base/apps/map2cam/map2cam.h b/isis/src/base/apps/map2cam/map2cam.h index 8763feed61..81995866fd 100644 --- a/isis/src/base/apps/map2cam/map2cam.h +++ b/isis/src/base/apps/map2cam/map2cam.h @@ -14,17 +14,17 @@ class map2cam : public Isis::Transform { public: // constructor - map2cam (const int inputSamples, const int inputLines, Isis::Projection *inmap, - const int outputSamples, const int outputLines, Isis::Camera *outcam); - + map2cam(const int inputSamples, const int inputLines, Isis::Projection *inmap, + const int outputSamples, const int outputLines, Isis::Camera *outcam); + // destructor - ~map2cam () {}; + ~map2cam() {}; // Implementations for parent's pure virtual members - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine); - int OutputSamples () const; - int OutputLines () const; + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine); + int OutputSamples() const; + int OutputLines() const; }; #endif diff --git a/isis/src/base/apps/map2map/map2map.cpp b/isis/src/base/apps/map2map/map2map.cpp index 8e628acec5..854cf1ef90 100644 --- a/isis/src/base/apps/map2map/map2map.cpp +++ b/isis/src/base/apps/map2map/map2map.cpp @@ -9,13 +9,13 @@ using namespace std; using namespace Isis; -void PrintMap (); +void PrintMap(); void LoadMapRange(); -map GuiHelpers(){ - map helper; - helper ["PrintMap"] = (void*) PrintMap; - helper ["LoadMapRange"] = (void*) LoadMapRange; +map GuiHelpers() { + map helper; + helper ["PrintMap"] = (void *) PrintMap; + helper ["LoadMapRange"] = (void *) LoadMapRange; return helper; } @@ -26,10 +26,10 @@ void IsisMain() { // Get the map projection file provided by the user UserInterface &ui = Application::GetUserInterface(); Pvl userPvl(ui.GetFilename("MAP")); - PvlGroup &userMappingGrp = userPvl.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userMappingGrp = userPvl.FindGroup("Mapping", Pvl::Traverse); // Open the input cube and get the projection - Cube *icube = p.SetInputCube ("FROM"); + Cube *icube = p.SetInputCube("FROM"); // Get the mapping group PvlGroup fromMappingGrp = icube->GetGroup("Mapping"); @@ -58,19 +58,19 @@ void IsisMain() { // Deal with user overrides entered in the GUI. Do this by changing the user's mapping group, which // will then overlay anything in the output mapping group. if(ui.WasEntered("MINLAT") && !ui.GetBoolean("MATCHMAP")) { - userMappingGrp.AddKeyword( PvlKeyword("MinimumLatitude", ui.GetDouble("MINLAT")), Pvl::Replace ); + userMappingGrp.AddKeyword(PvlKeyword("MinimumLatitude", ui.GetDouble("MINLAT")), Pvl::Replace); } if(ui.WasEntered("MAXLAT") && !ui.GetBoolean("MATCHMAP")) { - userMappingGrp.AddKeyword( PvlKeyword("MaximumLatitude", ui.GetDouble("MAXLAT")), Pvl::Replace ); + userMappingGrp.AddKeyword(PvlKeyword("MaximumLatitude", ui.GetDouble("MAXLAT")), Pvl::Replace); } if(ui.WasEntered("MINLON") && !ui.GetBoolean("MATCHMAP")) { - userMappingGrp.AddKeyword( PvlKeyword("MinimumLongitude", ui.GetDouble("MINLON")), Pvl::Replace ); + userMappingGrp.AddKeyword(PvlKeyword("MinimumLongitude", ui.GetDouble("MINLON")), Pvl::Replace); } if(ui.WasEntered("MAXLON") && !ui.GetBoolean("MATCHMAP")) { - userMappingGrp.AddKeyword( PvlKeyword("MaximumLongitude", ui.GetDouble("MAXLON")), Pvl::Replace ); + userMappingGrp.AddKeyword(PvlKeyword("MaximumLongitude", ui.GetDouble("MAXLON")), Pvl::Replace); } /** @@ -118,7 +118,8 @@ void IsisMain() { outMappingGrp.DeleteKeyword("PixelResolution"); } - if(fromMappingGrp.HasKeyword("Scale")); { + if(fromMappingGrp.HasKeyword("Scale")); + { fromMappingGrp.DeleteKeyword("Scale"); } @@ -263,15 +264,15 @@ void IsisMain() { if(!userMappingGrp.HasKeyword(latitudes[index].Name())) { if(((string)userMappingGrp["LatitudeType"]).compare("Planetographic") == 0) { outMappingGrp[latitudes[index].Name()] = Projection::ToPlanetographic( - (double)fromMappingGrp[latitudes[index].Name()], - (double)fromMappingGrp["EquatorialRadius"], - (double)fromMappingGrp["PolarRadius"]); + (double)fromMappingGrp[latitudes[index].Name()], + (double)fromMappingGrp["EquatorialRadius"], + (double)fromMappingGrp["PolarRadius"]); } else { outMappingGrp[latitudes[index].Name()] = Projection::ToPlanetocentric( - (double)fromMappingGrp[latitudes[index].Name()], - (double)fromMappingGrp["EquatorialRadius"], - (double)fromMappingGrp["PolarRadius"]); + (double)fromMappingGrp[latitudes[index].Name()], + (double)fromMappingGrp["EquatorialRadius"], + (double)fromMappingGrp["PolarRadius"]); } } } @@ -284,14 +285,14 @@ void IsisMain() { if(!ui.WasEntered("MINLON") || !ui.WasEntered("MAXLON")) { string msg = "Unable to determine the correct [MinimumLongitude,MaximumLongitude]."; msg += " Please specify these values in the [MINLON,MAXLON] parameters"; - throw iException::Message(iException::Pvl,msg,_FILEINFO_); + throw iException::Message(iException::Pvl, msg, _FILEINFO_); } } - int samples,lines; + int samples, lines; Pvl mapData; // Copy to preserve cube labels so we can match cube size - if (userPvl.HasObject("IsisCube")) { + if(userPvl.HasObject("IsisCube")) { mapData = userPvl; mapData.FindObject("IsisCube").DeleteGroup("Mapping"); mapData.FindObject("IsisCube").AddGroup(outMappingGrp); @@ -302,50 +303,50 @@ void IsisMain() { // *NOTE: The UpperLeftX,UpperLeftY keywords will not be used in the CreateForCube // method, and they will instead be recalculated. This is correct. - Projection *outproj = ProjectionFactory::CreateForCube(mapData,samples,lines, - ui.GetBoolean("MATCHMAP")); + Projection *outproj = ProjectionFactory::CreateForCube(mapData, samples, lines, + ui.GetBoolean("MATCHMAP")); // Set up the transform object which will simply map // output line/samps -> output lat/lons -> input line/samps - Transform *transform = new map2map (icube->Samples(), - icube->Lines(), - icube->Projection(), - samples, - lines, - outproj, - ui.GetBoolean("TRIM")); + Transform *transform = new map2map(icube->Samples(), + icube->Lines(), + icube->Projection(), + samples, + lines, + outproj, + ui.GetBoolean("TRIM")); // Allocate the output cube and add the mapping labels - Cube *ocube = p.SetOutputCube ("TO", transform->OutputSamples(), - transform->OutputLines(), - icube->Bands()); + Cube *ocube = p.SetOutputCube("TO", transform->OutputSamples(), + transform->OutputLines(), + icube->Bands()); PvlGroup cleanOutGrp = outproj->Mapping(); // ProjectionFactory::CreateForCube updated mapData to have the correct // upperleftcornerx, upperleftcornery, scale and resolution. Use these // updated numbers. - cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping",Pvl::Traverse)["UpperLeftCornerX"], Pvl::Replace); - cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping",Pvl::Traverse)["UpperLeftCornerY"], Pvl::Replace); - cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping",Pvl::Traverse)["Scale"], Pvl::Replace); - cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping",Pvl::Traverse)["PixelResolution"], Pvl::Replace); + cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping", Pvl::Traverse)["UpperLeftCornerX"], Pvl::Replace); + cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping", Pvl::Traverse)["UpperLeftCornerY"], Pvl::Replace); + cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping", Pvl::Traverse)["Scale"], Pvl::Replace); + cleanOutGrp.AddKeyword(mapData.FindGroup("Mapping", Pvl::Traverse)["PixelResolution"], Pvl::Replace); ocube->PutGroup(cleanOutGrp); // Set up the interpolator Interpolator *interp; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } else { string msg = "Unknow value for INTERP [" + ui.GetString("INTERP") + "]"; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } // Warp the cube @@ -360,9 +361,9 @@ void IsisMain() { } // Transform object constructor -map2map::map2map (const int inputSamples, const int inputLines, Projection *inmap, - const int outputSamples, const int outputLines, Projection *outmap, - bool trim) { +map2map::map2map(const int inputSamples, const int inputLines, Projection *inmap, + const int outputSamples, const int outputLines, Projection *outmap, + bool trim) { p_inputSamples = inputSamples; p_inputLines = inputLines; p_inmap = inmap; @@ -383,28 +384,28 @@ map2map::map2map (const int inputSamples, const int inputLines, Projection *inma wrapPossible = wrapPossible && inmap->SetUniversalGround(0, 180); int worldEnd = (int)(inmap->WorldX() + 0.5); - p_inputWorldSize = abs(worldEnd - worldStart)*2; + p_inputWorldSize = abs(worldEnd - worldStart) * 2; } } // Transform method mapping output line/samps to lat/lons to input line/samps -bool map2map::Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { +bool map2map::Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { // See if the output image coordinate converts to lat/lon - if (!p_outmap->SetWorld(outSample,outLine)) return false; + if(!p_outmap->SetWorld(outSample, outLine)) return false; // See if we should trim - if ((p_trim) && (p_outmap->HasGroundRange())) { - if (p_outmap->Latitude() < p_outmap->MinimumLatitude()) return false; - if (p_outmap->Latitude() > p_outmap->MaximumLatitude()) return false; - if (p_outmap->Longitude() < p_outmap->MinimumLongitude()) return false; - if (p_outmap->Longitude() > p_outmap->MaximumLongitude()) return false; + if((p_trim) && (p_outmap->HasGroundRange())) { + if(p_outmap->Latitude() < p_outmap->MinimumLatitude()) return false; + if(p_outmap->Latitude() > p_outmap->MaximumLatitude()) return false; + if(p_outmap->Longitude() < p_outmap->MinimumLongitude()) return false; + if(p_outmap->Longitude() > p_outmap->MaximumLongitude()) return false; } // Get the universal lat/lon and see if it can be converted to input line/samp double lat = p_outmap->UniversalLatitude(); double lon = p_outmap->UniversalLongitude(); - if (!p_inmap->SetUniversalGround(lat,lon)) return false; + if(!p_inmap->SetUniversalGround(lat, lon)) return false; inSample = p_inmap->WorldX(); inLine = p_inmap->WorldY(); @@ -424,20 +425,20 @@ bool map2map::Xform (double &inSample, double &inLine, } // Make sure the point is inside the input image - if (inSample < 0.5) return false; - if (inLine < 0.5) return false; - if (inSample > p_inputSamples + 0.5) return false; - if (inLine > p_inputLines + 0.5) return false; + if(inSample < 0.5) return false; + if(inLine < 0.5) return false; + if(inSample > p_inputSamples + 0.5) return false; + if(inLine > p_inputLines + 0.5) return false; // Everything is good return true; } -int map2map::OutputSamples () const { +int map2map::OutputSamples() const { return p_outputSamples; } -int map2map::OutputLines () const { +int map2map::OutputLines() const { return p_outputLines; } @@ -449,7 +450,7 @@ void PrintMap() { // Get mapping group from map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); //Write map file out to the log Isis::Application::GuiLog(userGrp); @@ -464,7 +465,7 @@ void LoadMapRange() { try { userMap.Read(ui.GetFilename("MAP")); } - catch (iException &e) { + catch(iException &e) { e.Clear(); } @@ -474,7 +475,7 @@ void LoadMapRange() { try { fromMap.Read(ui.GetFilename("FROM")); } - catch (iException &e) { + catch(iException &e) { e.Clear(); } @@ -484,7 +485,7 @@ void LoadMapRange() { try { fromMapping = fromMap.FindGroup("Mapping", Pvl::Traverse); } - catch (iException &e) { + catch(iException &e) { e.Clear(); } @@ -493,7 +494,7 @@ void LoadMapRange() { try { userMapping = userMap.FindGroup("Mapping", Pvl::Traverse); } - catch (iException &e) { + catch(iException &e) { e.Clear(); } @@ -526,23 +527,23 @@ void LoadMapRange() { if(((string)userMapping["LatitudeType"]).compare(fromMapping["LatitudeType"]) != 0) { // new lat type different? if(((string)userMapping["LatitudeType"]).compare("Planetographic") == 0) { fromMapping["MinimumLatitude"] = Projection::ToPlanetographic( - (double)fromMapping["MinimumLatitude"], - (double)fromMapping["EquatorialRadius"], - (double)fromMapping["PolarRadius"]); + (double)fromMapping["MinimumLatitude"], + (double)fromMapping["EquatorialRadius"], + (double)fromMapping["PolarRadius"]); fromMapping["MaximumLatitude"] = Projection::ToPlanetographic( - (double)fromMapping["MaximumLatitude"], - (double)fromMapping["EquatorialRadius"], - (double)fromMapping["PolarRadius"]); + (double)fromMapping["MaximumLatitude"], + (double)fromMapping["EquatorialRadius"], + (double)fromMapping["PolarRadius"]); } else { fromMapping["MinimumLatitude"] = Projection::ToPlanetocentric( - (double)fromMapping["MinimumLatitude"], - (double)fromMapping["EquatorialRadius"], - (double)fromMapping["PolarRadius"]); + (double)fromMapping["MinimumLatitude"], + (double)fromMapping["EquatorialRadius"], + (double)fromMapping["PolarRadius"]); fromMapping["MaximumLatitude"] = Projection::ToPlanetocentric( - (double)fromMapping["MaximumLatitude"], - (double)fromMapping["EquatorialRadius"], - (double)fromMapping["PolarRadius"]); + (double)fromMapping["MaximumLatitude"], + (double)fromMapping["EquatorialRadius"], + (double)fromMapping["PolarRadius"]); } } } @@ -553,7 +554,7 @@ void LoadMapRange() { fromMapping["MinimumLongitude"] = fromMap.FindGroup("Mapping", Pvl::Traverse)["MinimumLongitude"]; fromMapping["MaximumLongitude"] = fromMap.FindGroup("Mapping", Pvl::Traverse)["MaximumLongitude"]; } - catch (iException &e) { + catch(iException &e) { e.Clear(); } } diff --git a/isis/src/base/apps/map2map/map2map.h b/isis/src/base/apps/map2map/map2map.h index 0fdf1098e6..49451b38e8 100644 --- a/isis/src/base/apps/map2map/map2map.h +++ b/isis/src/base/apps/map2map/map2map.h @@ -16,18 +16,18 @@ class map2map : public Isis::Transform { public: // constructor - map2map (const int inputSamples, const int inputLines, Isis::Projection *inmap, - const int outputSamples, const int outputLines, Isis::Projection *outmap, - bool trim); - + map2map(const int inputSamples, const int inputLines, Isis::Projection *inmap, + const int outputSamples, const int outputLines, Isis::Projection *outmap, + bool trim); + // destructor - ~map2map () {}; + ~map2map() {}; // Implementations for parent's pure virtual members - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine); - int OutputSamples () const; - int OutputLines () const; + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine); + int OutputSamples() const; + int OutputLines() const; }; #endif diff --git a/isis/src/base/apps/mapgrid/mapgrid.cpp b/isis/src/base/apps/mapgrid/mapgrid.cpp index 4fa00ccf0c..90fcef1d10 100644 --- a/isis/src/base/apps/mapgrid/mapgrid.cpp +++ b/isis/src/base/apps/mapgrid/mapgrid.cpp @@ -9,9 +9,9 @@ using namespace std; using namespace Isis; -void StartNewLine(std::ofstream&); -void AddPointToLine(std::ofstream&, double, double); -void EndLine(std::ofstream&); +void StartNewLine(std::ofstream &); +void AddPointToLine(std::ofstream &, double, double); +void EndLine(std::ofstream &); void CheckContinuous(double latlon, double latlon_start, double X, double Y, double lastX, double lastY, double maxChange, std::ofstream &os); void IsisMain() { @@ -31,7 +31,7 @@ void IsisMain() { // Get mapfile, add values for range and create projection string mapFile = ui.GetFilename("MAPFILE"); Pvl p(mapFile); - PvlGroup &mapping = p.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &mapping = p.FindGroup("Mapping", Pvl::Traverse); if(mapping.HasKeyword("MinimumLatitude")) { mapping.DeleteKeyword("MinimumLatitude"); @@ -49,30 +49,30 @@ void IsisMain() { mapping.DeleteKeyword("MaximumLongitude"); } - mapping += PvlKeyword("MinimumLatitude",latStart); - mapping += PvlKeyword("MaximumLatitude",latEnd); - mapping += PvlKeyword("MinimumLongitude",lonStart); - mapping += PvlKeyword("MaximumLongitude",lonEnd); + mapping += PvlKeyword("MinimumLatitude", latStart); + mapping += PvlKeyword("MaximumLatitude", latEnd); + mapping += PvlKeyword("MinimumLongitude", lonStart); + mapping += PvlKeyword("MaximumLongitude", lonEnd); Projection *proj; try { proj = ProjectionFactory::Create(p); } - catch (iException &e) { - string msg = "Cannot create grid - MapFile [" + mapFile + - "] does not contain necessary information to create a projection"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + catch(iException &e) { + string msg = "Cannot create grid - MapFile [" + mapFile + + "] does not contain necessary information to create a projection"; + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Write grid to well known text output - string out = Filename(ui.GetFilename("TO")).Expanded(); + string out = Filename(ui.GetFilename("TO")).Expanded(); std::ofstream os; - os.open(out.c_str(),std::ios::out); + os.open(out.c_str(), std::ios::out); // Display the progress...10% 20% etc. Progress prog; - int steps = (int)(abs((latEnd - latStart) / latSpacing) + + int steps = (int)(abs((latEnd - latStart) / latSpacing) + abs((lonEnd - lonStart) / lonSpacing) + 0.5) + 3; prog.SetMaximumSteps(steps); prog.CheckStatus(); @@ -83,20 +83,20 @@ void IsisMain() { */ os << "" << endl; os << "" << endl; + "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"" << endl << + "xsi:schemaLocation=\"http://org.maptools.org/\"" << endl << + "xmlns:ogr=\"http://org.maptools.org/\"" << endl << + "xmlns:gml=\"http://www.opengis.net/gml\">" << endl; /** * Draw the interior longitude lines by looping through the longitude * range and drawing across each latitude line using the longitude increment. The first - * and last line will be skipped for now. + * and last line will be skipped for now. */ - for (double j=lonStart+lonSpacing; jSetGround(k,j); + for(double k = latStart; k <= latEnd; k += lonInc) { + proj->SetGround(k, j); AddPointToLine(os, proj->XCoord(), proj->YCoord()); } @@ -108,10 +108,10 @@ void IsisMain() { * Draw the exterior longitude boundary lines. This happens by drawing just the first and * last longitude lines. */ - for (double r=lonStart; r<=lonEnd; r+=(lonEnd-lonStart)) { + for(double r = lonStart; r <= lonEnd; r += (lonEnd - lonStart)) { StartNewLine(os); - for (double s=latStart; s<=latEnd; s+=lonInc) { - proj->SetGround(s,r); + for(double s = latStart; s <= latEnd; s += lonInc) { + proj->SetGround(s, r); AddPointToLine(os, proj->XCoord(), proj->YCoord()); } EndLine(os); @@ -121,14 +121,14 @@ void IsisMain() { /** * Draw the interior latitude lines by looping through the latitude * range and drawing across each longitude line using the latitude increment. The first - * and last line will be skipped for now. + * and last line will be skipped for now. */ - for (double i=latStart+latSpacing; iSetGround(i,l); + for(double l = lonStart; l <= lonEnd; l += latInc) { + proj->SetGround(i, l); AddPointToLine(os, proj->XCoord(), proj->YCoord()); } EndLine(os); @@ -139,11 +139,11 @@ void IsisMain() { * Draw the exterior latitude boundary lines. This happens by drawing just the first and * last longitude lines. */ - for (double m=latStart; m<=latEnd; m+=(latEnd-latStart)) { + for(double m = latStart; m <= latEnd; m += (latEnd - latStart)) { StartNewLine(os); - for (double n=lonStart; n<=lonEnd; n+=latInc) { - proj->SetGround(m,n); + for(double n = lonStart; n <= lonEnd; n += latInc) { + proj->SetGround(m, n); AddPointToLine(os, proj->XCoord(), proj->YCoord()); } @@ -154,9 +154,9 @@ void IsisMain() { /** * Draw the bounding box using a series of lines. */ - if (ui.GetBoolean("BOUNDED")) { - double minX,maxX,minY,maxY; - proj->XYRange(minX,maxX,minY,maxY); + if(ui.GetBoolean("BOUNDED")) { + double minX, maxX, minY, maxY; + proj->XYRange(minX, maxX, minY, maxY); StartNewLine(os); AddPointToLine(os, minX, minY); @@ -182,22 +182,22 @@ void IsisMain() { os << "" << endl; // add mapping to print.prt - PvlGroup projMapping = proj->Mapping(); - Application::Log(projMapping); + PvlGroup projMapping = proj->Mapping(); + Application::Log(projMapping); } /** * This will prepare a new line start in GML. This should be called every time a new line is * started and generates unique IDs for each line. - * + * * @param os output file stream */ void StartNewLine(std::ofstream &os) { static int lineID = 0; os << "" << endl; - os << " " << endl; - os << " " << lineID << "" << endl; + os << " " << endl; + os << " " << lineID << "" << endl; os << " " << "" << ""; lineID ++; @@ -207,7 +207,7 @@ void StartNewLine(std::ofstream &os) { * This will add a point to a line started with StartNewLine. StartNewLine must be * called before using this method, and EndLine after all of the points in the line have * been added. - * + * * @param os output file stream * @param x x coordinate * @param y y coordinate @@ -219,12 +219,12 @@ void AddPointToLine(std::ofstream &os, const double x, const double y) { /** * This will end a line in GML. This should be called after each line has the necessary points * added using AddPointToLine. - * + * * @param os output file stream */ void EndLine(std::ofstream &os) { os << "" << "" << "" << endl; - os << " " << endl; + os << " " << endl; os << "" << endl; } @@ -232,7 +232,7 @@ void EndLine(std::ofstream &os) { * This function was created to deal with potential discontinuities in mapping patterns in order to not * connect them. It will create a new line if there is more than a maxChange difference in the points. * This was coded for ObliqueCylindrical. - * + * * @param latlon Current latitude or longitude value * @param latlon_start Initial latitude or longitude value of this line * @param X X coordinate of this point diff --git a/isis/src/base/apps/maplab/maplab.cpp b/isis/src/base/apps/maplab/maplab.cpp index dcaeb001c0..6e1c0cae81 100644 --- a/isis/src/base/apps/maplab/maplab.cpp +++ b/isis/src/base/apps/maplab/maplab.cpp @@ -10,10 +10,10 @@ using namespace Isis; using namespace std; -void IsisMain(){ +void IsisMain() { // Access input parameters (user interface) UserInterface &ui = Application::GetUserInterface(); - + // Open the input cube Cube cube; cube.Open(ui.GetFilename("FROM"), "rw"); @@ -21,25 +21,25 @@ void IsisMain(){ //Get the map projection file provided by the user Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &mapGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &mapGrp = userMap.FindGroup("Mapping", Pvl::Traverse); // Error checking to ensure the map projection file provided contains // information pertaining to a target, body radius, and longitude direction - if (!mapGrp.HasKeyword("TargetName")) { + if(!mapGrp.HasKeyword("TargetName")) { string msg = "The given MAP [" + userMap.Name() + - "] does not have the TargetName keyword."; - throw iException::Message( iException::User, msg, _FILEINFO_ ); + "] does not have the TargetName keyword."; + throw iException::Message(iException::User, msg, _FILEINFO_); } - else if (!mapGrp.HasKeyword("EquatorialRadius") || - !mapGrp.HasKeyword("PolarRadius")) { + else if(!mapGrp.HasKeyword("EquatorialRadius") || + !mapGrp.HasKeyword("PolarRadius")) { string msg = "The given MAP [" + userMap.Name() + - "] does not have the EquatorialRadius and PolarRadius keywords."; - throw iException::Message( iException::User, msg, _FILEINFO_ ); + "] does not have the EquatorialRadius and PolarRadius keywords."; + throw iException::Message(iException::User, msg, _FILEINFO_); } - else if (!mapGrp.HasKeyword("LongitudeDomain")) { + else if(!mapGrp.HasKeyword("LongitudeDomain")) { string msg = "The given MAP [" + userMap.Name() + - "] does not have the LongitudeDomain keyword."; - throw iException::Message( iException::User, msg, _FILEINFO_ ); + "] does not have the LongitudeDomain keyword."; + throw iException::Message(iException::User, msg, _FILEINFO_); } //Read in line and sample inputs @@ -50,39 +50,39 @@ void IsisMain(){ string option = ui.GetString("COORDINATES"); //Given x,y coordinates - if(option=="XY") { + if(option == "XY") { //find values for x and y at the origin (upperleftcorner) double x = ui.GetDouble("X"); double y = ui.GetDouble("Y"); //Get Resolution and Scale double res = 0.0; double scale = 0.0; - Projection *proj = ProjectionFactory::Create(userMap,false); - if( mapGrp.HasKeyword("PixelResolution") ) { - double localRadius = proj->LocalRadius( proj->TrueScaleLatitude() ); + Projection *proj = ProjectionFactory::Create(userMap, false); + if(mapGrp.HasKeyword("PixelResolution")) { + double localRadius = proj->LocalRadius(proj->TrueScaleLatitude()); res = mapGrp.FindKeyword("PixelResolution"); scale = (2.0 * Isis::PI * localRadius) / (360.0 * res); } - else if( mapGrp.HasKeyword("Scale") ) { - double localRadius = proj->LocalRadius( proj->TrueScaleLatitude() ); + else if(mapGrp.HasKeyword("Scale")) { + double localRadius = proj->LocalRadius(proj->TrueScaleLatitude()); scale = mapGrp.FindKeyword("Scale"); res = (2.0 * Isis::PI * localRadius) / (360.0 * scale); } else { string msg = "The given MAP [" + userMap.Name() + - "] does not have the PixelResolution or Scale keywords."; - throw iException::Message( iException::User, msg, _FILEINFO_ ); + "] does not have the PixelResolution or Scale keywords."; + throw iException::Message(iException::User, msg, _FILEINFO_); } - x = x - res*(samp - 0.5); - y = y + res*(line - 0.5); + x = x - res * (samp - 0.5); + y = y + res * (line - 0.5); //add origen values to Mapping Group - mapGrp.AddKeyword(PvlKeyword("UpperLeftCornerX",x,"meters"), Pvl::Replace); - mapGrp.AddKeyword(PvlKeyword("UpperLeftCornerY",y,"meters"), Pvl::Replace); - if( not mapGrp.HasKeyword("PixelResolution") ) { - mapGrp.AddKeyword(PvlKeyword("PixelResolution",res,"meters")); + mapGrp.AddKeyword(PvlKeyword("UpperLeftCornerX", x, "meters"), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("UpperLeftCornerY", y, "meters"), Pvl::Replace); + if(not mapGrp.HasKeyword("PixelResolution")) { + mapGrp.AddKeyword(PvlKeyword("PixelResolution", res, "meters")); } - if( not mapGrp.HasKeyword("Scale") ) { - mapGrp.AddKeyword(PvlKeyword("Scale",scale,"pixels/degree")); + if(not mapGrp.HasKeyword("Scale")) { + mapGrp.AddKeyword(PvlKeyword("Scale", scale, "pixels/degree")); } } //Given latitude,longitude coordinates @@ -91,40 +91,40 @@ void IsisMain(){ double lat = ui.GetDouble("LAT"); double lon = ui.GetDouble("LONG"); //create projection using input map - Projection *proj = ProjectionFactory::Create(userMap,false); + Projection *proj = ProjectionFactory::Create(userMap, false); // feed lat, lon into projection - proj->SetGround(lat,lon); + proj->SetGround(lat, lon); //find origen values for x and y double x = proj->XCoord(); double y = proj->YCoord(); //Get Resolution and Scale double res = 0.0; double scale = 0.0; - if( mapGrp.HasKeyword("PixelResolution") ) { - double localRadius = proj->LocalRadius( proj->TrueScaleLatitude() ); + if(mapGrp.HasKeyword("PixelResolution")) { + double localRadius = proj->LocalRadius(proj->TrueScaleLatitude()); res = mapGrp.FindKeyword("PixelResolution"); scale = (2.0 * Isis::PI * localRadius) / (360.0 * res); } - else if( mapGrp.HasKeyword("Scale") ) { - double localRadius = proj->LocalRadius( proj->TrueScaleLatitude() ); + else if(mapGrp.HasKeyword("Scale")) { + double localRadius = proj->LocalRadius(proj->TrueScaleLatitude()); scale = mapGrp.FindKeyword("Scale"); res = (2.0 * Isis::PI * localRadius) / (360.0 * scale); } else { string msg = "The given MAP[" + userMap.Name() + - "] does not have the PixelResolution or Scale keywords."; - throw iException::Message( iException::User, msg, _FILEINFO_ ); + "] does not have the PixelResolution or Scale keywords."; + throw iException::Message(iException::User, msg, _FILEINFO_); } - x = x - res*(samp - 0.5); - y = y + res*(line - 0.5); + x = x - res * (samp - 0.5); + y = y + res * (line - 0.5); //add origen values to Mapping Group - mapGrp.AddKeyword(PvlKeyword("UpperLeftCornerX",x,"meters"), Pvl::Replace); - mapGrp.AddKeyword(PvlKeyword("UpperLeftCornerY",y,"meters"), Pvl::Replace); - if( not mapGrp.HasKeyword("PixelResolution") ) { - mapGrp.AddKeyword(PvlKeyword("PixelResolution",res,"meters")); + mapGrp.AddKeyword(PvlKeyword("UpperLeftCornerX", x, "meters"), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("UpperLeftCornerY", y, "meters"), Pvl::Replace); + if(not mapGrp.HasKeyword("PixelResolution")) { + mapGrp.AddKeyword(PvlKeyword("PixelResolution", res, "meters")); } - if( not mapGrp.HasKeyword("Scale") ) { - mapGrp.AddKeyword(PvlKeyword("Scale",scale,"pixels/degree")); + if(not mapGrp.HasKeyword("Scale")) { + mapGrp.AddKeyword(PvlKeyword("Scale", scale, "pixels/degree")); } } // Output the mapping group used to the Gui session log @@ -133,7 +133,7 @@ void IsisMain(){ Pvl *label = cube.Label(); PvlObject &o = label->FindObject("IsisCube"); //Add Mapping Group to input cube - if (o.HasGroup("Mapping")){ + if(o.HasGroup("Mapping")) { o.DeleteGroup("Mapping"); } o.AddGroup(mapGrp); @@ -141,13 +141,13 @@ void IsisMain(){ //keep track of change to labels in history History hist = History("IsisCube"); try { - cube.Read(hist); + cube.Read(hist); } catch(iException &e) { - e.Clear(); + e.Clear(); } hist.AddEntry(); - cube.Write(hist); + cube.Write(hist); - cube.Close(); + cube.Close(); } diff --git a/isis/src/base/apps/mapmos/mapmos.cpp b/isis/src/base/apps/mapmos/mapmos.cpp index fe30bb25b9..71af731121 100644 --- a/isis/src/base/apps/mapmos/mapmos.cpp +++ b/isis/src/base/apps/mapmos/mapmos.cpp @@ -2,29 +2,29 @@ #include "ProcessMapMosaic.h" #include "PvlGroup.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { // Get the user interface UserInterface &ui = Application::GetUserInterface(); - + ProcessMapMosaic m; // Get the MatchBandBin Flag - m.SetBandBinMatch(ui.GetBoolean("MATCHBANDBIN")); + m.SetBandBinMatch(ui.GetBoolean("MATCHBANDBIN")); // Get the track flag bool bTrack = ui.GetBoolean("TRACK"); - m.SetTrackFlag(bTrack); + m.SetTrackFlag(bTrack); // Get the output projection set up properly - if (ui.GetBoolean("CREATE")) { + if(ui.GetBoolean("CREATE")) { Cube inCube; inCube.Open(ui.GetFilename("FROM")); - // Set the create flag - m.SetCreateFlag(true); + // Set the create flag + m.SetCreateFlag(true); // Use the input projection as a starting point for the mosaic PvlGroup mapGroup = inCube.Label()->FindGroup("Mapping", Pvl::Traverse); @@ -35,7 +35,7 @@ void IsisMain() { mapGroup.AddKeyword(PvlKeyword("MinimumLongitude", ui.GetDouble("MINLON")), Pvl::Replace); mapGroup.AddKeyword(PvlKeyword("MaximumLongitude", ui.GetDouble("MAXLON")), Pvl::Replace); - CubeAttributeOutput oAtt = ui.GetOutputAttribute("MOSAIC"); + CubeAttributeOutput oAtt = ui.GetOutputAttribute("MOSAIC"); m.SetOutputCube(ui.GetFilename("FROM"), mapGroup, oAtt, ui.GetFilename("MOSAIC")); } @@ -44,64 +44,64 @@ void IsisMain() { } // Set up the mosaic priority, either the input cube will be - // placed ontop of the mosaic or beneath it + // placed ontop of the mosaic or beneath it MosaicPriority priority; - string sType; - if (ui.GetString("PRIORITY") == "BENEATH") { + string sType; + if(ui.GetString("PRIORITY") == "BENEATH") { priority = mosaic; } - else if (ui.GetString("PRIORITY") == "ONTOP") { - priority = input; + else if(ui.GetString("PRIORITY") == "ONTOP") { + priority = input; } - else { - priority = band; - sType = ui.GetString("TYPE"); - if (sType=="BANDNUMBER") { - m.SetBandNumber(ui.GetInteger("NUMBER")); - } - else { - // Key Name & Value - m.SetBandKeyWord(ui.GetString("KEYNAME"), ui.GetString("KEYVALUE")); - } - // Band Criteria - BandCriteria eCriteria = Lesser; - if (ui.GetString("CRITERIA") == "GREATER") - eCriteria = Greater; - m.SetBandCriteria(eCriteria); + else { + priority = band; + sType = ui.GetString("TYPE"); + if(sType == "BANDNUMBER") { + m.SetBandNumber(ui.GetInteger("NUMBER")); + } + else { + // Key Name & Value + m.SetBandKeyWord(ui.GetString("KEYNAME"), ui.GetString("KEYVALUE")); + } + // Band Criteria + BandCriteria eCriteria = Lesser; + if(ui.GetString("CRITERIA") == "GREATER") + eCriteria = Greater; + m.SetBandCriteria(eCriteria); } - + // Set priority m.SetPriority(priority); - if (priority == input || priority == band) { - m.SetHighSaturationFlag(ui.GetBoolean("HIGHSATURATION")); - m.SetLowSaturationFlag (ui.GetBoolean("LOWSATURATION")); - m.SetNullFlag(ui.GetBoolean("NULL")); - } - - // Start Process + if(priority == input || priority == band) { + m.SetHighSaturationFlag(ui.GetBoolean("HIGHSATURATION")); + m.SetLowSaturationFlag(ui.GetBoolean("LOWSATURATION")); + m.SetNullFlag(ui.GetBoolean("NULL")); + } + + // Start Process if(!m.StartProcess(ui.GetFilename("FROM"))) { - // Logs the cube if it falls outside of the given mosaic - PvlGroup outsiders("Outside"); - outsiders += PvlKeyword("File", ui.GetFilename("FROM")); - Application::Log(outsiders); + // Logs the cube if it falls outside of the given mosaic + PvlGroup outsiders("Outside"); + outsiders += PvlKeyword("File", ui.GetFilename("FROM")); + Application::Log(outsiders); } - else { - // Logs the input file location in the mosaic - PvlGroup imgPosition("ImageLocation"); - int iStartLine = m.GetInputStartLine(); - int iStartSample = m.GetInputStartSample(); - imgPosition += PvlKeyword("File", ui.GetFilename("FROM")); - imgPosition += PvlKeyword("StartSample", iStartSample); - imgPosition += PvlKeyword("StartLine", iStartLine); - Application::Log(imgPosition); - } - - if (bTrack != m.GetTrackFlag()) { - ui.Clear("TRACK"); - ui.PutBoolean("TRACK", m.GetTrackFlag()); - } - - m.EndProcess(); + else { + // Logs the input file location in the mosaic + PvlGroup imgPosition("ImageLocation"); + int iStartLine = m.GetInputStartLine(); + int iStartSample = m.GetInputStartSample(); + imgPosition += PvlKeyword("File", ui.GetFilename("FROM")); + imgPosition += PvlKeyword("StartSample", iStartSample); + imgPosition += PvlKeyword("StartLine", iStartLine); + Application::Log(imgPosition); + } + + if(bTrack != m.GetTrackFlag()) { + ui.Clear("TRACK"); + ui.PutBoolean("TRACK", m.GetTrackFlag()); + } + + m.EndProcess(); } diff --git a/isis/src/base/apps/mappt/mappt.cpp b/isis/src/base/apps/mappt/mappt.cpp index 8ec93fe1a6..d0b444d9f1 100644 --- a/isis/src/base/apps/mappt/mappt.cpp +++ b/isis/src/base/apps/mappt/mappt.cpp @@ -14,14 +14,14 @@ #include "ProjectionFactory.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void PrintMap (); +void PrintMap(); -map GuiHelpers(){ - map helper; - helper ["PrintMap"] = (void*) PrintMap; +map GuiHelpers() { + map helper; + helper ["PrintMap"] = (void *) PrintMap; return helper; } @@ -37,65 +37,65 @@ void IsisMain() { UserInterface &ui = Application::GetUserInterface(); // Get the sample/line position if we have an image point - if (ui.GetString("TYPE") == "IMAGE") { + if(ui.GetString("TYPE") == "IMAGE") { double samp = ui.GetDouble("SAMPLE"); double line = ui.GetDouble("LINE"); - proj->SetWorld(samp,line); + proj->SetWorld(samp, line); } // Get the lat/lon position if we have a ground point - else if (ui.GetString("TYPE") == "GROUND") { + else if(ui.GetString("TYPE") == "GROUND") { double lat = ui.GetDouble("LATITUDE"); double lon = ui.GetDouble("LONGITUDE"); - + // Make sure we have a valid latitude value - if (fabs(lat) > 90.0) { - string msg = "Invalid value for LATITUDE [" - + iString(lat) + "] outside range of "; + if(fabs(lat) > 90.0) { + string msg = "Invalid value for LATITUDE [" + + iString(lat) + "] outside range of "; msg += "[-90,90]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } iString coordsys = ui.GetString("COORDSYS"); coordsys.UpCase(); // All of these ifs will finish by setting the ground in the projection, - // there are 4 options, Universal, InputFileSystem, Mapfile, and + // there are 4 options, Universal, InputFileSystem, Mapfile, and // Userdefined. // Positive East, 0-360, Planetocentric - if (coordsys == "UNIVERSAL") { + if(coordsys == "UNIVERSAL") { proj->SetUniversalGround(lat, lon); } // Use the coordinate system of the input file - else if (coordsys == "INPUTFILESYS") { + else if(coordsys == "INPUTFILESYS") { proj->SetGround(lat, lon); } // Use the mapping group from a given file - else if (coordsys == "MAP") { + else if(coordsys == "MAP") { Filename mapFile = ui.GetFilename("MAP"); // Does it exist? - if (!mapFile.Exists()) { - string msg = "Filename ["+ ui.GetFilename("MAP") +"] does not exist"; + if(!mapFile.Exists()) { + string msg = "Filename [" + ui.GetFilename("MAP") + "] does not exist"; throw iException::Message(iException::User, msg, _FILEINFO_); } // Load it up into a new projection Pvl mapPvl; mapPvl.Read(mapFile.Expanded()); - Projection * altmap = ProjectionFactory::CreateFromCube(mapPvl); + Projection *altmap = ProjectionFactory::CreateFromCube(mapPvl); // Set lat and lon in its system altmap->SetGround(lat, lon); - // Set universal in input cube from universal from given + // Set universal in input cube from universal from given // mapping/projection proj->SetUniversalGround( altmap->UniversalLatitude(), altmap->UniversalLongitude()); - + // I think this is right, no cube owns it, and the factory doesn't. delete altmap; altmap = NULL; @@ -104,19 +104,19 @@ void IsisMain() { // User defined coordinate system, 8 possible combinations // we only have to make changes for some of them. // Convert from given system to universal and then set. - else if (coordsys == "USERDEFINED") { + else if(coordsys == "USERDEFINED") { double lat2 = lat; double lon2 = lon; - if (ui.GetString("LATTYPE") == "PLANETOGRAPHIC") { + if(ui.GetString("LATTYPE") == "PLANETOGRAPHIC") { lat2 = proj->ToPlanetocentric(lat); } - if (ui.GetString("LONDOM") == "180") { + if(ui.GetString("LONDOM") == "180") { lon2 = proj->To360Domain(lon); } - if (ui.GetString("LONDIR") == "POSITIVEWEST") { + if(ui.GetString("LONDIR") == "POSITIVEWEST") { // Use lon2, we know its already in 0-360 lon2 = proj->ToPositiveEast(lon2, 360); } @@ -129,54 +129,54 @@ void IsisMain() { else { double x = ui.GetDouble("X"); double y = ui.GetDouble("Y"); - proj->SetCoordinate(x,y); + proj->SetCoordinate(x, y); } // Create Brick on samp, line to get the dn value of the pixel - Brick b(1,1,1,icube->PixelType()); - int intSamp = (int)(proj->WorldX()+0.5); - int intLine = (int)(proj->WorldY()+0.5); - b.SetBasePosition(intSamp,intLine,1); + Brick b(1, 1, 1, icube->PixelType()); + int intSamp = (int)(proj->WorldX() + 0.5); + int intLine = (int)(proj->WorldY() + 0.5); + b.SetBasePosition(intSamp, intLine, 1); icube->Read(b); // Log the position - if (proj->IsGood()) { + if(proj->IsGood()) { PvlGroup results("Results"); results += PvlKeyword("Filename", Filename(ui.GetFilename("FROM")).Expanded()); - results += PvlKeyword("Sample",proj->WorldX()); - results += PvlKeyword("Line",proj->WorldY()); - results += PvlKeyword("PixelValue",PixelToString(b[0])); - results += PvlKeyword("X",proj->XCoord()); - results += PvlKeyword("Y",proj->YCoord()); + results += PvlKeyword("Sample", proj->WorldX()); + results += PvlKeyword("Line", proj->WorldY()); + results += PvlKeyword("PixelValue", PixelToString(b[0])); + results += PvlKeyword("X", proj->XCoord()); + results += PvlKeyword("Y", proj->YCoord()); // Put together all the keywords for different coordinate systems. - PvlKeyword centLat = - PvlKeyword("PlanetocentricLatitude",proj->UniversalLatitude()); + PvlKeyword centLat = + PvlKeyword("PlanetocentricLatitude", proj->UniversalLatitude()); - PvlKeyword graphLat = + PvlKeyword graphLat = PvlKeyword("PlanetographicLatitude", proj->ToPlanetographic(proj->UniversalLatitude())); - PvlKeyword pE360 = - PvlKeyword("PositiveEast360Longitude",proj->UniversalLongitude()); + PvlKeyword pE360 = + PvlKeyword("PositiveEast360Longitude", proj->UniversalLongitude()); - PvlKeyword pW360 = + PvlKeyword pW360 = PvlKeyword("PositiveWest360Longitude", - proj->ToPositiveWest(proj->UniversalLongitude(),360)); + proj->ToPositiveWest(proj->UniversalLongitude(), 360)); - PvlKeyword pE180 = + PvlKeyword pE180 = PvlKeyword("PositiveEast180Longitude", proj->To180Domain(proj->UniversalLongitude())); - PvlKeyword pW180 = + PvlKeyword pW180 = PvlKeyword("PositiveWest180Longitude", proj->To180Domain(proj->ToPositiveEast( - proj->UniversalLongitude(),360))); + proj->UniversalLongitude(), 360))); // Input map coordinate system location // Latitude - if (proj->IsPlanetocentric()) { + if(proj->IsPlanetocentric()) { centLat.AddComment("Input map coordinate system"); results += centLat; } @@ -186,8 +186,8 @@ void IsisMain() { } // Longitude - if (proj->IsPositiveEast()) { - if (proj->Has360Domain()) { + if(proj->IsPositiveEast()) { + if(proj->Has360Domain()) { results += pE360; } else { @@ -195,7 +195,7 @@ void IsisMain() { } } else { - if (proj->Has360Domain()) { + if(proj->Has360Domain()) { results += pW360; } else { @@ -205,7 +205,7 @@ void IsisMain() { // Non input corrdinate system locations // Latitude - if (proj->IsPlanetocentric()) { + if(proj->IsPlanetocentric()) { graphLat.AddComment("Location in other coordinate systems"); results += graphLat; } @@ -215,8 +215,8 @@ void IsisMain() { } // Longitude - if (proj->IsPositiveEast()) { - if (proj->Has360Domain()) { + if(proj->IsPositiveEast()) { + if(proj->Has360Domain()) { results += pW360; results += pE180; results += pW180; @@ -228,7 +228,7 @@ void IsisMain() { } } else { - if (proj->Has360Domain()) { + if(proj->Has360Domain()) { results += pE360; results += pE180; results += pW180; @@ -243,17 +243,17 @@ void IsisMain() { Application::Log(results); // Write an output label file if necessary - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { // Get user params from ui string outFile = Filename(ui.GetFilename("TO")).Expanded(); bool exists = Filename(outFile).Exists(); bool append = ui.GetBoolean("APPEND"); // Write the pvl group out to the file - if (ui.GetString("FORMAT") == "PVL") { + if(ui.GetString("FORMAT") == "PVL") { Pvl temp; temp.AddGroup(results); - if (append) { + if(append) { temp.Append(outFile); } else { @@ -266,14 +266,14 @@ void IsisMain() { else { ofstream os; bool writeHeader = false; - if (append) { - os.open(outFile.c_str(),ios::app); - if (!exists) { + if(append) { + os.open(outFile.c_str(), ios::app); + if(!exists) { writeHeader = true; } } else { - os.open(outFile.c_str(),ios::out); + os.open(outFile.c_str(), ios::out); writeHeader = true; } @@ -281,7 +281,7 @@ void IsisMain() { for(int i = 0; i < results.Keywords(); i++) { os << results[i].Name(); - if(i < results.Keywords()-1) { + if(i < results.Keywords() - 1) { os << ","; } } @@ -291,7 +291,7 @@ void IsisMain() { for(int i = 0; i < results.Keywords(); i++) { os << (string)results[i]; - if(i < results.Keywords()-1) { + if(i < results.Keywords() - 1) { os << ","; } } @@ -305,7 +305,7 @@ void IsisMain() { } else { string msg = "Could not project requested position"; - throw iException::Message(iException::Projection,msg,_FILEINFO_); + throw iException::Message(iException::Projection, msg, _FILEINFO_); } } @@ -316,7 +316,7 @@ void PrintMap() { // Get mapping group from map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); //Write map file out to the log Isis::Application::GuiLog(userGrp); diff --git a/isis/src/base/apps/mapsize/mapsize.cpp b/isis/src/base/apps/mapsize/mapsize.cpp index 873abf3e08..5d525dc23a 100644 --- a/isis/src/base/apps/mapsize/mapsize.cpp +++ b/isis/src/base/apps/mapsize/mapsize.cpp @@ -3,7 +3,7 @@ #include "ProjectionFactory.h" #include "Projection.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { @@ -14,19 +14,19 @@ void IsisMain() { Pvl lab; lab.Read(ui.GetFilename("MAP")); - int samples,lines; - Projection *outmap = ProjectionFactory::CreateForCube(lab,samples,lines); + int samples, lines; + Projection *outmap = ProjectionFactory::CreateForCube(lab, samples, lines); // Obtain x/y min/max distances in meters - double xmin,xmax,ymin,ymax; - outmap->XYRange(xmin,xmax,ymin,ymax); + double xmin, xmax, ymin, ymax; + outmap->XYRange(xmin, xmax, ymin, ymax); double xdist = xmax - xmin; double ydist = ymax - ymin; double scale, width, height; double inchesPerMeter = 39.37; // See if the user specified inches or scale - if (ui.GetString("OPTION") == "SCALE") { + if(ui.GetString("OPTION") == "SCALE") { scale = ui.GetDouble("SCALE"); width = xdist / scale * inchesPerMeter; height = ydist / scale * inchesPerMeter; @@ -36,7 +36,7 @@ void IsisMain() { height = ui.GetDouble("HEIGHT"); double xscale = xdist / width * inchesPerMeter; double yscale = ydist / height * inchesPerMeter; - scale = max(xscale,yscale); + scale = max(xscale, yscale); // Recompute as one is likely to be reduced width = xdist / scale * inchesPerMeter; height = ydist / scale * inchesPerMeter; @@ -44,26 +44,26 @@ void IsisMain() { // Create a label and log it PvlGroup results("Results"); - results += PvlKeyword("Map",ui.GetFilename("MAP")); - results += PvlKeyword("Scale",scale); - results += PvlKeyword("Width",width,"inches"); - results += PvlKeyword("Height",height,"inches"); - results += PvlKeyword("Samples",samples); - results += PvlKeyword("Lines",lines); + results += PvlKeyword("Map", ui.GetFilename("MAP")); + results += PvlKeyword("Scale", scale); + results += PvlKeyword("Width", width, "inches"); + results += PvlKeyword("Height", height, "inches"); + results += PvlKeyword("Samples", samples); + results += PvlKeyword("Lines", lines); results += PvlKeyword("RealSize", ((Isis::BigInt)lines * samples * 4) / 1024.0, "KB"); results += PvlKeyword("SignedWordSize", ((Isis::BigInt)lines * samples * 2) / 1024.0, "KB"); results += PvlKeyword("UnsignedByteSize", ((Isis::BigInt)lines * samples) / 1024.0, "KB"); Application::Log(results); // Write the output file if requested - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { Pvl temp; temp.AddGroup(results); - temp.AddGroup(lab.FindGroup("Mapping",Pvl::Traverse)); - temp.Write(ui.GetFilename("TO","txt")); + temp.AddGroup(lab.FindGroup("Mapping", Pvl::Traverse)); + temp.Write(ui.GetFilename("TO", "txt")); } - Application::Log(lab.FindGroup("Mapping",Pvl::Traverse)); + Application::Log(lab.FindGroup("Mapping", Pvl::Traverse)); p.EndProcess(); } diff --git a/isis/src/base/apps/maptemplate/maptemplate.cpp b/isis/src/base/apps/maptemplate/maptemplate.cpp index 1c8b749f31..cd8c004a85 100644 --- a/isis/src/base/apps/maptemplate/maptemplate.cpp +++ b/isis/src/base/apps/maptemplate/maptemplate.cpp @@ -29,22 +29,22 @@ double calcResolution(); //helper button functins in the code void helperButtonLogMap(); -void helperButtonLoadMap (); +void helperButtonLoadMap(); void helperButtonLogTargDef(); void helperButtonLoadTargDef(); void helperButtonLogRadius(); -void helperButtonCalcRange (); -double helperButtonCalcResolution (); - -map GuiHelpers(){ - map helper; - helper ["helperButtonLogMap"] = (void*) helperButtonLogMap; - helper ["helperButtonLoadMap"] = (void*) helperButtonLoadMap; - helper ["helperButtonLogTargDef"] = (void*) helperButtonLogTargDef; - helper ["helperButtonLoadTargDef"] = (void*) helperButtonLoadTargDef; - helper ["helperButtonLogRadius"] = (void*) helperButtonLogRadius; - helper ["helperButtonCalcRange"] = (void*) helperButtonCalcRange; - helper ["helperButtonCalcResolution"] = (void*) helperButtonCalcResolution; +void helperButtonCalcRange(); +double helperButtonCalcResolution(); + +map GuiHelpers() { + map helper; + helper ["helperButtonLogMap"] = (void *) helperButtonLogMap; + helper ["helperButtonLoadMap"] = (void *) helperButtonLoadMap; + helper ["helperButtonLogTargDef"] = (void *) helperButtonLogTargDef; + helper ["helperButtonLoadTargDef"] = (void *) helperButtonLoadTargDef; + helper ["helperButtonLogRadius"] = (void *) helperButtonLogRadius; + helper ["helperButtonCalcRange"] = (void *) helperButtonCalcRange; + helper ["helperButtonCalcResolution"] = (void *) helperButtonCalcResolution; return helper; } @@ -56,14 +56,14 @@ void IsisMain() { addRange(mapping); addResolution(mapping); - // Get map file name form GUI and write the mapping group pvl + // Get map file name form GUI and write the mapping group pvl // to the output file, add .map extension if the // user didnt enter an extension UserInterface &ui = Application::GetUserInterface(); Filename out = ui.GetFilename("MAP"); string output = ui.GetFilename("MAP"); - if (out.Extension() == "") { - output += ".map"; + if(out.Extension() == "") { + output += ".map"; } Pvl p; p.AddGroup(mapping); @@ -71,12 +71,12 @@ void IsisMain() { } //Helper function to output map file to log. -void helperButtonLogMap () { +void helperButtonLogMap() { UserInterface &ui = Application::GetUserInterface(); string mapFile(ui.GetFilename("MAP")); Pvl p; p.Read(mapFile); - PvlGroup t = p.FindGroup("mapping",Pvl::Traverse); + PvlGroup t = p.FindGroup("mapping", Pvl::Traverse); string Ostring = "***** Output of [" + mapFile + "] *****"; Application::GuiLog(Ostring); Application::GuiLog(t); @@ -84,12 +84,12 @@ void helperButtonLogMap () { //...........end of helper function LogMap ........ //Helper 2 function to update GUI with map file values. -void helperButtonLoadMap () { +void helperButtonLoadMap() { UserInterface &ui = Application::GetUserInterface(); string mapFile(ui.GetFilename("MAP")); Pvl p; p.Read(mapFile); - PvlGroup t = p.FindGroup("mapping",Pvl::Traverse); + PvlGroup t = p.FindGroup("mapping", Pvl::Traverse); //Projection Stuff ui.Clear("CLON"); ui.Clear("CLAT"); @@ -100,57 +100,57 @@ void helperButtonLoadMap () { ui.Clear("PLON"); ui.Clear("PROT"); - if (t.HasKeyword("ProjectionName")) { + if(t.HasKeyword("ProjectionName")) { iString projIn = (string)t["ProjectionName"]; projIn.UpCase(); ui.Clear("PROJECTION"); - ui.PutAsString("PROJECTION",projIn); + ui.PutAsString("PROJECTION", projIn); } - if (t.HasKeyword("CenterLongitude")) { + if(t.HasKeyword("CenterLongitude")) { double clonIn = t["CenterLongitude"]; ui.Clear("CLON"); - ui.PutDouble("CLON",clonIn); + ui.PutDouble("CLON", clonIn); } - if (t.HasKeyword("CenterLatitude")) { + if(t.HasKeyword("CenterLatitude")) { double clatIn = t["CenterLatitude"]; ui.Clear("CLAT"); - ui.PutDouble("CLAT",clatIn); + ui.PutDouble("CLAT", clatIn); } - if (t.HasKeyword("ScaleFactor")) { + if(t.HasKeyword("ScaleFactor")) { double scaleFactorIn = t["ScaleFactor"]; ui.Clear("SCALEFACTOR"); - ui.PutDouble("SCALEFACTOR",scaleFactorIn); + ui.PutDouble("SCALEFACTOR", scaleFactorIn); } - if (t.HasKeyword("FirstStandardParallel")) { + if(t.HasKeyword("FirstStandardParallel")) { double par1In = t["FirstStandardParallel"]; ui.Clear("PAR1"); - ui.PutDouble("PAR1",par1In); + ui.PutDouble("PAR1", par1In); } - if (t.HasKeyword("SecondStandardParallel")) { + if(t.HasKeyword("SecondStandardParallel")) { double par2In = t["SecondStandardParallel"]; ui.Clear("PAR2"); - ui.PutDouble("PAR2",par2In); + ui.PutDouble("PAR2", par2In); } - if (t.HasKeyword("PoleLatitude")) { + if(t.HasKeyword("PoleLatitude")) { double pLatIn = t["PoleLatitude"]; ui.Clear("PLAT"); - ui.PutDouble("PLAT",pLatIn); + ui.PutDouble("PLAT", pLatIn); } - if (t.HasKeyword("PoleLongitude")) { + if(t.HasKeyword("PoleLongitude")) { double pLonIn = t["PoleLongitude"]; ui.Clear("PLON"); - ui.PutDouble("PLON",pLonIn); + ui.PutDouble("PLON", pLonIn); } - if (t.HasKeyword("PoleRotation")) { + if(t.HasKeyword("PoleRotation")) { double pRotIn = t["PoleRotation"]; ui.Clear("PROT"); - ui.PutDouble("PROT",pRotIn); + ui.PutDouble("PROT", pRotIn); } //Target Parameters stuff string use = "IMAGE"; ui.Clear("TARGOPT"); - ui.PutAsString("TARGOPT",use); + ui.PutAsString("TARGOPT", use); ui.Clear("TARGDEF"); ui.Clear("TARGETNAME"); ui.Clear("LATTYPE"); @@ -158,34 +158,34 @@ void helperButtonLoadMap () { ui.Clear("EQRADIUS"); ui.Clear("POLRADIUS"); - if (t.HasKeyword("TargetName")) { + if(t.HasKeyword("TargetName")) { string use = "USER"; ui.Clear("TARGOPT"); - ui.PutAsString("TARGOPT",use); + ui.PutAsString("TARGOPT", use); string tNameIn = t["TargetName"]; ui.Clear("TARGETNAME"); - ui.PutAsString("TARGETNAME",tNameIn); + ui.PutAsString("TARGETNAME", tNameIn); iString LTIn = (string)t["LatitudeType"]; LTIn.UpCase(); ui.Clear("LATTYPE"); - ui.PutAsString("LATTYPE",LTIn); + ui.PutAsString("LATTYPE", LTIn); iString LDIn = (string)t["LongitudeDirection"]; LDIn.UpCase(); ui.Clear("LONDIR"); - ui.PutAsString("LONDIR",LDIn); + ui.PutAsString("LONDIR", LDIn); string LDomIn = t["LongitudeDomain"]; ui.Clear("LONDOM"); - ui.PutAsString("LONDOM",LDomIn); + ui.PutAsString("LONDOM", LDomIn); string EQIn = t["EquatorialRadius"]; ui.Clear("EQRADIUS"); - ui.PutAsString("EQRADIUS",EQIn); + ui.PutAsString("EQRADIUS", EQIn); string PRIn = t["PolarRadius"]; ui.Clear("POLRADIUS"); - ui.PutAsString("POLRADIUS",PRIn); + ui.PutAsString("POLRADIUS", PRIn); } //Ground Range Parameter stuff ui.Clear("MINLAT"); @@ -194,52 +194,52 @@ void helperButtonLoadMap () { ui.Clear("MAXLON"); string useR = "IMAGE"; ui.Clear("RNGOPT"); - ui.PutAsString("RNGOPT",useR); + ui.PutAsString("RNGOPT", useR); - if (t.HasKeyword("MinimumLatitude")) { + if(t.HasKeyword("MinimumLatitude")) { double minlatIn = t["MinimumLatitude"]; string useR = "USER"; ui.Clear("RNGOPT"); - ui.PutAsString("RNGOPT",useR); + ui.PutAsString("RNGOPT", useR); ui.Clear("MINLAT"); - ui.PutDouble("MINLAT",minlatIn); + ui.PutDouble("MINLAT", minlatIn); double maxlatIn = t["MaximumLatitude"]; ui.Clear("MAXLAT"); - ui.PutDouble("MAXLAT",maxlatIn); + ui.PutDouble("MAXLAT", maxlatIn); double minlonIn = t["MinimumLongitude"]; ui.Clear("MINLON"); - ui.PutDouble("MINLON",minlonIn); + ui.PutDouble("MINLON", minlonIn); double maxlonIn = t["MaximumLongitude"]; ui.Clear("MAXLON"); - ui.PutDouble("MAXLON",maxlonIn); + ui.PutDouble("MAXLON", maxlonIn); } //Resolution Parameter stuff - if (t.HasKeyword("PixelResolution")) { + if(t.HasKeyword("PixelResolution")) { string useM = "MPP"; ui.Clear("RESOPT"); - ui.PutAsString("RESOPT",useM); + ui.PutAsString("RESOPT", useM); double pixresIn = t["PixelResolution"]; ui.Clear("RESOLUTION"); - ui.PutDouble("RESOLUTION",pixresIn); + ui.PutDouble("RESOLUTION", pixresIn); } - if (t.HasKeyword("Scale")) { + if(t.HasKeyword("Scale")) { string useM = "PPD"; ui.Clear("RESOPT"); - ui.PutAsString("RESOPT",useM); + ui.PutAsString("RESOPT", useM); double Mscale = t["Scale"]; ui.Clear("RESOLUTION"); - ui.PutDouble("RESOLUTION",Mscale); + ui.PutDouble("RESOLUTION", Mscale); } } //----------End Helper function to load map file into GUI ----------- //helper function to output targdef to log -void helperButtonLogTargDef (){ +void helperButtonLogTargDef() { UserInterface &ui = Application::GetUserInterface(); - string targetFile(ui.GetFilename("TARGDEF")); + string targetFile(ui.GetFilename("TARGDEF")); Pvl p; p.Read(targetFile); - PvlGroup t = p.FindGroup("mapping",Pvl::Traverse); + PvlGroup t = p.FindGroup("mapping", Pvl::Traverse); string Ostring = "***** Output of [" + targetFile + "] *****"; Application::GuiLog(Ostring); Application::GuiLog(t); @@ -254,42 +254,42 @@ void helperButtonLoadTargDef() { // test if targdef was entered Pvl p; p.Read(targetFile); - PvlGroup t = p.FindGroup("mapping",Pvl::Traverse); + PvlGroup t = p.FindGroup("mapping", Pvl::Traverse); //Load the targdef values into the GUI string tOpt = "USER"; ui.Clear("TARGOPT"); - ui.PutAsString("TARGOPT",tOpt); - if (t.HasKeyword("TargetName")) { + ui.PutAsString("TARGOPT", tOpt); + if(t.HasKeyword("TargetName")) { string tNameIn = t["TargetName"]; ui.Clear("TARGETNAME"); - ui.PutAsString("TARGETNAME",tNameIn); + ui.PutAsString("TARGETNAME", tNameIn); } - if (t.HasKeyword("LatitudeType")) { + if(t.HasKeyword("LatitudeType")) { iString LTIn = (string)t["LatitudeType"]; LTIn.UpCase(); ui.Clear("LATTYPE"); - ui.PutAsString("LATTYPE",LTIn); + ui.PutAsString("LATTYPE", LTIn); } - if (t.HasKeyword("LongitudeDirection")) { + if(t.HasKeyword("LongitudeDirection")) { iString LDIn = (string)t["LongitudeDirection"]; LDIn.UpCase(); ui.Clear("LONDIR"); - ui.PutAsString("LONDIR",LDIn); + ui.PutAsString("LONDIR", LDIn); } - if (t.HasKeyword("LongitudeDomain")) { + if(t.HasKeyword("LongitudeDomain")) { string LDomIn = t["LongitudeDomain"]; ui.Clear("LONDOM"); - ui.PutAsString("LONDOM",LDomIn); + ui.PutAsString("LONDOM", LDomIn); } - if (t.HasKeyword("EquatorialRadius")) { + if(t.HasKeyword("EquatorialRadius")) { string EQIn = t["EquatorialRadius"]; ui.Clear("EQRADIUS"); - ui.PutAsString("EQRADIUS",EQIn); + ui.PutAsString("EQRADIUS", EQIn); } - if (t.HasKeyword("PolarRadius")) { + if(t.HasKeyword("PolarRadius")) { string PRIn = t["PolarRadius"]; ui.Clear("POLRADIUS"); - ui.PutAsString("POLRADIUS",PRIn); + ui.PutAsString("POLRADIUS", PRIn); } } //-----------end Helper Function to Load target def into GUI -------- @@ -310,40 +310,40 @@ void helperButtonLogRadius() { //-----------end ot log radius helper function--------- //Helper function to run calcRange function. -void helperButtonCalcRange () { +void helperButtonCalcRange() { UserInterface &ui = Application::GetUserInterface(); double minLat; double maxLat; double minLon; double maxLon; // Run the function calcRange of calculate range info - calcRange(minLat,maxLat,minLon,maxLon); + calcRange(minLat, maxLat, minLon, maxLon); // Write ranges to the GUI string use = "USER"; ui.Clear("RNGOPT"); - ui.PutAsString("RNGOPT",use); + ui.PutAsString("RNGOPT", use); ui.Clear("MINLAT"); - ui.PutDouble("MINLAT",minLat); + ui.PutDouble("MINLAT", minLat); ui.Clear("MAXLAT"); - ui.PutDouble("MAXLAT",maxLat); + ui.PutDouble("MAXLAT", maxLat); ui.Clear("MINLON"); - ui.PutDouble("MINLON",minLon); + ui.PutDouble("MINLON", minLon); ui.Clear("MAXLON"); - ui.PutDouble("MAXLON",maxLon); + ui.PutDouble("MAXLON", maxLon); } //--------------End Helper function to run calcRange ---------------- //Helper function to run calcResolution function. -double helperButtonCalcResolution(){ +double helperButtonCalcResolution() { UserInterface &ui = Application::GetUserInterface(); // Call calcResolution which will return a double double Res = calcResolution(); //update the GUI with the new resolution string resUse = "MPP"; ui.Clear("RESOPT"); - ui.PutAsString("RESOPT",resUse); + ui.PutAsString("RESOPT", resUse); ui.Clear("RESOLUTION"); - ui.PutDouble("RESOLUTION",Res); + ui.PutDouble("RESOLUTION", Res); return Res; } //..............End Helper function to run calcResolution @@ -353,7 +353,7 @@ void addProject(PvlGroup &mapping) { UserInterface &ui = Application::GetUserInterface(); iString projName = ui.GetString("PROJECTION"); //setup a look up table for projection names - map projLUT; + map projLUT; projLUT ["SINUSOIDAL"] = "Sinusoidal"; projLUT ["MERCATOR"] = "Mercator"; projLUT ["TRANSVERSEMERCATOR"] = "TransverseMercator"; @@ -365,101 +365,101 @@ void addProject(PvlGroup &mapping) { projLUT ["OBLIQUECYLINDRICAL"] = "ObliqueCylindrical"; // Add Projection keywords to the mappping PVL - mapping += PvlKeyword("ProjectionName",projLUT[projName]); - if (ui.WasEntered("CLON")) { + mapping += PvlKeyword("ProjectionName", projLUT[projName]); + if(ui.WasEntered("CLON")) { double clonOut = ui.GetDouble("CLON"); - mapping += PvlKeyword("CenterLongitude",clonOut); + mapping += PvlKeyword("CenterLongitude", clonOut); } - if (ui.WasEntered("CLAT")) { + if(ui.WasEntered("CLAT")) { double clatOut = ui.GetDouble("CLAT"); - mapping += PvlKeyword("CenterLatitude",clatOut); + mapping += PvlKeyword("CenterLatitude", clatOut); } - if (ui.WasEntered("SCALEFACTOR")) { + if(ui.WasEntered("SCALEFACTOR")) { double scaleFactorOut = ui.GetDouble("SCALEFACTOR"); - mapping += PvlKeyword("ScaleFactor",scaleFactorOut); + mapping += PvlKeyword("ScaleFactor", scaleFactorOut); } - if (ui.WasEntered("PAR1")) { + if(ui.WasEntered("PAR1")) { double par1 = ui.GetDouble("PAR1"); - mapping += PvlKeyword("FirstStandardParallel",par1); + mapping += PvlKeyword("FirstStandardParallel", par1); } - if (ui.WasEntered("PAR2")) { + if(ui.WasEntered("PAR2")) { double par2 = ui.GetDouble("PAR2"); - mapping += PvlKeyword("SecondStandardParallel",par2); + mapping += PvlKeyword("SecondStandardParallel", par2); } - if (ui.WasEntered("PLAT")) { + if(ui.WasEntered("PLAT")) { double plat = ui.GetDouble("PLAT"); - mapping += PvlKeyword("PoleLatitude",plat); + mapping += PvlKeyword("PoleLatitude", plat); } - if (ui.WasEntered("PLON")) { + if(ui.WasEntered("PLON")) { double plon = ui.GetDouble("PLON"); - mapping += PvlKeyword("PoleLongitude",plon); + mapping += PvlKeyword("PoleLongitude", plon); } - if (ui.WasEntered("PROT")) { + if(ui.WasEntered("PROT")) { double prot = ui.GetDouble("PROT"); - mapping += PvlKeyword("PoleRotation",prot); + mapping += PvlKeyword("PoleRotation", prot); } } // Function to Add the target information to the Mapping PVL void addTarget(PvlGroup &mapping) { UserInterface &ui = Application::GetUserInterface(); - if (ui.GetString("TARGOPT") == "SYSTEM") { + if(ui.GetString("TARGOPT") == "SYSTEM") { string targetFile(ui.GetFilename("TARGDEF")); Pvl p; p.Read(targetFile); PvlGroup t = p.FindGroup("mapping"); - if (t.HasKeyword("TargetName")) { + if(t.HasKeyword("TargetName")) { mapping += t["TargetName"]; } - if (t.HasKeyword("EquatorialRadius")) { + if(t.HasKeyword("EquatorialRadius")) { mapping += t["EquatorialRadius"]; } - if (t.HasKeyword("PolarRadius")) { + if(t.HasKeyword("PolarRadius")) { mapping += t["PolarRadius"]; } - if (t.HasKeyword("LatitudeType")) { + if(t.HasKeyword("LatitudeType")) { mapping += t["LatitudeType"]; } - if (t.HasKeyword("LongitudeDirection")) { + if(t.HasKeyword("LongitudeDirection")) { mapping += t["LongitudeDirection"]; } } // if TARGOPT is user and no radii enter the run TargetRadii to get // the system radii for target name. - else if (ui.GetString("TARGOPT") == "USER") { + else if(ui.GetString("TARGOPT") == "USER") { iString targetName = ui.GetString("TARGETNAME"); PvlGroup grp = Projection::TargetRadii(targetName); double equatorialRad = grp["EquatorialRadius"]; double polarRad = grp["PolarRadius"]; // if radii were entered in GUI then set radii to entered value - if (ui.WasEntered("EQRADIUS")) { + if(ui.WasEntered("EQRADIUS")) { equatorialRad = ui.GetDouble("EQRADIUS"); } - if (ui.WasEntered("POLRADIUS")) { + if(ui.WasEntered("POLRADIUS")) { polarRad = ui.GetDouble("POLRADIUS"); } iString latType = ui.GetString("LATTYPE"); - if (latType == "PLANETOCENTRIC") { + if(latType == "PLANETOCENTRIC") { latType = "Planetocentric"; } - else if (latType == "PLANETOGRAPHIC") { + else if(latType == "PLANETOGRAPHIC") { latType = "Planetographic"; } iString lonDir = ui.GetString("LONDIR"); - if (lonDir == "POSITIVEEAST") { + if(lonDir == "POSITIVEEAST") { lonDir = "PositiveEast"; } - else if (lonDir == "POSITIVEWEST") { + else if(lonDir == "POSITIVEWEST") { lonDir = "PositiveWest"; } iString lonDom = ui.GetString("LONDOM"); //Add targdef values to the mapping pvl - mapping += PvlKeyword("TargetName",targetName); - mapping += PvlKeyword("EquatorialRadius",equatorialRad, "meters"); - mapping += PvlKeyword("PolarRadius",polarRad, "meters"); - mapping += PvlKeyword("LatitudeType",latType); - mapping += PvlKeyword("LongitudeDirection",lonDir); - mapping += PvlKeyword("LongitudeDomain",lonDom); + mapping += PvlKeyword("TargetName", targetName); + mapping += PvlKeyword("EquatorialRadius", equatorialRad, "meters"); + mapping += PvlKeyword("PolarRadius", polarRad, "meters"); + mapping += PvlKeyword("LatitudeType", latType); + mapping += PvlKeyword("LongitudeDirection", lonDir); + mapping += PvlKeyword("LongitudeDomain", lonDom); } } @@ -467,28 +467,28 @@ void addTarget(PvlGroup &mapping) { void addRange(PvlGroup &mapping) { UserInterface &ui = Application::GetUserInterface(); //Use the values that have been entered in the GUI - if (ui.GetString("RNGOPT") == "USER") { + if(ui.GetString("RNGOPT") == "USER") { double minLat = ui.GetDouble("MINLAT"); - mapping += PvlKeyword("MinimumLatitude",minLat); + mapping += PvlKeyword("MinimumLatitude", minLat); double maxLat = ui.GetDouble("MAXLAT"); - mapping += PvlKeyword("MaximumLatitude",maxLat); + mapping += PvlKeyword("MaximumLatitude", maxLat); double minLon = ui.GetDouble("MINLON"); - mapping += PvlKeyword("MinimumLongitude",minLon); + mapping += PvlKeyword("MinimumLongitude", minLon); double maxLon = ui.GetDouble("MAXLON"); - mapping += PvlKeyword("MaximumLongitude",maxLon); + mapping += PvlKeyword("MaximumLongitude", maxLon); } - else if (ui.GetString("RNGOPT") == "CALC") { + else if(ui.GetString("RNGOPT") == "CALC") { // calculate range values using function calcRange and fromlist double minLat; double maxLat; double minLon; double maxLon; //Call calcRange to calculate min and max ground range values - calcRange(minLat,maxLat,minLon,maxLon); - mapping += PvlKeyword("MinimumLatitude",minLat); - mapping += PvlKeyword("MaximumLatitude",maxLat); - mapping += PvlKeyword("MinimumLongitude",minLon); - mapping += PvlKeyword("MaximumLongitude",maxLon); + calcRange(minLat, maxLat, minLon, maxLon); + mapping += PvlKeyword("MinimumLatitude", minLat); + mapping += PvlKeyword("MaximumLatitude", maxLat); + mapping += PvlKeyword("MinimumLongitude", minLon); + mapping += PvlKeyword("MaximumLongitude", maxLon); } } @@ -496,23 +496,23 @@ void addRange(PvlGroup &mapping) { void addResolution(PvlGroup &mapping) { // Use values that have been entered in GUI UserInterface &ui = Application::GetUserInterface(); - if (ui.GetString("RESOPT") == "PPD") { + if(ui.GetString("RESOPT") == "PPD") { double res = ui.GetDouble("RESOLUTION"); - mapping += PvlKeyword("Scale",iString(res),"pixels/degree"); + mapping += PvlKeyword("Scale", iString(res), "pixels/degree"); } - else if (ui.GetString("RESOPT") == "MPP") { + else if(ui.GetString("RESOPT") == "MPP") { double res = ui.GetDouble("RESOLUTION"); - mapping += PvlKeyword("PixelResolution",iString(res),"meters/pixel"); + mapping += PvlKeyword("PixelResolution", iString(res), "meters/pixel"); } - else if (ui.GetString("RESOPT") == "CALC") { + else if(ui.GetString("RESOPT") == "CALC") { // run the function to calculate the resolution double Res = calcResolution(); - mapping += PvlKeyword("PixelResolution",Res,"meters/pixel"); + mapping += PvlKeyword("PixelResolution", Res, "meters/pixel"); } } // Function to calculate the ground range from multiple inputs (list of images) -void calcRange(double &minLat, double &maxLat, +void calcRange(double &minLat, double &maxLat, double &minLon, double &maxLon) { UserInterface &ui = Application::GetUserInterface(); FileList flist(ui.GetFilename("FROMLIST")); @@ -520,14 +520,14 @@ void calcRange(double &minLat, double &maxLat, maxLat = -DBL_MAX; minLon = DBL_MAX; maxLon = -DBL_MAX; - //set up PVL of mapping info from GUI:: need to do this so we use the + //set up PVL of mapping info from GUI:: need to do this so we use the // most current info from GUI to calculate the range Pvl userMap; PvlGroup userGrp("Mapping"); - if (ui.GetString("TARGOPT") == "SYSTEM") { + if(ui.GetString("TARGOPT") == "SYSTEM") { userMap.Read(ui.GetFilename("TARGDEF")); } - else if (ui.GetString("TARGOPT") == "USER") { + else if(ui.GetString("TARGOPT") == "USER") { userGrp += PvlKeyword("TargetName", ui.GetString("TARGETNAME")); iString targetName = ui.GetString("TARGETNAME"); PvlGroup grp = Projection::TargetRadii(targetName); @@ -535,25 +535,25 @@ void calcRange(double &minLat, double &maxLat, double polarRad = grp["PolarRadius"]; // if radii were entered in GUI then set radii to entered value - if (ui.WasEntered("EQRADIUS")) { + if(ui.WasEntered("EQRADIUS")) { equatorialRad = ui.GetDouble("EQRADIUS"); } - if (ui.WasEntered("POLRADIUS")) { + if(ui.WasEntered("POLRADIUS")) { polarRad = ui.GetDouble("POLRADIUS"); } - if (ui.GetString("LATTYPE") == "PLANETOCENTRIC") { + if(ui.GetString("LATTYPE") == "PLANETOCENTRIC") { string latType = "Planetocentric"; userGrp += PvlKeyword("LatitudeType", latType); } - else if (ui.GetString("LATTYPE") == "PLANETOGRAPHIC") { + else if(ui.GetString("LATTYPE") == "PLANETOGRAPHIC") { string latType = "Planetographic"; userGrp += PvlKeyword("LatitudeType", latType); } - if (ui.GetString("LONDIR") == "POSITIVEEAST") { + if(ui.GetString("LONDIR") == "POSITIVEEAST") { string lonD = "PositiveEast"; userGrp += PvlKeyword("LongitudeDirection", lonD); } - else if (ui.GetString("LONDIR") == "POSITIVEWEST") { + else if(ui.GetString("LONDIR") == "POSITIVEWEST") { string lonD = "PositiveWest"; userGrp += PvlKeyword("LongitudeDirection", lonD); } @@ -563,7 +563,7 @@ void calcRange(double &minLat, double &maxLat, userMap.AddGroup(userGrp); } - for (int i=0; i<(int)flist.size(); i++) { + for(int i = 0; i < (int)flist.size(); i++) { // Get the mapping group from the camera double camMinLat; double camMaxLat; @@ -571,29 +571,29 @@ void calcRange(double &minLat, double &maxLat, double camMaxLon; Cube c; c.Open(flist[i]); - Camera *cam=c.Camera(); + Camera *cam = c.Camera(); Pvl defaultMap; cam->BasicMapping(defaultMap); PvlGroup &defaultGrp = defaultMap.FindGroup("Mapping"); //Move any defaults that are not in the user map - for (int k=0; kGroundRange(camMinLat,camMaxLat,camMinLon,camMaxLon,userMap); - if (camMinLat < minLat) { + cam->GroundRange(camMinLat, camMaxLat, camMinLon, camMaxLon, userMap); + if(camMinLat < minLat) { minLat = camMinLat; } - if (camMaxLat > maxLat) { + if(camMaxLat > maxLat) { maxLat = camMaxLat; } - if (camMinLon < minLon) { + if(camMinLon < minLon) { minLon = camMinLon; } - if (camMaxLon > maxLon) { + if(camMaxLon > maxLon) { maxLon = camMaxLon; } } @@ -608,20 +608,20 @@ double calcResolution() { double highRes = DBL_MAX; double lowRes = -DBL_MAX; // Loop through the from list at get high and low camera resolution - for (int i=0; i<(int)flist.size(); i++) { + for(int i = 0; i < (int)flist.size(); i++) { Cube c; c.Open(flist[i]); Camera *cam = c.Camera(); double camLowRes = cam->LowestImageResolution(); double camHighRes = cam->HighestImageResolution(); - if (camLowRes > lowRes) lowRes = camLowRes; - if (camHighRes < highRes) highRes = camHighRes; + if(camLowRes > lowRes) lowRes = camLowRes; + if(camHighRes < highRes) highRes = camHighRes; sumRes = sumRes + (camLowRes + camHighRes) / 2.0; } //user input (RESCALCOPT) at GUI will determain what is output // highest, lowest, or avg - if (ui.GetString("RESCALCOPT") == "HIGH") return highRes; - if (ui.GetString("RESCALCOPT") == "LOW") return lowRes; + if(ui.GetString("RESCALCOPT") == "HIGH") return highRes; + if(ui.GetString("RESCALCOPT") == "LOW") return lowRes; return(sumRes / flist.size()); } diff --git a/isis/src/base/apps/maptrim/maptrim.cpp b/isis/src/base/apps/maptrim/maptrim.cpp index 468f83d32c..27560c4e25 100644 --- a/isis/src/base/apps/maptrim/maptrim.cpp +++ b/isis/src/base/apps/maptrim/maptrim.cpp @@ -8,10 +8,10 @@ #include "Application.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void trim(Buffer &in,Buffer &out); +void trim(Buffer &in, Buffer &out); void getSize(Buffer &in); double slat, elat, slon, elon; @@ -20,39 +20,39 @@ Projection *proj; void IsisMain() { // Get the projection - UserInterface &ui = Application::GetUserInterface (); + UserInterface &ui = Application::GetUserInterface(); Pvl pvl(ui.GetFilename("FROM")); proj = ProjectionFactory::CreateFromCube(pvl); - + // Determine ground range to crop and/or trim - if (ui.WasEntered ("MINLAT")) { - slat = ui.GetDouble ("MINLAT"); - elat = ui.GetDouble ("MAXLAT"); - slon = ui.GetDouble ("MINLON"); - elon = ui.GetDouble ("MAXLON"); + if(ui.WasEntered("MINLAT")) { + slat = ui.GetDouble("MINLAT"); + elat = ui.GetDouble("MAXLAT"); + slon = ui.GetDouble("MINLON"); + elon = ui.GetDouble("MAXLON"); } - else if (proj->HasGroundRange()) { + else if(proj->HasGroundRange()) { slat = proj->MinimumLatitude(); elat = proj->MaximumLatitude(); slon = proj->MinimumLongitude(); elon = proj->MaximumLongitude(); } else { - string msg = "Latitude and longitude range not defined in projection"; - throw iException::Message(iException::User,msg,_FILEINFO_); - } + string msg = "Latitude and longitude range not defined in projection"; + throw iException::Message(iException::User, msg, _FILEINFO_); + } string mode = ui.GetString("MODE"); if(mode != "TRIM") { - smallestLine = smallestSample = INT_MAX; - biggestLine = biggestSample = -INT_MAX; + smallestLine = smallestSample = INT_MAX; + biggestLine = biggestSample = -INT_MAX; ProcessByLine p; - p.SetInputCube("FROM"); + p.SetInputCube("FROM"); p.StartProcess(getSize); p.EndProcess(); - + int samples = biggestSample - smallestSample + 1; int lines = biggestLine - smallestLine + 1; @@ -65,12 +65,12 @@ void IsisMain() { else { cropParams += " to=TEMPORARYcropped.cub "; } - + cropParams += " sample= " + iString(smallestSample); cropParams += " nsamples= " + iString(samples); cropParams += " line= " + iString(smallestLine); cropParams += " nlines= " + iString(lines); - + try { Isis::iApp->Exec("crop", cropParams); } @@ -88,24 +88,24 @@ void IsisMain() { } // Trim image if necessary - if(mode != "CROP") { - ProcessByLine p; + if(mode != "CROP") { + ProcessByLine p; CubeAttributeInput att; if(mode == "BOTH") { - p.SetInputCube("TEMPORARYcropped.cub", att); + p.SetInputCube("TEMPORARYcropped.cub", att); } else { //if its trim p.SetInputCube("FROM"); } - p.SetOutputCube("TO"); + p.SetOutputCube("TO"); p.StartProcess(trim); p.EndProcess(); if(mode == "BOTH") remove("TEMPORARYcropped.cub"); } // Add mapping to print.prt - PvlGroup mapping = proj->Mapping(); - Application::Log(mapping); + PvlGroup mapping = proj->Mapping(); + Application::Log(mapping); delete proj; proj = NULL; @@ -114,14 +114,14 @@ void IsisMain() { // Size up the cropped area in terms of lines and samples void getSize(Buffer &in) { double lat, lon; - for (int i = 0; i < in.size(); i++) { - proj->SetWorld ((double)in.Sample(i),(double)in.Line(i)); + for(int i = 0; i < in.size(); i++) { + proj->SetWorld((double)in.Sample(i), (double)in.Line(i)); lat = proj->Latitude(); lon = proj->Longitude(); - + // Skip past pixels outside of lat/lon range - if (lat < slat || lat > elat || lon < slon || lon > elon) { - continue; + if(lat < slat || lat > elat || lon < slon || lon > elon) { + continue; } else { if(in.Line(i) < smallestLine) { @@ -144,12 +144,12 @@ void getSize(Buffer &in) { void trim(Buffer &in, Buffer &out) { // Loop for each pixel in the line. Find lat/lon of pixel, if outside // of range, set to NULL. - double lat,lon; - for (int i = 0; i < in.size(); i++) { - proj->SetWorld ((double)in.Sample(i),(double)in.Line(i)); + double lat, lon; + for(int i = 0; i < in.size(); i++) { + proj->SetWorld((double)in.Sample(i), (double)in.Line(i)); lat = proj->Latitude(); lon = proj->Longitude(); - if (lat < slat || lat > elat || lon < slon || lon > elon) { + if(lat < slat || lat > elat || lon < slon || lon > elon) { out[i] = Isis::Null; } else { diff --git a/isis/src/base/apps/mask/mask.cpp b/isis/src/base/apps/mask/mask.cpp index 17f7e7fd36..a5b5f48327 100644 --- a/isis/src/base/apps/mask/mask.cpp +++ b/isis/src/base/apps/mask/mask.cpp @@ -3,104 +3,103 @@ #include "SpecialPixel.h" #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; -void mask (vector &in, - vector &out); +void mask(vector &in, + vector &out); enum which_special {NONE, NULLP, ALL} spixels; -enum range_preserve {INSIDE,OUTSIDE} preserve; +enum range_preserve {INSIDE, OUTSIDE} preserve; -double minimum,maximum; +double minimum, maximum; bool masked; void IsisMain() { // We will be processing by line ProcessByLine p; - masked= false; + masked = false; // Setup the input and output cubes UserInterface &ui = Application::GetUserInterface(); - - if (!ui.WasEntered("MASK")) + + if(!ui.WasEntered("MASK")) ui.PutFilename("MASK", ui.GetFilename("FROM")); printf("MASK=%s", ui.GetFilename("MASK").c_str()); p.SetInputCube("FROM"); - p.SetInputCube("MASK",OneBand); - p.SetOutputCube ("TO"); + p.SetInputCube("MASK", OneBand); + p.SetOutputCube("TO"); + - // Get min/max info minimum = VALID_MIN8; maximum = VALID_MAX8; - if (ui.WasEntered ("MINIMUM")) minimum = ui.GetDouble ("MINIMUM"); - if (ui.WasEntered ("MAXIMUM")) maximum = ui.GetDouble ("MAXIMUM"); + if(ui.WasEntered("MINIMUM")) minimum = ui.GetDouble("MINIMUM"); + if(ui.WasEntered("MAXIMUM")) maximum = ui.GetDouble("MAXIMUM"); // Will we preserve inside or outside of min/max range preserve = INSIDE; string Preserve; - if (ui.WasEntered ("PRESERVE")) Preserve = ui.GetString ("PRESERVE"); - if (Preserve == "OUTSIDE") preserve = OUTSIDE; + if(ui.WasEntered("PRESERVE")) Preserve = ui.GetString("PRESERVE"); + if(Preserve == "OUTSIDE") preserve = OUTSIDE; // How are special pixels handled? spixels = NULLP; string Spixels; - if (ui.WasEntered ("SPIXELS")) Spixels = ui.GetString ("SPIXELS"); - if (Spixels == "NONE") spixels = NONE; - if (Spixels == "ALL") spixels = ALL; + if(ui.WasEntered("SPIXELS")) Spixels = ui.GetString("SPIXELS"); + if(Spixels == "NONE") spixels = NONE; + if(Spixels == "ALL") spixels = ALL; // Start the processing p.StartProcess(mask); p.EndProcess(); // Report if no masking occurred - if (!masked) { + if(!masked) { string message = "No mask was performed-the output file is the same as "; message += "the input file."; - throw iException::Message(iException::User,message,_FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } } // Line processing routine - void mask (vector &in, - vector &out) - { - - Buffer &inp = *in[0]; - Buffer &mask = *in[1]; - Buffer &outp = *out[0]; - - // Loop for each pixel in the line. - for (int i=0; i= minimum && mask[i] <= maximum)) - outp[i] = inp[i]; - else if (preserve == OUTSIDE && (mask[i] < minimum || mask[i] > maximum)) - outp[i] = inp[i]; - else { - outp[i] = NULL8; - masked = true; - } - } - } - - } +void mask(vector &in, + vector &out) { + + Buffer &inp = *in[0]; + Buffer &mask = *in[1]; + Buffer &outp = *out[0]; + + // Loop for each pixel in the line. + for(int i = 0; i < inp.size(); i++) { + if(IsSpecial(mask[i])) { + if(spixels == ALL) { + outp[i] = NULL8; + masked = true; + } + else if(spixels == NULLP && mask[i] == NULL8) { + outp[i] = NULL8; + masked = true; + } + else { + outp[i] = inp[i]; + } + } + + else { + if(preserve == INSIDE && (mask[i] >= minimum && mask[i] <= maximum)) + outp[i] = inp[i]; + else if(preserve == OUTSIDE && (mask[i] < minimum || mask[i] > maximum)) + outp[i] = inp[i]; + else { + outp[i] = NULL8; + masked = true; + } + } + } + +} diff --git a/isis/src/base/apps/mat2cnet/mat2cnet.cpp b/isis/src/base/apps/mat2cnet/mat2cnet.cpp index 8147742e9e..446006727f 100644 --- a/isis/src/base/apps/mat2cnet/mat2cnet.cpp +++ b/isis/src/base/apps/mat2cnet/mat2cnet.cpp @@ -15,14 +15,14 @@ using namespace std; using namespace Isis; -std::map snMap; +std::map snMap; //std::map fscMap; void IsisMain() { - // The following steps can take a significant amount of time, so + // The following steps can take a significant amount of time, so // set up a progress object, incrementing at 1%, to keep the user informed Isis::PvlGroup &uip = Isis::Preference::Preferences().FindGroup("UserInterface"); - uip["ProgressBarPercent"] = 1; + uip["ProgressBarPercent"] = 1; UserInterface &ui = Application::GetUserInterface(); Progress progress; @@ -33,117 +33,117 @@ void IsisMain() { SerialNumberList snl(ui.GetFilename("LIST3"), true, &progress); progress.CheckStatus(); - if (list2.size() != (unsigned)snl.Size()) { + if(list2.size() != (unsigned)snl.Size()) { iString msg = "Invalid input file number of lines. The ISIS 2 file list ["; msg += ui.GetAsString("LIST2") + "] must contain the same number of lines "; msg += "as the ISIS 3 file list [" + ui.GetAsString("LIST3") + "]"; - throw Isis::iException::Message (Isis::iException::User, msg, _FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } progress.SetText("Mapping Isis 2 fsc numbers to Isis 3 serial numbers."); progress.SetMaximumSteps(list2.size()); // Setup a map between ISIS2 image number (fsc) and ISIS3 sn - for (unsigned int f=0; f((int)fsc, sn)); + } + else if(qube.HasKeyword("IMAGE_ID")) { + fsc = qube.FindKeyword("IMAGE_ID")[0]; + } + else { + throw iException::Message(iException::Pvl, + "Can not find required keyword IMAGE_NUMBER or IMAGE_ID in [" + currFile + "]", + _FILEINFO_); + } + + iString sn(snl.SerialNumber(f)); + snMap.insert(std::pair((int)fsc, sn)); } progress.CheckStatus(); // Create a new control network ControlNet cnet; - cnet.SetType (ControlNet::ImageToGround); - cnet.SetTarget (ui.GetString("TARGET")); + cnet.SetType(ControlNet::ImageToGround); + cnet.SetTarget(ui.GetString("TARGET")); cnet.SetNetworkId(ui.GetString("NETWORKID")); cnet.SetUserName(Isis::Application::UserName()); cnet.SetDescription(ui.GetString("DESCRIPTION")); cnet.SetCreatedDate(Isis::Application::DateTime()); // Open the match point file - TextFile mpFile (ui.GetFilename("MATCH")); + TextFile mpFile(ui.GetFilename("MATCH")); iString currLine; int inTotalMeas = 0; // Read the first line with the number of measurments - mpFile.GetLine (currLine); + mpFile.GetLine(currLine); currLine.Token("="); currLine.Token(" "); - try{ + try { inTotalMeas = int(currLine); } catch(Isis::iException &e) { throw iException::Message(iException::User, "Invalid match point file header for [" - + ui.GetAsString("MATCH") + + ui.GetAsString("MATCH") + "]. First line does not contain number of measurements." , _FILEINFO_); } - // Read line 2, the column header line - mpFile.GetLine (currLine); + // Read line 2, the column header line + mpFile.GetLine(currLine); currLine.ConvertWhiteSpace(); currLine.Compress(); - while (currLine!= "") { + while(currLine != "") { iString label = currLine.Token(" "); - // this line should contain only text labels, + // this line should contain only text labels, double error = 0; try { error = label; // if we are able to convert label to a double, we have an error throw iException::Message(iException::User, "Invalid match point file header for [" - + ui.GetAsString("MATCH") + + ui.GetAsString("MATCH") + "]. Second line does not contain proper non-numerical column labels." , _FILEINFO_); } - catch ( Isis::iException e ) { - // if this line does not contain a double, continue - if (error == 0) { + catch(Isis::iException e) { + // if this line does not contain a double, continue + if(error == 0) { e.Clear();// not really an error, this is text value, as expected continue; } // if this line contains numeric data, throw an error - else{ + else { throw e; } } } - + // Reset the progress object for feedback about conversion processing progress.SetText("Converting match point file"); progress.SetMaximumSteps(inTotalMeas); int line = 2; - while (mpFile.GetLine(currLine)) { + while(mpFile.GetLine(currLine)) { line ++; // Update the Progress object try { progress.CheckStatus(); - } - catch ( Isis::iException e ) { + } + catch(Isis::iException e) { string msg = "\"Matchpoint total\" keyword at the top of the match point file ["; msg += ui.GetAsString("MATCH") + "] equals [" + iString(inTotalMeas); msg += "] and is likely incorrect. Number of measures in match point file exceeds this value at line ["; msg += iString(line) + "]."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } - + // Declare the Point and Measure ControlPoint *cpoint; @@ -156,27 +156,27 @@ void IsisMain() { iString fsc = ""; double lineNum, sampNum, diam; string matClass = ""; - try{ + try { pid = currLine.Token(" "); // ID of the point fsc = currLine.Token(" "); // FSC of the Isis 2 cube - lineNum = currLine.Token(" "); // line number - sampNum = currLine.Token(" "); // sample number + lineNum = currLine.Token(" "); // line number + sampNum = currLine.Token(" "); // sample number matClass = currLine.Token(" "); // Match Point Class diam = currLine.Token(" "); // Diameter, in case of a crater } - catch (iException &e){ + catch(iException &e) { iString msg = "Invalid value(s) in match point file ["; msg += ui.GetAsString("MATCH") + "] at line [" + iString(line); msg += "]. Verify line, sample, diameter values are doubles."; - throw Isis::iException::Message (Isis::iException::User, msg, _FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Set the coordinate and serial number for this measure - cmeasure.SetCoordinate(sampNum,lineNum); + cmeasure.SetCoordinate(sampNum, lineNum); cmeasure.SetCubeSerialNumber(snMap[(int)fsc]); - if(snMap[(int)fsc].empty()) { + if(snMap[(int)fsc].empty()) { std::string msg = "None of the images specified in the ISIS 2 file list ["; msg += ui.GetAsString("LIST2"); msg += "] have an IMAGE_NUMBER or IMAGE_ID that matches the FSC [" + fsc; @@ -186,37 +186,37 @@ void IsisMain() { } //Set the Measure Type - if (iString::Equal(matClass,"T")) { + if(iString::Equal(matClass, "T")) { cmeasure.SetReference(true); cmeasure.SetType(ControlMeasure::ValidatedManual); } - else if (iString::Equal(matClass,"M")) { + else if(iString::Equal(matClass, "M")) { cmeasure.SetType(ControlMeasure::ValidatedManual); } - else if (iString::Equal(matClass,"S")) { + else if(iString::Equal(matClass, "S")) { cmeasure.SetType(ControlMeasure::ValidatedAutomatic); } - else if (iString::Equal(matClass,"U") && - (cmeasure.Sample() != 0.0) && (cmeasure.Line() != 0.0)) { + else if(iString::Equal(matClass, "U") && + (cmeasure.Sample() != 0.0) && (cmeasure.Line() != 0.0)) { cmeasure.SetType(ControlMeasure::Estimated); } - else if (iString::Equal(matClass,"U")) { + else if(iString::Equal(matClass, "U")) { cmeasure.SetType(ControlMeasure::Unmeasured); } else { iString msg = "Unknown measurment type [" + matClass + "] "; msg += "in match point file [" + ui.GetAsString("MATCH") + "] "; msg += "at line [" + iString(line) + "]"; - throw Isis::iException::Message (Isis::iException::User, msg, _FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } //Set Diameter try { //Check to see if the column was, in fact, a double cmeasure.SetDiameter(diam); - } - catch (iException &e) { - //If we get here, diam was not a double, + } + catch(iException &e) { + //If we get here, diam was not a double, // but the error is not important otherwise e.Clear(); } @@ -224,10 +224,10 @@ void IsisMain() { //Find the point that matches the PointID, create point if it does not exist try { cpoint = cnet.Find(pid); - } - catch (iException &e) { + } + catch(iException &e) { // point not found in control net, but this is not an error, so clear exception - e.Clear(); + e.Clear(); // add point to control net, default point type is "Tie" e.Clear(); cnet.Add(ControlPoint(pid)); @@ -237,12 +237,12 @@ void IsisMain() { //Add the measure try { cpoint->Add(cmeasure); - } - catch (iException &e) { + } + catch(iException &e) { iString msg = "Invalid match point file [" + ui.GetAsString("MATCH") + "]"; msg += ". Repeated PointID/FSC combination [" + pid + ", " + fsc; msg += "] in match point file at line [" + iString(line) + "]."; - throw Isis::iException::Message (Isis::iException::User, msg, _FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } @@ -250,12 +250,12 @@ void IsisMain() { try { progress.CheckStatus(); } - catch ( Isis::iException e ) { + catch(Isis::iException e) { string msg = "\"Matchpoint total\" keyword at the top of the match point file ["; msg += ui.GetAsString("MATCH") + "] equals [" + iString(inTotalMeas); msg += "] and is likely incorrect. Number of measures in match point file exceeds this value at line ["; msg += iString(line) + "]."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } @@ -263,107 +263,107 @@ void IsisMain() { // Added RAND PPP file as input ////////////////////////////// // Open the RAND PPP file - if (ui.GetBoolean("INPUTPPP")) { + if(ui.GetBoolean("INPUTPPP")) { int numRandOnly = 0; vector randOnlyIDs; TextFile randFile(ui.GetFilename("PPP")); progress.SetText("Converting RAND PPP file"); randFile.GetLine(currLine); - int inTotalLine = (int) (randFile.Size()/(currLine.size())); + int inTotalLine = (int)(randFile.Size() / (currLine.size())); progress.SetMaximumSteps(inTotalLine); randFile.Rewind(); - + line = 0; - while (randFile.GetLine(currLine)) { + while(randFile.GetLine(currLine)) { line ++; // Update the Progress object try { progress.CheckStatus(); - } - catch ( Isis::iException e ) { + } + catch(Isis::iException e) { iString msg = "RAND PPP file may not be valid. Line count calculated ["; msg += iString(inTotalLine) + "] for RAND PPP file [" + ui.GetAsString("PPP"); msg += "] appears invalid at line [" + iString(line) + "]."; - throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Programmer, msg, _FILEINFO_); } // Declare the Point ControlPoint *cpoint = NULL; - + // if end of valid data, break, stop processing - if (currLine.find("JULIAN") != string::npos) { - // Since Progress MaximumSteps was approximated using the number of lines in the RAND PPP file, - // we need to subtract the number of lines left from the Progress steps + if(currLine.find("JULIAN") != string::npos) { + // Since Progress MaximumSteps was approximated using the number of lines in the RAND PPP file, + // we need to subtract the number of lines left from the Progress steps // since the following lines are not going to be processed - progress.AddSteps(line-inTotalLine); // line < inTotalLine, so this is negative + progress.AddSteps(line - inTotalLine); // line < inTotalLine, so this is negative break; } // break columns into substrings since some files have colunms that can't be tokenized easily. // This is because some files have columns running into each other without spaces separating them - + // column 1 = latitude, begins the line and is 24 characters double lat; - iString col1 = currLine.substr(0,24); + iString col1 = currLine.substr(0, 24); // remove any white space from beginning of string //col1.ConvertWhiteSpace(); //col1.TrimHead(" "); - try{ + try { // convert to double lat = col1; } - catch (Isis::iException &e){ + catch(Isis::iException &e) { iString msg = "Invalid value(s) in RAND PPP file ["; msg += ui.GetAsString("PPP") + "] at line [" + iString(line); msg += "]. Verify latitude value is a double."; - throw Isis::iException::Message (Isis::iException::User, msg, _FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // column 2 = longitude, begins at 25th char and is 24 characters double lon; - iString col2 = currLine.substr(24,24); + iString col2 = currLine.substr(24, 24); // remove any white space from beginning of string //col2.TrimHead(" "); - try{ + try { // convert to double - lon = col2; + lon = col2; } - catch (Isis::iException &e){ + catch(Isis::iException &e) { iString msg = "Invalid value(s) in RAND PPP file ["; msg += ui.GetAsString("PPP") + "] at line [" + iString(line); msg += "]. Verify longitude value is a double."; - throw Isis::iException::Message (Isis::iException::User, msg, _FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // column 3 = radius, begins at 49th char and is 24 characters double rad; - iString col3 = currLine.substr(48,24); + iString col3 = currLine.substr(48, 24); // remove any white space from beginning of string //col3.TrimHead(" "); - try{ + try { // convert to double and convert km to meters - rad = col3; - rad = rad*1000; + rad = col3; + rad = rad * 1000; } - catch (Isis::iException &e){ + catch(Isis::iException &e) { iString msg = "Invalid value(s) in RAND PPP file ["; msg += ui.GetAsString("PPP") + "] at line [" + iString(line); msg += "]. Verify radius value is a double."; - throw Isis::iException::Message (Isis::iException::User, msg, _FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // column 4 = point id, begins at 73rd char and is 7 characters iString pid = currLine.substr(72); // remove any white space from beginning of string pid.TrimHead(" "); - if (pid.length() > 7) { + if(pid.length() > 7) { iString msg = "Invalid value(s) in RAND PPP file ["; msg += ui.GetAsString("PPP") + "] at line [" + iString(line); msg += "]. Point ID [" + pid + "] has more than 7 characters."; - throw Isis::iException::Message (Isis::iException::User, msg, _FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } - + //Find the point that matches the PointID, create it if it does not exist try { cpoint = cnet.Find(pid); @@ -372,24 +372,24 @@ void IsisMain() { cpoint->SetType(ControlPoint::Ground); } } - catch (iException &e) { - // point not found in control net means it was not in the matchpoint file, + catch(iException &e) { + // point not found in control net means it was not in the matchpoint file, // but this is not an error, so clear exception - e.Clear(); + e.Clear(); // do not add the point to the control net, but save off the currLine for output log numRandOnly++; randOnlyIDs.push_back(currLine); } - + if(cpoint != NULL) { //Add the lat,lon,rad to point try { - cpoint->SetUniversalGround(lat,lon,rad); - } - catch (iException &e) { + cpoint->SetUniversalGround(lat, lon, rad); + } + catch(iException &e) { iString msg = "Unable to set universal ground point to control network from line ["; msg += iString(line) + "] of RAND PPP file [" + ui.GetAsString("PPP") + "]"; - throw Isis::iException::Message (Isis::iException::User, msg, _FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } } @@ -397,51 +397,51 @@ void IsisMain() { try { progress.CheckStatus(); } - catch ( Isis::iException e ) { + catch(Isis::iException e) { iString msg = "RAND PPP file may not be valid. Line count calculated ["; msg += iString(inTotalLine) + "] for RAND PPP file [" + ui.GetAsString("PPP"); msg += "] appears invalid at line [" + iString(line) + "]."; - throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Programmer, msg, _FILEINFO_); } - // Write results to Logs + // Write results to Logs // Summary group is created with the counts of RAND PPP only points PvlGroup summaryGroup = PvlGroup("Summary"); summaryGroup.AddKeyword(PvlKeyword("RandOnlyPoints", numRandOnly)); - + bool log; Filename logFile; // if a filename was entered, use it to create the log - if (ui.WasEntered("PPPLOG")) { + if(ui.WasEntered("PPPLOG")) { log = true; logFile = ui.GetFilename("PPPLOG"); } // if no filename was entered, but there were some RAND PPP only points, // create an log named "randOnlyPoints" in the current directory - else if (numRandOnly > 0) { + else if(numRandOnly > 0) { log = true; logFile = "randOnlyPoints.log"; } - // if all RAND PPP points are found in the MATCH file and no log file is named, + // if all RAND PPP points are found in the MATCH file and no log file is named, // only output summary to application log else { log = false; } - - if (log) { + + if(log) { // Write details in error log Pvl results; results.SetName("Results"); results.AddGroup(summaryGroup); - if (numRandOnly > 0) { - // if there are any RAND PPP only points, + if(numRandOnly > 0) { + // if there are any RAND PPP only points, // add comment to the summary log to alert user summaryGroup.AddComment("Some Point IDs in the RAND PPP file have no measures in the MATCH file."); summaryGroup.AddComment("These Point IDs are contained in [" + logFile.Name() + "]."); TextFile outlog(logFile.Expanded(), "overwrite", randOnlyIDs); } - else{ - // if there are no RAND PPP only points and user wanted to create a log, + else { + // if there are no RAND PPP only points and user wanted to create a log, // add comment to the summary log to alert user summaryGroup.AddComment("All Point IDs in the RAND PPP file have measures in the MATCH file."); summaryGroup.AddComment("No RAND PPP log was created."); diff --git a/isis/src/base/apps/median/median.cpp b/isis/src/base/apps/median/median.cpp index abb89b1ef5..944b12e3b8 100644 --- a/isis/src/base/apps/median/median.cpp +++ b/isis/src/base/apps/median/median.cpp @@ -21,7 +21,7 @@ void FilterAll(Buffer &in, double &v); void FilterValid(Buffer &in, double &v); void FilterInvalid(Buffer &in, double &v); -void IsisMain(){ +void IsisMain() { //Set up ProcessByBoxcar ProcessByBoxcar p; @@ -29,7 +29,7 @@ void IsisMain(){ p.SetInputCube("FROM"); p.SetOutputCube("TO"); - //Set up Boxcar size + //Set up Boxcar size UserInterface &ui = Application::GetUserInterface(); int samples = ui.GetInteger("SAMPLES"); int lines = ui.GetInteger("LINES"); @@ -42,20 +42,20 @@ void IsisMain(){ filterLrs = ui.GetBoolean("LRS"); filterHis = ui.GetBoolean("HIS"); filterLis = ui.GetBoolean("LIS"); - if (ui.GetString("MINOPT") == "PERCENTAGE") { + if(ui.GetString("MINOPT") == "PERCENTAGE") { int size = lines * samples; double perc = ui.GetDouble("MINIMUM") / 100; - minimum = (int) (size * perc); + minimum = (int)(size * perc); } else { minimum = (int) ui.GetDouble("MINIMUM"); } low = -DBL_MAX; high = DBL_MAX; - if (ui.WasEntered("LOW")){ + if(ui.WasEntered("LOW")) { low = ui.GetDouble("LOW"); } - if (ui.WasEntered("HIGH")){ + if(ui.WasEntered("HIGH")) { high = ui.GetDouble("HIGH"); } @@ -64,51 +64,51 @@ void IsisMain(){ propagate = (ui.GetString("REPLACEMENT") == "CENTER"); //Check for filter style, and process accordingly - if (ui.GetString("FILTER") == "ALL"){ + if(ui.GetString("FILTER") == "ALL") { p.StartProcess(FilterAll); p.EndProcess(); } - else if (ui.GetString("FILTER") == "INSIDE"){ + else if(ui.GetString("FILTER") == "INSIDE") { p.StartProcess(FilterValid); p.EndProcess(); } - else if (ui.GetString("FILTER") == "OUTSIDE"){ + else if(ui.GetString("FILTER") == "OUTSIDE") { p.StartProcess(FilterInvalid); p.EndProcess(); } } //Function which loops through every pixel in the boxcar, -//and outputs the median value to the center pixel, if +//and outputs the median value to the center pixel, if //the center pixel is valid. -void FilterValid(Buffer &in, double &v){ +void FilterValid(Buffer &in, double &v) { double centerPixel = in[(in.size()-1)/2]; //Check if the center pixel is a Special Pixel type to be //filtered. If not, ignore the pixel and move on - if (IsSpecial(centerPixel) ){ - if ((IsNullPixel(centerPixel)) && (!filterNull)) { - v = centerPixel; - return; + if(IsSpecial(centerPixel)) { + if((IsNullPixel(centerPixel)) && (!filterNull)) { + v = centerPixel; + return; } - else if ((IsLisPixel(centerPixel)) && (!filterLis)) { - v = centerPixel; - return; + else if((IsLisPixel(centerPixel)) && (!filterLis)) { + v = centerPixel; + return; } - else if ((IsLrsPixel(centerPixel)) && (!filterLrs)) { - v = centerPixel; - return; + else if((IsLrsPixel(centerPixel)) && (!filterLrs)) { + v = centerPixel; + return; } - else if ((IsHisPixel(centerPixel)) && (!filterHis)) { - v = centerPixel; - return; + else if((IsHisPixel(centerPixel)) && (!filterHis)) { + v = centerPixel; + return; } - else if ((IsHrsPixel(centerPixel)) && (!filterHrs)) { - v = centerPixel; - return; + else if((IsHrsPixel(centerPixel)) && (!filterHrs)) { + v = centerPixel; + return; } } - else if (centerPixelhigh){ + else if(centerPixel < low || centerPixel > high) { v = centerPixel; return; } @@ -119,16 +119,16 @@ void FilterValid(Buffer &in, double &v){ //to the center. If there are, sort the vector and write //the median value to the center. std::vector boxdata(0); - for (int i=0; i=low && in[i]<=high){ + for(int i = 0; i < in.size(); i++) { + if(!IsSpecial(in[i]) && in[i] >= low && in[i] <= high) { boxdata.push_back(in[i]); } - else{ + else { continue; } } - if (boxdata.size()=low && centerPixel<=high){ + else if((IsHrsPixel(centerPixel)) && (!filterHrs)) { v = centerPixel; return; + } + } + else if(centerPixel >= low && centerPixel <= high) { + v = centerPixel; + return; } //Build a vector of non-Special pixel values from the @@ -182,16 +182,16 @@ void FilterInvalid(Buffer &in, double &v){ //write a user-selected value to the center pixel. std::vector boxdata(0); - for (int i=0; i=low && in[i]<=high){ + for(int i = 0; i < in.size(); i++) { + if(!IsSpecial(in[i]) && in[i] >= low && in[i] <= high) { boxdata.push_back(in[i]); } - else{ + else { continue; } } - if (boxdata.size() boxdata(0); - for (int i=0; i=low && in[i]<=high){ + for(int i = 0; i < in.size(); i++) { + if(!IsSpecial(in[i]) && in[i] >= low && in[i] <= high) { boxdata.push_back(in[i]); } - else{ + else { continue; } } - if (boxdata.size()= in[i]){ - v = in[i]; + for(int i = 0; i < in.size() ; i++) { + if(!IsSpecial(in[i])) { + if(v >= in[i]) { + v = in[i]; } } } @@ -61,18 +61,18 @@ void minimumFilter (Buffer &in,double &v) { // Maximum DN filter -void maximumFilter (Buffer &in,double &v) { - - v = -(DBL_MAX); /*Initialize v to the SMALLEST DN possible for - Isis, ensuring that it will be replaced so +void maximumFilter(Buffer &in, double &v) { + + v = -(DBL_MAX); /*Initialize v to the SMALLEST DN possible for + Isis, ensuring that it will be replaced so long as there are valid pixels in the boxcar*/ - - for (int i=0; ihigh){ + else if(centerPixel < low || centerPixel > high) { v = centerPixel; } @@ -120,16 +120,16 @@ void FilterValid(Buffer &in, double &v){ //the mode, provided there are enough for filtering std::vector boxdata(0); - for (int i=0; i=low && in[i]<=high){ + for(int i = 0; i < in.size(); i++) { + if(!IsSpecial(in[i]) && in[i] >= low && in[i] <= high) { boxdata.push_back(in[i]); } - else{ + else { continue; } } - if (boxdata.size()maxCount){ + else { + if(count > maxCount) { modeVal = boxdata[i-1]; maxCount = count; } @@ -163,7 +163,7 @@ void FilterValid(Buffer &in, double &v){ //Function to loop through the boxcar and find and write //the mode value to the center pixel, but only if the //center pixel is invalid -void FilterInvalid(Buffer &in, double &v){ +void FilterInvalid(Buffer &in, double &v) { double centerPixel = in[(in.size()-1)/2]; //Check if the center pixel is valid @@ -171,48 +171,48 @@ void FilterInvalid(Buffer &in, double &v){ //valid type, or a normal value between low and high. //If the center is valid, write the original value to the //center, and move the boxcar - if (IsSpecial(centerPixel)){ - if ((IsNullPixel(centerPixel)) && (!filterNull)) { + if(IsSpecial(centerPixel)) { + if((IsNullPixel(centerPixel)) && (!filterNull)) { v = centerPixel; return; } - else if ((IsLisPixel(centerPixel)) && (!filterLis)) { + else if((IsLisPixel(centerPixel)) && (!filterLis)) { v = centerPixel; return; } - else if ((IsLrsPixel(centerPixel)) && (!filterLrs)) { + else if((IsLrsPixel(centerPixel)) && (!filterLrs)) { v = centerPixel; return; } - else if ((IsHisPixel(centerPixel)) && (!filterHis)) { + else if((IsHisPixel(centerPixel)) && (!filterHis)) { v = centerPixel; return; } - else if ((IsHrsPixel(centerPixel)) && (!filterHrs)) { + else if((IsHrsPixel(centerPixel)) && (!filterHrs)) { v = centerPixel; return; } } - else if (centerPixel>=low && centerPixel<=high){ + else if(centerPixel >= low && centerPixel <= high) { v = centerPixel; } - //Now, build a vector containing non-Special pixels, + //Now, build a vector containing non-Special pixels, //and, if there are enough, process the vector to //determine the mode. If there aren't enough, write //a user selected value to the center. std::vector boxdata(0); - for (int i=0; i=low && in[i]<=high){ + for(int i = 0; i < in.size(); i++) { + if(!IsSpecial(in[i]) && in[i] >= low && in[i] <= high) { boxdata.push_back(in[i]); } - else{ + else { continue; } } - if (boxdata.size()maxCount){ + else { + if(count > maxCount) { modeVal = boxdata[i-1]; maxCount = count; } @@ -243,7 +243,7 @@ void FilterInvalid(Buffer &in, double &v){ //Function to process the boxcar and determine the mode, //regardless of validity of the center pixel -void FilterAll(Buffer &in, double &v){ +void FilterAll(Buffer &in, double &v) { double centerPixel = in[(in.size()-1)/2]; //Check if the center pixel is valid @@ -251,45 +251,45 @@ void FilterAll(Buffer &in, double &v){ //valid type, or a normal value between low and high. //If the center is valid, write the original value to the //center, and move the boxcar - if (IsSpecial(centerPixel)){ - if ((IsNullPixel(centerPixel)) && (!filterNull)) { + if(IsSpecial(centerPixel)) { + if((IsNullPixel(centerPixel)) && (!filterNull)) { v = centerPixel; return; } - else if ((IsLisPixel(centerPixel)) && (!filterLis)) { + else if((IsLisPixel(centerPixel)) && (!filterLis)) { v = centerPixel; return; } - else if ((IsLrsPixel(centerPixel)) && (!filterLrs)) { + else if((IsLrsPixel(centerPixel)) && (!filterLrs)) { v = centerPixel; return; } - else if ((IsHisPixel(centerPixel)) && (!filterHis)) { + else if((IsHisPixel(centerPixel)) && (!filterHis)) { v = centerPixel; return; } - else if ((IsHrsPixel(centerPixel)) && (!filterHrs)) { + else if((IsHrsPixel(centerPixel)) && (!filterHrs)) { v = centerPixel; return; } } - //Now, build a vector containing non-Special pixels, + //Now, build a vector containing non-Special pixels, //and, if there are enough, process the vector to //determine the mode. If there aren't enough, write //a user selected value to the center. std::vector boxdata(0); - for (int i=0; i=low && in[i]<=high){ + for(int i = 0; i < in.size(); i++) { + if(!IsSpecial(in[i]) && in[i] >= low && in[i] <= high) { boxdata.push_back(in[i]); } - else{ + else { continue; } } - if (boxdata.size()maxCount){ + else { + if(count > maxCount) { modeVal = boxdata[i-1]; - maxCount = count; + maxCount = count; } count = 1; } diff --git a/isis/src/base/apps/mosrange/mosrange.cpp b/isis/src/base/apps/mosrange/mosrange.cpp index d167f7bf9f..f0ef91ecfb 100644 --- a/isis/src/base/apps/mosrange/mosrange.cpp +++ b/isis/src/base/apps/mosrange/mosrange.cpp @@ -7,43 +7,51 @@ #include "Pvl.h" #include "Statistics.h" -using namespace std; +using namespace std; using namespace Isis; - template inline T MIN(const T &A, const T &B) { - if ( A < B ) { return (A); } - else { return (B); } - } +template inline T MIN(const T &A, const T &B) { + if(A < B) { + return (A); + } + else { + return (B); + } +} - template inline T MAX(const T &A, const T &B) { - if ( A > B ) { return (A); } - else { return (B); } - } +template inline T MAX(const T &A, const T &B) { + if(A > B) { + return (A); + } + else { + return (B); + } +} inline double SetFloor(double value, const int precision) { - double scale = pow(10.0, precision); - value = floor(value * scale) / scale; - return (value); + double scale = pow(10.0, precision); + value = floor(value * scale) / scale; + return (value); } inline double SetRound(double value, const int precision) { - double scale = pow(10.0, precision); - value = rint(value * scale) / scale; - return (value); + double scale = pow(10.0, precision); + value = rint(value * scale) / scale; + return (value); } inline double SetCeil(double value, const int precision) { - double scale = pow(10.0, precision); - value = ceil(value * scale) / scale; - return (value); + double scale = pow(10.0, precision); + value = ceil(value * scale) / scale; + return (value); } -inline double Scale (const double pixres, const double polarRadius, - const double equiRadius, const double trueLat = 0.0) { +inline double Scale(const double pixres, const double polarRadius, + const double equiRadius, const double trueLat = 0.0) { double lat = trueLat * Isis::PI / 180.0; double a = polarRadius * cos(lat); double b = equiRadius * sin(lat); - double localRadius = equiRadius * polarRadius / sqrt(a*a + b*b); + double localRadius = equiRadius * polarRadius / sqrt(a * a + b * b); return (localRadius / pixres * pi_c() / 180.0); } @@ -54,20 +62,20 @@ void IsisMain() { FileList flist; UserInterface &ui = Application::GetUserInterface(); flist.Read(ui.GetFilename("FROMLIST")); - if (flist.size() < 1) { + if(flist.size() < 1) { string msg = "The list file[" + ui.GetFilename("FROMLIST") + - " does not contain any filenames"; - throw iException::Message(iException::User,msg,_FILEINFO_); + " does not contain any filenames"; + throw iException::Message(iException::User, msg, _FILEINFO_); } string projection("Equirectangular"); if(ui.WasEntered("MAP")) { - Pvl mapfile(ui.GetFilename("MAP")); - projection = (string) mapfile.FindGroup("Mapping")["ProjectionName"]; + Pvl mapfile(ui.GetFilename("MAP")); + projection = (string) mapfile.FindGroup("Mapping")["ProjectionName"]; } if(ui.WasEntered("PROJECTION")) { - projection = ui.GetString("PROJECTION"); + projection = ui.GetString("PROJECTION"); } // Gather other user inputs to projection @@ -92,12 +100,12 @@ void IsisMain() { PvlObject fileset("FileSet"); // Save major equitorial and polar radii for last occuring - double eqRad; - double eq2Rad; + double eqRad; + double eq2Rad; double poleRad; string target("Unknown"); - for (unsigned int i = 0 ; i < flist.size() ; i++) { + for(unsigned int i = 0 ; i < flist.size() ; i++) { // Set the input image, get the camera model, and a basic mapping // group Cube cube; @@ -108,7 +116,7 @@ void IsisMain() { PvlObject fmap("File"); - fmap += PvlKeyword("Name",flist[i]); + fmap += PvlKeyword("Name", flist[i]); fmap += PvlKeyword("Lines", lines); fmap += PvlKeyword("Samples", samples); @@ -116,10 +124,10 @@ void IsisMain() { Pvl mapping; cam->BasicMapping(mapping); PvlGroup &mapgrp = mapping.FindGroup("Mapping"); - mapgrp.AddKeyword(PvlKeyword("ProjectionName",projection),Pvl::Replace); - mapgrp.AddKeyword(PvlKeyword("LatitudeType",lattype),Pvl::Replace); - mapgrp.AddKeyword(PvlKeyword("LongitudeDirection",londir),Pvl::Replace); - mapgrp.AddKeyword(PvlKeyword("LongitudeDomain",londom),Pvl::Replace); + mapgrp.AddKeyword(PvlKeyword("ProjectionName", projection), Pvl::Replace); + mapgrp.AddKeyword(PvlKeyword("LatitudeType", lattype), Pvl::Replace); + mapgrp.AddKeyword(PvlKeyword("LongitudeDirection", londir), Pvl::Replace); + mapgrp.AddKeyword(PvlKeyword("LongitudeDomain", londom), Pvl::Replace); // Get the radii double radii[3]; @@ -139,20 +147,20 @@ void IsisMain() { scaleStat.AddData(&lowres, 1); scaleStat.AddData(&hires, 1); - double pixres = (lowres+hires)/2.0; + double pixres = (lowres + hires) / 2.0; double scale = Scale(pixres, poleRad, eqRad); - mapgrp.AddKeyword(PvlKeyword("PixelResolution",pixres),Pvl::Replace); - mapgrp.AddKeyword(PvlKeyword("Scale",scale,"pixels/degree"),Pvl::Replace); - mapgrp += PvlKeyword("MinPixelResolution",lowres,"meters"); - mapgrp += PvlKeyword("MaxPixelResolution",hires,"meters"); + mapgrp.AddKeyword(PvlKeyword("PixelResolution", pixres), Pvl::Replace); + mapgrp.AddKeyword(PvlKeyword("Scale", scale, "pixels/degree"), Pvl::Replace); + mapgrp += PvlKeyword("MinPixelResolution", lowres, "meters"); + mapgrp += PvlKeyword("MaxPixelResolution", hires, "meters"); // Get the universal ground range - double minlat,maxlat,minlon,maxlon; - cam->GroundRange(minlat,maxlat,minlon,maxlon,mapping); - mapgrp.AddKeyword(PvlKeyword("MinimumLatitude",minlat),Pvl::Replace); - mapgrp.AddKeyword(PvlKeyword("MaximumLatitude",maxlat),Pvl::Replace); - mapgrp.AddKeyword(PvlKeyword("MinimumLongitude",minlon),Pvl::Replace); - mapgrp.AddKeyword(PvlKeyword("MaximumLongitude",maxlon),Pvl::Replace); + double minlat, maxlat, minlon, maxlon; + cam->GroundRange(minlat, maxlat, minlon, maxlon, mapping); + mapgrp.AddKeyword(PvlKeyword("MinimumLatitude", minlat), Pvl::Replace); + mapgrp.AddKeyword(PvlKeyword("MaximumLatitude", maxlat), Pvl::Replace); + mapgrp.AddKeyword(PvlKeyword("MinimumLongitude", minlon), Pvl::Replace); + mapgrp.AddKeyword(PvlKeyword("MaximumLongitude", maxlon), Pvl::Replace); fmap.AddGroup(mapgrp); fileset.AddObject(fmap); @@ -168,30 +176,30 @@ void IsisMain() { // Construct the output mapping group with statistics PvlGroup mapping("Mapping"); - double avgPixRes((scaleStat.Minimum()+scaleStat.Maximum())/2.0); - double avgLat((latitudeStat.Minimum()+latitudeStat.Maximum())/2.0); - double avgLon((longitudeStat.Minimum()+longitudeStat.Maximum())/2.0); - double avgEqRad((equiRadStat.Minimum()+equiRadStat.Maximum())/2.0); - double avgPoleRad((poleRadStat.Minimum()+poleRadStat.Maximum())/2.0); + double avgPixRes((scaleStat.Minimum() + scaleStat.Maximum()) / 2.0); + double avgLat((latitudeStat.Minimum() + latitudeStat.Maximum()) / 2.0); + double avgLon((longitudeStat.Minimum() + longitudeStat.Maximum()) / 2.0); + double avgEqRad((equiRadStat.Minimum() + equiRadStat.Maximum()) / 2.0); + double avgPoleRad((poleRadStat.Minimum() + poleRadStat.Maximum()) / 2.0); double scale = Scale(avgPixRes, avgPoleRad, avgEqRad); - mapping += PvlKeyword("ProjectionName",projection); + mapping += PvlKeyword("ProjectionName", projection); mapping += PvlKeyword("TargetName", target); - mapping += PvlKeyword("EquatorialRadius",eqRad,"meters"); - mapping += PvlKeyword("PolarRadius",poleRad,"meters"); - mapping += PvlKeyword("LatitudeType",lattype); - mapping += PvlKeyword("LongitudeDirection",londir); - mapping += PvlKeyword("LongitudeDomain",londom); + mapping += PvlKeyword("EquatorialRadius", eqRad, "meters"); + mapping += PvlKeyword("PolarRadius", poleRad, "meters"); + mapping += PvlKeyword("LatitudeType", lattype); + mapping += PvlKeyword("LongitudeDirection", londir); + mapping += PvlKeyword("LongitudeDomain", londom); mapping += PvlKeyword("PixelResolution", SetRound(avgPixRes, digits), "meters/pixel"); mapping += PvlKeyword("Scale", SetRound(scale, digits), "pixels/degree"); - mapping += PvlKeyword("MinPixelResolution",scaleStat.Minimum(),"meters"); - mapping += PvlKeyword("MaxPixelResolution",scaleStat.Maximum(),"meters"); - mapping += PvlKeyword("CenterLongitude", SetRound(avgLon,digits)); - mapping += PvlKeyword("CenterLatitude", SetRound(avgLat,digits)); - mapping += PvlKeyword("MinimumLatitude", MAX(SetFloor(latitudeStat.Minimum(),digits), -90.0)); - mapping += PvlKeyword("MaximumLatitude", MIN(SetCeil(latitudeStat.Maximum(),digits), 90.0)); - mapping += PvlKeyword("MinimumLongitude",MAX(SetFloor(longitudeStat.Minimum(),digits), -180.0)); - mapping += PvlKeyword("MaximumLongitude",MIN(SetCeil(longitudeStat.Maximum(),digits), 360.0)); + mapping += PvlKeyword("MinPixelResolution", scaleStat.Minimum(), "meters"); + mapping += PvlKeyword("MaxPixelResolution", scaleStat.Maximum(), "meters"); + mapping += PvlKeyword("CenterLongitude", SetRound(avgLon, digits)); + mapping += PvlKeyword("CenterLatitude", SetRound(avgLat, digits)); + mapping += PvlKeyword("MinimumLatitude", MAX(SetFloor(latitudeStat.Minimum(), digits), -90.0)); + mapping += PvlKeyword("MaximumLatitude", MIN(SetCeil(latitudeStat.Maximum(), digits), 90.0)); + mapping += PvlKeyword("MinimumLongitude", MAX(SetFloor(longitudeStat.Minimum(), digits), -180.0)); + mapping += PvlKeyword("MaximumLongitude", MIN(SetCeil(longitudeStat.Maximum(), digits), 360.0)); PvlKeyword clat("PreciseCenterLongitude", avgLon); clat.AddComment("Actual Parameters without precision applied"); @@ -199,23 +207,23 @@ void IsisMain() { mapping += PvlKeyword("PreciseCenterLatitude", avgLat); mapping += PvlKeyword("PreciseMinimumLatitude", latitudeStat.Minimum()); mapping += PvlKeyword("PreciseMaximumLatitude", latitudeStat.Maximum()); - mapping += PvlKeyword("PreciseMinimumLongitude",longitudeStat.Minimum()); - mapping += PvlKeyword("PreciseMaximumLongitude",longitudeStat.Maximum()); + mapping += PvlKeyword("PreciseMinimumLongitude", longitudeStat.Minimum()); + mapping += PvlKeyword("PreciseMaximumLongitude", longitudeStat.Maximum()); + - Application::GuiLog(mapping); // Write the output file if requested - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { Pvl temp; temp.AddGroup(mapping); - temp.Write(ui.GetFilename("TO","map")); + temp.Write(ui.GetFilename("TO", "map")); } - if (ui.WasEntered("LOG")) { + if(ui.WasEntered("LOG")) { Pvl temp; temp.AddObject(fileset); - temp.Write(ui.GetFilename("LOG","log")); + temp.Write(ui.GetFilename("LOG", "log")); } p.EndProcess(); diff --git a/isis/src/base/apps/mvstats/mvstats.cpp b/isis/src/base/apps/mvstats/mvstats.cpp index 6bd0861262..e2f2c58c31 100644 --- a/isis/src/base/apps/mvstats/mvstats.cpp +++ b/isis/src/base/apps/mvstats/mvstats.cpp @@ -8,14 +8,14 @@ #include "Pvl.h" #include "MultivariateStatistics.h" -using namespace std; +using namespace std; using namespace Isis; std::vector< vector > covariance; std::vector< vector > correlation; MultivariateStatistics stats; -void MakeStats(vector &in, vector &out); +void MakeStats(vector &in, vector &out); void WriteText(int size, string filename); void WriteCube(Buffer &inout); @@ -23,11 +23,11 @@ void IsisMain() { //Check to see if an output file was specified UserInterface &ui = Application::GetUserInterface(); - if (!ui.WasEntered("CUBE") && !ui.WasEntered("FLATFILE")){ + if(!ui.WasEntered("CUBE") && !ui.WasEntered("FLATFILE")) { string message = "At least one output file must be entered"; - throw iException::Message (iException::User, message, _FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } - + string file = ui.GetFilename("FROM"); //Use a Process to get the number of bands in the input cube @@ -36,30 +36,27 @@ void IsisMain() { int bands = icube->Bands(); //Check to see if the input cube has enough bands - if (bands < 2){ + if(bands < 2) { string message = "Input band must have at least two bands!"; - throw iException::Message (iException::User, message, _FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } //Set the matrices according to the number of bands in the input cube covariance.resize(bands); correlation.resize(bands); - for (int i=0; iPhysicalBand(i))); - CubeAttributeInput band_b ("d+" + iString(icube->PhysicalBand(j))); + CubeAttributeInput band_a("d+" + iString(icube->PhysicalBand(i))); + CubeAttributeInput band_b("d+" + iString(icube->PhysicalBand(j))); //Set Input files and process, to accumulate the statistics p.SetInputCube(file, band_a); p.SetInputCube(file, band_b); - Progress* progress = p.Progress(); + Progress *progress = p.Progress(); progress->SetText(progText); p.StartProcess(MakeStats); p.EndProcess(); //If the bands are the same, use the Variance of one, and a Correlation //of 1, for speed and simplicity - if (i == j){ + if(i == j) { covariance[i-1][j-1] = stats.X().Variance(); correlation[i-1][j-1] = 1.0; } //Otherwise, set the matrix to the appropriate value - else{ + else { covariance[i-1][j-1] = stats.Covariance(); correlation[i-1][j-1] = stats.Correlation(); } @@ -93,17 +90,17 @@ void IsisMain() { } //Mirror the matrices to create a full representation, instead //of half-matrices - for (int i=0; iPutGroup(bandBin); p.EndProcess(); @@ -125,7 +122,7 @@ void IsisMain() { //Function to gather the data and feed them to a //MultivariateStatistics container -void MakeStats(vector &in, vector &out){ +void MakeStats(vector &in, vector &out) { double *x = in[0]->DoubleBuffer(); double *y = in[1]->DoubleBuffer(); @@ -133,13 +130,13 @@ void MakeStats(vector &in, vector &out){ } //Function to generate a flatfile to represent the matrices -void WriteText(int size, string filename){ +void WriteText(int size, string filename) { ofstream outputFile; outputFile.open(filename.c_str()); string line = " "; outputFile << "Correlation:" << endl << endl; - for (int i=0; i GuiHelpers(){ - map helper; - helper ["PrintMap"] = (void*) PrintMap; - helper ["ComputePixRes"] = (void*) ComputePixRes; - helper ["LoadMapRes"] = (void*) LoadMapRes; - helper ["ComputeInputRange"] = (void*) ComputeInputRange; - helper ["LoadMapRange"] = (void*) LoadMapRange; +map GuiHelpers() { + map helper; + helper ["PrintMap"] = (void *) PrintMap; + helper ["ComputePixRes"] = (void *) ComputePixRes; + helper ["LoadMapRes"] = (void *) LoadMapRes; + helper ["ComputeInputRange"] = (void *) ComputeInputRange; + helper ["LoadMapRange"] = (void *) LoadMapRange; return helper; } @@ -38,14 +38,14 @@ void IsisMain() { //Create a process to create the input cubes Process p; //Create the input cubes, matching sample/lines - Cube *inCube = p.SetInputCube ("FROM"); + Cube *inCube = p.SetInputCube("FROM"); Cube *latCube = p.SetInputCube("LATCUB", SpatialMatch); Cube *lonCube = p.SetInputCube("LONCUB", SpatialMatch); //A 1x1 brick to read in the latitude and longitude DN values from //the specified cubes - Brick latBrick(1,1,1, latCube->PixelType()); - Brick lonBrick(1,1,1, lonCube->PixelType()); + Brick latBrick(1, 1, 1, latCube->PixelType()); + Brick lonBrick(1, 1, 1, lonCube->PixelType()); UserInterface &ui = Application::GetUserInterface(); @@ -64,7 +64,7 @@ void IsisMain() { int degree = ui.GetInteger("DEGREE"); //We are using a polynomial with two variables - PolynomialBivariate sampFunct(degree); + PolynomialBivariate sampFunct(degree); PolynomialBivariate lineFunct(degree); //We will be solving the function using the least squares method @@ -76,28 +76,28 @@ void IsisMain() { //y = cos(lat_center) * sin(latitude) - sin(lat_center) * cos(latitude) * cos(longitude - lon_center) //Get the center lat and long from the input cubes - double lat_center = latCube->Statistics()->Average() * PI/180.0; - double lon_center = lonCube->Statistics()->Average() * PI/180.0; + double lat_center = latCube->Statistics()->Average() * PI / 180.0; + double lon_center = lonCube->Statistics()->Average() * PI / 180.0; /** * Loop through lines and samples projecting the latitude and longitude at those - * points to stereographic x and y and adding these points to the LeastSquares - * matrix. + * points to stereographic x and y and adding these points to the LeastSquares + * matrix. */ - for(int i = 1; i <= inCube->Lines(); i+= linc) { - for(int j = 1; j <= inCube->Samples(); j+= sinc) { + for(int i = 1; i <= inCube->Lines(); i += linc) { + for(int j = 1; j <= inCube->Samples(); j += sinc) { latBrick.SetBasePosition(j, i, 1); latCube->Read(latBrick); if(IsSpecial(latBrick.at(0))) continue; - double lat = latBrick.at(0) * PI/180.0; + double lat = latBrick.at(0) * PI / 180.0; lonBrick.SetBasePosition(j, i, 1); lonCube->Read(lonBrick); if(IsSpecial(lonBrick.at(0))) continue; - double lon = lonBrick.at(0) * PI/180.0; + double lon = lonBrick.at(0) * PI / 180.0; //Project lat and lon to x and y using a stereographic projection - double k = 2/(1 + sin(lat_center) * sin(lat) + cos(lat_center)*cos(lat)*cos(lon - lon_center)); + double k = 2 / (1 + sin(lat_center) * sin(lat) + cos(lat_center) * cos(lat) * cos(lon - lon_center)); double x = k * cos(lat) * sin(lon - lon_center); double y = k * (cos(lat_center) * sin(lat)) - (sin(lat_center) * cos(lat) * cos(lon - lon_center)); @@ -116,7 +116,7 @@ void IsisMain() { } //If the line increment goes past the last line in the cube, we want to //always read the last line.. - if(i != inCube->Lines() && i + linc > inCube->Lines()) { + if(i != inCube->Lines() && i + linc > inCube->Lines()) { i = inCube->Lines() - linc; } } @@ -165,18 +165,18 @@ void IsisMain() { oFile.Close(); //Records the error to the log - PvlGroup error( "Error" ); - error += PvlKeyword( "Degree", degree ); - error += PvlKeyword( "NumberOfPoints", (int)sampResiduals.size() ); - error += PvlKeyword( "SampleMinimumError", sampErr.Minimum() ); - error += PvlKeyword( "SampleAverageError", sampErr.Average() ); - error += PvlKeyword( "SampleMaximumError", sampErr.Maximum() ); - error += PvlKeyword( "SampleStdDeviationError", sampErr.StandardDeviation() ); - error += PvlKeyword( "LineMinimumError", lineErr.Minimum() ); - error += PvlKeyword( "LineAverageError", lineErr.Average() ); - error += PvlKeyword( "LineMaximumError", lineErr.Maximum() ); - error += PvlKeyword( "LineStdDeviationError", lineErr.StandardDeviation() ); - Application::Log( error ); + PvlGroup error("Error"); + error += PvlKeyword("Degree", degree); + error += PvlKeyword("NumberOfPoints", (int)sampResiduals.size()); + error += PvlKeyword("SampleMinimumError", sampErr.Minimum()); + error += PvlKeyword("SampleAverageError", sampErr.Average()); + error += PvlKeyword("SampleMaximumError", sampErr.Maximum()); + error += PvlKeyword("SampleStdDeviationError", sampErr.StandardDeviation()); + error += PvlKeyword("LineMinimumError", lineErr.Minimum()); + error += PvlKeyword("LineAverageError", lineErr.Average()); + error += PvlKeyword("LineMaximumError", lineErr.Maximum()); + error += PvlKeyword("LineStdDeviationError", lineErr.StandardDeviation()); + Application::Log(error); //Close the input cubes for cleanup p.EndProcess(); @@ -186,7 +186,7 @@ void IsisMain() { //Creates the mapping group Pvl mapFile; mapFile.Read(ui.GetFilename("MAP")); - PvlGroup &mapGrp = mapFile.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &mapGrp = mapFile.FindGroup("Mapping", Pvl::Traverse); //Reopen the lat and long cubes latCube = new Cube(); @@ -234,18 +234,18 @@ void IsisMain() { SpiceInt code; SpiceBoolean found; - bodn2c_c (target.c_str(), &code, &found); + bodn2c_c(target.c_str(), &code, &found); - if (!found) { + if(!found) { string msg = "Could not convert Target [" + target + "] to NAIF code"; - throw Isis::iException::Message(Isis::iException::Io,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Io, msg, _FILEINFO_); } SpiceInt n; SpiceDouble radii[3]; - bodvar_c(code,"RADII",&n,radii); + bodvar_c(code, "RADII", &n, radii); equRadius = PvlKeyword("EquatorialRadius", radii[0] * 1000); polRadius = PvlKeyword("PolarRadius", radii[2] * 1000); @@ -258,35 +258,35 @@ void IsisMain() { //If the latitude type is not in the mapping group, copy it from the input if(!mapGrp.HasKeyword("LatitudeType")) { if(ui.GetString("LATTYPE") == "PLANETOCENTRIC") { - mapGrp.AddKeyword(PvlKeyword("LatitudeType","Planetocentric"), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("LatitudeType", "Planetocentric"), Pvl::Replace); } else { - mapGrp.AddKeyword(PvlKeyword("LatitudeType","Planetographic"), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("LatitudeType", "Planetographic"), Pvl::Replace); } } //If the longitude direction is not in the mapping group, copy it from the input if(!mapGrp.HasKeyword("LongitudeDirection")) { if(ui.GetString("LONDIR") == "POSITIVEEAST") { - mapGrp.AddKeyword(PvlKeyword("LongitudeDirection","PositiveEast"), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("LongitudeDirection", "PositiveEast"), Pvl::Replace); } else { - mapGrp.AddKeyword(PvlKeyword("LongitudeDirection","PositiveWest"), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("LongitudeDirection", "PositiveWest"), Pvl::Replace); } } //If the longitude domain is not in the mapping group, assume it is 360 if(!mapGrp.HasKeyword("LongitudeDomain")) { - mapGrp.AddKeyword(PvlKeyword("LongitudeDomain","360"), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("LongitudeDomain", "360"), Pvl::Replace); } //If the default range is to be computed, use the input lat/long cubes to determine the range if(ui.GetString("DEFAULTRANGE") == "COMPUTE") { - //NOTE - When computing the min/max longitude this application does not account for the + //NOTE - When computing the min/max longitude this application does not account for the //longitude seam if it exists. Since the min/max are calculated from the statistics of //the input longitude cube and then converted to the mapping group's domain they may be - //invalid for cubes containing the longitude seam. - + //invalid for cubes containing the longitude seam. + Statistics *latStats = latCube->Statistics(); Statistics *lonStats = lonCube->Statistics(); @@ -294,7 +294,7 @@ void IsisMain() { double maxLat = latStats->Maximum(); bool isOcentric = ((std::string)mapGrp.FindKeyword("LatitudeType")) == "Planetocentric"; - + if(isOcentric) { if(ui.GetString("LATTYPE") != "PLANETOCENTRIC") { minLat = Projection::ToPlanetocentric(minLat, (double)equRadius, (double)polRadius); @@ -313,7 +313,7 @@ void IsisMain() { double maxLon = lonDomain == 360 ? Projection::To360Domain(lonStats->Maximum()) : Projection::To180Domain(lonStats->Maximum()); bool isPosEast = ((std::string)mapGrp.FindKeyword("LongitudeDirection")) == "PositiveEast"; - + if(isPosEast) { if(ui.GetString("LONDIR") != "POSITIVEEAST") { minLon = Projection::ToPositiveEast(minLon, lonDomain); @@ -333,94 +333,94 @@ void IsisMain() { maxLon = temp; } - mapGrp.AddKeyword(PvlKeyword("MinimumLatitude", minLat),Pvl::Replace); - mapGrp.AddKeyword(PvlKeyword("MaximumLatitude", maxLat),Pvl::Replace); - mapGrp.AddKeyword(PvlKeyword("MinimumLongitude", minLon),Pvl::Replace); - mapGrp.AddKeyword(PvlKeyword("MaximumLongitude", maxLon),Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("MinimumLatitude", minLat), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("MaximumLatitude", maxLat), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("MinimumLongitude", minLon), Pvl::Replace); + mapGrp.AddKeyword(PvlKeyword("MaximumLongitude", maxLon), Pvl::Replace); } //If the user decided to enter a ground range then override - if (ui.WasEntered("MINLAT")) { + if(ui.WasEntered("MINLAT")) { mapGrp.AddKeyword(PvlKeyword("MinimumLatitude", - ui.GetDouble("MINLAT")),Pvl::Replace); + ui.GetDouble("MINLAT")), Pvl::Replace); } - - if (ui.WasEntered("MAXLAT")) { + + if(ui.WasEntered("MAXLAT")) { mapGrp.AddKeyword(PvlKeyword("MaximumLatitude", - ui.GetDouble("MAXLAT")),Pvl::Replace); + ui.GetDouble("MAXLAT")), Pvl::Replace); } - if (ui.WasEntered("MINLON")) { + if(ui.WasEntered("MINLON")) { mapGrp.AddKeyword(PvlKeyword("MinimumLongitude", - ui.GetDouble("MINLON")),Pvl::Replace); + ui.GetDouble("MINLON")), Pvl::Replace); } - - if (ui.WasEntered("MAXLON")) { + + if(ui.WasEntered("MAXLON")) { mapGrp.AddKeyword(PvlKeyword("MaximumLongitude", - ui.GetDouble("MAXLON")),Pvl::Replace); + ui.GetDouble("MAXLON")), Pvl::Replace); } - + //If the pixel resolution is to be computed, compute the pixels/degree from the input - if (ui.GetString("PIXRES") == "COMPUTE") { - latBrick.SetBasePosition(1,1,1); + if(ui.GetString("PIXRES") == "COMPUTE") { + latBrick.SetBasePosition(1, 1, 1); latCube->Read(latBrick); - lonBrick.SetBasePosition(1,1,1); + lonBrick.SetBasePosition(1, 1, 1); lonCube->Read(lonBrick); //Read the lat and long at the upper left corner - double a = latBrick.at(0) * PI/180.0; - double c = lonBrick.at(0) * PI/180.0; - - latBrick.SetBasePosition(latCube->Samples(),latCube->Lines(),1); + double a = latBrick.at(0) * PI / 180.0; + double c = lonBrick.at(0) * PI / 180.0; + + latBrick.SetBasePosition(latCube->Samples(), latCube->Lines(), 1); latCube->Read(latBrick); - lonBrick.SetBasePosition(lonCube->Samples(),lonCube->Lines(),1); + lonBrick.SetBasePosition(lonCube->Samples(), lonCube->Lines(), 1); lonCube->Read(lonBrick); //Read the lat and long at the lower right corner - double b = latBrick.at(0) * PI/180.0; - double d = lonBrick.at(0) * PI/180.0; + double b = latBrick.at(0) * PI / 180.0; + double d = lonBrick.at(0) * PI / 180.0; //Determine the angle between the two points double angle = acos(cos(a) * cos(b) * cos(c - d) + sin(a) * sin(b)); //double angle = acos((cos(a1) * cos(b1) * cos(b2)) + (cos(a1) * sin(b1) * cos(a2) * sin(b2)) + (sin(a1) * sin(a2))); - angle *= 180/PI; + angle *= 180 / PI; //Determine the number of pixels between the two points - double pixels = sqrt(pow(latCube->Samples() -1.0, 2.0) + pow(latCube->Lines() -1.0, 2.0)); + double pixels = sqrt(pow(latCube->Samples() - 1.0, 2.0) + pow(latCube->Lines() - 1.0, 2.0)); //Add the scale in pixels/degree to the mapping group mapGrp.AddKeyword(PvlKeyword("Scale", - pixels/angle, "pixels/degree"), - Pvl::Replace); - if (mapGrp.HasKeyword("PixelResolution")) { + pixels / angle, "pixels/degree"), + Pvl::Replace); + if(mapGrp.HasKeyword("PixelResolution")) { mapGrp.DeleteKeyword("PixelResolution"); } } // If the user decided to enter a resolution then override - if (ui.GetString("PIXRES") == "MPP") { + if(ui.GetString("PIXRES") == "MPP") { mapGrp.AddKeyword(PvlKeyword("PixelResolution", - ui.GetDouble("RESOLUTION"), "meters/pixel"), - Pvl::Replace); - if (mapGrp.HasKeyword("Scale")) { + ui.GetDouble("RESOLUTION"), "meters/pixel"), + Pvl::Replace); + if(mapGrp.HasKeyword("Scale")) { mapGrp.DeleteKeyword("Scale"); } } - else if (ui.GetString("PIXRES") == "PPD") { + else if(ui.GetString("PIXRES") == "PPD") { mapGrp.AddKeyword(PvlKeyword("Scale", - ui.GetDouble("RESOLUTION"), "pixels/degree"), - Pvl::Replace); - if (mapGrp.HasKeyword("PixelResolution")) { + ui.GetDouble("RESOLUTION"), "pixels/degree"), + Pvl::Replace); + if(mapGrp.HasKeyword("PixelResolution")) { mapGrp.DeleteKeyword("PixelResolution"); } } //Create a projection using the map file we created - int samples,lines; - Projection *outmap = ProjectionFactory::CreateForCube(mapFile,samples,lines,false); + int samples, lines; + Projection *outmap = ProjectionFactory::CreateForCube(mapFile, samples, lines, false); //Write the map file to the log Application::GuiLog(mapGrp); @@ -434,39 +434,39 @@ void IsisMain() { double tolerance = ui.GetDouble("TOLERANCE") * outmap->Resolution(); //Create a new transform object - Transform *transform = new nocam2map (sampSol, lineSol, outmap, - latCube, lonCube, - ui.GetString("LATTYPE") == "PLANETOCENTRIC", - ui.GetString("LONDIR") == "POSITIVEEAST", - tolerance, ui.GetInteger("ITERATIONS"), - inCube->Samples(), inCube->Lines(), - samples, lines); - + Transform *transform = new nocam2map(sampSol, lineSol, outmap, + latCube, lonCube, + ui.GetString("LATTYPE") == "PLANETOCENTRIC", + ui.GetString("LONDIR") == "POSITIVEEAST", + tolerance, ui.GetInteger("ITERATIONS"), + inCube->Samples(), inCube->Lines(), + samples, lines); + //Allocate the output cube and add the mapping labels - Cube *oCube = r.SetOutputCube ("TO", transform->OutputSamples(), - transform->OutputLines(), - inCube->Bands()); + Cube *oCube = r.SetOutputCube("TO", transform->OutputSamples(), + transform->OutputLines(), + inCube->Bands()); oCube->PutGroup(mapGrp); //Determine which interpolation to use Interpolator *interp = NULL; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } - + //Warp the cube r.StartProcess(*transform, *interp); r.EndProcess(); // add mapping to print.prt - PvlGroup mapping = outmap->Mapping(); - Application::Log(mapping); + PvlGroup mapping = outmap->Mapping(); + Application::Log(mapping); //Clean up delete latCube; @@ -480,12 +480,12 @@ void IsisMain() { // Transform object constructor -nocam2map::nocam2map (LeastSquares sample, LeastSquares line, Projection *outmap, - Cube *latCube, Cube *lonCube, - bool isOcentric, bool isPosEast, - double tolerance, int iterations, - const int inputSamples, const int inputLines, - const int outputSamples, const int outputLines) { +nocam2map::nocam2map(LeastSquares sample, LeastSquares line, Projection *outmap, + Cube *latCube, Cube *lonCube, + bool isOcentric, bool isPosEast, + double tolerance, int iterations, + const int inputSamples, const int inputLines, + const int outputSamples, const int outputLines) { p_sampleSol = &sample; p_lineSol = &line; @@ -500,17 +500,17 @@ nocam2map::nocam2map (LeastSquares sample, LeastSquares line, Projection *outmap p_isPosEast = isPosEast; p_tolerance = tolerance; p_iterations = iterations; - p_latCenter = p_latCube->Statistics()->Average() * PI/180.0; - p_lonCenter = p_lonCube->Statistics()->Average() * PI/180.0; + p_latCenter = p_latCube->Statistics()->Average() * PI / 180.0; + p_lonCenter = p_lonCube->Statistics()->Average() * PI / 180.0; p_radius = p_outmap->LocalRadius(p_latCenter); } // Transform method mapping output line/samps to lat/lons to input line/samps -bool nocam2map::Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { - if (!p_outmap->SetWorld(outSample,outLine)) return false; +bool nocam2map::Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { + if(!p_outmap->SetWorld(outSample, outLine)) return false; if(outSample > p_outputSamples) return false; if(outLine > p_outputLines) return false; @@ -537,11 +537,11 @@ bool nocam2map::Xform (double &inSample, double &inLine, else lon_known = p_outmap->Longitude(); } - lat_known *= PI/180.0; - lon_known *= PI/180.0; + lat_known *= PI / 180.0; + lon_known *= PI / 180.0; //Project the known lat/long to x/y using the stereographic projection - double k_known = 2/(1 + sin(p_latCenter) * sin(lat_known) + cos(p_latCenter)*cos(lat_known)*cos(lon_known - p_lonCenter)); + double k_known = 2 / (1 + sin(p_latCenter) * sin(lat_known) + cos(p_latCenter) * cos(lat_known) * cos(lon_known - p_lonCenter)); double x_known = k_known * cos(lat_known) * sin(lon_known - p_lonCenter); double y_known = k_known * (cos(p_latCenter) * sin(lat_known)) - (sin(p_latCenter) * cos(lat_known) * cos(lon_known - p_lonCenter)); @@ -554,41 +554,41 @@ bool nocam2map::Xform (double &inSample, double &inLine, double line_guess = p_lineSol->Evaluate(data_known); //If the sample/line guess is out of bounds return false - if (sample_guess < -1.5) return false; - if (line_guess < -1.5) return false; - if (sample_guess > p_inputSamples + 1.5) return false; - if (line_guess > p_inputLines + 1.5) return false; + if(sample_guess < -1.5) return false; + if(line_guess < -1.5) return false; + if(sample_guess > p_inputSamples + 1.5) return false; + if(line_guess > p_inputLines + 1.5) return false; - if (sample_guess < 0.5) sample_guess = 1; - if (line_guess < 0.5) line_guess = 1; - if (sample_guess > p_inputSamples + 0.5) sample_guess = p_inputSamples; - if (line_guess > p_inputLines + 0.5) line_guess = p_inputLines; + if(sample_guess < 0.5) sample_guess = 1; + if(line_guess < 0.5) line_guess = 1; + if(sample_guess > p_inputSamples + 0.5) sample_guess = p_inputSamples; + if(line_guess > p_inputLines + 0.5) line_guess = p_inputLines; //Create a bilinear interpolator Interpolator interp(Interpolator::BiLinearType); //Create a 2x2 buffer to read the lat and long cubes Portal latPortal(interp.Samples(), interp.Lines(), - p_latCube->PixelType() , - interp.HotSample(), interp.HotLine()); + p_latCube->PixelType() , + interp.HotSample(), interp.HotLine()); Portal lonPortal(interp.Samples(), interp.Lines(), - p_lonCube->PixelType() , - interp.HotSample(), interp.HotLine()); + p_lonCube->PixelType() , + interp.HotSample(), interp.HotLine()); //Set the buffers positions to the sample/line guess and read from the lat/long cubes - latPortal.SetPosition (sample_guess, line_guess, 1); + latPortal.SetPosition(sample_guess, line_guess, 1); p_latCube->Read(latPortal); - lonPortal.SetPosition (sample_guess, line_guess, 1); + lonPortal.SetPosition(sample_guess, line_guess, 1); p_lonCube->Read(lonPortal); //Get the lat/long guess from the interpolator - double lat_guess = interp.Interpolate(sample_guess, line_guess, latPortal.DoubleBuffer()) * PI/180.0; - double lon_guess = interp.Interpolate(sample_guess, line_guess, lonPortal.DoubleBuffer()) * PI/180.0; + double lat_guess = interp.Interpolate(sample_guess, line_guess, latPortal.DoubleBuffer()) * PI / 180.0; + double lon_guess = interp.Interpolate(sample_guess, line_guess, lonPortal.DoubleBuffer()) * PI / 180.0; //Project the lat/long guess to x/y using the stereographic projection - double k_guess = 2/(1 + sin(p_latCenter) * sin(lat_guess) + cos(p_latCenter)*cos(lat_guess)*cos(lon_guess - p_lonCenter)); + double k_guess = 2 / (1 + sin(p_latCenter) * sin(lat_guess) + cos(p_latCenter) * cos(lat_guess) * cos(lon_guess - p_lonCenter)); double x_guess = k_guess * cos(lat_guess) * sin(lon_guess - p_lonCenter); double y_guess = k_guess * (cos(p_latCenter) * sin(lat_guess)) - (sin(p_latCenter) * cos(lat_guess) * cos(lon_guess - p_lonCenter)); @@ -602,33 +602,33 @@ bool nocam2map::Xform (double &inSample, double &inLine, if(iteration++ >= p_iterations) return false; //Create a 1st order polynomial function - PolynomialBivariate sampFunct(1); + PolynomialBivariate sampFunct(1); PolynomialBivariate lineFunct(1); - //Create a least squares solution + //Create a least squares solution LeastSquares sampConverge(sampFunct); LeastSquares lineConverge(lineFunct); //Add the points around the line/sample guess point to the least squares matrix - for(int i = (int)(line_guess + 0.5) -1; i <= (int)(line_guess + 0.5) + 1; i++) { + for(int i = (int)(line_guess + 0.5) - 1; i <= (int)(line_guess + 0.5) + 1; i++) { //If the line is out of bounds, then skip it - if (i < 1 || i > p_inputLines) continue; - for(int j = (int)(sample_guess + 0.5) -1; j <= (int)(sample_guess + 0.5) + 1; j++) { + if(i < 1 || i > p_inputLines) continue; + for(int j = (int)(sample_guess + 0.5) - 1; j <= (int)(sample_guess + 0.5) + 1; j++) { //If the sample is out of bounds, then skip it if(j < 1 || j > p_inputSamples) continue; - latPortal.SetPosition (j, i, 1); + latPortal.SetPosition(j, i, 1); p_latCube->Read(latPortal); if(IsSpecial(latPortal.at(0))) continue; - double n_lat = latPortal.at(0) * PI/180.0; + double n_lat = latPortal.at(0) * PI / 180.0; - lonPortal.SetPosition (j, i, 1); + lonPortal.SetPosition(j, i, 1); p_lonCube->Read(lonPortal); - if(IsSpecial(lonPortal.at(0))) continue; - double n_lon = lonPortal.at(0) * PI/180.0; + if(IsSpecial(lonPortal.at(0))) continue; + double n_lon = lonPortal.at(0) * PI / 180.0; //Conver the lat/lon to x/y using the stereographic projection - double n_k = 2/(1 + sin(p_latCenter) * sin(n_lat) + cos(p_latCenter)*cos(n_lat)*cos(n_lon - p_lonCenter)); + double n_k = 2 / (1 + sin(p_latCenter) * sin(n_lat) + cos(p_latCenter) * cos(n_lat) * cos(n_lon - p_lonCenter)); double n_x = n_k * cos(n_lat) * sin(n_lon - p_lonCenter); double n_y = n_k * (cos(p_latCenter) * sin(n_lat)) - (sin(p_latCenter) * cos(n_lat) * cos(n_lon - p_lonCenter)); @@ -651,15 +651,15 @@ bool nocam2map::Xform (double &inSample, double &inLine, line_guess = lineConverge.Evaluate(data_known); //If the new sample/line is out of bounds return false - if (sample_guess < -1.5) return false; - if (line_guess < -1.5) return false; - if (sample_guess > p_inputSamples + 1.5) return false; - if (line_guess > p_inputLines + 1.5) return false; - - if (sample_guess < 0.5) sample_guess = 1; - if (line_guess < 0.5) line_guess = 1; - if (sample_guess > p_inputSamples + 0.5) sample_guess = p_inputSamples; - if (line_guess > p_inputLines + 0.5) line_guess = p_inputLines; + if(sample_guess < -1.5) return false; + if(line_guess < -1.5) return false; + if(sample_guess > p_inputSamples + 1.5) return false; + if(line_guess > p_inputLines + 1.5) return false; + + if(sample_guess < 0.5) sample_guess = 1; + if(line_guess < 0.5) line_guess = 1; + if(sample_guess > p_inputSamples + 0.5) sample_guess = p_inputSamples; + if(line_guess > p_inputLines + 0.5) line_guess = p_inputLines; //Set the buffers positions to the sample/line guess and read from the lat/long cubes latPortal.SetPosition(sample_guess, line_guess, 1); @@ -669,11 +669,11 @@ bool nocam2map::Xform (double &inSample, double &inLine, p_lonCube->Read(lonPortal); //Get the lat/long guess from the interpolator - lat_guess = interp.Interpolate(sample_guess, line_guess, latPortal.DoubleBuffer()) * PI/180.0; - lon_guess = interp.Interpolate(sample_guess, line_guess, lonPortal.DoubleBuffer()) * PI/180.0; + lat_guess = interp.Interpolate(sample_guess, line_guess, latPortal.DoubleBuffer()) * PI / 180.0; + lon_guess = interp.Interpolate(sample_guess, line_guess, lonPortal.DoubleBuffer()) * PI / 180.0; //Project the lat/long guess to x/y using the stereographic projection - k_guess = 2/(1 + sin(p_latCenter) * sin(lat_guess) + cos(p_latCenter)*cos(lat_guess)*cos(lon_guess - p_lonCenter)); + k_guess = 2 / (1 + sin(p_latCenter) * sin(lat_guess) + cos(p_latCenter) * cos(lat_guess) * cos(lon_guess - p_lonCenter)); x_guess = k_guess * cos(lat_guess) * sin(lon_guess - p_lonCenter); y_guess = k_guess * (cos(p_latCenter) * sin(lat_guess)) - (sin(p_latCenter) * cos(lat_guess) * cos(lon_guess - p_lonCenter)); @@ -690,11 +690,11 @@ bool nocam2map::Xform (double &inSample, double &inLine, return true; } -int nocam2map::OutputSamples () const { +int nocam2map::OutputSamples() const { return p_outputSamples; } -int nocam2map::OutputLines () const { +int nocam2map::OutputLines() const { return p_outputLines; } @@ -705,82 +705,82 @@ void PrintMap() { // Get mapping group from map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); //Write map file out to the log Isis::Application::GuiLog(userGrp); } //Helper function to get camera resolution. -void ComputePixRes () { +void ComputePixRes() { Process p; UserInterface &ui = Application::GetUserInterface(); Cube *latCube = p.SetInputCube("LATCUB"); Cube *lonCube = p.SetInputCube("LONCUB"); - Brick latBrick(1,1,1,latCube->PixelType()); - Brick lonBrick(1,1,1,lonCube->PixelType()); - latBrick.SetBasePosition(1,1,1); + Brick latBrick(1, 1, 1, latCube->PixelType()); + Brick lonBrick(1, 1, 1, lonCube->PixelType()); + latBrick.SetBasePosition(1, 1, 1); latCube->Read(latBrick); - lonBrick.SetBasePosition(1,1,1); + lonBrick.SetBasePosition(1, 1, 1); lonCube->Read(lonBrick); - - double a = latBrick.at(0) * PI/180.0; - double c = lonBrick.at(0) * PI/180.0; - - latBrick.SetBasePosition(latCube->Samples(),latCube->Lines(),1); + + double a = latBrick.at(0) * PI / 180.0; + double c = lonBrick.at(0) * PI / 180.0; + + latBrick.SetBasePosition(latCube->Samples(), latCube->Lines(), 1); latCube->Read(latBrick); - lonBrick.SetBasePosition(lonCube->Samples(),lonCube->Lines(),1); + lonBrick.SetBasePosition(lonCube->Samples(), lonCube->Lines(), 1); lonCube->Read(lonBrick); - double b = latBrick.at(0) * PI/180.0; - double d = lonBrick.at(0) * PI/180.0; + double b = latBrick.at(0) * PI / 180.0; + double d = lonBrick.at(0) * PI / 180.0; double angle = acos(cos(a) * cos(b) * cos(c - d) + sin(a) * sin(b)); - angle *= 180/PI; + angle *= 180 / PI; - double pixels = sqrt(pow(latCube->Samples() -1.0, 2.0) + pow(latCube->Lines() -1.0, 2.0)); + double pixels = sqrt(pow(latCube->Samples() - 1.0, 2.0) + pow(latCube->Lines() - 1.0, 2.0)); p.EndProcess(); ui.Clear("RESOLUTION"); - ui.PutDouble("RESOLUTION", pixels/angle); + ui.PutDouble("RESOLUTION", pixels / angle); ui.Clear("PIXRES"); - ui.PutAsString("PIXRES","PPD"); + ui.PutAsString("PIXRES", "PPD"); } // Helper function to get mapping resolution. -void LoadMapRes () { +void LoadMapRes() { UserInterface &ui = Application::GetUserInterface(); // Get mapping group from map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); // Set resolution - if (userGrp.HasKeyword("Scale")) { + if(userGrp.HasKeyword("Scale")) { ui.Clear("RESOLUTION"); - ui.PutDouble("RESOLUTION",userGrp["Scale"]); + ui.PutDouble("RESOLUTION", userGrp["Scale"]); ui.Clear("PIXRES"); - ui.PutAsString("PIXRES","PPD"); + ui.PutAsString("PIXRES", "PPD"); } - else if (userGrp.HasKeyword("PixelResolution")) { + else if(userGrp.HasKeyword("PixelResolution")) { ui.Clear("RESOLUTION"); - ui.PutDouble("RESOLUTION",userGrp["PixelResolution"]); + ui.PutDouble("RESOLUTION", userGrp["PixelResolution"]); ui.Clear("PIXRES"); - ui.PutAsString("PIXRES","MPP"); + ui.PutAsString("PIXRES", "MPP"); } else { string msg = "No resolution value found in [" + ui.GetFilename("MAP") + "]"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } //Helper function to compute input range. -void ComputeInputRange () { +void ComputeInputRange() { Process p; Cube *latCub = p.SetInputCube("LATCUB"); Cube *lonCub = p.SetInputCube("LONCUB"); @@ -788,7 +788,7 @@ void ComputeInputRange () { UserInterface &ui = Application::GetUserInterface(); Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); Statistics *latStats = latCub->Statistics(); Statistics *lonStats = lonCub->Statistics(); @@ -822,7 +822,7 @@ void ComputeInputRange () { string target; - //If user entered target + //If user entered target if(ui.WasEntered("TARGET")) { target = ui.GetString("TARGET"); } @@ -836,18 +836,18 @@ void ComputeInputRange () { SpiceInt code; SpiceBoolean found; - bodn2c_c (target.c_str(), &code, &found); + bodn2c_c(target.c_str(), &code, &found); - if (!found) { + if(!found) { string msg = "Could not convert Target [" + target + "] to NAIF code"; - throw Isis::iException::Message(Isis::iException::Io,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Io, msg, _FILEINFO_); } SpiceInt n; SpiceDouble radii[3]; - bodvar_c(code,"RADII",&n,radii); + bodvar_c(code, "RADII", &n, radii); equRadius = radii[0] * 1000; polRadius = radii[2] * 1000; @@ -910,7 +910,7 @@ void ComputeInputRange () { // Set default ground range param to camera ui.Clear("DEFAULTRANGE"); - ui.PutAsString("DEFAULTRANGE","COMPUTE"); + ui.PutAsString("DEFAULTRANGE", "COMPUTE"); } //Helper function to get ground range from map file. @@ -920,7 +920,7 @@ void LoadMapRange() { // Get map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); // Set ground range keywords that are found in mapfile int count = 0; @@ -928,30 +928,30 @@ void LoadMapRange() { ui.Clear("MAXLAT"); ui.Clear("MINLON"); ui.Clear("MAXLON"); - if (userGrp.HasKeyword("MinimumLatitude")) { - ui.PutDouble("MINLAT",userGrp["MinimumLatitude"]); + if(userGrp.HasKeyword("MinimumLatitude")) { + ui.PutDouble("MINLAT", userGrp["MinimumLatitude"]); count++; } - if (userGrp.HasKeyword("MaximumLatitude")) { - ui.PutDouble("MAXLAT",userGrp["MaximumLatitude"]); + if(userGrp.HasKeyword("MaximumLatitude")) { + ui.PutDouble("MAXLAT", userGrp["MaximumLatitude"]); count++; } - if (userGrp.HasKeyword("MinimumLongitude")) { - ui.PutDouble("MINLON",userGrp["MinimumLongitude"]); + if(userGrp.HasKeyword("MinimumLongitude")) { + ui.PutDouble("MINLON", userGrp["MinimumLongitude"]); count++; } - if (userGrp.HasKeyword("MaximumLongitude")) { - ui.PutDouble("MAXLON",userGrp["MaximumLongitude"]); + if(userGrp.HasKeyword("MaximumLongitude")) { + ui.PutDouble("MAXLON", userGrp["MaximumLongitude"]); count++; } // Set default ground range param to map ui.Clear("DEFAULTRANGE"); - ui.PutAsString("DEFAULTRANGE","MAP"); + ui.PutAsString("DEFAULTRANGE", "MAP"); - if (count < 4) { + if(count < 4) { string msg = "One or more of the values for the ground range was not found"; msg += " in [" + ui.GetFilename("MAP") + "]"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } diff --git a/isis/src/base/apps/nocam2map/nocam2map.h b/isis/src/base/apps/nocam2map/nocam2map.h index 245c729a2c..e07a670203 100644 --- a/isis/src/base/apps/nocam2map/nocam2map.h +++ b/isis/src/base/apps/nocam2map/nocam2map.h @@ -24,21 +24,21 @@ class nocam2map : public Isis::Transform { public: // constructor - nocam2map (Isis::LeastSquares sample, Isis::LeastSquares line, Isis::Projection *outmap, - Isis::Cube *latCube, Isis::Cube *lonCube, - bool isOcentric ,bool isPosEast, - double tolerance, int iterations, - const int inputSamples, const int inputLines, - const int outputSamples, const int outputLines); - + nocam2map(Isis::LeastSquares sample, Isis::LeastSquares line, Isis::Projection *outmap, + Isis::Cube *latCube, Isis::Cube *lonCube, + bool isOcentric , bool isPosEast, + double tolerance, int iterations, + const int inputSamples, const int inputLines, + const int outputSamples, const int outputLines); + // destructor - ~nocam2map () {}; + ~nocam2map() {}; // Implementations for parent's pure virtual members - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine); - int OutputSamples () const; - int OutputLines () const; + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine); + int OutputSamples() const; + int OutputLines() const; }; #endif diff --git a/isis/src/base/apps/noisefilter/noisefilter.cpp b/isis/src/base/apps/noisefilter/noisefilter.cpp index 8dbabbdf8c..d31df54d3e 100644 --- a/isis/src/base/apps/noisefilter/noisefilter.cpp +++ b/isis/src/base/apps/noisefilter/noisefilter.cpp @@ -3,12 +3,12 @@ #include "UserInterface.h" -using namespace std; +using namespace std; using namespace Isis; // Globals and prototypes -void RemoveNoiseViaStd (Buffer &in, Buffer &out, QuickFilter &filter); -void RemoveNoiseViaDn (Buffer &in, Buffer &out, QuickFilter &filter); +void RemoveNoiseViaStd(Buffer &in, Buffer &out, QuickFilter &filter); +void RemoveNoiseViaDn(Buffer &in, Buffer &out, QuickFilter &filter); double tolmin; double tolmax; @@ -35,25 +35,25 @@ void IsisMain() { // Read tolerances UserInterface &ui = Application::GetUserInterface(); - tolmin = ui.GetDouble ("TOLMIN"); - tolmax = ui.GetDouble ("TOLMAX"); + tolmin = ui.GetDouble("TOLMIN"); + tolmax = ui.GetDouble("TOLMAX"); // Will noise pixels be replaced with boxcar average or Null? replaceWithAverage = true; - if (ui.GetString("REPLACE") == "NULL") replaceWithAverage = false; + if(ui.GetString("REPLACE") == "NULL") replaceWithAverage = false; // Find out how to handle special pixels - nullIsNoise = ui.GetBoolean ("NULLISNOISE"); - hisIsNoise = ui.GetBoolean ("HISISNOISE"); - hrsIsNoise = ui.GetBoolean ("HRSISNOISE"); - lisIsNoise = ui.GetBoolean ("LISISNOISE"); - lrsIsNoise = ui.GetBoolean ("LRSISNOISE"); + nullIsNoise = ui.GetBoolean("NULLISNOISE"); + hisIsNoise = ui.GetBoolean("HISISNOISE"); + hrsIsNoise = ui.GetBoolean("HRSISNOISE"); + lisIsNoise = ui.GetBoolean("LISISNOISE"); + lrsIsNoise = ui.GetBoolean("LRSISNOISE"); // Process each line brightPixelsReplaced = 0; darkPixelsReplaced = 0; specialPixelsReplaced = 0; - if (ui.GetString("TOLDEF") == "STDDEV") { + if(ui.GetString("TOLDEF") == "STDDEV") { flattol = ui.GetDouble("FLATTOL"); p.StartProcess(RemoveNoiseViaStd); } @@ -63,33 +63,33 @@ void IsisMain() { // Generate a results group and log it PvlGroup results("Results"); - results += PvlKeyword("DarkPixelsReplaced",darkPixelsReplaced); - results += PvlKeyword("BrightPixelsReplaced",brightPixelsReplaced); - results += PvlKeyword("SpecialPixelsReplaced",specialPixelsReplaced); + results += PvlKeyword("DarkPixelsReplaced", darkPixelsReplaced); + results += PvlKeyword("BrightPixelsReplaced", brightPixelsReplaced); + results += PvlKeyword("SpecialPixelsReplaced", specialPixelsReplaced); int pixelsReplaced = darkPixelsReplaced + brightPixelsReplaced + specialPixelsReplaced; - results += PvlKeyword("TotalPixelsReplaced",pixelsReplaced); - double pct = ((double)pixelsReplaced/ - ((double)icube->Samples()*(double)icube->Lines())) * 100.; - pct = (int) (pct * 10.0) / 10.0; - results += PvlKeyword("PercentChanged",pct); + results += PvlKeyword("TotalPixelsReplaced", pixelsReplaced); + double pct = ((double)pixelsReplaced / + ((double)icube->Samples() * (double)icube->Lines())) * 100.; + pct = (int)(pct * 10.0) / 10.0; + results += PvlKeyword("PercentChanged", pct); Application::Log(results); p.EndProcess(); } // Standard deviation line processing routine -void RemoveNoiseViaStd (Buffer &in, Buffer &out, QuickFilter &filter) { - for (int i=0; i 0.0) ? tolmax : tolmin; - if (sqrDiff > tol * tol * filter.Variance(i)) noisy = true; + if(sqrDiff > tol * tol * filter.Variance(i)) noisy = true; // If we have noise replace it - if (noisy) { + if(noisy) { out[i] = (replaceWithAverage) ? goodAvg : NULL8; (diff > 0.0) ? brightPixelsReplaced++ : darkPixelsReplaced++; } @@ -133,19 +133,19 @@ void RemoveNoiseViaStd (Buffer &in, Buffer &out, QuickFilter &filter) { } // DN noise filter line processing routine -void RemoveNoiseViaDn (Buffer &in, Buffer &out, QuickFilter &filter) { - for (int i=0; i 0.0) ? tolmax : tolmin; - if (abs(diff) > tol) noisy = true; + if(abs(diff) > tol) noisy = true; // If we have noise replace it - if (noisy) { + if(noisy) { out[i] = (replaceWithAverage) ? goodAvg : NULL8; (diff > 0.0) ? brightPixelsReplaced++ : darkPixelsReplaced++; } diff --git a/isis/src/base/apps/noproj/noproj.cpp b/isis/src/base/apps/noproj/noproj.cpp index 8741921e3d..d0cda625d5 100644 --- a/isis/src/base/apps/noproj/noproj.cpp +++ b/isis/src/base/apps/noproj/noproj.cpp @@ -18,36 +18,36 @@ using namespace Isis; using namespace std; -void LoadMatchSummingMode (); -void LoadInputSummingMode (); +void LoadMatchSummingMode(); +void LoadInputSummingMode(); -map GuiHelpers(){ - map helper; - helper ["LoadMatchSummingMode"] = (void*) LoadMatchSummingMode; - helper ["LoadInputSummingMode"] = (void*) LoadInputSummingMode; +map GuiHelpers() { + map helper; + helper ["LoadMatchSummingMode"] = (void *) LoadMatchSummingMode; + helper ["LoadInputSummingMode"] = (void *) LoadInputSummingMode; return helper; } -void IsisMain(){ - +void IsisMain() { + // Create a process so we can output the noproj'd labels without overwriting Process p; // Open the user interface and get the input file and the ideal specs file UserInterface &ui = Application::GetUserInterface(); - Cube *mcube,*icube; + Cube *mcube, *icube; // If a MATCH cube is entered, make sure to SetInputCube it first to get the SPICE blobs // from it propagated to the TO labels // Until polygon blobs are detached without "/" don't propagate them - p.PropagatePolygons ( false ); + p.PropagatePolygons(false); - if ((ui.WasEntered ("MATCH"))) { + if((ui.WasEntered("MATCH"))) { mcube = p.SetInputCube("MATCH"); icube = p.SetInputCube("FROM"); } - else{ + else { mcube = icube = p.SetInputCube("FROM"); } @@ -61,45 +61,45 @@ void IsisMain(){ // Get Ideal camera specifications Filename specs; - if ((ui.WasEntered ("SPECS"))) { + if((ui.WasEntered("SPECS"))) { specs = ui.GetFilename("SPECS"); } else { specs = "$base/applications/noprojInstruments???.pvl"; specs.HighestVersion(); } - Pvl idealSpecs( specs.Expanded() ); + Pvl idealSpecs(specs.Expanded()); PvlObject obSpecs = idealSpecs.FindObject("IdealInstrumentsSpecifications"); PvlGroup idealGp = obSpecs.FindGroup(groupName); - double transx,transy,transl,transs; + double transx, transy, transl, transs; transx = transy = transl = transs = 0.; - if (idealGp.HasKeyword("TransX")) transx = idealGp["TransX"]; - if (idealGp.HasKeyword("TransY")) transy = idealGp["TransY"]; - if (idealGp.HasKeyword("ItransL")) transl = idealGp["ItransL"]; - if (idealGp.HasKeyword("ItransS")) transs = idealGp["ItransS"]; + if(idealGp.HasKeyword("TransX")) transx = idealGp["TransX"]; + if(idealGp.HasKeyword("TransY")) transy = idealGp["TransY"]; + if(idealGp.HasKeyword("ItransL")) transl = idealGp["ItransL"]; + if(idealGp.HasKeyword("ItransS")) transs = idealGp["ItransS"]; int detectorSamples = mcube->Samples(); - if (idealGp.HasKeyword("DetectorSamples")) detectorSamples = idealGp["DetectorSamples"]; + if(idealGp.HasKeyword("DetectorSamples")) detectorSamples = idealGp["DetectorSamples"]; int numberLines = mcube->Lines(); int numberBands = mcube->Bands(); - if (idealGp.HasKeyword("DetectorLines")) numberLines = idealGp["DetectorLines"]; + if(idealGp.HasKeyword("DetectorLines")) numberLines = idealGp["DetectorLines"]; int xDepend = incam->FocalPlaneMap()->FocalPlaneXDependency(); // Get output summing mode - if (ui.GetString("SOURCE") == "FROMMATCH") { + if(ui.GetString("SOURCE") == "FROMMATCH") { LoadMatchSummingMode(); } - else if (ui.GetString("SOURCE") == "FROMINPUT") { + else if(ui.GetString("SOURCE") == "FROMINPUT") { LoadInputSummingMode(); } - double pixPitch = incam->PixelPitch()*ui.GetDouble("SUMMINGMODE"); - detectorSamples /= (int) (ui.GetDouble("SUMMINGMODE")); + double pixPitch = incam->PixelPitch() * ui.GetDouble("SUMMINGMODE"); + detectorSamples /= (int)(ui.GetDouble("SUMMINGMODE")); // Get the user options - int sampleExpansion = int((ui.GetDouble("SAMPEXP")/100.)*detectorSamples + .5); - int lineExpansion = int((ui.GetDouble("LINEEXP")/100.)*numberLines + .5); + int sampleExpansion = int((ui.GetDouble("SAMPEXP") / 100.) * detectorSamples + .5); + int lineExpansion = int((ui.GetDouble("LINEEXP") / 100.) * numberLines + .5); string instType; double exposure; @@ -115,11 +115,11 @@ void IsisMain(){ int detectorLines; int expandFlag; - if (incam->DetectorMap()->LineRate() != 0.0) { - instType= "LINESCAN"; - // Isis3 line rate is always in seconds so convert to milliseconds for the + if(incam->DetectorMap()->LineRate() != 0.0) { + instType = "LINESCAN"; + // Isis3 line rate is always in seconds so convert to milliseconds for the // Ideal instrument - exposure = incam->DetectorMap()->LineRate()*1000.; + exposure = incam->DetectorMap()->LineRate() * 1000.; detectorLines = 1; expandFlag = 1; } @@ -132,14 +132,14 @@ void IsisMain(){ // Adjust focal plane translations with line expansion for scanners since // the CCD is only 1 line - if (expandFlag) { - transl += lineExpansion/2; + if(expandFlag) { + transl += lineExpansion / 2; - if (xDepend == CameraFocalPlaneMap::Line) { - transx -= lineExpansion/2.*pixPitch*expandFlag; + if(xDepend == CameraFocalPlaneMap::Line) { + transx -= lineExpansion / 2.*pixPitch * expandFlag; } else { - transy -= lineExpansion/2.*pixPitch*expandFlag; + transy -= lineExpansion / 2.*pixPitch * expandFlag; } } @@ -147,7 +147,7 @@ void IsisMain(){ AlphaCube alpha(*(icube->Label())); double sample = alpha.BetaSample(.5); double line = alpha.BetaLine(.5); - incam->SetImage(sample,line); + incam->SetImage(sample, line); double et = incam->EphemerisTime(); // Get the output file name and set its attributes @@ -161,12 +161,12 @@ void IsisMain(){ // Determine the output image size from // 1) the idealInstrument pvl if there or // 2) the input size expanded by user specified percentage - Cube *ocube = p.SetOutputCube("match.cub",cao,1, 1, 1); + Cube *ocube = p.SetOutputCube("match.cub", cao, 1, 1, 1); // Extract the times and the target from the instrument group string startTime = inst["StartTime"]; string stopTime; - if (inst.HasKeyword("StopTime")) stopTime = (string) inst["StopTime"]; + if(inst.HasKeyword("StopTime")) stopTime = (string) inst["StopTime"]; string target = inst["TargetName"]; @@ -185,97 +185,97 @@ void IsisMain(){ inst.Clear(); // Add keywords for the "Ideal" instrument - Isis::PvlKeyword key("SpacecraftName", "IdealSpacecraft" ); - inst.AddKeyword( key); + Isis::PvlKeyword key("SpacecraftName", "IdealSpacecraft"); + inst.AddKeyword(key); key.SetName("InstrumentId"); - key.SetValue( "IdealCamera" ); - inst.AddKeyword( key); + key.SetValue("IdealCamera"); + inst.AddKeyword(key); key.SetName("TargetName"); - key.SetValue( target ); - inst.AddKeyword( key ); + key.SetValue(target); + inst.AddKeyword(key); key.SetName("SampleDetectors"); - key.SetValue( Isis::iString( detectorSamples )); - inst.AddKeyword( key); + key.SetValue(Isis::iString(detectorSamples)); + inst.AddKeyword(key); key.SetName("LineDetectors"); - key.SetValue( Isis::iString( detectorLines )); - inst.AddKeyword( key); + key.SetValue(Isis::iString(detectorLines)); + inst.AddKeyword(key); - key.SetName("InstrumentType" ); - key.SetValue( instType ); - inst.AddKeyword( key); + key.SetName("InstrumentType"); + key.SetValue(instType); + inst.AddKeyword(key); key.SetName("FocalLength"); - key.SetValue( Isis::iString( incam->FocalLength()), "millimeters" ); - inst.AddKeyword( key ); + key.SetValue(Isis::iString(incam->FocalLength()), "millimeters"); + inst.AddKeyword(key); key.SetName("PixelPitch"); - key.SetValue( Isis::iString( incam->PixelPitch()* - ui.GetDouble("SUMMINGMODE")), "millimeters" ); - inst.AddKeyword( key ); + key.SetValue(Isis::iString(incam->PixelPitch()* + ui.GetDouble("SUMMINGMODE")), "millimeters"); + inst.AddKeyword(key); - key.SetName("EphemerisTime"); - key.SetValue( Isis::iString( et ), "seconds" ); - inst.AddKeyword( key ); + key.SetName("EphemerisTime"); + key.SetValue(Isis::iString(et), "seconds"); + inst.AddKeyword(key); key.SetName("StartTime"); - key.SetValue( startTime ); - inst.AddKeyword( key ); + key.SetValue(startTime); + inst.AddKeyword(key); - if (stopTime != "") { + if(stopTime != "") { key.SetName("StopTime"); - key.SetValue( stopTime ); - inst.AddKeyword( key ); + key.SetValue(stopTime); + inst.AddKeyword(key); } key.SetName("FocalPlaneXDependency"); - key.SetValue( incam->FocalPlaneMap()->FocalPlaneXDependency() ); - inst.AddKeyword( key ); + key.SetValue(incam->FocalPlaneMap()->FocalPlaneXDependency()); + inst.AddKeyword(key); - if (transx != 0) { + if(transx != 0) { key.SetName("TransX0"); - key.SetValue( transx ); - inst.AddKeyword( key ); + key.SetValue(transx); + inst.AddKeyword(key); } - if (transy != 0) { + if(transy != 0) { key.SetName("TransY0"); - key.SetValue( transy ); - inst.AddKeyword( key ); + key.SetValue(transy); + inst.AddKeyword(key); } - if (transs != 0) { + if(transs != 0) { key.SetName("TransS0"); - key.SetValue( transs ); - inst.AddKeyword( key ); + key.SetValue(transs); + inst.AddKeyword(key); } - if (transl != 0) { - key.SetName("TransL0"); - key.SetValue( transl ); - inst.AddKeyword( key ); + if(transl != 0) { + key.SetName("TransL0"); + key.SetValue(transl); + inst.AddKeyword(key); } key.SetName("TransX"); - key.SetValue( incam->FocalPlaneMap()->SignMostSigX() ); - inst.AddKeyword( key ); + key.SetValue(incam->FocalPlaneMap()->SignMostSigX()); + inst.AddKeyword(key); key.SetName("TransY"); - key.SetValue( incam->FocalPlaneMap()->SignMostSigY() ); - inst.AddKeyword( key ); + key.SetValue(incam->FocalPlaneMap()->SignMostSigY()); + inst.AddKeyword(key); - if (instType == "LINESCAN") { + if(instType == "LINESCAN") { key.SetName("ExposureDuration"); - key.SetValue( Isis::iString( incam->DetectorMap()->LineRate()*1000.), "milliseconds" ); - inst.AddKeyword( key ); + key.SetValue(Isis::iString(incam->DetectorMap()->LineRate() * 1000.), "milliseconds"); + inst.AddKeyword(key); } key.SetName("MatchedCube"); - key.SetValue( mcube->Filename() ); - inst.AddKeyword( key ); + key.SetValue(mcube->Filename()); + inst.AddKeyword(key); ocube->PutGroup(inst); @@ -285,19 +285,19 @@ void IsisMain(){ // taking all the space it would require for the image data Pvl label; label.Read("match.lbl"); - PvlGroup &dims = label.FindGroup("Dimensions",Pvl::Traverse); + PvlGroup &dims = label.FindGroup("Dimensions", Pvl::Traverse); dims["Lines"] = numberLines; dims["Samples"] = detectorSamples; dims["Bands"] = numberBands; label.Write("match.lbl"); - + // And run cam2cam to apply the transformation string parameters; parameters += " FROM= " + ui.GetFilename("FROM"); parameters += " MATCH= " + string("match.cub"); parameters += " TO= " + ui.GetFilename("TO"); parameters += " INTERP=" + ui.GetString("INTERP"); - Isis::iApp ->Exec("cam2cam",parameters); + Isis::iApp ->Exec("cam2cam", parameters); // Cleanup by deleting the match files remove("match.History.IsisCube"); @@ -318,31 +318,31 @@ void IsisMain(){ // Extract label and create cube object Pvl *toLabel = toCube.Label(); PvlObject &o = toLabel->FindObject("IsisCube"); - o.DeleteGroup( "OriginalInstrument" ); + o.DeleteGroup("OriginalInstrument"); o.AddGroup(fromInst); toCube.Close(); } - // Helper function to get output summing mode from cube to MATCH -void LoadMatchSummingMode () { +// Helper function to get output summing mode from cube to MATCH +void LoadMatchSummingMode() { string file; UserInterface &ui = Application::GetUserInterface(); // Get camera from cube to match - if ((ui.GetString ("SOURCE") =="FROMMATCH") && (ui.WasEntered("MATCH"))) { + if((ui.GetString("SOURCE") == "FROMMATCH") && (ui.WasEntered("MATCH"))) { file = ui.GetFilename("MATCH"); } else { file = ui.GetFilename("FROM"); } - // Open the input cube and get the camera object +// Open the input cube and get the camera object Cube c; c.Open(file); Camera *cam = c.Camera(); ui.Clear("SUMMINGMODE"); - ui.PutDouble("SUMMINGMODE",cam->DetectorMap()->SampleScaleFactor()); + ui.PutDouble("SUMMINGMODE", cam->DetectorMap()->SampleScaleFactor()); ui.Clear("SOURCE"); ui.PutAsString("SOURCE", "FROMUSER"); @@ -350,18 +350,18 @@ void LoadMatchSummingMode () { // Helper function to get output summing mode from input cube (FROM) -void LoadInputSummingMode () { +void LoadInputSummingMode() { UserInterface &ui = Application::GetUserInterface(); - // Get camera from cube to match +// Get camera from cube to match string file = ui.GetFilename("FROM"); - // Open the input cube and get the camera object +// Open the input cube and get the camera object Cube c; c.Open(file); Camera *cam = c.Camera(); ui.Clear("SUMMINGMODE"); - ui.PutDouble("SUMMINGMODE",cam->DetectorMap()->SampleScaleFactor()); + ui.PutDouble("SUMMINGMODE", cam->DetectorMap()->SampleScaleFactor()); ui.Clear("SOURCE"); ui.PutAsString("SOURCE", "FROMUSER"); diff --git a/isis/src/base/apps/noseam/noseam.cpp b/isis/src/base/apps/noseam/noseam.cpp index edae3b4341..f1ec2c8a25 100644 --- a/isis/src/base/apps/noseam/noseam.cpp +++ b/isis/src/base/apps/noseam/noseam.cpp @@ -7,7 +7,7 @@ #include #include -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { @@ -22,71 +22,71 @@ void IsisMain() { int lns = ui.GetInteger("LNS"); int lnl = ui.GetInteger("LNL"); string match = ui.GetAsString("MATCHBANDBIN"); - + //Sets upt the pathName to be used for most application calls - Filename inFile = Isis::Filename( cubes[0] ); + Filename inFile = Isis::Filename(cubes[0]); Pvl &pref = Preference::Preferences(); string pathName = (string)pref.FindGroup("DataDirectory")["Temporary"] + "/"; - /** - * Creates a mosaic from the original images. It is placed here - * so that the failure MATCHBANDBIN causes does not leave + /** + * Creates a mosaic from the original images. It is placed here + * so that the failure MATCHBANDBIN causes does not leave * highpasses cubes lying around! */ string parameters = "FROMLIST=" + ui.GetFilename("FROMLIST") + - " MOSAIC=" + pathName + "OriginalMosaic.cub" + - " MATCHBANDBIN=" + match; - Isis::iApp ->Exec("automos",parameters); + " MOSAIC=" + pathName + "OriginalMosaic.cub" + + " MATCHBANDBIN=" + match; + Isis::iApp ->Exec("automos", parameters); //Creates the highpass cubes from the cubes FileList std::ofstream highPassList; - highPassList.open( "HighPassList.lis" ); - for ( unsigned i=0; iExec("algebra",parameters); - + " FROM2=" + pathName + "LowpassMosaic.cub" + + " TO=" + ui.GetFilename("TO") + + " OPERATOR= add"; + Isis::iApp ->Exec("algebra", parameters); + //Will remove all of the temp files by default - if ( ui.GetBoolean("REMOVETEMP") ) { + if(ui.GetBoolean("REMOVETEMP")) { string file("HighPassList.lis"); - remove( file.c_str() ); - file = pathName+"HighpassMosaic.cub"; - remove( file.c_str() ); - file = pathName+"LowpassMosaic.cub"; - remove( file.c_str() ); - file = pathName+"OriginalMosaic.cub"; - remove( file.c_str() ); + remove(file.c_str()); + file = pathName + "HighpassMosaic.cub"; + remove(file.c_str()); + file = pathName + "LowpassMosaic.cub"; + remove(file.c_str()); + file = pathName + "OriginalMosaic.cub"; + remove(file.c_str()); - for ( unsigned i=0; i nooverlap; - for ( int i = 0; i < serialNumbers.Size(); i ++ ) { - nooverlap.insert( serialNumbers.SerialNumber(i) ); + for(int i = 0; i < serialNumbers.Size(); i ++) { + nooverlap.insert(serialNumbers.SerialNumber(i)); } // Create the output - stringstream output (stringstream::in | stringstream::out); + stringstream output(stringstream::in | stringstream::out); output.precision(16); output.setf(ios::showpoint); string delim = ""; string pretty = ""; // Makes tab tables look pretty, ignored in CSV bool singleLine = false; - if ( ui.WasEntered("DETAIL") ) { - if ( ui.GetString("TABLETYPE") == "CSV" ) { + if(ui.WasEntered("DETAIL")) { + if(ui.GetString("TABLETYPE") == "CSV") { delim = ","; singleLine = ui.GetBoolean("SINGLELINE"); // This line was removed because reability (ios::showpoint) was more // important than an extra decimal place of precision. //output.setf(ios::scientific,ios::floatfield); } - else if ( ui.GetString("TABLETYPE") == "TAB" ) { + else if(ui.GetString("TABLETYPE") == "TAB") { delim = "\t"; pretty = "\t"; tab = true; } - - full = ( ui.GetString("DETAIL") == "FULL" ); + + full = (ui.GetString("DETAIL") == "FULL"); } bool firstFullOutput = true; - stringstream errors (stringstream::in | stringstream::out); + stringstream errors(stringstream::in | stringstream::out); int errorNum = 0; // Extracts the stats of each overlap and adds to the table @@ -80,18 +80,18 @@ void IsisMain() { Statistics area; Statistics sncount; int overlapnum = 0;//Makes sure there are overlaps - for ( int index = 0; index < overlaps.Size(); index ++ ) { + for(int index = 0; index < overlaps.Size(); index ++) { - if ( overlaps[index]->Size() > 1 ) { + if(overlaps[index]->Size() > 1) { overlapnum++; // Removes the overlapping Serial Numbers for the nooverlap set - for ( int i = 0; i < overlaps[index]->Size(); i ++ ) { - nooverlap.erase( (*overlaps[index])[i] ); + for(int i = 0; i < overlaps[index]->Size(); i ++) { + nooverlap.erase((*overlaps[index])[i]); } // Sets up the serial number stats - sncount.AddData( overlaps[index]->Size() ); + sncount.AddData(overlaps[index]->Size()); // Sets up the thickness stats by doing A over E const geos::geom::MultiPolygon *mpLatLon = overlaps[index]->Polygon(); @@ -104,28 +104,28 @@ void IsisMain() { Isis::Pvl maplab; maplab.AddGroup(Isis::PvlGroup("Mapping")); Isis::PvlGroup &mapGroup = maplab.FindGroup("Mapping"); - mapGroup += Isis::PvlKeyword("EquatorialRadius",(string)radii["EquatorialRadius"]); - mapGroup += Isis::PvlKeyword("PolarRadius",(string)radii["PolarRadius"]); - mapGroup += Isis::PvlKeyword("LatitudeType","Planetocentric"); - mapGroup += Isis::PvlKeyword("LongitudeDirection","PositiveEast"); - mapGroup += Isis::PvlKeyword("LongitudeDomain",360); - mapGroup += Isis::PvlKeyword("CenterLatitude",0); - mapGroup += Isis::PvlKeyword("CenterLongitude",0); - mapGroup += Isis::PvlKeyword("ProjectionName","Sinusoidal"); + mapGroup += Isis::PvlKeyword("EquatorialRadius", (string)radii["EquatorialRadius"]); + mapGroup += Isis::PvlKeyword("PolarRadius", (string)radii["PolarRadius"]); + mapGroup += Isis::PvlKeyword("LatitudeType", "Planetocentric"); + mapGroup += Isis::PvlKeyword("LongitudeDirection", "PositiveEast"); + mapGroup += Isis::PvlKeyword("LongitudeDomain", 360); + mapGroup += Isis::PvlKeyword("CenterLatitude", 0); + mapGroup += Isis::PvlKeyword("CenterLongitude", 0); + mapGroup += Isis::PvlKeyword("ProjectionName", "Sinusoidal"); Projection *proj = Isis::ProjectionFactory::Create(maplab); // Sets up the thickness and area stats try { - geos::geom::MultiPolygon *mpXY = PolygonTools::LatLonToXY( *mpLatLon, proj ); + geos::geom::MultiPolygon *mpXY = PolygonTools::LatLonToXY(*mpLatLon, proj); - double thicknessValue = PolygonTools::Thickness( mpXY ); - thickness.AddData( thicknessValue ); + double thicknessValue = PolygonTools::Thickness(mpXY); + thickness.AddData(thicknessValue); double areaValue = mpXY->getArea(); - area.AddData( areaValue ); + area.AddData(areaValue); - if( full ) { - if( firstFullOutput ) { + if(full) { + if(firstFullOutput) { output << "Overlap ID"; output << delim << "Thickness"; output << delim << pretty << "Area"; @@ -137,21 +137,22 @@ void IsisMain() { } output << index << pretty; output << delim << thicknessValue; - if( tab ) { - output << delim << FormatString( areaValue, 18, 4 ); - } else { + if(tab) { + output << delim << FormatString(areaValue, 18, 4); + } + else { output << delim << areaValue; } output << delim << overlaps[index]->Size() << pretty; output << delim << (*overlaps[index])[0]; - output << delim << serialNumbers.Filename( (*overlaps[index])[0] ); - for( int sn=1; sn < overlaps[index]->Size(); sn ++ ) { - if( !singleLine ) { + output << delim << serialNumbers.Filename((*overlaps[index])[0]); + for(int sn = 1; sn < overlaps[index]->Size(); sn ++) { + if(!singleLine) { output << endl << pretty << delim << pretty << delim << pretty << delim; output << pretty << pretty; } output << delim << pretty << (*overlaps[index])[sn]; - output << delim << serialNumbers.Filename( (*overlaps[index])[sn] ); + output << delim << serialNumbers.Filename((*overlaps[index])[sn]); } output << endl; } @@ -159,20 +160,22 @@ void IsisMain() { delete mpXY; mpXY = NULL; - } catch ( iException &e ) { + } + catch(iException &e) { - if( ui.WasEntered("ERRORS") ) { + if(ui.WasEntered("ERRORS")) { - if( errorNum > 0 ) { + if(errorNum > 0) { errors << endl; } errorNum ++; errors << e.PvlErrors().Group(0).FindKeyword("Message")[0]; - for (int serNum = 0; serNum < overlaps[index]->Size(); serNum++) { - if( serNum == 0 ) { + for(int serNum = 0; serNum < overlaps[index]->Size(); serNum++) { + if(serNum == 0) { errors << ": "; - } else { + } + else { errors << ", "; } errors << (*overlaps[index])[serNum]; @@ -184,7 +187,7 @@ void IsisMain() { progress.CheckStatus(); continue; } - + } progress.CheckStatus(); @@ -192,70 +195,70 @@ void IsisMain() { } // Checks if there were overlaps to output results from - if ( overlapnum == 0 ) { + if(overlapnum == 0) { std::string msg = "The overlap file ["; msg += Filename(ui.GetFilename("OVERLAPLIST")).Name(); msg += "] does not contain any overlaps across the provided cubes ["; msg += Filename(ui.GetFilename("FROMLIST")).Name() + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } //Create and Log the BRIEF description PvlGroup brief("Results"); - brief += PvlKeyword( "ThicknessMinimum", thickness.Minimum() ); - brief += PvlKeyword( "ThicknessMaximum", thickness.Maximum() ); - brief += PvlKeyword( "ThicknessAverage", thickness.Average() ); - brief += PvlKeyword( "ThicknessStandardDeviation", thickness.StandardDeviation() ); - brief += PvlKeyword( "ThicknessVariance", thickness.Variance() ); + brief += PvlKeyword("ThicknessMinimum", thickness.Minimum()); + brief += PvlKeyword("ThicknessMaximum", thickness.Maximum()); + brief += PvlKeyword("ThicknessAverage", thickness.Average()); + brief += PvlKeyword("ThicknessStandardDeviation", thickness.StandardDeviation()); + brief += PvlKeyword("ThicknessVariance", thickness.Variance()); - brief += PvlKeyword( "AreaMinimum", area.Minimum() ); - brief += PvlKeyword( "AreaMaximum", area.Maximum() ); - brief += PvlKeyword( "AreaAverage", area.Average() ); - brief += PvlKeyword( "AreaStandardDeviation", area.StandardDeviation() ); - brief += PvlKeyword( "AreaVariance", area.Variance() ); + brief += PvlKeyword("AreaMinimum", area.Minimum()); + brief += PvlKeyword("AreaMaximum", area.Maximum()); + brief += PvlKeyword("AreaAverage", area.Average()); + brief += PvlKeyword("AreaStandardDeviation", area.StandardDeviation()); + brief += PvlKeyword("AreaVariance", area.Variance()); - brief += PvlKeyword( "ImageStackMinimum", sncount.Minimum() ); - brief += PvlKeyword( "ImageStackMaximum", sncount.Maximum() ); - brief += PvlKeyword( "ImageStackAverage", sncount.Average() ); - brief += PvlKeyword( "ImageStackStandardDeviation", sncount.StandardDeviation() ); - brief += PvlKeyword( "ImageStackVariance", sncount.Variance() ); + brief += PvlKeyword("ImageStackMinimum", sncount.Minimum()); + brief += PvlKeyword("ImageStackMaximum", sncount.Maximum()); + brief += PvlKeyword("ImageStackAverage", sncount.Average()); + brief += PvlKeyword("ImageStackStandardDeviation", sncount.StandardDeviation()); + brief += PvlKeyword("ImageStackVariance", sncount.Variance()); - brief += PvlKeyword( "PolygonCount", overlaps.Size() ); + brief += PvlKeyword("PolygonCount", overlaps.Size()); // Add non-overlapping cubes to the output - if ( !nooverlap.empty() ) { - for ( set::iterator itt = nooverlap.begin(); itt != nooverlap.end(); itt ++ ) { - brief += PvlKeyword( "NoOverlap", serialNumbers.Filename(*itt) ); + if(!nooverlap.empty()) { + for(set::iterator itt = nooverlap.begin(); itt != nooverlap.end(); itt ++) { + brief += PvlKeyword("NoOverlap", serialNumbers.Filename(*itt)); } } - Application::Log( brief ); + Application::Log(brief); //Log the ERRORS file - if( ui.WasEntered("ERRORS") ) { + if(ui.WasEntered("ERRORS")) { string errorname = ui.GetFilename("ERRORS"); std::ofstream errorsfile; - errorsfile.open( errorname.c_str() ); + errorsfile.open(errorname.c_str()); errorsfile << errors.str(); errorsfile.close(); } //Log error num in print.prt if there were errors - if( errorNum > 0 ) { - PvlGroup grp( "OverlapStats" ); - PvlKeyword key( "ErrorNumber", iString(errorNum) ); - grp.AddKeyword( key ); - Application::Log( grp ); + if(errorNum > 0) { + PvlGroup grp("OverlapStats"); + PvlKeyword key("ErrorNumber", iString(errorNum)); + grp.AddKeyword(key); + Application::Log(grp); } // Display FULL output - if( full ) { + if(full) { string outname = ui.GetFilename("TO"); std::ofstream outfile; - outfile.open( outname.c_str() ); + outfile.open(outname.c_str()); outfile << output.str(); outfile.close(); if(outfile.fail()) { @@ -268,30 +271,30 @@ void IsisMain() { /** - * Takes a string and formats the length of that string around the decimal - * point. - * + * Takes a string and formats the length of that string around the decimal + * point. + * * @param input The input double to be formatted - * @param head The desired character length for the double prior to the + * @param head The desired character length for the double prior to the * decimal point. It will be filled with " " (white space) - * @param tail The desired character length for the double after the decimal + * @param tail The desired character length for the double after the decimal * point. It will be filled with "0". - * + * * @return std::string The formatted double for display */ -std::string FormatString( double input, int head, int tail ) { +std::string FormatString(double input, int head, int tail) { - iString result( input ); + iString result(input); int point = result.find_first_of("."); - iString resultHead( result.substr(0,point) ); - iString resultTail( result.substr(point+1,result.size()-point-1) ); + iString resultHead(result.substr(0, point)); + iString resultTail(result.substr(point + 1, result.size() - point - 1)); - for( int place = resultHead.size(); place < head; place ++ ) { + for(int place = resultHead.size(); place < head; place ++) { resultHead = " " + resultHead; } - for( int place = resultTail.size(); place < tail; place ++ ) { + for(int place = resultTail.size(); place < tail; place ++) { resultTail = resultTail + "0"; } diff --git a/isis/src/base/apps/pad/pad.cpp b/isis/src/base/apps/pad/pad.cpp index 0bdd2e35ec..4352535d78 100644 --- a/isis/src/base/apps/pad/pad.cpp +++ b/isis/src/base/apps/pad/pad.cpp @@ -6,15 +6,15 @@ #include "Projection.h" #include "SubArea.h" -using namespace std; +using namespace std; using namespace Isis; -void CreateBase (Buffer &buf); +void CreateBase(Buffer &buf); void IsisMain() { // We will be use a mosaic technique so get the size of the input file ProcessMosaic p; - Cube *icube = p.SetInputCube ("FROM"); + Cube *icube = p.SetInputCube("FROM"); int ins = icube->Samples(); int inl = icube->Lines(); int inb = icube->Bands(); @@ -34,33 +34,33 @@ void IsisMain() { // We need to create the output file ProcessByLine bl; bl.SetInputCube("FROM"); // Do this to match pixelType - bl.SetOutputCube("TO",ns,nl,nb); + bl.SetOutputCube("TO", ns, nl, nb); bl.ClearInputCubes(); // Now get rid of it bl.Progress()->SetText("Creating pad"); bl.StartProcess(CreateBase); - bl.EndProcess(); + bl.EndProcess(); // Place the input in the file we just created - Cube *ocube = p.SetOutputCube ("TO"); + Cube *ocube = p.SetOutputCube("TO"); p.Progress()->SetText("Inserting cube"); - p.StartProcess(leftPad+1, topPad+1, 1, input); + p.StartProcess(leftPad + 1, topPad + 1, 1, input); // Construct a label with the results PvlGroup results("Results"); - results += PvlKeyword ("InputLines", inl); - results += PvlKeyword ("InputSamples", ins); - results += PvlKeyword ("LeftPad", leftPad); - results += PvlKeyword ("RightPad", rightPad); - results += PvlKeyword ("TopPad", topPad); - results += PvlKeyword ("BottomPad", bottomPad); - results += PvlKeyword ("OutputLines", nl); - results += PvlKeyword ("OutputSamples", ns); + results += PvlKeyword("InputLines", inl); + results += PvlKeyword("InputSamples", ins); + results += PvlKeyword("LeftPad", leftPad); + results += PvlKeyword("RightPad", rightPad); + results += PvlKeyword("TopPad", topPad); + results += PvlKeyword("BottomPad", bottomPad); + results += PvlKeyword("OutputLines", nl); + results += PvlKeyword("OutputSamples", ns); // Update the Mapping, Instrument, and AlphaCube groups in the // output cube label SubArea s; - s.SetSubArea(inl,ins,1-topPad,1-leftPad,inl+bottomPad,ins+rightPad,1.0,1.0); - s.UpdateLabel(icube,ocube,results); + s.SetSubArea(inl, ins, 1 - topPad, 1 - leftPad, inl + bottomPad, ins + rightPad, 1.0, 1.0); + s.UpdateLabel(icube, ocube, results); p.EndProcess(); @@ -68,8 +68,8 @@ void IsisMain() { Application::Log(results); } -void CreateBase (Buffer &buf) { - for (int i=0; iSamples(), icube->Lines(), icube->Bands()); + if(ui.GetString("MODE") == "TRANSFORM") { + Cube *ocube = p.SetOutputCube(ui.GetAsString("TO"), cao, icube->Samples(), icube->Lines(), icube->Bands()); numDimensions = icube->Bands(); pca = Isis::PrincipalComponentAnalysis(numDimensions); ProcessByBrick p2; @@ -50,9 +49,9 @@ void IsisMain() Isis::TableRecord record; record += field; Isis::Table table("Transform Matrix", record); - for (int i=0; i row; - for (int j=0; jWrite(table); p.EndProcess(); } - else if (ui.GetString("MODE") == "INVERSE") { - if (!(icube->HasTable("Transform Matrix")) ) { - std::string m="The input cube has not been transformed into its principal components"; - throw Isis::iException::Message(Isis::iException::Programmer,m,_FILEINFO_); + else if(ui.GetString("MODE") == "INVERSE") { + if(!(icube->HasTable("Transform Matrix"))) { + std::string m = "The input cube has not been transformed into its principal components"; + throw Isis::iException::Message(Isis::iException::Programmer, m, _FILEINFO_); } Isis::Table table("Transform Matrix"); icube->Read(table); numDimensions = table.Records(); TNT::Array2D transform(numDimensions, numDimensions); - for (int i=0; i row = table[i]["Columns"]; - for (int j=0; jSamples(), icube->Lines(), numDimensions); + Cube *ocube = p.SetOutputCube(ui.GetAsString("TO"), cao, icube->Samples(), icube->Lines(), numDimensions); Pvl *label = ocube->Label(); // remove the transform matrix table from the cube - for (int i=0; i< label->Objects(); i++) { - if (label->Object(i).HasKeyword("Name") + for(int i = 0; i < label->Objects(); i++) { + if(label->Object(i).HasKeyword("Name") && label->Object(i)["Name"].IsEquivalent("Transform Matrix")) label->DeleteObject(i); } p.Progress()->SetText("Inverting Cube"); @@ -93,25 +92,25 @@ void IsisMain() p.EndProcess(); } else { - std::string m="Invalid option for MODE [" + ui.GetString("MODE") + "]"; - throw Isis::iException::Message(Isis::iException::Programmer,m,_FILEINFO_); + std::string m = "Invalid option for MODE [" + ui.GetString("MODE") + "]"; + throw Isis::iException::Message(Isis::iException::Programmer, m, _FILEINFO_); } } // Processing routine for the pca with one input cube -void Transform (Buffer &in, Buffer &out){ - for (int i=0; i pre(1, in.BandDimension()); - for (int k=0;k post = pca.Transform(pre); - for (int k=0; k pre(1, in.BandDimension()); - for (int k=0;kin.size()) pre[0][k] = 0.0; + for(int k = 0; k < pre.dim2(); k++) { + int index = i + j * in.SampleDimension() + k * in.SampleDimension() * in.LineDimension(); + if(k + 1 > in.size()) pre[0][k] = 0.0; else pre[0][k] = in[index]; } TNT::Array2D post = pca.Inverse(pre); - for (int k=0; k 0)) { ocube->PutGroup(otherLabels.FindGroup("Mapping")); } - if (otherLabels.HasGroup("Instrument") && + if(otherLabels.HasGroup("Instrument") && (otherLabels.FindGroup("Instrument").Keywords() > 0)) { ocube->PutGroup(otherLabels.FindGroup("Instrument")); } - if (otherLabels.HasGroup("BandBin") && + if(otherLabels.HasGroup("BandBin") && (otherLabels.FindGroup("BandBin").Keywords() > 0)) { ocube->PutGroup(otherLabels.FindGroup("BandBin")); } - if (otherLabels.HasGroup("Archive") && + if(otherLabels.HasGroup("Archive") && (otherLabels.FindGroup("Archive").Keywords() > 0)) { ocube->PutGroup(otherLabels.FindGroup("Archive")); } - p.EndProcess (); + p.EndProcess(); return; } diff --git a/isis/src/base/apps/percent/percent.cpp b/isis/src/base/apps/percent/percent.cpp index dd8e7b4ad6..3a0e3b86b1 100644 --- a/isis/src/base/apps/percent/percent.cpp +++ b/isis/src/base/apps/percent/percent.cpp @@ -10,7 +10,7 @@ #include "iString.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { @@ -18,7 +18,7 @@ void IsisMain() { Process p; // Open the input cube - Cube *icube = p.SetInputCube("FROM",OneBand); + Cube *icube = p.SetInputCube("FROM", OneBand); // Get the desired percentage(s) UserInterface &ui = Application::GetUserInterface(); @@ -26,27 +26,27 @@ void IsisMain() { sPercentage = ui.GetString("PERCENTAGE"); vector tokens; iString::Split(',', sPercentage, tokens, true); - PvlGroup results("Results"); - PvlKeyword kwPercent("Percentage"); - PvlKeyword kwValue("Value"); + PvlGroup results("Results"); + PvlKeyword kwPercent("Percentage"); + PvlKeyword kwValue("Value"); - for(unsigned int i = 0; iHistogram(); double value = hist->Percent(percentage); - kwPercent += percentage; - kwValue += value; + kwPercent += percentage; + kwValue += value; } results += kwPercent; results += kwValue; // Log the results - Application::Log(results); + Application::Log(results); // Write an output file if requested - if (ui.WasEntered("TO")) { - Pvl temp; - temp.AddGroup(results); - temp.Write(ui.GetFilename("TO","txt")); - } + if(ui.WasEntered("TO")) { + Pvl temp; + temp.AddGroup(results); + temp.Write(ui.GetFilename("TO", "txt")); + } } diff --git a/isis/src/base/apps/phocube/phocube.cpp b/isis/src/base/apps/phocube/phocube.cpp index 1a7823b09f..6d30905e65 100644 --- a/isis/src/base/apps/phocube/phocube.cpp +++ b/isis/src/base/apps/phocube/phocube.cpp @@ -6,66 +6,66 @@ #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; // Global variables Camera *cam; int nbands; bool phase, emission, incidence, latitude, longitude, pixelResolution, - lineResolution, sampleResolution, detectorResolution, northAzimuth, - sunAzimuth, spacecraftAzimuth, offnadirAngle; + lineResolution, sampleResolution, detectorResolution, northAzimuth, + sunAzimuth, spacecraftAzimuth, offnadirAngle; -void phocube (Buffer &out); +void phocube(Buffer &out); void IsisMain() { // Get the camera information Process p1; - Cube *icube = p1.SetInputCube("FROM",OneBand); + Cube *icube = p1.SetInputCube("FROM", OneBand); cam = icube->Camera(); - // We will be processing by brick. + // We will be processing by brick. ProcessByBrick p; // Find out which bands are to be created UserInterface &ui = Application::GetUserInterface(); nbands = 0; - if ((phase = ui.GetBoolean("PHASE"))) nbands++; - if ((emission = ui.GetBoolean("EMISSION"))) nbands++; - if ((incidence = ui.GetBoolean("INCIDENCE"))) nbands++; - if ((latitude = ui.GetBoolean("LATITUDE"))) nbands++; - if ((longitude = ui.GetBoolean("LONGITUDE"))) nbands++; - if ((pixelResolution = ui.GetBoolean("PIXELRESOLUTION"))) nbands++; - if ((lineResolution = ui.GetBoolean("LINERESOLUTION"))) nbands++; - if ((sampleResolution = ui.GetBoolean("SAMPLERESOLUTION"))) nbands++; - if ((detectorResolution = ui.GetBoolean("DETECTORRESOLUTION"))) nbands++; - if ((northAzimuth = ui.GetBoolean("NORTHAZIMUTH"))) nbands++; - if ((sunAzimuth = ui.GetBoolean("SUNAZIMUTH"))) nbands++; - if ((spacecraftAzimuth = ui.GetBoolean("SPACECRAFTAZIMUTH"))) nbands++; - if ((offnadirAngle = ui.GetBoolean("OFFNADIRANGLE"))) nbands++; - - if (nbands < 1) { + if((phase = ui.GetBoolean("PHASE"))) nbands++; + if((emission = ui.GetBoolean("EMISSION"))) nbands++; + if((incidence = ui.GetBoolean("INCIDENCE"))) nbands++; + if((latitude = ui.GetBoolean("LATITUDE"))) nbands++; + if((longitude = ui.GetBoolean("LONGITUDE"))) nbands++; + if((pixelResolution = ui.GetBoolean("PIXELRESOLUTION"))) nbands++; + if((lineResolution = ui.GetBoolean("LINERESOLUTION"))) nbands++; + if((sampleResolution = ui.GetBoolean("SAMPLERESOLUTION"))) nbands++; + if((detectorResolution = ui.GetBoolean("DETECTORRESOLUTION"))) nbands++; + if((northAzimuth = ui.GetBoolean("NORTHAZIMUTH"))) nbands++; + if((sunAzimuth = ui.GetBoolean("SUNAZIMUTH"))) nbands++; + if((spacecraftAzimuth = ui.GetBoolean("SPACECRAFTAZIMUTH"))) nbands++; + if((offnadirAngle = ui.GetBoolean("OFFNADIRANGLE"))) nbands++; + + if(nbands < 1) { string message = "At least one photometry parameter must be entered" "[PHASE, EMISSION, INCIDENCE, LATITUDE, LONGITUDE]"; - throw iException::Message (iException::User, message, _FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } // Create a bandbin group for the output label PvlKeyword name("Name"); - if (phase) name += "Phase Angle"; - if (emission) name += "Emission Angle"; - if (incidence) name += "Incidence Angle"; - if (latitude) name += "Latitude"; - if (longitude) name += "Longitude"; - if (pixelResolution) name += "Pixel Resolution"; - if (lineResolution) name += "Line Resolution"; - if (sampleResolution) name += "Sample Resolution"; - if (detectorResolution) name += "Detector Resolution"; - if (northAzimuth) name += "North Azimuth"; - if (sunAzimuth) name += "Sun Azimuth"; - if (spacecraftAzimuth) name += "Spacecraft Azimuth"; - if (offnadirAngle) name += "OffNadir Angle"; + if(phase) name += "Phase Angle"; + if(emission) name += "Emission Angle"; + if(incidence) name += "Incidence Angle"; + if(latitude) name += "Latitude"; + if(longitude) name += "Longitude"; + if(pixelResolution) name += "Pixel Resolution"; + if(lineResolution) name += "Line Resolution"; + if(sampleResolution) name += "Sample Resolution"; + if(detectorResolution) name += "Detector Resolution"; + if(northAzimuth) name += "North Azimuth"; + if(sunAzimuth) name += "Sun Azimuth"; + if(spacecraftAzimuth) name += "Spacecraft Azimuth"; + if(offnadirAngle) name += "OffNadir Angle"; PvlGroup bandBin("BandBin"); bandBin += name; @@ -73,8 +73,8 @@ void IsisMain() { // of input cube elements (label, blobs, etc...). It *must* be cleared // prior to systematic processing. (void) p.SetInputCube("FROM", OneBand); - Cube *ocube = p.SetOutputCube("TO",icube->Samples(), icube->Lines(), nbands); - p.SetBrickSize(64,64,nbands); + Cube *ocube = p.SetOutputCube("TO", icube->Samples(), icube->Lines(), nbands); + p.SetBrickSize(64, 64, nbands); p.ClearInputCubes(); // Toss the input file as stated above // Start the processing @@ -84,11 +84,11 @@ void IsisMain() { // exists, remove all existing keywords and add the keywords for this app. // Otherwise, just put the group in. PvlObject &cobj = ocube->Label()->FindObject("IsisCube"); - if (cobj.HasGroup("BandBin")) { + if(cobj.HasGroup("BandBin")) { PvlGroup &bb = cobj.FindGroup("BandBin"); bb.Clear(); PvlContainer::PvlKeywordIterator k = bandBin.Begin(); - while (k != bandBin.End()) { + while(k != bandBin.End()) { bb += *k; ++k; } @@ -100,72 +100,72 @@ void IsisMain() { p.EndProcess(); } -void phocube (Buffer &out) { +void phocube(Buffer &out) { - for (int i=0; i<64; i++) { - for (int j=0; j<64; j++) { + for(int i = 0; i < 64; i++) { + for(int j = 0; j < 64; j++) { int index = i * 64 + j; double samp = out.Sample(index); double line = out.Line(index); - cam->SetImage(samp,line); - - if (cam->HasSurfaceIntersection()) { - if (phase) { + cam->SetImage(samp, line); + + if(cam->HasSurfaceIntersection()) { + if(phase) { out[index] = cam->PhaseAngle(); index += 64 * 64; } - if (emission) { + if(emission) { out[index] = cam->EmissionAngle(); index += 64 * 64; } - if (incidence) { + if(incidence) { out[index] = cam->IncidenceAngle(); index += 64 * 64; } - if (latitude) { + if(latitude) { out[index] = cam->UniversalLatitude(); index += 64 * 64; } - if (longitude) { + if(longitude) { out[index] = cam->UniversalLongitude(); index += 64 * 64; } - if (pixelResolution) { + if(pixelResolution) { out[index] = cam->PixelResolution(); index += 64 * 64; } - if (lineResolution) { + if(lineResolution) { out[index] = cam->LineResolution(); index += 64 * 64; } - if (sampleResolution) { + if(sampleResolution) { out[index] = cam->SampleResolution(); index += 64 * 64; } - if (detectorResolution) { + if(detectorResolution) { out[index] = cam->SampleResolution(); index += 64 * 64; } - if (northAzimuth) { + if(northAzimuth) { out[index] = cam->NorthAzimuth(); index += 64 * 64; } - if (sunAzimuth) { + if(sunAzimuth) { out[index] = cam->SunAzimuth(); index += 64 * 64; } - if (spacecraftAzimuth) { + if(spacecraftAzimuth) { out[index] = cam->SpacecraftAzimuth(); index += 64 * 64; } - if (offnadirAngle) { + if(offnadirAngle) { out[index] = cam->OffNadirAngle(); index += 64 * 64; } } // Trim outerspace else { - for (int b=0; b #include #include @@ -42,99 +42,99 @@ namespace Isis { /** * @brief Construct from PVL and Cube file - * + * * @author Kris Becker - 2/21/2010 - * + * * @param pvl Photometric parameter files * @param cube Input cube file */ - Hillier::Hillier (PvlObject &pvl, Cube &cube) { + Hillier::Hillier(PvlObject &pvl, Cube &cube) { _camera = cube.Camera(); init(pvl, cube); } /** - * @brief Compute photometric DN at given line/sample/band - * - * This routine applies the photometric angles to the equation - * and returns the calibration coefficient at the given cube - * location. - * - * The return parameter is the photometric standard/photometric - * correction coefficient at the given pixel location. - * + * @brief Compute photometric DN at given line/sample/band + * + * This routine applies the photometric angles to the equation + * and returns the calibration coefficient at the given cube + * location. + * + * The return parameter is the photometric standard/photometric + * correction coefficient at the given pixel location. + * * @author Kris Becker - 2/21/2010 - * + * * @param line Line of cube image to compute photometry * @param sample Sample of cube image to compute photometry * @param band Band of cube image to compute photometry - * + * * @return double Photometric correction at cube loation */ double Hillier::Compute(const double &line, const double &sample, int band) { // Update band if necessary - if (_camera->Band() != band) { + if(_camera->Band() != band) { _camera->SetBand(band); } - if (!_camera->SetImage(sample, line)) return (Null); + if(!_camera->SetImage(sample, line)) return (Null); double i = _camera->IncidenceAngle(); double e = _camera->EmissionAngle(); double g = _camera->PhaseAngle(); - if (i >= 90.0) return (Null); + if(i >= 90.0) return (Null); return(photometry(i, e, g, band)); } /** * @brief Method to get photometric property given angles - * - * This routine computes the photometric property at the given - * cube location after ensuring a proper parameter container is - * found for the specified band. - * + * + * This routine computes the photometric property at the given + * cube location after ensuring a proper parameter container is + * found for the specified band. + * * @author Kris Becker - 2/21/2010 - * + * * @param i Incidence angle at cube location * @param e Emission angle at cube location * @param g Phase angle at cube location - * @param band Band number in cube (actually is band index) for + * @param band Band number in cube (actually is band index) for * lookup purposes - * - * @return double Returns photometric correction using + * + * @return double Returns photometric correction using * parameters */ double Hillier::photometry(double i, double e, double g, int band) const { - // Test for valid band - if ((band <= 0) || (band > (int) _bandpho.size())) { + // Test for valid band + if((band <= 0) || (band > (int) _bandpho.size())) { std::string mess = "Provided band " + iString(band) + " out of range."; throw iException::Message(iException::Programmer, mess, _FILEINFO_); } double ph = photometry(_bandpho[band-1], i, e, g); - return (_bandpho[band-1].phoStd/ph); + return (_bandpho[band-1].phoStd / ph); } /** - * @brief Performs actual photometric correction calculations - * - * This routine computes photometric correction using parameters - * for the Hillier-Buratti-Hill equation. - * + * @brief Performs actual photometric correction calculations + * + * This routine computes photometric correction using parameters + * for the Hillier-Buratti-Hill equation. + * * @author Kris Becker - 2/21/2010 - * + * * @param parms Container of band-specific Hillier parameters * @param i Incidence angle in degrees * @param e Emission angle in degrees * @param g Phase angle in degrees - * + * * @return double Photometric correction parameter */ - double Hillier::photometry(const Parameters &parms, double i, double e, + double Hillier::photometry(const Parameters &parms, double i, double e, double g) const { // Ensure problematic values are adjusted - if (i == 0.0) i = 10.E-12; - if (e == 0.0) e = 10.E-12; + if(i == 0.0) i = 10.E-12; + if(e == 0.0) e = 10.E-12; // Convert to radians i *= rpd_c(); @@ -150,22 +150,22 @@ namespace Isis { // Simple Hillier photometric polynomial equation with exponential opposition // surge term. - double rcal = (mu0/(mu+mu0)) * (parms.b0 * exp(-parms.b1*alpha) + parms.a0 + - (parms.a1 * alpha) + (parms.a2 * alpha2) + - (parms.a3 * alpha * alpha2) + - (parms.a4 * alpha2 * alpha2)); + double rcal = (mu0 / (mu + mu0)) * (parms.b0 * exp(-parms.b1 * alpha) + parms.a0 + + (parms.a1 * alpha) + (parms.a2 * alpha2) + + (parms.a3 * alpha * alpha2) + + (parms.a4 * alpha2 * alpha2)); return (rcal); } /** - * @brief Return parameters used for all bands - * - * Method creates keyword vectors of band specific parameters - * used in the photometric correction. - * + * @brief Return parameters used for all bands + * + * Method creates keyword vectors of band specific parameters + * used in the photometric correction. + * * @author Kris Becker - 2/22/2010 - * + * * @param pvl Output PVL container write keywords */ void Hillier::Report(PvlContainer &pvl) { @@ -174,18 +174,18 @@ namespace Isis { pvl += PvlKeyword("EmaRef", _eRef, "degrees"); pvl += PvlKeyword("PhaRef", _gRef, "degrees"); PvlKeyword units("HillierUnits"); - PvlKeyword phostd("PhotometricStandard"); - PvlKeyword bbc("BandBinCenter"); + PvlKeyword phostd("PhotometricStandard"); + PvlKeyword bbc("BandBinCenter"); PvlKeyword bbct("BandBinCenterTolerance"); PvlKeyword bbn("BandNumber"); - PvlKeyword b0("B0"); - PvlKeyword b1("B1"); - PvlKeyword a0("A0"); - PvlKeyword a1("A1"); - PvlKeyword a2("A2"); - PvlKeyword a3("A3"); - PvlKeyword a4("A4"); - for (unsigned int i = 0 ; i < _bandpho.size() ; i++) { + PvlKeyword b0("B0"); + PvlKeyword b1("B1"); + PvlKeyword a0("A0"); + PvlKeyword a1("A1"); + PvlKeyword a2("A2"); + PvlKeyword a3("A3"); + PvlKeyword a4("A4"); + for(unsigned int i = 0 ; i < _bandpho.size() ; i++) { Parameters &p = _bandpho[i]; units.AddValue(p.units); phostd.AddValue(p.phoStd); @@ -217,31 +217,31 @@ namespace Isis { /** - * @brief Determine Hillier parameters given a wavelength - * - * This method determines the set of Hillier parameters to use - * for a given wavelength. It iterates through all band - * profiles as read from the PVL file and computes the - * difference between the "wavelength" parameter and the - * BandBinCenter keyword. The absolute value of this value is - * checked against the BandBinCenterTolerance paramter and if it - * is less than or equal to it, a Parameter container is - * returned. - * + * @brief Determine Hillier parameters given a wavelength + * + * This method determines the set of Hillier parameters to use + * for a given wavelength. It iterates through all band + * profiles as read from the PVL file and computes the + * difference between the "wavelength" parameter and the + * BandBinCenter keyword. The absolute value of this value is + * checked against the BandBinCenterTolerance paramter and if it + * is less than or equal to it, a Parameter container is + * returned. + * * @author Kris Becker - 2/22/2010 - * + * * @param wavelength Wavelength used to find parameter set - * - * @return Hillier::Parameters Container of valid values. If + * + * @return Hillier::Parameters Container of valid values. If * not found, a value of iProfile = -1 is returned. */ Hillier::Parameters Hillier::findParameters(const double wavelength) const { - for (unsigned int i = 0 ; i < _profiles.size() ; i++) { + for(unsigned int i = 0 ; i < _profiles.size() ; i++) { const DbProfile &p = _profiles[i]; - if (p.exists("BandBinCenter")) { + if(p.exists("BandBinCenter")) { double p_center = ConfKey(p, "BandBinCenter", Null); double tolerance = ConfKey(p, "BandBinCenterTolerance", 1.0E-6); - if (fabs(wavelength-p_center) <= fabs(tolerance)) { + if(fabs(wavelength - p_center) <= fabs(tolerance)) { Parameters pars = extract(p); pars.iProfile = i; pars.wavelength = wavelength; @@ -256,16 +256,16 @@ namespace Isis { } /** - * @brief Extracts necessary Hillier parameters from profile - * - * Given a profile read from the input PVL file, this method - * extracts needed parameters (from Keywords) in the PVL profile - * and creates a container of the converted values. - * + * @brief Extracts necessary Hillier parameters from profile + * + * Given a profile read from the input PVL file, this method + * extracts needed parameters (from Keywords) in the PVL profile + * and creates a container of the converted values. + * * @author Kris Becker - 2/22/2010 - * + * * @param p Profile to extract/convert - * + * * @return Hillier::Parameters Container of extracted values */ Hillier::Parameters Hillier::extract(const DbProfile &p) const { @@ -280,72 +280,72 @@ namespace Isis { pars.wavelength = ConfKey(p, "BandBinCenter", Null); pars.tolerance = ConfKey(p, "BandBinCenterTolerance", Null); // Determine equation units - defaults to Radians - pars.units = ConfKey(p,"HillierUnits", iString("Radians")); + pars.units = ConfKey(p, "HillierUnits", iString("Radians")); pars.phaUnit = (iString::Equal(pars.units, "Degrees")) ? 1.0 : rpd_c(); return (pars); } /** - * @brief Initialize class from input PVL and Cube files - * - * This method is typically called at class instantiation time, - * but is reentrant. It reads the parameter PVL file and - * extracts Photometric model and Normalization models from it. - * The cube is needed to match all potential profiles for each - * band. - * + * @brief Initialize class from input PVL and Cube files + * + * This method is typically called at class instantiation time, + * but is reentrant. It reads the parameter PVL file and + * extracts Photometric model and Normalization models from it. + * The cube is needed to match all potential profiles for each + * band. + * * @param pvl Input PVL parameter files - * @param cube Input cube file to correct - * - * @author Kris Becker - 2/22/2010 - * @history 2010-02-25 Kris Becker Added check for valid incidence angle + * @param cube Input cube file to correct + * + * @author Kris Becker - 2/22/2010 + * @history 2010-02-25 Kris Becker Added check for valid incidence angle */ void Hillier::init(PvlObject &pvl, Cube &cube) { // Make it reentrant - _profiles.clear(); - _bandpho.clear(); + _profiles.clear(); + _bandpho.clear(); // Interate over all Photometric groups - _normProf = DbProfile(pvl.FindObject("NormalizationModel").FindGroup("Algorithm",Pvl::Traverse)); + _normProf = DbProfile(pvl.FindObject("NormalizationModel").FindGroup("Algorithm", Pvl::Traverse)); _iRef = ConfKey(_normProf, "IncRef", 30.0); _eRef = ConfKey(_normProf, "EmaRef", 0.0); _gRef = ConfKey(_normProf, "PhaRef", _iRef); // Check for valid incidence angle - if (_iRef > fabs(90.0)) { + if(_iRef > fabs(90.0)) { ostringstream mess; - mess << "Invalid incidence angle (" << _iRef + mess << "Invalid incidence angle (" << _iRef << " >= 90.0) provided in PVL config file " << pvl.Filename(); throw iException::Message(iException::User, mess.str(), _FILEINFO_); } - + PvlObject &phoObj = pvl.FindObject("PhotometricModel"); DbProfile phoProf = DbProfile(phoObj); PvlObject::PvlGroupIterator algo = phoObj.BeginGroup(); - while (algo != phoObj.EndGroup()) { - if (iString::Equal(algo->Name(), "Algorithm")) { - _profiles.push_back(DbProfile(phoProf,DbProfile(*algo))); + while(algo != phoObj.EndGroup()) { + if(iString::Equal(algo->Name(), "Algorithm")) { + _profiles.push_back(DbProfile(phoProf, DbProfile(*algo))); } ++algo; } Pvl *label = cube.Label(); - PvlKeyword center = label->FindGroup("BandBin",Pvl::Traverse)["Center"]; + PvlKeyword center = label->FindGroup("BandBin", Pvl::Traverse)["Center"]; string errs(""); - for (int i = 0; i < cube.Bands() ; i++) { + for(int i = 0; i < cube.Bands() ; i++) { Parameters parms = findParameters(center[i]); - if (parms.IsValid()) { - parms.band = i+1; - _camera->SetBand(i+1); + if(parms.IsValid()) { + parms.band = i + 1; + _camera->SetBand(i + 1); parms.phoStd = photometry(parms, _iRef, _eRef, _gRef); _bandpho.push_back(parms); } else { // Appropriate photometric parameters not found ostringstream mess; - mess << "Band " << i+1 << " with wavelength Center = " << center[i] - << " does not have PhotometricModel Algorithm group/profile"; + mess << "Band " << i + 1 << " with wavelength Center = " << center[i] + << " does not have PhotometricModel Algorithm group/profile"; iException &e = iException::Message(iException::User, mess.str(), _FILEINFO_); errs += e.Errors() + "\n"; e.Clear(); @@ -353,7 +353,7 @@ namespace Isis { } // Check for errors and throw them all at the same time - if (!errs.empty()) { + if(!errs.empty()) { errs += " --> Errors in the input PVL file \"" + pvl.Filename() + "\""; throw iException::Message(iException::User, errs, _FILEINFO_); } diff --git a/isis/src/base/apps/phohillier/Hillier.h b/isis/src/base/apps/phohillier/Hillier.h index 9b70a70836..ef47d20e10 100644 --- a/isis/src/base/apps/phohillier/Hillier.h +++ b/isis/src/base/apps/phohillier/Hillier.h @@ -1,30 +1,30 @@ #if !defined(Hillier_h) #define Hillier_h -/** - * @file - * $Revision: 1.2 $ - * $Date: 2010/02/24 09:54:18 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.2 $ + * $Date: 2010/02/24 09:54:18 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include -#include +#include #include #include "iString.h" @@ -34,47 +34,57 @@ namespace Isis { -/** Implement templatized MIN fumnction */ - template inline T MIN(const T &A, const T &B) { - if ( A < B ) { return (A); } - else { return (B); } - } - - /** Implement templatized MAX function */ - template inline T MAX(const T &A, const T &B) { - if ( A > B ) { return (A); } - else { return (B); } - } + /** Implement templatized MIN fumnction */ + template inline T MIN(const T &A, const T &B) { + if(A < B) { + return (A); + } + else { + return (B); + } + } + + /** Implement templatized MAX function */ + template inline T MAX(const T &A, const T &B) { + if(A > B) { + return (A); + } + else { + return (B); + } + } class PvlObject; class Camera; - /** - * @brief An implementation of the Hillier photometric function - * - * This class implements the Hillier-Buratti-Hill photometric - * equation as outline in thier paper "Multispectral Photometry - * of the Moon and Absolute Calibration of the Clementine UV/VIS + /** + * @brief An implementation of the Hillier photometric function + * + * This class implements the Hillier-Buratti-Hill photometric + * equation as outline in thier paper "Multispectral Photometry + * of the Moon and Absolute Calibration of the Clementine UV/VIS * Camera", published in Icaris v141, pg. 205-255 (1999). - * + * * @author 2010-02-15 Kris Becker * @history 2010-02-24 Kris Becker - Changed include paths by adding "naif" to NAIF * includes - * - */ + * + */ class Hillier { public: /** * @brief Create Hilier photometric object - * + * */ - Hillier (PvlObject &pvl, Cube &cube); + Hillier(PvlObject &pvl, Cube &cube); //! Destructor virtual ~Hillier() {}; - void setCamera(Camera *cam) { _camera = cam; } + void setCamera(Camera *cam) { + _camera = cam; + } double Compute(const double &line, const double &sample, int band = 1); double photometry(double i, double e, double g, int band = 1) const; void Report(PvlContainer &pvl); @@ -82,16 +92,18 @@ namespace Isis { private: /** * @brief Container for band photometric correction parameters - * + * * @author Kris Becker - 2/21/2010 */ struct Parameters { - Parameters() : b0(0.0), b1(0.0), a0(0.0), a1(0.0), a2(0.0), a3(0.0), - a4(0.0), wavelength(0.0), tolerance(0.0), - units("Degrees"), phaUnit(1.0), band(0), phoStd(0.0), - iProfile(-1) { } + Parameters() : b0(0.0), b1(0.0), a0(0.0), a1(0.0), a2(0.0), a3(0.0), + a4(0.0), wavelength(0.0), tolerance(0.0), + units("Degrees"), phaUnit(1.0), band(0), phoStd(0.0), + iProfile(-1) { } ~Parameters() { } - bool IsValid() const { return (iProfile != -1); } + bool IsValid() const { + return (iProfile != -1); + } double b0, b1, a0, a1, a2, a3, a4; // - T ConfKey(const DbProfile &conf, const std::string &keyname, - const T &defval,int index = 0) const { - if (!conf.exists(keyname)) { return (defval); } - if (conf.count(keyname) < index) { return (defval); } + template + T ConfKey(const DbProfile &conf, const std::string &keyname, + const T &defval, int index = 0) const { + if(!conf.exists(keyname)) { + return (defval); + } + if(conf.count(keyname) < index) { + return (defval); + } iString iValue(conf.value(keyname, index)); T value = iValue; // This makes it work with a string? return (value); diff --git a/isis/src/base/apps/phohillier/phohillier.cpp b/isis/src/base/apps/phohillier/phohillier.cpp index 500d41abf3..030b99373d 100644 --- a/isis/src/base/apps/phohillier/phohillier.cpp +++ b/isis/src/base/apps/phohillier/phohillier.cpp @@ -11,16 +11,16 @@ #include "PvlGroup.h" #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; // Global variables Hillier *pho; -void hillier (Buffer &in, Buffer &out); +void hillier(Buffer &in, Buffer &out); void IsisMain() { - // We will be processing by line + // We will be processing by line ProcessByLine p; // Set up the input cube and get camera information @@ -33,7 +33,7 @@ void IsisMain() { UserInterface &ui = Application::GetUserInterface(); // Get the name of the parameter file Pvl par(ui.GetFilename("PHOPAR")); - auto_ptr photom = auto_ptr (new Hillier(par, *icube)); + auto_ptr photom = auto_ptr (new Hillier(par, *icube)); pho = photom.get(); // Start the processing @@ -47,27 +47,27 @@ void IsisMain() { } /** - * @brief Apply Hillier photometric correction - * - * Short function dispatched for each line to apply the Hillier photometrc - * correction function. - * + * @brief Apply Hillier photometric correction + * + * Short function dispatched for each line to apply the Hillier photometrc + * correction function. + * * @author kbecker (2/20/2010) - * + * * @param in Buffer containing input data * @param out Buffer of photometrically corrected data */ void hillier(Buffer &in, Buffer &out) { - for (int i=0; iCompute(in.Line(i), in.Sample(i), in.Band(i)); - out[i] = (IsSpecial(ph) ? Null : in[i] * ph); + out[i] = (IsSpecial(ph) ? Null : in[i] * ph); } } return; diff --git a/isis/src/base/apps/photemplate/photemplate.cpp b/isis/src/base/apps/photemplate/photemplate.cpp index f752a9b69f..b8b61c316b 100644 --- a/isis/src/base/apps/photemplate/photemplate.cpp +++ b/isis/src/base/apps/photemplate/photemplate.cpp @@ -22,13 +22,13 @@ void IsisMain() { addAtmosModel(p); addNormalModel(p); - // Get the output file name from the GUI and write the pvl + // Get the output file name from the GUI and write the pvl // to the file. If no extension is given, '.pvl' will be used. - UserInterface &ui = Application::GetUserInterface(); + UserInterface &ui = Application::GetUserInterface(); Filename out = ui.GetFilename("PVL"); string output = ui.GetFilename("PVL"); - if (out.Extension() == "") { - output += ".pvl"; + if(out.Extension() == "") { + output += ".pvl"; } p.Write(output); @@ -45,9 +45,9 @@ void addPhoModel(Pvl &pvl) { //Get the photometric model and any parameters specific to that //model and write it to the algorithm group - + //Hapke Henyey Greenstein Photometric Model - if (ui.GetString("PHOTOMETRIC") == "HAPKEHEN") { + if(ui.GetString("PHOTOMETRIC") == "HAPKEHEN") { phoAlgo.AddKeyword(PvlKeyword("Name", "Hapkehen")); double theta = ui.GetDouble("THETA"); @@ -106,9 +106,9 @@ void addAtmosModel(Pvl &pvl) { //If the normalization model is one with an atmospheric model //then create an atmospheric model and add it to the PVL. - if((ui.GetString("NORMALIZATION") == "ATMALBEDO" | - ui.GetString("NORMALIZATION") == "ATMSHADE" || - ui.GetString("NORMALIZATION") == "ATMTOPO")) { + if((ui.GetString("NORMALIZATION") == "ATMALBEDO" | + ui.GetString("NORMALIZATION") == "ATMSHADE" || + ui.GetString("NORMALIZATION") == "ATMTOPO")) { //Create an object for the atmospheric model PvlObject atmosModel("AtmosphericModel"); @@ -119,12 +119,12 @@ void addAtmosModel(Pvl &pvl) { //model and write it to the algorithm group //Anisotropic 1 Atmospheric Model - if (ui.GetString("ATMOSPHERIC") == "ANISOTROPIC1") { + if(ui.GetString("ATMOSPHERIC") == "ANISOTROPIC1") { atmosAlgo.AddKeyword(PvlKeyword("Name", "Anisotropic1")); bool nulneg = ui.GetBoolean("NULNEG"); - //if NULNEG is checked add it to the group, otherwise the + //if NULNEG is checked add it to the group, otherwise the //default is to leave it out if(nulneg) { atmosAlgo.AddKeyword(PvlKeyword("Nulneg", "YES")); @@ -165,7 +165,7 @@ void addAtmosModel(Pvl &pvl) { bool nulneg = ui.GetBoolean("NULNEG"); - //if NULNEG is checked add it to the group, otherwise the + //if NULNEG is checked add it to the group, otherwise the //default is to leave it out if(nulneg) { atmosAlgo.AddKeyword(PvlKeyword("Nulneg", "Yes")); @@ -206,7 +206,7 @@ void addAtmosModel(Pvl &pvl) { bool nulneg = ui.GetBoolean("NULNEG"); - //if NULNEG is checked add it to the group, otherwise the + //if NULNEG is checked add it to the group, otherwise the //default is to leave it out if(nulneg) { atmosAlgo.AddKeyword(PvlKeyword("Nulneg", "Yes")); @@ -247,7 +247,7 @@ void addAtmosModel(Pvl &pvl) { bool nulneg = ui.GetBoolean("NULNEG"); - //if NULNEG is checked add it to the group, otherwise the + //if NULNEG is checked add it to the group, otherwise the //default is to leave it out if(nulneg) { atmosAlgo.AddKeyword(PvlKeyword("Nulneg", "Yes")); @@ -288,7 +288,7 @@ void addAtmosModel(Pvl &pvl) { bool nulneg = ui.GetBoolean("NULNEG"); - //if NULNEG is checked add it to the group, otherwise the + //if NULNEG is checked add it to the group, otherwise the //default is to leave it out if(nulneg) { atmosAlgo.AddKeyword(PvlKeyword("Nulneg", "Yes")); @@ -319,7 +319,7 @@ void addAtmosModel(Pvl &pvl) { bool nulneg = ui.GetBoolean("NULNEG"); - //if NULNEG is checked add it to the group, otherwise the + //if NULNEG is checked add it to the group, otherwise the //default is to leave it out if(nulneg) { atmosAlgo.AddKeyword(PvlKeyword("Nulneg", "Yes")); @@ -364,7 +364,7 @@ void addNormalModel(Pvl &pvl) { //model and write it to the algorithm group //Albedo Normalization Model - if (ui.GetString("NORMALIZATION") == "ALBEDO") { + if(ui.GetString("NORMALIZATION") == "ALBEDO") { normalAlgo.AddKeyword(PvlKeyword("Name", "Albedo")); double incref = ui.GetDouble("INCREF"); diff --git a/isis/src/base/apps/photomet/photomet.cpp b/isis/src/base/apps/photomet/photomet.cpp index 223420cbf2..d855b33ee8 100644 --- a/isis/src/base/apps/photomet/photomet.cpp +++ b/isis/src/base/apps/photomet/photomet.cpp @@ -13,20 +13,20 @@ #define MIN(x,y) (((x) < (y)) ? (x) : (y)) #define MAX(x,y) (((x) > (y)) ? (x) : (y)) -using namespace std; +using namespace std; using namespace Isis; // Global variables Camera *cam; Cube *icube; Photometry *pho; -double maxema; -double maxinc; +double maxema; +double maxinc; -void photomet (Buffer &in, Buffer &out); +void photomet(Buffer &in, Buffer &out); void IsisMain() { - // We will be processing by line + // We will be processing by line ProcessByLine p; // Set up the input cube and get camera information @@ -47,17 +47,18 @@ void IsisMain() { // Get the BandBin Center from the image PvlGroup pvlg = icube->GetGroup("BandBin"); double wl; - if (pvlg.HasKeyword("Center")) { + if(pvlg.HasKeyword("Center")) { PvlKeyword &wavelength = pvlg.FindKeyword("Center"); wl = wavelength[0]; - } else { + } + else { wl = 1.0; } // Create the photometry object and set the wavelength - PvlGroup &algo = par.FindObject("NormalizationModel").FindGroup("Algorithm",Pvl::Traverse); - if (!algo.HasKeyword("Wl")) { - algo.AddKeyword(Isis::PvlKeyword("Wl",wl)); + PvlGroup &algo = par.FindObject("NormalizationModel").FindGroup("Algorithm", Pvl::Traverse); + if(!algo.HasKeyword("Wl")) { + algo.AddKeyword(Isis::PvlKeyword("Wl", wl)); } pho = new Photometry(par); pho->SetPhotomWl(wl); @@ -68,46 +69,46 @@ void IsisMain() { } /** - * Perform photometric correction - * + * Perform photometric correction + * * @param in Buffer containing input DN values - * @param out Buffer containing output DN values - * @author Janet Barrett - * @internal + * @param out Buffer containing output DN values + * @author Janet Barrett + * @internal * @history 2009-01-08 Jeannie Walldren - Modified to set off * target pixels to null. Added check for new maxinc * and maxema parameters. */ -void photomet (Buffer &in, Buffer &out) { +void photomet(Buffer &in, Buffer &out) { - double pha,inc,ema,mult,base; - for (int i=0; iSetImage(in.Sample(i),in.Line(i))) { + else if(!cam->SetImage(in.Sample(i), in.Line(i))) { out[i] = NULL8; } // otherwise, compute angle values - else{ + else { pha = cam->PhaseAngle(); inc = cam->IncidenceAngle(); ema = cam->EmissionAngle(); - + // if invalid angles, set to null - if (inc >= 90.0 || ema >= 90.0) { + if(inc >= 90.0 || ema >= 90.0) { out[i] = NULL8; - } + } // if angles greater than max allowed by user, set to null - else if (inc > maxinc || ema > maxema) { + else if(inc > maxinc || ema > maxema) { out[i] = NULL8; } // otherwise, do photometric correction else { - pho->Compute(pha,inc,ema,in[i],out[i],mult,base); + pho->Compute(pha, inc, ema, in[i], out[i], mult, base); } - } + } } } diff --git a/isis/src/base/apps/photrim/photrim.cpp b/isis/src/base/apps/photrim/photrim.cpp index 5b9776b12d..a62f2629bc 100644 --- a/isis/src/base/apps/photrim/photrim.cpp +++ b/isis/src/base/apps/photrim/photrim.cpp @@ -3,7 +3,7 @@ #include "ProcessByLine.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; // Global variables @@ -17,7 +17,7 @@ double minIncidence; double maxIncidence; int lastBand; -void photrim (Buffer &in, Buffer &out); +void photrim(Buffer &in, Buffer &out); void IsisMain() { // We will be processing by line @@ -28,17 +28,17 @@ void IsisMain() { cam = icube->Camera(); // Create the output cube - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); // Get the trim angles UserInterface &ui = Application::GetUserInterface(); - minPhase = ui.GetDouble ("MINPHASE"); - maxPhase = ui.GetDouble ("MAXPHASE"); - minEmission = ui.GetDouble ("MINEMISSION"); - maxEmission = ui.GetDouble ("MAXEMISSION"); - minIncidence = ui.GetDouble ("MININCIDENCE"); - maxIncidence = ui.GetDouble ("MAXINCIDENCE"); + minPhase = ui.GetDouble("MINPHASE"); + maxPhase = ui.GetDouble("MAXPHASE"); + minEmission = ui.GetDouble("MINEMISSION"); + maxEmission = ui.GetDouble("MAXEMISSION"); + minIncidence = ui.GetDouble("MININCIDENCE"); + maxIncidence = ui.GetDouble("MAXINCIDENCE"); // Start the processing lastBand = 0; @@ -48,29 +48,29 @@ void IsisMain() { // Line processing routine -void photrim (Buffer &in, Buffer &out) { +void photrim(Buffer &in, Buffer &out) { // See if there is a change in band which would change the camera model - if (in.Band() != lastBand) { + if(in.Band() != lastBand) { lastBand = in.Band(); cam->SetBand(icube->PhysicalBand(lastBand)); } // Loop for each pixel in the line. - double samp,phase,emission,incidence; + double samp, phase, emission, incidence; double line = in.Line(); - for (int i=0; iSetImage(samp,line); - if (cam->HasSurfaceIntersection()) { - if (((phase = cam->PhaseAngle()) < minPhase) || (phase > maxPhase)) { + cam->SetImage(samp, line); + if(cam->HasSurfaceIntersection()) { + if(((phase = cam->PhaseAngle()) < minPhase) || (phase > maxPhase)) { out[i] = Isis::NULL8; } - else if (((emission = cam->EmissionAngle()) < minEmission) || - (emission > maxEmission)) { + else if(((emission = cam->EmissionAngle()) < minEmission) || + (emission > maxEmission)) { out[i] = Isis::NULL8; } - else if (((incidence = cam->IncidenceAngle()) < minIncidence) || - (incidence > maxIncidence)) { + else if(((incidence = cam->IncidenceAngle()) < minIncidence) || + (incidence > maxIncidence)) { out[i] = Isis::NULL8; } else { diff --git a/isis/src/base/apps/pointreg/pointreg.cpp b/isis/src/base/apps/pointreg/pointreg.cpp index a84b34d997..ca4245c5e0 100644 --- a/isis/src/base/apps/pointreg/pointreg.cpp +++ b/isis/src/base/apps/pointreg/pointreg.cpp @@ -19,11 +19,11 @@ using namespace std; using namespace Isis; -void PrintTemp (); +void PrintTemp(); -map GuiHelpers(){ - map helper; - helper ["PrintTemp"] = (void*) PrintTemp; +map GuiHelpers() { + map helper; + helper ["PrintTemp"] = (void *) PrintTemp; return helper; } @@ -43,7 +43,7 @@ void IsisMain() { // Create a ControlNet from the input file ControlNet inNet(ui.GetFilename("CNET")); - if (inNet.Size() <= 0) { + if(inNet.Size() <= 0) { std::string msg = "Input control network [" + ui.GetFilename("CNET") + "] "; msg += "contains no points"; throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); @@ -67,14 +67,14 @@ void IsisMain() { progress.SetMaximumSteps(inNet.Size()); progress.CheckStatus(); - int ignored=0, unmeasured=0, registered=0, unregistered=0, notintersected=0, validated=0; + int ignored = 0, unmeasured = 0, registered = 0, unregistered = 0, notintersected = 0, validated = 0; CubeManager cubeMgr; cubeMgr.SetNumOpenCubes(50); // Register the points and create a new // ControlNet containing the refined measurements - for (int i=0; iPatternChip()->TackCube(patternCM.Sample(), patternCM.Line()); ar->PatternChip()->Load(patternCube); - - if (patternCM.IsValidated()) validated++; - if (!patternCM.IsMeasured()) continue; + + if(patternCM.IsValidated()) validated++; + if(!patternCM.IsMeasured()) continue; if(!patternCM.IsReference()) { patternCM.SetReference(true); patternCM.SetChooserName("Application pointreg"); @@ -150,68 +152,68 @@ void IsisMain() { } // add reference measure outPoint.Add(patternCM); - + // reset goodMeasureCount for this point before looping measures - int goodMeasureCount = 0; + int goodMeasureCount = 0; // Register all the unvalidated measurements - for (int j = 0; j < inPoint.Size(); j++) { + for(int j = 0; j < inPoint.Size(); j++) { // don't register the reference, go to next measure - if (j == inPoint.ReferenceIndex()){ - if (!inPoint[j].Ignore()) goodMeasureCount++; + if(j == inPoint.ReferenceIndex()) { + if(!inPoint[j].Ignore()) goodMeasureCount++; continue; } // if the measurement is valid, keep it as is and go to next measure - if (inPoint[j].IsValidated()) { + if(inPoint[j].IsValidated()) { validated++; outPoint.Add(inPoint[j]); - if (!inPoint[j].Ignore()) goodMeasureCount++; + if(!inPoint[j].Ignore()) goodMeasureCount++; continue; } // if the point is unmeasured, add to output only if necessary and go to next measure - if (!inPoint[j].IsMeasured()) { + if(!inPoint[j].IsMeasured()) { unmeasured++; - if (ui.GetBoolean("OUTPUTUNMEASURED")) { + if(ui.GetBoolean("OUTPUTUNMEASURED")) { outPoint.Add(inPoint[j]); } continue; } // if user chose not to reprocess successful measures, keep registered measure as is and go to next measure - if (registerMeasures == "ESTIMATED" && inPoint[j].Type() != ControlMeasure::Estimated) { + if(registerMeasures == "ESTIMATED" && inPoint[j].Type() != ControlMeasure::Estimated) { outPoint.Add(inPoint[j]); - if (!inPoint[j].Ignore()) goodMeasureCount++; + if(!inPoint[j].Ignore()) goodMeasureCount++; continue; } - + ControlMeasure searchCM = inPoint[j]; - + // refresh pattern cube pointer to ensure it stays valid Cube &patternCube = *cubeMgr.OpenCube(files.Filename(patternCM.CubeSerialNumber())); Cube &searchCube = *cubeMgr.OpenCube(files.Filename(searchCM.CubeSerialNumber())); ar->SearchChip()->TackCube(searchCM.Sample(), searchCM.Line()); - + try { - ar->SearchChip()->Load(searchCube,*(ar->PatternChip()),patternCube); - + ar->SearchChip()->Load(searchCube, *(ar->PatternChip()), patternCube); + // If the measurements were correctly registered // Write them to the new ControlNet AutoReg::RegisterStatus res = ar->Register(); - + double score1, score2; ar->ZScores(score1, score2); searchCM.SetZScores(score1, score2); - if (res == AutoReg::Success) { + if(res == AutoReg::Success) { // Check to make sure the newly calculated measure position is on the // surface of the planet - Camera* cam = searchCube.Camera(); + Camera *cam = searchCube.Camera(); bool foundLatLon = cam->SetImage(ar->CubeSample(), ar->CubeLine()); - if (foundLatLon) { + if(foundLatLon) { registered++; searchCM.SetType(ControlMeasure::Automatic); searchCM.SetError(searchCM.Sample() - ar->CubeSample(), searchCM.Line() - ar->CubeLine()); - searchCM.SetCoordinate(ar->CubeSample(),ar->CubeLine()); + searchCM.SetCoordinate(ar->CubeSample(), ar->CubeLine()); searchCM.SetGoodnessOfFit(ar->GoodnessOfFit()); searchCM.SetChooserName("Application pointreg"); searchCM.SetDateTime(); @@ -232,7 +234,7 @@ void IsisMain() { else { unregistered++; searchCM.SetType(ControlMeasure::Estimated); - + if(res == AutoReg::FitChipToleranceNotMet) { searchCM.SetError(inPoint[j].Sample() - ar->CubeSample(), inPoint[j].Line() - ar->CubeLine()); searchCM.SetGoodnessOfFit(ar->GoodnessOfFit()); @@ -242,8 +244,8 @@ void IsisMain() { searchCM.SetIgnore(true); outPoint.Add(searchCM); } - } - catch (iException &e) { + } + catch(iException &e) { e.Clear(); unregistered++; searchCM.SetType(ControlMeasure::Estimated); @@ -254,28 +256,28 @@ void IsisMain() { } } - // Jeff Anderson put in this test (Dec 2, 2008) to allow for control - // points to be good so long as at least two measure could be + // Jeff Anderson put in this test (Dec 2, 2008) to allow for control + // points to be good so long as at least two measure could be // registered. When a measure can't be registered to the reference then // that measure is set to be ignored where in the past the whole point // was ignored - if (goodMeasureCount < 2) { - if (!outPoint.Held() && outPoint.Type() != ControlPoint::Ground) { + if(goodMeasureCount < 2) { + if(!outPoint.Held() && outPoint.Type() != ControlPoint::Ground) { outPoint.SetIgnore(true); } } // Otherwise, ignore=false. This is already set at the beginning of the registration process // Check to see if the control point has now been assigned - // to "ignore". If not, add it to the network. If so, only + // to "ignore". If not, add it to the network. If so, only // add it to the output if the OUTPUTIGNORED parameter is selected // 2008-11-14 Jeannie Walldren - if (!outPoint.Ignore()) { + if(!outPoint.Ignore()) { outNet.Add(outPoint); } - else{ - ignored++; - if (ui.GetBoolean("OUTPUTIGNORED")) outNet.Add(outPoint); + else { + ignored++; + if(ui.GetBoolean("OUTPUTIGNORED")) outNet.Add(outPoint); } } } @@ -283,21 +285,21 @@ void IsisMain() { // If flatfile was entered, create the flatfile // The flatfile is comma seperated and can be imported into an excel // spreadsheet - if (ui.WasEntered("FLATFILE")) { + if(ui.WasEntered("FLATFILE")) { string fFile = Filename(ui.GetFilename("FLATFILE")).Expanded(); ofstream os; - os.open(fFile.c_str(),ios::out); + os.open(fFile.c_str(), ios::out); os << "PointId,OriginalMeasurementSample,OriginalMeasurementLine," << - "RegisteredMeasurementSample,RegisteredMeasurementLine,SampleDifference," << - "LineDifference,ZScoreMin,ZScoreMax,GoodnessOfFit" << endl; + "RegisteredMeasurementSample,RegisteredMeasurementLine,SampleDifference," << + "LineDifference,ZScoreMin,ZScoreMax,GoodnessOfFit" << endl; os << NULL8 << endl; - for (int i=0; iRegTemplate(); - Application::Log(autoRegTemplate); + PvlGroup autoRegTemplate = ar->RegTemplate(); + Application::Log(autoRegTemplate); outNet.Write(ui.GetFilename("TO")); diff --git a/isis/src/base/apps/poly/poly.cpp b/isis/src/base/apps/poly/poly.cpp index 3bc2e27f94..5877c29b06 100644 --- a/isis/src/base/apps/poly/poly.cpp +++ b/isis/src/base/apps/poly/poly.cpp @@ -4,10 +4,10 @@ #include "SpecialPixel.h" #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; -void poly (Buffer &in, Buffer &out); +void poly(Buffer &in, Buffer &out); double coefficients[8]; double add; @@ -15,27 +15,27 @@ int order; void IsisMain() { // We will be processing by line - ProcessByLine p; + ProcessByLine p; // Setup the input and output cubes p.SetInputCube("FROM"); - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); // Get user parameters - UserInterface &ui = Application::GetUserInterface(); - coefficients[0] = ui.GetDouble ("MULT1"); - coefficients[1] = ui.GetDouble ("MULT2"); - coefficients[2] = ui.GetDouble ("MULT3"); - coefficients[3] = ui.GetDouble ("MULT4"); - coefficients[4] = ui.GetDouble ("MULT5"); - coefficients[5] = ui.GetDouble ("MULT6"); - coefficients[6] = ui.GetDouble ("MULT7"); - coefficients[7] = ui.GetDouble ("MULT8"); - add = ui.GetDouble ("ADD"); + UserInterface &ui = Application::GetUserInterface(); + coefficients[0] = ui.GetDouble("MULT1"); + coefficients[1] = ui.GetDouble("MULT2"); + coefficients[2] = ui.GetDouble("MULT3"); + coefficients[3] = ui.GetDouble("MULT4"); + coefficients[4] = ui.GetDouble("MULT5"); + coefficients[5] = ui.GetDouble("MULT6"); + coefficients[6] = ui.GetDouble("MULT7"); + coefficients[7] = ui.GetDouble("MULT8"); + add = ui.GetDouble("ADD"); // Determine the order - for (order=7; order>=0; order--) { - if (coefficients[order] != 0.0) break; + for(order = 7; order >= 0; order--) { + if(coefficients[order] != 0.0) break; } order += 1; @@ -45,18 +45,18 @@ void IsisMain() { } // Line processing routine -void poly (Buffer &in, Buffer &out) { - // Loop for each pixel in the line. - for (int i = 0; i < in.size(); i++) { - if (IsSpecial(in[i])) { +void poly(Buffer &in, Buffer &out) { + // Loop for each pixel in the line. + for(int i = 0; i < in.size(); i++) { + if(IsSpecial(in[i])) { out[i] = in[i]; } else { out[i] = add; - for (int j = 1; j <= order; j++) { - out[i] += pow(in[i], j) * coefficients[j-1]; + for(int j = 1; j <= order; j++) { + out[i] += pow(in[i], j) * coefficients[j-1]; } } } - + } diff --git a/isis/src/base/apps/pvldiff/pvldiff.cpp b/isis/src/base/apps/pvldiff/pvldiff.cpp index 10f2a6af99..e9cf024a45 100644 --- a/isis/src/base/apps/pvldiff/pvldiff.cpp +++ b/isis/src/base/apps/pvldiff/pvldiff.cpp @@ -8,7 +8,7 @@ #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; bool filesMatch; @@ -20,8 +20,7 @@ void CompareKeywords(const PvlKeyword &pvl1, const PvlKeyword &pvl2); void CompareObjects(const PvlObject &pvl1, const PvlObject &pvl2); void CompareGroups(const PvlGroup &pvl1, const PvlGroup &pvl2); -void IsisMain () -{ +void IsisMain() { UserInterface &ui = Application::GetUserInterface(); tolerances = PvlGroup(); @@ -67,7 +66,7 @@ void IsisMain () } void CompareKeywords(const PvlKeyword &pvl1, const PvlKeyword &pvl2) { - if(pvl1.Name().compare( pvl2.Name() ) != 0) { + if(pvl1.Name().compare(pvl2.Name()) != 0) { filesMatch = false; differenceReason = "Keyword '" + pvl1.Name() + "' does not match keyword '" + pvl2.Name() + "'"; } @@ -78,20 +77,20 @@ void CompareKeywords(const PvlKeyword &pvl1, const PvlKeyword &pvl2) { return; } - if (tolerances.HasKeyword(pvl1.Name()) && - tolerances[pvl1.Name()].Size() > 1 && + if(tolerances.HasKeyword(pvl1.Name()) && + tolerances[pvl1.Name()].Size() > 1 && pvl1.Size() != tolerances[pvl1.Name()].Size()) { string msg = "Size of keyword '" + pvl1.Name() + "' does not match with "; msg += "its number of tolerances in the DIFF file."; - throw iException::Message(iException::User,msg, _FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - if (ignorekeys.HasKeyword(pvl1.Name()) && - ignorekeys[pvl1.Name()].Size() > 1 && + if(ignorekeys.HasKeyword(pvl1.Name()) && + ignorekeys[pvl1.Name()].Size() > 1 && pvl1.Size() != ignorekeys[pvl1.Name()].Size()) { string msg = "Size of keyword '" + pvl1.Name() + "' does not match with "; msg += "its number of ignore keys in the DIFF file."; - throw iException::Message(iException::User,msg, _FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } for(int i = 0; i < pvl1.Size() && filesMatch; i++) { @@ -101,55 +100,55 @@ void CompareKeywords(const PvlKeyword &pvl1, const PvlKeyword &pvl2) { iString unit2 = pvl2.Unit(i); int ignoreIndex = 0; - if (ignorekeys.HasKeyword(pvl1.Name()) && ignorekeys[pvl1.Name()].Size() > 1) { + if(ignorekeys.HasKeyword(pvl1.Name()) && ignorekeys[pvl1.Name()].Size() > 1) { ignoreIndex = i; } try { - if(!ignorekeys.HasKeyword(pvl1.Name()) || - ignorekeys[pvl1.Name()][ignoreIndex] == "false") { - - if(!unit1.Equal(unit2)) { - filesMatch = false; - differenceReason = "Keyword '" + pvl1.Name() + "': units do not match."; - return; - } - - double tolerance = 0.0; - double difference = abs((double)val1 - (double)val2); - - if(tolerances.HasKeyword(pvl1.Name())) { - tolerance = (tolerances[pvl1.Name()].Size() == 1) ? - tolerances[pvl1.Name()][0] : tolerances[pvl1.Name()][i]; - } - - if(difference > tolerance) { - filesMatch = false; - if (pvl1.Size() == 1) { - differenceReason = "Keyword '" + pvl1.Name() + "': difference is " + - iString(difference); - } - else { - differenceReason = "Keyword '" + pvl1.Name() + "' at index " + - iString(i) + ": difference is " + iString(difference); - } - differenceReason += " (tolerance is " + iString(tolerance) + ")"; - } + if(!ignorekeys.HasKeyword(pvl1.Name()) || + ignorekeys[pvl1.Name()][ignoreIndex] == "false") { + + if(!unit1.Equal(unit2)) { + filesMatch = false; + differenceReason = "Keyword '" + pvl1.Name() + "': units do not match."; + return; + } + + double tolerance = 0.0; + double difference = abs((double)val1 - (double)val2); + + if(tolerances.HasKeyword(pvl1.Name())) { + tolerance = (tolerances[pvl1.Name()].Size() == 1) ? + tolerances[pvl1.Name()][0] : tolerances[pvl1.Name()][i]; + } + + if(difference > tolerance) { + filesMatch = false; + if(pvl1.Size() == 1) { + differenceReason = "Keyword '" + pvl1.Name() + "': difference is " + + iString(difference); + } + else { + differenceReason = "Keyword '" + pvl1.Name() + "' at index " + + iString(i) + ": difference is " + iString(difference); + } + differenceReason += " (tolerance is " + iString(tolerance) + ")"; + } } } catch(iException e) { iException::Clear(); if(!val1.Equal(val2)) { - filesMatch = false; - differenceReason = "Keyword '" + pvl1.Name() + "': values do not match."; + filesMatch = false; + differenceReason = "Keyword '" + pvl1.Name() + "': values do not match."; } } } } void CompareObjects(const PvlObject &pvl1, const PvlObject &pvl2) { - if(pvl1.Name().compare( pvl2.Name() ) != 0) { + if(pvl1.Name().compare(pvl2.Name()) != 0) { filesMatch = false; differenceReason = "Object " + pvl1.Name() + " does not match " + pvl2.Name(); } diff --git a/isis/src/base/apps/ratio/ratio.cpp b/isis/src/base/apps/ratio/ratio.cpp index f6634f0012..e7caee4546 100644 --- a/isis/src/base/apps/ratio/ratio.cpp +++ b/isis/src/base/apps/ratio/ratio.cpp @@ -2,24 +2,24 @@ #include "ProcessByLine.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void ratio (vector &in, - vector &out); +void ratio(vector &in, + vector &out); void IsisMain() { ProcessByLine p; p.SetInputCube("NUMERATOR"); p.SetInputCube("DENOMINATOR"); - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); p.StartProcess(ratio); p.EndProcess(); } // Line processing routine -void ratio (vector &in, - vector &out) { +void ratio(vector &in, + vector &out) { Buffer &num = *in[0]; Buffer &den = *in[1]; Buffer &rat = *out[0]; @@ -27,15 +27,15 @@ void ratio (vector &in, // Loop for each pixel in the line. Check // for special pixels and if any are found the // output will be set to NULL. - for (int i=0; iOpen(from); ins = cube->Samples(); inl = cube->Lines(); inb = bands.size(); - if (inb == 0) { + if(inb == 0) { inb = cube->Bands(); - for (int i = 1; i<=inb; i++) { + for(int i = 1; i <= inb; i++) { bands.push_back((iString)i); } } string alg = ui.GetString("ALGORITHM"); - vper = ui.GetDouble ("VALIDPER")/100.; + vper = ui.GetDouble("VALIDPER") / 100.; - if (ui.GetString("MODE") == "TOTAL") { - ons = ui.GetInteger ("ONS"); - onl = ui.GetInteger ("ONL"); + if(ui.GetString("MODE") == "TOTAL") { + ons = ui.GetInteger("ONS"); + onl = ui.GetInteger("ONL"); sscale = (double)ins / (double)ons; lscale = (double)inl / (double)onl; } else { - sscale = ui.GetDouble ("SSCALE"); - lscale = ui.GetDouble ("LSCALE"); - ons = (int)ceil ((double)ins/sscale); - onl = (int)ceil ((double)inl/lscale); + sscale = ui.GetDouble("SSCALE"); + lscale = ui.GetDouble("LSCALE"); + ons = (int)ceil((double)ins / sscale); + onl = (int)ceil((double)inl / lscale); } - if (ons > ins || onl > inl) { + if(ons > ins || onl > inl) { string msg = "Number of output samples/lines must be less than or equal"; msg = msg + " to the input samples/lines."; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // Allocate output file Cube *ocube = NULL; try { - ocube = p.SetOutputCube ("TO",ons,onl,inb); + ocube = p.SetOutputCube("TO", ons, onl, inb); // Our processing routine only needs 1 // the original set was for info about the cube only p.ClearInputCubes(); - } catch (iException &e) { + } + catch(iException &e) { // If there is a problem, catch it and close the cube so it isn't open next time around cube->Close(); throw e; } // Create all necessary buffers - in = new LineManager (*cube); + in = new LineManager(*cube); // Start the processing line = 1.0; iline = 1; sb = 0; - if (alg == "AVERAGE") p.StartProcess(average); - if (alg == "NEAREST") p.StartProcess(nearest); + if(alg == "AVERAGE") p.StartProcess(average); + if(alg == "NEAREST") p.StartProcess(nearest); // Construct a label with the results PvlGroup results("Results"); - results += PvlKeyword ("InputLines", inl); - results += PvlKeyword ("InputSamples", ins); - results += PvlKeyword ("StartingLine", "1"); - results += PvlKeyword ("StartingSample", "1"); - results += PvlKeyword ("EndingLine", inl); - results += PvlKeyword ("EndingSample", ins); - results += PvlKeyword ("LineIncrement", lscale); - results += PvlKeyword ("SampleIncrement", sscale); - results += PvlKeyword ("OutputLines", onl); - results += PvlKeyword ("OutputSamples", ons); - + results += PvlKeyword("InputLines", inl); + results += PvlKeyword("InputSamples", ins); + results += PvlKeyword("StartingLine", "1"); + results += PvlKeyword("StartingSample", "1"); + results += PvlKeyword("EndingLine", inl); + results += PvlKeyword("EndingSample", ins); + results += PvlKeyword("LineIncrement", lscale); + results += PvlKeyword("SampleIncrement", sscale); + results += PvlKeyword("OutputLines", onl); + results += PvlKeyword("OutputSamples", ons); + // Update the Mapping, Instrument, and AlphaCube groups in the output // cube label SubArea s; - s.SetSubArea(inl,ins,1,1,inl,ins,lscale,sscale); - s.UpdateLabel(cube,ocube,results); - + s.SetSubArea(inl, ins, 1, 1, inl, ins, lscale, sscale); + s.UpdateLabel(cube, ocube, results); + // Cleanup p.EndProcess(); delete in; @@ -130,7 +131,7 @@ void IsisMain() { } // Line processing routine for averaging algorithm -void average (Buffer &out) { +void average(Buffer &out) { static double *sinctab; static double *sum; static double *npts; @@ -139,7 +140,7 @@ void average (Buffer &out) { double rline = (double)out.Line() * lscale; - if (out.Line() == 1 && out.Band() == 1) { + if(out.Line() == 1 && out.Band() == 1) { sinctab = new double[ons]; sum = new double[ons]; npts = new double[ons]; @@ -147,8 +148,8 @@ void average (Buffer &out) { npts2 = new double[ons]; // Fill sinctab and Initialize buffers for first band - for (int osamp=0; osampSetLine(iline,(iString::ToInteger(bands[sb]))); + while(iline <= rline) { + if((int)iline <= inl) { + in->SetLine(iline, (iString::ToInteger(bands[sb]))); cube->Read(*in); } int isamp = 1; - for (int osamp=0; osamp ins) continue; + if(isamp > ins) continue; - if (IsValidPixel( (*in)[isamp-1])) { + if(IsValidPixel((*in)[isamp-1])) { sum[osamp] += (*in)[isamp-1] * (1.0 - sdel); npts[osamp] += (1.0 - sdel); - if (osamp+1 < ons) { + if(osamp + 1 < ons) { sum[osamp+1] += (*in)[isamp-1] * sdel; npts[osamp+1] += sdel; } @@ -189,16 +190,16 @@ void average (Buffer &out) { iline++; } - if (iline <= inl) { - in->SetLine(iline,(iString::ToInteger(bands[sb]))); + if(iline <= inl) { + in->SetLine(iline, (iString::ToInteger(bands[sb]))); cube->Read(*in); } double ldel = (double)iline - rline; double ldel2 = 1.0 - ldel; int isamp = 1; - for (int osamp=0; osamp ins) continue; - if (IsValidPixel( (*in)[isamp-1])) { + if(isamp > ins) continue; + if(IsValidPixel((*in)[isamp-1])) { sum[osamp] += (*in)[isamp-1] * (1.0 - sdel) * ldel2; npts[osamp] += (1.0 - sdel) * ldel2; - if (osamp+1 < ons) { + if(osamp + 1 < ons) { sum[osamp+1] += (*in)[isamp-1] * sdel * ldel2; npts[osamp+1] += sdel * ldel2; } sum2[osamp] += (*in)[isamp-1] * (1.0 - sdel) * ldel; npts2[osamp] += (1.0 - sdel) * ldel; - if (osamp+1 < ons) { + if(osamp + 1 < ons) { sum2[osamp+1] += (*in)[isamp-1] * sdel * ldel; npts2[osamp+1] += sdel * ldel; } @@ -226,17 +227,18 @@ void average (Buffer &out) { isamp++; } - if (iline < inl) iline++; + if(iline < inl) iline++; double npix = sscale * lscale; - for (int osamp=0; osamp npix * vper ) { + for(int osamp = 0; osamp < ons; osamp++) { + if(npts[osamp] > npix * vper) { out[osamp] = sum[osamp] / npts[osamp]; } else { if(replaceMode == "NEAREST") { - out[osamp] = (*in)[(int)(sinctab[osamp]+0.5) - 1]; - }else{ + out[osamp] = (*in)[(int)(sinctab[osamp] + 0.5) - 1]; + } + else { out[osamp] = Isis::Null; } } @@ -246,10 +248,10 @@ void average (Buffer &out) { npts2[osamp] = 0.0; } - if (out.Line() == onl && out.Band() != inb) { + if(out.Line() == onl && out.Band() != inb) { sb++; iline = 1; - for (int osamp=0; osampSetLine(readLine,(iString::ToInteger(bands[sb]))); + in->SetLine(readLine, (iString::ToInteger(bands[sb]))); cube->Read(*in); // Scale down buffer - for (int osamp=0; osampFindGroup("RESEAUS",Pvl::Traverse); + PvlGroup &res = cube.Label()->FindGroup("RESEAUS", Pvl::Traverse); // Get reseau line, sample, type, and valid Keywords PvlKeyword lines = res.FindKeyword("LINE"); @@ -71,26 +71,26 @@ void IsisMain() { PvlKeyword valid = res.FindKeyword("VALID"); int numres = lines.Size(); - Brick brick(sdim,ldim,1,cube.PixelType()); - for (int res=0; res (2*sdev)) array[s][l] = avg; + if(diff > (2 * sdev)) array[s][l] = avg; } // Walk bottom edge & replace data outside of 2devs with the avg - for (int s = 0; s < sdim; s++) { - int l = ldim-1; + for(int s = 0; s < sdim; s++) { + int l = ldim - 1; double diff = fabs(array[s][l] - avg); - if (diff > (2*sdev)) array[s][l] = avg; + if(diff > (2 * sdev)) array[s][l] = avg; } // Walk left edge & replace data outside of 2devs with the avg - for (int l = 0; l < ldim; l++) { + for(int l = 0; l < ldim; l++) { int s = 0; double diff = fabs(array[s][l] - avg); - if (diff > (2*sdev)) array[s][l] = avg; + if(diff > (2 * sdev)) array[s][l] = avg; } // Walk right edge & replace data outside of 2devs with the avg - for (int l = 0; l < ldim; l++) { - int s = sdim-1; + for(int l = 0; l < ldim; l++) { + int s = sdim - 1; double diff = fabs(array[s][l] - avg); - if (diff > (2*sdev)) array[s][l] = avg; - } + if(diff > (2 * sdev)) array[s][l] = avg; + } srand(0); double dn, gdn1, gdn2; - for (int l = 0; l < ldim; l++) { + for(int l = 0; l < ldim; l++) { int c = l * sdim; //count // Top Edge Reseau - if ((int)type[res] == 2 && l < (ldim / 2)) continue; + if((int)type[res] == 2 && l < (ldim / 2)) continue; // Bottom Edge Reseau - if ((int)type[res] == 8 && l > (ldim / 2 + 1)) continue; - for (int s = 0; s < sdim; s++, c++) { + if((int)type[res] == 8 && l > (ldim / 2 + 1)) continue; + for(int s = 0; s < sdim; s++, c++) { // Left Edge Reseau - if ((int)type[res] == 4 && s < (sdim / 2)) continue; + if((int)type[res] == 4 && s < (sdim / 2)) continue; // Right Edge Reseau - if ((int)type[res] == 6 && s > (sdim / 2 + 1)) continue; + if((int)type[res] == 6 && s > (sdim / 2 + 1)) continue; double sum = 0.0; int gline1 = 0; int gline2 = ldim - 1; gdn1 = array[s][gline1]; - gdn2 = array[s][gline2]; + gdn2 = array[s][gline2]; // Linear Interpolation to get pixel value dn = gdn2 + (l - gline2) * (gdn1 - gdn2) / (gline1 - gline2); - sum += dn; + sum += dn; int gsamp1 = 0; int gsamp2 = sdim - 1; @@ -189,8 +189,8 @@ void IsisMain() { int rdm = rand(); double drandom = rdm / (double)RAND_MAX; double offset = 0.0; - if (drandom < .333) offset = -1.0; - if (drandom > .666) offset = 1.0; + if(drandom < .333) offset = -1.0; + if(drandom > .666) offset = 1.0; brick[c] = dn + offset; } } @@ -204,7 +204,7 @@ void IsisMain() { // Copy the input cube to the output cube void cpy(Buffer &in, Buffer &out) { - for (int i=0; i &in, +void convert(vector &in, vector &out); Stretch redStretch, greenStretch, blueStretch; void IsisMain() { - // Open input cubes - ProcessByLine p; - Cube* redCube = p.SetInputCube("RED", Isis::OneBand); - Cube* greenCube = p.SetInputCube("GREEN", Isis::OneBand); - Cube* blueCube = p.SetInputCube("BLUE", Isis::OneBand); + // Open input cubes + ProcessByLine p; + Cube *redCube = p.SetInputCube("RED", Isis::OneBand); + Cube *greenCube = p.SetInputCube("GREEN", Isis::OneBand); + Cube *blueCube = p.SetInputCube("BLUE", Isis::OneBand); // Clear out stretch pairs for multiple runs redStretch.ClearPairs(); greenStretch.ClearPairs(); blueStretch.ClearPairs(); - // Get information from the GUI to build stretch pairs. + // Get information from the GUI to build stretch pairs. // "Automatic" uses histogram percentages for uses in the stretch pairs - // "Manual" uses pixels values to build the stretch pairs + // "Manual" uses pixels values to build the stretch pairs double rMin, rMax, gMin, gMax, bMin, bMax; UserInterface &ui = Application::GetUserInterface(); // Automatic is selected - if (ui.GetString("MODE") == "AUTOMATIC") { - Histogram* redHist = redCube->Histogram(); - Histogram* greenHist = greenCube->Histogram(); - Histogram* blueHist = blueCube->Histogram(); + if(ui.GetString("MODE") == "AUTOMATIC") { + Histogram *redHist = redCube->Histogram(); + Histogram *greenHist = greenCube->Histogram(); + Histogram *blueHist = blueCube->Histogram(); rMin = redHist->Percent(ui.GetDouble("RMINPER")); rMax = redHist->Percent(ui.GetDouble("RMAXPER")); @@ -44,8 +44,9 @@ void IsisMain() { gMax = greenHist->Percent(ui.GetDouble("GMAXPER")); bMin = blueHist->Percent(ui.GetDouble("BMINPER")); bMax = blueHist->Percent(ui.GetDouble("BMAXPER")); - // Manual is selected - } else { + // Manual is selected + } + else { rMin = ui.GetDouble("RMIN"); rMax = ui.GetDouble("RMAX"); gMin = ui.GetDouble("GMIN"); @@ -64,38 +65,38 @@ void IsisMain() { greenStretch.AddPair(gMax, 1.0); blueStretch.AddPair(bMax, 1.0); - // Handle special pixels + // Handle special pixels redStretch.SetNull(0.0); redStretch.SetLis(0.0); - redStretch.SetLrs(0.0); + redStretch.SetLrs(0.0); redStretch.SetHrs(1.0); redStretch.SetHis(1.0); greenStretch.SetNull(0.0); greenStretch.SetLis(0.0); - greenStretch.SetLrs(0.0); + greenStretch.SetLrs(0.0); greenStretch.SetHrs(1.0); greenStretch.SetHis(1.0); blueStretch.SetNull(0.0); blueStretch.SetLis(0.0); - blueStretch.SetLrs(0.0); + blueStretch.SetLrs(0.0); blueStretch.SetHrs(1.0); blueStretch.SetHis(1.0); // Start the processing - p.SetOutputCube ("HUE"); - p.SetOutputCube ("SATURATION"); - p.SetOutputCube ("VALUE"); + p.SetOutputCube("HUE"); + p.SetOutputCube("SATURATION"); + p.SetOutputCube("VALUE"); p.StartProcess(convert); p.EndProcess(); -} +} -// Line processing routine +// Line processing routine // This works by creating an RGB QColor from 3 qreals representing Red, Green, // and Blue. This is converted into HSV format, and the data from this is // sent to the output buffers. -void convert (vector &in, - vector &out) { +void convert(vector &in, + vector &out) { // Input file buffers Buffer &red = *in[0]; @@ -107,24 +108,24 @@ void convert (vector &in, Buffer &saturation = *out[1]; Buffer &value = *out[2]; - for (int i = 0; i < red.size(); i++) { + for(int i = 0; i < red.size(); i++) { qreal r = redStretch.Map(red[i]); qreal g = greenStretch.Map(green[i]); qreal b = blueStretch.Map(blue[i]); QColor rgb; rgb.setRgbF(r, g, b); - QColor hsv = rgb.toHsv(); + QColor hsv = rgb.toHsv(); /** * HSV Stores colors in terms of hue, saturation, and value. The hue determines the color, - * which is an angle around the color wheel. However, hsv.hueF() in the qt library returns a - * percentage around the color wheel and not an angle. For example, 0% means the origin and - * 50% means 180 degrees around the circle. We want the hue to be in degrees, so to convert - * this percentage we multiple by 360 degrees. The basic colors are: 0 degrees = RED, - * 60 degrees = YELLOW, 120 degrees = GREEN, 180 degrees = CYAN, 240 degrees = BLUE and - * 300 degrees = PURPLE. - * The saturation is how much grey is in the color (intensity of the color). A saturation value of zero means it's perfect, + * which is an angle around the color wheel. However, hsv.hueF() in the qt library returns a + * percentage around the color wheel and not an angle. For example, 0% means the origin and + * 50% means 180 degrees around the circle. We want the hue to be in degrees, so to convert + * this percentage we multiple by 360 degrees. The basic colors are: 0 degrees = RED, + * 60 degrees = YELLOW, 120 degrees = GREEN, 180 degrees = CYAN, 240 degrees = BLUE and + * 300 degrees = PURPLE. + * The saturation is how much grey is in the color (intensity of the color). A saturation value of zero means it's perfect, * while a saturation value of 1 would cause any color to become pure grey. As an example, the color RGB(255,0,0) * is pure so the saturation would be zero. The value is how bright the color is. A value of 0 is always black, * and 100 is the color (if not saturated). @@ -132,7 +133,7 @@ void convert (vector &in, * HUE = COLOR (degrees around the color wheel) * SATURATION = INTENSITY (0-1, 0 being no color/grey) * VALUE = BRIGHTNESS (0 being black) - * + * * For more information, see * http://en.wikipedia.org/wiki/Color_spaces */ @@ -140,4 +141,4 @@ void convert (vector &in, saturation[i] = hsv.saturationF(); value[i] = hsv.valueF(); } -} +} diff --git a/isis/src/base/apps/rotate/rotate.cpp b/isis/src/base/apps/rotate/rotate.cpp index 40efcdba27..556efdff60 100644 --- a/isis/src/base/apps/rotate/rotate.cpp +++ b/isis/src/base/apps/rotate/rotate.cpp @@ -3,42 +3,42 @@ #include "rotate.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { ProcessRubberSheet p; // Open the input cube - Cube *icube = p.SetInputCube ("FROM"); + Cube *icube = p.SetInputCube("FROM"); // Set up the transform object UserInterface &ui = Application::GetUserInterface(); Transform *transform = new Rotate(icube->Samples(), icube->Lines(), - ui.GetDouble("DEGREES")); + ui.GetDouble("DEGREES")); // Determine the output size int samples = transform->OutputSamples(); int lines = transform->OutputLines(); // Allocate the output file - p.SetOutputCube ("TO", samples, lines, icube->Bands()); + p.SetOutputCube("TO", samples, lines, icube->Bands()); // Set up the interpolator Interpolator *interp; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } else { string msg = "Unknow value for INTERP [" + ui.GetString("INTERP") + "]"; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } p.StartProcess(*transform, *interp); diff --git a/isis/src/base/apps/rotate/rotate.h b/isis/src/base/apps/rotate/rotate.h index aee19f28b3..8fd226f9af 100644 --- a/isis/src/base/apps/rotate/rotate.h +++ b/isis/src/base/apps/rotate/rotate.h @@ -21,87 +21,87 @@ class Rotate : public Isis::Transform { public: // constructor - Rotate (const double inputSamples, const double inputLines, - const double rotation) { + Rotate(const double inputSamples, const double inputLines, + const double rotation) { // Angles for SIN & COS are measured positive counter-clockwise // but the program is assuming positive clockwise, so use the negative angle - + // Setup private data for calculating where a pixel in the output comes from - double PI = acos (-1.0); - + double PI = acos(-1.0); + p_degrees = -rotation; p_radians = p_degrees * PI / 180.0; - - p_cosRad = cos (p_radians); - p_sinRad = sin (p_radians); - + + p_cosRad = cos(p_radians); + p_sinRad = sin(p_radians); + // Rotate the corners of the input to find the output size double samples[4]; double lines[4]; - + // Rotate (1,1) = (0.5,0.5) samples[0] = 0.5 * p_sinRad + 0.5 * p_cosRad; lines[0] = 0.5 * p_cosRad - 0.5 * p_sinRad; // Rotate (ns,1) = (ns+0.5, .5) - samples[1] = 0.5 * p_sinRad + (inputSamples+0.5) * p_cosRad; - lines[1] = 0.5 * p_cosRad - (inputSamples+0.5) * p_sinRad; + samples[1] = 0.5 * p_sinRad + (inputSamples + 0.5) * p_cosRad; + lines[1] = 0.5 * p_cosRad - (inputSamples + 0.5) * p_sinRad; // Rotate (1,nl) = (.5, nl+0.5) - samples[2] = (inputLines+0.5) * p_sinRad + 0.5 * p_cosRad; - lines[2] = (inputLines+0.5) * p_cosRad - 0.5 * p_sinRad; + samples[2] = (inputLines + 0.5) * p_sinRad + 0.5 * p_cosRad; + lines[2] = (inputLines + 0.5) * p_cosRad - 0.5 * p_sinRad; // Rotate (ns,nl) = (ns+0.5, nl+0.5) - samples[3] = (inputLines+0.5) * p_sinRad + (inputSamples+0.5) * p_cosRad; - lines[3] = (inputLines+0.5) * p_cosRad - (inputSamples+0.5) * p_sinRad; - + samples[3] = (inputLines + 0.5) * p_sinRad + (inputSamples + 0.5) * p_cosRad; + lines[3] = (inputLines + 0.5) * p_cosRad - (inputSamples + 0.5) * p_sinRad; + // Find the min and max samp and line p_minSamp = samples[0]; - for (int i=1; i<=3; i++) if (samples[i] < p_minSamp) p_minSamp = samples[i]; + for(int i = 1; i <= 3; i++) if(samples[i] < p_minSamp) p_minSamp = samples[i]; p_maxSamp = samples[0]; - for (int i=1; i<=3; i++) if (samples[i] > p_maxSamp) p_maxSamp = samples[i]; + for(int i = 1; i <= 3; i++) if(samples[i] > p_maxSamp) p_maxSamp = samples[i]; p_minLine = lines[0]; - for (int i=1; i<=3; i++) if (lines[i] < p_minLine) p_minLine = lines[i]; + for(int i = 1; i <= 3; i++) if(lines[i] < p_minLine) p_minLine = lines[i]; p_maxLine = lines[0]; - for (int i=1; i<=3; i++) if (lines[i] > p_maxLine) p_maxLine = lines[i]; - + for(int i = 1; i <= 3; i++) if(lines[i] > p_maxLine) p_maxLine = lines[i]; + // Calculate the output size. If there is a fractional pixel, round up - p_outputSamples = (int)ceil (p_maxSamp - p_minSamp); - p_outputLines = (int)ceil (p_maxLine - p_minLine); - - if ((p_degrees == 90.0) || (p_degrees == -90)) { + p_outputSamples = (int)ceil(p_maxSamp - p_minSamp); + p_outputLines = (int)ceil(p_maxLine - p_minLine); + + if((p_degrees == 90.0) || (p_degrees == -90)) { p_outputSamples = (int)inputLines; p_outputLines = (int)inputSamples; } - if ((p_degrees == 180.0) || (p_degrees == -180.0)) { + if((p_degrees == 180.0) || (p_degrees == -180.0)) { p_outputSamples = (int)inputSamples; p_outputLines = (int)inputLines; } } // destructor - ~Rotate () {}; + ~Rotate() {}; // Implementations for parent's pure virtual members // Convert the requested output samp/line to an input samp/line - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { // First calculate the rotated input position (uses equation of a line) double inRotSamp = outSample - 0.5 + p_minSamp; double inRotLine = outLine - 0.5 + p_minLine; - + // Now unrotate the position from above to get the original input position // inSample = (-inRotLine * p_sinRad) + (inRotSamp * p_cosRad); inSample = (inRotSamp * p_cosRad) - (inRotLine * p_sinRad); inLine = (inRotLine * p_cosRad) + (inRotSamp * p_sinRad); - + return true; } // Return the output number of samples - int OutputSamples () const { + int OutputSamples() const { return p_outputSamples; } // Return the output number of lines - int OutputLines () const { + int OutputLines() const { return p_outputLines; } }; diff --git a/isis/src/base/apps/seedgrid/seedgrid.cpp b/isis/src/base/apps/seedgrid/seedgrid.cpp index 78594c3256..0e98333e56 100644 --- a/isis/src/base/apps/seedgrid/seedgrid.cpp +++ b/isis/src/base/apps/seedgrid/seedgrid.cpp @@ -9,11 +9,11 @@ using namespace std; using namespace Isis; -void PrintMap (); +void PrintMap(); -map GuiHelpers(){ - map helper; - helper ["PrintMap"] = (void*) PrintMap; +map GuiHelpers() { + map helper; + helper ["PrintMap"] = (void *) PrintMap; return helper; } @@ -27,62 +27,62 @@ void IsisMain() { double equatorialRadius = 0.0; string spacing = ui.GetString("SPACING"); - if (spacing == "METER") { - Pvl userMap; + if(spacing == "METER") { + Pvl userMap; userMap.Read(ui.GetFilename("PROJECTION")); PvlGroup &mapGroup = userMap.FindGroup("Mapping", Pvl::Traverse); - + // Construct a Projection for converting between Lon/Lat and X/Y // Note: Should this be an option to include this in the program? string target; - if (ui.WasEntered("TARGET")) { + if(ui.WasEntered("TARGET")) { target = ui.GetString("TARGET"); } - else if (mapGroup.HasKeyword("TargetName")) { - target = mapGroup.FindKeyword("TargetName")[0]; - ui.PutAsString("TARGET", target); + else if(mapGroup.HasKeyword("TargetName")) { + target = mapGroup.FindKeyword("TargetName")[0]; + ui.PutAsString("TARGET", target); } else { string msg = "A target must be specified either by the [TARGET] parameter "; msg += "or included as a value for keyword [TargetName] in the projection file."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } PvlGroup radii = Projection::TargetRadii(target); - + mapGroup.AddKeyword(PvlKeyword("TargetName", target), Pvl::Replace); mapGroup.AddKeyword(PvlKeyword("EquatorialRadius", (string) radii["EquatorialRadius"])); mapGroup.AddKeyword(PvlKeyword("PolarRadius", (string) radii["PolarRadius"])); - if (!ui.WasEntered("PROJECTION")) { - mapGroup.AddKeyword(PvlKeyword("LatitudeType","Planetocentric")); - mapGroup.AddKeyword(PvlKeyword("LongitudeDirection","PositiveEast")); - mapGroup.AddKeyword(PvlKeyword("LongitudeDomain",360)); - mapGroup.AddKeyword(PvlKeyword("CenterLatitude",0)); - mapGroup.AddKeyword(PvlKeyword("CenterLongitude",0)); + if(!ui.WasEntered("PROJECTION")) { + mapGroup.AddKeyword(PvlKeyword("LatitudeType", "Planetocentric")); + mapGroup.AddKeyword(PvlKeyword("LongitudeDirection", "PositiveEast")); + mapGroup.AddKeyword(PvlKeyword("LongitudeDomain", 360)); + mapGroup.AddKeyword(PvlKeyword("CenterLatitude", 0)); + mapGroup.AddKeyword(PvlKeyword("CenterLongitude", 0)); } - - mapGroup.AddKeyword(PvlKeyword("MinimumLatitude", ui.GetDouble("MINLAT")),Pvl::Replace); - mapGroup.AddKeyword(PvlKeyword("MaximumLatitude", ui.GetDouble("MAXLAT")),Pvl::Replace); - mapGroup.AddKeyword(PvlKeyword("MinimumLongitude", ui.GetDouble("MINLON")),Pvl::Replace); - mapGroup.AddKeyword(PvlKeyword("MaximumLongitude", ui.GetDouble("MAXLON")),Pvl::Replace); - + + mapGroup.AddKeyword(PvlKeyword("MinimumLatitude", ui.GetDouble("MINLAT")), Pvl::Replace); + mapGroup.AddKeyword(PvlKeyword("MaximumLatitude", ui.GetDouble("MAXLAT")), Pvl::Replace); + mapGroup.AddKeyword(PvlKeyword("MinimumLongitude", ui.GetDouble("MINLON")), Pvl::Replace); + mapGroup.AddKeyword(PvlKeyword("MaximumLongitude", ui.GetDouble("MAXLON")), Pvl::Replace); + Projection *proj = Isis::ProjectionFactory::Create(userMap); - + // Convert the Lat/Lon range to an X/Y range. double minX; double minY; double maxX; double maxY; bool foundRange = proj->XYRange(minX, maxX, minY, maxY); - if (!foundRange) { + if(!foundRange) { string msg = "Cannot convert Lat/Long range to an X/Y range."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Create the control net to store the points in. - cnet.SetType (ControlNet::ImageToGround); - cnet.SetTarget (target); + cnet.SetType(ControlNet::ImageToGround); + cnet.SetTarget(target); string networkId = ui.GetString("NETWORKID"); cnet.SetNetworkId(networkId); cnet.SetUserName(Isis::Application::UserName()); @@ -100,33 +100,33 @@ void IsisMain() { int maxSteps = 0; double x = minX; - while (x <= maxX) { + while(x <= maxX) { double y = minY; - while (y <= maxY) { + while(y <= maxY) { maxSteps++; y += yStepSize; } x += xStepSize; } - if (maxSteps > 0) { + if(maxSteps > 0) { gridStatus.SetMaximumSteps(maxSteps); gridStatus.SetText("Seeding Grid"); gridStatus.CheckStatus(); } x = minX; - while (x <= maxX) { + while(x <= maxX) { double y = minY; - while (y <= maxY) { - proj->SetCoordinate(x,y); - if (!proj->IsSky() && proj->Latitude() < ui.GetDouble("MAXLAT") && + while(y <= maxY) { + proj->SetCoordinate(x, y); + if(!proj->IsSky() && proj->Latitude() < ui.GetDouble("MAXLAT") && proj->Longitude() < ui.GetDouble("MAXLON") && proj->Latitude() > ui.GetDouble("MINLAT") && proj->Longitude() > ui.GetDouble("MINLON")) { ControlPoint control; - control.SetId (pointId.Next()); - control.SetIgnore (true); + control.SetId(pointId.Next()); + control.SetIgnore(true); control.SetUniversalGround(proj->Latitude(), proj->Longitude(), equatorialRadius); cnet.Add(control); } @@ -137,11 +137,11 @@ void IsisMain() { } } else { - - if (!ui.WasEntered("TARGET")) { + + if(!ui.WasEntered("TARGET")) { string msg = "A target must be specified by the [TARGET] parameter "; msg += "or included as a value for keyword [TargetName] in the projection file."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } string target = ui.GetString("TARGET"); @@ -149,8 +149,8 @@ void IsisMain() { equatorialRadius = radii["EquatorialRadius"]; // Create the control net to store the points in. - cnet.SetType (ControlNet::ImageToGround); - cnet.SetTarget (target); + cnet.SetType(ControlNet::ImageToGround); + cnet.SetTarget(target); string networkId = ui.GetString("NETWORKID"); cnet.SetNetworkId(networkId); cnet.SetUserName(Isis::Application::UserName()); @@ -162,7 +162,7 @@ void IsisMain() { double minLat = ui.GetDouble("MINLAT"); double maxLat = ui.GetDouble("MAXLAT"); double latStep = ui.GetDouble("LATSTEP"); - + double minLon = ui.GetDouble("MINLON"); double maxLon = ui.GetDouble("MAXLON"); double lonStep = ui.GetDouble("LONSTEP"); @@ -171,9 +171,9 @@ void IsisMain() { int maxSteps = 0; double lon = minLon; - while (lon <= maxLon) { + while(lon <= maxLon) { double lat = minLat; - while (lat <= maxLat) { + while(lat <= maxLat) { maxSteps++; lat += latStep; } @@ -181,22 +181,22 @@ void IsisMain() { lon += lonStep; } - if (maxSteps > 0) { + if(maxSteps > 0) { gridStatus.SetMaximumSteps(maxSteps); gridStatus.SetText("Seeding Grid"); gridStatus.CheckStatus(); } - + lon = minLon; - while (lon <= maxLon) { + while(lon <= maxLon) { double lat = minLat; - while (lat <= maxLat) { + while(lat <= maxLat) { ControlPoint control; - control.SetId (pointId.Next()); - control.SetIgnore (true); + control.SetId(pointId.Next()); + control.SetIgnore(true); control.SetUniversalGround(lat, lon, equatorialRadius); cnet.Add(control); - + lat += latStep; gridStatus.CheckStatus(); } @@ -204,7 +204,7 @@ void IsisMain() { } } - PvlGroup results ("Results"); + PvlGroup results("Results"); results += PvlKeyword("EquatorialRadius", equatorialRadius); results += PvlKeyword("NumberControlPoints", cnet.Size()); Application::Log(results); @@ -219,7 +219,7 @@ void PrintMap() { // Get mapping group from map file Pvl userMap; userMap.Read(ui.GetFilename("PROJECTION")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); //Write map file out to the log Isis::Application::GuiLog(userGrp); diff --git a/isis/src/base/apps/segment/segment.cpp b/isis/src/base/apps/segment/segment.cpp index 968b18e5af..c9e788a98c 100644 --- a/isis/src/base/apps/segment/segment.cpp +++ b/isis/src/base/apps/segment/segment.cpp @@ -2,7 +2,7 @@ #include "Application.h" #include "Cube.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { @@ -14,34 +14,34 @@ void IsisMain() { int lineOverlap = ui.GetInteger("OVERLAP"); //Throws exception if user is dumb - if ( lineOverlap >= numberOfLines ) { - throw iException::Message( iException::User, "The Line Overlap (OVERLAP) must be less than the Number of Lines (LN).", _FILEINFO_ ); + if(lineOverlap >= numberOfLines) { + throw iException::Message(iException::User, "The Line Overlap (OVERLAP) must be less than the Number of Lines (LN).", _FILEINFO_); } //Opens the cube Cube cube; - cube.Open( inFile.Expanded() ); + cube.Open(inFile.Expanded()); //Loops through, cropping as desired int cropNum = 1; int startLine = 1; bool hasReachedEndOfCube = false; - while ( startLine <= cube.Lines() && not hasReachedEndOfCube ) { + while(startLine <= cube.Lines() && not hasReachedEndOfCube) { //! Sets up the proper paramaters for running the crop program string parameters = "FROM=" + inFile.Expanded() + - " TO=" + inFile.Path() + "/" + inFile.Basename() + ".segment" + iString(cropNum) + ".cub" - + " LINE=" + iString(startLine) + " NLINES="; + " TO=" + inFile.Path() + "/" + inFile.Basename() + ".segment" + iString(cropNum) + ".cub" + + " LINE=" + iString(startLine) + " NLINES="; - if ( startLine + numberOfLines > cube.Lines() ) { - parameters += iString( cube.Lines() - ( startLine - 1 ) ); + if(startLine + numberOfLines > cube.Lines()) { + parameters += iString(cube.Lines() - (startLine - 1)); hasReachedEndOfCube = true; } else { parameters += iString(numberOfLines); } - Isis::iApp ->Exec("crop",parameters); + Isis::iApp ->Exec("crop", parameters); //The starting line for next crop - startLine = 1 + cropNum * ( numberOfLines - lineOverlap ); + startLine = 1 + cropNum * (numberOfLines - lineOverlap); cropNum++; } } diff --git a/isis/src/base/apps/shade/shade.cpp b/isis/src/base/apps/shade/shade.cpp index c25c322aac..9b9d8db7c1 100644 --- a/isis/src/base/apps/shade/shade.cpp +++ b/isis/src/base/apps/shade/shade.cpp @@ -4,50 +4,50 @@ #include "Constants.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; double pixelResolution; double saz; double zenith; -void shade (Buffer &in, double &v); +void shade(Buffer &in, double &v); void IsisMain() { - - const double DEG2RAD = PI/180.0; + + const double DEG2RAD = PI / 180.0; ProcessByBoxcar p; UserInterface &ui = Application::GetUserInterface(); // Open the input cube - Cube *inCube = p.SetInputCube ("FROM"); + Cube *inCube = p.SetInputCube("FROM"); // Allocate the output cube - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); - p.SetBoxcarSize(3,3); + p.SetBoxcarSize(3, 3); // Read user parameters - // This parameter as used by the algorithm is 0-360 with 0 at 3 o'clock, + // This parameter as used by the algorithm is 0-360 with 0 at 3 o'clock, // increasing in the clockwise direction. The value taken in from the user is // 0-360 with 0 at 12 o'clock increasing in the clockwise direction. - saz = ui.GetDouble ("AZIMUTH"); + saz = ui.GetDouble("AZIMUTH"); saz += 270; - if (saz > 360) saz -= 360; + if(saz > 360) saz -= 360; saz *= DEG2RAD; - + // This parameter as used by the algorithm is 0-90 as the angle to the light source, - // this means 90 is at the horizon and 0 is directly overhead. - zenith = ui.GetDouble ("ZENITH"); + // this means 90 is at the horizon and 0 is directly overhead. + zenith = ui.GetDouble("ZENITH"); zenith *= DEG2RAD; // Get from labels or from user - if (ui.WasEntered("PIXELRESOL")) { - pixelResolution = ui.GetDouble ("PIXELRESOL"); + if(ui.WasEntered("PIXELRESOL")) { + pixelResolution = ui.GetDouble("PIXELRESOL"); } else { - if (inCube->Label()->FindObject("IsisCube").HasGroup("Mapping")) { + if(inCube->Label()->FindObject("IsisCube").HasGroup("Mapping")) { pixelResolution = inCube->Label()->FindObject("IsisCube").FindGroup("Mapping")["PixelResolution"]; } else { @@ -57,72 +57,73 @@ void IsisMain() { } } - p.StartProcess (shade); - p.EndProcess (); + p.StartProcess(shade); + p.EndProcess(); } // Shade processing routine -void shade (Buffer &in,double &v) { +void shade(Buffer &in, double &v) { - // first we just check to make sure that we don't have any special pixels + // first we just check to make sure that we don't have any special pixels bool specials = false; - for (int i=0; i GuiHelpers(){ - map helper; - helper ["PrintMap"] = (void*) PrintMap; - helper ["LoadMapRes"] = (void*) LoadMapRes; - helper ["LoadCameraRes"] = (void*) LoadCameraRes; - helper ["LoadMapRange"] = (void*) LoadMapRange; - helper ["LoadCameraRange"] = (void*) LoadCameraRange; +void PrintMap(); +void LoadMapRes(); +void LoadCameraRes(); +void LoadMapRange(); +void LoadCameraRange(); + +map GuiHelpers() { + map helper; + helper ["PrintMap"] = (void *) PrintMap; + helper ["LoadMapRes"] = (void *) LoadMapRes; + helper ["LoadCameraRes"] = (void *) LoadCameraRes; + helper ["LoadMapRange"] = (void *) LoadMapRange; + helper ["LoadCameraRange"] = (void *) LoadCameraRange; return helper; } @@ -39,21 +39,21 @@ class sky2map : public Transform { public: // constructor - sky2map (const int inputSamples, const int inputLines, Camera *incam, - const int outputSamples, const int outputLines, Projection *outmap, - bool trim); - + sky2map(const int inputSamples, const int inputLines, Camera *incam, + const int outputSamples, const int outputLines, Projection *outmap, + bool trim); + // destructor - ~sky2map () {}; + ~sky2map() {}; // Implementations for parent's pure virtual members - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine); - int OutputSamples () const; - int OutputLines () const; + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine); + int OutputSamples() const; + int OutputLines() const; }; -void BandChange (const int band); +void BandChange(const int band); Cube *icube; Camera *incam; @@ -65,120 +65,120 @@ void IsisMain() { UserInterface &ui = Application::GetUserInterface(); Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); // Open the input cube, get the camera object, and the cam map projection // Note: The default target info is positive west, planetocentric, 360 - icube = p.SetInputCube ("FROM"); + icube = p.SetInputCube("FROM"); incam = icube->Camera(); - // Pvl lab(ui.GetFilename("FROM")); - // PvlGroup &inst = lab.FindGroup("Instrument",Pvl::Traverse); +// Pvl lab(ui.GetFilename("FROM")); +// PvlGroup &inst = lab.FindGroup("Instrument",Pvl::Traverse); //inst["TargetName"] = "Sky"; - - // Add the default mapping info to the user entered mapping group - userGrp.AddKeyword(PvlKeyword("TargetName","Sky"),Pvl::Replace); - userGrp.AddKeyword(PvlKeyword("EquatorialRadius",1.0),Pvl::Replace); - userGrp.AddKeyword(PvlKeyword("PolarRadius",1.0),Pvl::Replace); - userGrp.AddKeyword(PvlKeyword("LatitudeType","Planetocentric"),Pvl::Replace); - userGrp.AddKeyword(PvlKeyword("LongitudeDirection","PositiveWest"),Pvl::Replace); - userGrp.AddKeyword(PvlKeyword("LongitudeDomain","360"),Pvl::Replace); - if (userGrp.HasKeyword("PixelResolution")) { + + // Add the default mapping info to the user entered mapping group + userGrp.AddKeyword(PvlKeyword("TargetName", "Sky"), Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("EquatorialRadius", 1.0), Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("PolarRadius", 1.0), Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("LatitudeType", "Planetocentric"), Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("LongitudeDirection", "PositiveWest"), Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("LongitudeDomain", "360"), Pvl::Replace); + if(userGrp.HasKeyword("PixelResolution")) { userGrp.DeleteKeyword("PixelResolution"); } - if (ui.GetString("DEFAULTRANGE") == "CAMERA") { + if(ui.GetString("DEFAULTRANGE") == "CAMERA") { // Get the default ra/dec range - double minRa,maxRa,minDec,maxDec; - incam->RaDecRange(minRa,maxRa,minDec,maxDec); - userGrp.AddKeyword(PvlKeyword("MinimumLongitude",minRa),Pvl::Replace); - userGrp.AddKeyword(PvlKeyword("MaximumLongitude",maxRa),Pvl::Replace); - userGrp.AddKeyword(PvlKeyword("MinimumLatitude",minDec),Pvl::Replace); - userGrp.AddKeyword(PvlKeyword("MaximumLatitude",maxDec),Pvl::Replace); + double minRa, maxRa, minDec, maxDec; + incam->RaDecRange(minRa, maxRa, minDec, maxDec); + userGrp.AddKeyword(PvlKeyword("MinimumLongitude", minRa), Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("MaximumLongitude", maxRa), Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("MinimumLatitude", minDec), Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("MaximumLatitude", maxDec), Pvl::Replace); } - if (ui.GetString("DEFAULTSCALE") == "CAMERA") { + if(ui.GetString("DEFAULTSCALE") == "CAMERA") { double res = incam->RaDecResolution(); - userGrp.AddKeyword(PvlKeyword("Scale",1.0/res),Pvl::Replace); + userGrp.AddKeyword(PvlKeyword("Scale", 1.0 / res), Pvl::Replace); } // Override computed range with the users request - if (ui.WasEntered("SRA")) { - userGrp.AddKeyword(PvlKeyword("MinimumLongitude",ui.GetDouble("SRA")),Pvl::Replace); + if(ui.WasEntered("SRA")) { + userGrp.AddKeyword(PvlKeyword("MinimumLongitude", ui.GetDouble("SRA")), Pvl::Replace); } - if (ui.WasEntered("ERA")) { - userGrp.AddKeyword(PvlKeyword("MaximumLongitude",ui.GetDouble("ERA")),Pvl::Replace); + if(ui.WasEntered("ERA")) { + userGrp.AddKeyword(PvlKeyword("MaximumLongitude", ui.GetDouble("ERA")), Pvl::Replace); } - if (ui.WasEntered("SDEC")){ - userGrp.AddKeyword(PvlKeyword("MinimumLatitude",ui.GetDouble("SDEC")),Pvl::Replace); + if(ui.WasEntered("SDEC")) { + userGrp.AddKeyword(PvlKeyword("MinimumLatitude", ui.GetDouble("SDEC")), Pvl::Replace); } - if (ui.WasEntered("EDEC")){ - userGrp.AddKeyword(PvlKeyword("MaximumLatitude",ui.GetDouble("EDEC")),Pvl::Replace); + if(ui.WasEntered("EDEC")) { + userGrp.AddKeyword(PvlKeyword("MaximumLatitude", ui.GetDouble("EDEC")), Pvl::Replace); } // Get the resolution from the user if they decided to enter it - if (ui.GetString("DEFAULTSCALE") == "USER") { - userGrp.AddKeyword(PvlKeyword("Scale",ui.GetDouble("SCALE")),Pvl::Replace); + if(ui.GetString("DEFAULTSCALE") == "USER") { + userGrp.AddKeyword(PvlKeyword("Scale", ui.GetDouble("SCALE")), Pvl::Replace); } - + // Create the projection - int samples,lines; - Projection *proj = ProjectionFactory::CreateForCube(userMap,samples,lines); + int samples, lines; + Projection *proj = ProjectionFactory::CreateForCube(userMap, samples, lines); // Output the mapping group used to the gui session log Application::GuiLog(userGrp); - // Create the transform object which maps + // Create the transform object which maps // output line/samp -> output lat/lon (dec/ra) -> input line/samp - Transform *xform = new sky2map (icube->Samples(),icube->Lines(),incam, - samples,lines,proj, - ui.GetBoolean("Trim")); + Transform *xform = new sky2map(icube->Samples(), icube->Lines(), incam, + samples, lines, proj, + ui.GetBoolean("Trim")); // Create the output cube and add the projection group - Cube *ocube = p.SetOutputCube("TO",xform->OutputSamples(), - xform->OutputLines(), - icube->Bands()); + Cube *ocube = p.SetOutputCube("TO", xform->OutputSamples(), + xform->OutputLines(), + icube->Bands()); ocube->PutGroup(userGrp); // Set up the interpolator Interpolator *interp = NULL; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } // If we need to deal with band dependent camera models, register // our function to handle that - if (!incam->IsBandIndependent()) { + if(!incam->IsBandIndependent()) { p.BandChange(BandChange); } // See if center of input image projects. If it does, force tile // containing this center to be processed in ProcessRubberSheet. - double centerSamp = icube->Samples () / 2.; - double centerLine = icube->Lines () / 2.; - incam->SetImage(centerSamp,centerLine); - if (proj->SetGround(incam->Declination(), - incam->RightAscension())) { - p.ForceTile (proj->WorldX(),proj->WorldY ()); + double centerSamp = icube->Samples() / 2.; + double centerLine = icube->Lines() / 2.; + incam->SetImage(centerSamp, centerLine); + if(proj->SetGround(incam->Declination(), + incam->RightAscension())) { + p.ForceTile(proj->WorldX(), proj->WorldY()); } // Create an alpha cube group for the output cube - if (!ocube->HasGroup("AlphaCube")) { + if(!ocube->HasGroup("AlphaCube")) { PvlGroup alpha("AlphaCube"); - alpha += PvlKeyword("AlphaSamples",icube->Samples()); - alpha += PvlKeyword("AlphaLines",icube->Lines()); - alpha += PvlKeyword("AlphaStartingSample",0.5); - alpha += PvlKeyword("AlphaStartingLine",0.5); - alpha += PvlKeyword("AlphaEndingSample",icube->Samples()+0.5); - alpha += PvlKeyword("AlphaEndingLine",icube->Lines()+0.5); - alpha += PvlKeyword("BetaSamples",icube->Samples()); - alpha += PvlKeyword("BetaLines",icube->Lines()); + alpha += PvlKeyword("AlphaSamples", icube->Samples()); + alpha += PvlKeyword("AlphaLines", icube->Lines()); + alpha += PvlKeyword("AlphaStartingSample", 0.5); + alpha += PvlKeyword("AlphaStartingLine", 0.5); + alpha += PvlKeyword("AlphaEndingSample", icube->Samples() + 0.5); + alpha += PvlKeyword("AlphaEndingLine", icube->Lines() + 0.5); + alpha += PvlKeyword("BetaSamples", icube->Samples()); + alpha += PvlKeyword("BetaLines", icube->Lines()); ocube->PutGroup(alpha); } @@ -187,22 +187,22 @@ void IsisMain() { p.EndProcess(); // add mapping to print.prt - PvlGroup mapping = proj->Mapping(); - Application::Log(mapping); + PvlGroup mapping = proj->Mapping(); + Application::Log(mapping); // Cleanup delete xform; delete interp; } -void BandChange (const int band) { +void BandChange(const int band) { incam->SetBand(band); } -sky2map::sky2map (const int inputSamples, const int inputLines, - Camera *incam, const int outputSamples, - const int outputLines, Projection *outmap, - bool trim) { +sky2map::sky2map(const int inputSamples, const int inputLines, + Camera *incam, const int outputSamples, + const int outputLines, Projection *outmap, + bool trim) { p_inputSamples = inputSamples; p_inputLines = inputLines; p_incam = incam; @@ -215,30 +215,30 @@ sky2map::sky2map (const int inputSamples, const int inputLines, } // Transform method mapping output line/samps to lat/lons to input line/samps -bool sky2map::Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { +bool sky2map::Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { // See if the output image coordinate converts to lat/lon - if (!p_outmap->SetWorld(outSample,outLine)) return false; + if(!p_outmap->SetWorld(outSample, outLine)) return false; // See if we should trim - if ((p_trim) && (p_outmap->HasGroundRange())) { - if (p_outmap->Latitude() < p_outmap->MinimumLatitude()) return false; - if (p_outmap->Latitude() > p_outmap->MaximumLatitude()) return false; - if (p_outmap->Longitude() < p_outmap->MinimumLongitude()) return false; - if (p_outmap->Longitude() > p_outmap->MaximumLongitude()) return false; + if((p_trim) && (p_outmap->HasGroundRange())) { + if(p_outmap->Latitude() < p_outmap->MinimumLatitude()) return false; + if(p_outmap->Latitude() > p_outmap->MaximumLatitude()) return false; + if(p_outmap->Longitude() < p_outmap->MinimumLongitude()) return false; + if(p_outmap->Longitude() > p_outmap->MaximumLongitude()) return false; } // Get the lat/lon and see if it can be converted to input line/samp double lat = p_outmap->Latitude(); double lon = p_outmap->Longitude(); - if (!p_incam->SetRightAscensionDeclination(lon,lat)) return false; + if(!p_incam->SetRightAscensionDeclination(lon, lat)) return false; // Make sure the point is inside the input image - if (p_incam->Sample() < 0.5) return false; - if (p_incam->Line() < 0.5) return false; - if (p_incam->Sample() > p_inputSamples + 0.5) return false; - if (p_incam->Line() > p_inputLines + 0.5) return false; + if(p_incam->Sample() < 0.5) return false; + if(p_incam->Line() < 0.5) return false; + if(p_incam->Sample() > p_inputSamples + 0.5) return false; + if(p_incam->Line() > p_inputLines + 0.5) return false; // Everything is good inSample = p_incam->Sample(); @@ -246,11 +246,11 @@ bool sky2map::Xform (double &inSample, double &inLine, return true; } -int sky2map::OutputSamples () const { +int sky2map::OutputSamples() const { return p_outputSamples; } -int sky2map::OutputLines () const { +int sky2map::OutputLines() const { return p_outputLines; } @@ -261,35 +261,35 @@ void PrintMap() { // Get mapping group from map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); //Write map file out to the log Isis::Application::GuiLog(userGrp); } // Helper function to get mapping resolution. -void LoadMapRes () { +void LoadMapRes() { UserInterface &ui = Application::GetUserInterface(); // Get mapping group from map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); // Set resolution - if (userGrp.HasKeyword("Scale")) { + if(userGrp.HasKeyword("Scale")) { ui.Clear("SCALE"); - ui.PutDouble("SCALE",userGrp["Scale"]); + ui.PutDouble("SCALE", userGrp["Scale"]); } else { - string msg = "Mapfile [" + ui.GetFilename("MAP") + - "] does not have [SCALE] keyword to load"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + string msg = "Mapfile [" + ui.GetFilename("MAP") + + "] does not have [SCALE] keyword to load"; + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } //Helper function to get camera resolution. -void LoadCameraRes () { +void LoadCameraRes() { UserInterface &ui = Application::GetUserInterface(); // Open the input cube, get the camera object, and the cam map projection @@ -299,7 +299,7 @@ void LoadCameraRes () { double res = cam->RaDecResolution(); ui.Clear("SCALE"); - ui.PutDouble("SCALE",1.0 / res); + ui.PutDouble("SCALE", 1.0 / res); } //Helper function to get ground range from map file. @@ -314,40 +314,40 @@ void LoadMapRange() { // Get map file Pvl userMap; userMap.Read(ui.GetFilename("MAP")); - PvlGroup &userGrp = userMap.FindGroup("Mapping",Pvl::Traverse); + PvlGroup &userGrp = userMap.FindGroup("Mapping", Pvl::Traverse); // Set ground range keywords that are found in mapfile int count = 0; - if (userGrp.HasKeyword("MinimumLongitude")) { - ui.PutDouble("SRA",userGrp["MinimumLongitude"]); + if(userGrp.HasKeyword("MinimumLongitude")) { + ui.PutDouble("SRA", userGrp["MinimumLongitude"]); count++; } - if (userGrp.HasKeyword("MaximumLongitude")) { - ui.PutDouble("ERA",userGrp["MaximumLongitude"]); + if(userGrp.HasKeyword("MaximumLongitude")) { + ui.PutDouble("ERA", userGrp["MaximumLongitude"]); count++; } - if (userGrp.HasKeyword("MinimumLatitude")) { - ui.PutDouble("SDEC",userGrp["MinimumLatitude"]); + if(userGrp.HasKeyword("MinimumLatitude")) { + ui.PutDouble("SDEC", userGrp["MinimumLatitude"]); count++; } - if (userGrp.HasKeyword("MaximumLatitude")) { - ui.PutDouble("EDEC",userGrp["MaximumLatitude"]); + if(userGrp.HasKeyword("MaximumLatitude")) { + ui.PutDouble("EDEC", userGrp["MaximumLatitude"]); count++; } // Set default ground range param to map ui.Clear("DEFAULTRANGE"); - ui.PutAsString("DEFAULTRANGE","MAP"); + ui.PutAsString("DEFAULTRANGE", "MAP"); - if (count < 4) { + if(count < 4) { string msg = "One or more of the values for the sky range was not found"; msg += " in [" + ui.GetFilename("MAP") + "]"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } } //Helper function to load camera range. -void LoadCameraRange () { +void LoadCameraRange() { UserInterface &ui = Application::GetUserInterface(); // Open the input cube, get the camera object, and the cam map projection @@ -356,22 +356,22 @@ void LoadCameraRange () { Camera *cam = c.Camera(); // Make the target info match the user mapfile - double minra,maxra,mindec,maxdec; - cam->RaDecRange(minra,maxra,mindec,maxdec); + double minra, maxra, mindec, maxdec; + cam->RaDecRange(minra, maxra, mindec, maxdec); // Set ground range parameters in UI ui.Clear("SRA"); - ui.PutDouble("SRA",minra); + ui.PutDouble("SRA", minra); ui.Clear("ERA"); - ui.PutDouble("ERA",maxra); + ui.PutDouble("ERA", maxra); ui.Clear("SDEC"); - ui.PutDouble("SDEC",mindec); + ui.PutDouble("SDEC", mindec); ui.Clear("EDEC"); - ui.PutDouble("EDEC",maxdec); + ui.PutDouble("EDEC", maxdec); // Set default ground range param to camera ui.Clear("DEFAULTRANGE"); - ui.PutAsString("DEFAULTRANGE","CAMERA"); + ui.PutAsString("DEFAULTRANGE", "CAMERA"); } diff --git a/isis/src/base/apps/skypt/skypt.cpp b/isis/src/base/apps/skypt/skypt.cpp index f7a3e08b58..a90db008e1 100644 --- a/isis/src/base/apps/skypt/skypt.cpp +++ b/isis/src/base/apps/skypt/skypt.cpp @@ -10,7 +10,7 @@ void IsisMain() { // Get user interface UserInterface &ui = Application::GetUserInterface(); - // Get input cube and get camera model for it + // Get input cube and get camera model for it string channel = ui.GetFilename("FROM"); Cube cube; cube.Open(channel); @@ -18,61 +18,61 @@ void IsisMain() { // Get the type of conversion that we are doing string type = ui.GetString("TYPE"); - double samp,line; + double samp, line; // Do conversion from samp/line to ra/dec - if (type == "IMAGE") { + if(type == "IMAGE") { // Get users sample & line values and do a setImage for the camera samp = ui.GetDouble("SAMPLE"); line = ui.GetDouble("LINE"); - cam->SetImage(samp,line); + cam->SetImage(samp, line); } // Do conversion from ra/dec to samp/line else { double ra = ui.GetDouble("RA"); double dec = ui.GetDouble("DEC"); - if (!cam->SetRightAscensionDeclination(ra,dec)) { + if(!cam->SetRightAscensionDeclination(ra, dec)) { string msg = "Invalid Ra/Dec coordinate"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } samp = cam->Sample(); line = cam->Line(); } // Create Brick on samp, line to get the dn value of the pixel - Brick b(3,3,1,cube.PixelType()); - int intSamp = (int)(samp+0.5); - int intLine = (int)(line+0.5); - b.SetBasePosition(intSamp,intLine,1); + Brick b(3, 3, 1, cube.PixelType()); + int intSamp = (int)(samp + 0.5); + int intLine = (int)(line + 0.5); + b.SetBasePosition(intSamp, intLine, 1); cube.Read(b); // Create group with sky position - PvlGroup sp("SkyPoint"); + PvlGroup sp("SkyPoint"); { - sp += PvlKeyword("Filename",Filename(channel).Expanded()); - sp += PvlKeyword("Sample",cam->Sample()); - sp += PvlKeyword("Line",cam->Line()); - sp += PvlKeyword("RightAscension",cam->RightAscension()); - sp += PvlKeyword("Declination",cam->Declination()); - sp += PvlKeyword("EphemerisTime",cam->EphemerisTime()); - sp += PvlKeyword("PixelValue",PixelToString(b[0])); + sp += PvlKeyword("Filename", Filename(channel).Expanded()); + sp += PvlKeyword("Sample", cam->Sample()); + sp += PvlKeyword("Line", cam->Line()); + sp += PvlKeyword("RightAscension", cam->RightAscension()); + sp += PvlKeyword("Declination", cam->Declination()); + sp += PvlKeyword("EphemerisTime", cam->EphemerisTime()); + sp += PvlKeyword("PixelValue", PixelToString(b[0])); } //Write the group to the screen Application::Log(sp); - + // Write an output label file if necessary - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { // Get user params from ui string outFile = Filename(ui.GetFilename("TO")).Expanded(); bool exists = Filename(outFile).Exists(); bool append = ui.GetBoolean("APPEND"); // Write the pvl group out to the file - if (ui.GetString("FORMAT") == "PVL") { + if(ui.GetString("FORMAT") == "PVL") { Pvl temp; temp.SetTerminator(""); temp.AddGroup(sp); - if (append) { + if(append) { temp.Append(ui.GetAsString("TO")); } else { @@ -84,32 +84,32 @@ void IsisMain() { else { ofstream os; bool writeHeader = false; - if (append) { - os.open(outFile.c_str(),ios::app); - if (!exists) { + if(append) { + os.open(outFile.c_str(), ios::app); + if(!exists) { writeHeader = true; } } else { - os.open(outFile.c_str(),ios::out); + os.open(outFile.c_str(), ios::out); writeHeader = true; } - + if(writeHeader) { for(int i = 0; i < sp.Keywords(); i++) { os << sp[i].Name(); - if(i < sp.Keywords()-1) { + if(i < sp.Keywords() - 1) { os << ","; } } os << endl; } - + for(int i = 0; i < sp.Keywords(); i++) { os << (string)sp[i]; - if(i < sp.Keywords()-1) { + if(i < sp.Keywords() - 1) { os << ","; } } diff --git a/isis/src/base/apps/skyrange/skyrange.cpp b/isis/src/base/apps/skyrange/skyrange.cpp index b127e8c0f8..a74607b934 100644 --- a/isis/src/base/apps/skyrange/skyrange.cpp +++ b/isis/src/base/apps/skyrange/skyrange.cpp @@ -13,53 +13,53 @@ void IsisMain() { Camera *cam = icube->Camera(); // Get the ra/dec range and resolution - double minRa,maxRa,minDec,maxDec; - cam->RaDecRange(minRa,maxRa,minDec,maxDec); + double minRa, maxRa, minDec, maxDec; + cam->RaDecRange(minRa, maxRa, minDec, maxDec); double res = cam->RaDecResolution(); // Get the center ra/dec - cam->SetImage(icube->Samples()/2.0,icube->Lines()/2.0); + cam->SetImage(icube->Samples() / 2.0, icube->Lines() / 2.0); double centerRa = cam->RightAscension(); double centerDec = cam->Declination(); // Compute the rotation - cam->SetRightAscensionDeclination(centerRa,centerDec+2.0*res); - double x = cam->Sample() - icube->Samples()/2.0; - double y = cam->Line() - icube->Lines()/2.0; - double rot = atan2(-y,x) * 180.0 / Isis::PI; + cam->SetRightAscensionDeclination(centerRa, centerDec + 2.0 * res); + double x = cam->Sample() - icube->Samples() / 2.0; + double y = cam->Line() - icube->Lines() / 2.0; + double rot = atan2(-y, x) * 180.0 / Isis::PI; rot = 90.0 - rot; - if (rot < 0.0) rot += 360.0; + if(rot < 0.0) rot += 360.0; // Setup and log results PvlGroup results("Range"); - results += PvlKeyword("MinimumRightAscension",minRa,"degrees"); - results += PvlKeyword("MaximumRightAscension",maxRa,"degrees"); - results += PvlKeyword("MinimumDeclination",minDec,"degrees"); - results += PvlKeyword("MaximumDeclination",maxDec,"degrees"); - results += PvlKeyword("MinimumRightAscension",Projection::ToHMS(minRa),"hms"); - results += PvlKeyword("MaximumRightAscension",Projection::ToHMS(maxRa),"hms"); - results += PvlKeyword("MinimumDeclination",Projection::ToDMS(minDec),"dms"); - results += PvlKeyword("MaximumDeclination",Projection::ToDMS(maxDec),"dms"); - results += PvlKeyword("Resolution",res,"degrees/pixel"); + results += PvlKeyword("MinimumRightAscension", minRa, "degrees"); + results += PvlKeyword("MaximumRightAscension", maxRa, "degrees"); + results += PvlKeyword("MinimumDeclination", minDec, "degrees"); + results += PvlKeyword("MaximumDeclination", maxDec, "degrees"); + results += PvlKeyword("MinimumRightAscension", Projection::ToHMS(minRa), "hms"); + results += PvlKeyword("MaximumRightAscension", Projection::ToHMS(maxRa), "hms"); + results += PvlKeyword("MinimumDeclination", Projection::ToDMS(minDec), "dms"); + results += PvlKeyword("MaximumDeclination", Projection::ToDMS(maxDec), "dms"); + results += PvlKeyword("Resolution", res, "degrees/pixel"); Application::Log(results); // Setup and log orientation PvlGroup orient("Orientation"); - orient += PvlKeyword("CenterSample",icube->Samples()/2.0); - orient += PvlKeyword("CenterLine",icube->Lines()/2.0); - orient += PvlKeyword("CenterRightAscension",centerRa,"degrees"); - orient += PvlKeyword("CenterDeclination",centerDec,"degrees"); - orient += PvlKeyword("CelestialNorthClockAngle",rot,"degrees"); - orient += PvlKeyword("Resolution",res,"degrees/pixel"); + orient += PvlKeyword("CenterSample", icube->Samples() / 2.0); + orient += PvlKeyword("CenterLine", icube->Lines() / 2.0); + orient += PvlKeyword("CenterRightAscension", centerRa, "degrees"); + orient += PvlKeyword("CenterDeclination", centerDec, "degrees"); + orient += PvlKeyword("CelestialNorthClockAngle", rot, "degrees"); + orient += PvlKeyword("Resolution", res, "degrees/pixel"); Application::Log(orient); // Write the output file if requested UserInterface ui = Application::GetUserInterface(); - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { Pvl temp; temp.AddGroup(results); temp.AddGroup(orient); - temp.Write(ui.GetFilename("TO","txt")); + temp.Write(ui.GetFilename("TO", "txt")); } p.EndProcess(); diff --git a/isis/src/base/apps/slither/ControlByRow.h b/isis/src/base/apps/slither/ControlByRow.h index edbc1ece69..a5c229054e 100644 --- a/isis/src/base/apps/slither/ControlByRow.h +++ b/isis/src/base/apps/slither/ControlByRow.h @@ -1,27 +1,27 @@ #ifndef ControlByRow_h #define ControlByRow_h -/** - * @file - * $Revision: 1.2 $ - * $Date: 2007/01/30 22:12:21 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.2 $ + * $Date: 2007/01/30 22:12:21 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include #include "ControlMeasure.h" @@ -32,265 +32,272 @@ namespace Isis { -/** - * @brief Container for point collection - */ -struct PointData { - ControlMeasure refPoint; - ControlMeasure chpPoint; -}; + /** + * @brief Container for point collection + */ + struct PointData { + ControlMeasure refPoint; + ControlMeasure chpPoint; + }; -/** - * @brief Less than test for Control point group - * - * This function tests the reference line numbers and returns true if the first - * point reference line is less than the second. - * - * @param p1 First PointData set to compare - * @param p2 Second PointData set to compare - * - * @return bool If first point reference line is less than the second - */ -inline bool PointLess(const PointData &p1, const PointData &p2) { - return (p1.refPoint.Line() < p2.refPoint.Line()); -} + /** + * @brief Less than test for Control point group + * + * This function tests the reference line numbers and returns true if the first + * point reference line is less than the second. + * + * @param p1 First PointData set to compare + * @param p2 Second PointData set to compare + * + * @return bool If first point reference line is less than the second + */ + inline bool PointLess(const PointData &p1, const PointData &p2) { + return (p1.refPoint.Line() < p2.refPoint.Line()); + } -/** - * @brief Equality test for Control point group - * - * This function tests the reference line numbers for equality and returns true - * if the line references are equivalent, according to an approximation using an - * epsilon of 1.0e-6. - * - * @param p1 First PointData set to compare - * @param p2 Second PointData set to compare - * - * @return bool If the reference point lines are (approximately) equivalent - */ -inline bool PointEqual(const PointData &p1, const PointData &p2) { - return (gsl_fcmp(p1.refPoint.Line(), p2.refPoint.Line(), 1.0E-6) == 0); -} + /** + * @brief Equality test for Control point group + * + * This function tests the reference line numbers for equality and returns true + * if the line references are equivalent, according to an approximation using an + * epsilon of 1.0e-6. + * + * @param p1 First PointData set to compare + * @param p2 Second PointData set to compare + * + * @return bool If the reference point lines are (approximately) equivalent + */ + inline bool PointEqual(const PointData &p1, const PointData &p2) { + return (gsl_fcmp(p1.refPoint.Line(), p2.refPoint.Line(), 1.0E-6) == 0); + } -/** - * @brief Collector for Control points within the same row for analysis - * - * This class is designed to be used as a Functor object collecting control net - * file and collapsing all column measures into on row. This is primarily used - * for analysis of coregistration results with one or more columns specified - * in the search/pattern chip strategy. - * - */ -class ControlByRow { - public: - /** - * @brief Structure to return control point statistics for row - * - * This structure contains the row statistics of merged control points. - * This will eventually be used to compute the spline interpolations for - * line and sample offsets. - * - */ - struct RowPoint { - RowPoint() : refLine(0.0), refSamp(0.0), chpLine(0.0), chpSamp(0.0), - total(0), count(0) { } - double refLine; //!< Reference line (row) - double refSamp; //!< Reference sample - double chpLine; //!< Registered line - double chpSamp; //!< Registered sample - int total; //!< Total points in row - int count; //!< Valid points found - - Statistics rSStats; - Statistics cLStats; - Statistics cSStats; - Statistics cLOffset; - Statistics cSOffset; - Statistics GOFStats; - }; + /** + * @brief Collector for Control points within the same row for analysis + * + * This class is designed to be used as a Functor object collecting control net + * file and collapsing all column measures into on row. This is primarily used + * for analysis of coregistration results with one or more columns specified + * in the search/pattern chip strategy. + * + */ + class ControlByRow { + public: + /** + * @brief Structure to return control point statistics for row + * + * This structure contains the row statistics of merged control points. + * This will eventually be used to compute the spline interpolations for + * line and sample offsets. + * + */ + struct RowPoint { + RowPoint() : refLine(0.0), refSamp(0.0), chpLine(0.0), chpSamp(0.0), + total(0), count(0) { } + double refLine; //!< Reference line (row) + double refSamp; //!< Reference sample + double chpLine; //!< Registered line + double chpSamp; //!< Registered sample + int total; //!< Total points in row + int count; //!< Valid points found - public: - /** - * @brief Default constructor - */ - ControlByRow() { - _minGOF = DBL_MIN; - _maxGOF = DBL_MAX; - } + Statistics rSStats; + Statistics cLStats; + Statistics cSStats; + Statistics cLOffset; + Statistics cSOffset; + Statistics GOFStats; + }; - /** - * @brief Constructor that sets the maximum goodness of fit tolerance - * @param maxGOF Value that specifies the maximum goodness of fit which is - * typically never expected to exceed 1.0 for a good fit. - */ - ControlByRow(double maxGOF) { - _minGOF = DBL_MIN; - _maxGOF = maxGOF; - } + public: + /** + * @brief Default constructor + */ + ControlByRow() { + _minGOF = DBL_MIN; + _maxGOF = DBL_MAX; + } - /** - * @brief Constructor that sets the maximum goodness of fit tolerance - * @param minGOF Value of minimum goodness of fit. Allows user selectable - * adjustment to coregistration minimum tolerance - * @param maxGOF Value that specifies the maximum goodness of fit which is - * typically never expected to exceed 1.0 for a good fit. - */ - ControlByRow(double minGOF, double maxGOF) { - _minGOF = minGOF; - _maxGOF = maxGOF; - } + /** + * @brief Constructor that sets the maximum goodness of fit tolerance + * @param maxGOF Value that specifies the maximum goodness of fit which is + * typically never expected to exceed 1.0 for a good fit. + */ + ControlByRow(double maxGOF) { + _minGOF = DBL_MIN; + _maxGOF = maxGOF; + } - /** - * @brief Destructor - */ - ~ControlByRow() { } + /** + * @brief Constructor that sets the maximum goodness of fit tolerance + * @param minGOF Value of minimum goodness of fit. Allows user selectable + * adjustment to coregistration minimum tolerance + * @param maxGOF Value that specifies the maximum goodness of fit which is + * typically never expected to exceed 1.0 for a good fit. + */ + ControlByRow(double minGOF, double maxGOF) { + _minGOF = minGOF; + _maxGOF = maxGOF; + } - /** - * @brief Determines the number of points (rows) found valid - * - * The number returned is really the number of unique rows of coregistration - * chips gleened from the control net. - * - * @return unsigned int Row/line count - */ - inline unsigned int size() const { return (_rowList.size()); } + /** + * @brief Destructor + */ + ~ControlByRow() { } - /** - * @brief Set the minimum acceptable goodness of fit value - * - * This sets the minimum (absolute) value used to gleen valid points from - * the control net data. - * - * @param minGOF Minimum goodness of fit tolerance - */ - void setMinGOF(double minGOF) { _minGOF = minGOF; } + /** + * @brief Determines the number of points (rows) found valid + * + * The number returned is really the number of unique rows of coregistration + * chips gleened from the control net. + * + * @return unsigned int Row/line count + */ + inline unsigned int size() const { + return (_rowList.size()); + } - /** - * @brief Set the maximum acceptable goodness of fit value - * - * This sets the maximum (absolute) value used to gleen valid points from - * the control net data. This is intended to use to exclude wild points - * that exceed the level of reasonable tolerance. This is typically 1.0 for - * most coregistration algorithms. - * - * @param maxGOF Maximum goodness of fit tolerance - */ - void setMaxGOF(double maxGOF) { _maxGOF = maxGOF; } + /** + * @brief Set the minimum acceptable goodness of fit value + * + * This sets the minimum (absolute) value used to gleen valid points from + * the control net data. + * + * @param minGOF Minimum goodness of fit tolerance + */ + void setMinGOF(double minGOF) { + _minGOF = minGOF; + } - /** - * @brief Operator used to add a point to the data set - * - * This method provides support for the STL for_each algorithm. This allows - * this class to be used as a functor object. - * - * @param p Point to tested for acceptance in the list - */ - void operator() (const PointData &p) { - addPoint(p); - return; - } + /** + * @brief Set the maximum acceptable goodness of fit value + * + * This sets the maximum (absolute) value used to gleen valid points from + * the control net data. This is intended to use to exclude wild points + * that exceed the level of reasonable tolerance. This is typically 1.0 for + * most coregistration algorithms. + * + * @param maxGOF Maximum goodness of fit tolerance + */ + void setMaxGOF(double maxGOF) { + _maxGOF = maxGOF; + } - /** - * @brief Formal method of adding a control point to the data set - * - * This method will add the provided point to the collection of rows (or - * lines of points). - * - * @param p Point to add to the list - */ - void addPoint(const PointData &p) { - if (_rowList.exists(p.refPoint.Line())) { - PointList &r = _rowList.get(p.refPoint.Line()); - r.push_back(p); + /** + * @brief Operator used to add a point to the data set + * + * This method provides support for the STL for_each algorithm. This allows + * this class to be used as a functor object. + * + * @param p Point to tested for acceptance in the list + */ + void operator()(const PointData &p) { + addPoint(p); + return; } - else { - PointList pl; - pl.push_back(p); - _rowList.add(p.refPoint.Line(),pl); + + /** + * @brief Formal method of adding a control point to the data set + * + * This method will add the provided point to the collection of rows (or + * lines of points). + * + * @param p Point to add to the list + */ + void addPoint(const PointData &p) { + if(_rowList.exists(p.refPoint.Line())) { + PointList &r = _rowList.get(p.refPoint.Line()); + r.push_back(p); + } + else { + PointList pl; + pl.push_back(p); + _rowList.add(p.refPoint.Line(), pl); + } + return; } - return; - } - /** - * @brief Returns a point at the ith location - * - * Traverses the list of points after computing the merge statistics for the - * ith row. - * - * @param i Index of point to return - * - * @return RowPoint Structure containing the (statistically) merged row - */ - RowPoint operator[](int i) const { - try { - return (computeStats(_rowList.getNth(i))); - } catch (iException &oor) { - std::string msg = "Requested value (" + iString(i) + ") not found"; - throw iException::Message(Isis::iException::User,msg,_FILEINFO_); + /** + * @brief Returns a point at the ith location + * + * Traverses the list of points after computing the merge statistics for the + * ith row. + * + * @param i Index of point to return + * + * @return RowPoint Structure containing the (statistically) merged row + */ + RowPoint operator[](int i) const { + try { + return (computeStats(_rowList.getNth(i))); + } + catch(iException &oor) { + std::string msg = "Requested value (" + iString(i) + ") not found"; + throw iException::Message(Isis::iException::User, msg, _FILEINFO_); + } } - } - private: - typedef std::vector PointList; //!< Composite list - typedef CollectorMap CNetRow; /** + private: + typedef std::vector PointList; //!< Composite list + typedef CollectorMap CNetRow; /** * Nifty templated collector class works just * nicely for merging rows of correlations */ - double _minGOF; //!< Minimum acceptable goodness of fit - double _maxGOF; //!< Maximum acceptable goodness of fit - CNetRow _rowList; //!< Collection of merged rows/lines + double _minGOF; //!< Minimum acceptable goodness of fit + double _maxGOF; //!< Maximum acceptable goodness of fit + CNetRow _rowList; //!< Collection of merged rows/lines - /** - * @brief Convenience method for adding point to Statistics class - * - * The interface to the Isis Statistics class requires the value to be added - * by address. This method expedites the addition of values from say a - * function or method. - * - * @param value Value to add to Statistics class - * @param stats Statistics class to add the data point to - */ - inline void addToStats(double value, Statistics &stats) const { - stats.AddData(&value, 1); - return; - } - - /** - * @brief All important method that computes statistics for a row - * - * This method computes the statistics for a potentially merged row of - * coregistration chips. It applies the minimum and maximum goodness of fit - * tolerance checks and add valid points to each statistical component of - * the merge. - * - * @param cols List of column chip registrations - * - * @return RowPoint Structure containing the statistics for row/line of - * merged registration columns - */ - RowPoint computeStats(const std::vector &cols) const { - RowPoint rp; - rp.refLine = cols[0].refPoint.Line(); - for (unsigned int i = 0; i < cols.size() ; i++) { - double regGOF(cols[i].chpPoint.GoodnessOfFit()); - if (fabs(regGOF) > _maxGOF) continue; - if (fabs(regGOF) < _minGOF) continue; - (rp.count)++; - addToStats(cols[i].refPoint.Sample(), rp.rSStats); - addToStats(cols[i].chpPoint.Line(), rp.cLStats); - addToStats(cols[i].chpPoint.Sample(), rp.cSStats); - addToStats(cols[i].chpPoint.LineError(), rp.cLOffset); - addToStats(cols[i].chpPoint.SampleError(), rp.cSOffset); - addToStats(cols[i].chpPoint.GoodnessOfFit(), rp.GOFStats); + /** + * @brief Convenience method for adding point to Statistics class + * + * The interface to the Isis Statistics class requires the value to be added + * by address. This method expedites the addition of values from say a + * function or method. + * + * @param value Value to add to Statistics class + * @param stats Statistics class to add the data point to + */ + inline void addToStats(double value, Statistics &stats) const { + stats.AddData(&value, 1); + return; } - rp.total = cols.size(); - rp.refSamp = rp.rSStats.Average(); - rp.chpLine = rp.cLStats.Average(); - rp.chpSamp = rp.cSStats.Average(); - return (rp); - } + /** + * @brief All important method that computes statistics for a row + * + * This method computes the statistics for a potentially merged row of + * coregistration chips. It applies the minimum and maximum goodness of fit + * tolerance checks and add valid points to each statistical component of + * the merge. + * + * @param cols List of column chip registrations + * + * @return RowPoint Structure containing the statistics for row/line of + * merged registration columns + */ + RowPoint computeStats(const std::vector &cols) const { + RowPoint rp; + rp.refLine = cols[0].refPoint.Line(); + for(unsigned int i = 0; i < cols.size() ; i++) { + double regGOF(cols[i].chpPoint.GoodnessOfFit()); + if(fabs(regGOF) > _maxGOF) continue; + if(fabs(regGOF) < _minGOF) continue; + (rp.count)++; + addToStats(cols[i].refPoint.Sample(), rp.rSStats); + addToStats(cols[i].chpPoint.Line(), rp.cLStats); + addToStats(cols[i].chpPoint.Sample(), rp.cSStats); + addToStats(cols[i].chpPoint.LineError(), rp.cLOffset); + addToStats(cols[i].chpPoint.SampleError(), rp.cSOffset); + addToStats(cols[i].chpPoint.GoodnessOfFit(), rp.GOFStats); + } + + rp.total = cols.size(); + rp.refSamp = rp.rSStats.Average(); + rp.chpLine = rp.cLStats.Average(); + rp.chpSamp = rp.cSStats.Average(); + return (rp); + } -}; + }; } // namespace Isis diff --git a/isis/src/base/apps/slither/SlitherTransform.cpp b/isis/src/base/apps/slither/SlitherTransform.cpp index 6ddf8164ea..7a8b72e07b 100644 --- a/isis/src/base/apps/slither/SlitherTransform.cpp +++ b/isis/src/base/apps/slither/SlitherTransform.cpp @@ -17,40 +17,40 @@ namespace Isis { /** * @brief Constructor where all the business is taking place - * + * * This constructor accepts a cube to be transformed and the control net file * generated after matching it to a reference image. It is assumed that the * control net has the reference image identified via the ControlMeasure class. - * + * * It computes the interpolations for line and samples from the control net * registration data. This interpolation preserves lines whole, shifting them * up and/or down and left or right. - * + * * @param cube Input cube to be transformed * @param cnet Control net that will be used to compute the spline offsets * @param lInterp Type of spline to compute for line offsets * @param sInterp Type of spline to compute for sample offsets * @see NumericalApproximation */ - SlitherTransform::SlitherTransform(Cube &cube, ControlNet &cnet, - InterpType lInterp, InterpType sInterp) : - _rows(), _badRows(), - _pntsTotal(0), _pntsUsed(0), _pntsTossed(0), - _iDir(1.0), - _outputLines(cube.Lines()), - _outputSamples(cube.Samples()), - _lineOffset(0.0), _sampOffset(0.0) { + SlitherTransform::SlitherTransform(Cube &cube, ControlNet &cnet, + InterpType lInterp, InterpType sInterp) : + _rows(), _badRows(), + _pntsTotal(0), _pntsUsed(0), _pntsTossed(0), + _iDir(1.0), + _outputLines(cube.Lines()), + _outputSamples(cube.Samples()), + _lineOffset(0.0), _sampOffset(0.0) { // Collect the points from the control file _lineSpline.SetInterpType(lInterp); _sampSpline.SetInterpType(sInterp); vector points; - for (int i=0; i < cnet.Size(); i++) { + for(int i = 0; i < cnet.Size(); i++) { ControlPoint &cp = cnet[i]; _pntsTotal++; - if (!cp.Ignore()) { - if (cp.Size() != 2) { -// cout << "Point " << i << " doesn't have two measures but " + if(!cp.Ignore()) { + if(cp.Size() != 2) { +// cout << "Point " << i << " doesn't have two measures but " // << cp.Size() << endl; _pntsTossed++; } @@ -58,31 +58,31 @@ namespace Isis { // Determine reference image assuming first one is the reference // if it is not expressly identified int snIndex(0), mnIndex(1); - if (!cp[snIndex].IsReference()) { + if(!cp[snIndex].IsReference()) { snIndex = 1; mnIndex = 0; } - // Add the point set to the list - PointData p; - p.refPoint = cp[snIndex]; - p.chpPoint = cp[mnIndex]; - points.push_back(p); - _pntsUsed++; + // Add the point set to the list + PointData p; + p.refPoint = cp[snIndex]; + p.chpPoint = cp[mnIndex]; + points.push_back(p); + _pntsUsed++; } } } // Points must be sorted and then collapsed into one column sort(points.begin(), points.end(), PointLess); - ControlByRow pts = for_each(points.begin(), points.end(), + ControlByRow pts = for_each(points.begin(), points.end(), ControlByRow(1.0)); // Now retrieve the collapsed points identifying good ones and bad ones _rows.clear(); _badRows.clear(); - for (unsigned int n = 0 ; n < pts.size() ; n++) { + for(unsigned int n = 0 ; n < pts.size() ; n++) { RowPoint p = pts[n]; - if (p.count > 0) { + if(p.count > 0) { _rows.push_back(p); } else { @@ -93,7 +93,7 @@ namespace Isis { // Add the points to the spline interpolators. It is important to use // the offsets only in this case so the reverse tranform can be provided // as well. - for (unsigned int n = 0 ; n < _rows.size() ; n++) { + for(unsigned int n = 0 ; n < _rows.size() ; n++) { RowPoint rp = _rows[n]; _lineSpline.AddData(rp.refLine, rp.cLOffset.Average()); _sampSpline.AddData(rp.refLine, rp.cSOffset.Average()); @@ -102,22 +102,22 @@ namespace Isis { /** * @brief Convert the requested output samp/line to an input samp/line - * + * * Computes the incoming line and sample for the given output line and * sample. These coordinates are determined entirely by the interpolations of * the control net coregistrations upon instantiation of this object. - * + * * @param inSample Returns the input sample coordinate for this outSample, * outLine * @param inLine Returns the input line coordinate for this outSample, * outLine * @param outSample Current sample pixel location requested * @param outLine Current line location requested - * + * * @return bool Always returns true as the value will always be provided */ - bool SlitherTransform::Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { + bool SlitherTransform::Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { inLine = getLineXform(outLine); inSample = getSampXform(outLine, outSample); return (true); @@ -125,24 +125,24 @@ namespace Isis { /** * @brief Computes statistics for each line in the output image - * + * * This method computes (gathers, really) the statistics as determined via the * application of the interpolation from the transform. For every valid line, * sample, it accumulates the line offsets as provided via the tranform. - * + * * @return Statistics Provides the statistics class that contains the * statistics information - * @see Statistics - * @history 2008-11-05 Jeannie Walldren - removed const from - * method so that _lineSpline is not const. - * + * @see Statistics + * @history 2008-11-05 Jeannie Walldren - removed const from + * method so that _lineSpline is not const. + * */ - Statistics SlitherTransform::LineStats() { + Statistics SlitherTransform::LineStats() { Statistics stats; - for (int line = 0 ; line < _outputLines ; line++) { - double outLine(line+1), inLine; + for(int line = 0 ; line < _outputLines ; line++) { + double outLine(line + 1), inLine; inLine = getLineXform(outLine); - if ((inLine >= 1.0) && (inLine <= _outputLines)) { + if((inLine >= 1.0) && (inLine <= _outputLines)) { outLine = getOffset(outLine, _lineSpline); stats.AddData(&outLine, 1); } @@ -152,25 +152,25 @@ namespace Isis { /** * @brief Computes statistics for samples in the output image - * + * * This method computes (gathers, really) the statistics as determined via the * application of the interpolation from the transform. For every valid line, * sample, it accumulates the sample offsets as provided via the tranform. - * + * * @return Statistics Provides the statistics class that contains the * statistics information - * @see Statistics - * @history 2008-11-05 Jeannie Walldren - removed const from - * method so that _sampSpline is not const. - * + * @see Statistics + * @history 2008-11-05 Jeannie Walldren - removed const from + * method so that _sampSpline is not const. + * */ - Statistics SlitherTransform::SampleStats() { + Statistics SlitherTransform::SampleStats() { Statistics stats; - for (int line = 0 ; line < _outputLines ; line++) { - double outLine(line+1), inLine; + for(int line = 0 ; line < _outputLines ; line++) { + double outLine(line + 1), inLine; inLine = getLineXform(outLine); - if ((inLine >= 1.0) && (inLine <= _outputLines)) { + if((inLine >= 1.0) && (inLine <= _outputLines)) { double outSamp = getOffset(outLine, _sampSpline); stats.AddData(&outSamp, 1); } @@ -180,13 +180,13 @@ namespace Isis { /** * @brief Provides detailed information and statistics for the current transform - * + * * This method produces a large volume of information pertaining to the computed * transform. This information is written to the provided stream and assumes * the caller has created a valid stream. - * + * * @param out Output stream to write data to - * + * * @return std::ostream& Returns the output stream */ std::ostream &SlitherTransform::dumpState(std::ostream &out) { @@ -195,7 +195,7 @@ namespace Isis { out.setf(std::ios::fixed); out << "# General line, sample statistics\n"; - out << setw(10) << "Axis" + out << setw(10) << "Axis" << setw(10) << "Spline" << setw(12) << "Average" << setw(12) << "StdDev" @@ -227,11 +227,11 @@ namespace Isis { int allPoints(numberPointsUsed() + numberBadPoints()); - out << "\n\n" << setw(10) << "BadRows" << setw(10) << numberBadRows() + out << "\n\n" << setw(10) << "BadRows" << setw(10) << numberBadRows() << " (Rows with no valid points)\n"; - out << setw(10) << "Points" << setw(10) << numberPointsUsed() + out << setw(10) << "Points" << setw(10) << numberPointsUsed() << " of " << allPoints << " (Points with 2 measures)\n"; - out << setw(10) << "AllPoints" << setw(10) << totalPoints() + out << setw(10) << "AllPoints" << setw(10) << totalPoints() << " (Including ignored points)\n"; @@ -240,7 +240,7 @@ namespace Isis { out << setw(10) << "FromLine" << setw(10) << "FromSamp" << setw(10) << "MatchLine" - << setw(10) << "MatchSamp" + << setw(10) << "MatchSamp" << setw(12) << "LineOffset" << setw(12) << "SampOffset" << setw(12) << "LineStdDev" @@ -251,7 +251,7 @@ namespace Isis { << endl; RowList::const_iterator rItr; - for (rItr = _rows.begin() ; rItr != _rows.end() ; ++rItr) { + for(rItr = _rows.begin() ; rItr != _rows.end() ; ++rItr) { double clStd(rItr->cLOffset.StandardDeviation()); double csStd(rItr->cSOffset.StandardDeviation()); out << setw(10) << setprecision(2) << rItr->chpLine @@ -270,19 +270,19 @@ namespace Isis { out << "\n\n# Map of each output line and sample with relative offsets\n"; // Write headers - out << setw(10) << "InLine" - << setw(10) << "InSamp" - << setw(10) << "OutLine" - << setw(10) << "OutSamp" + out << setw(10) << "InLine" + << setw(10) << "InSamp" + << setw(10) << "OutLine" + << setw(10) << "OutSamp" << setw(12) << "LineOffset" << setw(12) << "SampOffset" << endl; - double outSamp(OutputSamples()/2); - for (int line = 1 ; line <= OutputLines() ; line++) { + double outSamp(OutputSamples() / 2); + for(int line = 1 ; line <= OutputLines() ; line++) { double outLine(line), inLine, inSamp; double sampOffset, lineOffset; - + Xform(inSamp, inLine, outSamp, outLine); sampOffset = getOffset(outLine, _sampSpline); lineOffset = getOffset(outLine, _lineSpline); diff --git a/isis/src/base/apps/slither/SlitherTransform.h b/isis/src/base/apps/slither/SlitherTransform.h index 11cdd90abb..3ddd3c2074 100644 --- a/isis/src/base/apps/slither/SlitherTransform.h +++ b/isis/src/base/apps/slither/SlitherTransform.h @@ -12,23 +12,23 @@ namespace Isis { -class SlitherTransform : public Transform { - /** - * @author 2006-06-22 Kris Becker - * - * @internal - * @history 2008-11-05 Jeannie Walldren - Updated references to - * DataInterp with NumericalApproximation. Removed - * const from LineStats() and SampleStats(), - * getOffset(), getLineXform(), and getSampXform() - * since calling NumericalApproximation::Evaluate() - * changes class variables. - * - */ + class SlitherTransform : public Transform { + /** + * @author 2006-06-22 Kris Becker + * + * @internal + * @history 2008-11-05 Jeannie Walldren - Updated references to + * DataInterp with NumericalApproximation. Removed + * const from LineStats() and SampleStats(), + * getOffset(), getLineXform(), and getSampXform() + * since calling NumericalApproximation::Evaluate() + * changes class variables. + * + */ public: typedef NumericalApproximation::InterpType InterpType; - SlitherTransform(Cube &cube, ControlNet &cnet, + SlitherTransform(Cube &cube, ControlNet &cnet, InterpType lInterp = NumericalApproximation::CubicNatural, InterpType sInterp = NumericalApproximation::CubicNatural); @@ -41,14 +41,16 @@ class SlitherTransform : public Transform { /** * @brief Number of points used in computation of transform - * + * * This method returns the number of row points used in the computation of * the spline interpolation fits. - * + * * @return int Number of row point data sets used in sample/line * interopolations */ - inline int size() const { return (_rows.size()); } + inline int size() const { + return (_rows.size()); + } /** * @brief Sets forward transform direction @@ -56,11 +58,13 @@ class SlitherTransform : public Transform { * This is the normal expected operation. The forward transform direction * implies the transform is applied to the search image, not the pattern, * or reference, image used to create the control network. - * + * * The search image is typically the FROM parameter in co-registration * applications. */ - inline void setForward() { _iDir = 1.0; } + inline void setForward() { + _iDir = 1.0; + } /** * @brief Sets reverse transform direction @@ -68,102 +72,116 @@ class SlitherTransform : public Transform { * The reverse transform direction implies the transform is applied to the * pattern, or reference, image, not the search image used to create the * control network. - * + * * The reference image is the MATCH parameter in co-registration * applications. */ - inline void setReverse() { _iDir = -1.0; } + inline void setReverse() { + _iDir = -1.0; + } /** * @brief Total points in control net file - * + * * This method reports to the caller the total number of points in the * control net file. This includes ignored points as well that are * automatically excluded. Points that do not have exactly 2 measures are * excluded as well. - * + * * @return int Number of points used */ - inline int totalPoints() const { return(_pntsTotal); } + inline int totalPoints() const { + return(_pntsTotal); + } /** * @brief Number of points used from the input control net file - * + * * This method reports to the caller the number of points used when read * from the control point file. This count does not include ingored * points or bad points. - * + * * @return int Number of points used */ - inline int numberPointsUsed() const { return(_pntsUsed); } + inline int numberPointsUsed() const { + return(_pntsUsed); + } /** * @brief Number of points tossed on input to this class - * + * * This method reports to the caller the number of points excluded when * read from the control point file that exceeded a certain cnet line. - * + * * @return int Number of points excluded */ - inline int numberBadPoints() const { return(_pntsTossed); } + inline int numberBadPoints() const { + return(_pntsTossed); + } /** * @brief Number of bad rows detected in control net - * + * * This method reports to the caller the number of bad rows detected after * merging chip column registrations for each row. This will typically * indicate the goodness of fit excluded all the points in that row by * constraints imposed by the merging function. - * + * * @return int Number of bad rows detected * @see ControlByRow */ - inline int numberBadRows() const { return(_badRows.size()); } + inline int numberBadRows() const { + return(_badRows.size()); + } // Implementations for parent's pure virtual members - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine); + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine); /** * @brief Determine the number of samples in the output image - * + * * This method returns the number of samples that will result in the image * created from this transform. Default behavior is to use the same * number of samples as the input image. - * + * * @return int Number of samples in output image */ - int OutputSamples () const { return _outputSamples; }; + int OutputSamples() const { + return _outputSamples; + }; /** * @brief Determine the number of lines in the output image - * + * * This method returns the number of lines that will result in the image * created from this transform. Default behavior is to use the same * number of lines as the input image. - * + * * @return int Number of lines in output image */ - int OutputLines () const { return _outputLines; }; + int OutputLines() const { + return _outputLines; + }; /** * @brief Add an additional offset to the line output translation - * + * * This method provides the users of this class to shift the image an * additional number of lines than are determined by the control net * registration information provides. - * + * * This is mostly useful when the registration had an initial starting * offset as opposed to the assumption of generally spatially registering * images. - * + * * Negative values shifts the image down in the output image. Positive * values shift the image up. * * This method can be called at any time during the processing to change * the relative shift. It does not affect the size of the output image, * only the placement of the samples. - * + * * @param lineOffset Additional offset to shift lines in output image */ void addLineOffset(double lineOffset) { @@ -173,22 +191,22 @@ class SlitherTransform : public Transform { /** * @brief Add an additional offset to the sample output transform - * + * * This method provides the users of this class to shift the image an * additional number of samples than are determined by the control net * registration information provides. - * + * * This is mostly useful when the registration had an initial starting * offset as opposed to the assumption of generally spatially registering * images. - * + * * Negative values shifts the image right in the output image. Positive * values shift the image left. - * + * * This method can be called at any time during the processing to change * the relative shift. It does not affect the size of the output image, * only the placement of the samples. - * + * * @param sampOffset Additional offset to shift samples in output image */ void addSampleOffset(double sampOffset) { @@ -200,7 +218,7 @@ class SlitherTransform : public Transform { Statistics SampleStats(); std::ostream &dumpState(std::ostream &out); - + private: typedef ControlByRow::RowPoint RowPoint; typedef std::vector RowList; @@ -210,79 +228,79 @@ class SlitherTransform : public Transform { int _pntsUsed; //!< Total number points not ignored int _pntsTossed; //!< Total number points tossed double _iDir; //!< Interpolation direction - + NumericalApproximation _lineSpline; //!< Line spline interpolation NumericalApproximation _sampSpline; //!< Sample spline interpolation int _outputLines; //!< Number output lines int _outputSamples; //!< Number output samples - + double _lineOffset; //!< Additional spatial line offset double _sampOffset; //!< Additional spatial sample offset /** * @brief Compute the relative shift of the given axis - * + * * This method computes the relative shift at the given location, * typically the line, additionally incorporating the user selected * direction, forward or reverse. - * + * * To acheive the actual location, the input element (sample, line) * location and the user specified offset must be additionally applied. - * + * * @param x Coordinate of the value to get interpolation for * @param interp Interpolation computed for the axis - * + * * @return double Relative shift at the specified coordinate * @see getLineXform - * @see getSampXform - * @history 2008-11-05 Jeannie Walldren - removed const from + * @see getSampXform + * @history 2008-11-05 Jeannie Walldren - removed const from * interp parameter since call to Evaluate() will * fill values of class variables */ inline double getOffset(const double &x, NumericalApproximation &interp) const { - return (_iDir * interp.Evaluate(x,NumericalApproximation::NearestEndpoint)); + return (_iDir * interp.Evaluate(x, NumericalApproximation::NearestEndpoint)); } /** * @brief Compute the line transform given output line - * + * * This method computes the absolute input line from the image given the * requested output line. It uses interpolation functions precomputed * from the input control net file provided by a coregistration * application, typically. - * + * * @param line Output line coordinate to compute input line for - * - * @return double Input line coordinate at the output line coordinate - * @history 2008-11-05 Jeannie Walldren - removed const from + * + * @return double Input line coordinate at the output line coordinate + * @history 2008-11-05 Jeannie Walldren - removed const from * method so that _lineSpline is not const. */ - inline double getLineXform(const double line) { + inline double getLineXform(const double line) { return (line - getOffset(line, _lineSpline) + _lineOffset); } /** * @brief Compute the sample transform given output line, sample - * + * * This method computes the absolute input line from the image given the * requested output line. It uses interpolation functions precomputed * from the input control net file provided by a coregistration * application, typically. - * + * * @param line Output line coordinate to compute input sample for * @param samp Output sample coordinate to compute input sample for - * + * * @return double Input sample coordinate at the output line, sample * coordinate - * @history 2008-11-05 Jeannie Walldren - removed const from - * method so that _sampSpline is not const. + * @history 2008-11-05 Jeannie Walldren - removed const from + * method so that _sampSpline is not const. */ - inline double getSampXform(const double line, const double samp){ + inline double getSampXform(const double line, const double samp) { return (samp - getOffset(line, _sampSpline) + _sampOffset); } - + }; } diff --git a/isis/src/base/apps/slither/slither.cpp b/isis/src/base/apps/slither/slither.cpp index 50abc742ca..0b10632307 100644 --- a/isis/src/base/apps/slither/slither.cpp +++ b/isis/src/base/apps/slither/slither.cpp @@ -13,13 +13,13 @@ using namespace std; using namespace Isis; - + void IsisMain() { // Warp an image ProcessRubberSheet p; // Open the input cube - Cube *icube = p.SetInputCube ("FROM"); + Cube *icube = p.SetInputCube("FROM"); // Get the control point file UserInterface &ui = Application::GetUserInterface(); @@ -29,13 +29,13 @@ void IsisMain() { // Set default type to Cubic spline interpolation NumericalApproximation::InterpType iType(NumericalApproximation::CubicNatural); string splineType = ui.GetString("SPLINE"); - if (splineType == "LINEAR") { + if(splineType == "LINEAR") { iType = NumericalApproximation::Linear; } - else if (splineType == "POLYNOMIAL") { + else if(splineType == "POLYNOMIAL") { iType = NumericalApproximation::Polynomial; } - else if (splineType == "AKIMA") { + else if(splineType == "AKIMA") { iType = NumericalApproximation::Akima; } @@ -48,16 +48,16 @@ void IsisMain() { transform.addLineOffset(lineOffset); transform.addSampleOffset(sampleOffset); string splineDir = ui.GetString("DIRECTION"); - if (splineDir == "REVERSE") { + if(splineDir == "REVERSE") { transform.setReverse(); } // Dump the transform statistics - if (ui.WasEntered("RESULTS")) { + if(ui.WasEntered("RESULTS")) { // Get the control point file string rFile = Filename(ui.GetFilename("RESULTS")).Expanded(); ofstream os; - os.open(rFile.c_str(),ios::out); + os.open(rFile.c_str(), ios::out); os << "# Slither Transform Results\n" << "# RunDate: " << iTime::CurrentLocalTime() << endl << "# FROM: " << icube->Filename() << endl @@ -67,25 +67,25 @@ void IsisMain() { } // Allocate the output file, same size as input - p.SetOutputCube ("TO",transform.OutputSamples(), - transform.OutputLines(), - icube->Bands()); + p.SetOutputCube("TO", transform.OutputSamples(), + transform.OutputLines(), + icube->Bands()); // Set up the interpolator Interpolator *interp; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } else { string msg = "Unknown value for INTERP [" + ui.GetString("INTERP") + "]"; - throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Programmer, msg, _FILEINFO_); } // Create the output file diff --git a/isis/src/base/apps/slpmap/slpmap.cpp b/isis/src/base/apps/slpmap/slpmap.cpp index 6b635479cd..c8118fb94f 100644 --- a/isis/src/base/apps/slpmap/slpmap.cpp +++ b/isis/src/base/apps/slpmap/slpmap.cpp @@ -4,15 +4,15 @@ #include "Camera.h" #include "Projection.h" -using namespace std; +using namespace std; using namespace Isis; bool degrees; double resolution[2]; -void createSlpCube (Buffer &in, double &v); -void createAspectCube (Buffer &in, double &v); +void createSlpCube(Buffer &in, double &v); +void createAspectCube(Buffer &in, double &v); void IsisMain() { ProcessByBoxcar p; @@ -23,11 +23,11 @@ void IsisMain() { // as ProcessByBoxcar only allows one input cube and one // output cube, two seperate process must be done - Cube *icube = p.SetInputCube ("FROM"); - p.SetBoxcarSize( 3, 3 ); - p.SetOutputCube ("TO"); + Cube *icube = p.SetInputCube("FROM"); + p.SetBoxcarSize(3, 3); + p.SetOutputCube("TO"); - if(ui.GetString("OUTPUT") == "SLOPE" ) { + if(ui.GetString("OUTPUT") == "SLOPE") { // For slope we need a resolution // Try to use the camera first try { @@ -35,24 +35,24 @@ void IsisMain() { // Really we should be doing this at every point in the image... but for now, // the center will work. - if(!cam->SetImage(icube->Samples()/2,icube->Lines()/2)) { + if(!cam->SetImage(icube->Samples() / 2, icube->Lines() / 2)) { // Get into the catch(...) - throw iException::Message(iException::Programmer,"",_FILEINFO_); + throw iException::Message(iException::Programmer, "", _FILEINFO_); } // Convert resolution to the DN value's unit (easier) resolution[0] = cam->SampleResolution() / ui.GetDouble("CONVERSION");; resolution[1] = cam->LineResolution() / ui.GetDouble("CONVERSION");; } - catch (iException &e) { + catch(iException &e) { // Failed at getting the camera, reset our exception and try again with the projection e.Clear(); Projection *proj = icube->Projection(); - if(!proj->SetWorld(icube->Samples()/2,icube->Lines()/2)) { + if(!proj->SetWorld(icube->Samples() / 2, icube->Lines() / 2)) { iString message = "Failed to SetWorld at the center of the image"; - throw iException::Message(iException::Programmer,message,_FILEINFO_); + throw iException::Message(iException::Programmer, message, _FILEINFO_); } // Convert resolution to the DN value's unit (easier) @@ -60,10 +60,10 @@ void IsisMain() { resolution[1] = proj->Resolution() / ui.GetDouble("CONVERSION"); } - p.StartProcess (createSlpCube); - } + p.StartProcess(createSlpCube); + } else { - p.StartProcess (createAspectCube); + p.StartProcess(createAspectCube); } p.EndProcess(); @@ -71,19 +71,19 @@ void IsisMain() { /** - * http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=How%20Slope%20(3D%20Analyst)%20works - * + * http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=How%20Slope%20(3D%20Analyst)%20works + * * "Conceptually, the Slope function fits a plane to the z-values of a 3 x 3 * cell neighborhood around the processing or center cell. The slope value of * this plane is calculated using the average maximum technique (see * References). The direction the plane faces is the aspect for the processing * cell. The lower the slope value, the flatter the terrain; the higher the * slope value, the steeper the terrain." - * + * * @param in Input cube data (3x3 matrix) * @param v Output value */ -void createSlpCube( Buffer &in, double &v ) { +void createSlpCube(Buffer &in, double &v) { const double &a = in[0]; const double &b = in[1]; const double &c = in[2]; @@ -95,27 +95,27 @@ void createSlpCube( Buffer &in, double &v ) { const double &i = in[8]; // If anything we're actually calculating with is special, fail - if(Isis::IsSpecial(a) || - Isis::IsSpecial(b) || - Isis::IsSpecial(c) || - Isis::IsSpecial(f) || - Isis::IsSpecial(g) || - Isis::IsSpecial(h) || - Isis::IsSpecial(i)) { + if(Isis::IsSpecial(a) || + Isis::IsSpecial(b) || + Isis::IsSpecial(c) || + Isis::IsSpecial(f) || + Isis::IsSpecial(g) || + Isis::IsSpecial(h) || + Isis::IsSpecial(i)) { v = Isis::Null; return; } // [dz/dx] = ((c + 2f + i) - (a + 2d + g)) / (8 * x_cell_size) - double changeInX = ((c + 2*f + i) - (a + 2*d + g)) / (8 * resolution[0]); + double changeInX = ((c + 2 * f + i) - (a + 2 * d + g)) / (8 * resolution[0]); // [dz/dy] = ((g + 2h + i) - (a + 2b + c)) / (8 * y_cell_size) - double changeInY = ((g + 2*h + i) - (a + 2*b + c)) / (8 * resolution[0]); + double changeInY = ((g + 2 * h + i) - (a + 2 * b + c)) / (8 * resolution[0]); - double changeMag = sqrt(changeInX*changeInX + changeInY*changeInY); + double changeMag = sqrt(changeInX * changeInX + changeInY * changeInY); double slopeRadians = atan(changeMag); - + if(!degrees) { v = slopeRadians; } @@ -127,15 +127,15 @@ void createSlpCube( Buffer &in, double &v ) { /** * http://webhelp.esri.com/arcgisdesktop/9.3/index.cfm?TopicName=How%20Aspect%20(3D%20Analyst)%20works - * + * * "Conceptually, the Aspect function fits a plane to the z-values of a 3 x 3 * cell neighborhood around the processing or center cell. The direction the * plane faces is the aspect for the processing cell." - * + * * @param in Input cube data (3x3 matrix) * @param v Output value */ -void createAspectCube( Buffer &in, double &v ) { +void createAspectCube(Buffer &in, double &v) { const double &a = in[0]; const double &b = in[1]; const double &c = in[2]; @@ -147,22 +147,22 @@ void createAspectCube( Buffer &in, double &v ) { const double &i = in[8]; // If anything we're actually calculating with is special, fail - if(Isis::IsSpecial(a) || - Isis::IsSpecial(b) || - Isis::IsSpecial(c) || - Isis::IsSpecial(f) || - Isis::IsSpecial(g) || - Isis::IsSpecial(h) || - Isis::IsSpecial(i)) { + if(Isis::IsSpecial(a) || + Isis::IsSpecial(b) || + Isis::IsSpecial(c) || + Isis::IsSpecial(f) || + Isis::IsSpecial(g) || + Isis::IsSpecial(h) || + Isis::IsSpecial(i)) { v = Isis::Null; return; } // [dz/dx] = ((c + 2f + i) - (a + 2d + g)) / 8 - double changeInX = ((c + 2*f + i) - (a + 2*d + g)) / 8; + double changeInX = ((c + 2 * f + i) - (a + 2 * d + g)) / 8; // [dz/dy] = ((g + 2h + i) - (a + 2b + c)) / 8 - double changeInY = ((g + 2*h + i) - (a + 2*b + c)) / 8; + double changeInY = ((g + 2 * h + i) - (a + 2 * b + c)) / 8; // aspect = 57.29578 * atan2 ([dz/dy], -[dz/dx]) = in degrees double aspectRadians = atan2(changeInY, -changeInX); @@ -175,7 +175,7 @@ void createAspectCube( Buffer &in, double &v ) { else if aspect > 90.0 cell = 360.0 - aspect + 90.0 else - cell = 90.0 - aspect + cell = 90.0 - aspect */ if(aspectRadians < 0) { @@ -187,7 +187,7 @@ void createAspectCube( Buffer &in, double &v ) { else { v = Isis::PI / 2.0 - aspectRadians; } - + if(!degrees) { v = aspectRadians; } diff --git a/isis/src/base/apps/specadd/specadd.cpp b/isis/src/base/apps/specadd/specadd.cpp index be639ac32b..eceec50f48 100644 --- a/isis/src/base/apps/specadd/specadd.cpp +++ b/isis/src/base/apps/specadd/specadd.cpp @@ -2,10 +2,10 @@ #include "ProcessByLine.h" #include "SpecialPixel.h" -using namespace std; +using namespace std; using namespace Isis; -void specadd (vector &in, vector &out); +void specadd(vector &in, vector &out); void IsisMain() { ProcessByLine p; @@ -13,23 +13,22 @@ void IsisMain() { // Setup the input and output cubes p.SetInputCube("FROM"); p.SetInputCube("MATCH"); - p.SetOutputCube ("TO" ); + p.SetOutputCube("TO"); p.StartProcess(specadd); p.EndProcess(); } // Line processing routine -void specadd (vector &in, vector &out) -{ +void specadd(vector &in, vector &out) { Buffer &from = *in[0]; Buffer &match = *in[1]; Buffer &to = *out[0]; // copy the original image unless it's a special pixel // in which case the information is copied from the match cube - for (int i=0; i maxBands) { + if(bands > maxBands) { iString msg = "Parameter bands [" + iString(bands) + "] exceeds maximum allowable size " - + "of [" + iString(maxBands) + "] for cube [" + icube->Filename() + "]"; - throw iException::Message(iException::User,msg, _FILEINFO_); + + "of [" + iString(maxBands) + "] for cube [" + icube->Filename() + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } - + //Set the Boxcar Parameters low = -DBL_MAX; high = DBL_MAX; - if (ui.WasEntered("LOW")) { + if(ui.WasEntered("LOW")) { low = ui.GetDouble("LOW"); } - if (ui.WasEntered("HIGH")) { + if(ui.WasEntered("HIGH")) { high = ui.GetDouble("HIGH"); } - + //Obtain output cube p.SetOutputCube("TO"); //Start the filter method p.StartProcess(Filter); p.EndProcess(); - + } /** @@ -57,12 +57,12 @@ void IsisMain() { * average value of the pixels around each valid pixel, writing that * average to the output at the pixel index */ -void Filter (Buffer &in, Buffer &out) { +void Filter(Buffer &in, Buffer &out) { Isis::QuickFilter filter(in.size(), bands, 1); filter.SetMinMax(low, high); filter.AddLine(in.DoubleBuffer()); - for (int i = 0; i < in.size(); i ++) { + for(int i = 0; i < in.size(); i ++) { out[i] = in[i] / filter.Average(i); } } diff --git a/isis/src/base/apps/spechighpass/spechighpass.cpp b/isis/src/base/apps/spechighpass/spechighpass.cpp index 43db9b2a32..9c80f0a8b7 100644 --- a/isis/src/base/apps/spechighpass/spechighpass.cpp +++ b/isis/src/base/apps/spechighpass/spechighpass.cpp @@ -5,7 +5,7 @@ #include -using namespace std; +using namespace std; using namespace Isis; // Which pixel types to filter @@ -14,7 +14,7 @@ double low ; double high; // Prototype -void Filter (Buffer &in, Buffer &out); +void Filter(Buffer &in, Buffer &out); void IsisMain() { //Set up ProcessBySpectra @@ -27,30 +27,30 @@ void IsisMain() { bands = ui.GetInteger("BANDS"); //Check for cases of too many bands - if (bands >= (2 * cubeBands)) { + if(bands >= (2 * cubeBands)) { iString msg = "Parameter bands [" + iString(bands) + "] exceeds maximum allowable size " - + "of [" + iString((cubeBands * 2) - 1) + "] for cube [" + icube->Filename() + "]"; - throw iException::Message(iException::User,msg, _FILEINFO_); + + "of [" + iString((cubeBands * 2) - 1) + "] for cube [" + icube->Filename() + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } - + //Set the Boxcar Parameters low = -DBL_MAX; high = DBL_MAX; - if (ui.WasEntered("LOW")) { + if(ui.WasEntered("LOW")) { low = ui.GetDouble("LOW"); } - if (ui.WasEntered("HIGH")) { + if(ui.WasEntered("HIGH")) { high = ui.GetDouble("HIGH"); } - + //Obtain output cube p.SetOutputCube("TO"); //Start the filter method p.StartProcess(Filter); p.EndProcess(); - + } /** @@ -58,12 +58,12 @@ void IsisMain() { * value of the pixels around each valid pixel, writing that * average to the output at the pixel index */ -void Filter (Buffer &in, Buffer &out) { +void Filter(Buffer &in, Buffer &out) { QuickFilter *filter = new QuickFilter(in.size(), bands, 1); filter->SetMinMax(low, high); filter->AddLine(in.DoubleBuffer()); - for (int i=0; i < in.size(); i++) { + for(int i = 0; i < in.size(); i++) { out[i] = in[i] - filter->Average(i); } delete filter; diff --git a/isis/src/base/apps/speclowpass/speclowpass.cpp b/isis/src/base/apps/speclowpass/speclowpass.cpp index 7e362bb2ea..af1c25fc6f 100644 --- a/isis/src/base/apps/speclowpass/speclowpass.cpp +++ b/isis/src/base/apps/speclowpass/speclowpass.cpp @@ -3,7 +3,7 @@ #include "UserInterface.h" #include "QuickFilter.h" -using namespace std; +using namespace std; using namespace Isis; // Which pixel types to filter @@ -12,7 +12,7 @@ double low ; double high; // Prototype -void Filter (Buffer &in, Buffer &out); +void Filter(Buffer &in, Buffer &out); void IsisMain() { // Set up ProcessBySpectra @@ -25,30 +25,30 @@ void IsisMain() { bands = ui.GetInteger("BANDS"); // Check for cases of too many bands - if (bands > maxBands) { + if(bands > maxBands) { iString msg = "Parameter bands [" + iString(bands) + "] exceeds maximum allowable size " - + "of [" + iString(maxBands) + "] for cube [" + icube->Filename() + "]"; - throw iException::Message(iException::User,msg, _FILEINFO_); + + "of [" + iString(maxBands) + "] for cube [" + icube->Filename() + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } - + // Set the Boxcar Parameters low = -DBL_MAX; high = DBL_MAX; - if (ui.WasEntered("LOW")) { + if(ui.WasEntered("LOW")) { low = ui.GetDouble("LOW"); } - if (ui.WasEntered("HIGH")) { + if(ui.WasEntered("HIGH")) { high = ui.GetDouble("HIGH"); } - + // Obtain output cube p.SetOutputCube("TO"); // Start the filter method p.StartProcess(Filter); p.EndProcess(); - + } /** @@ -56,12 +56,12 @@ void IsisMain() { * average value of the pixels around each valid pixel, writing that * average to the output at the pixel index */ -void Filter (Buffer &in, Buffer &out) { +void Filter(Buffer &in, Buffer &out) { Isis::QuickFilter filter(in.size(), bands, 1); filter.SetMinMax(low, high); filter.AddLine(in.DoubleBuffer()); - for (int i = 0; i < in.size(); i ++) { + for(int i = 0; i < in.size(); i ++) { out[i] = filter.Average(i); } } diff --git a/isis/src/base/apps/specpix/specpix.cpp b/isis/src/base/apps/specpix/specpix.cpp index fa4c9350b2..712a93988b 100644 --- a/isis/src/base/apps/specpix/specpix.cpp +++ b/isis/src/base/apps/specpix/specpix.cpp @@ -8,7 +8,7 @@ #include "SpecialPixel.h" #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; enum SpecPix { @@ -32,10 +32,10 @@ vector rngList; int numRange; // Line processing routine -void specpix (Buffer &in, Buffer &out); +void specpix(Buffer &in, Buffer &out); -bool Descending (const spRange &r1,const spRange &r2); -int nnull,nlis,nlrs,nhis,nhrs; +bool Descending(const spRange &r1, const spRange &r2); +int nnull, nlis, nlrs, nhis, nhrs; void IsisMain() { // We will be processing by line @@ -45,7 +45,7 @@ void IsisMain() { // Setup the input and output cubes p.SetInputCube("FROM"); - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); spRange temp; // Read range values from user @@ -53,57 +53,57 @@ void IsisMain() { temp.min = 0; temp.max = 0; - if (ui.WasEntered ("NULLMIN")) temp.min = ui.GetDouble ("NULLMIN"); - if (ui.WasEntered ("NULLMAX")) temp.max = ui.GetDouble ("NULLMAX"); + if(ui.WasEntered("NULLMIN")) temp.min = ui.GetDouble("NULLMIN"); + if(ui.WasEntered("NULLMAX")) temp.max = ui.GetDouble("NULLMAX"); - if (temp.min != 0 || temp.max != 0) { + if(temp.min != 0 || temp.max != 0) { nnull = 0; temp.specPix = NULLP; - rngList.push_back (temp); + rngList.push_back(temp); temp.min = 0; temp.max = 0; temp.specPix = NONE; } - if (ui.WasEntered ("LRSMIN")) temp.min = ui.GetDouble ("LRSMIN"); - if (ui.WasEntered ("LRSMAX")) temp.max = ui.GetDouble ("LRSMAX"); - if (temp.min != 0 || temp.max != 0) { + if(ui.WasEntered("LRSMIN")) temp.min = ui.GetDouble("LRSMIN"); + if(ui.WasEntered("LRSMAX")) temp.max = ui.GetDouble("LRSMAX"); + if(temp.min != 0 || temp.max != 0) { nlrs = 0; temp.specPix = LRS; - rngList.push_back (temp); + rngList.push_back(temp); temp.min = 0; temp.max = 0; temp.specPix = NONE; } - if (ui.WasEntered ("HRSMIN")) temp.min = ui.GetDouble ("HRSMIN"); - if (ui.WasEntered ("HRSMAX")) temp.max = ui.GetDouble ("HRSMAX"); - if (temp.min != 0 || temp.max != 0) { + if(ui.WasEntered("HRSMIN")) temp.min = ui.GetDouble("HRSMIN"); + if(ui.WasEntered("HRSMAX")) temp.max = ui.GetDouble("HRSMAX"); + if(temp.min != 0 || temp.max != 0) { nhrs = 0; temp.specPix = HRS; - rngList.push_back (temp); + rngList.push_back(temp); temp.min = 0; temp.max = 0; temp.specPix = NONE; } - if (ui.WasEntered ("LISMIN")) temp.min = ui.GetDouble ("LISMIN"); - if (ui.WasEntered ("LISMAX")) temp.max = ui.GetDouble ("LISMAX"); - if (temp.min != 0 || temp.max != 0) { + if(ui.WasEntered("LISMIN")) temp.min = ui.GetDouble("LISMIN"); + if(ui.WasEntered("LISMAX")) temp.max = ui.GetDouble("LISMAX"); + if(temp.min != 0 || temp.max != 0) { nlis = 0; temp.specPix = LIS; - rngList.push_back (temp); + rngList.push_back(temp); temp.min = 0; temp.max = 0; temp.specPix = NONE; } - if (ui.WasEntered ("HISMIN")) temp.min = ui.GetDouble ("HISMIN"); - if (ui.WasEntered ("HISMAX")) temp.max = ui.GetDouble ("HISMAX"); - if (temp.min != 0 || temp.max != 0) { + if(ui.WasEntered("HISMIN")) temp.min = ui.GetDouble("HISMIN"); + if(ui.WasEntered("HISMAX")) temp.max = ui.GetDouble("HISMAX"); + if(temp.min != 0 || temp.max != 0) { nhis = 0; temp.specPix = HIS; - rngList.push_back (temp); + rngList.push_back(temp); temp.min = 0; temp.max = 0; temp.specPix = NONE; @@ -116,20 +116,20 @@ void IsisMain() { // the min is less than the next max, there is overlap between those // two sets of ranges. numRange = rngList.size(); - if (numRange > 1) { + if(numRange > 1) { vector sortList(numRange); - copy (rngList.begin(), rngList.end(), sortList.begin()); - sort (sortList.begin(),sortList.end(),Descending); - for (int i=0; i= rngList[rng].min && in[i] <= rngList[rng].max) { + if(in[i] >= rngList[rng].min && in[i] <= rngList[rng].max) { out[i] = NULL8; nnull++; } break; case LRS: - if (in[i] >= rngList[rng].min && in[i] <= rngList[rng].max) { + if(in[i] >= rngList[rng].min && in[i] <= rngList[rng].max) { out[i] = LOW_REPR_SAT8; nlrs++; } break; case HRS: - if (in[i] >= rngList[rng].min && in[i] <= rngList[rng].max) { + if(in[i] >= rngList[rng].min && in[i] <= rngList[rng].max) { out[i] = HIGH_REPR_SAT8; nhrs++; } break; case LIS: - if (in[i] >= rngList[rng].min && in[i] <= rngList[rng].max) { + if(in[i] >= rngList[rng].min && in[i] <= rngList[rng].max) { out[i] = LOW_INSTR_SAT8; nlis++; } break; case HIS: - if (in[i] >= rngList[rng].min && in[i] <= rngList[rng].max) { + if(in[i] >= rngList[rng].min && in[i] <= rngList[rng].max) { out[i] = HIGH_INSTR_SAT8; nhis++; } @@ -206,9 +205,8 @@ void specpix (Buffer &in,Buffer &out) } } -bool Descending (const spRange &r1,const spRange &r2) -{ - if (r1.min > r2.min) { +bool Descending(const spRange &r1, const spRange &r2) { + if(r1.min > r2.min) { return true; } else diff --git a/isis/src/base/apps/spicefit/spicefit.cpp b/isis/src/base/apps/spicefit/spicefit.cpp index a07cc01335..b609c316b2 100644 --- a/isis/src/base/apps/spicefit/spicefit.cpp +++ b/isis/src/base/apps/spicefit/spicefit.cpp @@ -13,23 +13,23 @@ void IsisMain() { try { // Open the cube Cube cube; - cube.Open(ui.GetFilename("FROM"),"rw"); + cube.Open(ui.GetFilename("FROM"), "rw"); //check for existing polygon, if exists delete it - if (cube.Label()->HasObject("Polygon")){ + if(cube.Label()->HasObject("Polygon")) { cube.Label()->DeleteObject("Polygon"); } // Get the camera, interpolate to a parabola Camera *cam = cube.Camera(); - if (cam->DetectorMap()->LineRate() == 0.0) { + if(cam->DetectorMap()->LineRate() == 0.0) { string msg = "[" + ui.GetFilename("FROM") + "] is not a line scan camera"; - throw iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw iException::Message(Isis::iException::User, msg, _FILEINFO_); } cam->InstrumentRotation()->SetPolynomial(); // Get the instrument pointing keyword from the kernels group and update its value to table. - Isis::PvlGroup kernels = cube.Label()->FindGroup("Kernels",Isis::Pvl::Traverse); + Isis::PvlGroup kernels = cube.Label()->FindGroup("Kernels", Isis::Pvl::Traverse); // Write out the "Table" label to the tabled kernels in the kernels group kernels["InstrumentPointing"] = "Table"; @@ -41,8 +41,8 @@ void IsisMain() { cube.Write(cmatrix); cube.Close(); } - catch (iException &e) { + catch(iException &e) { string msg = "Unable to fit pointing for [" + ui.GetFilename("FROM") + "]"; - throw iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw iException::Message(Isis::iException::User, msg, _FILEINFO_); } } diff --git a/isis/src/base/apps/spiceinit/spiceinit.cpp b/isis/src/base/apps/spiceinit/spiceinit.cpp index e3236c51d0..a02d68886f 100644 --- a/isis/src/base/apps/spiceinit/spiceinit.cpp +++ b/isis/src/base/apps/spiceinit/spiceinit.cpp @@ -15,11 +15,11 @@ using namespace std; using namespace Isis; bool TryKernels(Cube *icube, Process &p, - Kernel lk, Kernel pck, + Kernel lk, Kernel pck, Kernel targetSpk, Kernel ck, - Kernel fk, Kernel ik, - Kernel sclk, Kernel spk, - Kernel iak, Kernel dem, + Kernel fk, Kernel ik, + Kernel sclk, Kernel spk, + Kernel iak, Kernel dem, Kernel exk); void GetUserEnteredKernel(const string ¶m, Kernel &kernel); @@ -32,33 +32,34 @@ void IsisMain() { Cube *icube = p.SetInputCube(ui.GetFilename("FROM"), cai, ReadWrite); // Make sure at least one CK & SPK quality was selected - if (!ui.GetBoolean("CKPREDICTED") && !ui.GetBoolean("CKRECON") && !ui.GetBoolean("CKSMITHED") && !ui.GetBoolean("CKNADIR")) { + if(!ui.GetBoolean("CKPREDICTED") && !ui.GetBoolean("CKRECON") && !ui.GetBoolean("CKSMITHED") && !ui.GetBoolean("CKNADIR")) { string msg = "At least one CK quality must be selected"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - if (!ui.GetBoolean("SPKPREDICTED") && !ui.GetBoolean("SPKRECON") && !ui.GetBoolean("SPKSMITHED")) { + if(!ui.GetBoolean("SPKPREDICTED") && !ui.GetBoolean("SPKRECON") && !ui.GetBoolean("SPKSMITHED")) { string msg = "At least one SPK quality must be selected"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // Make sure it is not projected Projection *proj = NULL; try { proj = icube->Projection(); - } catch (iException &e) { + } + catch(iException &e) { proj = NULL; e.Clear(); } - if (proj != NULL) { + if(proj != NULL) { string msg = "Can not initialize SPICE for a map projected cube"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } Pvl lab = *icube->Label(); // if cube has existing polygon delete it - if (icube->Label()->HasObject("Polygon")) { + if(icube->Label()->HasObject("Polygon")) { icube->Label()->DeleteObject("Polygon"); } @@ -67,25 +68,25 @@ void IsisMain() { string transFile = p.MissionData("base", "translations/MissionName2DataDir.trn"); // Get the mission translation manager ready - PvlTranslationManager missionXlater (lab, transFile); + PvlTranslationManager missionXlater(lab, transFile); // Get the mission name so we can search the correct DB's for kernels - string mission = missionXlater.Translate ("MissionName"); + string mission = missionXlater.Translate("MissionName"); // Get system base kernels unsigned int allowed = 0; unsigned int allowedCK = 0; unsigned int allowedSPK = 0; - if (ui.GetBoolean("CKPREDICTED")) allowedCK |= spiceInit::kernelTypeEnum("PREDICTED"); - if (ui.GetBoolean("CKRECON")) allowedCK |= spiceInit::kernelTypeEnum("RECONSTRUCTED"); - if (ui.GetBoolean("CKSMITHED")) allowedCK |= spiceInit::kernelTypeEnum("SMITHED"); - if (ui.GetBoolean("CKNADIR")) allowedCK |= spiceInit::kernelTypeEnum("NADIR"); - if (ui.GetBoolean("SPKPREDICTED")) allowedSPK |= spiceInit::kernelTypeEnum("PREDICTED"); - if (ui.GetBoolean("SPKRECON")) allowedSPK |= spiceInit::kernelTypeEnum("RECONSTRUCTED"); - if (ui.GetBoolean("SPKSMITHED")) allowedSPK |= spiceInit::kernelTypeEnum("SMITHED"); - KernelDb baseKernels (allowed); - KernelDb ckKernels (allowedCK); - KernelDb spkKernels (allowedSPK); + if(ui.GetBoolean("CKPREDICTED")) allowedCK |= spiceInit::kernelTypeEnum("PREDICTED"); + if(ui.GetBoolean("CKRECON")) allowedCK |= spiceInit::kernelTypeEnum("RECONSTRUCTED"); + if(ui.GetBoolean("CKSMITHED")) allowedCK |= spiceInit::kernelTypeEnum("SMITHED"); + if(ui.GetBoolean("CKNADIR")) allowedCK |= spiceInit::kernelTypeEnum("NADIR"); + if(ui.GetBoolean("SPKPREDICTED")) allowedSPK |= spiceInit::kernelTypeEnum("PREDICTED"); + if(ui.GetBoolean("SPKRECON")) allowedSPK |= spiceInit::kernelTypeEnum("RECONSTRUCTED"); + if(ui.GetBoolean("SPKSMITHED")) allowedSPK |= spiceInit::kernelTypeEnum("SMITHED"); + KernelDb baseKernels(allowed); + KernelDb ckKernels(allowedCK); + KernelDb spkKernels(allowedSPK); baseKernels.LoadSystemDb(mission); ckKernels.LoadSystemDb(mission); @@ -103,7 +104,7 @@ void IsisMain() { ck = ckKernels.SpacecraftPointing(lab); spk = spkKernels.SpacecraftPosition(lab); - if (ui.GetBoolean("CKNADIR")) { + if(ui.GetBoolean("CKNADIR")) { // Only add nadir if no spacecraft pointing found std::vector kernels; kernels.push_back("Nadir"); @@ -122,18 +123,19 @@ void IsisMain() { GetUserEnteredKernel("EXTRA", exk); // Get shape kernel - if (ui.GetString ("SHAPE") == "USER") { + if(ui.GetString("SHAPE") == "USER") { GetUserEnteredKernel("MODEL", dem); - } else if (ui.GetString("SHAPE") == "SYSTEM") { + } + else if(ui.GetString("SHAPE") == "SYSTEM") { dem = baseKernels.Dem(lab); } bool kernelSuccess = false; - if (ck.size() == 0 && !ui.WasEntered("CK")) { - throw iException::Message(iException::Camera, - "No Camera Kernel found for the image ["+ui.GetFilename("FROM") - +"]", + if(ck.size() == 0 && !ui.WasEntered("CK")) { + throw iException::Message(iException::Camera, + "No Camera Kernel found for the image [" + ui.GetFilename("FROM") + + "]", _FILEINFO_); } else if(ui.WasEntered("CK")) { @@ -146,22 +148,22 @@ void IsisMain() { Kernel realCkKernel = ck.top(); ck.pop(); - if (ui.WasEntered("CK")) { + if(ui.WasEntered("CK")) { ui.GetAsString("CK", realCkKernel.kernels); } // Merge SpacecraftPointing and Frame into ck - for (int i = 0; i < fk.size(); i++) { + for(int i = 0; i < fk.size(); i++) { realCkKernel.push_back(fk[i]); } kernelSuccess = TryKernels(icube, p, lk, pck, targetSpk, - realCkKernel, fk, ik, sclk, spk, iak, dem, exk); + realCkKernel, fk, ik, sclk, spk, iak, dem, exk); } if(!kernelSuccess) { - throw iException::Message(iException::Camera, - "Unable to initialize camera model", + throw iException::Message(iException::Camera, + "Unable to initialize camera model", _FILEINFO_); } @@ -169,17 +171,17 @@ void IsisMain() { } /** - * If the user entered the parameter param, then - * kernel is replaced by the user's values and - * quality is reset to 0. - * - * @param param - * @param kernel + * If the user entered the parameter param, then + * kernel is replaced by the user's values and + * quality is reset to 0. + * + * @param param + * @param kernel */ void GetUserEnteredKernel(const string ¶m, Kernel &kernel) { UserInterface &ui = Application::GetUserInterface(); - if (ui.WasEntered(param)) { + if(ui.WasEntered(param)) { kernel = Kernel(); // NOTE: This is using GetAsString so that vars like $mgs can be used. ui.GetAsString(param, kernel.kernels); @@ -187,10 +189,10 @@ void GetUserEnteredKernel(const string ¶m, Kernel &kernel) { } bool TryKernels(Cube *icube, Process &p, - Kernel lk, Kernel pck, + Kernel lk, Kernel pck, Kernel targetSpk, Kernel ck, - Kernel fk, Kernel ik, Kernel sclk, - Kernel spk, Kernel iak, + Kernel fk, Kernel ik, Kernel sclk, + Kernel spk, Kernel iak, Kernel dem, Kernel exk) { Pvl lab = *icube->Label(); @@ -206,34 +208,34 @@ bool TryKernels(Cube *icube, Process &p, PvlKeyword demKeyword("ShapeModel"); PvlKeyword exkKeyword("Extra"); - for (int i=0; i DBL_EPSILON) { - currentKernels.AddKeyword(PvlKeyword("StartPadding", ui.GetDouble("STARTPAD"), "seconds")); + currentKernels.AddKeyword(PvlKeyword("StartPadding", ui.GetDouble("STARTPAD"), "seconds")); } if(ui.GetDouble("ENDPAD") > DBL_EPSILON) { - currentKernels.AddKeyword(PvlKeyword("EndPadding", ui.GetDouble("ENDPAD"), "seconds")); + currentKernels.AddKeyword(PvlKeyword("EndPadding", ui.GetDouble("ENDPAD"), "seconds")); } - currentKernels.AddKeyword(PvlKeyword("CameraVersion",CameraFactory::CameraVersion(lab)), Pvl::Replace); + currentKernels.AddKeyword(PvlKeyword("CameraVersion", CameraFactory::CameraVersion(lab)), Pvl::Replace); // Add the modified Kernels group to the input cube labels icube->PutGroup(currentKernels); @@ -306,23 +308,24 @@ bool TryKernels(Cube *icube, Process &p, try { cam = icube->Camera(); Application::Log(currentKernels); - } catch (iException &e) { + } + catch(iException &e) { Pvl errPvl = e.PvlErrors(); if(errPvl.Groups() > 0) { - currentKernels += PvlKeyword("Error", errPvl.Group(errPvl.Groups()-1)["Message"][0]); + currentKernels += PvlKeyword("Error", errPvl.Group(errPvl.Groups() - 1)["Message"][0]); } - + Application::Log(currentKernels); icube->PutGroup(originalKernels); throw e; } - if (ui.GetBoolean("ATTACH")) { + if(ui.GetBoolean("ATTACH")) { Table ckTable = cam->InstrumentRotation()->Cache("InstrumentPointing"); ckTable.Label() += PvlKeyword("Description", "Created by spiceinit"); ckTable.Label() += PvlKeyword("Kernels"); - for (int i=0; iWrite(ckTable); @@ -330,7 +333,7 @@ bool TryKernels(Cube *icube, Process &p, Table spkTable = cam->InstrumentPosition()->Cache("InstrumentPosition"); spkTable.Label() += PvlKeyword("Description", "Created by spiceinit"); spkTable.Label() += PvlKeyword("Kernels"); - for (int i=0; iWrite(spkTable); @@ -338,10 +341,10 @@ bool TryKernels(Cube *icube, Process &p, Table bodyTable = cam->BodyRotation()->Cache("BodyRotation"); bodyTable.Label() += PvlKeyword("Description", "Created by spiceinit"); bodyTable.Label() += PvlKeyword("Kernels"); - for (int i=0; iSolarLongitude()); @@ -350,7 +353,7 @@ bool TryKernels(Cube *icube, Process &p, Table sunTable = cam->SunPosition()->Cache("SunPosition"); sunTable.Label() += PvlKeyword("Description", "Created by spiceinit"); sunTable.Label() += PvlKeyword("Kernels"); - for (int i=0; iWrite(sunTable); @@ -361,15 +364,15 @@ bool TryKernels(Cube *icube, Process &p, PvlKeyword origTargPos = currentKernels["TargetPosition"]; currentKernels["InstrumentPointing"] = "Table"; - for (int i=0; iPutGroup(currentKernels); @@ -377,29 +380,35 @@ bool TryKernels(Cube *icube, Process &p, //modify Kernels group only else { Pvl *label = icube->Label(); - int i=0; - while (i < label->Objects()) { + int i = 0; + while(i < label->Objects()) { PvlObject currObj = label->Object(i); - if (currObj.IsNamed("Table")) { - if (currObj["Name"][0] == iString("InstrumentPointing")) { + if(currObj.IsNamed("Table")) { + if(currObj["Name"][0] == iString("InstrumentPointing")) { label->DeleteObject(i); - } else if (currObj["Name"][0] == iString("InstrumentPosition")) { + } + else if(currObj["Name"][0] == iString("InstrumentPosition")) { label->DeleteObject(i); - } else if (currObj["Name"][0] == iString("BodyRotation")) { + } + else if(currObj["Name"][0] == iString("BodyRotation")) { label->DeleteObject(i); - } else if (currObj["Name"][0] == iString("SunPosition")) { + } + else if(currObj["Name"][0] == iString("SunPosition")) { label->DeleteObject(i); - } else { + } + else { i++; } - } else { + } + else { i++; } } } p.WriteHistory(*icube); - } catch (iException &e) { + } + catch(iException &e) { e.Clear(); icube->PutGroup(originalKernels); return false; diff --git a/isis/src/base/apps/stats/stats.cpp b/isis/src/base/apps/stats/stats.cpp index 0b13910e55..b307895201 100644 --- a/isis/src/base/apps/stats/stats.cpp +++ b/isis/src/base/apps/stats/stats.cpp @@ -7,7 +7,7 @@ #include "Histogram.h" #include "Pvl.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { @@ -32,62 +32,64 @@ void IsisMain() { // Construct a label with the results PvlGroup results("Results"); - results += PvlKeyword ("From", icube->Filename()); - if (stats->ValidPixels() != 0) { - results += PvlKeyword("Average",stats->Average()); - results += PvlKeyword ("StandardDeviation", stats->StandardDeviation()); - results += PvlKeyword ("Variance", stats->Variance()); + results += PvlKeyword("From", icube->Filename()); + if(stats->ValidPixels() != 0) { + results += PvlKeyword("Average", stats->Average()); + results += PvlKeyword("StandardDeviation", stats->StandardDeviation()); + results += PvlKeyword("Variance", stats->Variance()); // These statistics only worked on a histogram - results += PvlKeyword ("Median", stats->Median()); - results += PvlKeyword ("Mode", stats->Mode()); - results += PvlKeyword ("Skew", stats->Skew()); - results += PvlKeyword ("Minimum", stats->Minimum()); - results += PvlKeyword ("Maximum", stats->Maximum()); - results += PvlKeyword ("Sum", stats->Sum()); + results += PvlKeyword("Median", stats->Median()); + results += PvlKeyword("Mode", stats->Mode()); + results += PvlKeyword("Skew", stats->Skew()); + results += PvlKeyword("Minimum", stats->Minimum()); + results += PvlKeyword("Maximum", stats->Maximum()); + results += PvlKeyword("Sum", stats->Sum()); } - results += PvlKeyword ("TotalPixels", stats->TotalPixels()); - results += PvlKeyword ("ValidPixels", stats->ValidPixels()); - results += PvlKeyword ("OverValidMaximumPixels", stats->OverRangePixels()); - results += PvlKeyword ("UnderValidMinimumPixels", stats->UnderRangePixels()); - results += PvlKeyword ("NullPixels", stats->NullPixels()); - results += PvlKeyword ("LisPixels", stats->LisPixels()); - results += PvlKeyword ("LrsPixels", stats->LrsPixels()); - results += PvlKeyword ("HisPixels", stats->HisPixels()); - results += PvlKeyword ("HrsPixels", stats->HrsPixels()); + results += PvlKeyword("TotalPixels", stats->TotalPixels()); + results += PvlKeyword("ValidPixels", stats->ValidPixels()); + results += PvlKeyword("OverValidMaximumPixels", stats->OverRangePixels()); + results += PvlKeyword("UnderValidMinimumPixels", stats->UnderRangePixels()); + results += PvlKeyword("NullPixels", stats->NullPixels()); + results += PvlKeyword("LisPixels", stats->LisPixels()); + results += PvlKeyword("LrsPixels", stats->LrsPixels()); + results += PvlKeyword("HisPixels", stats->HisPixels()); + results += PvlKeyword("HrsPixels", stats->HrsPixels()); // Write the results to the output file if the user specified one - if (ui.WasEntered("TO")) { + if(ui.WasEntered("TO")) { string outFile = Filename(ui.GetFilename("TO")).Expanded(); bool exists = Filename(outFile).Exists(); bool append = ui.GetBoolean("APPEND"); ofstream os; bool writeHeader = false; //write the results in the requested format. - if (ui.GetString("FORMAT") == "PVL") { + if(ui.GetString("FORMAT") == "PVL") { Pvl temp; temp.AddGroup(results); - if (append) { + if(append) { temp.Append(outFile); } else { temp.Write(outFile); } - } else { + } + else { //if the format was not PVL, write out a flat file. - if (append) { - os.open(outFile.c_str(),ios::app); - if (!exists) { + if(append) { + os.open(outFile.c_str(), ios::app); + if(!exists) { writeHeader = true; } - }else { - os.open(outFile.c_str(),ios::out); + } + else { + os.open(outFile.c_str(), ios::out); writeHeader = true; - } - } + } + } if(writeHeader) { for(int i = 0; i < results.Keywords(); i++) { os << results[i].Name(); - if(i < results.Keywords()-1) { + if(i < results.Keywords() - 1) { os << ","; } } @@ -95,7 +97,7 @@ void IsisMain() { } for(int i = 0; i < results.Keywords(); i++) { os << (string)results[i]; - if(i < results.Keywords()-1) { + if(i < results.Keywords() - 1) { os << ","; } } diff --git a/isis/src/base/apps/std2isis/std2isis.cpp b/isis/src/base/apps/std2isis/std2isis.cpp index 155cb13d84..3b5c9c4a00 100644 --- a/isis/src/base/apps/std2isis/std2isis.cpp +++ b/isis/src/base/apps/std2isis/std2isis.cpp @@ -21,9 +21,9 @@ double hrs_max = DBL_MIN; double lrs_min = DBL_MAX; double lrs_max = DBL_MIN; -void toGrayCube (Buffer &out); -void toRGBCube (Buffer &out); -void toARGBCube (Buffer &out); +void toGrayCube(Buffer &out); +void toRGBCube(Buffer &out); +void toARGBCube(Buffer &out); double TestSpecial(const double pixel); @@ -33,15 +33,15 @@ void IsisMain() { // Set special pixel ranges - if (ui.GetBoolean("SETNULLRANGE")) { + if(ui.GetBoolean("SETNULLRANGE")) { null_min = ui.GetDouble("NULLMIN"); null_max = ui.GetDouble("NULLMAX"); } - if (ui.GetBoolean("SETHRSRANGE")) { + if(ui.GetBoolean("SETHRSRANGE")) { hrs_min = ui.GetDouble("HRSMIN"); hrs_max = ui.GetDouble("HRSMAX"); } - if (ui.GetBoolean("SETLRSRANGE")) { + if(ui.GetBoolean("SETLRSRANGE")) { lrs_min = ui.GetDouble("LRSMIN"); lrs_max = ui.GetDouble("LRSMAX"); } @@ -68,19 +68,22 @@ void IsisMain() { bool is_signed = JP2_decoder->GetSignedData(); delete JP2_decoder; ProcessImport jp; - jp.SetDimensions(nsamps,nlines,nbands); - if (pixelbytes == 1) { + jp.SetDimensions(nsamps, nlines, nbands); + if(pixelbytes == 1) { jp.SetPixelType(Isis::UnsignedByte); - } else if (pixelbytes == 2) { - if (is_signed) { + } + else if(pixelbytes == 2) { + if(is_signed) { jp.SetPixelType(Isis::SignedWord); - } else { + } + else { jp.SetPixelType(Isis::UnsignedWord); } - } else { - throw iException::Message(iException::User, - "The file [" + ui.GetFilename("FROM") + "] contains unsupported data type.", - _FILEINFO_); + } + else { + throw iException::Message(iException::User, + "The file [" + ui.GetFilename("FROM") + "] contains unsupported data type.", + _FILEINFO_); } jp.SetInputFile(iString(ui.GetFilename("FROM"))); jp.SetOutputCube("TO"); @@ -88,38 +91,39 @@ void IsisMain() { jp.StartProcess(); jp.EndProcess(); } - catch (Isis::iException &e) { - throw iException::Message(iException::User, - "The file [" + ui.GetFilename("FROM") + "] does not contain a recognized image format.", - _FILEINFO_); + catch(Isis::iException &e) { + throw iException::Message(iException::User, + "The file [" + ui.GetFilename("FROM") + "] does not contain a recognized image format.", + _FILEINFO_); } - } else { + } + else { string mode = ui.GetString("MODE"); - if (mode == "AUTO") { - if (qimage->isGrayscale()) + if(mode == "AUTO") { + if(qimage->isGrayscale()) mode = "GRAYSCALE"; - else if (qimage->hasAlphaChannel()) + else if(qimage->hasAlphaChannel()) mode = "ARGB"; else mode = "RGB"; } - if (mode == "GRAYSCALE") { + if(mode == "GRAYSCALE") { Cube *outCube = p.SetOutputCube("TO", qimage->width(), qimage->height()); Pvl *label = outCube->Label(); - PvlGroup bandBin ("BandBin"); - PvlKeyword name ("Name"); + PvlGroup bandBin("BandBin"); + PvlKeyword name("Name"); name += "Gray"; bandBin += name; label->AddGroup(bandBin); p.StartProcess(toGrayCube); } - else if (mode == "RGB") { + else if(mode == "RGB") { Cube *outCube = p.SetOutputCube("TO", qimage->width(), qimage->height(), 3); Pvl *label = outCube->Label(); - PvlGroup bandBin ("BandBin"); - PvlKeyword name ("Name"); + PvlGroup bandBin("BandBin"); + PvlKeyword name("Name"); name += "Red"; name += "Green"; name += "Blue"; @@ -130,8 +134,8 @@ void IsisMain() { else { Cube *outCube = p.SetOutputCube("TO", qimage->width(), qimage->height(), 4); Pvl *label = outCube->Label(); - PvlGroup bandBin ("BandBin"); - PvlKeyword name ("Name"); + PvlGroup bandBin("BandBin"); + PvlKeyword name("Name"); name += "Red"; name += "Green"; name += "Blue"; @@ -140,112 +144,112 @@ void IsisMain() { label->AddGroup(bandBin); p.StartProcess(toARGBCube); } - + delete qimage; qimage = NULL; p.EndProcess(); } } -void toGrayCube (Buffer &out) { +void toGrayCube(Buffer &out) { for(int sample = 0; sample < out.SampleDimension(); sample ++) { double pixel = qGray(qimage->pixel(sample, line)); out[sample] = TestSpecial(pixel); } - line ++; + line ++; } -void toRGBCube (Buffer &out) { - if (band == 0) { - for(int sample = 0; sample < out.SampleDimension(); sample ++) { +void toRGBCube(Buffer &out) { + if(band == 0) { + for(int sample = 0; sample < out.SampleDimension(); sample ++) { double pixel = qRed(qimage->pixel(sample, line)); out[sample] = TestSpecial(pixel); } } - else if (band == 1) { - for(int sample = 0; sample < out.SampleDimension(); sample ++) { + else if(band == 1) { + for(int sample = 0; sample < out.SampleDimension(); sample ++) { double pixel = qGreen(qimage->pixel(sample, line)); out[sample] = TestSpecial(pixel); } } - else if (band == 2) { - for(int sample = 0; sample < out.SampleDimension(); sample ++) { + else if(band == 2) { + for(int sample = 0; sample < out.SampleDimension(); sample ++) { double pixel = qBlue(qimage->pixel(sample, line)); out[sample] = TestSpecial(pixel); } } else { string msg = "RGB cubes must have exactly three bands."; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } line++; - if (line == qimage->height()) { + if(line == qimage->height()) { line = 0; band++; } } -void toARGBCube (Buffer &out) { - if (band == 0) { - for(int sample = 0; sample < out.SampleDimension(); sample ++) { +void toARGBCube(Buffer &out) { + if(band == 0) { + for(int sample = 0; sample < out.SampleDimension(); sample ++) { double pixel = qRed(qimage->pixel(sample, line)); out[sample] = TestSpecial(pixel); } } - else if (band == 1) { - for(int sample = 0; sample < out.SampleDimension(); sample ++) { + else if(band == 1) { + for(int sample = 0; sample < out.SampleDimension(); sample ++) { double pixel = qGreen(qimage->pixel(sample, line)); out[sample] = TestSpecial(pixel); } } - else if (band == 2) { - for(int sample = 0; sample < out.SampleDimension(); sample ++) { + else if(band == 2) { + for(int sample = 0; sample < out.SampleDimension(); sample ++) { double pixel = qBlue(qimage->pixel(sample, line)); out[sample] = TestSpecial(pixel); } } - else if (band == 3) { - for(int sample = 0; sample < out.SampleDimension(); sample ++) { + else if(band == 3) { + for(int sample = 0; sample < out.SampleDimension(); sample ++) { double pixel = qAlpha(qimage->pixel(sample, line)); out[sample] = TestSpecial(pixel); } } else { string msg = "ARGB cubes must have exactly four bands."; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } line++; - if (line == qimage->height()) { + if(line == qimage->height()) { line = 0; band++; } } -/** +/** * Tests the pixel. If it is valid it will return the dn value, * otherwise it will return the Isis special pixel value that * corresponds to it - * + * * @param pixel The double precision value that represents a * pixel. * @return double The double precision value representing the * pixel will return as a valid dn or changed to an isis * special pixel. */ - double TestSpecial(const double pixel){ - if (pixel <= null_max && pixel >= null_min){ - return Isis::NULL8; - } - else if (pixel <= hrs_max && pixel >= hrs_min){ - return Isis::HIGH_REPR_SAT8; - } - else if (pixel <= lrs_max && pixel >= lrs_min){ - return Isis::LOW_REPR_SAT8; - } - else { - return pixel; - } +double TestSpecial(const double pixel) { + if(pixel <= null_max && pixel >= null_min) { + return Isis::NULL8; + } + else if(pixel <= hrs_max && pixel >= hrs_min) { + return Isis::HIGH_REPR_SAT8; + } + else if(pixel <= lrs_max && pixel >= lrs_min) { + return Isis::LOW_REPR_SAT8; } + else { + return pixel; + } +} diff --git a/isis/src/base/apps/stretch/stretch.cpp b/isis/src/base/apps/stretch/stretch.cpp index 044fc91e32..2b07654f8e 100644 --- a/isis/src/base/apps/stretch/stretch.cpp +++ b/isis/src/base/apps/stretch/stretch.cpp @@ -7,79 +7,77 @@ #include "PvlGroup.h" #include "PvlKeyword.h" -using namespace std; +using namespace std; using namespace Isis; -void stretch (Buffer &in, Buffer &out); +void stretch(Buffer &in, Buffer &out); Stretch str; Statistics stats; void IsisMain() { ProcessByLine p; - Cube* inCube = p.SetInputCube("FROM"); - + Cube *inCube = p.SetInputCube("FROM"); + UserInterface &ui = Application::GetUserInterface(); - + string pairs; // first just get the pairs from where ever and worry about // whether they are dn values or %'s later - if (ui.GetBoolean("READFILE")) { + if(ui.GetBoolean("READFILE")) { Filename pairsFileName = ui.GetFilename("INPUTFILE"); TextFile pairsFile; pairsFile.SetComment("#"); pairsFile.Open(pairsFileName.Expanded()); - + // concat all non-comment lines into one string (pairs) string line = ""; - while (pairsFile.GetLine(line, true)) { + while(pairsFile.GetLine(line, true)) { pairs += " " + line; } pairs += line; } else { - if (ui.WasEntered("PAIRS")) + if(ui.WasEntered("PAIRS")) pairs = ui.GetString("PAIRS"); } - if (ui.GetBoolean("USEPERCENTAGES")) + if(ui.GetBoolean("USEPERCENTAGES")) str.Parse(pairs, inCube->Histogram()); else str.Parse(pairs); // Setup new mappings for special pixels if necessary - if (ui.WasEntered("NULL")) + if(ui.WasEntered("NULL")) str.SetNull(StringToPixel(ui.GetString("NULL"))); - if (ui.WasEntered("LIS")) + if(ui.WasEntered("LIS")) str.SetLis(StringToPixel(ui.GetString("LIS"))); - if (ui.WasEntered("LRS")) + if(ui.WasEntered("LRS")) str.SetLrs(StringToPixel(ui.GetString("LRS"))); - if (ui.WasEntered("HIS")) - str.SetHis(StringToPixel(ui.GetString("HIS"))); - if (ui.WasEntered("HRS")) - str.SetHrs(StringToPixel(ui.GetString("HRS"))); + if(ui.WasEntered("HIS")) + str.SetHis(StringToPixel(ui.GetString("HIS"))); + if(ui.WasEntered("HRS")) + str.SetHrs(StringToPixel(ui.GetString("HRS"))); - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); // Start the processing p.StartProcess(stretch); p.EndProcess(); - + PvlKeyword dnPairs = PvlKeyword("StretchPairs"); dnPairs.AddValue(str.Text()); - + PvlGroup results = PvlGroup("Results"); results.AddKeyword(dnPairs); - + Application::Log(results); - + } // Line processing routine -void stretch (Buffer &in, Buffer &out) -{ - for (int i=0; i #include -using namespace std; +using namespace std; using namespace Isis; Table *table; @@ -54,19 +54,19 @@ void IsisMain() { void readTable(Isis::Buffer &outcube) { for(int record = startRecord; record < startRecord + numRecords; record ++) { for(int element = startElement; element < startElement + numElements; element ++) { - int index = (numElements * (record-1)) + (element - startElement); + int index = (numElements * (record - 1)) + (element - startElement); - if((*table)[record-1][field].IsReal()){ + if((*table)[record-1][field].IsReal()) { std::vector data = (*table)[record-1][field]; - outcube[index] = data.at(element-1); + outcube[index] = data.at(element - 1); } - else if((*table)[record-1][field].IsInteger()){ + else if((*table)[record-1][field].IsInteger()) { std::vector data = (*table)[record-1][field]; - outcube[index] = data.at(element-1); + outcube[index] = data.at(element - 1); } - else if((*table)[record-1][field].IsDouble()){ + else if((*table)[record-1][field].IsDouble()) { std::vector data = (*table)[record-1][field]; - outcube[index] = data.at(element-1); + outcube[index] = data.at(element - 1); } } } diff --git a/isis/src/base/apps/tabledump/tabledump.cpp b/isis/src/base/apps/tabledump/tabledump.cpp index 13807e81b7..5665939e6b 100644 --- a/isis/src/base/apps/tabledump/tabledump.cpp +++ b/isis/src/base/apps/tabledump/tabledump.cpp @@ -14,13 +14,13 @@ string previousFile = ""; void helperButtonGetTableList(); -map GuiHelpers(){ - map helper; - helper ["helperButtonGetTableList"] = (void*) helperButtonGetTableList; +map GuiHelpers() { + map helper; + helper ["helperButtonGetTableList"] = (void *) helperButtonGetTableList; return helper; } -void IsisMain(){ +void IsisMain() { // Gather parameters from the UserInterface UserInterface &ui = Application::GetUserInterface(); Filename file = ui.GetFilename("FROM"); @@ -29,10 +29,10 @@ void IsisMain(){ // Set the character to separate the entries string delimit; - if (ui.GetString("DELIMIT") == "COMMA") { + if(ui.GetString("DELIMIT") == "COMMA") { delimit = ","; } - else if (ui.GetString("DELIMIT") == "SPACE") { + else if(ui.GetString("DELIMIT") == "SPACE") { delimit = " "; } else { @@ -40,62 +40,62 @@ void IsisMain(){ } // Open the file and output the column headings - stringstream ss (stringstream::in | stringstream::out); + stringstream ss(stringstream::in | stringstream::out); - for (int i=0; i< table[0].Fields(); i++) { - for (int j=0; j 1) { + else if(table[0][i].Size() > 1) { title += "(" + iString(j) + ")"; } - if (i == table[0].Fields()-1 && j == table[0][i].Size()-1) { + if(i == table[0].Fields() - 1 && j == table[0][i].Size() - 1) { // We've reached the last field, omit the delimiter ss << title; } - else{ + else { ss << title + delimit; } } } // Loop through for each record - for (int i=0; i currField = table[i][j]; - for (int k=0; k<(int)currField.size(); k++) { + for(int k = 0; k < (int)currField.size(); k++) { // check to see that we aren't on either the last field, or // (if we are), we aren't on the last element of the field - if (j < table[i].Fields()-1 || - k < (int)currField.size()-1) { + if(j < table[i].Fields() - 1 || + k < (int)currField.size() - 1) { ss << currField[k] << delimit; } else { @@ -103,13 +103,13 @@ void IsisMain(){ } } } - else if (table[i][j].IsDouble()) { + else if(table[i][j].IsDouble()) { vector currField = table[i][j]; - for (int k=0; k<(int)currField.size(); k++) { + for(int k = 0; k < (int)currField.size(); k++) { // check to see that we aren't on either the last field, or // (if we are), we aren't on the last element of the field - if (j < table[i].Fields()-1 || - k < (int)currField.size()-1) { + if(j < table[i].Fields() - 1 || + k < (int)currField.size() - 1) { ss << currField[k] << delimit; } else { @@ -127,7 +127,7 @@ void IsisMain(){ outFile << ss.str(); outFile.close(); } - else if (ui.IsInteractive()){ + else if(ui.IsInteractive()) { std::string log = ss.str(); Application::GuiLog(log); } @@ -143,10 +143,10 @@ void helperButtonGetTableList() { UserInterface &ui = Application::GetUserInterface(); string currentFile = ui.GetFilename("FROM"); - const Pvl label (Filename(currentFile).Expanded()); + const Pvl label(Filename(currentFile).Expanded()); // Check to see if the "FILE" parameter has changed since last press - if (currentFile != previousFile) { + if(currentFile != previousFile) { ui.Clear("NAME"); pos = 0; previousFile = currentFile; @@ -154,21 +154,21 @@ void helperButtonGetTableList() { // Look for tables int cnt = 0; - while (!match) { + while(!match) { // If we've gone through all objects and found nothing, throw an exception - if (cnt >= label.Objects()) { + if(cnt >= label.Objects()) { pos = 0; string msg = "Parameter [FROM] has no tables."; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } // When the end of the objects is hit, display "NAME" parameter as blank - if (pos >= label.Objects()) { + if(pos >= label.Objects()) { list = ""; match = true; pos = 0; // Prepare to start over again } // When we find a table, fetch its name to stick in the "NAME" parameter - else if (label.Object(pos).Name() == "Table") { + else if(label.Object(pos).Name() == "Table") { list = label.Object(pos)["Name"][0].c_str(); match = true; pos++; @@ -181,5 +181,5 @@ void helperButtonGetTableList() { } ui.Clear("NAME"); - ui.PutString("NAME",list); + ui.PutString("NAME", list); } diff --git a/isis/src/base/apps/tonematch/tonematch.cpp b/isis/src/base/apps/tonematch/tonematch.cpp index 58ce002bc3..0f5f2f36ae 100644 --- a/isis/src/base/apps/tonematch/tonematch.cpp +++ b/isis/src/base/apps/tonematch/tonematch.cpp @@ -8,11 +8,11 @@ using namespace std; using namespace Isis; -void getStats (vector &in, vector &out); -void toneMatch (Buffer &in, Buffer &out); +void getStats(vector &in, vector &out); +void toneMatch(Buffer &in, Buffer &out); MultivariateStatistics stats; -double base,mult; +double base, mult; void IsisMain() { // We will be processing by line @@ -22,17 +22,17 @@ void IsisMain() { UserInterface &ui = Application::GetUserInterface(); // If the user selected pOverlap, get the projected overlap statistics - if (ui.GetBoolean("POVERLAP")) { + if(ui.GetBoolean("POVERLAP")) { // Set up the overlap statistics object - Cube from,match; + Cube from, match; from.Open(ui.GetFilename("FROM")); match.Open(ui.GetFilename("MATCH")); - OverlapStatistics oStats(from,match); + OverlapStatistics oStats(from, match); //Make sure the projections overlap - if (!oStats.HasOverlap()) { + if(!oStats.HasOverlap()) { string msg = "Input Cubes do not appear to overlap"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Get mvstat data for the overlapping area stats = oStats.GetMStats(1); @@ -40,32 +40,32 @@ void IsisMain() { // If the user didnt select pOverlap, get the stats of the entire cubes else { - // Setup the input cubes to match - p.SetInputCube("FROM",Isis::OneBand); - p.SetInputCube("MATCH",Isis::OneBand); + // Setup the input cubes to match + p.SetInputCube("FROM", Isis::OneBand); + p.SetInputCube("MATCH", Isis::OneBand); - // Get the statistics from the cubes - p.StartProcess(getStats); + // Get the statistics from the cubes + p.StartProcess(getStats); } // compute the linear regression fit of the mvstats data - stats.LinearRegression(base,mult); + stats.LinearRegression(base, mult); // Apply the correction p.ClearInputCubes(); p.SetInputCube("FROM"); - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); p.StartProcess(toneMatch); p.EndProcess(); } -void getStats (vector &in, vector &out) { - stats.AddData(in[0]->DoubleBuffer(),in[1]->DoubleBuffer(),in[0]->size()); +void getStats(vector &in, vector &out) { + stats.AddData(in[0]->DoubleBuffer(), in[1]->DoubleBuffer(), in[0]->size()); } -void toneMatch (Buffer &in, Buffer &out) { - for (int i=0; iSamples(), icube->Lines(), - ui.GetDouble("STRANS"), - ui.GetDouble("LTRANS")); + ui.GetDouble("STRANS"), + ui.GetDouble("LTRANS")); // Allocate the output file, same size as input - p.SetOutputCube ("TO",icube->Samples(),icube->Lines(),icube->Bands()); + p.SetOutputCube("TO", icube->Samples(), icube->Lines(), icube->Bands()); // Set up the interpolator Interpolator *interp; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } else { string msg = "Unknow value for INTERP [" + ui.GetString("INTERP") + "]"; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } p.StartProcess(*transform, *interp); diff --git a/isis/src/base/apps/translate/translate.h b/isis/src/base/apps/translate/translate.h index df9e28f28e..c710f3a3d2 100644 --- a/isis/src/base/apps/translate/translate.h +++ b/isis/src/base/apps/translate/translate.h @@ -15,8 +15,8 @@ class Translate : public Isis::Transform { public: // constructor - Translate (const double inputSamples, const double inputLines, - const double sampleTrans, const double lineTrans){ + Translate(const double inputSamples, const double inputLines, + const double sampleTrans, const double lineTrans) { // Save off the sample and line translation p_sampleTrans = sampleTrans; p_lineTrans = lineTrans; @@ -26,24 +26,24 @@ class Translate : public Isis::Transform { } // destructor - ~Translate () {}; + ~Translate() {}; // Implementations for parent's pure virtual members // Convert the requested output samp/line to an input samp/line - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { inSample = outSample - p_sampleTrans; inLine = outLine - p_lineTrans; return true; } // Return the output number of samples - int OutputSamples () const { + int OutputSamples() const { return p_outputSamples; } // Return the output number of lines - int OutputLines () const { + int OutputLines() const { return p_outputLines; } }; diff --git a/isis/src/base/apps/trim/trim.cpp b/isis/src/base/apps/trim/trim.cpp index 4caeb6cc5f..a73c584462 100644 --- a/isis/src/base/apps/trim/trim.cpp +++ b/isis/src/base/apps/trim/trim.cpp @@ -3,32 +3,32 @@ #include "SpecialPixel.h" #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; // Line processing routine -void trim (Buffer &in, Buffer &out); +void trim(Buffer &in, Buffer &out); + +int top, bottom, lleft, rright; -int top,bottom,lleft,rright; - void IsisMain() { // We will be processing by line ProcessByLine p; // Setup the input and output cubes Cube *icube = p.SetInputCube("FROM"); - p.SetOutputCube ("TO"); + p.SetOutputCube("TO"); // Override the defaults if the user entered a value UserInterface &ui = Application::GetUserInterface(); - top = ui.GetInteger ("TOP"); - bottom = ui.GetInteger ("BOTTOM"); - lleft = ui.GetInteger ("LEFT"); - rright = ui.GetInteger ("RIGHT"); + top = ui.GetInteger("TOP"); + bottom = ui.GetInteger("BOTTOM"); + lleft = ui.GetInteger("LEFT"); + rright = ui.GetInteger("RIGHT"); // Will anything be trimmed from the cube? bool notrim = false; - if (top == 0 && bottom == 0 && lleft == 0 && rright == 0) { + if(top == 0 && bottom == 0 && lleft == 0 && rright == 0) { notrim = true; } @@ -41,28 +41,27 @@ void IsisMain() { p.EndProcess(); //The user didn't trim anything - if (notrim == true) { + if(notrim == true) { string message = "No trimming was done-output equals input file"; - throw iException::Message(iException::User,message,_FILEINFO_); + throw iException::Message(iException::User, message, _FILEINFO_); } - + } // Line processing routine - void trim (Buffer &in,Buffer &out) - { +void trim(Buffer &in, Buffer &out) { // Test for line trim and NULL full line - if (in.Line () <= top || in.Line () > bottom) { - for (int i=0; i bottom) { + for(int i = 0; i < in.size(); i++) { out[i] = NULL8; } } else { - // Loop and test for sample trim - for (int i=0; i rright) { + // Loop and test for sample trim + for(int i = 0; i < in.size(); i++) { + if(in.Sample(i) <= lleft || in.Sample(i) > rright) { out[i] = NULL8; } else { diff --git a/isis/src/base/apps/trimfilter/trimfilter.cpp b/isis/src/base/apps/trimfilter/trimfilter.cpp index c4c3c5d4d4..e738c89a02 100644 --- a/isis/src/base/apps/trimfilter/trimfilter.cpp +++ b/isis/src/base/apps/trimfilter/trimfilter.cpp @@ -3,12 +3,12 @@ #include "UserInterface.h" #include "iException.h" -using namespace std; +using namespace std; using namespace Isis; // prototypes and globals bool trimmed; -void trimfilter (Buffer &in, Buffer &out, QuickFilter &filter); +void trimfilter(Buffer &in, Buffer &out, QuickFilter &filter); // The trimfilter main routine void IsisMain() { @@ -27,10 +27,10 @@ void IsisMain() { double low = -DBL_MAX; double high = DBL_MAX; int minimum; - if (ui.GetString("MINOPT") == "PERCENTAGE") { + if(ui.GetString("MINOPT") == "PERCENTAGE") { int size = lines * samples; double perc = ui.GetDouble("MINIMUM") / 100; - minimum = (int) (size * perc); + minimum = (int)(size * perc); } else { minimum = (int) ui.GetDouble("MINIMUM"); @@ -43,16 +43,16 @@ void IsisMain() { p.EndProcess(); // Cleanup // If trimming did not occur tell the user - if (!trimmed) { + if(!trimmed) { string msg = "Your selected parameters did not trim any data from the cube"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } } // Line processing routine -void trimfilter (Buffer &in, Buffer &out, QuickFilter &filter) { - for (int i=0; i= filter.MinimumPixels()) { +void trimfilter(Buffer &in, Buffer &out, QuickFilter &filter) { + for(int i = 0; i < filter.Samples(); i++) { + if(filter.Count(i) >= filter.MinimumPixels()) { out[i] = in[i]; } else { diff --git a/isis/src/base/apps/uncrop/uncrop.cpp b/isis/src/base/apps/uncrop/uncrop.cpp index 292aa10dd7..8b74ea3630 100644 --- a/isis/src/base/apps/uncrop/uncrop.cpp +++ b/isis/src/base/apps/uncrop/uncrop.cpp @@ -2,7 +2,7 @@ #include "ProcessMosaic.h" #include "AlphaCube.h" -using namespace std; +using namespace std; using namespace Isis; void IsisMain() { @@ -10,13 +10,13 @@ void IsisMain() { p.SetBandBinMatch(false); // Set the input cube for the process object - p.SetInputCube ("FROM"); + p.SetInputCube("FROM"); // Set up the mosaic priority UserInterface &ui = Application::GetUserInterface(); - string combineMethod = ui.GetString ("COMBINE"); + string combineMethod = ui.GetString("COMBINE"); MosaicPriority priority; - if (combineMethod == "PARENT") { + if(combineMethod == "PARENT") { priority = mosaic; } else { @@ -27,11 +27,11 @@ void IsisMain() { Pvl lab; lab.Read(ui.GetFilename("FROM")); AlphaCube acube(lab); - int outSample = (int) (acube.AlphaSample(0.5) + 0.5); - int outLine = (int) (acube.AlphaLine(0.5) + 0.5); - int outBand = 1; + int outSample = (int)(acube.AlphaSample(0.5) + 0.5); + int outLine = (int)(acube.AlphaLine(0.5) + 0.5); + int outBand = 1; - p.SetOutputCube ("PARENT"); + p.SetOutputCube("PARENT"); p.StartProcess(outSample, outLine, outBand, priority); p.EndProcess(); diff --git a/isis/src/base/apps/vicar2isis/vicar2isis.cpp b/isis/src/base/apps/vicar2isis/vicar2isis.cpp index b684bcbb26..55fe37a019 100644 --- a/isis/src/base/apps/vicar2isis/vicar2isis.cpp +++ b/isis/src/base/apps/vicar2isis/vicar2isis.cpp @@ -3,31 +3,30 @@ #include "UserInterface.h" #include "Pvl.h" -using namespace std; +using namespace std; using namespace Isis; -void IsisMain () -{ - UserInterface &ui = Application::GetUserInterface (); +void IsisMain() { + UserInterface &ui = Application::GetUserInterface(); ProcessImportVicar p; // Set Special Pixel ranges - if (ui.GetBoolean("SETNULLRANGE")) { - p.SetNull(ui.GetDouble("NULLMIN"),ui.GetDouble("NULLMAX")); + if(ui.GetBoolean("SETNULLRANGE")) { + p.SetNull(ui.GetDouble("NULLMIN"), ui.GetDouble("NULLMAX")); } - if (ui.GetBoolean("SETHRSRANGE")) { - p.SetHRS(ui.GetDouble("HRSMIN"),ui.GetDouble("HRSMAX")); + if(ui.GetBoolean("SETHRSRANGE")) { + p.SetHRS(ui.GetDouble("HRSMIN"), ui.GetDouble("HRSMAX")); } - if (ui.GetBoolean("SETLRSRANGE")) { - p.SetLRS(ui.GetDouble("LRSMIN"),ui.GetDouble("LRSMAX")); + if(ui.GetBoolean("SETLRSRANGE")) { + p.SetLRS(ui.GetDouble("LRSMIN"), ui.GetDouble("LRSMAX")); } Pvl vicLab; - p.SetVicarFile(ui.GetFilename ("FROM"),vicLab); + p.SetVicarFile(ui.GetFilename("FROM"), vicLab); p.SetOutputCube("TO"); - p.StartProcess (); - p.EndProcess (); + p.StartProcess(); + p.EndProcess(); return; } diff --git a/isis/src/base/apps/warp/WarpTransform.cpp b/isis/src/base/apps/warp/WarpTransform.cpp index b5e2f393f7..afad241f32 100644 --- a/isis/src/base/apps/warp/WarpTransform.cpp +++ b/isis/src/base/apps/warp/WarpTransform.cpp @@ -4,130 +4,130 @@ #include "WarpTransform.h" namespace Isis { - WarpTransform::WarpTransform(BasisFunction &basisLine, - BasisFunction &basisSamp, bool weighted, std::vector &inputLine, - std::vector &inputSample, std::vector &outputLine, - std::vector &outputSample, int inputLines, int inputSamples, - int outputLines, int outputSamples) { + WarpTransform::WarpTransform(BasisFunction &basisLine, + BasisFunction &basisSamp, bool weighted, std::vector &inputLine, + std::vector &inputSample, std::vector &outputLine, + std::vector &outputSample, int inputLines, int inputSamples, + int outputLines, int outputSamples) { // Determine the size of the output cube if necessary // We do this by solving for output position given an input position // then walk the edge of the input file to find the maximum output // line/sample - if ((outputLines == 0) || (outputSamples == 0)) { + if((outputLines == 0) || (outputSamples == 0)) { LeastSquares lsqOutputLine(basisLine); LeastSquares lsqOutputSamp(basisSamp); std::vector known; known.resize(2); - for (int i=0; i<(int)inputLine.size(); i++) { + for(int i = 0; i < (int)inputLine.size(); i++) { known[0] = inputLine[i]; known[1] = inputSample[i]; - lsqOutputLine.AddKnown(known,outputLine[i]); - lsqOutputSamp.AddKnown(known,outputSample[i]); + lsqOutputLine.AddKnown(known, outputLine[i]); + lsqOutputSamp.AddKnown(known, outputSample[i]); } - + lsqOutputLine.Solve(); lsqOutputSamp.Solve(); - + outputLines = 0; outputSamples = 0; // Walk top and bottom edge - for (int samp=1; samp<=inputSamples; samp++) { + for(int samp = 1; samp <= inputSamples; samp++) { known[0] = 1.0; known[1] = samp; - int oline = (int) (lsqOutputLine.Evaluate(known) + 0.5); - int osamp = (int) (lsqOutputSamp.Evaluate(known) + 0.5); - if (oline > outputLines) outputLines = oline; - if (osamp > outputSamples) outputSamples = osamp; - + int oline = (int)(lsqOutputLine.Evaluate(known) + 0.5); + int osamp = (int)(lsqOutputSamp.Evaluate(known) + 0.5); + if(oline > outputLines) outputLines = oline; + if(osamp > outputSamples) outputSamples = osamp; + known[0] = inputLines; known[1] = samp; - oline = (int) (lsqOutputLine.Evaluate(known) + 0.5); - osamp = (int) (lsqOutputSamp.Evaluate(known) + 0.5); - if (oline > outputLines) outputLines = oline; - if (osamp > outputSamples) outputSamples = osamp; + oline = (int)(lsqOutputLine.Evaluate(known) + 0.5); + osamp = (int)(lsqOutputSamp.Evaluate(known) + 0.5); + if(oline > outputLines) outputLines = oline; + if(osamp > outputSamples) outputSamples = osamp; } - + // Walk left and right edge - for (int line=1; line<=inputLines; line++) { + for(int line = 1; line <= inputLines; line++) { known[0] = line; known[1] = 1.0; - int oline = (int) (lsqOutputLine.Evaluate(known) + 0.5); - int osamp = (int) (lsqOutputSamp.Evaluate(known) + 0.5); - if (oline > outputLines) outputLines = oline; - if (osamp > outputSamples) outputSamples = osamp; - + int oline = (int)(lsqOutputLine.Evaluate(known) + 0.5); + int osamp = (int)(lsqOutputSamp.Evaluate(known) + 0.5); + if(oline > outputLines) outputLines = oline; + if(osamp > outputSamples) outputSamples = osamp; + known[0] = line; known[1] = inputSamples; - oline = (int) (lsqOutputLine.Evaluate(known) + 0.5); - osamp = (int) (lsqOutputSamp.Evaluate(known) + 0.5); - if (oline > outputLines) outputLines = oline; - if (osamp > outputSamples) outputSamples = osamp; + oline = (int)(lsqOutputLine.Evaluate(known) + 0.5); + osamp = (int)(lsqOutputSamp.Evaluate(known) + 0.5); + if(oline > outputLines) outputLines = oline; + if(osamp > outputSamples) outputSamples = osamp; } } - + p_outputLines = outputLines; p_outputSamples = outputSamples; - + // Create the equations for the control points using a least squares fit p_lsqInputSamp = new LeastSquares(basisSamp); p_lsqInputLine = new LeastSquares(basisLine); std::vector known; known.resize(2); - for (int i=0; i<(int)inputLine.size(); i++) { + for(int i = 0; i < (int)inputLine.size(); i++) { known[0] = outputLine[i]; known[1] = outputSample[i]; - p_lsqInputLine->AddKnown(known,inputLine[i]); - p_lsqInputSamp->AddKnown(known,inputSample[i]); + p_lsqInputLine->AddKnown(known, inputLine[i]); + p_lsqInputSamp->AddKnown(known, inputSample[i]); } - + p_lsqInputLine->Solve(); p_lsqInputSamp->Solve(); - + p_weighted = weighted; - if (weighted) { + if(weighted) { p_outputLine = outputLine; p_outputSample = outputSample; } } - + WarpTransform::~WarpTransform() { - if (p_lsqInputLine != NULL) delete p_lsqInputLine; - if (p_lsqInputSamp != NULL) delete p_lsqInputSamp; + if(p_lsqInputLine != NULL) delete p_lsqInputLine; + if(p_lsqInputSamp != NULL) delete p_lsqInputSamp; } - - + + // Convert the requested output samp/line to an input samp/line - bool WarpTransform::Xform (double &inSample, double &inLine, - const double outSample, const double outLine) { - if (p_weighted) { - for (int i=0; i<(int) p_outputLine.size(); i++) { + bool WarpTransform::Xform(double &inSample, double &inLine, + const double outSample, const double outLine) { + if(p_weighted) { + for(int i = 0; i < (int) p_outputLine.size(); i++) { double dist = (outLine - p_outputLine[i]) * (outLine - p_outputLine[i]) + (outSample - p_outputSample[i]) * (outSample - p_outputSample[i]); dist = sqrt(dist); double weight = 1.0; - if (dist >= 0.001) weight = 1.0 / dist; - p_lsqInputLine->Weight(i,weight); - p_lsqInputSamp->Weight(i,weight); + if(dist >= 0.001) weight = 1.0 / dist; + p_lsqInputLine->Weight(i, weight); + p_lsqInputSamp->Weight(i, weight); } p_lsqInputLine->Solve(); p_lsqInputSamp->Solve(); } - + static std::vector vars; - if (vars.size() != 2) vars.resize(2); + if(vars.size() != 2) vars.resize(2); vars[0] = outLine; vars[1] = outSample; inLine = p_lsqInputLine->Evaluate(vars); inSample = p_lsqInputSamp->Evaluate(vars); return true; } - - PvlGroup WarpTransform::Residuals () { + + PvlGroup WarpTransform::Residuals() { PvlGroup errs("Residuals"); - for (int i=0; iKnowns(); i++) { - PvlKeyword p("POINT"+iString(i+1)); + for(int i = 0; i < p_lsqInputLine->Knowns(); i++) { + PvlKeyword p("POINT" + iString(i + 1)); p += p_lsqInputLine->Residual(i); p += p_lsqInputSamp->Residual(i); errs += p; diff --git a/isis/src/base/apps/warp/WarpTransform.h b/isis/src/base/apps/warp/WarpTransform.h index b090e3ba78..bd91d0f88f 100644 --- a/isis/src/base/apps/warp/WarpTransform.h +++ b/isis/src/base/apps/warp/WarpTransform.h @@ -8,28 +8,32 @@ #include "PvlGroup.h" namespace Isis { -class WarpTransform : public Transform { + class WarpTransform : public Transform { public: - WarpTransform(Isis::BasisFunction &basisLine, - Isis::BasisFunction &basisSamp, bool weighted, - std::vector &inputLine, std::vector &inputSample, - std::vector &outputLine, std::vector &outputSample, - int inputLines, int inputSamples, int outputLines, int outputSamples); + WarpTransform(Isis::BasisFunction &basisLine, + Isis::BasisFunction &basisSamp, bool weighted, + std::vector &inputLine, std::vector &inputSample, + std::vector &outputLine, std::vector &outputSample, + int inputLines, int inputSamples, int outputLines, int outputSamples); ~WarpTransform(); - + // Implementations for parent's pure virtual members - bool Xform (double &inSample, double &inLine, - const double outSample, const double outLine); - int OutputSamples () const { return p_outputSamples; }; - int OutputLines () const { return p_outputLines; }; + bool Xform(double &inSample, double &inLine, + const double outSample, const double outLine); + int OutputSamples() const { + return p_outputSamples; + }; + int OutputLines() const { + return p_outputLines; + }; Isis::PvlGroup Residuals(); - + private: int p_outputSamples; int p_outputLines; Isis::LeastSquares *p_lsqInputLine; Isis::LeastSquares *p_lsqInputSamp; - + std::vector p_outputLine; std::vector p_outputSample; bool p_weighted; diff --git a/isis/src/base/apps/warp/warp.cpp b/isis/src/base/apps/warp/warp.cpp index f134da939c..8ff2bda6f0 100644 --- a/isis/src/base/apps/warp/warp.cpp +++ b/isis/src/base/apps/warp/warp.cpp @@ -11,7 +11,7 @@ using namespace std; using namespace Isis; - + void IsisMain() { // Warp an image ProcessRubberSheet p; @@ -21,14 +21,14 @@ void IsisMain() { string cfile = ui.GetFilename("CONTROL"); ControlNet cn(cfile); - vector inputLine,inputSample,outputLine,outputSample; - for (int i=0; i inputLine, inputSample, outputLine, outputSample; + for(int i = 0; i < cn.Size(); i++) { ControlPoint cp = cn[i]; - if (cp.Size() != 2) { + if(cp.Size() != 2) { string msg = "Control points must have exactly 2 control measures"; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } - if (!cp.Ignore()) { + if(!cp.Ignore()) { inputLine.push_back(cp[0].Line()); inputSample.push_back(cp[0].Sample()); outputLine.push_back(cp[1].Line()); @@ -38,24 +38,24 @@ void IsisMain() { // If there are no valid control points, // throw an error - if (inputLine.size() < 1) { + if(inputLine.size() < 1) { string msg = "The specified Control Network is empty."; - throw Isis::iException::Message(Isis::iException::User,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::User, msg, _FILEINFO_); } // Open the input cube Cube *icube = p.SetInputCube("FROM"); // Determine the size of the output cube - int onl,ons; - if (ui.GetString("OSIZE") == "MATCH") { + int onl, ons; + if(ui.GetString("OSIZE") == "MATCH") { Cube c; - c.Open(iString(ui.GetFilename("CUBE")),"r"); + c.Open(iString(ui.GetFilename("CUBE")), "r"); onl = c.Lines(); ons = c.Samples(); c.Close(); } - else if (ui.GetString("OSIZE") == "COMPUTE") { + else if(ui.GetString("OSIZE") == "COMPUTE") { onl = 0; ons = 0; } @@ -71,32 +71,32 @@ void IsisMain() { bool weighted = ui.GetBoolean("WEIGHTED"); // Set up the transform object - WarpTransform *transform = new WarpTransform(*basisLine,*basisSamp,weighted, - inputLine,inputSample, - outputLine,outputSample, - icube->Lines(),icube->Samples(), - onl,ons); + WarpTransform *transform = new WarpTransform(*basisLine, *basisSamp, weighted, + inputLine, inputSample, + outputLine, outputSample, + icube->Lines(), icube->Samples(), + onl, ons); // Allocate the output file, same size as input - p.SetOutputCube ("TO",transform->OutputSamples(), - transform->OutputLines(), - icube->Bands()); + p.SetOutputCube("TO", transform->OutputSamples(), + transform->OutputLines(), + icube->Bands()); // Set up the interpolator Interpolator *interp; - if (ui.GetString("INTERP") == "NEARESTNEIGHBOR") { + if(ui.GetString("INTERP") == "NEARESTNEIGHBOR") { interp = new Interpolator(Interpolator::NearestNeighborType); } - else if (ui.GetString("INTERP") == "BILINEAR") { + else if(ui.GetString("INTERP") == "BILINEAR") { interp = new Interpolator(Interpolator::BiLinearType); } - else if (ui.GetString("INTERP") == "CUBICCONVOLUTION") { + else if(ui.GetString("INTERP") == "CUBICCONVOLUTION") { interp = new Interpolator(Interpolator::CubicConvolutionType); } else { string msg = "Unknow value for INTERP [" + ui.GetString("INTERP") + "]"; - throw Isis::iException::Message(Isis::iException::Programmer,msg,_FILEINFO_); + throw Isis::iException::Message(Isis::iException::Programmer, msg, _FILEINFO_); } p.StartProcess(*transform, *interp); diff --git a/isis/src/base/objs/AdaptiveGruen/AdaptiveGruen.cpp b/isis/src/base/objs/AdaptiveGruen/AdaptiveGruen.cpp index 6329d54a07..841f44e480 100644 --- a/isis/src/base/objs/AdaptiveGruen/AdaptiveGruen.cpp +++ b/isis/src/base/objs/AdaptiveGruen/AdaptiveGruen.cpp @@ -1,35 +1,35 @@ -/** - * @file - * $Revision: 1.1 $ - * $Date: 2009/09/09 23:42:41 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.1 $ + * $Date: 2009/09/09 23:42:41 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include "AdaptiveGruen.h" /** * @brief AdaptiveGruen algorithm entry point for the plugin - * + * * @param pvl Input registration config file containing algorithm parameters * @return Isis::AutoReg* Returns a pointer to the plugin registration object */ -extern "C" Isis::AutoReg *AdaptiveGruenPlugin (Isis::Pvl &pvl) { +extern "C" Isis::AutoReg *AdaptiveGruenPlugin(Isis::Pvl &pvl) { return new Isis::AdaptiveGruen(pvl); } diff --git a/isis/src/base/objs/AdaptiveGruen/AdaptiveGruen.h b/isis/src/base/objs/AdaptiveGruen/AdaptiveGruen.h index 9bc613e127..3115f0c007 100644 --- a/isis/src/base/objs/AdaptiveGruen/AdaptiveGruen.h +++ b/isis/src/base/objs/AdaptiveGruen/AdaptiveGruen.h @@ -1,75 +1,79 @@ #if !defined(AdaptiveGruen_h) #define AdaptiveGruen_h -/** - * @file - * $Revision: 1.1 $ - * $Date: 2009/09/09 23:42:41 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.1 $ + * $Date: 2009/09/09 23:42:41 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include "Gruen.h" namespace Isis { class Pvl; - /** - * @brief Gruen (adaptive) pattern matching - * - * The AdaptiveGruen pattern/search chip registration algorithm is derived - * from the Gruen class. It is adaptive in that it uses an Affine transform - * to load the subsearch chip from the search chip. The Affine transform is - * iteratively minimized to converge on an cummulative affine solution that + /** + * @brief Gruen (adaptive) pattern matching + * + * The AdaptiveGruen pattern/search chip registration algorithm is derived + * from the Gruen class. It is adaptive in that it uses an Affine transform + * to load the subsearch chip from the search chip. The Affine transform is + * iteratively minimized to converge on an cummulative affine solution that * best matches the pattern chip. - * + * * @ingroup PatternMatching - * + * * @see Gruen AutoReg MinimumGruen - * + * * @author 2009-09-09 Kris Becker - * + * * @internal - */ + */ class AdaptiveGruen : public Gruen { public: /** * @brief Construct a AdaptiveGruen search algorithm - * - * This will construct an AdaptiveGruen search algorithm. It is - * recommended that you use a AutoRegFactory class as opposed to this - * constructor - * + * + * This will construct an AdaptiveGruen search algorithm. It is + * recommended that you use a AutoRegFactory class as opposed to this + * constructor + * * @param pvl A Pvl object that contains a valid automatic registration * definition */ - AdaptiveGruen (Pvl &pvl) : Gruen(pvl) { } + AdaptiveGruen(Pvl &pvl) : Gruen(pvl) { } /** Destructor for AdaptiveGruen */ virtual ~AdaptiveGruen() {} /** * AdaptiveGruen is adaptive - */ - virtual bool IsAdaptive() { return (true); } + */ + virtual bool IsAdaptive() { + return (true); + } protected: /** Return name of Algorithm */ - virtual std::string AlgorithmName() const {return ("AdaptiveGruen");} + virtual std::string AlgorithmName() const { + return ("AdaptiveGruen"); + } }; diff --git a/isis/src/base/objs/AdaptiveGruen/unitTest.cpp b/isis/src/base/objs/AdaptiveGruen/unitTest.cpp index 9e996f57f5..f7fa00f233 100644 --- a/isis/src/base/objs/AdaptiveGruen/unitTest.cpp +++ b/isis/src/base/objs/AdaptiveGruen/unitTest.cpp @@ -11,60 +11,60 @@ using namespace Isis; -int main () { +int main() { Isis::Preference::Preferences(true); try { - PvlGroup alg("Algorithm"); - alg += PvlKeyword("Name","AdaptiveGruen"); - alg += PvlKeyword("Tolerance",100.0); - alg += PvlKeyword("AffineTranslationTolerance",0.2); - alg += PvlKeyword("AffineScaleTolerance",0.7); - alg += PvlKeyword("MaximumIterations",30); + PvlGroup alg("Algorithm"); + alg += PvlKeyword("Name", "AdaptiveGruen"); + alg += PvlKeyword("Tolerance", 100.0); + alg += PvlKeyword("AffineTranslationTolerance", 0.2); + alg += PvlKeyword("AffineScaleTolerance", 0.7); + alg += PvlKeyword("MaximumIterations", 30); - PvlGroup pchip("PatternChip"); - pchip += PvlKeyword("Samples",15); - pchip += PvlKeyword("Lines",15); + PvlGroup pchip("PatternChip"); + pchip += PvlKeyword("Samples", 15); + pchip += PvlKeyword("Lines", 15); - PvlGroup schip("SearchChip"); - schip += PvlKeyword("Samples",30); - schip += PvlKeyword("Lines",30); + PvlGroup schip("SearchChip"); + schip += PvlKeyword("Samples", 30); + schip += PvlKeyword("Lines", 30); - PvlObject o("AutoRegistration"); - o.AddGroup(alg); - o.AddGroup(pchip); - o.AddGroup(schip); + PvlObject o("AutoRegistration"); + o.AddGroup(alg); + o.AddGroup(pchip); + o.AddGroup(schip); - Pvl pvl; - pvl.AddObject(o); - std::cout << pvl << std::endl; + Pvl pvl; + pvl.AddObject(o); + std::cout << pvl << std::endl; - AutoReg *ar = AutoRegFactory::Create(pvl); + AutoReg *ar = AutoRegFactory::Create(pvl); - Cube p; - p.Open("$messenger/testData/EW0131770376G.equi.cub"); + Cube p; + p.Open("$messenger/testData/EW0131770376G.equi.cub"); - Cube s; - s.Open("$messenger/testData/EW0131770381F.equi.cub"); + Cube s; + s.Open("$messenger/testData/EW0131770381F.equi.cub"); - ar->SearchChip()->TackCube(512.0, 512.0); - ar->SearchChip()->Load(s); - ar->PatternChip()->TackCube(512.0, 512.0); - ar->PatternChip()->Load(p); + ar->SearchChip()->TackCube(512.0, 512.0); + ar->SearchChip()->Load(s); + ar->PatternChip()->TackCube(512.0, 512.0); + ar->PatternChip()->Load(p); - std::cout << "Register = " << ar->Register() << std::endl; - std::cout << "Position = " << ar->CubeSample() << " " << - ar->CubeLine() << std::endl; + std::cout << "Register = " << ar->Register() << std::endl; + std::cout << "Position = " << ar->CubeSample() << " " << + ar->CubeLine() << std::endl; #if defined(FULL_DISCLOSURE) - Pvl pstat = ar->RegistrationStatistics(); - std::cout << "\n\n" << pstat << std::endl; + Pvl pstat = ar->RegistrationStatistics(); + std::cout << "\n\n" << pstat << std::endl; #endif - + } - catch (iException &e) { + catch(iException &e) { e.Report(); } diff --git a/isis/src/base/objs/Affine/Affine.cpp b/isis/src/base/objs/Affine/Affine.cpp index 6c31db79a6..ffbfc50c5c 100644 --- a/isis/src/base/objs/Affine/Affine.cpp +++ b/isis/src/base/objs/Affine/Affine.cpp @@ -1,24 +1,24 @@ -/** - * @file - * $Revision: 1.7 $ - * $Date: 2009/12/22 02:09:54 $ - * +/** + * @file + * $Revision: 1.7 $ + * $Date: 2009/12/22 02:09:54 $ + * * Unless noted otherwise, the portions of Isis written by the USGS are public - * domain. See individual third-party library and package descriptions for + * domain. See individual third-party library and package descriptions for * intellectual property information,user agreements, and related information. - * + * * Although Isis has been used by the USGS, no warranty, expressed or implied, - * is made by the USGS as to the accuracy and functioning of such software - * and related material nor shall the fact of distribution constitute any such - * warranty, and no responsibility is assumed by the USGS in connection - * therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see - * the Privacy & Disclaimers page on the Isis website, + * is made by the USGS as to the accuracy and functioning of such software + * and related material nor shall the fact of distribution constitute any such + * warranty, and no responsibility is assumed by the USGS in connection + * therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see + * the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include #include @@ -35,23 +35,23 @@ using namespace std; namespace Isis { /** - * Constructs an Affine transform. The default transform is - * the identity. + * Constructs an Affine transform. The default transform is + * the identity. */ - Affine::Affine () { + Affine::Affine() { Identity(); p_x = p_y = p_xp = p_yp = 0.0; } /** - * @brief Create Affine transform from matrix - * - * This constructor creates the affine transform from a forward matrix. The - * input matrix is checked for the proper dimensions (3x3) and is then - * inverted to complete the inverse functionality. - * - * The input matrix must be invertable or an exception will be thrown! - * + * @brief Create Affine transform from matrix + * + * This constructor creates the affine transform from a forward matrix. The + * input matrix is checked for the proper dimensions (3x3) and is then + * inverted to complete the inverse functionality. + * + * The input matrix must be invertable or an exception will be thrown! + * * @param a Forward affine matrix */ Affine::Affine(const Affine::AMatrix &a) { @@ -66,19 +66,19 @@ namespace Isis { /** * @brief Return an Affine identity matrix - * + * * @return Affine::AMatrix The identity matrix */ Affine::AMatrix Affine::getIdentity() { - AMatrix ident(3,3, 0.0); - for (int i = 0 ; i < ident.dim2() ; i++) { + AMatrix ident(3, 3, 0.0); + for(int i = 0 ; i < ident.dim2() ; i++) { ident[i][i] = 1.0; } return (ident); } /** - * Set the forward and inverse affine transform to the identity. + * Set the forward and inverse affine transform to the identity. * That is, xp = x and yp = y for all (x,y). */ void Affine::Identity() { @@ -86,22 +86,22 @@ namespace Isis { p_invmat = getIdentity(); } - /** + /** * Given a set of coordinate pairs (n >= 3), compute the affine - * transform that best fits the points. If given exactly three + * transform that best fits the points. If given exactly three * coordinates that are not colinear, the fit will be guarenteed - * to be exact through the points. - * + * to be exact through the points. + * * @param x The transformation x coordinates * @param y The transformation y coordinates * @param xp The transformation xp coordinates * @param yp The transformation yp coordinates * @param n The number of coordiante pairs - * + * * @throws Isis::iException::Math - Affine transform not invertible */ - void Affine::Solve (const double x[], const double y[], - const double xp[], const double yp[], int n) { + void Affine::Solve(const double x[], const double y[], + const double xp[], const double yp[], int n) { // We must solve two least squares equations PolynomialBivariate xpFunc(1); PolynomialBivariate ypFunc(1); @@ -109,12 +109,12 @@ namespace Isis { LeastSquares ypLSQ(ypFunc); // Push the knowns into the least squares class - for (int i=0; i coord(2); coord[0] = x[i]; coord[1] = y[i]; - xpLSQ.AddKnown(coord,xp[i]); - ypLSQ.AddKnown(coord,yp[i]); + xpLSQ.AddKnown(coord, xp[i]); + ypLSQ.AddKnown(coord, yp[i]); } // Solve for A,B,C,D,E,F @@ -138,25 +138,25 @@ namespace Isis { /** * Apply a translation to the current affine transform - * + * * @param tx translatation to add to x' * @param ty translation to add to y' */ - void Affine::Translate (double tx, double ty) { + void Affine::Translate(double tx, double ty) { AMatrix trans = getIdentity(); trans[0][2] = tx; trans[1][2] = ty; - p_matrix = TNT::matmult(trans,p_matrix); - + p_matrix = TNT::matmult(trans, p_matrix); + trans[0][2] = -tx; trans[1][2] = -ty; - p_invmat = TNT::matmult(p_invmat,trans); + p_invmat = TNT::matmult(p_invmat, trans); } /** * Apply a translation to the current affine transform - * + * * @param angle degrees of counterclockwise rotation */ void Affine::Rotate(double angle) { @@ -167,36 +167,36 @@ namespace Isis { rot[0][1] = -sin(angleRadians); rot[1][0] = sin(angleRadians); rot[1][1] = cos(angleRadians); - p_matrix = TNT::matmult(rot,p_matrix); + p_matrix = TNT::matmult(rot, p_matrix); angleRadians = -angleRadians; rot[0][0] = cos(angleRadians); rot[0][1] = -sin(angleRadians); rot[1][0] = sin(angleRadians); rot[1][1] = cos(angleRadians); - p_invmat = TNT::matmult(p_invmat,rot); + p_invmat = TNT::matmult(p_invmat, rot); } /** * Apply a scale to the current affine transform - * + * * @param scaleFactor The scale factor */ - void Affine::Scale (double scaleFactor) { + void Affine::Scale(double scaleFactor) { AMatrix scale = getIdentity(); scale[0][0] = scaleFactor; scale[1][1] = scaleFactor; - p_matrix = TNT::matmult(scale,p_matrix); - + p_matrix = TNT::matmult(scale, p_matrix); + scale[0][0] = scaleFactor; scale[1][1] = scaleFactor; - p_invmat = TNT::matmult(p_invmat,scale); + p_invmat = TNT::matmult(p_invmat, scale); } /** * Compute (xp,yp) given (x,y). Use the methods xp() and yp() to - * obtain the results. - * + * obtain the results. + * * @param x The transformation x factor * @param y The transformation y factor */ @@ -209,8 +209,8 @@ namespace Isis { /** * Compute (x,y) given (xp,yp). Use the methods x() and y() to - * obtain the results. - * + * obtain the results. + * * @param xp The inverse transformation xp factor * @param yp The inverse transformation yp factor */ @@ -220,15 +220,15 @@ namespace Isis { p_x = p_invmat[0][0] * xp + p_invmat[0][1] * yp + p_invmat[0][2]; p_y = p_invmat[1][0] * xp + p_invmat[1][1] * yp + p_invmat[1][2]; } - + /** * Return the affine coeffients for the entered variable (1 or 2). The coefficients - * are returned in a 3-dimensional vector - * + * are returned in a 3-dimensional vector + * * @param var The coefficient vector index (1 or 2) */ - vector Affine::Coefficients( int var ) { - int index = var-1; + vector Affine::Coefficients(int var) { + int index = var - 1; vector coef; coef.push_back(p_matrix[index][0]); coef.push_back(p_matrix[index][1]); @@ -238,26 +238,26 @@ namespace Isis { /** * Return the inverse affine coeffients for the entered variable (1 or 2). - * The coefficients are returned in a 3-dimensional vector - * + * The coefficients are returned in a 3-dimensional vector + * * @param var The inverse coefficient vector index */ - vector Affine::InverseCoefficients( int var ) { - int index = var-1; - vector coef; - coef.push_back(p_invmat[index][0]); - coef.push_back(p_invmat[index][1]); - coef.push_back(p_invmat[index][2]); - return coef; - } + vector Affine::InverseCoefficients(int var) { + int index = var - 1; + vector coef; + coef.push_back(p_invmat[index][0]); + coef.push_back(p_invmat[index][1]); + coef.push_back(p_invmat[index][2]); + return coef; + } /** - * @brief Checks affine matrix to ensure it is a 3x3 standard form transform - * + * @brief Checks affine matrix to ensure it is a 3x3 standard form transform + * * @param am Affine matrix to validate */ - void Affine::checkDims(const AMatrix &am) const throw (iException &) { - if ((am.dim1() != 3) && (am.dim2() != 3)) { + void Affine::checkDims(const AMatrix &am) const throw(iException &) { + if((am.dim1() != 3) && (am.dim2() != 3)) { ostringstream mess; mess << "Affine matrices must be 3x3 - this one is " << am.dim1() << "x" << am.dim2(); @@ -267,17 +267,17 @@ namespace Isis { } /** - * @brief Compute the inverse of a matrix - * - * This method will compute the inverse of an affine matrix for purposes of - * forward and inverse Affine computations. - * + * @brief Compute the inverse of a matrix + * + * This method will compute the inverse of an affine matrix for purposes of + * forward and inverse Affine computations. + * * @param a Matrix to invert - * + * * @return Affine::AMatrix The inverted matrix */ - Affine::AMatrix Affine::invert(const AMatrix &a) const throw (iException &) { - // Now compute the inverse affine matrix using singular value + Affine::AMatrix Affine::invert(const AMatrix &a) const throw(iException &) { + // Now compute the inverse affine matrix using singular value // decomposition A = USV'. So invA = V invS U'. Where ' represents // the transpose of a matrix and invS is S with the recipricol of the // diagonal elements @@ -289,10 +289,10 @@ namespace Isis { // The inverse of S is 1 over each diagonal element of S AMatrix invS; svd.getS(invS); - for (int i=0; i #include "tnt/tnt_array2d.h" #include "iException.h" namespace Isis { -/** - * @brief Affine basis function - * - * An affine transform in two-dimensional space is defined as - * - * @code - * x' = Ax + By + C - * y' = Dx + Ey + F - * @endcode - * - * This routine allows the programmer to define three or more - * mappings from (x,y) to (x',y') and will solve for A,B,C,D,E,F. - * - * If the above coefficients can be computed then the inverse of - * the affine transform exists and will be computed such that - * - * @code - * x = A'x' + B'y' + C' - * y = D'x' + E'y' + F' - * @endcode - * - * Alternatively (or in combination), translations and rotations - * can be applied to create a transform. - * - * @see http://www.gnome.org/~mathieu/libart/libart-affine-transformation-matrices.html - * - * @ingroup Math - * - * @author 2005-03-24 Jeff Anderson - * - * @internal - * @todo Allow the programmer to apply scale and shear. - * @todo Write multiplaction method (operator*) for Affine * Affine. - * - * @history 2006-08-03 Tracie Sucharski, Added Scale method - * @history 2007-07-12 Debbie A. Cook, Added methods Coefficients - * and InverseCoefficients - * @history 2008-06-18 Christopher Austin - Added documentation - * @history 2008-10-29 Steven Lambright - Corrected usage of std::vector, - * problem pointed out by "novas0x2a" (Support Forum - * Member) - * @history 2009-07-24 Kris Becker Introduced the AMatrix typedef; added new - * constructor that accepts an AMatrix; added static method to return - * an Affine identity matrix; added methods to retrieve forward and - * inverse AMatrixs; added new method that inverts the matrix. - * - */ + /** + * @brief Affine basis function + * + * An affine transform in two-dimensional space is defined as + * + * @code + * x' = Ax + By + C + * y' = Dx + Ey + F + * @endcode + * + * This routine allows the programmer to define three or more + * mappings from (x,y) to (x',y') and will solve for A,B,C,D,E,F. + * + * If the above coefficients can be computed then the inverse of + * the affine transform exists and will be computed such that + * + * @code + * x = A'x' + B'y' + C' + * y = D'x' + E'y' + F' + * @endcode + * + * Alternatively (or in combination), translations and rotations + * can be applied to create a transform. + * + * @see http://www.gnome.org/~mathieu/libart/libart-affine-transformation-matrices.html + * + * @ingroup Math + * + * @author 2005-03-24 Jeff Anderson + * + * @internal + * @todo Allow the programmer to apply scale and shear. + * @todo Write multiplaction method (operator*) for Affine * Affine. + * + * @history 2006-08-03 Tracie Sucharski, Added Scale method + * @history 2007-07-12 Debbie A. Cook, Added methods Coefficients + * and InverseCoefficients + * @history 2008-06-18 Christopher Austin - Added documentation + * @history 2008-10-29 Steven Lambright - Corrected usage of std::vector, + * problem pointed out by "novas0x2a" (Support Forum + * Member) + * @history 2009-07-24 Kris Becker Introduced the AMatrix typedef; added new + * constructor that accepts an AMatrix; added static method to return + * an Affine identity matrix; added methods to retrieve forward and + * inverse AMatrixs; added new method that inverts the matrix. + * + */ class Affine { public: typedef TNT::Array2D AMatrix; - Affine (); + Affine(); Affine(const AMatrix &a); - ~Affine (); - void Solve (const double x[], const double y[], - const double xp[], const double yp[], int n); + ~Affine(); + void Solve(const double x[], const double y[], + const double xp[], const double yp[], int n); static AMatrix getIdentity(); - void Identity (); - void Translate (double tx, double ty); + void Identity(); + void Translate(double tx, double ty); void Rotate(double rot); void Scale(double scaleFactor); void Compute(double x, double y); //! Returns the computed x' - double xp() const { return p_xp; }; + double xp() const { + return p_xp; + }; //! Returns the computed y' - double yp() const { return p_yp; }; + double yp() const { + return p_yp; + }; void ComputeInverse(double xp, double yp); //! Returns the computed x - double x() const { return p_x; }; + double x() const { + return p_x; + }; //! Returns the computed y - double y() const { return p_y; }; + double y() const { + return p_y; + }; - std::vector Coefficients( int var ); - std::vector InverseCoefficients( int var ); + std::vector Coefficients(int var); + std::vector InverseCoefficients(int var); //! Returns the forward Affine matrix - AMatrix Forward() const { return (p_matrix.copy()); } + AMatrix Forward() const { + return (p_matrix.copy()); + } //! Returns the inverse Affine matrix - AMatrix Inverse() const { return (p_invmat.copy()); } + AMatrix Inverse() const { + return (p_invmat.copy()); + } private: AMatrix p_matrix; //!< Affine forward matrix @@ -121,8 +133,8 @@ namespace Isis { double p_xp; //!< x' value of the (x',y') coordinate double p_yp; //!< y' value of the (x',y') coordinate - void checkDims(const AMatrix &am) const throw (iException &); - AMatrix invert(const AMatrix &a) const throw (iException &); + void checkDims(const AMatrix &am) const throw(iException &); + AMatrix invert(const AMatrix &a) const throw(iException &); }; }; diff --git a/isis/src/base/objs/Affine/unitTest.cpp b/isis/src/base/objs/Affine/unitTest.cpp index 50207d23bb..d1cd183b24 100644 --- a/isis/src/base/objs/Affine/unitTest.cpp +++ b/isis/src/base/objs/Affine/unitTest.cpp @@ -8,19 +8,19 @@ using namespace std; using namespace TNT; -int main () { +int main() { typedef Isis::Affine::AMatrix AMatrix; Isis::Preference::Preferences(true); Isis::Affine a; // Test translate - a.Translate (1.0,-1.0); - a.Compute(0.0,0.0); + a.Translate(1.0, -1.0); + a.Compute(0.0, 0.0); std::cout << setprecision(1) << std::endl; std::cout << std::fixed << a.xp() << std::endl; std::cout << std::fixed << a.yp() << std::endl; - a.ComputeInverse(a.xp(),a.yp()); + a.ComputeInverse(a.xp(), a.yp()); std::cout << std::fixed << a.x() << std::endl; std::cout << std::fixed << a.y() << std::endl; std::cout << "---" << std::endl; @@ -28,10 +28,10 @@ int main () { // Test rotate a.Identity(); a.Rotate(90.0); - a.Compute(0.0,1.0); + a.Compute(0.0, 1.0); std::cout << std::fixed << a.xp() << std::endl; std::cout << std::fixed << a.yp() << std::endl; - a.ComputeInverse(a.xp(),a.yp()); + a.ComputeInverse(a.xp(), a.yp()); std::cout << std::fixed << a.x() << std::endl; std::cout << std::fixed << a.y() << std::endl; std::cout << "---" << std::endl; @@ -42,43 +42,43 @@ int main () { double xp[] = { 3.0, 1.0, 3.0 }; double yp[] = { 3.0, 1.0, 1.0 }; - a.Solve(x,y,xp,yp,3); + a.Solve(x, y, xp, yp, 3); std::cout << "Forward: 1.0, 1.0\n"; - a.Compute(1.0,1.0); + a.Compute(1.0, 1.0); std::cout << std::fixed << a.xp() << std::endl; std::cout << std::fixed << a.yp() << std::endl; std::cout << "Inverse: " << a.xp() << "," << a.yp() << std::endl; - a.ComputeInverse(a.xp(),a.yp()); + a.ComputeInverse(a.xp(), a.yp()); std::cout << std::fixed << a.x() << std::endl; std::cout << std::fixed << a.y() << std::endl; std::cout << "---" << std::endl; std::cout << "Forward: 3.0, 3.0\n"; - a.Compute(3.0,3.0); + a.Compute(3.0, 3.0); std::cout << std::fixed << a.xp() << std::endl; std::cout << std::fixed << a.yp() << std::endl; std::cout << "Inverse: " << a.xp() << "," << a.yp() << std::endl; - a.ComputeInverse(a.xp(),a.yp()); + a.ComputeInverse(a.xp(), a.yp()); std::cout << std::fixed << a.x() << std::endl; std::cout << std::fixed << a.y() << std::endl; std::cout << "---" << std::endl; std::cout << "Forward: 1.0, 3.0\n"; - a.Compute(1.0,3.0); + a.Compute(1.0, 3.0); std::cout << std::fixed << a.xp() << std::endl; std::cout << std::fixed << a.yp() << std::endl; std::cout << "Inverse: " << a.xp() << "," << a.yp() << std::endl; - a.ComputeInverse(a.xp(),a.yp()); + a.ComputeInverse(a.xp(), a.yp()); std::cout << std::fixed << a.x() << std::endl; std::cout << std::fixed << a.y() << std::endl; std::cout << "---" << std::endl; std::cout << "Forward: 3.0, 1.0\n"; - a.Compute(3.0,1.0); + a.Compute(3.0, 1.0); std::cout << std::fixed << a.xp() << std::endl; std::cout << std::fixed << a.yp() << std::endl; std::cout << "Inverse: " << a.xp() << "," << a.yp() << std::endl; - a.ComputeInverse(a.xp(),a.yp()); + a.ComputeInverse(a.xp(), a.yp()); std::cout << std::fixed << a.x() << std::endl; std::cout << std::fixed << a.y() << std::endl; std::cout << "---" << std::endl; @@ -119,11 +119,11 @@ int main () { std::cout << "\nMatrix Constructor\n"; Isis::Affine b(forward); std::cout << "Forward: 1.0, 3.0\n"; - b.Compute(1.0,3.0); + b.Compute(1.0, 3.0); std::cout << std::fixed << b.xp() << std::endl; std::cout << std::fixed << b.yp() << std::endl; std::cout << "Inverse: " << b.xp() << "," << b.yp() << std::endl; - a.ComputeInverse(b.xp(),b.yp()); + a.ComputeInverse(b.xp(), b.yp()); std::cout << std::fixed << b.x() << std::endl; std::cout << std::fixed << b.y() << std::endl; std::cout << "---" << std::endl; diff --git a/isis/src/base/objs/Albedo/Albedo.cpp b/isis/src/base/objs/Albedo/Albedo.cpp index 5e3afdb24b..9667501e76 100644 --- a/isis/src/base/objs/Albedo/Albedo.cpp +++ b/isis/src/base/objs/Albedo/Albedo.cpp @@ -6,7 +6,7 @@ #define MAX(x,y) (((x) > (y)) ? (x) : (y)) namespace Isis { - Albedo::Albedo (Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl,pmodel) { + Albedo::Albedo(Pvl &pvl, PhotoModel &pmodel) : NormModel(pvl, pmodel) { PvlGroup &algorithm = pvl.FindObject("NormalizationModel").FindGroup("Algorithm", Pvl::Traverse); SetNormIncref(0.0); @@ -15,19 +15,19 @@ namespace Isis { SetNormAlbedo(1.0); // Get value from user - if (algorithm.HasKeyword("Incref")) { + if(algorithm.HasKeyword("Incref")) { SetNormIncref(algorithm["Incref"]); } - if (algorithm.HasKeyword("Incmat")) { + if(algorithm.HasKeyword("Incmat")) { SetNormIncmat(algorithm["Incmat"]); } - if (algorithm.HasKeyword("Thresh")) { + if(algorithm.HasKeyword("Thresh")) { SetNormThresh(algorithm["Thresh"]); } - if (algorithm.HasKeyword("Albedo")) { + if(algorithm.HasKeyword("Albedo")) { SetNormAlbedo(algorithm["Albedo"]); } @@ -37,10 +37,9 @@ namespace Isis { GetPhotoModel()->SetStandardConditions(false); } - void Albedo::NormModelAlgorithm (double phase, double incidence, - double emission, double dn, double &albedo, double &mult, - double &base) - { + void Albedo::NormModelAlgorithm(double phase, double incidence, + double emission, double dn, double &albedo, double &mult, + double &base) { double psurf; double result; @@ -48,40 +47,40 @@ namespace Isis { psurf = GetPhotoModel()->CalcSurfAlbedo(phase, incidence, emission); // thresh is a parameter limiting how much we amplify the dns - if (p_normPsurfref > psurf*p_normThresh) { + if(p_normPsurfref > psurf * p_normThresh) { result = NULL8; albedo = NULL8; mult = 0.0; base = 0.0; } else { - if (psurf == 0.0) { + if(psurf == 0.0) { std::string msg = "Divide by zero error"; - throw iException::Message(iException::Math,msg,_FILEINFO_); + throw iException::Message(iException::Math, msg, _FILEINFO_); } else { result = dn * p_normPsurfref / psurf; - albedo = result; - mult = p_normPsurfref / psurf; - base = 0.0; + albedo = result; + mult = p_normPsurfref / psurf; + base = 0.0; } } } - /** - * Set the normalization function parameter. This is the - * reference incidence angle to which the image photometry will - * be normalized. This parameter is limited to values that are - * >=0 and <90. - * - * @param incref Normalization function parameter, default - * is 0.0 - */ - void Albedo::SetNormIncref (const double incref) { - if (incref < 0.0 || incref >= 90.0) { + /** + * Set the normalization function parameter. This is the + * reference incidence angle to which the image photometry will + * be normalized. This parameter is limited to values that are + * >=0 and <90. + * + * @param incref Normalization function parameter, default + * is 0.0 + */ + void Albedo::SetNormIncref(const double incref) { + if(incref < 0.0 || incref >= 90.0) { std::string msg = "Invalid value of normalization incref [" + - iString(incref) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + iString(incref) + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } p_normIncref = incref; } @@ -92,11 +91,11 @@ namespace Isis { * * @param incmat Normalization function parameter, default is 0.0 */ - void Albedo::SetNormIncmat (const double incmat) { - if (incmat < 0.0 || incmat >= 90.0) { + void Albedo::SetNormIncmat(const double incmat) { + if(incmat < 0.0 || incmat >= 90.0) { std::string msg = "Invalid value of normalization incmat [" + - iString(incmat) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + iString(incmat) + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } p_normIncmat = incmat; } @@ -109,7 +108,7 @@ namespace Isis { * * @param albedo Normalization function parameter */ - void Albedo::SetNormAlbedo (const double albedo) { + void Albedo::SetNormAlbedo(const double albedo) { p_normAlbedo = albedo; } @@ -127,11 +126,11 @@ namespace Isis { * @param thresh Normalization function parameter, default * is 30.0 */ - void Albedo::SetNormThresh (const double thresh) { + void Albedo::SetNormThresh(const double thresh) { p_normThresh = thresh; } } -extern "C" Isis::NormModel *AlbedoPlugin (Isis::Pvl &pvl, Isis::PhotoModel &pmodel) { - return new Isis::Albedo(pvl,pmodel); +extern "C" Isis::NormModel *AlbedoPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) { + return new Isis::Albedo(pvl, pmodel); } diff --git a/isis/src/base/objs/Albedo/Albedo.h b/isis/src/base/objs/Albedo/Albedo.h index 2ec949dd46..69db060281 100644 --- a/isis/src/base/objs/Albedo/Albedo.h +++ b/isis/src/base/objs/Albedo/Albedo.h @@ -1,65 +1,65 @@ #if !defined(Albedo_h) #define Albedo_h -/** - * @file - * $Revision: 1.5 $ - * $Date: 2008/06/18 17:26:08 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.5 $ + * $Date: 2008/06/18 17:26:08 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include "NormModel.h" namespace Isis { class Pvl; -/** - * @brief Albedo normalization - * - * Consistent dividing out of photometric model at given an- - * gles and putting it back in at reference incidence but zero - * phase. Let the reference incidence default to zero. For - * Hapke model only, the photometric function multiplied back - * in will be modified to take out opposition effect. This - * requires saving the actual value of B0 while temporarily - * setting it to zero in the common block to compute the over- - * all normalization. - * - * - * @author 1998-12-21 Randy Kirk - * - * @internal - * @history 2007-08-15 Steven Lambright - Refactored code - * @history 2008-03-07 Janet Barrett - Changed name of Incmatch - * parmater to Incmat - * @history 2008-06-18 Christopher Austin - Fixed documentation errors - */ + /** + * @brief Albedo normalization + * + * Consistent dividing out of photometric model at given an- + * gles and putting it back in at reference incidence but zero + * phase. Let the reference incidence default to zero. For + * Hapke model only, the photometric function multiplied back + * in will be modified to take out opposition effect. This + * requires saving the actual value of B0 while temporarily + * setting it to zero in the common block to compute the over- + * all normalization. + * + * + * @author 1998-12-21 Randy Kirk + * + * @internal + * @history 2007-08-15 Steven Lambright - Refactored code + * @history 2008-03-07 Janet Barrett - Changed name of Incmatch + * parmater to Incmat + * @history 2008-06-18 Christopher Austin - Fixed documentation errors + */ class Albedo : public NormModel { public: - Albedo (Pvl &pvl, PhotoModel &pmodel); + Albedo(Pvl &pvl, PhotoModel &pmodel); virtual ~Albedo() {}; protected: - virtual void NormModelAlgorithm (double pha, double inc, double ema, - double dn, double &albedo, double &mult, double &base); - virtual void NormModelAlgorithm (double pha, double inc, double ema, - double deminc, double demema, double dn, double &albedo, - double &mult, double &base) {}; + virtual void NormModelAlgorithm(double pha, double inc, double ema, + double dn, double &albedo, double &mult, double &base); + virtual void NormModelAlgorithm(double pha, double inc, double ema, + double deminc, double demema, double dn, double &albedo, + double &mult, double &base) {}; private: //! Set parameters needed for albedo normalization diff --git a/isis/src/base/objs/Albedo/unitTest.cpp b/isis/src/base/objs/Albedo/unitTest.cpp index 9fa63f17b5..b66bfafe07 100644 --- a/isis/src/base/objs/Albedo/unitTest.cpp +++ b/isis/src/base/objs/Albedo/unitTest.cpp @@ -11,7 +11,7 @@ using namespace Isis; -int main () { +int main() { Isis::Preference::Preferences(true); double result; double mult; @@ -20,13 +20,13 @@ int main () { std::cout << "UNIT TEST for Albedo normalization function" << std::endl << std::endl; PvlGroup algp("Algorithm"); - algp += PvlKeyword("Name","Lambert"); + algp += PvlKeyword("Name", "Lambert"); PvlObject op("PhotometricModel"); op.AddGroup(algp); PvlGroup algn("Algorithm"); - algn += PvlKeyword("Name","Albedo"); + algn += PvlKeyword("Name", "Albedo"); PvlObject on("NormalizationModel"); on.AddGroup(algn); @@ -38,21 +38,21 @@ int main () { try { PhotoModel *pm = PhotoModelFactory::Create(pvl); - NormModel *nm = NormModelFactory::Create(pvl,*pm); - + NormModel *nm = NormModelFactory::Create(pvl, *pm); + std::cout << "Test phase=0.0, incidence=0.0, emission=0.0, dn=.0800618902 ..." << std::endl; - nm->CalcNrmAlbedo(0.0,0.0,0.0,.0800618902,result,mult,base); + nm->CalcNrmAlbedo(0.0, 0.0, 0.0, .0800618902, result, mult, base); std::cout << "Normalization value = " << result << std::endl << std::endl; - + std::cout << "Test phase=86.7207248, incidence=51.7031305, emission=38.9372914, dn=.0797334611 ..." << std::endl; - nm->CalcNrmAlbedo(86.7207248,51.7031305,38.9372914,.0797334611,result,mult,base); + nm->CalcNrmAlbedo(86.7207248, 51.7031305, 38.9372914, .0797334611, result, mult, base); std::cout << "Normalization value = " << result << std::endl << std::endl; - + std::cout << "Test phase=180, incidence=90, emission=90, dn=.0794225037 ..." << std::endl; - nm->CalcNrmAlbedo(180.0,90.0,90.0,.0794225037,result,mult,base); + nm->CalcNrmAlbedo(180.0, 90.0, 90.0, .0794225037, result, mult, base); std::cout << "Normalization value = " << result << std::endl << std::endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } diff --git a/isis/src/base/objs/AlbedoAtm/AlbedoAtm.cpp b/isis/src/base/objs/AlbedoAtm/AlbedoAtm.cpp index 484218f69c..2df46b7721 100644 --- a/isis/src/base/objs/AlbedoAtm/AlbedoAtm.cpp +++ b/isis/src/base/objs/AlbedoAtm/AlbedoAtm.cpp @@ -10,30 +10,30 @@ namespace Isis { /** * Constructs AlbedoAtm object using a Pvl, PhotoModel, and * AtmosModel - * @param pvl - * @param pmodel - * @param amodel - * - * @internal + * @param pvl + * @param pmodel + * @param amodel + * + * @internal * @history 2008-11-05 Jeannie Walldren - Modified references * to NumericalMethods class and replaced Isis::PI with * PI since this is in Isis namespace. */ - AlbedoAtm::AlbedoAtm (Pvl &pvl, PhotoModel &pmodel, AtmosModel &amodel) : - NormModel(pvl,pmodel,amodel) { + AlbedoAtm::AlbedoAtm(Pvl &pvl, PhotoModel &pmodel, AtmosModel &amodel) : + NormModel(pvl, pmodel, amodel) { PvlGroup &algo = pvl.FindObject("NormalizationModel") - .FindGroup("Algorithm",Pvl::Traverse); + .FindGroup("Algorithm", Pvl::Traverse); // Set default value SetNormIncref(0.0); // Get value from user - if (algo.HasKeyword("Incref")) { + if(algo.HasKeyword("Incref")) { SetNormIncref(algo["Incref"]); } // First-time setup: // Calculate normalization at standard conditions GetPhotoModel()->SetStandardConditions(true); - p_normPsurfref = GetPhotoModel()->CalcSurfAlbedo(p_normIncref, p_normIncref,0.0); + p_normPsurfref = GetPhotoModel()->CalcSurfAlbedo(p_normIncref, p_normIncref, 0.0); GetPhotoModel()->SetStandardConditions(false); // Get reference hemispheric albedo @@ -41,32 +41,31 @@ namespace Isis { p_normAhref = (GetAtmosModel()->AtmosAhSpline()).Evaluate(p_normIncref, NumericalApproximation::Extrapolate); - p_normMunotref = cos((PI/180.0)*p_normIncref); + p_normMunotref = cos((PI / 180.0) * p_normIncref); // Now calculate atmosphere at standard conditions GetAtmosModel()->SetStandardConditions(true); - GetAtmosModel()->CalcAtmEffect(p_normIncref,p_normIncref,0.0, - &p_normPstdref,&p_normTransref, - &p_normTrans0ref,&p_normSbar); + GetAtmosModel()->CalcAtmEffect(p_normIncref, p_normIncref, 0.0, + &p_normPstdref, &p_normTransref, + &p_normTrans0ref, &p_normSbar); GetAtmosModel()->SetStandardConditions(false); } - /** + /** * @param phase Value of phase angle. * @param incidence Value of incidence angle. * @param emission Value of emission angle. * @param dn * @param albedo - * @param mult - * @param base - * @internal + * @param mult + * @param base + * @internal * @history 2008-11-05 Jeannie Walldren - Modified references * to NumericalMethods class and replaced Isis::PI with * PI since this is in Isis namespace. */ - void AlbedoAtm::NormModelAlgorithm (double phase, double incidence, - double emission, double dn, double &albedo, double &mult, double &base) - { + void AlbedoAtm::NormModelAlgorithm(double phase, double incidence, + double emission, double dn, double &albedo, double &mult, double &base) { double psurf; double ahInterp; double munot; @@ -83,31 +82,31 @@ namespace Isis { double fourthterm; double fifthterm; - psurf = GetPhotoModel()->CalcSurfAlbedo(phase,incidence, - emission); + psurf = GetPhotoModel()->CalcSurfAlbedo(phase, incidence, + emission); ahInterp = (GetAtmosModel()->AtmosAhSpline()).Evaluate(incidence, NumericalApproximation::Extrapolate); - munot = cos(incidence*(PI/180.0)); - GetAtmosModel()->CalcAtmEffect(phase,incidence,emission,&pstd,&trans,&trans0,&p_normSbar); + munot = cos(incidence * (PI / 180.0)); + GetAtmosModel()->CalcAtmEffect(phase, incidence, emission, &pstd, &trans, &trans0, &p_normSbar); // With model at actual geometry, calculate rho from dn dpo = dn - pstd; dpm = (psurf - ahInterp * munot) * trans0; q = ahInterp * munot * trans + GetAtmosModel()->AtmosAb() * p_normSbar * dpo + dpm; - if (dpo <= 0.0 && GetAtmosModel()->AtmosNulneg()) { + if(dpo <= 0.0 && GetAtmosModel()->AtmosNulneg()) { rho = 0.0; } else { firsterm = GetAtmosModel()->AtmosAb() * p_normSbar; secondterm = dpo * dpm; thirdterm = firsterm * secondterm; - fourthterm = pow(q,2.0) - 4.0 * thirdterm; + fourthterm = pow(q, 2.0) - 4.0 * thirdterm; - if (fourthterm < 0.0) { + if(fourthterm < 0.0) { std::string msg = "Square root of negative encountered"; - throw iException::Message(iException::Math,msg,_FILEINFO_); + throw iException::Message(iException::Math, msg, _FILEINFO_); } else { fifthterm = q + sqrt(fourthterm); @@ -117,38 +116,38 @@ namespace Isis { } // Now use rho and reference geometry to calculate output dnout - if ((1.0-rho*GetAtmosModel()->AtmosAb()*p_normSbar) <= 0.0) { + if((1.0 - rho * GetAtmosModel()->AtmosAb()*p_normSbar) <= 0.0) { std::string msg = "Divide by zero encountered"; - throw iException::Message(iException::Math,msg,_FILEINFO_); + throw iException::Message(iException::Math, msg, _FILEINFO_); } else { - albedo = p_normPstdref + rho * (p_normAhref * p_normMunotref * - p_normTransref / (1.0 - rho * GetAtmosModel()->AtmosAb() * - p_normSbar) + (p_normPsurfref - p_normAhref * - p_normMunotref) * p_normTrans0ref); + albedo = p_normPstdref + rho * (p_normAhref * p_normMunotref * + p_normTransref / (1.0 - rho * GetAtmosModel()->AtmosAb() * + p_normSbar) + (p_normPsurfref - p_normAhref * + p_normMunotref) * p_normTrans0ref); } } - /** - * Set the normalization function parameter. This is the - * reference incidence angle to which the image photometry will - * be normalized. This parameter is limited to values that are - * >=0 and <90. - * - * @param incref Normalization function parameter, default - * is 0.0 - */ - void AlbedoAtm::SetNormIncref (const double incref) { - if (incref < 0.0 || incref >= 90.0) { + /** + * Set the normalization function parameter. This is the + * reference incidence angle to which the image photometry will + * be normalized. This parameter is limited to values that are + * >=0 and <90. + * + * @param incref Normalization function parameter, default + * is 0.0 + */ + void AlbedoAtm::SetNormIncref(const double incref) { + if(incref < 0.0 || incref >= 90.0) { std::string msg = "Invalid value of normalization incref [" + - iString(incref) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + iString(incref) + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } p_normIncref = incref; } } -extern "C" Isis::NormModel *AlbedoAtmPlugin (Isis::Pvl &pvl, Isis::PhotoModel &pmodel, Isis::AtmosModel &amodel) { - return new Isis::AlbedoAtm(pvl,pmodel,amodel); +extern "C" Isis::NormModel *AlbedoAtmPlugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel, Isis::AtmosModel &amodel) { + return new Isis::AlbedoAtm(pvl, pmodel, amodel); } diff --git a/isis/src/base/objs/AlbedoAtm/AlbedoAtm.h b/isis/src/base/objs/AlbedoAtm/AlbedoAtm.h index d4090407fa..d85c750e83 100644 --- a/isis/src/base/objs/AlbedoAtm/AlbedoAtm.h +++ b/isis/src/base/objs/AlbedoAtm/AlbedoAtm.h @@ -1,62 +1,62 @@ #ifndef AlbedoAtm_h #define AlbedoAtm_h -/** - * @file - * $Revision: 1.7 $ - * $Date: 2009/05/11 21:53:32 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.7 $ + * $Date: 2009/05/11 21:53:32 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include "NormModel.h" namespace Isis { class Pvl; -/** - * @brief Albedo normalization with atmosphere - * - * @ingroup RadiometricAndPhotometricCorrection - * @author 1998-12-21 Randy Kirk - * - * @internal - * @history 2007-08-15 Steven Lambright - Refactored code and fixed unit test - * @history 2008-06-18 Christopher Austin - Fixed documentation errors - * @history 2008-11-05 Jeannie Walldren - Modified references - * to NumericalMethods class. - * @history 2008-11-07 Jeannie Walldren - Fixed documentation. - * @history 2009-05-11 Janet Barrett - Fixed so that the NormModelAlgorithm - * supporting DEM input is the empty function. DEM input is not yet - * supported. - * - */ + /** + * @brief Albedo normalization with atmosphere + * + * @ingroup RadiometricAndPhotometricCorrection + * @author 1998-12-21 Randy Kirk + * + * @internal + * @history 2007-08-15 Steven Lambright - Refactored code and fixed unit test + * @history 2008-06-18 Christopher Austin - Fixed documentation errors + * @history 2008-11-05 Jeannie Walldren - Modified references + * to NumericalMethods class. + * @history 2008-11-07 Jeannie Walldren - Fixed documentation. + * @history 2009-05-11 Janet Barrett - Fixed so that the NormModelAlgorithm + * supporting DEM input is the empty function. DEM input is not yet + * supported. + * + */ class AlbedoAtm : public NormModel { public: - AlbedoAtm (Pvl &pvl, PhotoModel &pmodel, AtmosModel &amodel); + AlbedoAtm(Pvl &pvl, PhotoModel &pmodel, AtmosModel &amodel); //! Empty Destructor virtual ~AlbedoAtm() {}; protected: - virtual void NormModelAlgorithm (double pha, double inc, double ema, - double dn, double &albedo, double &mult, double &base); - virtual void NormModelAlgorithm (double pha, double inc, double ema, - double deminc, double demema, double dn, double &albedo, - double &mult, double &base) {}; + virtual void NormModelAlgorithm(double pha, double inc, double ema, + double dn, double &albedo, double &mult, double &base); + virtual void NormModelAlgorithm(double pha, double inc, double ema, + double deminc, double demema, double dn, double &albedo, + double &mult, double &base) {}; private: //! Set parameters needed for albedo normalization diff --git a/isis/src/base/objs/AlbedoAtm/unitTest.cpp b/isis/src/base/objs/AlbedoAtm/unitTest.cpp index f284ab899c..1021836037 100644 --- a/isis/src/base/objs/AlbedoAtm/unitTest.cpp +++ b/isis/src/base/objs/AlbedoAtm/unitTest.cpp @@ -14,37 +14,37 @@ using namespace Isis; -int main () { +int main() { Isis::Preference::Preferences(true); double result; double mult; double base; - std::cout << "UNIT TEST for AlbedoAtm normalization function" << - std::endl << std::endl; + std::cout << "UNIT TEST for AlbedoAtm normalization function" << + std::endl << std::endl; PvlGroup algp("Algorithm"); - algp += PvlKeyword("Name","Lambert"); + algp += PvlKeyword("Name", "Lambert"); PvlObject op("PhotometricModel"); op.AddGroup(algp); PvlGroup alga("Algorithm"); - alga += PvlKeyword("Name","Anisotropic1"); - alga += PvlKeyword("Bha","0.85"); - alga += PvlKeyword("Tau","0.28"); - alga += PvlKeyword("Wha","0.95"); - alga += PvlKeyword("Hga","0.68"); - alga += PvlKeyword("Tauref","0.0"); - alga += PvlKeyword("Hnorm","0.003"); + alga += PvlKeyword("Name", "Anisotropic1"); + alga += PvlKeyword("Bha", "0.85"); + alga += PvlKeyword("Tau", "0.28"); + alga += PvlKeyword("Wha", "0.95"); + alga += PvlKeyword("Hga", "0.68"); + alga += PvlKeyword("Tauref", "0.0"); + alga += PvlKeyword("Hnorm", "0.003"); PvlObject oa("AtmosphericModel"); oa.AddGroup(alga); PvlGroup algn("Algorithm"); - algn += PvlKeyword("Name","AlbedoAtm"); - algn += PvlKeyword("Incref","0.0"); - algn += PvlKeyword("Thresh","30.0"); + algn += PvlKeyword("Name", "AlbedoAtm"); + algn += PvlKeyword("Incref", "0.0"); + algn += PvlKeyword("Thresh", "30.0"); PvlObject on("NormalizationModel"); on.AddGroup(algn); @@ -58,25 +58,25 @@ int main () { try { PhotoModel *pm = PhotoModelFactory::Create(pvl); - AtmosModel *am = AtmosModelFactory::Create(pvl,*pm); - AlbedoAtm *nm = (AlbedoAtm*)NormModelFactory::Create(pvl,*pm,*am); - + AtmosModel *am = AtmosModelFactory::Create(pvl, *pm); + AlbedoAtm *nm = (AlbedoAtm *)NormModelFactory::Create(pvl, *pm, *am); + std::cout << "Test phase=86.7207248, incidence=51.7031305, emission=38.9372914, " << - "dn=.0800618902 ..." << std::endl; - nm->CalcNrmAlbedo(86.7207248,51.7031305,38.9372914,.0800618902,result,mult,base); + "dn=.0800618902 ..." << std::endl; + nm->CalcNrmAlbedo(86.7207248, 51.7031305, 38.9372914, .0800618902, result, mult, base); std::cout << "Normalization value = " << result << std::endl << std::endl; - + std::cout << "Test phase=86.7207248, incidence=51.7031305, emission=38.9372914, " << - "dn=.0797334611 ..." << std::endl; - nm->CalcNrmAlbedo(86.7207248,51.7031305,38.9372914,.0797334611,result,mult,base); + "dn=.0797334611 ..." << std::endl; + nm->CalcNrmAlbedo(86.7207248, 51.7031305, 38.9372914, .0797334611, result, mult, base); std::cout << "Normalization value = " << result << std::endl << std::endl; - + std::cout << "Test phase=86.7187773, incidence=51.7060221, emission=38.9331391, " << - "dn=.0794225037 ..." << std::endl; - nm->CalcNrmAlbedo(86.7187773,51.7060221,38.9331391,.0794225037,result,mult,base); + "dn=.0794225037 ..." << std::endl; + nm->CalcNrmAlbedo(86.7187773, 51.7060221, 38.9331391, .0794225037, result, mult, base); std::cout << "Normalization value = " << result << std::endl << std::endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } diff --git a/isis/src/base/objs/AlphaCube/AlphaCube.cpp b/isis/src/base/objs/AlphaCube/AlphaCube.cpp index 002e98813e..d4096455d0 100644 --- a/isis/src/base/objs/AlphaCube/AlphaCube.cpp +++ b/isis/src/base/objs/AlphaCube/AlphaCube.cpp @@ -1,33 +1,33 @@ -/** - * @file - * $Revision: 1.1.1.1 $ - * $Date: 2006/10/31 23:18:06 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.1.1.1 $ + * $Date: 2006/10/31 23:18:06 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include "AlphaCube.h" using namespace std; namespace Isis { //! Constructs an AlphaCube object using a PVL object. - AlphaCube::AlphaCube (Isis::Pvl &pvl) { + AlphaCube::AlphaCube(Isis::Pvl &pvl) { Isis::PvlObject &isiscube = pvl.FindObject("IsisCube"); - if (isiscube.HasGroup("AlphaCube")) { + if(isiscube.HasGroup("AlphaCube")) { Isis::PvlGroup &alpha = isiscube.FindGroup("AlphaCube"); p_alphaSamples = alpha["AlphaSamples"]; p_alphaLines = alpha["AlphaLines"]; @@ -39,104 +39,104 @@ namespace Isis { p_betaLines = alpha["BetaLines"]; } else { - Isis::PvlGroup &dims = isiscube.FindGroup("Dimensions",Isis::Pvl::Traverse); + Isis::PvlGroup &dims = isiscube.FindGroup("Dimensions", Isis::Pvl::Traverse); p_alphaSamples = dims["Samples"]; p_alphaLines = dims["Lines"]; p_alphaStartingSample = 0.5; - p_alphaStartingLine = 0.5; - p_alphaEndingSample = (double) p_alphaSamples + 0.5; + p_alphaStartingLine = 0.5; + p_alphaEndingSample = (double) p_alphaSamples + 0.5; p_alphaEndingLine = (double) p_alphaLines + 0.5; p_betaSamples = p_alphaSamples; p_betaLines = p_alphaLines; } - + ComputeSlope(); } - /** Constructs an AlphaCube object with a basic mapping from corner-to-corner, - * beta 0.5,0.5 maps to alpha 0.5,0.5 and beta ns+0.5,nl+0.5 maps to alpha + /** Constructs an AlphaCube object with a basic mapping from corner-to-corner, + * beta 0.5,0.5 maps to alpha 0.5,0.5 and beta ns+0.5,nl+0.5 maps to alpha * ns+0.5, nl+0.5. - */ - AlphaCube::AlphaCube (int alphaSamples, int alphaLines, - int betaSamples, int betaLines, - double alphaSs, double alphaSl, - double alphaEs, double alphaEl) { + */ + AlphaCube::AlphaCube(int alphaSamples, int alphaLines, + int betaSamples, int betaLines, + double alphaSs, double alphaSl, + double alphaEs, double alphaEl) { p_alphaSamples = alphaSamples; p_alphaLines = alphaLines; p_alphaStartingSample = alphaSs; - p_alphaStartingLine = alphaSl; - p_alphaEndingSample = alphaEs; + p_alphaStartingLine = alphaSl; + p_alphaEndingSample = alphaEs; p_alphaEndingLine = alphaEl; - + p_betaSamples = betaSamples; p_betaLines = betaLines; - + ComputeSlope(); } - /** Constructs an AlphaCube object given alphaSamples, alphaLines, + /** Constructs an AlphaCube object given alphaSamples, alphaLines, * betaSamples and betaLines. */ - AlphaCube::AlphaCube (int alphaSamples, int alphaLines, - int betaSamples, int betaLines) { + AlphaCube::AlphaCube(int alphaSamples, int alphaLines, + int betaSamples, int betaLines) { p_alphaSamples = alphaSamples; p_alphaLines = alphaLines; p_alphaStartingSample = 0.5; - p_alphaStartingLine = 0.5; - p_alphaEndingSample = (double) alphaSamples + 0.5; + p_alphaStartingLine = 0.5; + p_alphaEndingSample = (double) alphaSamples + 0.5; p_alphaEndingLine = (double) alphaLines + 0.5; - + p_betaSamples = betaSamples; p_betaLines = betaLines; - + ComputeSlope(); } -/** - * Merges two AlphaCube objects. This facilities combinations of programs - * crop-enlarge, crop-crop, reduce-pad, etc. - * - * @param add The AlphaCube object to be merged. - */ - void AlphaCube::Rehash (AlphaCube &add) { + /** + * Merges two AlphaCube objects. This facilities combinations of programs + * crop-enlarge, crop-crop, reduce-pad, etc. + * + * @param add The AlphaCube object to be merged. + */ + void AlphaCube::Rehash(AlphaCube &add) { double sl = AlphaLine(add.AlphaLine(0.5)); double ss = AlphaSample(add.AlphaSample(0.5)); - double el = AlphaLine(add.AlphaLine(add.BetaLines()+0.5)); - double es = AlphaSample(add.AlphaSample(add.BetaSamples()+0.5)); - + double el = AlphaLine(add.AlphaLine(add.BetaLines() + 0.5)); + double es = AlphaSample(add.AlphaSample(add.BetaSamples() + 0.5)); + p_alphaStartingLine = sl; p_alphaStartingSample = ss; p_alphaEndingLine = el; p_alphaEndingSample = es; p_betaLines = add.BetaLines(); p_betaSamples = add.BetaSamples(); - + ComputeSlope(); } -/** - * Writes or update the Alpha keywords (AlphaLines, AlphaSamples, - * AlphaStartingSamples, etc) in the proper group in a PVL object. It chooses - * first to write and AlphaGroup if the Mapping group exists. - * If not then is will write the keywords in the Instrument group if it exists. - * Otherwise it will write to the AlphaCube group. - * - * @param &pvl The PVL object to write to. - * - */ - void AlphaCube::UpdateGroup (Isis::Pvl &pvl) { + /** + * Writes or update the Alpha keywords (AlphaLines, AlphaSamples, + * AlphaStartingSamples, etc) in the proper group in a PVL object. It chooses + * first to write and AlphaGroup if the Mapping group exists. + * If not then is will write the keywords in the Instrument group if it exists. + * Otherwise it will write to the AlphaCube group. + * + * @param &pvl The PVL object to write to. + * + */ + void AlphaCube::UpdateGroup(Isis::Pvl &pvl) { // If we have a mapping group we do not want to update the alpha cube // group as it represents the dimensions and sub-area of the raw instrument // cube Isis::PvlObject &cube = pvl.FindObject("IsisCube"); - if (cube.HasGroup("Mapping")) return; - + if(cube.HasGroup("Mapping")) return; + // Add the labels to the pvl - if (cube.HasGroup("AlphaCube")) { + if(cube.HasGroup("AlphaCube")) { AlphaCube temp(pvl); temp.Rehash(*this); *this = temp; - + Isis::PvlGroup &alpha = cube.FindGroup("AlphaCube"); alpha["AlphaSamples"] = p_alphaSamples; alpha["AlphaLines"] = p_alphaLines; @@ -149,29 +149,29 @@ namespace Isis { } else { Isis::PvlGroup alpha("AlphaCube"); - alpha += Isis::PvlKeyword("AlphaSamples",p_alphaSamples); - alpha += Isis::PvlKeyword("AlphaLines",p_alphaLines); - alpha += Isis::PvlKeyword("AlphaStartingSample",p_alphaStartingSample); - alpha += Isis::PvlKeyword("AlphaStartingLine",p_alphaStartingLine); - alpha += Isis::PvlKeyword("AlphaEndingSample",p_alphaEndingSample); - alpha += Isis::PvlKeyword("AlphaEndingLine",p_alphaEndingLine); - alpha += Isis::PvlKeyword("BetaSamples",p_betaSamples); - alpha += Isis::PvlKeyword("BetaLines",p_betaLines); + alpha += Isis::PvlKeyword("AlphaSamples", p_alphaSamples); + alpha += Isis::PvlKeyword("AlphaLines", p_alphaLines); + alpha += Isis::PvlKeyword("AlphaStartingSample", p_alphaStartingSample); + alpha += Isis::PvlKeyword("AlphaStartingLine", p_alphaStartingLine); + alpha += Isis::PvlKeyword("AlphaEndingSample", p_alphaEndingSample); + alpha += Isis::PvlKeyword("AlphaEndingLine", p_alphaEndingLine); + alpha += Isis::PvlKeyword("BetaSamples", p_betaSamples); + alpha += Isis::PvlKeyword("BetaLines", p_betaLines); cube.AddGroup(alpha); } } - /** - * Computes the line and sample slopes. (Starting and ending + /** + * Computes the line and sample slopes. (Starting and ending * alpha lines/samples divided by the number of beta lines/samples). - * + * * @internal * @todo Why the +0.5 and -0.5? */ - void AlphaCube::ComputeSlope () { - p_lineSlope = double (p_alphaEndingLine - p_alphaStartingLine) / - double ((p_betaLines + 0.5) - 0.5); - p_sampSlope = double (p_alphaEndingSample - p_alphaStartingSample) / - double ((p_betaSamples + 0.5) - 0.5); + void AlphaCube::ComputeSlope() { + p_lineSlope = double(p_alphaEndingLine - p_alphaStartingLine) / + double((p_betaLines + 0.5) - 0.5); + p_sampSlope = double(p_alphaEndingSample - p_alphaStartingSample) / + double((p_betaSamples + 0.5) - 0.5); } } diff --git a/isis/src/base/objs/AlphaCube/AlphaCube.h b/isis/src/base/objs/AlphaCube/AlphaCube.h index 8bbb5311d9..3801771ef9 100644 --- a/isis/src/base/objs/AlphaCube/AlphaCube.h +++ b/isis/src/base/objs/AlphaCube/AlphaCube.h @@ -1,96 +1,104 @@ -/** - * @file - * $Revision: 1.1.1.1 $ - * $Date: 2006/10/31 23:18:06 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.1.1.1 $ + * $Date: 2006/10/31 23:18:06 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #if !defined(AlphaCube_h) #define AlphaCube_h #include "Pvl.h" namespace Isis { -/** - * @brief This class is used to rewrite the "alpha" keywords out of the - * AlphaCube group or Instrument group. - * - * This class allows programmers to map cube pixel positions back to the first - * cube they came from.This is critical for camera models or radiometric models - * in order to map input cube pixels to camera detector position. - * The alpha keywords are automatically generated in programs like crop, pad, - * reduce, and enlarge. - * - * @ingroup LowLevelCubeIO - * - * @author 2004-02-13 Jeff Anderson - * - * @internal - * @history 2004-02-13 Jeff Anderson - Added another constructor and - * refactored UpdateGroup method. - * @history 2004-06-03 Jeff Anderson - Fixed bug in UpdateGroup which - * occured when a cube label did not already have a AlphaCube group. - * @history 2005-02-14 Leah Dahmer - Modified file to support Doxygen - * documentation. - * - * @todo 2005-04-06 Add coded example. - */ - class AlphaCube { + /** + * @brief This class is used to rewrite the "alpha" keywords out of the + * AlphaCube group or Instrument group. + * + * This class allows programmers to map cube pixel positions back to the first + * cube they came from.This is critical for camera models or radiometric models + * in order to map input cube pixels to camera detector position. + * The alpha keywords are automatically generated in programs like crop, pad, + * reduce, and enlarge. + * + * @ingroup LowLevelCubeIO + * + * @author 2004-02-13 Jeff Anderson + * + * @internal + * @history 2004-02-13 Jeff Anderson - Added another constructor and + * refactored UpdateGroup method. + * @history 2004-06-03 Jeff Anderson - Fixed bug in UpdateGroup which + * occured when a cube label did not already have a AlphaCube group. + * @history 2005-02-14 Leah Dahmer - Modified file to support Doxygen + * documentation. + * + * @todo 2005-04-06 Add coded example. + */ + class AlphaCube { public: - AlphaCube (Isis::Pvl &pvl); - AlphaCube (int alphaSamples, int alphaLines, - int betaSamples, int betaLines); - AlphaCube (int alphaSamples, int alphaLines, - int betaSamples, int betaLines, - double alphaSs, double alphaSl, - double alphaEs, double alphaEl); - //! Destroys the AlphaCube object. - ~AlphaCube () {}; + AlphaCube(Isis::Pvl &pvl); + AlphaCube(int alphaSamples, int alphaLines, + int betaSamples, int betaLines); + AlphaCube(int alphaSamples, int alphaLines, + int betaSamples, int betaLines, + double alphaSs, double alphaSl, + double alphaEs, double alphaEl); + //! Destroys the AlphaCube object. + ~AlphaCube() {}; - //! Returns the number of lines in the alpha cube. - inline int AlphaLines () const { return p_alphaLines; }; - //! Returns the number of samples in the alpha cube. - inline int AlphaSamples () const { return p_alphaSamples; }; - //! Returns the number of lines in the beta cube. - inline int BetaLines () const { return p_betaLines; }; - //! Returns the number of samples in the beta cube. - inline int BetaSamples () const { return p_betaSamples; }; - //! Returns an alpha line given a beta line. + //! Returns the number of lines in the alpha cube. + inline int AlphaLines() const { + return p_alphaLines; + }; + //! Returns the number of samples in the alpha cube. + inline int AlphaSamples() const { + return p_alphaSamples; + }; + //! Returns the number of lines in the beta cube. + inline int BetaLines() const { + return p_betaLines; + }; + //! Returns the number of samples in the beta cube. + inline int BetaSamples() const { + return p_betaSamples; + }; + //! Returns an alpha line given a beta line. inline double AlphaLine(double betaLine) { return p_lineSlope * (betaLine - 0.5) + p_alphaStartingLine; } - //! Returns an alpha sample given a beta sample. + //! Returns an alpha sample given a beta sample. inline double AlphaSample(double betaSample) { return p_sampSlope * (betaSample - 0.5) + p_alphaStartingSample; } - //! Returns a beta line given an alpha line. + //! Returns a beta line given an alpha line. inline double BetaLine(double alphaLine) { - return (alphaLine - p_alphaStartingLine) / p_lineSlope + 0.5; + return (alphaLine - p_alphaStartingLine) / p_lineSlope + 0.5; } - //! Returns a beta sample given an alpha sample. + //! Returns a beta sample given an alpha sample. inline double BetaSample(double alphaSample) { - return (alphaSample - p_alphaStartingSample) / p_sampSlope + 0.5; + return (alphaSample - p_alphaStartingSample) / p_sampSlope + 0.5; } - - void UpdateGroup (Isis::Pvl &pvl); - - void Rehash (AlphaCube &alphaCube); - + + void UpdateGroup(Isis::Pvl &pvl); + + void Rehash(AlphaCube &alphaCube); + private: void ComputeSlope(); int p_alphaLines; /**< The number of alpha lines in the cube. */ diff --git a/isis/src/base/objs/AlphaCube/unitTest.cpp b/isis/src/base/objs/AlphaCube/unitTest.cpp index 66052a0021..2215c4f046 100644 --- a/isis/src/base/objs/AlphaCube/unitTest.cpp +++ b/isis/src/base/objs/AlphaCube/unitTest.cpp @@ -5,9 +5,9 @@ using namespace std; -int main () { +int main() { Isis::Preference::Preferences(true); - Isis::AlphaCube c(4,8,2,3,1.5,2.5,3.5,5.5); + Isis::AlphaCube c(4, 8, 2, 3, 1.5, 2.5, 3.5, 5.5); cout << "1st Test Alpha" << endl; cout << c.AlphaSamples() << endl; cout << c.AlphaLines() << endl; @@ -17,8 +17,8 @@ int main () { cout << c.AlphaLine(c.BetaLines()) << endl; cout << c.AlphaSample(0.5) << endl; cout << c.AlphaLine(0.5) << endl; - cout << c.AlphaSample(c.BetaSamples()+0.5) << endl; - cout << c.AlphaLine(c.BetaLines()+0.5) << endl; + cout << c.AlphaSample(c.BetaSamples() + 0.5) << endl; + cout << c.AlphaLine(c.BetaLines() + 0.5) << endl; cout << endl; cout << "1st Test Beta" << endl; @@ -29,8 +29,8 @@ int main () { cout << c.BetaSample(c.AlphaSamples()) << endl; cout << c.BetaLine(c.AlphaLines()) << endl; cout << endl; - - Isis::AlphaCube d(2,3,2,4,1.5,1.5,2.5,3.5); + + Isis::AlphaCube d(2, 3, 2, 4, 1.5, 1.5, 2.5, 3.5); cout << "2nd Alpha Test" << endl; cout << d.AlphaSamples() << endl; cout << d.AlphaLines() << endl; @@ -40,8 +40,8 @@ int main () { cout << d.AlphaLine(d.BetaLines()) << endl; cout << d.AlphaSample(0.5) << endl; cout << d.AlphaLine(0.5) << endl; - cout << d.AlphaSample(d.BetaSamples()+0.5) << endl; - cout << d.AlphaLine(d.BetaLines()+0.5) << endl; + cout << d.AlphaSample(d.BetaSamples() + 0.5) << endl; + cout << d.AlphaLine(d.BetaLines() + 0.5) << endl; cout << endl; cout << "2nd Beta Test" << endl; @@ -63,8 +63,8 @@ int main () { cout << c.AlphaLine(c.BetaLines()) << endl; cout << c.AlphaSample(0.5) << endl; cout << c.AlphaLine(0.5) << endl; - cout << c.AlphaSample(c.BetaSamples()+0.5) << endl; - cout << c.AlphaLine(c.BetaLines()+0.5) << endl; + cout << c.AlphaSample(c.BetaSamples() + 0.5) << endl; + cout << c.AlphaLine(c.BetaLines() + 0.5) << endl; cout << endl; cout << "3rd Test Beta" << endl; @@ -77,17 +77,17 @@ int main () { cout << endl; try { - Isis::Pvl lab; - lab.AddObject(Isis::PvlObject("IsisCube")); - Isis::PvlObject &isiscube = lab.FindObject("IsisCube"); - isiscube.AddGroup(Isis::PvlGroup("Dimensions")); - Isis::PvlGroup &dims = isiscube.FindGroup("Dimensions"); - dims += Isis::PvlKeyword("Samples",4); - dims += Isis::PvlKeyword("Lines",8); - c.UpdateGroup(lab); - cout << lab << endl; + Isis::Pvl lab; + lab.AddObject(Isis::PvlObject("IsisCube")); + Isis::PvlObject &isiscube = lab.FindObject("IsisCube"); + isiscube.AddGroup(Isis::PvlGroup("Dimensions")); + Isis::PvlGroup &dims = isiscube.FindGroup("Dimensions"); + dims += Isis::PvlKeyword("Samples", 4); + dims += Isis::PvlKeyword("Lines", 8); + c.UpdateGroup(lab); + cout << lab << endl; } - catch (Isis::iException &e) { + catch(Isis::iException &e) { e.Report(false); } diff --git a/isis/src/base/objs/Anisotropic1/Anisotropic1.cpp b/isis/src/base/objs/Anisotropic1/Anisotropic1.cpp index 9bf0ff4eb0..d80abf9ac3 100644 --- a/isis/src/base/objs/Anisotropic1/Anisotropic1.cpp +++ b/isis/src/base/objs/Anisotropic1/Anisotropic1.cpp @@ -7,7 +7,7 @@ using std::max; namespace Isis { - Anisotropic1::Anisotropic1 (Pvl &pvl, PhotoModel &pmodel) : AtmosModel(pvl,pmodel) { + Anisotropic1::Anisotropic1(Pvl &pvl, PhotoModel &pmodel) : AtmosModel(pvl, pmodel) { // Set default values p_atmosAlpha0_0 = 0.0; @@ -48,60 +48,59 @@ namespace Isis { * * @param hnorm Atmospheric function parameter, default is 0.003 */ - void Anisotropic1::SetAtmosHnorm (const double hnorm) { - if (hnorm < 0.0) { + void Anisotropic1::SetAtmosHnorm(const double hnorm) { + if(hnorm < 0.0) { std::string msg = "Invalid value of Atmospheric hnorm [" + iString(hnorm) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosHnorm = hnorm; } /** - * Anisotropic atmospheric scattering with P1 single-particle - * phase fn, in the second approximation. This subroutine goes - * through much of the derivation twice, once for the axisymmetric - * (m=0) and once for the m=1 parts of scattered light. - * + * Anisotropic atmospheric scattering with P1 single-particle + * phase fn, in the second approximation. This subroutine goes + * through much of the derivation twice, once for the axisymmetric + * (m=0) and once for the m=1 parts of scattered light. + * * @param phase Value of the phase angle. * @param incidence Value of the incidence angle. * @param emission Value of the emission angle. - * + * * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original * code * @history 1999-03-12 K Teal Thompson Port to Unix/ISIS; * declare vars; add implicit none. * @history 2007-02-20 Janet Barrett - Imported from Isis2 * pht_atm_functions to Isis3. - * @history 2008-11-05 Jeannie Walldren - Replaced - * NumericalMethods::r8expint() with AtmosModel::En(). + * @history 2008-11-05 Jeannie Walldren - Replaced + * NumericalMethods::r8expint() with AtmosModel::En(). * Replaced Isis::PI with PI since this is in Isis * namespace. */ - void Anisotropic1::AtmosModelAlgorithm (double phase, double incidence, double emission) - { + void Anisotropic1::AtmosModelAlgorithm(double phase, double incidence, double emission) { double hpsq1; - double munot,munotp; + double munot, munotp; double maxval; - double mu,mup; + double mu, mup; double xx; - double emunot,emu; - double gmunot,gmu; - double sum,prod; + double emunot, emu; + double gmunot, gmu; + double sum, prod; double cosazss; - double xmunot_0,ymunot_0; - double xmu_0,ymu_0; - double xmunot_1,ymunot_1; - double xmu_1,ymu_1; - double cxx,cyy; + double xmunot_0, ymunot_0; + double xmu_0, ymu_0; + double xmunot_1, ymunot_1; + double xmu_1, ymu_1; + double cxx, cyy; double xystuff; - if (p_atmosBha == 0.0) { + if(p_atmosBha == 0.0) { p_atmosBha = 1.0e-6; } - if (p_atmosTau == 0.0) { + if(p_atmosTau == 0.0) { p_pstd = 0.0; p_trans = 1.0; p_trans0 = 1.0; @@ -109,117 +108,117 @@ namespace Isis { return; } - if (p_atmosWha == 1.0) { + if(p_atmosWha == 1.0) { std::string msg = "Anisotropic conservative case not implemented yet"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - if (TauOrWhaChanged()) { + if(TauOrWhaChanged()) { // preparation includes exponential integrals e sub 2 through 5 p_atmosWha2 = 0.5 * p_atmosWha; p_atmosWham = 1.0 - p_atmosWha; - p_atmosE2 = AtmosModel::En(2,p_atmosTau); - p_atmosE3 = AtmosModel::En(3,p_atmosTau); - p_atmosE4 = AtmosModel::En(4,p_atmosTau); - p_atmosE5 = AtmosModel::En(5,p_atmosTau); + p_atmosE2 = AtmosModel::En(2, p_atmosTau); + p_atmosE3 = AtmosModel::En(3, p_atmosTau); + p_atmosE4 = AtmosModel::En(4, p_atmosTau); + p_atmosE5 = AtmosModel::En(5, p_atmosTau); // first, get the required quantities for the axisymmetric m=0 part // zeroth moments of (uncorrected) x and y times characteristic fn - p_atmosX0_0 = p_atmosWha2 * (1.0 + (1.0/3.0) * p_atmosBha * + p_atmosX0_0 = p_atmosWha2 * (1.0 + (1.0 / 3.0) * p_atmosBha * p_atmosWham); - p_atmosY0_0 = p_atmosWha2 * (p_atmosE2 + p_atmosBha * p_atmosWham * + p_atmosY0_0 = p_atmosWha2 * (p_atmosE2 + p_atmosBha * p_atmosWham * p_atmosE4); // higher-order correction term for x and y p_atmosDelta_0 = (1.0 - (p_atmosX0_0 + p_atmosY0_0) - (1.0 - p_atmosWha * - (1.0 + (1.0/3.0) * p_atmosBha * p_atmosWham)) / (1.0 - - (p_atmosX0_0 - p_atmosY0_0))) / (p_atmosWha * (0.5 - p_atmosE3 + - p_atmosBha * p_atmosWham * (0.25 - p_atmosE5))); + (1.0 + (1.0 / 3.0) * p_atmosBha * p_atmosWham)) / (1.0 - + (p_atmosX0_0 - p_atmosY0_0))) / (p_atmosWha * (0.5 - p_atmosE3 + + p_atmosBha * p_atmosWham * (0.25 - p_atmosE5))); // moments of (corrected) x and y p_atmosAlpha0_0 = 1.0 + p_atmosDelta_0 * (0.5 - p_atmosE3); - p_atmosAlpha1_0 = 0.5 + p_atmosDelta_0 * ((1.0/3.0) - p_atmosE4); + p_atmosAlpha1_0 = 0.5 + p_atmosDelta_0 * ((1.0 / 3.0) - p_atmosE4); p_atmosBeta0_0 = p_atmosE2 + p_atmosDelta_0 * (0.5 - p_atmosE3); - p_atmosBeta1_0 = p_atmosE3 + p_atmosDelta_0 * ((1.0/3.0) - p_atmosE4); + p_atmosBeta1_0 = p_atmosE3 + p_atmosDelta_0 * ((1.0 / 3.0) - p_atmosE4); // gamma will be a weighted sum of m=0 x and y functions // but unlike before, call the weights q1 and p1, and we also // need additional weights q0 and p0 p_atmosFac = 2.0 - p_atmosWha * p_atmosAlpha0_0; - p_atmosDen = pow(p_atmosFac,2.0) - pow(p_atmosWha*p_atmosBeta0_0,2.0); - p_atmosQ0 = p_atmosBha * p_atmosWha * p_atmosWham * (p_atmosFac * - p_atmosAlpha1_0 - p_atmosWha * p_atmosBeta0_0 * p_atmosBeta1_0) / - p_atmosDen; - p_atmosP0 = p_atmosBha * p_atmosWha * p_atmosWham * (-p_atmosFac * - p_atmosBeta1_0 - p_atmosWha * p_atmosBeta0_0 * p_atmosAlpha1_0) / - p_atmosDen; + p_atmosDen = pow(p_atmosFac, 2.0) - pow(p_atmosWha * p_atmosBeta0_0, 2.0); + p_atmosQ0 = p_atmosBha * p_atmosWha * p_atmosWham * (p_atmosFac * + p_atmosAlpha1_0 - p_atmosWha * p_atmosBeta0_0 * p_atmosBeta1_0) / + p_atmosDen; + p_atmosP0 = p_atmosBha * p_atmosWha * p_atmosWham * (-p_atmosFac * + p_atmosBeta1_0 - p_atmosWha * p_atmosBeta0_0 * p_atmosAlpha1_0) / + p_atmosDen; p_atmosQ02p02 = p_atmosQ0 * p_atmosQ0 - p_atmosP0 * p_atmosP0; p_atmosQ1 = (2.0 * p_atmosWham * p_atmosFac) / p_atmosDen; - p_atmosP1 = (2.0 * p_atmosWham * p_atmosWha * p_atmosBeta0_0) / - p_atmosDen; + p_atmosP1 = (2.0 * p_atmosWham * p_atmosWha * p_atmosBeta0_0) / + p_atmosDen; p_atmosQ12p12 = p_atmosQ1 * p_atmosQ1 - p_atmosP1 * p_atmosP1; // sbar is total diffuse illumination and comes from moments - p_sbar = 1.0 - 2.0 * (p_atmosQ1 * p_atmosAlpha1_0 + p_atmosP1 * + p_sbar = 1.0 - 2.0 * (p_atmosQ1 * p_atmosAlpha1_0 + p_atmosP1 * p_atmosBeta1_0); // we're not done yet! still have to calculate the m=1 portion // zeroth moments of (uncorrected) x and y times characteristic fn - p_atmosX0_1 = 0.5 * p_atmosWha2 * p_atmosBha * (1.0 - (1.0/3.0)); + p_atmosX0_1 = 0.5 * p_atmosWha2 * p_atmosBha * (1.0 - (1.0 / 3.0)); p_atmosY0_1 = 0.5 * p_atmosWha2 * p_atmosBha * (p_atmosE2 - p_atmosE4); // higher-order correction term for x and y - p_atmosDelta_1 = (1.0 - (p_atmosX0_1 + p_atmosY0_1) - (1.0 - - (1.0/3.0) * p_atmosWha * p_atmosBha) / (1.0 - (p_atmosX0_1 - - p_atmosY0_1))) / (p_atmosWha2 * p_atmosBha * ((0.5 - 0.25) - - (p_atmosE3 - p_atmosE5))); + p_atmosDelta_1 = (1.0 - (p_atmosX0_1 + p_atmosY0_1) - (1.0 - + (1.0 / 3.0) * p_atmosWha * p_atmosBha) / (1.0 - (p_atmosX0_1 - + p_atmosY0_1))) / (p_atmosWha2 * p_atmosBha * ((0.5 - 0.25) - + (p_atmosE3 - p_atmosE5))); // moments of (corrected) x and y are not needed for m=1, so we're done SetOldTau(p_atmosTau); SetOldWha(p_atmosWha); } // correct the path lengths for planetary curvature - hpsq1 = pow((1.0+p_atmosHnorm),2.0) - 1.0; + hpsq1 = pow((1.0 + p_atmosHnorm), 2.0) - 1.0; - if (incidence == 90.0) { + if(incidence == 90.0) { munot = 0.0; } else { - munot = cos((PI/180.0)*incidence); + munot = cos((PI / 180.0) * incidence); } - maxval = max(1.0e-30,hpsq1+munot*munot); + maxval = max(1.0e-30, hpsq1 + munot * munot); munotp = p_atmosHnorm / (sqrt(maxval) - munot); - munotp = max(munotp,p_atmosTau/69.0); - if (emission == 90.0) { + munotp = max(munotp, p_atmosTau / 69.0); + if(emission == 90.0) { mu = 0.0; } else { - mu = cos((PI/180.0)*emission); + mu = cos((PI / 180.0) * emission); } - maxval = max(1.0e-30,hpsq1+mu*mu); + maxval = max(1.0e-30, hpsq1 + mu * mu); mup = p_atmosHnorm / (sqrt(maxval) - mu); - mup = max(mup,p_atmosTau/69.0); + mup = max(mup, p_atmosTau / 69.0); // build the x and y functions of mu0 and mu - maxval = max(1.0e-30,munotp); + maxval = max(1.0e-30, munotp); xx = -p_atmosTau / maxval; - if (xx < -69.0) { + if(xx < -69.0) { emunot = 0.0; } - else if (xx > 69.0) { + else if(xx > 69.0) { emunot = 1.0e30; } else { - emunot = exp(-p_atmosTau/munotp); + emunot = exp(-p_atmosTau / munotp); } - maxval = max(1.0e-30,mup); + maxval = max(1.0e-30, mup); xx = -p_atmosTau / maxval; - if (xx < -69.0) { + if(xx < -69.0) { emu = 0.0; } - else if (xx > 69.0) { + else if(xx > 69.0) { emu = 1.0e30; } else { - emu = exp(-p_atmosTau/mup); + emu = exp(-p_atmosTau / mup); } // first for m=0 @@ -241,22 +240,22 @@ namespace Isis { // purely atmos term uses x and y of both orders and is complex sum = munot + mu; prod = munot * mu; - cxx = 1.0 - p_atmosQ0 * sum + (p_atmosQ02p02 - p_atmosBha * + cxx = 1.0 - p_atmosQ0 * sum + (p_atmosQ02p02 - p_atmosBha * p_atmosQ12p12) * prod; - cyy = 1.0 + p_atmosQ0 * sum + (p_atmosQ02p02 - p_atmosBha * + cyy = 1.0 + p_atmosQ0 * sum + (p_atmosQ02p02 - p_atmosBha * p_atmosQ12p12) * prod; - if (phase == 90.0) { + if(phase == 90.0) { cosazss = 0.0 - munot * mu; } else { - cosazss = cos((PI/180.0)*phase) - munot * mu; + cosazss = cos((PI / 180.0) * phase) - munot * mu; } xystuff = cxx * xmunot_0 * xmu_0 - cyy * ymunot_0 * ymu_0 - p_atmosP0 * sum * (xmu_0 * ymunot_0 + ymu_0 * - xmunot_0) + cosazss * p_atmosBha * (xmu_1 * - xmunot_1 - ymu_1 * ymunot_1); + xmunot_0) + cosazss * p_atmosBha * (xmu_1 * + xmunot_1 - ymu_1 * ymunot_1); p_pstd = 0.25 * p_atmosWha * munotp / (munotp + mup) * xystuff; // xmitted surface term uses gammas from m=0 @@ -267,6 +266,6 @@ namespace Isis { } } -extern "C" Isis::AtmosModel *Anisotropic1Plugin (Isis::Pvl &pvl, Isis::PhotoModel &pmodel) { - return new Isis::Anisotropic1(pvl,pmodel); +extern "C" Isis::AtmosModel *Anisotropic1Plugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) { + return new Isis::Anisotropic1(pvl, pmodel); } diff --git a/isis/src/base/objs/Anisotropic1/Anisotropic1.h b/isis/src/base/objs/Anisotropic1/Anisotropic1.h index e50f97e07d..98d4991a64 100644 --- a/isis/src/base/objs/Anisotropic1/Anisotropic1.h +++ b/isis/src/base/objs/Anisotropic1/Anisotropic1.h @@ -1,60 +1,60 @@ #if !defined(Anisotropic1_h) #define Anisotropic1_h -/** - * @file - * $Revision: 1.5 $ - * $Date: 2008/11/05 23:36:30 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.5 $ + * $Date: 2008/11/05 23:36:30 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include "AtmosModel.h" namespace Isis { class Pvl; -/** - * @brief - * - * - * @ingroup RadiometricAndPhotometricCorrection - * @author 1998-12-21 Randy Kirk - * - * @internal - * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original - * code. - * @history 2007-02-20 Janet Barrett - Imported from Isis2. - * @history 2007-08-15 Steven Lambright - Refactored code - * @history 2008-03-07 Janet Barrett - Moved code to set standard - * conditions to the AtmosModel class - * @history 2008-06-18 Christopher Austin - Fixed documentation error - * @history 2008-11-05 Jeannie Walldren - Replaced reference to - * NumericalMethods::r8expint() with AtmosModel::En(). - * Added documentation from Isis2. - */ + /** + * @brief + * + * + * @ingroup RadiometricAndPhotometricCorrection + * @author 1998-12-21 Randy Kirk + * + * @internal + * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original + * code. + * @history 2007-02-20 Janet Barrett - Imported from Isis2. + * @history 2007-08-15 Steven Lambright - Refactored code + * @history 2008-03-07 Janet Barrett - Moved code to set standard + * conditions to the AtmosModel class + * @history 2008-06-18 Christopher Austin - Fixed documentation error + * @history 2008-11-05 Jeannie Walldren - Replaced reference to + * NumericalMethods::r8expint() with AtmosModel::En(). + * Added documentation from Isis2. + */ class Anisotropic1 : public AtmosModel { public: - Anisotropic1 (Pvl &pvl, PhotoModel &pmodel); + Anisotropic1(Pvl &pvl, PhotoModel &pmodel); virtual ~Anisotropic1() {}; protected: - virtual void AtmosModelAlgorithm (double phase, double incidence, - double emission); + virtual void AtmosModelAlgorithm(double phase, double incidence, + double emission); private: void SetAtmosHnorm(const double hnorm); diff --git a/isis/src/base/objs/Anisotropic1/unitTest.cpp b/isis/src/base/objs/Anisotropic1/unitTest.cpp index cd81aab969..03f01568c7 100644 --- a/isis/src/base/objs/Anisotropic1/unitTest.cpp +++ b/isis/src/base/objs/Anisotropic1/unitTest.cpp @@ -11,24 +11,24 @@ using namespace Isis; -int main () { +int main() { Isis::Preference::Preferences(true); double pstd; double trans; double trans0; double sbar; - std::cout << "UNIT TEST for Anisotropic1 atmospheric function" << - std::endl << std::endl; + std::cout << "UNIT TEST for Anisotropic1 atmospheric function" << + std::endl << std::endl; PvlGroup algp("Algorithm"); - algp += PvlKeyword("Name","Lambert"); + algp += PvlKeyword("Name", "Lambert"); PvlObject op("PhotometricModel"); op.AddGroup(algp); PvlGroup alga("Algorithm"); - alga += PvlKeyword("Name","Anisotropic1"); + alga += PvlKeyword("Name", "Anisotropic1"); alga += PvlKeyword("Tau", 0.28); alga += PvlKeyword("Bha", 0.85); alga += PvlKeyword("Hnorm", 0.003); @@ -43,11 +43,11 @@ int main () { try { PhotoModel *pm = PhotoModelFactory::Create(pvl); - AtmosModel *am = AtmosModelFactory::Create(pvl,*pm); - + AtmosModel *am = AtmosModelFactory::Create(pvl, *pm); + am->SetStandardConditions(true); std::cout << "Test phase=0.0, incidence=0.0, emission=0.0 (standard conditions) ..." << std::endl; - am->CalcAtmEffect(0.0,0.0,0.0,&pstd,&trans,&trans0,&sbar); + am->CalcAtmEffect(0.0, 0.0, 0.0, &pstd, &trans, &trans0, &sbar); std::cout << "Pstd = " << pstd << std::endl; std::cout << "Trans = " << trans << std::endl; std::cout << "Trans0 = " << trans0 << std::endl; @@ -55,20 +55,20 @@ int main () { am->SetStandardConditions(false); std::cout << "Test phase=86.7226722, incidence=51.7002388, emission=38.9414439 ..." << std::endl; - am->CalcAtmEffect(86.7226722,51.7002388,38.9414439,&pstd,&trans,&trans0,&sbar); + am->CalcAtmEffect(86.7226722, 51.7002388, 38.9414439, &pstd, &trans, &trans0, &sbar); std::cout << "Pstd = " << pstd << std::endl; std::cout << "Trans = " << trans << std::endl; std::cout << "Trans0 = " << trans0 << std::endl; std::cout << "Sbar = " << sbar << std::endl << std::endl; - + std::cout << "Test phase=180.0, incidence=90.0, emission=90.0 ..." << std::endl; - am->CalcAtmEffect(180.0,90.0,90.0,&pstd,&trans,&trans0,&sbar); + am->CalcAtmEffect(180.0, 90.0, 90.0, &pstd, &trans, &trans0, &sbar); std::cout << "Pstd = " << pstd << std::endl; std::cout << "Trans = " << trans << std::endl; std::cout << "Trans0 = " << trans0 << std::endl; std::cout << "Sbar = " << sbar << std::endl << std::endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } diff --git a/isis/src/base/objs/Anisotropic2/Anisotropic2.cpp b/isis/src/base/objs/Anisotropic2/Anisotropic2.cpp index f8bf2daa9c..00aa6e9a6e 100644 --- a/isis/src/base/objs/Anisotropic2/Anisotropic2.cpp +++ b/isis/src/base/objs/Anisotropic2/Anisotropic2.cpp @@ -11,14 +11,14 @@ using std::min; using std::max; namespace Isis { - Anisotropic2::Anisotropic2 (Pvl &pvl, PhotoModel &pmodel) : AtmosModel(pvl,pmodel) { - + Anisotropic2::Anisotropic2(Pvl &pvl, PhotoModel &pmodel) : AtmosModel(pvl, pmodel) { + // Set default value SetAtmosHnorm(0.003); // Get value from user - PvlGroup &algorithm = pvl.FindObject("AtmosphericModel").FindGroup("Algorithm",Pvl::Traverse); - if (algorithm.HasKeyword("Hnorm")) { + PvlGroup &algorithm = pvl.FindObject("AtmosphericModel").FindGroup("Algorithm", Pvl::Traverse); + if(algorithm.HasKeyword("Hnorm")) { SetAtmosHnorm(algorithm["Hnorm"]); } } @@ -33,66 +33,65 @@ namespace Isis { * * @param hnorm Atmospheric function parameter, default is 0.003 */ - void Anisotropic2::SetAtmosHnorm (const double hnorm) { - if (hnorm < 0.0) { + void Anisotropic2::SetAtmosHnorm(const double hnorm) { + if(hnorm < 0.0) { std::string msg = "Invalid value of Atmospheric hnorm [" + iString(hnorm) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosHnorm = hnorm; } /** - * Anisotropic atmospheric scattering with P1 single-particle - * phase fn, in the second approximation. This subroutine goes - * through much of the derivation twice, once for the axisymmetric - * (m=0) and once for the m=1 parts of scattered light. - * + * Anisotropic atmospheric scattering with P1 single-particle + * phase fn, in the second approximation. This subroutine goes + * through much of the derivation twice, once for the axisymmetric + * (m=0) and once for the m=1 parts of scattered light. + * * @param phase Value of the phase angle. * @param incidence Value of the incidence angle. * @param emission Value of the emission angle. - * + * * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original * code * @history 1999-03-12 K Teal Thompson Port to Unix/ISIS; * declare vars; add implicit none. * @history 2007-02-20 Janet Barrett - Imported from Isis2 * pht_atm_functions to Isis3. - * @history 2008-11-05 Jeannie Walldren - Replaced + * @history 2008-11-05 Jeannie Walldren - Replaced * NumericalMethods::r8expint() with AtmosModel::En(), * NumericalMethods::G11Prime() with * AtmosModel::G11Prime(), and NumericalMethods::r8ei() * with AtmosModel::Ei(). Replaced Isis::PI with PI * since this is in Isis namespace. */ - void Anisotropic2::AtmosModelAlgorithm (double phase, double incidence, double emission) - { + void Anisotropic2::AtmosModelAlgorithm(double phase, double incidence, double emission) { double xx; - double munot,mu; - double emunot,emu; - double munotp,mup; - double gmunot,gmu; + double munot, mu; + double emunot, emu; + double munotp, mup; + double gmunot, gmu; double hpsq1; - double f1munot,f2munot,f3munot; - double f1mmunot,f2mmunot,f3mmunot; + double f1munot, f2munot, f3munot; + double f1mmunot, f2mmunot, f3mmunot; double maxval; - double f1mu,f2mu,f3mu; - double f1mmu,f2mmu,f3mmu; + double f1mu, f2mu, f3mu; + double f1mmu, f2mmu, f3mmu; double sum; double prod; double cosazss; double xystuff; - double xmunot_0,ymunot_0; - double xmu_0,ymu_0; - double cxx,cyy; - double xmunot_1,ymunot_1; - double xmu_1,ymu_1; + double xmunot_0, ymunot_0; + double xmu_0, ymu_0; + double cxx, cyy; + double xmunot_1, ymunot_1; + double xmu_1, ymu_1; - if (p_atmosBha == 0.0) { + if(p_atmosBha == 0.0) { p_atmosBha = 1.0e-6; } - if (p_atmosTau == 0.0) { + if(p_atmosTau == 0.0) { p_pstd = 0.0; p_trans = 1.0; p_trans0 = 1.0; @@ -100,28 +99,28 @@ namespace Isis { return; } - if (p_atmosWha == 1.0) { + if(p_atmosWha == 1.0) { std::string msg = "Anisotropic conservative case not implemented yet"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - if (TauOrWhaChanged()) { + if(TauOrWhaChanged()) { // preparation includes exponential integrals e sub 2 through 5 p_wha2 = 0.5 * p_atmosWha; p_wham = 1.0 - p_atmosWha; - p_e1 = AtmosModel::En(1,p_atmosTau); - p_e1_2 = AtmosModel::En(1,2.0*p_atmosTau); - p_e2 = AtmosModel::En(2,p_atmosTau); - p_e3 = AtmosModel::En(3,p_atmosTau); - p_e4 = AtmosModel::En(4,p_atmosTau); - p_e5 = AtmosModel::En(5,p_atmosTau); + p_e1 = AtmosModel::En(1, p_atmosTau); + p_e1_2 = AtmosModel::En(1, 2.0 * p_atmosTau); + p_e2 = AtmosModel::En(2, p_atmosTau); + p_e3 = AtmosModel::En(3, p_atmosTau); + p_e4 = AtmosModel::En(4, p_atmosTau); + p_e5 = AtmosModel::En(5, p_atmosTau); // chandra's gmn functions require fm and fn at mu=-1 xx = -p_atmosTau; - if (xx < -69.0) { + if(xx < -69.0) { p_em = 0.0; } - else if (xx > 69.0) { + else if(xx > 69.0) { p_em = 1.0e30; } else { @@ -131,20 +130,20 @@ namespace Isis { p_f1m = log(2.0) - p_em * p_e1 + p_e1_2; p_f2m = -1.0 * (p_f1m + p_em * p_e2 - 1.0); p_f3m = -1.0 * (p_f2m + p_em * p_e3 - 0.5); - p_f4m = -1.0 * (p_f3m + p_em * p_e4 - (1.0/3.0)); + p_f4m = -1.0 * (p_f3m + p_em * p_e4 - (1.0 / 3.0)); p_g12 = (p_atmosTau * p_e1 * p_e2 + p_f1m + p_f2m) * 0.5; - p_g13 = (p_atmosTau * p_e1 * p_e3 + p_f1m + p_f3m) * (1.0/3.0); + p_g13 = (p_atmosTau * p_e1 * p_e3 + p_f1m + p_f3m) * (1.0 / 3.0); p_g14 = (p_atmosTau * p_e1 * p_e4 + p_f1m + p_f4m) * 0.25; p_g32 = (p_atmosTau * p_e3 * p_e2 + p_f3m + p_f2m) * 0.25; p_g33 = (p_atmosTau * p_e3 * p_e3 + p_f3m + p_f3m) * 0.2; - p_g34 = (p_atmosTau * p_e3 * p_e4 + p_f3m * p_f4m) * (1.0/6.0); + p_g34 = (p_atmosTau * p_e3 * p_e4 + p_f3m * p_f4m) * (1.0 / 6.0); // chandra's g'mn functions require g'11 and f at mu=+1 xx = p_atmosTau; - if (xx < -69.0) { + if(xx < -69.0) { p_e = 0.0; } - else if (xx > 69.0) { + else if(xx > 69.0) { p_e = 1.0e30; } else { @@ -154,38 +153,38 @@ namespace Isis { p_f1 = Eulgam() + log(p_atmosTau) + p_e * p_e1; p_f2 = p_f1 + p_e * p_e2 - 1.0; p_f3 = p_f2 + p_e * p_e3 - 0.5; - p_f4 = p_f3 + p_e * p_e4 - (1.0/3.0); + p_f4 = p_f3 + p_e * p_e4 - (1.0 / 3.0); p_g11p = AtmosModel::G11Prime(p_atmosTau); p_g12p = (p_atmosTau * (p_e1 - p_g11p) + p_em * (p_f1 + p_f2)) * 0.25; p_g13p = (p_atmosTau * (0.5 * p_e1 - p_g12p) + p_em * (p_f1 + p_f3)) * 0.2; - p_g14p = (p_atmosTau * ((1.0/3.0) * p_e1 - p_g13p) + p_em * (p_f1 + p_f4)) * (1.0/6.0); - p_g32p = (p_atmosTau * (p_e1 - p_g13p) + p_em * (p_f3 + p_f2)) * (1.0/6.0); + p_g14p = (p_atmosTau * ((1.0 / 3.0) * p_e1 - p_g13p) + p_em * (p_f1 + p_f4)) * (1.0 / 6.0); + p_g32p = (p_atmosTau * (p_e1 - p_g13p) + p_em * (p_f3 + p_f2)) * (1.0 / 6.0); p_g33p = (p_atmosTau * (0.5 * p_e1 - p_g32p) + p_em * (p_f3 + p_f3)) * 0.142857; - p_g34p = (p_atmosTau * ((1.0/3.0) * p_e1 - p_g33p) + p_em * (p_f3 + p_f4)) * 0.125; + p_g34p = (p_atmosTau * ((1.0 / 3.0) * p_e1 - p_g33p) + p_em * (p_f3 + p_f4)) * 0.125; // first, get the required quantities for the axisymmetric m=0 part // zeroth moments of (uncorrected) x and y times characteristic fn - p_x0_0 = p_wha2 * (1.0 + (1.0/3.0) * p_atmosBha * p_wham + p_wha2 * (p_g12 + p_atmosBha * - p_wham * (p_g14 + p_g32) + pow(p_atmosBha, 2.0) * pow(p_wham,2.0) * p_g34)); - p_y0_0 = p_wha2 * (p_e2 + p_atmosBha * p_wham * p_e4 + p_wha2 * (p_g12p - + p_atmosBha * p_wham * (p_g14p + p_g32p) + - pow(p_atmosBha, 2.0) * pow(p_wham,2.0) * p_g34p)); + p_x0_0 = p_wha2 * (1.0 + (1.0 / 3.0) * p_atmosBha * p_wham + p_wha2 * (p_g12 + p_atmosBha * + p_wham * (p_g14 + p_g32) + pow(p_atmosBha, 2.0) * pow(p_wham, 2.0) * p_g34)); + p_y0_0 = p_wha2 * (p_e2 + p_atmosBha * p_wham * p_e4 + p_wha2 * (p_g12p + + p_atmosBha * p_wham * (p_g14p + p_g32p) + + pow(p_atmosBha, 2.0) * pow(p_wham, 2.0) * p_g34p)); // higher-order correction term for x and y - p_delta_0 = (1.0 - (p_x0_0 + p_y0_0) - (1.0 - p_atmosWha * (1.0 + (1.0/3.0) * p_atmosBha * - p_wham)) / (1.0 - (p_x0_0 - p_y0_0))) / (p_atmosWha * (0.5 - p_e3 + p_atmosBha * p_wham * (0.25 - p_e5))); + p_delta_0 = (1.0 - (p_x0_0 + p_y0_0) - (1.0 - p_atmosWha * (1.0 + (1.0 / 3.0) * p_atmosBha * + p_wham)) / (1.0 - (p_x0_0 - p_y0_0))) / (p_atmosWha * (0.5 - p_e3 + p_atmosBha * p_wham * (0.25 - p_e5))); // moments of (corrected) x and y p_alpha0_0 = 1.0 + p_wha2 * (p_g12 + p_atmosBha * p_wham * p_g32) + p_delta_0 * (0.5 - p_e3); - p_alpha1_0 = 0.5 + p_wha2 * (p_g13 + p_atmosBha * p_wham * p_g33) + p_delta_0 * ((1.0/3.0) - p_e4); + p_alpha1_0 = 0.5 + p_wha2 * (p_g13 + p_atmosBha * p_wham * p_g33) + p_delta_0 * ((1.0 / 3.0) - p_e4); p_beta0_0 = p_e2 + p_wha2 * (p_g12p + p_atmosBha * p_wham * p_g32p) + p_delta_0 * (0.5 - p_e3); - p_beta1_0 = p_e3 + p_wha2 * (p_g13p + p_atmosBha * p_wham * p_g33p) + p_delta_0 * ((1.0/3.0) - p_e4); + p_beta1_0 = p_e3 + p_wha2 * (p_g13p + p_atmosBha * p_wham * p_g33p) + p_delta_0 * ((1.0 / 3.0) - p_e4); // gamma will be a weighted sum of m=0 x and y functions // but unlike before, call the weights q1 and p1, and we also // need additional weights q0 and p0 p_fac = 2.0 - p_atmosWha * p_alpha0_0; - p_den = pow(p_fac,2.0) - pow((p_atmosWha*p_beta0_0),2.0); + p_den = pow(p_fac, 2.0) - pow((p_atmosWha * p_beta0_0), 2.0); p_q0 = p_atmosBha * p_atmosWha * p_wham * (p_fac * p_alpha1_0 - p_atmosWha * p_beta0_0 * p_beta1_0) / p_den; p_p0 = p_atmosBha * p_atmosWha * p_wham * (-p_fac * p_beta1_0 - p_atmosWha * p_beta0_0 * p_alpha1_0) / p_den; p_q02p02 = p_q0 * p_q0 - p_p0 * p_p0; @@ -198,87 +197,87 @@ namespace Isis { // we're not done yet! still have to calculate the m=1 portion // zeroth moments of (uncorrected) x and y times characteristic fn - p_x0_1 = 0.5 * p_wha2 * p_atmosBha * (1.0 - (1.0/3.0) + 0.5 * p_wha2 * p_atmosBha * - (p_g12 - (p_g14 + p_g32) + p_g34)); - p_y0_1 = 0.5 * p_wha2 * p_atmosBha * (p_e2 - p_e4 + 0.5 * p_wha2 * p_atmosBha * + p_x0_1 = 0.5 * p_wha2 * p_atmosBha * (1.0 - (1.0 / 3.0) + 0.5 * p_wha2 * p_atmosBha * + (p_g12 - (p_g14 + p_g32) + p_g34)); + p_y0_1 = 0.5 * p_wha2 * p_atmosBha * (p_e2 - p_e4 + 0.5 * p_wha2 * p_atmosBha * (p_g12p - (p_g14p + p_g32p) + p_g34p)); // higher-order correction term for x and y - p_delta_1 = (1.0 - (p_x0_1 + p_y0_1) - (1.0 - (1.0/3.0) * p_atmosWha * p_atmosBha) / + p_delta_1 = (1.0 - (p_x0_1 + p_y0_1) - (1.0 - (1.0 / 3.0) * p_atmosWha * p_atmosBha) / (1.0 - (p_x0_1 - p_y0_1))) / (p_wha2 * p_atmosBha * - ((0.5 - 0.25) - (p_e3 - p_e5))); + ((0.5 - 0.25) - (p_e3 - p_e5))); // moments of (corrected) x and y are not needed for m=1, so we're done SetOldTau(p_atmosTau); SetOldWha(p_atmosWha); - } + } // correct the path lengths for planetary curvature - hpsq1 = pow((1.0+p_atmosHnorm),2.0) - 1.0; + hpsq1 = pow((1.0 + p_atmosHnorm), 2.0) - 1.0; - if (incidence == 90.0) { + if(incidence == 90.0) { munot = 0.0; } else { - munot = cos((PI/180.0)*incidence); + munot = cos((PI / 180.0) * incidence); } - maxval = max(1.0e-30,hpsq1+munot*munot); + maxval = max(1.0e-30, hpsq1 + munot * munot); munotp = p_atmosHnorm / (sqrt(maxval) - munot); - munotp = max(munotp,p_atmosTau/69.0); + munotp = max(munotp, p_atmosTau / 69.0); - if (emission == 90.0) { + if(emission == 90.0) { mu = 0.0; } else { - mu = cos((PI/180.0)*emission); + mu = cos((PI / 180.0) * emission); } - maxval = max(1.0e-30,hpsq1+mu*mu); + maxval = max(1.0e-30, hpsq1 + mu * mu); mup = p_atmosHnorm / (sqrt(maxval) - mu); - mup = max(mup,p_atmosTau/69.0); + mup = max(mup, p_atmosTau / 69.0); // build the x and y functions of mu0 and mu - maxval = max(1.0e-30,munotp); + maxval = max(1.0e-30, munotp); xx = -p_atmosTau / maxval; - if (xx < -69.0) { + if(xx < -69.0) { emunot = 0.0; } - else if (xx > 69.0) { + else if(xx > 69.0) { emunot = 1.0e30; } else { - emunot = exp(-p_atmosTau/munotp); + emunot = exp(-p_atmosTau / munotp); } - maxval = max(1.0e-30,mup); + maxval = max(1.0e-30, mup); xx = -p_atmosTau / maxval; - if (xx < -69.0) { + if(xx < -69.0) { emu = 0.0; } - else if (xx > 69.0) { + else if(xx > 69.0) { emu = 1.0e30; } else { - emu = exp(-p_atmosTau/mup); + emu = exp(-p_atmosTau / mup); } // in the second approximation the x and y include the f1, f3 functions xx = munotp; - if (fabs(xx-1.0) < 1.0e-10) { + if(fabs(xx - 1.0) < 1.0e-10) { f1munot = p_f1; - f1mmunot = xx * (log(1.0+1.0/xx) - p_e1 * emunot + - AtmosModel::En(1,p_atmosTau*(1.0+1.0/xx))); + f1mmunot = xx * (log(1.0 + 1.0 / xx) - p_e1 * emunot + + AtmosModel::En(1, p_atmosTau * (1.0 + 1.0 / xx))); } - else if (xx > 0.0) { - f1munot = xx * (log(xx/(1.0-xx)) + p_e1 / emunot + - AtmosModel::Ei(p_atmosTau*(1.0/xx-1.0))); - f1mmunot = xx * (log(1.0+1.0/xx) - p_e1 * emunot + - AtmosModel::En(1,p_atmosTau*(1.0+1.0/xx))); + else if(xx > 0.0) { + f1munot = xx * (log(xx / (1.0 - xx)) + p_e1 / emunot + + AtmosModel::Ei(p_atmosTau * (1.0 / xx - 1.0))); + f1mmunot = xx * (log(1.0 + 1.0 / xx) - p_e1 * emunot + + AtmosModel::En(1, p_atmosTau * (1.0 + 1.0 / xx))); } else { std::string msg = "Negative length of planetary curvature encountered"; - throw iException::Message(iException::Math,msg,_FILEINFO_); + throw iException::Message(iException::Math, msg, _FILEINFO_); } f2munot = munotp * (f1munot + p_e2 / emunot - 1); @@ -287,17 +286,17 @@ namespace Isis { f3mmunot = -munotp * (f2mmunot + p_e3 * emunot - 0.5); xx = mup; - if (fabs(xx-1.0) < 1.0e-10) { + if(fabs(xx - 1.0) < 1.0e-10) { f1mu = p_f1; - f1mmu = xx * (log(1.0+1.0/xx) - p_e1 * emu + AtmosModel::En(1,p_atmosTau*(1.0+1.0/xx))); + f1mmu = xx * (log(1.0 + 1.0 / xx) - p_e1 * emu + AtmosModel::En(1, p_atmosTau * (1.0 + 1.0 / xx))); } - else if (xx > 0.0) { - f1mu = xx * (log(xx/(1.0-xx)) + p_e1 / emu + AtmosModel::Ei(p_atmosTau*(1.0/xx-1.0))); - f1mmu = xx * (log(1.0+1.0/xx) - p_e1 * emu + AtmosModel::En(1,p_atmosTau*(1.0+1.0/xx))); + else if(xx > 0.0) { + f1mu = xx * (log(xx / (1.0 - xx)) + p_e1 / emu + AtmosModel::Ei(p_atmosTau * (1.0 / xx - 1.0))); + f1mmu = xx * (log(1.0 + 1.0 / xx) - p_e1 * emu + AtmosModel::En(1, p_atmosTau * (1.0 + 1.0 / xx))); } else { std::string msg = "Negative length of planetary curvature encountered"; - throw iException::Message(iException::Math,msg,_FILEINFO_); + throw iException::Message(iException::Math, msg, _FILEINFO_); } f2mu = mup * (f1mu + p_e2 / emu - 1); @@ -307,14 +306,14 @@ namespace Isis { // first for m=0 xmunot_0 = 1.0 + p_wha2 * (f1mmunot + p_atmosBha * p_wham * f3mmunot) + p_delta_0 * munotp * (1.0 - emunot); - ymunot_0 = emunot * (1.0 + p_wha2 * (f1munot + p_atmosBha * p_wham * f3munot)) + + ymunot_0 = emunot * (1.0 + p_wha2 * (f1munot + p_atmosBha * p_wham * f3munot)) + p_delta_0 * munotp * (1.0 - emunot); xmu_0 = 1.0 + p_wha2 * (f1mmu + p_atmosBha * p_wham * f3mmu) + p_delta_0 * mup * (1.0 - emu); ymu_0 = emu * (1.0 + p_wha2 * (f1mu + p_atmosBha * p_wham * f3mu)) + p_delta_0 * mup * (1.0 - emu); - // then for m=1 + // then for m=1 xmunot_1 = 1.0 + 0.5 * p_wha2 * p_atmosBha * (f1mmunot - f3mmunot) + p_delta_1 * munotp * (1.0 - emunot); - ymunot_1 = emunot * (1.0 + 0.5 * p_wha2 * p_atmosBha * + ymunot_1 = emunot * (1.0 + 0.5 * p_wha2 * p_atmosBha * (f1munot - f3munot)) + p_delta_1 * munotp * (1.0 - emunot); xmu_1 = 1.0 + 0.5 * p_wha2 * p_atmosBha * (f1mmu - f3mmu) + p_delta_1 * mup * (1.0 - emu); ymu_1 = emu * (1.0 + 0.5 * p_wha2 * p_atmosBha * (f1mu - f3mu)) + p_delta_1 * mup * (1.0 - emu); @@ -329,16 +328,16 @@ namespace Isis { cxx = 1.0 - p_q0 * sum + (p_q02p02 - p_atmosBha * p_q12p12) * prod; cyy = 1.0 + p_q0 * sum + (p_q02p02 - p_atmosBha * p_q12p12) * prod; - if (phase == 90.0) { + if(phase == 90.0) { cosazss = 0.0 - munot * mu; } else { - cosazss = cos((PI/180.0)*phase) - munot * mu; + cosazss = cos((PI / 180.0) * phase) - munot * mu; } - xystuff = cxx * xmunot_0 * xmu_0 - cyy * ymunot_0 * - ymu_0 - p_p0 * sum * (xmu_0 * ymunot_0 + ymu_0 * xmunot_0) + cosazss * p_atmosBha * (xmu_1 * - xmunot_1 - ymu_1 * ymunot_1); + xystuff = cxx * xmunot_0 * xmu_0 - cyy * ymunot_0 * + ymu_0 - p_p0 * sum * (xmu_0 * ymunot_0 + ymu_0 * xmunot_0) + cosazss * p_atmosBha * (xmu_1 * + xmunot_1 - ymu_1 * ymunot_1); p_pstd = 0.25 * p_atmosWha * munotp / (munotp + mup) * xystuff; // xmitted surface term uses gammas from m=0 @@ -349,8 +348,8 @@ namespace Isis { } } -extern "C" Isis::AtmosModel *Anisotropic2Plugin (Isis::Pvl &pvl, +extern "C" Isis::AtmosModel *Anisotropic2Plugin(Isis::Pvl &pvl, Isis::PhotoModel &pmodel) { - return new Isis::Anisotropic2(pvl,pmodel); + return new Isis::Anisotropic2(pvl, pmodel); } diff --git a/isis/src/base/objs/Anisotropic2/Anisotropic2.h b/isis/src/base/objs/Anisotropic2/Anisotropic2.h index 6f319ef326..e7e8f72c95 100644 --- a/isis/src/base/objs/Anisotropic2/Anisotropic2.h +++ b/isis/src/base/objs/Anisotropic2/Anisotropic2.h @@ -1,63 +1,63 @@ #if !defined(Anisotropic2_h) #define Anisotropic2_h -/** - * @file - * $Revision: 1.5 $ - * $Date: 2008/11/05 23:36:47 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.5 $ + * $Date: 2008/11/05 23:36:47 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include "AtmosModel.h" namespace Isis { class Pvl; -/** - * @brief - * - * - * @ingroup RadiometricAndPhotometricCorrection - * @author 1998-12-21 Randy Kirk - * - * @internal - * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original - * code. - * @history 2007-02-20 Janet Barrett - Imported from Isis2. - * @history 2007-08-15 Steven Lambright - Refactored code - * @history 2008-03-07 Janet Barrett - Moved code to set standard - * conditions to the AtmosModel class - * @history 2008-06-18 Christopher Austin - Fixed documentation error - * @history 2008-11-05 Jeannie Walldren - Replaced references - * to NumericalMethods::r8expint() with - * AtmosModel::En(), NumericalMethods::G11Prime() - * with AtmosModel::G11Prime(), and - * NumericalMethods::r8ei() with AtmosModel::Ei(). - * Added documentation from Isis2. - */ + /** + * @brief + * + * + * @ingroup RadiometricAndPhotometricCorrection + * @author 1998-12-21 Randy Kirk + * + * @internal + * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original + * code. + * @history 2007-02-20 Janet Barrett - Imported from Isis2. + * @history 2007-08-15 Steven Lambright - Refactored code + * @history 2008-03-07 Janet Barrett - Moved code to set standard + * conditions to the AtmosModel class + * @history 2008-06-18 Christopher Austin - Fixed documentation error + * @history 2008-11-05 Jeannie Walldren - Replaced references + * to NumericalMethods::r8expint() with + * AtmosModel::En(), NumericalMethods::G11Prime() + * with AtmosModel::G11Prime(), and + * NumericalMethods::r8ei() with AtmosModel::Ei(). + * Added documentation from Isis2. + */ class Anisotropic2 : public AtmosModel { public: - Anisotropic2 (Pvl &pvl, PhotoModel &pmodel); + Anisotropic2(Pvl &pvl, PhotoModel &pmodel); virtual ~Anisotropic2() {}; protected: - virtual void AtmosModelAlgorithm (double phase, double incidence, - double emission); + virtual void AtmosModelAlgorithm(double phase, double incidence, + double emission); private: void SetAtmosHnorm(const double hnorm); @@ -66,23 +66,23 @@ namespace Isis { double p_wha2; double p_wham; - double p_e1,p_e1_2,p_e2,p_e3,p_e4,p_e5; + double p_e1, p_e1_2, p_e2, p_e3, p_e4, p_e5; double p_em; double p_e; - double p_f1m,p_f2m,p_f3m,p_f4m; - double p_g12,p_g13,p_g14; - double p_g32,p_g33,p_g34; - double p_f1,p_f2,p_f3,p_f4; - double p_g11p,p_g12p,p_g13p,p_g14p; - double p_g32p,p_g33p,p_g34p; - double p_x0_0,p_y0_0; - double p_x0_1,p_y0_1; - double p_delta_0,p_delta_1; - double p_alpha0_0,p_alpha1_0; - double p_beta0_0,p_beta1_0; + double p_f1m, p_f2m, p_f3m, p_f4m; + double p_g12, p_g13, p_g14; + double p_g32, p_g33, p_g34; + double p_f1, p_f2, p_f3, p_f4; + double p_g11p, p_g12p, p_g13p, p_g14p; + double p_g32p, p_g33p, p_g34p; + double p_x0_0, p_y0_0; + double p_x0_1, p_y0_1; + double p_delta_0, p_delta_1; + double p_alpha0_0, p_alpha1_0; + double p_beta0_0, p_beta1_0; double p_fac; double p_den; - double p_p0,p_q0,p_p1,p_q1,p_q02p02,p_q12p12; + double p_p0, p_q0, p_p1, p_q1, p_q02p02, p_q12p12; }; }; diff --git a/isis/src/base/objs/Anisotropic2/unitTest.cpp b/isis/src/base/objs/Anisotropic2/unitTest.cpp index 1bebd39b17..98d50f557c 100644 --- a/isis/src/base/objs/Anisotropic2/unitTest.cpp +++ b/isis/src/base/objs/Anisotropic2/unitTest.cpp @@ -12,7 +12,7 @@ using namespace Isis; -int main () { +int main() { Isis::Preference::Preferences(true); double pstd; double trans; @@ -22,7 +22,7 @@ int main () { std::cout << "UNIT TEST for Anisotropic2 atmospheric function" << std::endl << std::endl; PvlGroup algp("Algorithm"); - algp += PvlKeyword("Name","Lambert"); + algp += PvlKeyword("Name", "Lambert"); PvlObject op("PhotometricModel"); op.AddGroup(algp); @@ -41,10 +41,10 @@ int main () { try { PhotoModel *pm = PhotoModelFactory::Create(pvl); - AtmosModel *am = AtmosModelFactory::Create(pvl,*pm); + AtmosModel *am = AtmosModelFactory::Create(pvl, *pm); am->SetStandardConditions(true); - am->CalcAtmEffect(0.0,0.0,0.0,&pstd,&trans,&trans0,&sbar); + am->CalcAtmEffect(0.0, 0.0, 0.0, &pstd, &trans, &trans0, &sbar); am->SetStandardConditions(false); std::cout << "Test phase=0.0, incidence=0.0, emission=0.0 (standard conditions) ..." << std::endl; @@ -52,9 +52,9 @@ int main () { std::cout << "Trans = " << trans << std::endl; std::cout << "Trans0 = " << trans0 << std::endl; std::cout << "Sbar = " << sbar << std::endl << std::endl; - + am->SetAtmosTau(.28); - am->CalcAtmEffect(86.7226722,51.7002388,38.9414439,&pstd,&trans,&trans0,&sbar); + am->CalcAtmEffect(86.7226722, 51.7002388, 38.9414439, &pstd, &trans, &trans0, &sbar); std::cout << "Test phase=86.7226722, incidence=51.7002388, emission=38.9414439 ..." << std::endl; std::cout << "Pstd = " << pstd << std::endl; @@ -62,15 +62,15 @@ int main () { std::cout << "Trans0 = " << trans0 << std::endl; std::cout << "Sbar = " << sbar << std::endl << std::endl; - am->CalcAtmEffect(180.0,90.0,90.0,&pstd,&trans,&trans0,&sbar); + am->CalcAtmEffect(180.0, 90.0, 90.0, &pstd, &trans, &trans0, &sbar); - std::cout << "Test phase=180.0, incidence=90.0, emission=90.0 ..." << std::endl; + std::cout << "Test phase=180.0, incidence=90.0, emission=90.0 ..." << std::endl; std::cout << "Pstd = " << pstd << std::endl; std::cout << "Trans = " << trans << std::endl; std::cout << "Trans0 = " << trans0 << std::endl; std::cout << "Sbar = " << sbar << std::endl << std::endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } diff --git a/isis/src/base/objs/Application/Application.h b/isis/src/base/objs/Application/Application.h index 30071f36c5..2a1ffe73da 100644 --- a/isis/src/base/objs/Application/Application.h +++ b/isis/src/base/objs/Application/Application.h @@ -81,7 +81,7 @@ namespace Isis { * @history 2010-03-17 Stuart Sides - Added the location of the Qt plugins * into the library path * @history 2010-06-29 Steven Lambright - Added a setlocale to english for - * numeric values + * numeric values */ class Application { public: diff --git a/isis/src/base/objs/AtmosModel/AtmosModel.cpp b/isis/src/base/objs/AtmosModel/AtmosModel.cpp index 167d906eb2..04d7ca0347 100644 --- a/isis/src/base/objs/AtmosModel/AtmosModel.cpp +++ b/isis/src/base/objs/AtmosModel/AtmosModel.cpp @@ -17,22 +17,22 @@ using namespace std; #define MAX(x,y) (((x) > (y)) ? (x) : (y)) namespace Isis { /** - * Create an AtmosModel object. Because this is a pure virtual - * class you can not create an AtmosModel class directly. Instead, + * Create an AtmosModel object. Because this is a pure virtual + * class you can not create an AtmosModel class directly. Instead, * see the @b Isis::AtmosModelFactory class. - * + * * @param pvl @b Isis::Pvl object containing a valid AtmosModel * specification - * @param pmodel PhotoModel object containing valud AtmosModel + * @param pmodel PhotoModel object containing valud AtmosModel * data - * - * @see atmosphericModels.doc - * @internal + * + * @see atmosphericModels.doc + * @internal * @history 2008-11-05 Jeannie Walldren - Replaced arrays with * vectors - * + * */ - AtmosModel::AtmosModel (Pvl &pvl, PhotoModel &pmodel) { + AtmosModel::AtmosModel(Pvl &pvl, PhotoModel &pmodel) { p_atmosAlgorithmName = "Unknown"; p_atmosPM = &pmodel; @@ -63,63 +63,66 @@ namespace Isis { p_trans0 = 0.0; p_standardConditions = false; - PvlGroup &algorithm = pvl.FindObject("AtmosphericModel").FindGroup("Algorithm",Pvl::Traverse); + PvlGroup &algorithm = pvl.FindObject("AtmosphericModel").FindGroup("Algorithm", Pvl::Traverse); - if (algorithm.HasKeyword("Nulneg")) { - SetAtmosNulneg( ((string)algorithm["Nulneg"]).compare("YES") == 0 ); + if(algorithm.HasKeyword("Nulneg")) { + SetAtmosNulneg(((string)algorithm["Nulneg"]).compare("YES") == 0); } else { p_atmosNulneg = false; } - if (algorithm.HasKeyword("Tau")) { - SetAtmosTau( algorithm["Tau"] ); + if(algorithm.HasKeyword("Tau")) { + SetAtmosTau(algorithm["Tau"]); } p_atmosTausave = p_atmosTau; - if (algorithm.HasKeyword("Tauref")) { - SetAtmosTauref( algorithm["Tauref"] ); + if(algorithm.HasKeyword("Tauref")) { + SetAtmosTauref(algorithm["Tauref"]); } - if (algorithm.HasKeyword("Wha")) { - SetAtmosWha( algorithm["Wha"] ); + if(algorithm.HasKeyword("Wha")) { + SetAtmosWha(algorithm["Wha"]); } p_atmosWhasave = p_atmosWha; - if (algorithm.HasKeyword("Wharef")) { - SetAtmosWharef( algorithm["Wharef"] ); - } else { + if(algorithm.HasKeyword("Wharef")) { + SetAtmosWharef(algorithm["Wharef"]); + } + else { p_atmosWharef = p_atmosWha; } - if (algorithm.HasKeyword("Hga")) { - SetAtmosHga( algorithm["Hga"] ); + if(algorithm.HasKeyword("Hga")) { + SetAtmosHga(algorithm["Hga"]); } p_atmosHgasave = p_atmosHga; - if (algorithm.HasKeyword("Hgaref")) { - SetAtmosHgaref( algorithm["Hgaref"] ); - } else { + if(algorithm.HasKeyword("Hgaref")) { + SetAtmosHgaref(algorithm["Hgaref"]); + } + else { p_atmosHgaref = p_atmosHga; } - if (algorithm.HasKeyword("Bha")) { - SetAtmosBha( algorithm["Bha"] ); + if(algorithm.HasKeyword("Bha")) { + SetAtmosBha(algorithm["Bha"]); } p_atmosBhasave = p_atmosBha; - if (algorithm.HasKeyword("Bharef")) { - SetAtmosBharef( algorithm["Bharef"] ); - } else { + if(algorithm.HasKeyword("Bharef")) { + SetAtmosBharef(algorithm["Bharef"]); + } + else { p_atmosBharef = p_atmosBha; } - if (algorithm.HasKeyword("Inc")) { - SetAtmosInc( algorithm["Inc"] ); + if(algorithm.HasKeyword("Inc")) { + SetAtmosInc(algorithm["Inc"]); } - if (algorithm.HasKeyword("Phi")) { - SetAtmosPhi( algorithm["Phi"] ); + if(algorithm.HasKeyword("Phi")) { + SetAtmosPhi(algorithm["Phi"]); } } @@ -127,17 +130,17 @@ namespace Isis { /** * Perform Chandra and Van de Hulst's series approximation * for the g'11 function needed in second order scattering - * theory. + * theory. * - * @param tau normal optical depth of atmosphere - * @returns @b double Value of the g'11 function evaluated + * @param tau normal optical depth of atmosphere + * @returns @b double Value of the g'11 function evaluated * at the given @b tau - * @internal - * @history 1998-12-21 Randy Kirk, USGS - Flagstaff - Original + * @internal + * @history 1998-12-21 Randy Kirk, USGS - Flagstaff - Original * code in Isis2 pht_am_functions - * @history 1999-03-12 K Teal Thompson - Port to Unix/ISIS; + * @history 1999-03-12 K Teal Thompson - Port to Unix/ISIS; * declare vars; c add implicit none. - * @history 2007-02-20 Janet Barrett - Imported from Isis2 to + * @history 2007-02-20 Janet Barrett - Imported from Isis2 to * Isis3 in NumericalMethods class. * @history 2008-11-05 Jeannie Walldren - Moved this method from * NumericalMethods class. @@ -162,66 +165,66 @@ namespace Isis { icnt = 1; fac = -tau; term = fac; - while (fabs(term) > fabs(sum)*tol) { + while(fabs(term) > fabs(sum)*tol) { sum = sum + term; icnt = icnt + 1; fi = (double) icnt; fac = fac * (-tau) / fi; term = fac / (fi * fi); } - elog = log(MAX(1.0e-30,tau)) + eulgam; + elog = log(MAX(1.0e-30, tau)) + eulgam; e1_2 = sum + PI * PI / 12.0 + 0.5 * - pow(elog,2.0); - result = 2.0 * (AtmosModel::En(1,tau) - + elog * AtmosModel::En(2,tau) + pow(elog, 2.0); + result = 2.0 * (AtmosModel::En(1, tau) + + elog * AtmosModel::En(2, tau) - tau * e1_2); return(result); - } + } /** - * This routine computes the exponential integral, - * @a Ei(x). This is defined as - * @f[ + * This routine computes the exponential integral, + * @a Ei(x). This is defined as + * @f[ * Ei(x) = - \int_{-x}^{\infty} * \frac{e^{-t}}{t}\mathrm{d}t * = \int_{-\infty}^{x} * \frac{e^{t}}{t}\mathrm{d}t - * @f] - * for @a x > 0. - * + * @f] + * for @a x > 0. + * * For small @a x, this method uses the power series, - * @f[ + * @f[ * Ei(x) = \gamma + \ln x + \frac{x}{1*1!} + \frac{x^2}{2*2!} * + ... - * @f] where @f$ \gamma = 0.5772156649... @f$ is Euler's - * constant, and for large @a x, the asymptotic series is - * used, - * @f[ + * @f] where @f$ \gamma = 0.5772156649... @f$ is Euler's + * constant, and for large @a x, the asymptotic series is + * used, + * @f[ * Ei(x) \sim \frac{e^x}{x} (1 + \frac{1!}{x} + * \frac{2!}{x^2} + ...) - * @f] - * - * @see mathworld.wolfram.com/ExponentialIntegral.html + * @f] + * + * @see mathworld.wolfram.com/ExponentialIntegral.html - * @param x Value at which the exponential integral will be + * @param x Value at which the exponential integral will be * computed, @a x > 0.0 * @returns @b double The exponential integral for the given * @a x. - * @throws Isis::iException::Programmer "Invalid arguments. + * @throws Isis::iException::Programmer "Invalid arguments. * Definition requires x > 0.0." - * @throws Isis::iException::Math "Power series failed to + * @throws Isis::iException::Math "Power series failed to * converge" - * @internal - * @history 1999-08-11 K Teal Thompson - Original + * @internal + * @history 1999-08-11 K Teal Thompson - Original * version named pht_r8ei in Isis2. - * @history 2007-02-20 Janet Barrett - Imported to Isis3 in + * @history 2007-02-20 Janet Barrett - Imported to Isis3 in * NumericalMethods class named r8ei(). - * @history 2008-11-05 Jeannie Walldren - Renamed and modified + * @history 2008-11-05 Jeannie Walldren - Renamed and modified * input parameters. Added documentation. */ - double AtmosModel::Ei (double x) throw (iException &){ + double AtmosModel::Ei(double x) throw(iException &) { //static double r8ei(double x) in original NumericalMethods class - // This method was derived from an algorithm in the text + // This method was derived from an algorithm in the text // Numerical Recipes in C: The Art of Scientific Computing // Section 6.3 by Flannery, Press, Teukolsky, and Vetterling double result; @@ -229,53 +232,53 @@ namespace Isis { double euler; // Euler's constant, lower-case gamma double epsilon; // desired relative error (tolerance) int maxit; // maximum number of iterations allowed - double sum,fact,term,prev; + double sum, fact, term, prev; fpmin = 1.0e-30; maxit = 100; epsilon = 6.0e-8; euler = 0.57721566; - if (x <= 0.0) { + if(x <= 0.0) { throw iException::Message(iException::Programmer, "AtmosModel::Ei() - Invalid argument. Definition requires x > 0.0. Entered x = " + iString(x), _FILEINFO_); } - if (x < fpmin) { //special case: avoid failure of convergence test because underflow + if(x < fpmin) { //special case: avoid failure of convergence test because underflow result = log(x) + euler; - } - else if (x <= -log(epsilon)) { //Use power series + } + else if(x <= -log(epsilon)) { //Use power series sum = 0.0; fact = 1.0; - for (int k=1; k<=maxit; k++) { + for(int k = 1; k <= maxit; k++) { fact = fact * x / k; term = fact / k; sum = sum + term; - if (term < epsilon*sum) { + if(term < epsilon * sum) { result = sum + log(x) + euler; return(result); } } throw iException::Message(iException::Math, - "AtmosModel::Ei() - Power series failed to converge in " + "AtmosModel::Ei() - Power series failed to converge in " + iString(maxit) + " iterations. Unable to calculate exponential integral.", _FILEINFO_); - } + } else { // Use asymptotic series sum = 0.0; term = 1.0; - for (int k=1; k<=maxit; k++) { + for(int k = 1; k <= maxit; k++) { prev = term; term = term * k / x; - if (term < epsilon) { + if(term < epsilon) { result = exp(x) * (1.0 + sum) / x; return(result); - } + } else { - if (term < prev) { // still converging: add new term + if(term < prev) { // still converging: add new term sum = sum + term; - } + } else { // diverging: subtract previous term and exit sum = sum - prev; result = exp(x) * (1.0 + sum) / x; @@ -288,93 +291,93 @@ namespace Isis { return(result); } - /** - * This routine evaluates the generalized exponential integral, - * @a En(x). This is defined as - * @f[ + /** + * This routine evaluates the generalized exponential integral, + * @a En(x). This is defined as + * @f[ * E_n(x) = \int_{1}^{\infty} \frac{e^{-xt}}{t^n}\mathrm{d}t * \mathrm{ for } x \in \mathbb{R }, n \in \mathbb{Z } * \mathrm{such that } x \ge 0.0, n \ge 0 - * @f] - * Notice that if @a x = 0, then the equation is not defined - * for @a n = 0 or @a n = 1, as these will result in @f$ - * E_n(x) = \infty @f$. - * + * @f] + * Notice that if @a x = 0, then the equation is not defined + * for @a n = 0 or @a n = 1, as these will result in @f$ + * E_n(x) = \infty @f$. + * * This method uses the following for cases: *
    - *
  • For n > 1 and x = 0.0, - * @f[ + *
  • For n > 1 and x = 0.0, + * @f[ * E_n(0) = \frac{1}{n-1} - * @f] - * + * @f] + * *
  • For n = 0 and x > 0.0, - * @f[ + * @f[ * E_0(x) = \frac{e^{-x}}{x} - * @f] - * + * @f] + * *
  • For @f$ x >\sim 1.0 @f$, Lentz's continued fraction * algorithm is used, - * @f[ + * @f[ * E_n(x) = e^{-x}(\frac{1}{x + n - \frac{1*n}{x + n + 2 - * \frac{2(n+1)}{x + n + 4 - ...}}}) - * @f] - * + * @f] + * *
  • For @f$ 0.0 < x <\sim 1.0 @f$, series representation is * used, - * @f[ + * @f[ * E_n(x) = \frac{(-x)^{n-1}}{(n-1)!}[- \ln x + \psi (n)] - * \sum_{m=0, m \neq n-1}^{\infty}\frac{(-x)^m}{(m-n+1)m!} - * @f] where @f$ \psi (1) = \gamma @f$ and @f$ \psi (n) = - + * @f] where @f$ \psi (1) = \gamma @f$ and @f$ \psi (n) = - * \gamma + \sum_{m=1}^{n-1} \frac{1}{m}@f$ and @f$ \gamma = - * 0.5772156649... @f$ is Euler's constant. + * 0.5772156649... @f$ is Euler's constant. *
- * - * The parameter @a n is of type @b unsigned @b int since @a n - * cannot be negative. - * - * The routine allows fast evaluation of - * @a En(x) to any accuracy, @f$\epsilon@f$, - * within the reach of your machine's word length for - * floating-point numbers. The only modification required for - * increased accuracy is to supply Euler's constant with enough - * significant digits. - * - * @see mathworld.wolfram.com/En-Function.html - * - * @param n Integer value at which the exponential integral + * + * The parameter @a n is of type @b unsigned @b int since @a n + * cannot be negative. + * + * The routine allows fast evaluation of + * @a En(x) to any accuracy, @f$\epsilon@f$, + * within the reach of your machine's word length for + * floating-point numbers. The only modification required for + * increased accuracy is to supply Euler's constant with enough + * significant digits. + * + * @see mathworld.wolfram.com/En-Function.html + * + * @param n Integer value at which the exponential integral * will be evaluated (n >= 0) - * @param x The exponential integral En(x) will be evaluated - * @returns @b double Value of the exponential integral for + * @param x The exponential integral En(x) will be evaluated + * @returns @b double Value of the exponential integral for * the give n and x. - * @throws Isis::iException::Programmer "Invalid arguments. + * @throws Isis::iException::Programmer "Invalid arguments. * Definition requires (x > 0.0 and n >=0 ) or (x >= * 0.0 and n > 1)." - * @throws Isis::iException::Math "Continued fraction failed to + * @throws Isis::iException::Math "Continued fraction failed to * converge" - * @throws Isis::iException::Math "Series representation failed to converge" - * @internal - * @history 1999-08-10 K Teal Thompson - Original version in + * @throws Isis::iException::Math "Series representation failed to converge" + * @internal + * @history 1999-08-10 K Teal Thompson - Original version in * named pht_r8expint Isis2. - * @history 2007-02-20 Janet Barrett - Imported to Isis3 in + * @history 2007-02-20 Janet Barrett - Imported to Isis3 in * NumericalMethods class named r8expint(). - * @history 2008-11-05 Jeannie Walldren - Renamed and modified + * @history 2008-11-05 Jeannie Walldren - Renamed and modified * input parameters. Added documentation. */ - double AtmosModel::En (unsigned int n, double x) throw (iException &){ + double AtmosModel::En(unsigned int n, double x) throw(iException &) { //static double r8expint(int n, double x) in original NumericalMethods class - // This method was derived from an algorithm in the text + // This method was derived from an algorithm in the text // Numerical Recipes in C: The Art of Scientific Computing // Section 6.3 by Flannery, Press, Teukolsky, and Vetterling int nm1; double result; - double a,b,c,d,h; + double a, b, c, d, h; double delta; double fact; double psi; - double fpmin; // close to smallest representable floating-point number - double maxit; // maximum number of iterations allowed - double epsilon; // desired relative error (tolerance) - double euler; // Euler's constant, gamma + double fpmin; // close to smallest representable floating-point number + double maxit; // maximum number of iterations allowed + double epsilon; // desired relative error (tolerance) + double euler; // Euler's constant, gamma fpmin = 1.0e-30; maxit = 100; @@ -382,63 +385,63 @@ namespace Isis { euler = 0.5772156649; nm1 = n - 1; - if (n < 0 || x < 0.0 || (x == 0.0 && (n == 0 || n == 1))) { + if(n < 0 || x < 0.0 || (x == 0.0 && (n == 0 || n == 1))) { iString msg = "AtmosModel::En() - Invalid arguments. "; - msg+= "Definition requires (x > 0.0 and n >=0 ) or (x >= 0.0 and n > 1). "; - msg+= "Entered x = " + iString(x) + " and n = " + iString((int) n); - throw iException::Message(iException::Programmer,msg, + msg += "Definition requires (x > 0.0 and n >=0 ) or (x >= 0.0 and n > 1). "; + msg += "Entered x = " + iString(x) + " and n = " + iString((int) n); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); - } - else if (n == 0) { // special case, this implies x > 0 by logic above + } + else if(n == 0) { // special case, this implies x > 0 by logic above result = exp(-x) / x; - } - else if (x == 0.0) { // special case, this implies n > 1 + } + else if(x == 0.0) { // special case, this implies n > 1 result = 1.0 / nm1; - } - else if (x > 1.0) { // Lentz's algorithm, this implies n > 0 + } + else if(x > 1.0) { // Lentz's algorithm, this implies n > 0 b = x + n; c = 1.0 / fpmin; d = 1.0 / b; h = d; - for (int i=1; i<=maxit; i++) { + for(int i = 1; i <= maxit; i++) { a = -i * (nm1 + i); b = b + 2.0; d = 1.0 / (a * d + b); c = b + a / c; delta = c * d; h = h * delta; - if (fabs(delta-1.0) < epsilon) { + if(fabs(delta - 1.0) < epsilon) { result = h * exp(-x); return(result); } } throw iException::Message(iException::Math, "AtmosModel::En() - Continued fraction failed to converge in " - + iString(maxit) + " iterations. Unable to calculate exponential integral.", + + iString(maxit) + " iterations. Unable to calculate exponential integral.", _FILEINFO_); - } + } else { // evaluate series - if (nm1 != 0) { + if(nm1 != 0) { result = 1.0 / nm1; - } + } else { result = -log(x) - euler; } fact = 1.0; - for (int i=1; i<=maxit; i++) { + for(int i = 1; i <= maxit; i++) { fact = -fact * x / i; - if (i != nm1) { + if(i != nm1) { delta = -fact / (i - nm1); - } + } else { psi = -euler; - for (int ii=1; ii<=nm1; ii++) { + for(int ii = 1; ii <= nm1; ii++) { psi = psi + 1.0 / ii; } delta = fact * (-log(x) + psi); } result = result + delta; - if (fabs(delta) < fabs(result)*epsilon) { + if(fabs(delta) < fabs(result)*epsilon) { return(result); } } @@ -451,23 +454,23 @@ namespace Isis { } /** - * Calculate the atmospheric scattering effect using photometric angle + * Calculate the atmospheric scattering effect using photometric angle * information - * + * * @param pha phase angle * @param inc incidence angle * @param ema emission angle - * @param pstd pure atmospheric-scattering term - * @param trans transmission of surface reflected light through + * @param pstd pure atmospheric-scattering term + * @param trans transmission of surface reflected light through * the atmosphere overall * @param trans0 transmission of surface reflected light * through the atmosphere with no scatterings in the * atmosphere * @param sbar illumination of the ground by the sky - * @throw Isis::iException::User "Invalid photometric angles" + * @throw Isis::iException::User "Invalid photometric angles" */ - void AtmosModel::CalcAtmEffect(double pha, double inc, double ema, - double *pstd, double *trans, double *trans0, double *sbar) { + void AtmosModel::CalcAtmEffect(double pha, double inc, double ema, + double *pstd, double *trans, double *trans0, double *sbar) { // Check validity of photometric angles //if (pha > 180.0 || inc > 90.0 || ema > 90.0 || pha < 0.0 || @@ -477,19 +480,19 @@ namespace Isis { //} // Apply atmospheric function - AtmosModelAlgorithm(pha,inc,ema); + AtmosModelAlgorithm(pha, inc, ema); *pstd = p_pstd; *trans = p_trans; *trans0 = p_trans0; *sbar = p_sbar; } - /** + /** * Used to calculate atmosphere at standard conditions */ void AtmosModel::SetStandardConditions(bool standard) { p_standardConditions = standard; - if (p_standardConditions) { + if(p_standardConditions) { p_atmosBhasave = p_atmosBha; p_atmosBha = p_atmosBharef; p_atmosHgasave = p_atmosHga; @@ -498,7 +501,8 @@ namespace Isis { p_atmosTau = p_atmosTauref; p_atmosWhasave = p_atmosWha; p_atmosWha = p_atmosWharef; - } else { + } + else { p_atmosBha = p_atmosBhasave; p_atmosHga = p_atmosHgasave; p_atmosTau = p_atmosTausave; @@ -506,39 +510,39 @@ namespace Isis { } } - /** - * This method computes the values of the atmospheric Ah - * table and sets the properties of the atmospheric Ah spline. - * It obtains the hemispheric albedo by integrating the - * photometric function times mu over mu = 0 to 1 and then over - * phi = 0 to 2*pi to calculate the hemispheric reflectance Ah - * needed for the photometric model with atmosphere. The - * Trapezoid rule is applied to the table of Ah to obtain + /** + * This method computes the values of the atmospheric Ah + * table and sets the properties of the atmospheric Ah spline. + * It obtains the hemispheric albedo by integrating the + * photometric function times mu over mu = 0 to 1 and then over + * phi = 0 to 2*pi to calculate the hemispheric reflectance Ah + * needed for the photometric model with atmosphere. The + * Trapezoid rule is applied to the table of Ah to obtain * bihemispheric albedo Ab. The parameter @a p_atmosAtmSwitch is - * set to 0 to integrate Ah. - * - * @internal - * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original + * set to 0 to integrate Ah. + * + * @internal + * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original * specs * @history 1999-01-15 K Teal Thompson - Original code - * @history 2000-12-29 Randy Kirk - Modified /hide_inc/ so phi + * @history 2000-12-29 Randy Kirk - Modified /hide_inc/ so phi * gets passed, etc. moved factors to outside * integration - * @history 2006-05-30 Randy Kirk - Added code to report the + * @history 2006-05-30 Randy Kirk - Added code to report the * directional hemispheric albedo that relates to * thermal balance for simulating Themis images - * @history 2007-02-20 Janet Barrett - Imported to Isis3 from + * @history 2007-02-20 Janet Barrett - Imported to Isis3 from * Isis2 pht_get_ah_table * @history 2008-11-05 Jeannie Walldren - Modified references to * NumericalMethods and replaced r8qromb() with * NumericalAtmosApprox::RombergsMethod(). Changed * name from PhtGetAhTable(). */ - void AtmosModel::GenerateAhTable() { + void AtmosModel::GenerateAhTable() { int inccnt; //for loop incidence angle count, 1:ninc double fun_temp;//temporary variable for integral double factor; //factor for integration: 1 except at ends of interval where it's 1/2 - double yp1,yp2; //first derivatives of first and last x values of @a p_atmosIncTable + double yp1, yp2; //first derivatives of first and last x values of @a p_atmosIncTable NumericalAtmosApprox::IntegFunc sub; sub = NumericalAtmosApprox::OuterFunction; @@ -548,43 +552,43 @@ namespace Isis { //Create NumericalAtmosApprox object here for RombergsMethod used in for loop NumericalAtmosApprox qromb; - for (inccnt=0; inccntAlgorithmName(); phtName.UpCase(); - if (p_atmosInc == 90.0) { + if(p_atmosInc == 90.0) { p_atmosAhTable[inccnt] = 0.0; } - else if (phtName == "LAMBERT") { + else if(phtName == "LAMBERT") { p_atmosAhTable[inccnt] = 1.0; } - else if (phtName == "LOMMELSEELIGER") { - p_atmosAhTable[inccnt] = 2.0 * log((1.0/p_atmosMunot)/p_atmosMunot); + else if(phtName == "LOMMELSEELIGER") { + p_atmosAhTable[inccnt] = 2.0 * log((1.0 / p_atmosMunot) / p_atmosMunot); } - else if (phtName == "MINNAERT") { - p_atmosAhTable[inccnt] = (pow(p_atmosMunot,((Minnaert*)p_atmosPM)->PhotoK()))/((Minnaert*)p_atmosPM)->PhotoK(); + else if(phtName == "MINNAERT") { + p_atmosAhTable[inccnt] = (pow(p_atmosMunot, ((Minnaert *)p_atmosPM)->PhotoK())) / ((Minnaert *)p_atmosPM)->PhotoK(); } - else if (phtName == "LUNARLAMBERT") { - p_atmosAhTable[inccnt] = 2.0 * ((LunarLambert*)p_atmosPM)->PhotoL() * - log((1.0+p_atmosMunot)/p_atmosMunot) + 1.0 - - ((LunarLambert*)p_atmosPM)->PhotoL(); + else if(phtName == "LUNARLAMBERT") { + p_atmosAhTable[inccnt] = 2.0 * ((LunarLambert *)p_atmosPM)->PhotoL() * + log((1.0 + p_atmosMunot) / p_atmosMunot) + 1.0 - + ((LunarLambert *)p_atmosPM)->PhotoL(); } else { - // numerically integrate the other photometric models - // outer integral is over phi from 0 to pi rad = 180 deg + // numerically integrate the other photometric models + // outer integral is over phi from 0 to pi rad = 180 deg p_atmosAtmSwitch = 0; // integrate AtmosModel function from 0 to 180 - fun_temp = qromb.RombergsMethod(this,sub,0,180); + fun_temp = qromb.RombergsMethod(this, sub, 0, 180); // the correct normalization with phi in degrees is: - p_atmosAhTable[inccnt] = fun_temp / (90.0*p_atmosMunot); + p_atmosAhTable[inccnt] = fun_temp / (90.0 * p_atmosMunot); } // Let's get our estimate of Ab by integrating (summing) - // A (i)sinicosi over our A table - if ((inccnt == 0) || (inccnt == p_atmosNinc-1)) { + // A (i)sinicosi over our A table + if((inccnt == 0) || (inccnt == p_atmosNinc - 1)) { factor = 0.5; } else { @@ -594,7 +598,7 @@ namespace Isis { p_atmosAb = p_atmosAb + p_atmosAhTable[inccnt] * p_atmosMunot * p_atmosSini * factor; } - factor = 2.0 * PI/180.0; + factor = 2.0 * PI / 180.0; p_atmosAb = p_atmosAb * factor; // set up clamped cubic spline @@ -602,44 +606,44 @@ namespace Isis { yp2 = 1.0e30; p_atmosAhSpline.Reset(); p_atmosAhSpline.SetInterpType(NumericalApproximation::CubicClamped); - p_atmosAhSpline.AddData(p_atmosIncTable,p_atmosAhTable); - p_atmosAhSpline.SetCubicClampedEndptDeriv(yp1,yp2); + p_atmosAhSpline.AddData(p_atmosIncTable, p_atmosAhTable); + p_atmosAhSpline.SetCubicClampedEndptDeriv(yp1, yp2); } /** - * This method computes the values of the atmospheric Hahg and - * Hahg0 tables and sets the properties of the atmospheric Hahg - * and Hahg0 splines. It integrates functions involving the - * single particle phase function (assumed to be Hapke - * Henyey-Greenstein) over mu = 0 to 1 and then over phi = 0 to - * 2*pi to calculate the corrections needed for the anisotropic - * photometric model with atmosphere. The Trapezoid rule is - * applied to the table of Ah to obtain bihemispheric albedo Ab. - * The parameter @a p_atmosAtmSwitch is set to 1, 2, 3 to - * evaluate the 3 required integrals. - * - * @internal - * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original + * This method computes the values of the atmospheric Hahg and + * Hahg0 tables and sets the properties of the atmospheric Hahg + * and Hahg0 splines. It integrates functions involving the + * single particle phase function (assumed to be Hapke + * Henyey-Greenstein) over mu = 0 to 1 and then over phi = 0 to + * 2*pi to calculate the corrections needed for the anisotropic + * photometric model with atmosphere. The Trapezoid rule is + * applied to the table of Ah to obtain bihemispheric albedo Ab. + * The parameter @a p_atmosAtmSwitch is set to 1, 2, 3 to + * evaluate the 3 required integrals. + * + * @internal + * @history 1998-12-21 Randy Kirk - USGS, Flagstaff - Original * specs * @history 1999-01-15 K Teal Thompson - Original code - * @history 2006-07-07 Randy Kirk - Modify get_ah_table to get + * @history 2006-07-07 Randy Kirk - Modify get_ah_table to get * other integrals - * @history 2000-12-29 Randy Kirk - Modified /hide_inc/ so phi + * @history 2000-12-29 Randy Kirk - Modified /hide_inc/ so phi * gets passed, etc. moved factors to outside * integration - * @history 2007-02-20 Janet Barrett - Imported to Isis3 from + * @history 2007-02-20 Janet Barrett - Imported to Isis3 from * Isis2 pht_get_ah_table * @history 2008-11-05 Jeannie Walldren - Modified references to * NumericalMethods and replaced r8qromb() with * NumericalAtmosApprox::RombergsMethod(). Changed - * name from GetHahgTables(). + * name from GetHahgTables(). */ - void AtmosModel::GenerateHahgTables() { + void AtmosModel::GenerateHahgTables() { int inccnt; // for loop incidence angle count,1:ninc double fun_temp; // temporary variable for integral double hahgsb_temp; // save increment to hahgsb double factor; // factor for integration: 1 except at ends of interval where it's 1/2 - double yp1,yp2; // derivatives of endpoints of data set + double yp1, yp2; // derivatives of endpoints of data set NumericalAtmosApprox::IntegFunc sub; sub = NumericalAtmosApprox::OuterFunction; @@ -647,25 +651,25 @@ namespace Isis { p_atmosHahgsb = 0.0; NumericalAtmosApprox qromb; - for (inccnt = 0; inccnt < p_atmosNinc; inccnt++) { + for(inccnt = 0; inccnt < p_atmosNinc; inccnt++) { p_atmosInc = (double) inccnt; p_atmosIncTable[inccnt] = p_atmosInc; - p_atmosMunot = cos((PI/180.0)*p_atmosInc); - p_atmosSini = sin((PI/180.0)*p_atmosInc); + p_atmosMunot = cos((PI / 180.0) * p_atmosInc); + p_atmosSini = sin((PI / 180.0) * p_atmosInc); p_atmosAtmSwitch = 1; qromb.Reset(); - fun_temp = qromb.RombergsMethod(this,sub,0,180); + fun_temp = qromb.RombergsMethod(this, sub, 0, 180); p_atmosHahgtTable[inccnt] = fun_temp * AtmosWha() / 360.0; p_atmosAtmSwitch = 2; - fun_temp = qromb.RombergsMethod(this,sub,0,180); + fun_temp = qromb.RombergsMethod(this, sub, 0, 180); hahgsb_temp = fun_temp * AtmosWha() / 360.0; - if ((inccnt == 0) || (inccnt == p_atmosNinc-1)) { + if((inccnt == 0) || (inccnt == p_atmosNinc - 1)) { factor = 0.5; } else { @@ -673,17 +677,17 @@ namespace Isis { } p_atmosHahgsb = p_atmosHahgsb + p_atmosSini * factor * hahgsb_temp; - if (p_atmosInc == 0.0) { + if(p_atmosInc == 0.0) { p_atmosHahgt0Table[inccnt] = 0.0; } else { p_atmosAtmSwitch = 3; - fun_temp = qromb.RombergsMethod(this,sub,0,180); + fun_temp = qromb.RombergsMethod(this, sub, 0, 180); p_atmosHahgt0Table[inccnt] = fun_temp * AtmosWha() * p_atmosMunot / (360.0 * p_atmosSini); } } - factor = 2.0 * PI/180.0; + factor = 2.0 * PI / 180.0; p_atmosHahgsb = p_atmosHahgsb * factor; // set up clamped cubic splines @@ -691,30 +695,30 @@ namespace Isis { yp2 = 1.0e30; p_atmosHahgtSpline.Reset(); p_atmosHahgtSpline.SetInterpType(NumericalApproximation::CubicClamped); - p_atmosHahgtSpline.AddData(p_atmosIncTable,p_atmosHahgtTable); - p_atmosHahgtSpline.SetCubicClampedEndptDeriv(yp1,yp2); + p_atmosHahgtSpline.AddData(p_atmosIncTable, p_atmosHahgtTable); + p_atmosHahgtSpline.SetCubicClampedEndptDeriv(yp1, yp2); p_atmosHahgt0Spline.Reset(); p_atmosHahgt0Spline.SetInterpType(NumericalApproximation::CubicClamped); - p_atmosHahgt0Spline.AddData(p_atmosIncTable,p_atmosHahgt0Table); - p_atmosHahgt0Spline.SetCubicClampedEndptDeriv(yp1,yp2); + p_atmosHahgt0Spline.AddData(p_atmosIncTable, p_atmosHahgt0Table); + p_atmosHahgt0Spline.SetCubicClampedEndptDeriv(yp1, yp2); } - /** - * Set the switch that controls the function that will be - * integrated. This method is only used for testing the - * methods in this class. This parameter is limited to the - * values 0, 1, 2, and 3. - * - * @param atmswitch Internal atmospheric function parameter, - * there is no default - * @throw Isis::iException::User "Invalid value of atmospheric - * atmswitch" - */ - void AtmosModel::SetAtmosAtmSwitch (const int atmswitch) { - if (atmswitch < 0 || atmswitch > 3) { + /** + * Set the switch that controls the function that will be + * integrated. This method is only used for testing the + * methods in this class. This parameter is limited to the + * values 0, 1, 2, and 3. + * + * @param atmswitch Internal atmospheric function parameter, + * there is no default + * @throw Isis::iException::User "Invalid value of atmospheric + * atmswitch" + */ + void AtmosModel::SetAtmosAtmSwitch(const int atmswitch) { + if(atmswitch < 0 || atmswitch > 3) { string msg = "Invalid value of atmospheric atmswitch [" + iString(atmswitch) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosAtmSwitch = atmswitch; @@ -728,14 +732,14 @@ namespace Isis { * * @param bha Anisotropic atmospheric function parameter, * default is 0.85 - * @throw Isis::iException::User "Invalid value of atmospheric - * bha" + * @throw Isis::iException::User "Invalid value of atmospheric + * bha" */ - void AtmosModel::SetAtmosBha (const double bha) { - if (bha < -1.0 || bha > 1.0) { + void AtmosModel::SetAtmosBha(const double bha) { + if(bha < -1.0 || bha > 1.0) { string msg = "Invalid value of Anisotropic atmospheric bha [" + - iString(bha) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + iString(bha) + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosBha = bha; @@ -743,19 +747,19 @@ namespace Isis { /** * Set the Atmospheric function parameter. This specifies the - * reference value of Bha to which the image will be normalized. + * reference value of Bha to which the image will be normalized. * If no value is given, then this parameter defaults to the * value provided for Bha. This parameter is limited to values * that are >=-1 and <=1. * - * @param bharef Atmospheric function parameter, no default - * @throw Isis::iException::User "Invalid value of atmospheric - * bharef" + * @param bharef Atmospheric function parameter, no default + * @throw Isis::iException::User "Invalid value of atmospheric + * bharef" */ - void AtmosModel::SetAtmosBharef (const double bharef) { - if (bharef < -1.0 || bharef > 1.0) { + void AtmosModel::SetAtmosBharef(const double bharef) { + if(bharef < -1.0 || bharef > 1.0) { string msg = "Invalid value of Atmospheric bharef [" + iString(bharef) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosBharef = bharef; @@ -769,13 +773,13 @@ namespace Isis { * * @param hga Hapke atmospheric function parameter, * default is 0.68 - * @throw Isis::iException::User "Invalid value of atmospheric - * hga" + * @throw Isis::iException::User "Invalid value of atmospheric + * hga" */ - void AtmosModel::SetAtmosHga (const double hga) { - if (hga <= -1.0 || hga >= 1.0) { + void AtmosModel::SetAtmosHga(const double hga) { + if(hga <= -1.0 || hga >= 1.0) { string msg = "Invalid value of Hapke atmospheric hga [" + iString(hga) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosHga = hga; @@ -783,19 +787,19 @@ namespace Isis { /** * Set the Atmospheric function parameter. This specifies the - * reference value of Hga to which the image will be normalized. + * reference value of Hga to which the image will be normalized. * If no value is given, then this parameter defaults to the * value provided for Hga. This parameter is limited to values * that are >-1 and <1. * - * @param hgaref Hapke atmospheric function parameter, no default - * @throw Isis::iException::User "Invalid value of atmospheric - * hgaref" + * @param hgaref Hapke atmospheric function parameter, no default + * @throw Isis::iException::User "Invalid value of atmospheric + * hgaref" */ - void AtmosModel::SetAtmosHgaref (const double hgaref) { - if (hgaref <= -1.0 || hgaref >= 1.0) { + void AtmosModel::SetAtmosHgaref(const double hgaref) { + if(hgaref <= -1.0 || hgaref >= 1.0) { string msg = "Invalid value of Atmospheric hgaref [" + iString(hgaref) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosHgaref = hgaref; @@ -808,18 +812,18 @@ namespace Isis { * * @param inc Internal atmospheric function parameter, * there is no default - * @throw Isis::iException::User "Invalid value of atmospheric + * @throw Isis::iException::User "Invalid value of atmospheric * inc" */ - void AtmosModel::SetAtmosInc (const double inc) { - if (inc < 0.0 || inc > 90.0) { + void AtmosModel::SetAtmosInc(const double inc) { + if(inc < 0.0 || inc > 90.0) { string msg = "Invalid value of atmospheric inc [" + iString(inc) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosInc = inc; - p_atmosMunot = cos(inc*PI/180.0); - p_atmosSini = sin(inc*PI/180.0); + p_atmosMunot = cos(inc * PI / 180.0); + p_atmosSini = sin(inc * PI / 180.0); } /** @@ -828,21 +832,21 @@ namespace Isis { * will be set to NULL. This parameter is limited to values * of YES or NO. * - * @param nulneg Atmospheric function parameter, default is NO - * @throw Isis::iException::User "Invalid value of atmospheric + * @param nulneg Atmospheric function parameter, default is NO + * @throw Isis::iException::User "Invalid value of atmospheric * nulneg" - * + * */ - void AtmosModel::SetAtmosNulneg (const string nulneg) { + void AtmosModel::SetAtmosNulneg(const string nulneg) { iString temp(nulneg); temp = temp.UpCase(); - if (temp != "NO" && temp != "YES") { + if(temp != "NO" && temp != "YES") { string msg = "Invalid value of Atmospheric nulneg [" + temp + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } - SetAtmosNulneg( temp.compare("YES") == 0 ); + SetAtmosNulneg(temp.compare("YES") == 0); } /** @@ -852,18 +856,18 @@ namespace Isis { * * @param phi Internal atmospheric function parameter, * there is no default - * @throw Isis::iException::User "Invalid value of atmospheric + * @throw Isis::iException::User "Invalid value of atmospheric * phi" - * + * */ - void AtmosModel::SetAtmosPhi (const double phi) { - if (phi < 0.0 || phi > 360.0) { + void AtmosModel::SetAtmosPhi(const double phi) { + if(phi < 0.0 || phi > 360.0) { string msg = "Invalid value of atmospheric phi [" + iString(phi) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosPhi = phi; - p_atmosCosphi = cos(phi*PI/180.0); + p_atmosCosphi = cos(phi * PI / 180.0); } /** @@ -871,14 +875,14 @@ namespace Isis { * normal optical depth of the atmosphere. This parameter is * limited to values that are >=0. * - * @param tau Atmospheric function parameter, default is 0.28 - * @throw Isis::iException::User "Invalid value of atmospheric - * tau" + * @param tau Atmospheric function parameter, default is 0.28 + * @throw Isis::iException::User "Invalid value of atmospheric + * tau" */ - void AtmosModel::SetAtmosTau (const double tau) { - if (tau < 0.0) { + void AtmosModel::SetAtmosTau(const double tau) { + if(tau < 0.0) { string msg = "Invalid value of Atmospheric tau [" + iString(tau) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosTau = tau; @@ -890,14 +894,14 @@ namespace Isis { * will be normalized. This parameter is limited to values that * are >=0. * - * @param tauref Atmospheric function parameter, default is 0.0 - * @throw Isis::iException::User "Invalid value of atmospheric - * tauref" + * @param tauref Atmospheric function parameter, default is 0.0 + * @throw Isis::iException::User "Invalid value of atmospheric + * tauref" */ - void AtmosModel::SetAtmosTauref (const double tauref) { - if (tauref < 0.0) { + void AtmosModel::SetAtmosTauref(const double tauref) { + if(tauref < 0.0) { string msg = "Invalid value of Atmospheric tauref [" + iString(tauref) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosTauref = tauref; @@ -908,15 +912,15 @@ namespace Isis { * scattering albedo of atmospheric particles. This parameter * is limited to values that are >0 and <=1. * - * @param wha Atmospheric function parameter, default is 0.95 - * @throw Isis::iException::User "Invalid value of atmospheric + * @param wha Atmospheric function parameter, default is 0.95 + * @throw Isis::iException::User "Invalid value of atmospheric * wha" - * + * */ - void AtmosModel::SetAtmosWha (const double wha) { - if (wha <= 0.0 || wha > 1.0) { + void AtmosModel::SetAtmosWha(const double wha) { + if(wha <= 0.0 || wha > 1.0) { string msg = "Invalid value of Atmospheric wha [" + iString(wha) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosWha = wha; @@ -928,14 +932,14 @@ namespace Isis { * the image will be normalized. This parameter is limited to * values that are >0 and <=1. * - * @param wharef Atmospheric function parameter, no default - * @throw Isis::iException::User "Invalid value of atmospheric + * @param wharef Atmospheric function parameter, no default + * @throw Isis::iException::User "Invalid value of atmospheric * wharef" */ - void AtmosModel::SetAtmosWharef (const double wharef) { - if (wharef <= 0.0 || wharef > 1.0) { + void AtmosModel::SetAtmosWharef(const double wharef) { + if(wharef <= 0.0 || wharef > 1.0) { string msg = "Invalid value of Atmospheric wharef [" + iString(wharef) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_atmosWharef = wharef; diff --git a/isis/src/base/objs/AtmosModel/AtmosModel.h b/isis/src/base/objs/AtmosModel/AtmosModel.h index 33bde5c45a..7c252b0247 100644 --- a/isis/src/base/objs/AtmosModel/AtmosModel.h +++ b/isis/src/base/objs/AtmosModel/AtmosModel.h @@ -1,27 +1,27 @@ #ifndef AtmosModel_h #define AtmosModel_h -/** - * @file - * $Revision: 1.10 $ - * $Date: 2008/11/07 23:48:13 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.10 $ + * $Date: 2008/11/07 23:48:13 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include #include @@ -33,47 +33,47 @@ using namespace std; namespace Isis { class Pvl; -/** - * @brief Isotropic atmos scattering model - * - * @ingroup RadiometricAndPhotometricCorrection - * @author 1998-12-21 Randy Kirk - * - * @internal - * @history 2007-02-20 Janet Barrett - Imported from Isis2. - * @history 2007-07-31 Steven Lambright - Fixed unit test - * @history 2007-08-15 Steven Lambright - Refactored - * @history 2008-03-07 Janet Barrett - Added code to set standard - * conditions. Also added bharef, hgaref, tauref, - * and wharef variables and supporting methods. - * @history 2008-06-18 Christopher Austin - Fixed much documentation - * @history 2008-07-09 Steven Lambright - Fixed unit test - * @history 2008-11-05 Jeannie Walldren - Moved numerical - * methods and functions to NumericalMethods and - * NumericalAtmosApprox classes. Moved G11Prime(), - * Ei(), and En() from NumericalMethods into this - * class. Added splines to protected variables and - * removed second derivative vector protected - * variables (p_atmosAhTable2, p_atmosHahgtTable2, - * p_atmosHahgt0Table2) that are no longer needed. - * Replaced arrays with vectors in protected - * variables. Added documentation from Isis2 files. - * Removed "Isis::" and "std::" in AtmosModel.cpp - * since that file uses std and Isis namespaces. - * @history 2008-11-07 Jeannie Walldren - Fixed documentation - */ + /** + * @brief Isotropic atmos scattering model + * + * @ingroup RadiometricAndPhotometricCorrection + * @author 1998-12-21 Randy Kirk + * + * @internal + * @history 2007-02-20 Janet Barrett - Imported from Isis2. + * @history 2007-07-31 Steven Lambright - Fixed unit test + * @history 2007-08-15 Steven Lambright - Refactored + * @history 2008-03-07 Janet Barrett - Added code to set standard + * conditions. Also added bharef, hgaref, tauref, + * and wharef variables and supporting methods. + * @history 2008-06-18 Christopher Austin - Fixed much documentation + * @history 2008-07-09 Steven Lambright - Fixed unit test + * @history 2008-11-05 Jeannie Walldren - Moved numerical + * methods and functions to NumericalMethods and + * NumericalAtmosApprox classes. Moved G11Prime(), + * Ei(), and En() from NumericalMethods into this + * class. Added splines to protected variables and + * removed second derivative vector protected + * variables (p_atmosAhTable2, p_atmosHahgtTable2, + * p_atmosHahgt0Table2) that are no longer needed. + * Replaced arrays with vectors in protected + * variables. Added documentation from Isis2 files. + * Removed "Isis::" and "std::" in AtmosModel.cpp + * since that file uses std and Isis namespaces. + * @history 2008-11-07 Jeannie Walldren - Fixed documentation + */ class AtmosModel { public: - AtmosModel (Pvl &pvl, PhotoModel &pmodel); + AtmosModel(Pvl &pvl, PhotoModel &pmodel); //! Empty destructor virtual ~AtmosModel() {}; // These methods were moved here from the NumericalMethods class - static double G11Prime(double tau); - static double Ei(double x) throw (iException &); - static double En(unsigned int n, double x) throw (iException &); + static double G11Prime(double tau); + static double Ei(double x) throw(iException &); + static double En(unsigned int n, double x) throw(iException &); // Calculate atmospheric scattering effect - void CalcAtmEffect(double pha, double inc, double ema, double *pstd, + void CalcAtmEffect(double pha, double inc, double ema, double *pstd, double *trans, double *trans0, double *sbar); // Used to calculate atmosphere at standard conditions virtual void SetStandardConditions(bool standard); @@ -82,105 +82,159 @@ namespace Isis { // Perform integration for Hapke Henyey-Greenstein atmosphere correction void GenerateHahgTables(); // Set parameters needed for atmospheric correction - void SetAtmosAtmSwitch (const int atmswitch); - void SetAtmosBha (const double bha ); - void SetAtmosBharef (const double bharef); - void SetAtmosHga (const double hga ); - void SetAtmosHgaref (const double hgaref); - void SetAtmosInc (const double inc ); - void SetAtmosNulneg (const string nulneg); - void SetAtmosPhi (const double phi ); - void SetAtmosTau (const double tau ); - void SetAtmosTauref (const double tauref); - void SetAtmosWha (const double wha ); - void SetAtmosWharef (const double wharef); - + void SetAtmosAtmSwitch(const int atmswitch); + void SetAtmosBha(const double bha); + void SetAtmosBharef(const double bharef); + void SetAtmosHga(const double hga); + void SetAtmosHgaref(const double hgaref); + void SetAtmosInc(const double inc); + void SetAtmosNulneg(const string nulneg); + void SetAtmosPhi(const double phi); + void SetAtmosTau(const double tau); + void SetAtmosTauref(const double tauref); + void SetAtmosWha(const double wha); + void SetAtmosWharef(const double wharef); + //! Return atmospheric algorithm name - string AlgorithmName () const { return p_atmosAlgorithmName; }; + string AlgorithmName() const { + return p_atmosAlgorithmName; + }; //! Return atmospheric Bha value - double AtmosBha () const { return p_atmosBha; }; + double AtmosBha() const { + return p_atmosBha; + }; //! Return atmospheric Tau value - double AtmosTau () const { return p_atmosTau; }; + double AtmosTau() const { + return p_atmosTau; + }; //! Return atmospheric Wha value - double AtmosWha () const { return p_atmosWha; }; + double AtmosWha() const { + return p_atmosWha; + }; //! Return atmospheric Hga value - double AtmosHga () const { return p_atmosHga; }; + double AtmosHga() const { + return p_atmosHga; + }; //! Return atmospheric Bharef value - double AtmosBharef () const { return p_atmosBharef; }; + double AtmosBharef() const { + return p_atmosBharef; + }; //! Return atmospheric Hgaref value - double AtmosHgaref () const { return p_atmosHgaref; }; + double AtmosHgaref() const { + return p_atmosHgaref; + }; //! Return atmospheric Tauref value - double AtmosTauref () const { return p_atmosTauref; }; + double AtmosTauref() const { + return p_atmosTauref; + }; //! Return atmospheric Wharef value - double AtmosWharef () const { return p_atmosWharef; }; + double AtmosWharef() const { + return p_atmosWharef; + }; //! Return atmospheric Nulneg value - bool AtmosNulneg () const { return p_atmosNulneg; }; + bool AtmosNulneg() const { + return p_atmosNulneg; + }; //! Return atmospheric Ab value - double AtmosAb () const { return p_atmosAb; }; + double AtmosAb() const { + return p_atmosAb; + }; //! Return atmospheric Hahgsb value - double AtmosHahgsb () const { return p_atmosHahgsb; }; + double AtmosHahgsb() const { + return p_atmosHahgsb; + }; //! Return atmospheric Ninc value - int AtmosNinc () const { return p_atmosNinc; }; + int AtmosNinc() const { + return p_atmosNinc; + }; //! Return atmospheric IncTable value - vector AtmosIncTable () { return p_atmosIncTable; }; + vector AtmosIncTable() { + return p_atmosIncTable; + }; //! Return atmospheric AhTable value - vector AtmosAhTable () { return p_atmosAhTable; }; + vector AtmosAhTable() { + return p_atmosAhTable; + }; //! Return atmospheric HahgtTable value - vector AtmosHahgtTable () { return p_atmosHahgtTable; }; + vector AtmosHahgtTable() { + return p_atmosHahgtTable; + }; //! Return atmospheric Hahgt0Table value - vector AtmosHahgt0Table () { return p_atmosHahgt0Table; }; + vector AtmosHahgt0Table() { + return p_atmosHahgt0Table; + }; /** * If GenerateAhTable() has been called this returns a clamped * cubic spline of the data set (@a p_atmosIncTable, - * @a p_atmosAhTable) with first derivatives of the endpoints - * equal to 1.0e30. Otherwise, it is a natural cubic spline with - * an empty data set. - * - * @returns @b NumericalApproximation Cubic spline - * @internal - * @history 2008-11-05 Jeannie Walldren - Original version + * @a p_atmosAhTable) with first derivatives of the endpoints + * equal to 1.0e30. Otherwise, it is a natural cubic spline with + * an empty data set. + * + * @returns @b NumericalApproximation Cubic spline + * @internal + * @history 2008-11-05 Jeannie Walldren - Original version */ - NumericalApproximation AtmosAhSpline() {return p_atmosAhSpline;}; + NumericalApproximation AtmosAhSpline() { + return p_atmosAhSpline; + }; /** - * If GenerateHahgTables() has been called this returns a - * clamped cubic spline of the data set (@a p_atmosIncTable, + * If GenerateHahgTables() has been called this returns a + * clamped cubic spline of the data set (@a p_atmosIncTable, * @a p_atmosHahgtTable) with first derivatives of the endpoints - * equal to 1.0e30. Otherwise, it is a natural cubic spline with - * an empty data set. - * + * equal to 1.0e30. Otherwise, it is a natural cubic spline with + * an empty data set. + * * @returns @b NumericalApproximation Cubic spline - * @internal - * @history 2008-11-05 Jeannie Walldren - Original version + * @internal + * @history 2008-11-05 Jeannie Walldren - Original version */ - NumericalApproximation AtmosHahgtSpline() {return p_atmosHahgtSpline;}; + NumericalApproximation AtmosHahgtSpline() { + return p_atmosHahgtSpline; + }; /** - * If GenerateHahgTables() has been called this returns a - * clamped cubic spline of the data set (@a p_atmosIncTable, - * @a p_atmosHahgt0Table) with first derivatives of the - * endpoints equal to 1.0e30. Otherwise, it is a natural cubic - * spline with an empty data set. - * + * If GenerateHahgTables() has been called this returns a + * clamped cubic spline of the data set (@a p_atmosIncTable, + * @a p_atmosHahgt0Table) with first derivatives of the + * endpoints equal to 1.0e30. Otherwise, it is a natural cubic + * spline with an empty data set. + * * @returns @b NumericalApproximation Cubic spline - * @internal - * @history 2008-11-05 Jeannie Walldren - Original version + * @internal + * @history 2008-11-05 Jeannie Walldren - Original version */ - NumericalApproximation AtmosHahgt0Spline() {return p_atmosHahgt0Spline;}; - + NumericalApproximation AtmosHahgt0Spline() { + return p_atmosHahgt0Spline; + }; + protected: - virtual void AtmosModelAlgorithm (double phase, double incidence, double emission) = 0; - - void SetAlgorithmName(string name) { p_atmosAlgorithmName = name; } - void SetAtmosNulneg(bool nulneg) { p_atmosNulneg = nulneg; } - void SetOldTau(double tau) { p_atmosTauold = tau; } - void SetOldWha(double wha) { p_atmosWhaold = wha; } - - PhotoModel *GetPhotoModel() const { return p_atmosPM; } - bool StandardConditions() const { return p_standardConditions; } + virtual void AtmosModelAlgorithm(double phase, double incidence, double emission) = 0; + + void SetAlgorithmName(string name) { + p_atmosAlgorithmName = name; + } + void SetAtmosNulneg(bool nulneg) { + p_atmosNulneg = nulneg; + } + void SetOldTau(double tau) { + p_atmosTauold = tau; + } + void SetOldWha(double wha) { + p_atmosWhaold = wha; + } + + PhotoModel *GetPhotoModel() const { + return p_atmosPM; + } + bool StandardConditions() const { + return p_standardConditions; + } bool TauOrWhaChanged() const; - double Eulgam() const { return p_atmosEulgam; } + double Eulgam() const { + return p_atmosEulgam; + } int p_atmosAtmSwitch; int p_atmosNinc; @@ -224,16 +278,16 @@ namespace Isis { private: bool p_standardConditions; - + string p_atmosAlgorithmName; - + PhotoModel *p_atmosPM; bool p_atmosNulneg; double p_atmosTauold; double p_atmosWhaold; - friend class NumericalAtmosApprox; + friend class NumericalAtmosApprox; }; }; diff --git a/isis/src/base/objs/AtmosModel/NumericalAtmosApprox.cpp b/isis/src/base/objs/AtmosModel/NumericalAtmosApprox.cpp index 7e9750d797..db71a9c0c6 100644 --- a/isis/src/base/objs/AtmosModel/NumericalAtmosApprox.cpp +++ b/isis/src/base/objs/AtmosModel/NumericalAtmosApprox.cpp @@ -2,23 +2,23 @@ * @file * $Revision: 1.2 $ * $Date: 2008/11/07 23:48:13 $ - * + * * Unless noted otherwise, the portions of Isis written by the USGS are public - * domain. See individual third-party library and package descriptions for + * domain. See individual third-party library and package descriptions for * intellectual property information,user agreements, and related information. * * Although Isis has been used by the USGS, no warranty, expressed or implied, - * is made by the USGS as to the accuracy and functioning of such software - * and related material nor shall the fact of distribution constitute any such - * warranty, and no responsibility is assumed by the USGS in connection + * is made by the USGS as to the accuracy and functioning of such software + * and related material nor shall the fact of distribution constitute any such + * warranty, and no responsibility is assumed by the USGS in connection * therewith. * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see - * the Privacy & Disclaimers page on the Isis website, + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see + * the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on * http://www.usgs.gov/privacy.html. - */ + */ #include #include "AtmosModel.h" @@ -29,48 +29,48 @@ using namespace std; namespace Isis { - /** - * This variation on the NumericalApproximation method - * integrates a specified AtmosModel function rather than an - * interpolated function based on a data set. It returns the - * integral of the given function from a to b for the given - * AtmosModel. Integration is performed by Romberg's method for - * Numerical Integration of order 2K, where, e.g., K=2 is - * simpson's rule. This is a generalization of the trapezoidal - * rule. Romberg Integration uses a series of refinements on - * the extended (or composite) trapezoidal rule. This method - * calls a polynomial interpolation (Neville's algorithm) to - * extrapolate successive refinements. - * - * @param am Pointer to AtmosModel object - * @param sub Enumerated value of atmospheric function to be + /** + * This variation on the NumericalApproximation method + * integrates a specified AtmosModel function rather than an + * interpolated function based on a data set. It returns the + * integral of the given function from a to b for the given + * AtmosModel. Integration is performed by Romberg's method for + * Numerical Integration of order 2K, where, e.g., K=2 is + * simpson's rule. This is a generalization of the trapezoidal + * rule. Romberg Integration uses a series of refinements on + * the extended (or composite) trapezoidal rule. This method + * calls a polynomial interpolation (Neville's algorithm) to + * extrapolate successive refinements. + * + * @param am Pointer to AtmosModel object + * @param sub Enumerated value of atmospheric function to be * integrated * @param a Lower limit of integration * @param b Upper limit of integration - * @return @b double Integral approximation of the function + * @return @b double Integral approximation of the function * on the interval (a, b) - * @throws Isis::iException::Programmer "Failed to converge." - * @throws Isis::iException::Programmer "Caught an error" (from + * @throws Isis::iException::Programmer "Failed to converge." + * @throws Isis::iException::Programmer "Caught an error" (from * RefineExtendedTrap(), Constructor, Evaluate(), or * PolynomialNevilleErrorEstimate() method) - * @see mathworld.wolfram.com/RombergIntegration.html - * @see RefineExtendedTrap() - * @internal - * @history 1999-08-11 K Teal Thompson - Original version in + * @see mathworld.wolfram.com/RombergIntegration.html + * @see RefineExtendedTrap() + * @internal + * @history 1999-08-11 K Teal Thompson - Original version in * Isis2. - * @history 2000-12-29 Randy Kirk - Add absolute error + * @history 2000-12-29 Randy Kirk - Add absolute error * tolerance. - * @history 2007-02-20 Janet Barrett - Imported to Isis3 in + * @history 2007-02-20 Janet Barrett - Imported to Isis3 in * AtmosModel class. Original name r8qromb(). * @history 2008-11-05 Jeannie Walldren - Renamed, moved to new * class, and changed i/o parameters. */ - double NumericalAtmosApprox::RombergsMethod (AtmosModel *am, IntegFunc sub, double a, double b) throw (iException &){ - // This method was derived from an algorithm in the text + double NumericalAtmosApprox::RombergsMethod(AtmosModel *am, IntegFunc sub, double a, double b) throw(iException &) { + // This method was derived from an algorithm in the text // Numerical Recipes in C: The Art of Scientific Computing // Section 4.3 by Flannery, Press, Teukolsky, and Vetterling int maxits = 20; // maximium number of iterations allowed to converge - double dss = 0; // error estimate for + double dss = 0; // error estimate for double h[maxits+1]; // relative stepsizes for trap double trap[maxits+1]; // successive trapeziodal approximations double epsilon; // desired fractional accuracy @@ -81,131 +81,131 @@ namespace Isis { epsilon2 = 1.0e-6; h[0] = 1.0; - try{ + try { NumericalApproximation interp(NumericalApproximation::PolynomialNeville); - for (int i=0; i= 4) { + trap[i] = RefineExtendedTrap(am, sub, a, b, trap[i], i + 1); // validates data here + if(i >= 4) { interp.AddData(5, &h[i-4], &trap[i-4]); - ss = interp.Evaluate(0.0,NumericalApproximation::Extrapolate); + ss = interp.Evaluate(0.0, NumericalApproximation::Extrapolate); dss = interp.PolynomialNevilleErrorEstimate()[0]; interp.Reset(); // we work only until our necessary accuracy is achieved - if (fabs(dss) <= epsilon*fabs(ss)) return ss; - if (fabs(dss) <= epsilon2) return ss; + if(fabs(dss) <= epsilon * fabs(ss)) return ss; + if(fabs(dss) <= epsilon2) return ss; } trap[i+1] = trap[i]; h[i+1] = 0.25 * h[i]; - // This is a key step: the factor is 0.25d0 even though - // the stepsize is decreased by 0.5d0. This makes the - // extraplolation a polynomial in h-squared as allowed - // by the equation from Numerical Recipes 4.2.1 pg.132, + // This is a key step: the factor is 0.25d0 even though + // the stepsize is decreased by 0.5d0. This makes the + // extraplolation a polynomial in h-squared as allowed + // by the equation from Numerical Recipes 4.2.1 pg.132, // not just a polynomial in h. } } - catch (iException e){ // catch error from RefineExtendedTrap, Constructor, Evaluate, PolynomialNevilleErrorEstimate + catch(iException e) { // catch error from RefineExtendedTrap, Constructor, Evaluate, PolynomialNevilleErrorEstimate throw e.Message(e.Type(), "NumericalAtmosApprox::RombergsMethod() - Caught the following error: ", _FILEINFO_); } - throw iException::Message(iException::Programmer, - "NumericalAtmosApprox::RombergsMethod() - Failed to converge in " - + iString(maxits) + " iterations.", + throw iException::Message(iException::Programmer, + "NumericalAtmosApprox::RombergsMethod() - Failed to converge in " + + iString(maxits) + " iterations.", _FILEINFO_); } - /** - * This variation on the NumericalApproximation method - * integrates a specified AtmosModel function rather than an - * interpolated function based on a data set. This routine - * computes the @a nth stage of refinement of an - * extended trapezoidal rule. This method is used by + /** + * This variation on the NumericalApproximation method + * integrates a specified AtmosModel function rather than an + * interpolated function based on a data set. This routine + * computes the @a nth stage of refinement of an + * extended trapezoidal rule. This method is used by * RombergsMethod() to integrate. When called with @a n = 1, the - * method returns the crudest estimate of the integral. + * method returns the crudest estimate of the integral. * Subsequent calls with @a n = 2, 3, ... (in sequential order) - * will improve the accuracy by adding + * will improve the accuracy by adding * 2@a n-2 additional interior points. This method - * can be used to integrate by the extended trapeziodal rule if - * you know the number of steps you want to take. - * - * @param am Pointer to AtmosModel object - * @param sub Enumerated value of atmospheric function to be + * can be used to integrate by the extended trapeziodal rule if + * you know the number of steps you want to take. + * + * @param am Pointer to AtmosModel object + * @param sub Enumerated value of atmospheric function to be * integrated * @param a Lower limit of integration * @param b Upper limit of integration * @param s Previous value of refinement * @param n Number of partitions to use when integrating - * @return @b double Integral (refined) approximation of the function + * @return @b double Integral (refined) approximation of the function * on the interval (a, b) - * @throws Isis::iException::Programmer "Caught an error" (from - * InrFunc2Bint() or OutrFunc2Bint() method) + * @throws Isis::iException::Programmer "Caught an error" (from + * InrFunc2Bint() or OutrFunc2Bint() method) * @see RombergsMethod() - * @internal + * @internal * @history 1999-08-11 K Teal Thompson - Original version. * @history 2007-02-20 Janet Barrett - Imported to Isis3 in AtmosModel class. Original name r8trapzd(). * @history 2008-11-05 Jeannie Walldren - Renamed, moved to new * class, and changed i/o parameters. */ - double NumericalAtmosApprox::RefineExtendedTrap(AtmosModel *am, IntegFunc sub, double a, double b, double s, unsigned int n) throw (iException &){ - // This method was derived from an algorithm in the text + double NumericalAtmosApprox::RefineExtendedTrap(AtmosModel *am, IntegFunc sub, double a, double b, double s, unsigned int n) throw(iException &) { + // This method was derived from an algorithm in the text // Numerical Recipes in C: The Art of Scientific Computing // Section 4.2 by Flannery, Press, Teukolsky, and Vetterling - try{ - if (n == 1) { + try { + if(n == 1) { double begin; double end; - if (sub == InnerFunction) { - begin = InrFunc2Bint(am,a); - end = InrFunc2Bint(am,b); + if(sub == InnerFunction) { + begin = InrFunc2Bint(am, a); + end = InrFunc2Bint(am, b); } else { - begin = OutrFunc2Bint(am,a); - end = OutrFunc2Bint(am,b); + begin = OutrFunc2Bint(am, a); + end = OutrFunc2Bint(am, b); } return (0.5 * (b - a) * (begin + end)); } else { int it; - double delta,tnm,x,sum; - it = (int)(pow(2.0,(double)(n-2))); + double delta, tnm, x, sum; + it = (int)(pow(2.0, (double)(n - 2))); tnm = it; delta = (b - a) / tnm; // spacing of the points to be added x = a + 0.5 * delta; sum = 0.0; - for (int i=0; ip_atmosPhi = phi; - am->p_atmosCosphi = cos((PI/180.0)*phi); + am->p_atmosCosphi = cos((PI / 180.0) * phi); NumericalAtmosApprox qromb; - try{ - result = qromb.RombergsMethod(am,sub,1.0e-6,1.0); + try { + result = qromb.RombergsMethod(am, sub, 1.0e-6, 1.0); return result; } - catch (iException e){ // catch exception from RombergsMethod() + catch(iException e) { // catch exception from RombergsMethod() throw e.Message(e.Type(), "NumericalAtmosApprox::OutrFunc2Bint() - Caught the following error: ", _FILEINFO_); @@ -233,24 +233,24 @@ namespace Isis { } /** - * Inner function to be integrated. This function is the inner + * Inner function to be integrated. This function is the inner * integrand with all its parameters except cos(ema) hidden. For - * atmSwitch=0 this integrand is mu times the photometric angle, - * giving the hemispheric albedo for the outer integral. - * atmSwitch of 1, 2, 3, give the 3 integrals over the - * atmospheric single- particle phase function used in the - * Hapke/Henyey-Greenstein atmospheric model. - * - * @param am Pointer to AtmosModel object - * @param mu Angle at which the function will be integrated - * @return @b double Value of the function evaluated at the - * given @a mu + * atmSwitch=0 this integrand is mu times the photometric angle, + * giving the hemispheric albedo for the outer integral. + * atmSwitch of 1, 2, 3, give the 3 integrals over the + * atmospheric single- particle phase function used in the + * Hapke/Henyey-Greenstein atmospheric model. + * + * @param am Pointer to AtmosModel object + * @param mu Angle at which the function will be integrated + * @return @b double Value of the function evaluated at the + * given @a mu * @throws Isis::iException::Programmer "Invalid value of * atmospheric switch used as argument to this * function" - * @internal - * @history 1999-03-15 Randy Kirk - Original version in Isis2. - * @history 2000-07-07 Randy Kirk - Add other integrals besides + * @internal + * @history 1999-03-15 Randy Kirk - Original version in Isis2. + * @history 2000-07-07 Randy Kirk - Add other integrals besides * Ah. * @history 2000-12-29 Randy Kirk - Modified /hide_inc/ so phi * gets passed, etc. Moved factors to outside @@ -263,7 +263,7 @@ namespace Isis { double NumericalAtmosApprox::InrFunc2Bint(AtmosModel *am, double mu) { double ema; //pass in mu, get emission angle double sine; //sin(ema) - double alpha; + double alpha; double phase; //angle between sun and camera double result; double phasefn;//Henyey-Greenstein phase fn @@ -274,65 +274,65 @@ namespace Isis { // calculate the phase angle // also calculate any of the other redundant parameters - ema = acos(mu) * (180.0/PI); - sine = sin(ema*(PI/180.0)); - if ((am->p_atmosAtmSwitch == 0) || (am->p_atmosAtmSwitch == 2)) { // Reflection phase <= 90 + ema = acos(mu) * (180.0 / PI); + sine = sin(ema * (PI / 180.0)); + if((am->p_atmosAtmSwitch == 0) || (am->p_atmosAtmSwitch == 2)) { // Reflection phase <= 90 alpha = am->p_atmosSini * sine * am->p_atmosCosphi + - am->p_atmosMunot * mu; + am->p_atmosMunot * mu; } else { // Transmission phase <= 90 alpha = am->p_atmosSini * sine * am->p_atmosCosphi - - am->p_atmosMunot * mu; + am->p_atmosMunot * mu; } - phase = acos(alpha) * (180.0/PI); + phase = acos(alpha) * (180.0 / PI); // now evaluate the integrand; all needed parameters // have been hidden separately and passed to it in COMMON. - if (am->p_atmosAtmSwitch == 0) { + if(am->p_atmosAtmSwitch == 0) { // integrand for hemispheric albedo - result = mu * am->p_atmosPM->CalcSurfAlbedo(phase,am->p_atmosInc,ema); + result = mu * am->p_atmosPM->CalcSurfAlbedo(phase, am->p_atmosInc, ema); } else { - phasefn = (1.0 - am->AtmosHga() * am->AtmosHga()) /pow((1.0+2.0*am->AtmosHga()*alpha+am->AtmosHga()*am->AtmosHga()),1.5); - xx = -am->AtmosTau() / max(am->p_atmosMunot,1.0e-30); - if (xx < -69.0) { + phasefn = (1.0 - am->AtmosHga() * am->AtmosHga()) / pow((1.0 + 2.0 * am->AtmosHga() * alpha + am->AtmosHga() * am->AtmosHga()), 1.5); + xx = -am->AtmosTau() / max(am->p_atmosMunot, 1.0e-30); + if(xx < -69.0) { emunot = 0.0; } - else if (xx > 69.0) { + else if(xx > 69.0) { emunot = 1.0e30; } else { emunot = exp(xx); } - xx = -am->AtmosTau() / max(mu,1.0e-30); + xx = -am->AtmosTau() / max(mu, 1.0e-30); - if (xx < -69.0) { + if(xx < -69.0) { emu = 0.0; } - else if (xx > 69.0) { + else if(xx > 69.0) { emu = 1.0e30; } else { emu = exp(xx); } - if (mu == am->p_atmosMunot) { + if(mu == am->p_atmosMunot) { tfac = am->AtmosTau() * emunot / (am->p_atmosMunot * am->p_atmosMunot); } else { tfac = (emunot - emu) / (am->p_atmosMunot - mu); } - if (am->p_atmosAtmSwitch == 1) { + if(am->p_atmosAtmSwitch == 1) { result = mu * (phasefn - 1.0) * tfac; } - else if (am->p_atmosAtmSwitch == 2) { + else if(am->p_atmosAtmSwitch == 2) { result = am->p_atmosMunot * mu * (phasefn - 1.0) * (1.0 - emunot * emu) / (am->p_atmosMunot + mu); } - else if (am->p_atmosAtmSwitch == 3) { + else if(am->p_atmosAtmSwitch == 3) { result = -sine * am->p_atmosCosphi * (phasefn - 1.0) * tfac; } else { string msg = "NumericalAtmosApprox::InrFunc2Bint() - Invalid value of atmospheric "; msg += "switch used as argument to this function"; - throw iException::Message(iException::Programmer,msg,_FILEINFO_); + throw iException::Message(iException::Programmer, msg, _FILEINFO_); } } return result; diff --git a/isis/src/base/objs/AtmosModel/NumericalAtmosApprox.h b/isis/src/base/objs/AtmosModel/NumericalAtmosApprox.h index 2f5c2c4e1c..6fe0f33655 100644 --- a/isis/src/base/objs/AtmosModel/NumericalAtmosApprox.h +++ b/isis/src/base/objs/AtmosModel/NumericalAtmosApprox.h @@ -4,23 +4,23 @@ * @file * $Revision: 1.2 $ * $Date: 2008/11/07 23:48:13 $ - * + * * Unless noted otherwise, the portions of Isis written by the USGS are public - * domain. See individual third-party library and package descriptions for + * domain. See individual third-party library and package descriptions for * intellectual property information,user agreements, and related information. * * Although Isis has been used by the USGS, no warranty, expressed or implied, - * is made by the USGS as to the accuracy and functioning of such software - * and related material nor shall the fact of distribution constitute any such - * warranty, and no responsibility is assumed by the USGS in connection + * is made by the USGS as to the accuracy and functioning of such software + * and related material nor shall the fact of distribution constitute any such + * warranty, and no responsibility is assumed by the USGS in connection * therewith. * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see - * the Privacy & Disclaimers page on the Isis website, + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html in a browser or see + * the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on * http://www.usgs.gov/privacy.html. - */ + */ #include #include @@ -29,38 +29,38 @@ using namespace std; namespace Isis { class AtmosModel; -/** - * This class extends @b Isis::NumericalApproximation. It was - * created to handle numerical integration methods for specific - * atmospheric functions in the @b Isis::AtmosModel class. - * Rather than using a data set to interpolate a function, these - * methods can take in a pointer to an AtmosModel object and an - * enumerated value for the specific function that needs to be - * integrated. - * - * @ingroup Math and RadiometricAndPhotometricCorrection - * - * @author 2008-11-05 Jeannie Walldren - * @internal - * @history 2008-11-05 Jeannie Walldren - Original Version. - * @history 2008-11-07 Jeannie Walldren - Fixed documentation - */ - class NumericalAtmosApprox : public NumericalApproximation{ + /** + * This class extends @b Isis::NumericalApproximation. It was + * created to handle numerical integration methods for specific + * atmospheric functions in the @b Isis::AtmosModel class. + * Rather than using a data set to interpolate a function, these + * methods can take in a pointer to an AtmosModel object and an + * enumerated value for the specific function that needs to be + * integrated. + * + * @ingroup Math and RadiometricAndPhotometricCorrection + * + * @author 2008-11-05 Jeannie Walldren + * @internal + * @history 2008-11-05 Jeannie Walldren - Original Version. + * @history 2008-11-07 Jeannie Walldren - Fixed documentation + */ + class NumericalAtmosApprox : public NumericalApproximation { public: //! Uses @b Isis::NumericalApproximation constructor - NumericalAtmosApprox(const NumericalApproximation::InterpType &itype=CubicNatural):NumericalApproximation(itype){}; + NumericalAtmosApprox(const NumericalApproximation::InterpType &itype = CubicNatural): NumericalApproximation(itype) {}; //! Empty destructor. - virtual ~NumericalAtmosApprox(){}; + virtual ~NumericalAtmosApprox() {}; /** - * This enum defines function to be integrated by Romberg's + * This enum defines function to be integrated by Romberg's * method. */ - enum IntegFunc { OuterFunction, //!< Indicates that Romberg's method will integrate the function OutrFunc2Bint() + enum IntegFunc { OuterFunction, //!< Indicates that Romberg's method will integrate the function OutrFunc2Bint() InnerFunction //!< Indicates that Romberg's method will integrate the function InrFunc2Bint() - }; - double RombergsMethod (AtmosModel *am, IntegFunc sub, double a, double b) throw (iException &); - double RefineExtendedTrap(AtmosModel *am, IntegFunc sub, double a, double b, double s, unsigned int n) throw (iException &); + }; + double RombergsMethod(AtmosModel *am, IntegFunc sub, double a, double b) throw(iException &); + double RefineExtendedTrap(AtmosModel *am, IntegFunc sub, double a, double b, double s, unsigned int n) throw(iException &); static double OutrFunc2Bint(AtmosModel *am, double phi); static double InrFunc2Bint(AtmosModel *am, double mu); diff --git a/isis/src/base/objs/AtmosModel/unitTest.cpp b/isis/src/base/objs/AtmosModel/unitTest.cpp index 0c34f5e318..cae90aa76a 100644 --- a/isis/src/base/objs/AtmosModel/unitTest.cpp +++ b/isis/src/base/objs/AtmosModel/unitTest.cpp @@ -16,32 +16,32 @@ using namespace std; using namespace Isis; void doit(Pvl &lab, PhotoModel &pm); -int main () { +int main() { Isis::Preference::Preferences(true); - cout << "UNIT TEST for Isis::AtmosModel" << endl << endl; + cout << "UNIT TEST for Isis::AtmosModel" << endl << endl; Pvl lab; lab.AddObject(PvlObject("PhotometricModel")); lab.FindObject("PhotometricModel").AddGroup(PvlGroup("Algorithm")); - lab.FindObject("PhotometricModel").FindGroup("Algorithm").AddKeyword(PvlKeyword("Name","Lambert"));// HapkeHen + lab.FindObject("PhotometricModel").FindGroup("Algorithm").AddKeyword(PvlKeyword("Name", "Lambert")); // HapkeHen PhotoModel *pm = PhotoModelFactory::Create(lab); - + cout << "Testing missing AtmosphericModel object ..." << endl; - doit(lab,*pm); + doit(lab, *pm); lab.AddObject(PvlObject("AtmosphericModel")); cout << "Testing missing Algorithm group ..." << endl; - doit(lab,*pm); + doit(lab, *pm); lab.FindObject("AtmosphericModel").AddGroup(PvlGroup("Algorithm")); cout << "Testing missing Name keyword ..." << endl; - doit(lab,*pm); + doit(lab, *pm); - lab.FindObject("AtmosphericModel").FindGroup("Algorithm").AddKeyword(PvlKeyword("Name","Anisotropic1"), Pvl::Replace); + lab.FindObject("AtmosphericModel").FindGroup("Algorithm").AddKeyword(PvlKeyword("Name", "Anisotropic1"), Pvl::Replace); cout << "Testing supported atmospheric model ..." << endl; - doit(lab,*pm); + doit(lab, *pm); - AtmosModel *am = AtmosModelFactory::Create(lab,*pm); + AtmosModel *am = AtmosModelFactory::Create(lab, *pm); try { am->SetAtmosWha(0.98); @@ -66,8 +66,8 @@ int main () { am->SetStandardConditions(false); am->SetAtmosWha(0.95); - } - catch (iException &e) { + } + catch(iException &e) { e.Report(false); } cout << endl; @@ -76,53 +76,53 @@ int main () { try { am->SetAtmosTau(-1.0); } - catch (iException &e) { + catch(iException &e) { e.Report(false); } try { am->SetAtmosWha(0.0); } - catch (iException &e) { + catch(iException &e) { e.Report(false); } try { am->SetAtmosWha(2.0); } - catch (iException &e) { + catch(iException &e) { e.Report(false); } try { am->SetAtmosHga(-1.0); } - catch (iException &e) { + catch(iException &e) { e.Report(false); } try { am->SetAtmosHga(1.0); } - catch (iException &e) { + catch(iException &e) { e.Report(false); } cout << endl; - cout << "Testing atmospheric model InrFunc2Bint method ..." - << endl; + cout << "Testing atmospheric model InrFunc2Bint method ..." + << endl; try { am->SetAtmosAtmSwitch(1); am->SetAtmosInc(0.0); am->SetAtmosPhi(0.0); am->SetAtmosHga(.68); am->SetAtmosTau(.28); - double result = NumericalAtmosApprox::InrFunc2Bint(am,1.0e-6); + double result = NumericalAtmosApprox::InrFunc2Bint(am, 1.0e-6); cout << "Results from InrFunc2Bint = " << result << - endl << endl; + endl << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(false); } cout << endl; @@ -133,17 +133,17 @@ int main () { am->SetAtmosPhi(78.75); am->SetAtmosHga(.68); am->SetAtmosTau(.28); - double result = NumericalAtmosApprox::InrFunc2Bint(am,.75000025); + double result = NumericalAtmosApprox::InrFunc2Bint(am, .75000025); cout << "Results from InrFunc2Bint = " << result << - endl << endl; + endl << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(false); } cout << endl; - cout << "Testing atmospheric model r8trapzd method ..." - << endl; + cout << "Testing atmospheric model r8trapzd method ..." + << endl; try { am->SetAtmosAtmSwitch(1); am->SetAtmosInc(0.0); @@ -152,36 +152,36 @@ int main () { am->SetAtmosTau(.28); double ss = 0; NumericalAtmosApprox nam; - for (int i = 1; i < 10; i++) { - ss = nam.RefineExtendedTrap(am,NumericalAtmosApprox::OuterFunction,0.0,180.0,ss,i); + for(int i = 1; i < 10; i++) { + ss = nam.RefineExtendedTrap(am, NumericalAtmosApprox::OuterFunction, 0.0, 180.0, ss, i); cout << "Results from r8trapzd = " << ss << " for i = " << i << endl; ss = 0; } cout << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(false); } - cout << "Testing atmospheric model OutrFunc2Bint method ..." - << endl; + cout << "Testing atmospheric model OutrFunc2Bint method ..." + << endl; try { am->SetAtmosAtmSwitch(1); am->SetAtmosInc(0.0); am->SetAtmosPhi(0.0); am->SetAtmosHga(.68); am->SetAtmosTau(.28); - double result = NumericalAtmosApprox::OutrFunc2Bint(am,0.0); + double result = NumericalAtmosApprox::OutrFunc2Bint(am, 0.0); cout << "Results from OutrFunc2Bint = " << result << - endl << endl; + endl << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(false); } cout << endl; - cout << "Testing atmospheric model r8qromb method ..." - << endl; + cout << "Testing atmospheric model r8qromb method ..." + << endl; try { am->SetAtmosAtmSwitch(1); am->SetAtmosInc(0.0); @@ -190,17 +190,17 @@ int main () { am->SetAtmosTau(.28); double ss; NumericalAtmosApprox nam; - ss = nam.RombergsMethod(am,NumericalAtmosApprox::OuterFunction,0.,180.); + ss = nam.RombergsMethod(am, NumericalAtmosApprox::OuterFunction, 0., 180.); cout << "Results from r8qromb = " << ss << - endl << endl; + endl << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(false); } cout << endl; - cout << "Testing atmospheric model GenerateAhTable method ..." - << endl; + cout << "Testing atmospheric model GenerateAhTable method ..." + << endl; try { am->GenerateAhTable(); @@ -209,24 +209,24 @@ int main () { int ninc = am->AtmosNinc(); vector inctable; inctable = am->AtmosIncTable(); - for (int i=0; i ahtable; ahtable = am->AtmosAhTable(); - for (int i=0; iSetAtmosWha(.95); am->SetAtmosInc(0.0); @@ -239,165 +239,166 @@ int main () { int ninc = am->AtmosNinc(); vector inctable; inctable = am->AtmosIncTable(); - for (int i=0; i hahgttable; hahgttable = am->AtmosHahgtTable(); - for (int i=0; i hahgt0table; hahgt0table = am->AtmosHahgt0Table(); - for (int i=0; iSetAtmosAtmSwitch(1); - am->SetAtmosInc(0.0); - am->SetAtmosPhi(0.0); - am->SetAtmosHga(.68); - am->SetAtmosTau(.28); - double ss = 0; - - NumericalAtmosApprox nam; - for(double a = 0.0; a < 0.8; a+=.3) { - for(double b = 0.8; b > a; b-=.3) { - ss = 0; - ss = nam.RefineExtendedTrap(am,NumericalAtmosApprox::OuterFunction,a,b,ss,10); - cout << "Results from r8trapzd = " << ss << " for interval (a,b) = (" - << a << "," << b << ")" << endl << endl; - } + try { + am->SetAtmosAtmSwitch(1); + am->SetAtmosInc(0.0); + am->SetAtmosPhi(0.0); + am->SetAtmosHga(.68); + am->SetAtmosTau(.28); + double ss = 0; + + NumericalAtmosApprox nam; + for(double a = 0.0; a < 0.8; a += .3) { + for(double b = 0.8; b > a; b -= .3) { + ss = 0; + ss = nam.RefineExtendedTrap(am, NumericalAtmosApprox::OuterFunction, a, b, ss, 10); + cout << "Results from r8trapzd = " << ss << " for interval (a,b) = (" + << a << "," << b << ")" << endl << endl; } + } - }catch (iException &error){ + } + catch(iException &error) { error.Report(false); } // Exponential integrals and G11Prime cout << "Test En ..." << endl; try { - int n = 1; - double x = .28; - double result; + int n = 1; + double x = .28; + double result; - result = AtmosModel::En(n,x); - cout << "Results from En(1,0.28) = " << result << endl; - cout << " Actual value = " << 0.957308 << endl - << endl; + result = AtmosModel::En(n, x); + cout << "Results from En(1,0.28) = " << result << endl; + cout << " Actual value = " << 0.957308 << endl + << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } try { - int n = 1; - double x = .733615937; - double result; + int n = 1; + double x = .733615937; + double result; - result = AtmosModel::En(n,x); - cout << "Results from En(1,0.733615937) = " << result << endl; - cout << " Actual value = " << 0.35086 << endl - << endl; + result = AtmosModel::En(n, x); + cout << "Results from En(1,0.733615937) = " << result << endl; + cout << " Actual value = " << 0.35086 << endl + << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } cout << "Test Ei ..." << endl; try { - double x = .234; - double result; + double x = .234; + double result; - result = AtmosModel::Ei(x); - cout << "Results from Ei(0.234) = " << result << endl; - cout << " Actual value = " << -0.626785 << endl - << endl; + result = AtmosModel::Ei(x); + cout << "Results from Ei(0.234) = " << result << endl; + cout << " Actual value = " << -0.626785 << endl + << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } try { - double x = 1.5; - double result; + double x = 1.5; + double result; - result = AtmosModel::Ei(x); - cout << " Results from Ei(1.5) = " << result << endl; - cout << " Actual value = " << 3.30129 << endl - << endl; + result = AtmosModel::Ei(x); + cout << " Results from Ei(1.5) = " << result << endl; + cout << " Actual value = " << 3.30129 << endl + << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } try { - double x = 2.6; - double result; + double x = 2.6; + double result; - result = AtmosModel::Ei(x); - cout << "Results from Ei(2.6) = " << result << endl; - cout << " Actual value = " << 7.57611 << endl - << endl; + result = AtmosModel::Ei(x); + cout << "Results from Ei(2.6) = " << result << endl; + cout << " Actual value = " << 7.57611 << endl + << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } try { - double x = .01583; - double result; + double x = .01583; + double result; - result = AtmosModel::Ei(x); - cout << "Results from Ei(0.01583) = " << result << endl; - cout << " Actual value = " << -3.55274 << endl - << endl; + result = AtmosModel::Ei(x); + cout << "Results from Ei(0.01583) = " << result << endl; + cout << " Actual value = " << -3.55274 << endl + << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } cout << "Test G11Prime ..." << endl; try { - double tau = .28; - double result; + double tau = .28; + double result; - result = AtmosModel::G11Prime(tau); - cout << "Results from G11Prime(0.28) = " << result << endl; - cout << " Actual value = " << 0.79134 << endl - << endl; + result = AtmosModel::G11Prime(tau); + cout << "Results from G11Prime(0.28) = " << result << endl; + cout << " Actual value = " << 0.79134 << endl + << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } try { - double tau = 1.5836; - double result; + double tau = 1.5836; + double result; - result = AtmosModel::G11Prime(tau); - cout << "Results from G11Prime(1.5836) = " << result << endl; - cout << " Actual value = " << 0.217167 << endl - << endl; + result = AtmosModel::G11Prime(tau); + cout << "Results from G11Prime(1.5836) = " << result << endl; + cout << " Actual value = " << 0.217167 << endl + << endl; } - catch (iException &e) { + catch(iException &e) { e.Report(); } cout << endl; cout << "x\tn\tG11Prime(x)\tEi(x)\tEn(x)" << endl; - for(double x = .5; x < 1.75; x+=.5) { + for(double x = .5; x < 1.75; x += .5) { for(int n = 0; n < 3; n++) { cout << x << "\t" << n << "\t"; cout << AtmosModel::G11Prime(x) << "\t"; @@ -407,13 +408,25 @@ int main () { } } cout << "EXCEPTIONS:" << endl; - try{AtmosModel::Ei(0.0);} // require x > 0 - catch(iException e){ e.Report(); } - try{AtmosModel::En(1,0.0);} // require (n>=0 & x>0) or (n>1 & x>=0) - catch(iException e){ e.Report(); } - try{AtmosModel::En(0,-1.0);}// require (n>=0 & x>0) or (n>1 & x>=0) - catch(iException e){ e.Report(); } - + try { + AtmosModel::Ei(0.0); // require x > 0 + } + catch(iException e) { + e.Report(); + } + try { + AtmosModel::En(1, 0.0); // require (n>=0 & x>0) or (n>1 & x>=0) + } + catch(iException e) { + e.Report(); + } + try { + AtmosModel::En(0, -1.0); // require (n>=0 & x>0) or (n>1 & x>=0) + } + catch(iException e) { + e.Report(); + } + cout << "\t************************************************" << endl; cout << endl; } @@ -421,9 +434,9 @@ int main () { void doit(Pvl &lab, PhotoModel &pm) { try { //AtmosModel *am = AtmosModelFactory::Create(lab,pm); - AtmosModelFactory::Create(lab,pm); + AtmosModelFactory::Create(lab, pm); } - catch (iException &error) { + catch(iException &error) { error.Report(false); } diff --git a/isis/src/base/objs/AtmosModelFactory/AtmosModelFactory.cpp b/isis/src/base/objs/AtmosModelFactory/AtmosModelFactory.cpp index 1a759be965..b4410787e9 100644 --- a/isis/src/base/objs/AtmosModelFactory/AtmosModelFactory.cpp +++ b/isis/src/base/objs/AtmosModelFactory/AtmosModelFactory.cpp @@ -1,25 +1,25 @@ -/** - * @file - * $Revision: 1.2 $ - * $Date: 2008/06/18 18:53:56 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.2 $ + * $Date: 2008/06/18 18:53:56 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ #include "AtmosModelFactory.h" #include "AtmosModel.h" @@ -28,10 +28,10 @@ #include "Filename.h" namespace Isis { - /** + /** * Create an AtmosModel object using a PVL specification. * An example of the PVL required for this is: - * + * * @code * Object = AtmosphericModel * Group = Algorithm @@ -45,28 +45,28 @@ namespace Isis { * EndGroup * EndObject * @endcode - * + * * There are many other options that can be set via the pvl and are * described in other documentation (see below). - * - * @param pvl The pvl object containing the specification - * @param pmodel The PhotoModel objects contining the data - * - * @return A pointer to the new AtmosModel - * + * + * @param pvl The pvl object containing the specification + * @param pmodel The PhotoModel objects contining the data + * + * @return A pointer to the new AtmosModel + * * @see atmosphericModels.doc **/ AtmosModel *AtmosModelFactory::Create(Pvl &pvl, PhotoModel &pmodel) { // Get the algorithm name to create PvlGroup &algo = pvl.FindObject("AtmosphericModel") - .FindGroup("Algorithm",Pvl::Traverse); + .FindGroup("Algorithm", Pvl::Traverse); std::string algorithm = algo["Name"]; // Open the factory plugin file Plugin *p = new Plugin; Filename f("AtmosModel.plugin"); - if (f.Exists()) { + if(f.Exists()) { p->Read("AtmosModel.plugin"); } else { @@ -74,9 +74,9 @@ namespace Isis { } // Get the algorithm specific plugin and return it - AtmosModel * (*plugin) (Pvl &pvl, PhotoModel &pmodel); - plugin = (AtmosModel * (*)(Pvl &pvl, PhotoModel &pmodel)) - p->GetPlugin(algorithm); - return (*plugin)(pvl,pmodel); + AtmosModel * (*plugin)(Pvl & pvl, PhotoModel & pmodel); + plugin = (AtmosModel * ( *)(Pvl & pvl, PhotoModel & pmodel)) + p->GetPlugin(algorithm); + return (*plugin)(pvl, pmodel); } } // end namespace isis diff --git a/isis/src/base/objs/AtmosModelFactory/AtmosModelFactory.h b/isis/src/base/objs/AtmosModelFactory/AtmosModelFactory.h index 64693cb1ea..aeb3dd7c37 100644 --- a/isis/src/base/objs/AtmosModelFactory/AtmosModelFactory.h +++ b/isis/src/base/objs/AtmosModelFactory/AtmosModelFactory.h @@ -1,27 +1,27 @@ #ifndef AtmosModelFactory_h #define AtmosModelFactory_h -/** - * @file - * $Revision: 1.2 $ - * $Date: 2008/06/18 18:53:56 $ - * - * Unless noted otherwise, the portions of Isis written by the USGS are - * public domain. See individual third-party library and package descriptions - * for intellectual property information, user agreements, and related - * information. - * - * Although Isis has been used by the USGS, no warranty, expressed or - * implied, is made by the USGS as to the accuracy and functioning of such - * software and related material nor shall the fact of distribution +/** + * @file + * $Revision: 1.2 $ + * $Date: 2008/06/18 18:53:56 $ + * + * Unless noted otherwise, the portions of Isis written by the USGS are + * public domain. See individual third-party library and package descriptions + * for intellectual property information, user agreements, and related + * information. + * + * Although Isis has been used by the USGS, no warranty, expressed or + * implied, is made by the USGS as to the accuracy and functioning of such + * software and related material nor shall the fact of distribution * constitute any such warranty, and no responsibility is assumed by the - * USGS in connection therewith. - * - * For additional information, launch - * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html + * USGS in connection therewith. + * + * For additional information, launch + * $ISISROOT/doc//documents/Disclaimers/Disclaimers.html * in a browser or see the Privacy & Disclaimers page on the Isis website, * http://isis.astrogeology.usgs.gov, and the USGS privacy and disclaimers on - * http://www.usgs.gov/privacy.html. - */ + * http://www.usgs.gov/privacy.html. + */ namespace Isis { class Pvl; @@ -31,31 +31,31 @@ namespace Isis { /** * This class is used to create AtmosModel objects. Typically, applications - *which perform atmospheric corrections need to use different types of + *which perform atmospheric corrections need to use different types of *atmospheric function such as Isotropic1, Anisotropic1, HapkeAtm1, etc. If this *factory is given a Pvl object which contains an AtmosModel definition, it will - *create that specific instance of the class. For example, - * + *create that specific instance of the class. For example, + * * @code * Object = AtmosphericModel Group = Algorithm * Name = Isotropic1 ... * EndGroup ... - *EndObject End + *EndObject End * @endcode - * + * * Will create an Isotropic 1st order object (which is derived from AtmosModel). - * The simplest way to create an AtmosModel class is to use the static Create + * The simplest way to create an AtmosModel class is to use the static Create * method - * + * * @code * Pvl p("myatmosmodel.pvl"); * AtmosModel *ar = AtmosModelFactory::Create(p); * @endcode - * + * * @ingroup PatternMatching * * @author 2006-01-23 Janet Barrett - * + * * @internal * @history 2008-06-18 Christopher Austin - Fixed documentation errors */ @@ -64,7 +64,7 @@ namespace Isis { static AtmosModel *Create(Pvl &pvl, PhotoModel &pmodel); private: - /** + /** * Constructor (its private so you can't use it). Use the Create Method * instead. */ diff --git a/isis/src/base/objs/AtmosModelFactory/unitTest.cpp b/isis/src/base/objs/AtmosModelFactory/unitTest.cpp index 33b1d2f235..b11bce4985 100644 --- a/isis/src/base/objs/AtmosModelFactory/unitTest.cpp +++ b/isis/src/base/objs/AtmosModelFactory/unitTest.cpp @@ -4,7 +4,7 @@ using namespace std; -int main () { +int main() { Isis::Preference::Preferences(true); cout << "All testing deferred to AtmosModel and it's extended classes." << endl; diff --git a/isis/src/base/objs/AutoReg/AutoReg.cpp b/isis/src/base/objs/AutoReg/AutoReg.cpp index c66aea2b18..2b27f75d42 100644 --- a/isis/src/base/objs/AutoReg/AutoReg.cpp +++ b/isis/src/base/objs/AutoReg/AutoReg.cpp @@ -20,16 +20,16 @@ namespace Isis { * * @see patternMatch.doc under the coreg application */ - AutoReg::AutoReg (Pvl &pvl) { + AutoReg::AutoReg(Pvl &pvl) { p_template = pvl.FindObject("AutoRegistration"); // Set default parameters - p_patternChip.SetSize(3,3); - p_searchChip.SetSize(5,5); - p_fitChip.SetSize(5,5); - p_reducedPatternChip.SetSize(3,3); - p_reducedSearchChip.SetSize(5,5); - p_reducedFitChip.SetSize(5,5); + p_patternChip.SetSize(3, 3); + p_searchChip.SetSize(5, 5); + p_fitChip.SetSize(5, 5); + p_reducedPatternChip.SetSize(3, 3); + p_reducedSearchChip.SetSize(5, 5); + p_reducedFitChip.SetSize(5, 5); SetPatternValidPercent(50.0); SetPatternZScoreMinimum(1.0); @@ -61,7 +61,7 @@ namespace Isis { p_sampMovement = 0.; p_lineMovement = 0.; - + Init(); Parse(pvl); } @@ -69,9 +69,9 @@ namespace Isis { /** * Initialize AutoReg object private variables. Fill fit chip, reduced pattern * chip and reduced search chip with nulls. - * + * */ - void AutoReg::Init(){ + void AutoReg::Init() { // Set computed parameters to NULL so we don't use values from a previous // run p_ZScore1 = Isis::Null; @@ -88,25 +88,25 @@ namespace Isis { // -------------------------------------------------- // Nulling out the fit chip // -------------------------------------------------- - for (int line = 1; line <= p_fitChip.Lines(); line++) { - for (int samp = 1; samp <= p_fitChip.Samples(); samp++) { - p_fitChip.SetValue(samp,line,Isis::Null); + for(int line = 1; line <= p_fitChip.Lines(); line++) { + for(int samp = 1; samp <= p_fitChip.Samples(); samp++) { + p_fitChip.SetValue(samp, line, Isis::Null); } } // -------------------------------------------------- // Nulling out the reduced pattern chip // -------------------------------------------------- - for (int line = 1; line <= p_reducedPatternChip.Lines(); line++) { - for (int samp = 1; samp <= p_reducedPatternChip.Samples(); samp++) { - p_reducedPatternChip.SetValue(samp,line,Isis::Null); + for(int line = 1; line <= p_reducedPatternChip.Lines(); line++) { + for(int samp = 1; samp <= p_reducedPatternChip.Samples(); samp++) { + p_reducedPatternChip.SetValue(samp, line, Isis::Null); } } // -------------------------------------------------- // Nulling out the reduced search chip // -------------------------------------------------- - for (int line = 1; line <= p_reducedSearchChip.Lines(); line++) { - for (int samp = 1; samp <= p_reducedSearchChip.Samples(); samp++) { - p_reducedSearchChip.SetValue(samp,line,Isis::Null); + for(int line = 1; line <= p_reducedSearchChip.Lines(); line++) { + for(int samp = 1; samp <= p_reducedSearchChip.Samples(); samp++) { + p_reducedSearchChip.SetValue(samp, line, Isis::Null); } } @@ -143,11 +143,11 @@ namespace Isis { * There are many other options that can be set via the pvl and are * described in other documentation (see below). * - * @see patternMatch.doc under the coreg + * @see patternMatch.doc under the coreg * application * - * @param pvl The pvl object containing the specification - * @internal + * @param pvl The pvl object containing the specification + * @internal * @history 2010-06-15 Jeannie Walldren - Added ability to read * ChipInterpolator keyword from the Algorithm group. **/ @@ -156,44 +156,44 @@ namespace Isis { // Get info from Algorithm group PvlGroup &algo = pvl.FindGroup("Algorithm", Pvl::Traverse); SetTolerance(algo["Tolerance"]); - if (algo.HasKeyword("ChipInterpolator")) { + if(algo.HasKeyword("ChipInterpolator")) { SetChipInterpolator((std::string)algo["ChipInterpolator"]); } - if (algo.HasKeyword("SubpixelAccuracy")) { + if(algo.HasKeyword("SubpixelAccuracy")) { SetSubPixelAccuracy((std::string)algo["SubpixelAccuracy"] == "True"); } - if (algo.HasKeyword("ReductionFactor")) { + if(algo.HasKeyword("ReductionFactor")) { SetReductionFactor((int)algo["ReductionFactor"]); } // Setup the pattern chip - PvlGroup &pchip = pvl.FindGroup("PatternChip",Pvl::Traverse); - PatternChip()->SetSize((int)pchip["Samples"],(int)pchip["Lines"]); + PvlGroup &pchip = pvl.FindGroup("PatternChip", Pvl::Traverse); + PatternChip()->SetSize((int)pchip["Samples"], (int)pchip["Lines"]); double minimum = Isis::ValidMinimum; double maximum = Isis::ValidMaximum; - if (pchip.HasKeyword("ValidMinimum")) minimum = pchip["ValidMinimum"]; - if (pchip.HasKeyword("ValidMaximum")) maximum = pchip["ValidMaximum"]; - PatternChip()->SetValidRange(minimum,maximum); + if(pchip.HasKeyword("ValidMinimum")) minimum = pchip["ValidMinimum"]; + if(pchip.HasKeyword("ValidMaximum")) maximum = pchip["ValidMaximum"]; + PatternChip()->SetValidRange(minimum, maximum); - if (pchip.HasKeyword("MinimumZScore")) { + if(pchip.HasKeyword("MinimumZScore")) { SetPatternZScoreMinimum((double)pchip["MinimumZScore"]); } // Setup the search chip - PvlGroup &schip = pvl.FindGroup("SearchChip",Pvl::Traverse); - SearchChip()->SetSize((int)schip["Samples"],(int)schip["Lines"]); + PvlGroup &schip = pvl.FindGroup("SearchChip", Pvl::Traverse); + SearchChip()->SetSize((int)schip["Samples"], (int)schip["Lines"]); minimum = Isis::ValidMinimum; maximum = Isis::ValidMaximum; - if (schip.HasKeyword("ValidMinimum")) minimum = schip["ValidMinimum"]; - if (schip.HasKeyword("ValidMaximum")) maximum = schip["ValidMaximum"]; - SearchChip()->SetValidRange(minimum,maximum); + if(schip.HasKeyword("ValidMinimum")) minimum = schip["ValidMinimum"]; + if(schip.HasKeyword("ValidMaximum")) maximum = schip["ValidMaximum"]; + SearchChip()->SetValidRange(minimum, maximum); // What percentage of the pattern chip should be valid - if (pchip.HasKeyword("ValidPercent")) { + if(pchip.HasKeyword("ValidPercent")) { SetPatternValidPercent((double)pchip["ValidPercent"]); } @@ -221,17 +221,18 @@ namespace Isis { } } - } catch (iException &e) { - std::string msg = "Improper format for AutoReg PVL ["+pvl.Filename()+"]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + } + catch(iException &e) { + std::string msg = "Improper format for AutoReg PVL [" + pvl.Filename() + "]"; + throw iException::Message(iException::User, msg, _FILEINFO_); } return; } /** - * If the sub-pixel accuracy is enabled, the Register() method will attempt to - * match the pattern chip to the search chip at sub-pixel accuracy, otherwise it - * will be registered at whole pixel accuracy. + * If the sub-pixel accuracy is enabled, the Register() method will attempt to + * match the pattern chip to the search chip at sub-pixel accuracy, otherwise it + * will be registered at whole pixel accuracy. * * @param on Set the state of registration accuracy. The * default is sub-pixel accuracy is on @@ -259,10 +260,10 @@ namespace Isis { * default is 50% if never invoked */ void AutoReg::SetPatternValidPercent(const double percent) { - if ((percent <= 0.0) || (percent > 100.0)) { + if((percent <= 0.0) || (percent > 100.0)) { std::string msg = "Invalid value of PatternValidPercent [" + iString(percent) + "]"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_patternValidPercent = percent; } @@ -279,10 +280,10 @@ namespace Isis { * @param minimum The minimum zscore value for the pattern chip. * Default is 1.0 */ - void AutoReg::SetPatternZScoreMinimum (double minimum) { + void AutoReg::SetPatternZScoreMinimum(double minimum) { if(minimum <= 0.0) { std::string msg = "MinimumZScore must be greater than 0"; - throw iException::Message(iException::User,msg,_FILEINFO_); + throw iException::Message(iException::User, msg, _FILEINFO_); } p_minimumPatternZScore = minimum; } @@ -300,37 +301,37 @@ namespace Isis { } /** - * Sets the Chip class interpolator type to be used to load pattern and search - * chips. - * Acceptable values for the interpolator parameter include: - *