mirror of
https://github.com/OPM/ResInsight.git
synced 2026-09-03 20:53:13 -05:00
Merged down changes from Resinsight dev branch
This commit is contained in:
@@ -13,6 +13,7 @@ set(CEE_LIBS LibCore)
|
||||
|
||||
set(CEE_SOURCE_FILES
|
||||
cvfArray-Test.cpp
|
||||
cvfArrayWrapper-Test.cpp
|
||||
cvfBase-Test.cpp
|
||||
cvfBase64-Test.cpp
|
||||
cvfCharArray-Test.cpp
|
||||
|
||||
@@ -250,6 +250,7 @@
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\ThirdParty\gtest\gtest-all.cpp" />
|
||||
<ClCompile Include="cvfArray-Test.cpp" />
|
||||
<ClCompile Include="cvfArrayWrapper-Test.cpp" />
|
||||
<ClCompile Include="cvfBase-Test.cpp" />
|
||||
<ClCompile Include="cvfBase64-Test.cpp" />
|
||||
<ClCompile Include="cvfCharArray-Test.cpp" />
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
<ClCompile Include="cvfLogger-Test.cpp" />
|
||||
<ClCompile Include="cvfLogEvent-Test.cpp" />
|
||||
<ClCompile Include="cvfCodeLocation-Test.cpp" />
|
||||
<ClCompile Include="cvfArrayWrapper-Test.cpp" />
|
||||
<ClCompile Include="cvfProgramOptions-Test.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
@@ -40,4 +41,4 @@
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="TriggerTBBCopy.txt" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
||||
@@ -0,0 +1,189 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) Ceetron Solutions AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||
// for more details.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
|
||||
#include "cvfBase.h"
|
||||
#include "cvfArray.h"
|
||||
#include "cvfArrayWrapperToEdit.h"
|
||||
#include "cvfArrayWrapperConst.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
using namespace cvf;
|
||||
|
||||
|
||||
|
||||
template <typename ArrayType, typename ElmType>
|
||||
void arrayWrapperConstTestFunction(const ArrayWrapperConst< ArrayType, ElmType> cinRefArray)
|
||||
{
|
||||
ElmType e;
|
||||
size_t size;
|
||||
|
||||
size = cinRefArray.size();
|
||||
e = cinRefArray[size-1];
|
||||
CVF_UNUSED(e);
|
||||
// cinRefArray[size-1] = e;
|
||||
{
|
||||
const ElmType& cre = cinRefArray[size-1];
|
||||
CVF_UNUSED(cre);
|
||||
|
||||
//ElmType& re = cinRefArray[size-1];
|
||||
//re = e;
|
||||
}
|
||||
}
|
||||
|
||||
template <typename ArrayType, typename ElmType>
|
||||
void arrayWrapperConstRefTestFunction(const ArrayWrapperConst< ArrayType, ElmType>& cinRefArray)
|
||||
{
|
||||
ElmType e;
|
||||
size_t size;
|
||||
|
||||
size = cinRefArray.size();
|
||||
e = cinRefArray[size-1];
|
||||
CVF_UNUSED(e);
|
||||
// cinRefArray[size-1] = e;
|
||||
{
|
||||
const ElmType& cre = cinRefArray[size-1];
|
||||
CVF_UNUSED(cre);
|
||||
//ElmType& re = cinRefArray[size-1];
|
||||
//re = e;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
template <typename ArrayType, typename ElmType>
|
||||
void arrayWrapperTestFunction(ArrayWrapperToEdit< ArrayType, ElmType> cinRefArray)
|
||||
{
|
||||
ElmType e, e2;
|
||||
size_t size;
|
||||
|
||||
size = cinRefArray.size();
|
||||
e = cinRefArray[size-1];
|
||||
e2 = cinRefArray[0];
|
||||
cinRefArray[0] = e;
|
||||
{
|
||||
const ElmType& cre = cinRefArray[size-1];
|
||||
CVF_UNUSED(cre);
|
||||
ElmType& re = cinRefArray[size-1];
|
||||
re = e2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(ArrayWrapperTest, AllSpecializations)
|
||||
{
|
||||
std::vector<cvf::Vec3d> vec3dStdVector;
|
||||
vec3dStdVector.push_back(Vec3d::ZERO);
|
||||
vec3dStdVector.push_back(Vec3d(1,1,1));
|
||||
|
||||
const std::vector<cvf::Vec3d> &cvec3dStdVector = vec3dStdVector;
|
||||
|
||||
cvf::Vec3dArray vec3dCvfArray(vec3dStdVector);
|
||||
const cvf::Vec3dArray& cvec3dCvfArray = vec3dCvfArray;
|
||||
|
||||
cvf::Array<size_t> siztCvfArray(2);
|
||||
siztCvfArray[0] = 0;
|
||||
siztCvfArray[1] = 1;
|
||||
|
||||
cvf::Array<uint> uintCvfArray(2);
|
||||
uintCvfArray[0] = 0;
|
||||
uintCvfArray[1] = 1;
|
||||
const cvf::Array<uint>& cuintCvfArray = uintCvfArray;
|
||||
|
||||
size_t siztBarePtrArray[2] = {0, 1};
|
||||
|
||||
size_t* siztBarePtr = new size_t[2];
|
||||
siztBarePtr[0] = 0;
|
||||
siztBarePtr[1] = 1;
|
||||
|
||||
const size_t* csiztBarePtr = siztBarePtr;
|
||||
|
||||
cvf::uint* uintBarePtr = new cvf::uint[2];
|
||||
uintBarePtr[0] = 0;
|
||||
uintBarePtr[1] = 1;
|
||||
|
||||
double* doubleBarePtr = new double[2];
|
||||
doubleBarePtr[0] = 0;
|
||||
doubleBarePtr[1] = 1;
|
||||
const double* cdoubleBarePtr = doubleBarePtr;
|
||||
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(&vec3dStdVector));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(&cvec3dStdVector));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(&vec3dCvfArray));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(&cvec3dCvfArray));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(&uintCvfArray));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(&cuintCvfArray));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(siztBarePtrArray, 2));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(siztBarePtr, 2));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(csiztBarePtr, 2));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(doubleBarePtr,2));
|
||||
arrayWrapperConstTestFunction(wrapArrayConst(cdoubleBarePtr, 2));
|
||||
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(&vec3dStdVector));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(&cvec3dStdVector));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(&vec3dCvfArray));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(&cvec3dCvfArray));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(&uintCvfArray));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(&cuintCvfArray));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(siztBarePtrArray, 2));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(siztBarePtr, 2));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(csiztBarePtr, 2));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(doubleBarePtr,2));
|
||||
arrayWrapperConstRefTestFunction(wrapArrayConst(cdoubleBarePtr, 2));
|
||||
|
||||
arrayWrapperTestFunction(wrapArrayToEdit(&vec3dStdVector));
|
||||
//arrayWrapperTestFunction3(wrapArray(&cvec3dStdVector));
|
||||
EXPECT_EQ(Vec3d::ZERO, vec3dStdVector[1]);
|
||||
EXPECT_EQ(Vec3d(1,1,1), vec3dStdVector[0]);
|
||||
|
||||
arrayWrapperTestFunction(wrapArrayToEdit(&vec3dCvfArray));
|
||||
EXPECT_EQ(Vec3d::ZERO, vec3dCvfArray[1]);
|
||||
EXPECT_EQ(Vec3d(1,1,1), vec3dStdVector[0]);
|
||||
//arrayWrapperTestFunction3(wrapArray(&cvec3dCvfArray));
|
||||
arrayWrapperTestFunction(wrapArrayToEdit(&uintCvfArray));
|
||||
//arrayWrapperTestFunction3(wrapArray(&cuintCvfArray));
|
||||
arrayWrapperTestFunction(wrapArrayToEdit(siztBarePtrArray, 2));
|
||||
//arrayWrapperTestFunction3(wrapArray(csiztBarePtr, 2));
|
||||
arrayWrapperTestFunction(wrapArrayToEdit(doubleBarePtr,2));
|
||||
//arrayWrapperTestFunction3(wrapArray(cdoubleBarePtr, 2));
|
||||
EXPECT_EQ(0.0, doubleBarePtr[1]);
|
||||
EXPECT_EQ(1.0, doubleBarePtr[0]);
|
||||
}
|
||||
@@ -15,6 +15,7 @@ set(CEE_LIBS LibGeometry LibCore)
|
||||
set(CEE_SOURCE_FILES
|
||||
cvfArrowGenerator-Test.cpp
|
||||
cvfBoundingBox-Test.cpp
|
||||
cvfBoundingBoxTree-Test.cpp
|
||||
cvfBoxGenerator-Test.cpp
|
||||
cvfFrustum-Test.cpp
|
||||
cvfEdgeKey-Test.cpp
|
||||
|
||||
@@ -251,6 +251,7 @@
|
||||
<ClCompile Include="..\..\ThirdParty\gtest\gtest-all.cpp" />
|
||||
<ClCompile Include="cvfArrowGenerator-Test.cpp" />
|
||||
<ClCompile Include="cvfBoundingBox-Test.cpp" />
|
||||
<ClCompile Include="cvfBoundingBoxTree-Test.cpp" />
|
||||
<ClCompile Include="cvfBoxGenerator-Test.cpp" />
|
||||
<ClCompile Include="cvfEdgeKey-Test.cpp" />
|
||||
<ClCompile Include="cvfFrustum-Test.cpp" />
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
<ClCompile Include="cvfTriangleVertexSplitter-Test.cpp" />
|
||||
<ClCompile Include="cvfVertexCompactor-Test.cpp" />
|
||||
<ClCompile Include="cvfTriangleMeshEdgeExtractor-Test.cpp" />
|
||||
<ClCompile Include="cvfBoundingBoxTree-Test.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="CMakeLists.txt" />
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
//##################################################################################################
|
||||
//
|
||||
// Custom Visualization Core library
|
||||
// Copyright (C) Ceetron Solutions AS
|
||||
//
|
||||
// This library may be used under the terms of either the GNU General Public License or
|
||||
// the GNU Lesser General Public License as follows:
|
||||
//
|
||||
// GNU General Public License Usage
|
||||
// This library 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.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
|
||||
// for more details.
|
||||
//
|
||||
// GNU Lesser General Public License Usage
|
||||
// This library is free software; you can redistribute it and/or modify
|
||||
// it under the terms of the GNU Lesser General Public License as published by
|
||||
// the Free Software Foundation; either version 2.1 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This library 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.
|
||||
//
|
||||
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
|
||||
// for more details.
|
||||
//
|
||||
//##################################################################################################
|
||||
|
||||
#include "cvfBoundingBoxTree.h"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace cvf;
|
||||
|
||||
std::ostream& operator<<(std::ostream& stream, const std::vector<size_t>& array)
|
||||
{
|
||||
for (size_t i = 0; i < array.size(); ++i)
|
||||
{
|
||||
stream << array[i] << " ";
|
||||
}
|
||||
stream << std::endl;
|
||||
return stream;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(BoundingBoxTree, Intersection)
|
||||
{
|
||||
BoundingBoxTree bbtree;
|
||||
|
||||
std::vector<cvf::BoundingBox> bbs;
|
||||
bbs.push_back(cvf::BoundingBox(Vec3d(0,0,0), Vec3d(1,1,1)));
|
||||
bbs.push_back(cvf::BoundingBox(Vec3d(1,0,0), Vec3d(2,1,1)));
|
||||
bbs.push_back(cvf::BoundingBox(Vec3d(2,0,0), Vec3d(3,1,1)));
|
||||
bbs.push_back(cvf::BoundingBox(Vec3d(3,0,0), Vec3d(4,1,1)));
|
||||
bbs.push_back(cvf::BoundingBox(Vec3d(4,0,0), Vec3d(5,1,1)));
|
||||
bbs.push_back(cvf::BoundingBox(Vec3d(0.5,0.5,0), Vec3d(5.5,1.5,1)));
|
||||
|
||||
|
||||
std::vector<size_t> ids;
|
||||
ids.push_back(10);
|
||||
ids.push_back(11);
|
||||
ids.push_back(12);
|
||||
ids.push_back(13);
|
||||
ids.push_back(14);
|
||||
ids.push_back(15);
|
||||
|
||||
bbtree.buildTreeFromBoundingBoxes(bbs, &ids);
|
||||
|
||||
{
|
||||
std::vector<size_t> intIds;
|
||||
bbtree.findIntersections(cvf::BoundingBox(Vec3d(0.25,0.25,0.25), Vec3d(4.5,0.4,0.4)), &intIds);
|
||||
size_t numBB = intIds.size();
|
||||
EXPECT_EQ(5, numBB);
|
||||
EXPECT_EQ(intIds[4], 13);
|
||||
//std::cout << intIds;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<size_t> intIds;
|
||||
bbtree.findIntersections(cvf::BoundingBox(Vec3d(0.25,0.75,0.25), Vec3d(4.5,0.8,0.4)), &intIds);
|
||||
size_t numBB = intIds.size();
|
||||
EXPECT_EQ(6, numBB);
|
||||
EXPECT_EQ(intIds[5], 15);
|
||||
//std::cout << intIds;
|
||||
}
|
||||
|
||||
{
|
||||
std::vector<size_t> intIds;
|
||||
bbtree.findIntersections(cvf::BoundingBox(Vec3d(2,0,0), Vec3d(3,1,1)), &intIds);
|
||||
size_t numBB = intIds.size();
|
||||
EXPECT_EQ(4, numBB);
|
||||
EXPECT_EQ(intIds[0], 11);
|
||||
//std::cout << intIds;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user