From b10fea7dbf55a89ee5f5571f27297141ea16607e Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Tue, 21 Sep 2021 22:48:57 -0700 Subject: [PATCH] make BB usable Signed-off-by: Louise Poubel --- include/ignition/rendering/BoundingBox.hh | 24 +++++++++++++ src/BoundingBox.cc | 37 ++++++++++++++++++++ src/BoundingBox_TEST.cc | 41 +++++++++++++++++++++++ 3 files changed, 102 insertions(+) create mode 100644 src/BoundingBox_TEST.cc diff --git a/include/ignition/rendering/BoundingBox.hh b/include/ignition/rendering/BoundingBox.hh index 1e6a2984b..911209c55 100644 --- a/include/ignition/rendering/BoundingBox.hh +++ b/include/ignition/rendering/BoundingBox.hh @@ -35,6 +35,30 @@ inline namespace IGNITION_RENDERING_VERSION_NAMESPACE { /// position / orientation / size info of the box and its label class IGNITION_RENDERING_VISIBLE BoundingBox { + /// \brief Constructor + public: BoundingBox(); + + /// \brief Copy constructor + /// \param[in] _box BoundingBox to copy. + public: BoundingBox(const BoundingBox &_box); + + /// \brief Move constructor + /// \param[in] _box BoundingBox to move. + public: BoundingBox(BoundingBox &&_box) noexcept; + + /// \brief Destructor + public: virtual ~BoundingBox(); + + /// \brief Move assignment operator. + /// \param[in] _box Heightmap box to move. + /// \return Reference to this. + public: BoundingBox &operator=(BoundingBox &&_box); + + /// \brief Copy Assignment operator. + /// \param[in] _box The heightmap box to set values from. + /// \return *this + public: BoundingBox &operator=(const BoundingBox &_box); + /// \internal /// \brief Private data IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING diff --git a/src/BoundingBox.cc b/src/BoundingBox.cc index 1b5967caa..505ec5b00 100644 --- a/src/BoundingBox.cc +++ b/src/BoundingBox.cc @@ -26,3 +26,40 @@ class ignition::rendering::BoundingBoxPrivate { }; +////////////////////////////////////////////////// +BoundingBox::BoundingBox() : + dataPtr(std::make_unique()) +{ +} + +///////////////////////////////////////////////// +BoundingBox::~BoundingBox() +{ +} + +////////////////////////////////////////////////// +BoundingBox::BoundingBox(const BoundingBox &_texture) + : dataPtr(std::make_unique(*_texture.dataPtr)) +{ +} + +////////////////////////////////////////////////// +BoundingBox::BoundingBox(BoundingBox &&_texture) noexcept + : dataPtr(std::exchange(_texture.dataPtr, nullptr)) +{ +} + +///////////////////////////////////////////////// +BoundingBox &BoundingBox::operator=( + const BoundingBox &_texture) +{ + return *this = BoundingBox(_texture); +} + +///////////////////////////////////////////////// +BoundingBox &BoundingBox::operator=(BoundingBox &&_texture) +{ + std::swap(this->dataPtr, _texture.dataPtr); + return *this; +} + diff --git a/src/BoundingBox_TEST.cc b/src/BoundingBox_TEST.cc new file mode 100644 index 000000000..d4ee62aab --- /dev/null +++ b/src/BoundingBox_TEST.cc @@ -0,0 +1,41 @@ +/* + * Copyright (C) 2021 Open Source Robotics Foundation + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +*/ + +#include + +#include "test_config.h" // NOLINT(build/include) +#include "ignition/rendering/BoundingBox.hh" + +using namespace ignition; +using namespace rendering; + +class BoundingBoxTest : public testing::Test +{ +}; + +///////////////////////////////////////////////// +TEST(BoundingBoxTest, BoundingBox) +{ + BoundingBox box; +} + +///////////////////////////////////////////////// +int main(int argc, char **argv) +{ + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +}