From 4d50c803d0320db14693b70befdf2953985fe29c Mon Sep 17 00:00:00 2001 From: csmemoe Date: Wed, 23 Feb 2022 15:03:49 -0700 Subject: [PATCH] Change the function that generates centroid triangles to generate them regardless of whether the cell points are oriented CW or CCW. --- dev/xmsprofile_debug | 2 +- xmsextractor/ugrid/XmUGridTriangulatorBase.cpp | 9 ++------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/dev/xmsprofile_debug b/dev/xmsprofile_debug index 6aaaf1d..cc1e593 100644 --- a/dev/xmsprofile_debug +++ b/dev/xmsprofile_debug @@ -8,7 +8,7 @@ compiler.version=16 build_type=Debug cppstd=17 [options] -xmsextractor:xms=False +xmsextractor:wchar_t=typedef xmsextractor:pybind=False xmsextractor:testing=True [build_requires] diff --git a/xmsextractor/ugrid/XmUGridTriangulatorBase.cpp b/xmsextractor/ugrid/XmUGridTriangulatorBase.cpp index 877e975..11fafda 100644 --- a/xmsextractor/ugrid/XmUGridTriangulatorBase.cpp +++ b/xmsextractor/ugrid/XmUGridTriangulatorBase.cpp @@ -317,14 +317,9 @@ bool XmUGridTriangulatorBase::GenerateCentroidTriangles(int a_cellIdx, Pt3d centroid = gmComputeCentroid(polygon); // make sure the centroid is located inside the cell - for (size_t pointIdx = 0; pointIdx < polygon.size(); ++pointIdx) + if (gmPointInPolygon2D(polygon, centroid) != 1) { - const Pt3d& pt1 = polygon[pointIdx]; - const Pt3d& pt2 = polygon[(pointIdx + 1) % numPoints]; - - // centroid should be to the left of each edge - if (gmTurn(pt1, pt2, centroid, 0.0) != TURN_LEFT) - return false; + return false; } // add centroid to list of points