Match3DCoarse.hpp
00001 //
00002 // COP match tool with coarse alignment
00003 // Copyright (C) 2008-2010 AQSENSE, S.L.
00004 //
00005 #if !defined (AQSENSE_SAL3DPP_MATCH3DCOARSE_HPP)
00006 #define AQSENSE_SAL3DPP_MATCH3DCOARSE_HPP
00007 
00008 #if defined (_MSC_VER) && (_MSC_VER >= 1020)
00009 #pragma once
00010 #endif // _MSC_VER && _MSC_VER >= 1020
00011 
00012 #include <sal3d/match3dcoarse.h>
00013 #include <sal3d/match3d.h>
00014 #include <sal3dpp/Match3D.hpp> /* for SurfacePoints */
00015 #include <sal3dpp/COP.hpp>
00016 #include <vector>
00017 
00018 namespace sal3d
00019 {
00090     class Match3DCoarse
00091     {
00092         public:
00106             explicit Match3DCoarse (const sal3d::COP &cop)
00107             {
00108                 _match3d.p = 0;
00109                 Error e;
00110                 sal3d_match3d_new_with_cop (cop.c_cop (), &_match3d, &e.e);
00111                 if (e.e.value < 0)
00112                     throw e;
00113             }
00114 
00128             explicit Match3DCoarse (const SurfacePoints &points)
00129             {
00130                 _match3d.p = 0;
00131                 Error e;
00132                 sal3d_match3d_new_with_surface_points (&points[0], points.size(),
00133                         &_match3d, &e.e);
00134                 if (e.e.value < 0)
00135                     throw e;
00136             }
00137 
00143             Match3DCoarse (const Match3DCoarse &match3d):
00144                 _match3d (match3d._match3d)
00145             {
00146                 Error e;
00147                 sal3d_match3d_share (_match3d, &e.e);
00148                 if (e.e.value < 0)
00149                     throw e;
00150             }
00151 
00155             ~Match3DCoarse ()
00156             {
00157                 sal3d_match3d_release (_match3d);
00158             }
00159 
00174             Movement3D
00175             operator() (const sal3d::COP &cop) const
00176             {
00177                 float quality;
00178                 int iters;
00179                 Match3DParameters params;
00180 
00181                 return this->operator()(cop, params, quality, iters);
00182             }
00183 
00202             Movement3D
00203             operator() (const sal3d::COP &cop, float &quality) const
00204             {
00205                 int iters;
00206                 Match3DParameters params;
00207 
00208                 return this->operator()(cop, params, quality, iters);
00209             }
00210 
00238             Movement3D
00239             operator() (const sal3d::COP &cop, const Match3DParameters &params,
00240                     float &quality, int &iterations) const
00241             {
00242                 sal3d_movement_3d movement;
00243                 Error e;
00244                 sal3d_match3dcoarse_align (_match3d, cop.c_cop (),
00245                         params.maxIterations, params.maxTranslationError,
00246                         params.maxRotationError, params.extractFeatures,
00247                         &movement, &quality, &iterations, &e.e);
00248                 if (e.e.value < 0)
00249                     throw e;
00250 
00251                 return Movement3D (movement);
00252             }
00253 
00261             Match3DCoarse &
00262             operator= (const Match3DCoarse &rhs)
00263             {
00264                 sal3d_match3d_share (rhs._match3d);
00265                 sal3d_match3d_release (_match3d);
00266                 _match3d = rhs._match3d;
00267 
00268                 return *this;
00269             }
00270 
00271         private:
00273             sal3d_match3d _match3d;
00274     };
00275 }
00276 
00277 #endif // !AQSENSE_SAL3DPP_MATCH3DCOARSE_HPP