diff options
Diffstat (limited to 'source/blender/freestyle')
12 files changed, 123 insertions, 61 deletions
diff --git a/source/blender/freestyle/CMakeLists.txt b/source/blender/freestyle/CMakeLists.txt index 7fbb219af08..c14a5c53734 100644 --- a/source/blender/freestyle/CMakeLists.txt +++ b/source/blender/freestyle/CMakeLists.txt @@ -491,6 +491,7 @@ set(SRC intern/system/TimeUtils.h intern/view_map/ArbitraryGridDensityProvider.cpp intern/view_map/ArbitraryGridDensityProvider.h + intern/view_map/AutoPtrHelper.h intern/view_map/AverageAreaGridDensityProvider.cpp intern/view_map/AverageAreaGridDensityProvider.h intern/view_map/BoxGrid.cpp diff --git a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp index 8bc7c0952a8..3243c4d1fb7 100644 --- a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp +++ b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.cpp @@ -100,22 +100,22 @@ ArbitraryGridDensityProviderFactory::ArbitraryGridDensityProviderFactory(unsigne ArbitraryGridDensityProviderFactory::~ArbitraryGridDensityProviderFactory() {} -auto_ptr<GridDensityProvider> ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source, - const real proscenium[4]) +AutoPtr<GridDensityProvider> ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source, + const real proscenium[4]) { - return auto_ptr<GridDensityProvider>(new ArbitraryGridDensityProvider(source, proscenium, numCells)); + return AutoPtr<GridDensityProvider>(new ArbitraryGridDensityProvider(source, proscenium, numCells)); } -auto_ptr<GridDensityProvider> +AutoPtr<GridDensityProvider> ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, const GridHelpers::Transform& transform) { - return auto_ptr<GridDensityProvider>(new ArbitraryGridDensityProvider(source, bbox, transform, numCells)); + return AutoPtr<GridDensityProvider>(new ArbitraryGridDensityProvider(source, bbox, transform, numCells)); } -auto_ptr<GridDensityProvider> ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source) +AutoPtr<GridDensityProvider> ArbitraryGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source) { - return auto_ptr<GridDensityProvider>(new ArbitraryGridDensityProvider(source, numCells)); + return AutoPtr<GridDensityProvider>(new ArbitraryGridDensityProvider(source, numCells)); } } /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h index 652cb9b34b0..c7939d34da4 100644 --- a/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h +++ b/source/blender/freestyle/intern/view_map/ArbitraryGridDensityProvider.h @@ -58,10 +58,10 @@ public: ArbitraryGridDensityProviderFactory(unsigned numCells); ~ArbitraryGridDensityProviderFactory(); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, - const GridHelpers::Transform& transform); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, + const GridHelpers::Transform& transform); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source); protected: unsigned numCells; diff --git a/source/blender/freestyle/intern/view_map/AutoPtrHelper.h b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h new file mode 100644 index 00000000000..17a43c184c7 --- /dev/null +++ b/source/blender/freestyle/intern/view_map/AutoPtrHelper.h @@ -0,0 +1,60 @@ +/* + * ***** BEGIN GPL LICENSE BLOCK ***** + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * ***** END GPL LICENSE BLOCK ***** + */ + +#ifndef __FREESTYLE_AUTOPTR_HELPER_H__ +#define __FREESTYLE_AUTOPTR_HELPER_H__ + +/** \file blender/freestyle/intern/view_map/AutoPtrHelper.h + * \ingroup freestyle + * \brief Utility header for auto_ptr/unique_ptr selection + * \author Sergey Sharybin + * \date 2015-02-09 + */ + +#include <memory> + +namespace Freestyle { + +#if __cplusplus > 199711L +template<typename T> +class AutoPtr : public std::unique_ptr<T> { +public: + AutoPtr() : std::unique_ptr<T>() {} + AutoPtr(T *ptr) : std::unique_ptr<T>(ptr) {} + + /* TODO(sergey): Is there more clear way to do this? */ + template<typename X> + AutoPtr(AutoPtr<X>& other) : std::unique_ptr<T>(other.get()) { + other.release(); + } +}; +#else +template<typename T> +class AutoPtr : public std::auto_ptr<T> { +public: + AutoPtr() : std::auto_ptr<T>() {} + AutoPtr(T *ptr) : std::auto_ptr<T>(ptr) {} + AutoPtr(std::auto_ptr_ref<T> ref) : std::auto_ptr<T>(ref) {} +}; +#endif + +} /* namespace Freestyle */ + +#endif // __FREESTYLE_AUTOPTR_HELPER_H__ diff --git a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp index 952b9752a3e..b5e133ec441 100644 --- a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp +++ b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.cpp @@ -121,22 +121,22 @@ AverageAreaGridDensityProviderFactory::AverageAreaGridDensityProviderFactory(rea AverageAreaGridDensityProviderFactory::~AverageAreaGridDensityProviderFactory() {} -auto_ptr<GridDensityProvider> +AutoPtr<GridDensityProvider> AverageAreaGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source, const real proscenium[4]) { - return auto_ptr<GridDensityProvider>(new AverageAreaGridDensityProvider(source, proscenium, sizeFactor)); + return AutoPtr<GridDensityProvider>(new AverageAreaGridDensityProvider(source, proscenium, sizeFactor)); } -auto_ptr<GridDensityProvider> +AutoPtr<GridDensityProvider> AverageAreaGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, const GridHelpers::Transform& transform) { - return auto_ptr<GridDensityProvider>(new AverageAreaGridDensityProvider(source, bbox, transform, sizeFactor)); + return AutoPtr<GridDensityProvider>(new AverageAreaGridDensityProvider(source, bbox, transform, sizeFactor)); } -auto_ptr<GridDensityProvider> AverageAreaGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source) +AutoPtr<GridDensityProvider> AverageAreaGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source) { - return auto_ptr<GridDensityProvider>(new AverageAreaGridDensityProvider(source, sizeFactor)); + return AutoPtr<GridDensityProvider>(new AverageAreaGridDensityProvider(source, sizeFactor)); } } /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h index d63557f5cda..2c58cc32da9 100644 --- a/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h +++ b/source/blender/freestyle/intern/view_map/AverageAreaGridDensityProvider.h @@ -55,10 +55,10 @@ public: AverageAreaGridDensityProviderFactory(real sizeFactor); ~AverageAreaGridDensityProviderFactory(); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, - const GridHelpers::Transform& transform); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, + const GridHelpers::Transform& transform); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source); protected: real sizeFactor; diff --git a/source/blender/freestyle/intern/view_map/GridDensityProvider.h b/source/blender/freestyle/intern/view_map/GridDensityProvider.h index 272d64dd6de..b49e74d6402 100644 --- a/source/blender/freestyle/intern/view_map/GridDensityProvider.h +++ b/source/blender/freestyle/intern/view_map/GridDensityProvider.h @@ -32,6 +32,7 @@ #include <algorithm> #include <memory> +#include "AutoPtrHelper.h" #include "OccluderSource.h" #include "../geometry/BBox.h" @@ -148,12 +149,12 @@ class GridDensityProviderFactory public: GridDensityProviderFactory() {} - virtual auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]) = 0; + virtual AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]) = 0; - virtual auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, - const GridHelpers::Transform& transform) = 0; + virtual AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, + const GridHelpers::Transform& transform) = 0; - virtual auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source) = 0; + virtual AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source) = 0; virtual ~GridDensityProviderFactory () {} diff --git a/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp b/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp index 00f5cc90cc4..18edc82b096 100644 --- a/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp +++ b/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.cpp @@ -36,45 +36,45 @@ HeuristicGridDensityProviderFactory::HeuristicGridDensityProviderFactory(real si HeuristicGridDensityProviderFactory::~HeuristicGridDensityProviderFactory() {} -auto_ptr<GridDensityProvider> +AutoPtr<GridDensityProvider> HeuristicGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source, const real proscenium[4]) { - auto_ptr<AverageAreaGridDensityProvider> avg(new AverageAreaGridDensityProvider(source, proscenium, sizeFactor)); - auto_ptr<Pow23GridDensityProvider> p23(new Pow23GridDensityProvider(source, proscenium, numFaces)); + AutoPtr<AverageAreaGridDensityProvider> avg(new AverageAreaGridDensityProvider(source, proscenium, sizeFactor)); + AutoPtr<Pow23GridDensityProvider> p23(new Pow23GridDensityProvider(source, proscenium, numFaces)); if (avg->cellSize() > p23->cellSize()) { - return (auto_ptr<GridDensityProvider>) p23; + return (AutoPtr<GridDensityProvider>) p23; } else { - return (auto_ptr<GridDensityProvider>) avg; + return (AutoPtr<GridDensityProvider>) avg; } } -auto_ptr<GridDensityProvider> +AutoPtr<GridDensityProvider> HeuristicGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, const GridHelpers::Transform& transform) { - auto_ptr<AverageAreaGridDensityProvider> avg(new AverageAreaGridDensityProvider(source, bbox, - transform, sizeFactor)); - auto_ptr<Pow23GridDensityProvider> p23(new Pow23GridDensityProvider(source, bbox, transform, numFaces)); + AutoPtr<AverageAreaGridDensityProvider> avg(new AverageAreaGridDensityProvider(source, bbox, + transform, sizeFactor)); + AutoPtr<Pow23GridDensityProvider> p23(new Pow23GridDensityProvider(source, bbox, transform, numFaces)); if (avg->cellSize() > p23->cellSize()) { - return (auto_ptr<GridDensityProvider>) p23; + return (AutoPtr<GridDensityProvider>) p23; } else { - return (auto_ptr<GridDensityProvider>) avg; + return (AutoPtr<GridDensityProvider>) avg; } } -auto_ptr<GridDensityProvider> HeuristicGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source) +AutoPtr<GridDensityProvider> HeuristicGridDensityProviderFactory::newGridDensityProvider(OccluderSource& source) { real proscenium[4]; GridDensityProvider::calculateOptimalProscenium(source, proscenium); - auto_ptr<AverageAreaGridDensityProvider> avg(new AverageAreaGridDensityProvider(source, proscenium, sizeFactor)); - auto_ptr<Pow23GridDensityProvider> p23(new Pow23GridDensityProvider(source, proscenium, numFaces)); + AutoPtr<AverageAreaGridDensityProvider> avg(new AverageAreaGridDensityProvider(source, proscenium, sizeFactor)); + AutoPtr<Pow23GridDensityProvider> p23(new Pow23GridDensityProvider(source, proscenium, numFaces)); if (avg->cellSize() > p23->cellSize()) { - return (auto_ptr<GridDensityProvider>) p23; + return (AutoPtr<GridDensityProvider>) p23; } else { - return (auto_ptr<GridDensityProvider>) avg; + return (AutoPtr<GridDensityProvider>) avg; } } diff --git a/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h b/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h index 65f2af6df2f..9414e4931f5 100644 --- a/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h +++ b/source/blender/freestyle/intern/view_map/HeuristicGridDensityProviderFactory.h @@ -42,10 +42,10 @@ public: HeuristicGridDensityProviderFactory(real sizeFactor, unsigned numFaces); ~HeuristicGridDensityProviderFactory(); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, - const GridHelpers::Transform& transform); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, + const GridHelpers::Transform& transform); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source); protected: real sizeFactor; diff --git a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp index e3bb9b87ecc..8dff079e0cf 100644 --- a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp +++ b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.cpp @@ -99,22 +99,22 @@ Pow23GridDensityProviderFactory::Pow23GridDensityProviderFactory(unsigned numFac Pow23GridDensityProviderFactory::~Pow23GridDensityProviderFactory () {} -auto_ptr<GridDensityProvider> +AutoPtr<GridDensityProvider> Pow23GridDensityProviderFactory::newGridDensityProvider(OccluderSource& source, const real proscenium[4]) { - return auto_ptr<GridDensityProvider>(new Pow23GridDensityProvider(source, proscenium, numFaces)); + return AutoPtr<GridDensityProvider>(new Pow23GridDensityProvider(source, proscenium, numFaces)); } -auto_ptr<GridDensityProvider> +AutoPtr<GridDensityProvider> Pow23GridDensityProviderFactory::newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, const GridHelpers::Transform& transform) { - return auto_ptr<GridDensityProvider>(new Pow23GridDensityProvider(source, bbox, transform, numFaces)); + return AutoPtr<GridDensityProvider>(new Pow23GridDensityProvider(source, bbox, transform, numFaces)); } -auto_ptr<GridDensityProvider> Pow23GridDensityProviderFactory::newGridDensityProvider(OccluderSource& source) +AutoPtr<GridDensityProvider> Pow23GridDensityProviderFactory::newGridDensityProvider(OccluderSource& source) { - return auto_ptr<GridDensityProvider>(new Pow23GridDensityProvider(source, numFaces)); + return AutoPtr<GridDensityProvider>(new Pow23GridDensityProvider(source, numFaces)); } } /* namespace Freestyle */ diff --git a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h index 7f646790ab6..5dfa9cdfc87 100644 --- a/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h +++ b/source/blender/freestyle/intern/view_map/Pow23GridDensityProvider.h @@ -58,10 +58,10 @@ public: Pow23GridDensityProviderFactory(unsigned numFaces); ~Pow23GridDensityProviderFactory(); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, - const GridHelpers::Transform& transform); - auto_ptr<GridDensityProvider> newGridDensityProvider(OccluderSource& source); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const real proscenium[4]); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source, const BBox<Vec3r>& bbox, + const GridHelpers::Transform& transform); + AutoPtr<GridDensityProvider> newGridDensityProvider(OccluderSource& source); protected: unsigned numFaces; diff --git a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp index a0a1282219c..8adc2fa66fd 100644 --- a/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp +++ b/source/blender/freestyle/intern/view_map/ViewMapBuilder.cpp @@ -1300,8 +1300,8 @@ void ViewMapBuilder::computeCusps(ViewMap *ioViewMap) void ViewMapBuilder::ComputeCumulativeVisibility(ViewMap *ioViewMap, WingedEdge& we, const BBox<Vec3r>& bbox, real epsilon, bool cull, GridDensityProviderFactory& factory) { - auto_ptr<GridHelpers::Transform> transform; - auto_ptr<OccluderSource> source; + AutoPtr<GridHelpers::Transform> transform; + AutoPtr<OccluderSource> source; if (_orthographicProjection) { transform.reset(new BoxGrid::Transform); @@ -1317,7 +1317,7 @@ void ViewMapBuilder::ComputeCumulativeVisibility(ViewMap *ioViewMap, WingedEdge& source.reset(new OccluderSource(*transform, we)); } - auto_ptr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform)); + AutoPtr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform)); if (_orthographicProjection) { BoxGrid grid(*source, *density, ioViewMap, _viewpoint, _EnableQI); @@ -1332,8 +1332,8 @@ void ViewMapBuilder::ComputeCumulativeVisibility(ViewMap *ioViewMap, WingedEdge& void ViewMapBuilder::ComputeDetailedVisibility(ViewMap *ioViewMap, WingedEdge& we, const BBox<Vec3r>& bbox, real epsilon, bool cull, GridDensityProviderFactory& factory) { - auto_ptr<GridHelpers::Transform> transform; - auto_ptr<OccluderSource> source; + AutoPtr<GridHelpers::Transform> transform; + AutoPtr<OccluderSource> source; if (_orthographicProjection) { transform.reset(new BoxGrid::Transform); @@ -1349,7 +1349,7 @@ void ViewMapBuilder::ComputeDetailedVisibility(ViewMap *ioViewMap, WingedEdge& w source.reset(new OccluderSource(*transform, we)); } - auto_ptr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform)); + AutoPtr<GridDensityProvider> density(factory.newGridDensityProvider(*source, bbox, *transform)); if (_orthographicProjection) { BoxGrid grid(*source, *density, ioViewMap, _viewpoint, _EnableQI); |