From 2acf50a454779067a19be8caeae3cc7c4d3b84fa Mon Sep 17 00:00:00 2001
From: Boris Basic <boris.basic@edf.fr>
Date: Wed, 29 Jan 2025 13:58:09 +0100
Subject: [PATCH] [fix #1081] extract_contour.extract_boundaries: ensure 64-bit
 integers are used

This fixes a bug on Windows that caused the contour of some meshes to be
extracted incorrectly.
---
 NEWS.txt                                  | 3 +++
 scripts/python3/pretel/extract_contour.py | 6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/NEWS.txt b/NEWS.txt
index eed12d2bb1..a7de360296 100644
--- a/NEWS.txt
+++ b/NEWS.txt
@@ -1,6 +1,9 @@
 Latest changes
 ==============
 
+Python: fix a bug with extract_contour on Windows occurring with some meshes
+and resulting in incorrect contour extraction.
+
 TELEMAC-2D/TELEMAC-3D/TOMAWAC/GAIA: fix time series exports for global models
 
 MASCARET: New keyword VARIABLES PRECISION 
diff --git a/scripts/python3/pretel/extract_contour.py b/scripts/python3/pretel/extract_contour.py
index 67d68553aa..a298cfb32a 100644
--- a/scripts/python3/pretel/extract_contour.py
+++ b/scripts/python3/pretel/extract_contour.py
@@ -1,6 +1,6 @@
 """ Functions to extract the contour of a mesh """
 
-from collections import defaultdict, OrderedDict
+from collections import OrderedDict, defaultdict
 
 import numpy as np
 from matplotlib.path import Path
@@ -80,9 +80,9 @@ def extract_boundaries(triangles):
             [triangles[:, [0, 1]], triangles[:, [0, 2]], triangles[:, [1, 2]]]
         ),
         axis=1
-    ).astype(int)
+    ).astype(np.int64)
 
-    # Use the Cantor pairing function to creeate edge IDs
+    # Use the Cantor pairing function to create edge IDs
     k1, k2 = edges[:, 0], edges[:, 1]
     edge_ids = (k1 + k2) * (k1 + k2 + 1) // 2 + k2
 
-- 
GitLab