diff --git a/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/RivCellFaceIntersection-Test.cpp b/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/RivCellFaceIntersection-Test.cpp index f086bafcb7..41b1a47596 100644 --- a/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/RivCellFaceIntersection-Test.cpp +++ b/ApplicationCode/ModelVisualization/ModelVisualization_UnitTests/RivCellFaceIntersection-Test.cpp @@ -148,242 +148,6 @@ private: }; -template -void arrayWrapperConstTestFunction(const ArrayWrapperConst< ArrayType, ElmType> cinRefArray) -{ - ElmType e; - size_t size; - - size = cinRefArray.size(); - e = cinRefArray[size-1]; - // cinRefArray[size-1] = e; - { - const ElmType& cre = cinRefArray[size-1]; - //ElmType& re = cinRefArray[size-1]; - //re = e; - } -} - -template -void arrayWrapperConstRefTestFunction(const ArrayWrapperConst< ArrayType, ElmType>& cinRefArray) -{ - ElmType e; - size_t size; - - size = cinRefArray.size(); - e = cinRefArray[size-1]; - // cinRefArray[size-1] = e; - { - const ElmType& cre = cinRefArray[size-1]; - //ElmType& re = cinRefArray[size-1]; - //re = e; - } -} - - -template -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]; - ElmType& re = cinRefArray[size-1]; - re = e2; - } -} - -template -void arrayWrapperRefTestFunction(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]; - ElmType& re = cinRefArray[size-1]; - re = e2; - } -} - -std::ostream& operator<< (std::ostream& stream, cvf::Vec3d v) -{ - stream << v[0] << " " << v[1] << " " << v[2] ; - return stream; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -TEST(ArrayWrapperTest, AllSpecializations) -{ - std::vector vec3dStdVector; - vec3dStdVector.push_back(Vec3d::ZERO); - vec3dStdVector.push_back(Vec3d(1,1,1)); - - const std::vector &cvec3dStdVector = vec3dStdVector; - - cvf::Vec3dArray vec3dCvfArray(vec3dStdVector); - const cvf::Vec3dArray& cvec3dCvfArray = vec3dCvfArray; - - cvf::Array siztCvfArray(2); - siztCvfArray[0] = 0; - siztCvfArray[1] = 1; - const cvf::Array& csiztCvfArray = siztCvfArray; - - cvf::Array uintCvfArray(2); - uintCvfArray[0] = 0; - uintCvfArray[1] = 1; - const cvf::Array& 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; - const cvf::uint* cuintBarePtr = uintBarePtr; - - 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]); - - arrayWrapperRefTestFunction(wrapArrayToEdit(&vec3dStdVector)); - EXPECT_EQ(Vec3d::ZERO, vec3dStdVector[0]); - EXPECT_EQ(Vec3d(1,1,1), vec3dStdVector[1]); - //arrayWrapperRefTestFunction3(wrapArray(&cvec3dStdVector)); - arrayWrapperRefTestFunction(wrapArrayToEdit(&vec3dCvfArray)); - EXPECT_EQ(Vec3d::ZERO, vec3dCvfArray[0]); - EXPECT_EQ(Vec3d(1,1,1), vec3dStdVector[1]); - //arrayWrapperRefTestFunction3(wrapArray(&cvec3dCvfArray)); - arrayWrapperRefTestFunction(wrapArrayToEdit(&uintCvfArray)); - //arrayWrapperRefTestFunction3(wrapArray(&cuintCvfArray)); - arrayWrapperRefTestFunction(wrapArrayToEdit(siztBarePtrArray, 2)); - //arrayWrapperRefTestFunction3(wrapArray(csiztBarePtr, 2)); - arrayWrapperRefTestFunction(wrapArrayToEdit(doubleBarePtr,2)); - //arrayWrapperRefTestFunction3(wrapArray(cdoubleBarePtr, 2)); - - EXPECT_EQ(0.0, doubleBarePtr[0]); - EXPECT_EQ(1.0, doubleBarePtr[1]); -} - -std::ostream& operator<<(std::ostream& stream, const std::vector& array) -{ - for (size_t i = 0; i < array.size(); ++i) - { - stream << array[i] << " "; - } - stream << std::endl; - return stream; -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -TEST(BoundingBoxTree, Intersection) -{ - cvf::BoundingBoxTree bbtree; - - std::vector 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 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 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 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 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; - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/cvfGeometryTools.cpp b/ApplicationCode/ModelVisualization/cvfGeometryTools.cpp index e66d156ece..abb13f8b77 100644 --- a/ApplicationCode/ModelVisualization/cvfGeometryTools.cpp +++ b/ApplicationCode/ModelVisualization/cvfGeometryTools.cpp @@ -661,9 +661,9 @@ void GeometryTools::addMidEdgeNodes(std::list >* poly } if (it2 != polygon->begin()) - polygon->insert(it2, std::make_pair(midPointIndex, true)); + polygon->insert(it2, std::make_pair((cvf::uint)midPointIndex, true)); else - polygon->insert(polygon->end(), std::make_pair(midPointIndex, true)); + polygon->insert(polygon->end(), std::make_pair((cvf::uint)midPointIndex, true)); ++it; }