mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
pre-proto - Deleting line segments shorter than tolerance used when connecting line segments to polygons.
This commit is contained in:
parent
7738b7f74b
commit
5630df5c1c
@ -112,7 +112,18 @@ void RigCellGeometryTools::createPolygonFromLineSegments(std::list<std::pair<cvf
|
||||
cvf::Vec3d lineSegmentStart = lIt->first;
|
||||
cvf::Vec3d lineSegmentEnd = lIt->second;
|
||||
cvf::Vec3d polygonEnd = polygon.back();
|
||||
if (((lineSegmentStart - polygonEnd).lengthSquared() < tolerance*tolerance))
|
||||
|
||||
double lineSegmentLength = (lineSegmentStart - lineSegmentEnd).lengthSquared();
|
||||
if (lineSegmentLength < tolerance*tolerance)
|
||||
{
|
||||
intersectionLineSegments.erase(lIt);
|
||||
isFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
double lineSegmentStartDiff = (lineSegmentStart - polygonEnd).lengthSquared();
|
||||
if (lineSegmentStartDiff < tolerance*tolerance)
|
||||
{
|
||||
polygon.push_back(lIt->second);
|
||||
intersectionLineSegments.erase(lIt);
|
||||
@ -120,7 +131,8 @@ void RigCellGeometryTools::createPolygonFromLineSegments(std::list<std::pair<cvf
|
||||
break;
|
||||
}
|
||||
|
||||
if (((lineSegmentEnd - polygonEnd).lengthSquared() < tolerance*tolerance))
|
||||
double lineSegmentEndDiff = (lineSegmentEnd - polygonEnd).lengthSquared();
|
||||
if (lineSegmentEndDiff < tolerance*tolerance)
|
||||
{
|
||||
polygon.push_back(lIt->first);
|
||||
intersectionLineSegments.erase(lIt);
|
||||
|
@ -76,6 +76,36 @@ TEST(RigCellGeometryTools, createMultiplePolygonTest)
|
||||
EXPECT_EQ(polygons.size(), 2);
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
TEST(RigCellGeometryTools, createPolygonTestRealCase)
|
||||
{
|
||||
std::list<std::pair<cvf::Vec3d, cvf::Vec3d>> intersectionLineSegments;
|
||||
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900632511830, 20.000000000000000, -0.011799300447865143), cvf::Vec3d(13.498900632515129, 20.000000000000000, -0.011874744050458887) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900633056895, 20.000000000000000, -0.024268930302180504), cvf::Vec3d(13.498900632515127, 20.000000000000000, -0.011874744050458887) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900632511830, 20.000000000000000, -0.011799300447865143), cvf::Vec3d(13.498900631970063, 20.000000000000000, 0.00059488709383226715) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900195597713, 10.000000000000000, -0.016369358494277231), cvf::Vec3d(13.498900195056242, 10.000000000000000, -0.0039819325234285293) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900195597711, 10.000000000000000, -0.016369358494277241), cvf::Vec3d(13.498900195600806, 10.000000000000000, -0.016440172032184591) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900196142280, 10.000000000000000, -0.028827609381707260), cvf::Vec3d(13.498900195600807, 10.000000000000000, -0.016440172032184591) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900196142280, 10.000000000000000, -0.028827609381707260), cvf::Vec3d(13.498900414562046, 14.999139949621291, -0.026549475935230070) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900414637365, 15.000863944878075, -0.026548599914369600), cvf::Vec3d(13.498900633056895, 20.000000000000000, -0.024268930302180504) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900414637365, 15.000863944878075, -0.026548599914369600), cvf::Vec3d(13.498900414562046, 14.999139949621291, -0.026549475935230073) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900413511738, 14.999966890459870, -0.0016942968682188385), cvf::Vec3d(13.498900413514638, 15.000033259475705, -0.0016942630763332898) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900631970063, 20.000000000000000, 0.00059488709383226715), cvf::Vec3d(13.498900413514637, 15.000033259475705, -0.0016942630763332901) });
|
||||
intersectionLineSegments.push_back({ cvf::Vec3d(13.498900413511738, 14.999966890459870, -0.0016942968682188385), cvf::Vec3d(13.498900195056240, 10.000000000000000, -0.0039819325234285319) });
|
||||
|
||||
std::vector<std::vector<cvf::Vec3d>> polygons;
|
||||
|
||||
RigCellGeometryTools::createPolygonFromLineSegments(intersectionLineSegments, polygons);
|
||||
|
||||
EXPECT_EQ(polygons.size(), 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user