2017-06-16 02:44:28 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-06-16 02:44:28 -05:00
|
|
|
// ResInsight 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 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-06-16 02:44:28 -05:00
|
|
|
// ResInsight 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.
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-06-16 02:44:28 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "gtest/gtest.h"
|
|
|
|
|
2022-03-11 06:24:01 -06:00
|
|
|
#include <QDateTime>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QElapsedTimer>
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RigHexIntersectionTools.h"
|
2017-06-16 02:44:28 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-06-16 02:44:28 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
TEST( RigHexIntersectionTools, planeHexCellIntersectionTest )
|
2017-06-16 02:44:28 -05:00
|
|
|
{
|
|
|
|
cvf::Vec3d hexCorners[8];
|
2019-09-06 03:40:57 -05:00
|
|
|
hexCorners[0] = cvf::Vec3d( 0, 0, 0 );
|
|
|
|
hexCorners[1] = cvf::Vec3d( 1, 0, 0 );
|
|
|
|
hexCorners[2] = cvf::Vec3d( 0, 1, 0 );
|
|
|
|
hexCorners[3] = cvf::Vec3d( 0, 0, 1 );
|
|
|
|
hexCorners[4] = cvf::Vec3d( 0, 1, 1 );
|
|
|
|
hexCorners[5] = cvf::Vec3d( 1, 1, 0 );
|
|
|
|
hexCorners[6] = cvf::Vec3d( 1, 0, 1 );
|
|
|
|
hexCorners[7] = cvf::Vec3d( 1, 1, 1 );
|
|
|
|
|
|
|
|
std::list<std::pair<cvf::Vec3d, cvf::Vec3d>> intersectionLineSegments;
|
|
|
|
bool isCellIntersected = false;
|
|
|
|
cvf::Plane fracturePlane;
|
|
|
|
|
|
|
|
fracturePlane.setFromPointAndNormal( cvf::Vec3d( 0.5, 0.5, 0.5 ), cvf::Vec3d( 1, 0, 0 ) );
|
2023-02-26 03:48:40 -06:00
|
|
|
isCellIntersected = RigHexIntersectionTools::planeHexCellIntersection( hexCorners, fracturePlane, intersectionLineSegments );
|
2019-09-06 03:40:57 -05:00
|
|
|
EXPECT_TRUE( isCellIntersected );
|
|
|
|
|
|
|
|
fracturePlane.setFromPointAndNormal( cvf::Vec3d( 1.5, 1.5, 1.5 ), cvf::Vec3d( 1, 0, 0 ) );
|
2023-02-26 03:48:40 -06:00
|
|
|
isCellIntersected = RigHexIntersectionTools::planeHexCellIntersection( hexCorners, fracturePlane, intersectionLineSegments );
|
2019-09-06 03:40:57 -05:00
|
|
|
EXPECT_FALSE( isCellIntersected );
|
2017-06-16 02:44:28 -05:00
|
|
|
}
|
2018-08-20 04:47:05 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2018-08-20 04:47:05 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
TEST( RigHexIntersectionTools, DISABLED_planeHexCellIntersectionPerformanceTest )
|
2018-08-20 04:47:05 -05:00
|
|
|
{
|
|
|
|
cvf::Vec3d hexCorners[8];
|
2019-09-06 03:40:57 -05:00
|
|
|
hexCorners[0] = cvf::Vec3d( 0, 0, 0 );
|
|
|
|
hexCorners[1] = cvf::Vec3d( 1, 0, 0 );
|
|
|
|
hexCorners[2] = cvf::Vec3d( 0, 1, 0 );
|
|
|
|
hexCorners[3] = cvf::Vec3d( 0, 0, 1 );
|
|
|
|
hexCorners[4] = cvf::Vec3d( 0, 1, 1 );
|
|
|
|
hexCorners[5] = cvf::Vec3d( 1, 1, 0 );
|
|
|
|
hexCorners[6] = cvf::Vec3d( 1, 0, 1 );
|
|
|
|
hexCorners[7] = cvf::Vec3d( 1, 1, 1 );
|
|
|
|
|
|
|
|
bool isCellIntersected = false;
|
2018-08-20 04:47:05 -05:00
|
|
|
cvf::Plane fracturePlaneIntersecting;
|
|
|
|
cvf::Plane fracturePlaneNotIntersecting;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
fracturePlaneNotIntersecting.setFromPointAndNormal( cvf::Vec3d( 1.5, 1.5, 1.5 ), cvf::Vec3d( 1, 0, 0 ) );
|
|
|
|
fracturePlaneIntersecting.setFromPointAndNormal( cvf::Vec3d( 0.5, 0.5, 0.5 ), cvf::Vec3d( 1, 0, 0 ) );
|
2018-08-20 04:47:05 -05:00
|
|
|
|
2022-03-11 06:24:01 -06:00
|
|
|
QElapsedTimer timeTotal;
|
2018-08-20 04:47:05 -05:00
|
|
|
timeTotal.start();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int run = 0; run < 5; run++ )
|
2018-08-20 04:47:05 -05:00
|
|
|
{
|
2022-03-11 06:24:01 -06:00
|
|
|
QElapsedTimer timeLocal;
|
2018-08-20 04:47:05 -05:00
|
|
|
timeLocal.start();
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( int i = 0; i < 2000000; i++ )
|
2018-08-20 04:47:05 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
std::list<std::pair<cvf::Vec3d, cvf::Vec3d>> intersectionLineSegments;
|
|
|
|
|
2023-02-26 03:48:40 -06:00
|
|
|
isCellIntersected =
|
|
|
|
RigHexIntersectionTools::planeHexCellIntersection( hexCorners, fracturePlaneIntersecting, intersectionLineSegments );
|
|
|
|
isCellIntersected =
|
|
|
|
RigHexIntersectionTools::planeHexCellIntersection( hexCorners, fracturePlaneNotIntersecting, intersectionLineSegments );
|
2018-08-20 04:47:05 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
qDebug() << "Time rim elapsed: " << timeLocal.elapsed();
|
|
|
|
}
|
|
|
|
|
2020-05-18 08:45:49 -05:00
|
|
|
qDebug() << "Time total elapsed: " << timeTotal.elapsed() << " intersected: " << static_cast<int>( isCellIntersected );
|
2018-08-20 04:47:05 -05:00
|
|
|
}
|