From fcf437cf69ecfea9754f81641393fe6b716d4f86 Mon Sep 17 00:00:00 2001 From: Ozan Tonkal Date: Sat, 7 Sep 2013 15:16:26 +0200 Subject: [PATCH] combine representation methods to one as setRepresentation --- modules/viz/include/opencv2/viz/viz3d.hpp | 4 +- modules/viz/src/viz3d.cpp | 4 +- modules/viz/src/viz3d_impl.cpp | 45 +++++++++++------------ modules/viz/src/viz3d_impl.hpp | 4 +- 4 files changed, 25 insertions(+), 32 deletions(-) diff --git a/modules/viz/include/opencv2/viz/viz3d.hpp b/modules/viz/include/opencv2/viz/viz3d.hpp index 4c6015d7d8..3e7d999355 100644 --- a/modules/viz/include/opencv2/viz/viz3d.hpp +++ b/modules/viz/include/opencv2/viz/viz3d.hpp @@ -65,9 +65,7 @@ namespace cv void setDesiredUpdateRate(double time); double getDesiredUpdateRate(); - void setRepresentationToSurface(); - void setRepresentationToWireframe(); - void setRepresentationToPoints(); + void setRepresentation(int representation); private: struct VizImpl; diff --git a/modules/viz/src/viz3d.cpp b/modules/viz/src/viz3d.cpp index 068d9b1b7a..ba323c243e 100644 --- a/modules/viz/src/viz3d.cpp +++ b/modules/viz/src/viz3d.cpp @@ -87,6 +87,4 @@ double cv::viz::Viz3d::getRenderingProperty(const String &id, int property) { re void cv::viz::Viz3d::setDesiredUpdateRate(double time) { impl_->setDesiredUpdateRate(time); } double cv::viz::Viz3d::getDesiredUpdateRate() { return impl_->getDesiredUpdateRate(); } -void cv::viz::Viz3d::setRepresentationToSurface() { impl_->setRepresentationToSurface(); } -void cv::viz::Viz3d::setRepresentationToWireframe() { impl_->setRepresentationToWireframe(); } -void cv::viz::Viz3d::setRepresentationToPoints() { impl_->setRepresentationToPoints(); } \ No newline at end of file +void cv::viz::Viz3d::setRepresentation(int representation) { impl_->setRepresentation(representation); } diff --git a/modules/viz/src/viz3d_impl.cpp b/modules/viz/src/viz3d_impl.cpp index d308ade254..765e71b224 100644 --- a/modules/viz/src/viz3d_impl.cpp +++ b/modules/viz/src/viz3d_impl.cpp @@ -464,33 +464,32 @@ void cv::viz::Viz3d::VizImpl::resetCamera() } /////////////////////////////////////////////////////////////////////////////////// -void cv::viz::Viz3d::VizImpl::setRepresentationToSurface() +void cv::viz::Viz3d::VizImpl::setRepresentation(int representation) { vtkActorCollection * actors = renderer_->GetActors(); actors->InitTraversal(); vtkActor * actor; - while ((actor = actors->GetNextActor()) != NULL) - actor->GetProperty()->SetRepresentationToSurface(); -} - -/////////////////////////////////////////////////////////////////////////////////// -void cv::viz::Viz3d::VizImpl::setRepresentationToPoints() -{ - vtkActorCollection * actors = renderer_->GetActors(); - actors->InitTraversal(); - vtkActor * actor; - while ((actor = actors->GetNextActor()) != NULL) - actor->GetProperty()->SetRepresentationToPoints(); -} - -/////////////////////////////////////////////////////////////////////////////////// -void cv::viz::Viz3d::VizImpl::setRepresentationToWireframe() -{ - vtkActorCollection * actors = renderer_->GetActors(); - actors->InitTraversal(); - vtkActor *actor; - while ((actor = actors->GetNextActor()) != NULL) - actor->GetProperty()->SetRepresentationToWireframe(); + switch (representation) + { + case REPRESENTATION_POINTS: + { + while ((actor = actors->GetNextActor()) != NULL) + actor->GetProperty()->SetRepresentationToPoints(); + break; + } + case REPRESENTATION_SURFACE: + { + while ((actor = actors->GetNextActor()) != NULL) + actor->GetProperty()->SetRepresentationToSurface(); + break; + } + case REPRESENTATION_WIREFRAME: + { + while ((actor = actors->GetNextActor()) != NULL) + actor->GetProperty()->SetRepresentationToWireframe(); + break; + } + } } ////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/viz/src/viz3d_impl.hpp b/modules/viz/src/viz3d_impl.hpp index b6986b20c3..98c2c45547 100644 --- a/modules/viz/src/viz3d_impl.hpp +++ b/modules/viz/src/viz3d_impl.hpp @@ -44,9 +44,7 @@ public: } } - void setRepresentationToSurface(); - void setRepresentationToPoints(); - void setRepresentationToWireframe(); + void setRepresentation(int representation); void setCamera(const Camera &camera); Camera getCamera() const;