Skip to content

Commit

Permalink
-fix another case in TrAutoFixFourTrianglePts.cpp
Browse files Browse the repository at this point in the history
-update version number
  • Loading branch information
alemon-aquaveo committed Jul 5, 2024
1 parent 8ee6dcd commit b332e94
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion _package/xms/grid/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
from . import triangulate # NOQA: F401
from . import ugrid # NOQA: F401

__version__ = '7.8.3'
__version__ = '7.8.4'
12 changes: 12 additions & 0 deletions test_files/bug15178.xmc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ASCII XmUGrid Version 2
LOCATIONS 5
POINT 0 -8.5 -16.6 0.0
POINT 1 6.1 -2.5 0.0
POINT 2 -28.3 0.1 0.0
POINT 3 23.5 49.6 0.0
POINT 4 7.2 -30.7 0.0
CELL_STREAM 20
CELL 0 TRIANGLE 3 1 3 2
CELL 1 TRIANGLE 3 4 1 0
CELL 2 TRIANGLE 3 1 4 3
CELL 3 TRIANGLE 3 2 0 1
41 changes: 39 additions & 2 deletions xmsgrid/triangulate/detail/TrAutoFixFourTrianglePts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,24 @@ void TrAutoFixFourTrianglePtsImpl::MakeTwoNewTriangles(VecPt3d& a_pts,
double area2 = iTriArea(t2, a_pts);
VecInt t3 = {bound[1], bound[2], bound[3]};
double area3 = iTriArea(t3, a_pts);
if (d2_02 < d2_13 && area0 > 0.0 && area1 > 0.0)
bool all_positive_area = area0 > 0.0 && area1 > 0.0 && area2 > 0.0 && area3 > 0.0;
bool do_case_1(false), do_case_2(false);
if (!all_positive_area)
{
if (area0 > 0.0 && area1 > 0.0)
do_case_1 = true;
else if (area2 > 0.0 && area3 > 0.0)
do_case_2 = true;
}
else
{
if (d2_02 < d2_13)
do_case_1 = true;
else
do_case_2 = true;
}

if (do_case_1) //if (d2_02 < d2_13 && area0 > 0.0 && area1 > 0.0)
{
a_tris[0] = t0;
a_tris[1] = t1;
Expand All @@ -255,7 +272,7 @@ void TrAutoFixFourTrianglePtsImpl::MakeTwoNewTriangles(VecPt3d& a_pts,
//a_tris[1][1] = bound[2];
//a_tris[1][2] = bound[3];
}
else if (area2 > 0.0 && area3 > 0.0)
else if (do_case_2) //else if (area2 > 0.0 && area3 > 0.0)
{
a_tris[0] = t2;
a_tris[1] = t3;
Expand Down Expand Up @@ -487,4 +504,24 @@ void TrAutoFixFourTrianglePtsUnitTests::test_bug15186a()
VecInt base_tris = {0, 1, 4, 0, 4, 3, 0, 2, 1, 2, 4, 1};
TS_ASSERT_EQUALS_VEC(base_tris, tris);
} // TrOuterTriangleDeleterTests::test_bug15186a
//------------------------------------------------------------------------------
/// \brief Tests TrAutoFixFourTrianglePts.
//------------------------------------------------------------------------------
void TrAutoFixFourTrianglePtsUnitTests::test_bug15178()
{
std::string testFilesPath(XMS_TEST_PATH);
std::string fname = testFilesPath + "bug15178.xmc";
std::shared_ptr<XmUGrid> ug = XmReadUGridFromAsciiFile(fname);
BSHP<TrTin> tin = iTinFromUGrid(ug);

VecInt bPts;
tin->GetBoundaryPoints(bPts);
TrAutoFixFourTrianglePtsImpl p;
p.SetUndeleteablePtIdxs(bPts);
p.Fix(tin);
TS_ASSERT_EQUALS(4, tin->Points().size());
VecInt tris = tin->Triangles();
VecInt base_tris = {0, 3, 2, 0, 2, 1};
TS_ASSERT_EQUALS_VEC(base_tris, tris);
} // TrOuterTriangleDeleterTests::test_bug15178
#endif // CXX_TEST
1 change: 1 addition & 0 deletions xmsgrid/triangulate/detail/TrAutoFixFourTrianglePts.t.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class TrAutoFixFourTrianglePtsUnitTests : public CxxTest::TestSuite
void test1();
void test_bug15186();
void test_bug15186a();
void test_bug15178();
}; // class TrAutoFixFourTrianglePtsUnitTests

#endif

0 comments on commit b332e94

Please sign in to comment.