From 88aeae3f48e68ad11123241c1ed88eb7a8a8189c Mon Sep 17 00:00:00 2001
From: Thomas Fischer <thomas.fischer@ufz.de>
Date: Mon, 23 May 2016 15:03:37 +0200
Subject: [PATCH] [FileIO] Check if line segment is already contained.

The check prevents to insert a line that is already a part of the node polygon.
---
 FileIO/GmshIO/GMSHPolygonTree.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/FileIO/GmshIO/GMSHPolygonTree.cpp b/FileIO/GmshIO/GMSHPolygonTree.cpp
index bca94645e9d..be35d891e14 100644
--- a/FileIO/GmshIO/GMSHPolygonTree.cpp
+++ b/FileIO/GmshIO/GMSHPolygonTree.cpp
@@ -311,7 +311,7 @@ void GMSHPolygonTree::writeLineConstraints(std::size_t& line_offset,
                                            std::size_t sfc_number,
                                            std::ostream& out) const
 {
-    for (auto polyline : *_plys)
+    for (auto polyline : _plys)
     {
         const std::size_t n_pnts(polyline->getNumberOfPoints());
         std::size_t first_pnt_id(polyline->getPointID(0)), second_pnt_id;
@@ -319,7 +319,8 @@ void GMSHPolygonTree::writeLineConstraints(std::size_t& line_offset,
         {
             second_pnt_id = polyline->getPointID(k);
             if (polyline->isSegmentMarked(k - 1) &&
-                _node_polygon->isPntInPolygon(*(polyline->getPoint(k))))
+                _node_polygon->isPntInPolygon(*(polyline->getPoint(k))) &&
+                !GeoLib::containsEdge(*_node_polygon, first_pnt_id, second_pnt_id))
             {
                 out << "Line(" << line_offset + k - 1 << ") = {" << first_pnt_id
                     << "," << second_pnt_id << "};\n";
-- 
GitLab