From 82d869fab164b78d287b30d8f22783c1d6c525eb Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 14 Jul 2022 18:02:50 -0700 Subject: [PATCH 1/3] update marker test Signed-off-by: Ian Chen --- src/LidarVisual_TEST.cc | 3 ++ src/Marker_TEST.cc | 81 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 83 insertions(+), 1 deletion(-) diff --git a/src/LidarVisual_TEST.cc b/src/LidarVisual_TEST.cc index 5cc600e7b..d45491d76 100644 --- a/src/LidarVisual_TEST.cc +++ b/src/LidarVisual_TEST.cc @@ -120,6 +120,9 @@ void LidarVisualTest::LidarVisual(const std::string &_renderEngine) 10, 3.5}; lidar->SetPoints(pts); EXPECT_EQ(pts.size(), lidar->PointCount()); + + lidar->PreRender(); + lidar->ClearPoints(); EXPECT_EQ(lidar->PointCount(), 0u); diff --git a/src/Marker_TEST.cc b/src/Marker_TEST.cc index 7510df123..f257c0c2c 100644 --- a/src/Marker_TEST.cc +++ b/src/Marker_TEST.cc @@ -19,9 +19,10 @@ #include #include "test_config.h" // NOLINT(build/include) +#include "ignition/rendering/Marker.hh" +#include "ignition/rendering/Material.hh" #include "ignition/rendering/RenderEngine.hh" #include "ignition/rendering/RenderingIface.hh" -#include "ignition/rendering/Marker.hh" #include "ignition/rendering/Scene.hh" using namespace ignition; @@ -32,6 +33,9 @@ class MarkerTest : public testing::Test, public testing::WithParamInterface { public: void Marker(const std::string &_renderEngine); + + /// \brief Test setting material + public: void Material(const std::string &_renderEngine); }; ///////////////////////////////////////////////// @@ -79,12 +83,26 @@ void MarkerTest::Marker(const std::string &_renderEngine) marker->SetType(MarkerType::MT_CAPSULE); EXPECT_EQ(MarkerType::MT_CAPSULE, marker->Type()); + // test attaching marker to visual + VisualPtr visual = scene->CreateVisual(); + ASSERT_NE(nullptr, visual); + visual->AddGeometry(marker); + marker->SetType(MarkerType::MT_CYLINDER); EXPECT_EQ(MarkerType::MT_CYLINDER, marker->Type()); + marker->SetType(MarkerType::MT_BOX); + EXPECT_EQ(MarkerType::MT_BOX, marker->Type()); + + marker->SetType(MarkerType::MT_SPHERE); + EXPECT_EQ(MarkerType::MT_SPHERE, marker->Type()); + marker->SetType(MarkerType::MT_NONE); EXPECT_EQ(MarkerType::MT_NONE, marker->Type()); + marker->SetType(static_cast(99)); + EXPECT_EQ(static_cast(99), marker->Type()); + marker->SetType(MarkerType::MT_POINTS); EXPECT_EQ(MarkerType::MT_POINTS, marker->Type()); @@ -103,6 +121,13 @@ void MarkerTest::Marker(const std::string &_renderEngine) marker->SetType(MarkerType::MT_TRIANGLE_FAN); EXPECT_EQ(MarkerType::MT_TRIANGLE_FAN, marker->Type()); + // set same type again + marker->SetType(MarkerType::MT_TRIANGLE_FAN); + EXPECT_EQ(MarkerType::MT_TRIANGLE_FAN, marker->Type()); + + // attach to visual again + EXPECT_NO_THROW(visual->AddGeometry(marker)); + // exercise point api EXPECT_NO_THROW(marker->AddPoint(math::Vector3d(0, 1, 2), math::Color::White)); @@ -118,12 +143,66 @@ void MarkerTest::Marker(const std::string &_renderEngine) rendering::unloadEngine(engine->Name()); } +///////////////////////////////////////////////// +void MarkerTest::Material(const std::string &_renderEngine) +{ + if (_renderEngine == "optix") + { + igndbg << "Marker not supported yet in rendering engine: " + << _renderEngine << std::endl; + return; + } + + + RenderEngine *engine = rendering::engine(_renderEngine); + if (!engine) + { + igndbg << "Engine '" << _renderEngine + << "' is not supported" << std::endl; + return; + } + + ScenePtr scene = engine->CreateScene("scene"); + + MarkerPtr marker = scene->CreateMarker(); + ASSERT_NE(nullptr, marker); + + EXPECT_NO_THROW(marker->SetMaterial(MaterialPtr(), false)); + EXPECT_EQ(nullptr, marker->Material()); + + MaterialPtr material = scene->CreateMaterial(); + ASSERT_NE(nullptr, material); + material->SetDiffuse(0.1, 0.2, 0.3); + + marker->SetType(MarkerType::MT_NONE); + EXPECT_EQ(MarkerType::MT_NONE, marker->Type()); + marker->SetMaterial(material, false); + EXPECT_EQ(material, marker->Material()); + + marker->SetType(MarkerType::MT_BOX); + EXPECT_EQ(MarkerType::MT_BOX, marker->Type()); + marker->SetMaterial(material, false); + EXPECT_EQ(material, marker->Material()); + + marker->SetType(MarkerType::MT_LINE_STRIP); + EXPECT_EQ(MarkerType::MT_LINE_STRIP, marker->Type()); + marker->SetMaterial(material, true); + EXPECT_NE(material, marker->Material()); + EXPECT_EQ(math::Color(0.1, 0.2, 0.3), marker->Material()->Diffuse()); +} + ///////////////////////////////////////////////// TEST_P(MarkerTest, Marker) { Marker(GetParam()); } +///////////////////////////////////////////////// +TEST_P(MarkerTest, Material) +{ + Material(GetParam()); +} + INSTANTIATE_TEST_CASE_P(Marker, MarkerTest, RENDER_ENGINE_VALUES, ignition::rendering::PrintToStringParam()); From c7dcb3bb11895c7f53ea82807567867e29771954 Mon Sep 17 00:00:00 2001 From: Ian Chen Date: Thu, 21 Jul 2022 16:01:28 -0700 Subject: [PATCH 2/3] style Signed-off-by: Ian Chen --- examples/waves/CMakeLists.txt | 2 ++ src/Marker_TEST.cc | 3 +-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/examples/waves/CMakeLists.txt b/examples/waves/CMakeLists.txt index d054c5db5..ad91d4cf5 100644 --- a/examples/waves/CMakeLists.txt +++ b/examples/waves/CMakeLists.txt @@ -6,6 +6,7 @@ include_directories(SYSTEM ) find_package(ignition-rendering6) +#find_package(ignition-common4) set(TARGET_THIRD_PARTY_DEPENDS "") @@ -51,6 +52,7 @@ add_executable(waves Main.cc GlutWindow.cc) target_link_libraries(waves ${IGNITION-RENDERING_LIBRARIES} +# ${IGNITION-COMMON_LIBRARIES} ${TARGET_THIRD_PARTY_DEPENDS} ) diff --git a/src/Marker_TEST.cc b/src/Marker_TEST.cc index f257c0c2c..3e05cfbd1 100644 --- a/src/Marker_TEST.cc +++ b/src/Marker_TEST.cc @@ -149,11 +149,10 @@ void MarkerTest::Material(const std::string &_renderEngine) if (_renderEngine == "optix") { igndbg << "Marker not supported yet in rendering engine: " - << _renderEngine << std::endl; + << _renderEngine << std::endl; return; } - RenderEngine *engine = rendering::engine(_renderEngine); if (!engine) { From 8880456e39e66ae1b558b959eb00a67e0162651f Mon Sep 17 00:00:00 2001 From: Louise Poubel Date: Fri, 22 Jul 2022 22:06:53 -0700 Subject: [PATCH 3/3] Windows warning Signed-off-by: Louise Poubel --- src/Marker_TEST.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Marker_TEST.cc b/src/Marker_TEST.cc index 3e05cfbd1..0f228020d 100644 --- a/src/Marker_TEST.cc +++ b/src/Marker_TEST.cc @@ -187,7 +187,7 @@ void MarkerTest::Material(const std::string &_renderEngine) EXPECT_EQ(MarkerType::MT_LINE_STRIP, marker->Type()); marker->SetMaterial(material, true); EXPECT_NE(material, marker->Material()); - EXPECT_EQ(math::Color(0.1, 0.2, 0.3), marker->Material()->Diffuse()); + EXPECT_EQ(math::Color(0.1f, 0.2f, 0.3f), marker->Material()->Diffuse()); } /////////////////////////////////////////////////