Permalink
Browse files

Make IsisAdjustCameraModel copy safe

  • Loading branch information...
1 parent 4c0fc0a commit fc7781839dcfbdf0bd772f69d1ccaea88978b5c2 Zack Moratto committed Dec 18, 2010
Showing with 8 additions and 15 deletions.
  1. +2 −9 src/asp/IsisIO/IsisAdjustCameraModel.cc
  2. +6 −6 src/asp/IsisIO/IsisAdjustCameraModel.h
@@ -32,13 +32,13 @@ IsisAdjustCameraModel::IsisAdjustCameraModel( std::string cube_filename,
// Opening labels and camera
Isis::Filename cubefile( cube_filename.c_str() );
m_label.Read( cubefile.Expanded() );
- m_camera = Isis::CameraFactory::Create( m_label );
+ m_camera = boost::shared_ptr<Isis::Camera>(Isis::CameraFactory::Create( m_label ));
// Gutting Camera
m_distortmap = m_camera->DistortionMap();
m_focalmap = m_camera->FocalPlaneMap();
m_detectmap = m_camera->DetectorMap();
- m_alphacube = new Isis::AlphaCube( m_label );
+ m_alphacube = boost::shared_ptr<Isis::AlphaCube>( new Isis::AlphaCube( m_label ) );
// Throw error if this is map projected image
if ( m_camera->HasProjection() )
@@ -50,13 +50,6 @@ IsisAdjustCameraModel::IsisAdjustCameraModel( std::string cube_filename,
m_pose_f->set_time_offset( middle_et );
}
-IsisAdjustCameraModel::~IsisAdjustCameraModel() {
- if ( m_camera )
- delete m_camera;
- if ( m_alphacube )
- delete m_alphacube;
-}
-
//-------------------------------------------------------------------------
// Set Time Function ( used to avoid setting the camera too much )
//-------------------------------------------------------------------------
@@ -44,7 +44,7 @@ namespace camera {
boost::shared_ptr<asp::BaseEquation> position_func,
boost::shared_ptr<asp::BaseEquation> pose_func );
- virtual ~IsisAdjustCameraModel();
+ virtual ~IsisAdjustCameraModel(){}
virtual std::string type() const { return "IsisAdjust"; }
@@ -75,9 +75,9 @@ namespace camera {
protected:
boost::shared_ptr<asp::BaseEquation> m_position_f, m_pose_f;
Isis::Pvl m_label;
- Isis::Camera *m_camera;
- Isis::AlphaCube *m_alphacube;
- Isis::CameraDistortionMap *m_distortmap;
+ boost::shared_ptr<Isis::Camera> m_camera;
+ boost::shared_ptr<Isis::AlphaCube> m_alphacube;
+ Isis::CameraDistortionMap *m_distortmap; // m_camera has ownership
Isis::CameraFocalPlaneMap *m_focalmap;
Isis::CameraDetectorMap *m_detectmap;
@@ -91,7 +91,7 @@ namespace camera {
// they use the adjustment functions in m_position_f and m_pose_f.
class EphemerisLMA : public math::LeastSquaresModelBase<EphemerisLMA> {
Vector3 m_point;
- Isis::Camera* m_camera;
+ boost::shared_ptr<Isis::Camera> m_camera;
Isis::CameraDistortionMap *m_distortmap;
Isis::CameraFocalPlaneMap *m_focalmap;
boost::shared_ptr<asp::BaseEquation> m_position_f, m_pose_f;
@@ -101,7 +101,7 @@ namespace camera {
typedef Matrix<double> jacobian_type;
inline EphemerisLMA( Vector3 const& point,
- Isis::Camera* camera,
+ boost::shared_ptr<Isis::Camera> camera,
Isis::CameraDistortionMap* distortmap,
Isis::CameraFocalPlaneMap* focalmap,
boost::shared_ptr<asp::BaseEquation> position,

0 comments on commit fc77818

Please sign in to comment.