diff --git a/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp index e961c0ceed..f98e5e5a62 100644 --- a/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp @@ -29,11 +29,15 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -int RigHexIntersectionTools::lineHexCellIntersection(const cvf::Vec3d p1, const cvf::Vec3d p2, const cvf::Vec3d hexCorners[8], const size_t hexIndex, std::vector* intersections) +int RigHexIntersectionTools::lineHexCellIntersection(const cvf::Vec3d p1, + const cvf::Vec3d p2, + const cvf::Vec3d hexCorners[8], + const size_t hexIndex, + std::vector* intersections) { CVF_ASSERT(intersections != NULL); - int intersectionCount = 0; + std::set uniqueIntersections; for ( int face = 0; face < 6 ; ++face ) { @@ -56,14 +60,20 @@ int RigHexIntersectionTools::lineHexCellIntersection(const cvf::Vec3d p1, const &isEntering); if ( intsStatus == 1 ) { - intersectionCount++; - intersections->push_back(HexIntersectionInfo(intersection, - isEntering, - static_cast(face), hexIndex)); + uniqueIntersections.insert(HexIntersectionInfo(intersection, + isEntering, + static_cast(face), hexIndex)); } } } + int intersectionCount = 0; + for ( const auto& intersection: uniqueIntersections) + { + intersections->push_back(intersection); + ++intersectionCount; + } + return intersectionCount; } @@ -153,3 +163,22 @@ bool RigHexIntersectionTools::planeHexIntersectionPolygons(std::array tolerance ) return hi1.m_intersectionPoint.x() < hi2.m_intersectionPoint.x(); + if ( cvf::Math::abs(hi2.m_intersectionPoint.y() - hi1.m_intersectionPoint.y()) > tolerance ) return hi1.m_intersectionPoint.y() < hi2.m_intersectionPoint.y(); + if ( cvf::Math::abs(hi2.m_intersectionPoint.z() - hi1.m_intersectionPoint.z()) > tolerance ) return hi1.m_intersectionPoint.z() < hi2.m_intersectionPoint.z(); + + return false; +} diff --git a/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.h b/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.h index 8a2b386967..e40bd6507c 100644 --- a/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.h @@ -48,6 +48,8 @@ public: size_t m_hexIndex; }; +bool operator<( const HexIntersectionInfo& hi1, const HexIntersectionInfo& hi2); + //-------------------------------------------------------------------------------------------------- /// Specialized Line - Hex intersection //--------------------------------------------------------------------------------------------------