From 620d92824ce08ba2bbae80b168739a08e6b450c7 Mon Sep 17 00:00:00 2001 From: Ozan Tonkal Date: Wed, 11 Sep 2013 13:23:57 +0200 Subject: [PATCH] hide VizMap and VizPair from public interface --- modules/viz/include/opencv2/viz.hpp | 7 +++---- modules/viz/src/precomp.hpp | 10 ++++++++++ modules/viz/src/viz.cpp | 34 +++++++++++++++++++++++----------- 3 files changed, 36 insertions(+), 15 deletions(-) diff --git a/modules/viz/include/opencv2/viz.hpp b/modules/viz/include/opencv2/viz.hpp index 61d92e3..bc0f73f 100644 --- a/modules/viz/include/opencv2/viz.hpp +++ b/modules/viz/include/opencv2/viz.hpp @@ -57,9 +57,6 @@ namespace cv { namespace viz { - typedef std::map VizMap; - typedef std::pair VizPair; - //! takes coordiante frame data and builds transfrom to global coordinate frame CV_EXPORTS Affine3f makeTransformToGlobal(const Vec3f& axis_x, const Vec3f& axis_y, const Vec3f& axis_z, const Vec3f& origin = Vec3f::all(0)); @@ -112,7 +109,9 @@ namespace cv static VizAccessor * instance_; static bool is_instantiated_; - static VizMap viz_map_; + + struct VizAccessorImpl; + static VizAccessorImpl * impl_; friend class Viz3d; }; diff --git a/modules/viz/src/precomp.hpp b/modules/viz/src/precomp.hpp index 23b98d3..d12011d 100644 --- a/modules/viz/src/precomp.hpp +++ b/modules/viz/src/precomp.hpp @@ -134,6 +134,16 @@ namespace cv } #include "viz3d_impl.hpp" + +namespace cv +{ + namespace viz + { + typedef std::map VizMap; + typedef std::pair VizPair; + } +} + #include #include #include diff --git a/modules/viz/src/viz.cpp b/modules/viz/src/viz.cpp index db109dd..8941584 100644 --- a/modules/viz/src/viz.cpp +++ b/modules/viz/src/viz.cpp @@ -138,11 +138,23 @@ namespace cv cv::viz::VizAccessor * cv::viz::VizAccessor::instance_ = 0; bool cv::viz::VizAccessor::is_instantiated_ = false; -cv::viz::VizMap cv::viz::VizAccessor::viz_map_; +cv::viz::VizAccessor::VizAccessorImpl * cv::viz::VizAccessor::impl_ = 0; -cv::viz::VizAccessor::VizAccessor() {} +struct cv::viz::VizAccessor::VizAccessorImpl +{ + cv::viz::VizMap viz_map; +}; + +cv::viz::VizAccessor::VizAccessor() { impl_ = new cv::viz::VizAccessor::VizAccessorImpl;} -cv::viz::VizAccessor::~VizAccessor() {} +cv::viz::VizAccessor::~VizAccessor() +{ + if(impl_) + { + delete impl_; + impl_ = 0; + } +} cv::viz::VizAccessor & cv::viz::VizAccessor::getInstance() { @@ -170,8 +182,8 @@ cv::viz::Viz3d cv::viz::VizAccessor::get(const String & window_name) String name; generateWindowName(window_name, name); - VizMap::iterator vm_itr = viz_map_.find(name); - bool exists = vm_itr != viz_map_.end(); + VizMap::iterator vm_itr = impl_->viz_map.find(name); + bool exists = vm_itr != impl_->viz_map.end(); if (exists) return vm_itr->second; else return Viz3d(window_name); } @@ -179,10 +191,10 @@ cv::viz::Viz3d cv::viz::VizAccessor::get(const String & window_name) void cv::viz::VizAccessor::add(Viz3d window) { String window_name = window.getWindowName(); - VizMap::iterator vm_itr = viz_map_.find(window_name); - bool exists = vm_itr != viz_map_.end(); + VizMap::iterator vm_itr = impl_->viz_map.find(window_name); + bool exists = vm_itr != impl_->viz_map.end(); if (exists) return ; - viz_map_.insert(VizPair(window_name, window)); + impl_->viz_map.insert(VizPair(window_name, window)); } void cv::viz::VizAccessor::remove(const String &window_name) @@ -191,10 +203,10 @@ void cv::viz::VizAccessor::remove(const String &window_name) String name; generateWindowName(window_name, name); - VizMap::iterator vm_itr = viz_map_.find(name); - bool exists = vm_itr != viz_map_.end(); + VizMap::iterator vm_itr = impl_->viz_map.find(name); + bool exists = vm_itr != impl_->viz_map.end(); if (!exists) return ; - viz_map_.erase(vm_itr); + impl_->viz_map.erase(vm_itr); } void cv::viz::VizAccessor::generateWindowName(const String &window_name, String &output) -- 2.7.4