2018-07-02 07:47:56 -05:00
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
|
|
|
#include "RiaPolyArcLineSampler.h"
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
TEST( RiaPolyArcLineSampler, Basic )
|
2018-07-02 07:47:56 -05:00
|
|
|
{
|
2020-11-06 03:46:38 -06:00
|
|
|
std::vector<cvf::Vec3d> points{ { 0, 0, 0 }, { 0, 0, -10 }, { 0, 10, -20 }, { 0, 20, -20 }, { 0, 30, -30 } };
|
2018-07-02 07:47:56 -05:00
|
|
|
|
2020-11-06 03:46:38 -06:00
|
|
|
RiaPolyArcLineSampler sampler( { 0, 0, -1 }, points );
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2020-10-06 05:37:16 -05:00
|
|
|
auto [sampledPoints, mds] = sampler.sampledPointsAndMDs( 2, true );
|
2019-11-18 03:29:53 -06:00
|
|
|
#if 1
|
2019-11-19 04:08:59 -06:00
|
|
|
for ( size_t pIdx = 0; pIdx < sampledPoints.size(); ++pIdx )
|
2018-07-02 07:47:56 -05:00
|
|
|
{
|
2023-02-26 03:48:40 -06:00
|
|
|
std::cout << sampledPoints[pIdx].x() << " " << sampledPoints[pIdx].y() << " " << sampledPoints[pIdx].z() << " md: " << mds[pIdx]
|
|
|
|
<< std::endl;
|
2018-11-16 01:43:19 -06:00
|
|
|
}
|
|
|
|
#endif
|
2019-11-18 03:29:53 -06:00
|
|
|
EXPECT_EQ( 55, (int)sampledPoints.size() );
|
2019-09-06 03:40:57 -05:00
|
|
|
EXPECT_NEAR( 51.4159, mds.back(), 1e-4 );
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2019-11-18 03:29:53 -06:00
|
|
|
EXPECT_NEAR( points[2].y(), sampledPoints[27].y(), 2 );
|
|
|
|
EXPECT_NEAR( points[2].z(), sampledPoints[27].z(), 2 );
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2019-11-18 03:29:53 -06:00
|
|
|
EXPECT_NEAR( points[4].y(), sampledPoints.back().y(), 2 );
|
|
|
|
EXPECT_NEAR( points[4].z(), sampledPoints.back().z(), 2 );
|
2018-11-16 01:43:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
TEST( RiaPolyArcLineSampler, TestInvalidInput )
|
2018-11-16 01:43:19 -06:00
|
|
|
{
|
|
|
|
{
|
|
|
|
// Two identical points after each other
|
2020-11-06 03:46:38 -06:00
|
|
|
std::vector<cvf::Vec3d> points{ { 0, 0, -20 }, { 0, 0, -20 } };
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2020-11-06 03:46:38 -06:00
|
|
|
RiaPolyArcLineSampler sampler( { 0, 0, -1 }, points );
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2020-10-06 05:37:16 -05:00
|
|
|
auto [sampledPoints, mds] = sampler.sampledPointsAndMDs( 2, true );
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
EXPECT_EQ( 0, (int)sampledPoints.size() );
|
2020-10-19 05:32:36 -05:00
|
|
|
EXPECT_EQ( 0, (int)mds.size() );
|
2018-11-16 01:43:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
std::vector<cvf::Vec3d> points;
|
|
|
|
|
2020-11-06 03:46:38 -06:00
|
|
|
RiaPolyArcLineSampler sampler( { 0, 0, -1 }, points );
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2020-10-06 05:37:16 -05:00
|
|
|
auto [sampledPoints, mds] = sampler.sampledPointsAndMDs( 2, true );
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
EXPECT_EQ( 0, (int)sampledPoints.size() );
|
2020-10-19 05:32:36 -05:00
|
|
|
EXPECT_EQ( 0, (int)mds.size() );
|
2018-11-16 01:43:19 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
{
|
2020-11-06 03:46:38 -06:00
|
|
|
std::vector<cvf::Vec3d> points{ { 0, 0, 0 } };
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2020-11-06 03:46:38 -06:00
|
|
|
RiaPolyArcLineSampler sampler( { 0, 0, -1 }, points );
|
2018-11-16 01:43:19 -06:00
|
|
|
|
2020-10-06 05:37:16 -05:00
|
|
|
auto [sampledPoints, mds] = sampler.sampledPointsAndMDs( 2, true );
|
2018-07-02 07:47:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
EXPECT_EQ( 0, (int)sampledPoints.size() );
|
2020-10-19 05:32:36 -05:00
|
|
|
EXPECT_EQ( 0, (int)mds.size() );
|
2018-11-16 01:43:19 -06:00
|
|
|
}
|
2018-07-02 07:47:56 -05:00
|
|
|
}
|