Source: netgen
Followup-For: Bug #1071223
Control: tags -1 ftbfs patch

Attached a patch that makes netgen compile.

Taken from upstream, see forwarded information.


--
tobi




-- System Information:
Debian Release: trixie/sid
  APT prefers oldstable-updates
  APT policy: (500, 'oldstable-updates'), (500, 'oldstable-security'), (500, 
'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 6.7.12-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=de_DE.UTF-8, LC_CTYPE=de_DE.UTF-8 (charmap=UTF-8), 
LANGUAGE=en_US:en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Description: Fix for FTBFS with opencascade 7.8.1
 Taken from upstream, with addtional bits (linkage) from the upstream bug.
 and one addtional include removed.
Bug: https://github.com/NGSolve/netgen/issues/170
Origin: 
https://github.com/NGSolve/netgen/commit/486c7d9bcb950dfb33c2a59b68eca3e720af4107
>From 6b89d2cf6203272d04d2738f145bc01b49d75186 Mon Sep 17 00:00:00 2001
From: "Hochsteger, Matthias" <mhochste...@cerbsim.com>
Date: Wed, 6 Mar 2024 16:29:11 +0100
Subject: [PATCH] Compatibility with Opencascade 7.8

---
 libsrc/meshing/basegeom.cpp | 13 +++++++------
 libsrc/meshing/basegeom.hpp |  8 --------
 libsrc/occ/occ_edge.cpp     |  5 -----
 libsrc/occ/occ_edge.hpp     |  1 -
 libsrc/occ/occ_face.cpp     |  5 -----
 libsrc/occ/occ_face.hpp     |  1 -
 libsrc/occ/occ_solid.hpp    |  2 --
 libsrc/occ/occ_vertex.cpp   |  5 -----
 libsrc/occ/occ_vertex.hpp   |  1 -
 libsrc/occ/occgeom.cpp      |  7 -------
 10 files changed, 7 insertions(+), 41 deletions(-)
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -377,25 +377,20 @@
       TKGeomAlgo
       TKGeomBase
       TKHLR
-      TKIGES
       TKLCAF
       TKMath
       TKMesh
       TKOffset
       TKPrim
-      TKSTEP
-      TKSTEP209
-      TKSTEPAttr
-      TKSTEPBase
-      TKSTL
+      TKDESTL
       TKService
       TKShHealing
       TKTopAlgo
       TKV3d
       TKVCAF
       TKXCAF
-      TKXDEIGES
-      TKXDESTEP
+      TKDEIGES
+      TKDESTEP
       TKXSBase
       TKernel
     )
--- a/libsrc/meshing/basegeom.cpp
+++ b/libsrc/meshing/basegeom.cpp
@@ -568,12 +568,13 @@
 
     auto & identifications = mesh.GetIdentifications();
 
-    std::map<size_t, PointIndex> vert2meshpt;
+    Array<PointIndex> vert2meshpt(vertices.Size());
+    vert2meshpt = PointIndex::INVALID;
     for(auto & vert : vertices)
       {
         auto pi = mesh.AddPoint(vert->GetPoint(), vert->properties.layer);
         tree.Insert(mesh[pi], pi);
-        vert2meshpt[vert->GetHash()] = pi;
+        vert2meshpt[vert->nr] = pi;
         mesh[pi].Singularity(vert->properties.hpref);
         mesh[pi].SetType(FIXEDPOINT);
 
@@ -585,8 +586,8 @@
 
     for(auto & vert : vertices)
         for(auto & ident : vert->identifications)
-            identifications.Add(vert2meshpt[ident.from->GetHash()],
-                                vert2meshpt[ident.to->GetHash()],
+            identifications.Add(vert2meshpt[ident.from->nr],
+                                vert2meshpt[ident.to->nr],
                                 ident.name,
                                 ident.type);
 
@@ -600,8 +601,8 @@
         auto edge = edges[edgenr].get();
         PointIndex startp, endp;
         // throws if points are not found
-        startp = vert2meshpt.at(edge->GetStartVertex().GetHash());
-        endp = vert2meshpt.at(edge->GetEndVertex().GetHash());
+        startp = vert2meshpt[edge->GetStartVertex().nr];
+        endp = vert2meshpt[edge->GetEndVertex().nr];
 
         // ignore collapsed edges
         if(startp == endp && edge->GetLength() < 1e-10 * bounding_box.Diam())
--- a/libsrc/meshing/basegeom.hpp
+++ b/libsrc/meshing/basegeom.hpp
@@ -68,7 +68,6 @@
     Transformation<3> primary_to_me;
 
     virtual ~GeometryShape() {}
-    virtual size_t GetHash() const = 0;
     virtual bool IsMappedShape( const GeometryShape & other, const 
Transformation<3> & trafo, double tolerance ) const;
   };
 
@@ -320,13 +319,6 @@
       throw Exception("Base geometry get tangent called");
     }
 
-    virtual size_t GetEdgeIndex(const GeometryEdge& edge) const
-    {
-      for(auto i : Range(edges))
-        if(edge.GetHash() == edges[i]->GetHash())
-          return i;
-      throw Exception("Couldn't find edge index");
-    }
     virtual void Save (const filesystem::path & filename) const;
     virtual void SaveToMeshFile (ostream & /* ost */) const { ; }
   };
--- a/libsrc/occ/occ_edge.cpp
+++ b/libsrc/occ/occ_edge.cpp
@@ -53,11 +53,6 @@
         throw Exception(ToString("not implemented") + __FILE__ + ":" + 
ToString(__LINE__));
     }
 
-    size_t OCCEdge::GetHash() const
-    {
-      return edge.HashCode(std::numeric_limits<Standard_Integer>::max());
-    }
-
     void OCCEdge::ProjectPoint(Point<3>& p, EdgePointGeomInfo* gi) const
     {
         auto pnt = ng2occ(p);
--- a/libsrc/occ/occ_edge.hpp
+++ b/libsrc/occ/occ_edge.hpp
@@ -36,7 +36,6 @@
         Point<3> GetCenter() const override;
         Point<3> GetPoint(double t) const override;
         double CalcStep(double t, double sag) const override;
-        size_t GetHash() const override;
         void ProjectPoint(Point<3>& p, EdgePointGeomInfo* gi) const override;
         Vec<3> GetTangent(double t) const override;
         bool IsDegenerated(double) const override {
--- a/libsrc/occ/occ_face.cpp
+++ b/libsrc/occ/occ_face.cpp
@@ -30,11 +30,6 @@
         return 0;
     }
 
-    size_t OCCFace::GetHash() const
-    {
-      return face.HashCode(std::numeric_limits<Standard_Integer>::max());
-    }
-
     Point<3> OCCFace::GetCenter() const
     {
         return occ2ng( props.CentreOfMass() );
--- a/libsrc/occ/occ_face.hpp
+++ b/libsrc/occ/occ_face.hpp
@@ -31,7 +31,6 @@
 
         const TopoDS_Face Shape() const { return face; }
 
-        size_t GetHash() const override;
         Point<3> GetCenter() const override;
         virtual size_t GetNBoundaries() const override;
         virtual Array<Segment> GetBoundary(const Mesh& mesh) const override;
--- a/libsrc/occ/occ_solid.hpp
+++ b/libsrc/occ/occ_solid.hpp
@@ -16,8 +16,6 @@
         OCCSolid(TopoDS_Shape dshape)
             : solid(TopoDS::Solid(dshape))
         { }
-
-        size_t GetHash() const override { return 
solid.HashCode(std::numeric_limits<Standard_Integer>::max()); }
     };
 }
 
--- a/libsrc/occ/occ_vertex.cpp
+++ b/libsrc/occ/occ_vertex.cpp
@@ -16,9 +16,4 @@
     {
         return p;
     }
-
-    size_t OCCVertex::GetHash() const
-    {
-      return vertex.HashCode(std::numeric_limits<Standard_Integer>::max());
-    }
 }
--- a/libsrc/occ/occ_vertex.hpp
+++ b/libsrc/occ/occ_vertex.hpp
@@ -24,7 +24,6 @@
         OCCVertex( TopoDS_Shape s );
         ~OCCVertex() {}
         Point<3> GetPoint() const override;
-        size_t GetHash() const override;
     };
 }
 
--- a/libsrc/occ/occgeom.cpp
+++ b/libsrc/occ/occgeom.cpp
@@ -1714,13 +1714,6 @@
         BRepTools::Read(shape, ss, builder);
       }
 
-    /*
-    // enumerate shapes and archive only integers
-    auto my_hash = [](const TopoDS_Shape & key) {
-        auto occ_hash = key.HashCode(1<<31UL);
-        return std::hash<decltype(occ_hash)>()(occ_hash);
-    };
-    */
     TopTools_IndexedMapOfShape shape_map;
     Array<TopoDS_Shape> shape_list;
 
--- a/libsrc/occ/Partition_Loop3d.hxx
+++ b/libsrc/occ/Partition_Loop3d.hxx
@@ -29,7 +29,7 @@
 #if OCC_VERSION_HEX < 0x070000
 #else
    #include <TopTools_ShapeMapHasher.hxx>
-   #include <TopTools_OrientedShapeMapHasher.hxx>
+   //#include <TopTools_OrientedShapeMapHasher.hxx>
    #include <TopTools_MapOfOrientedShape.hxx>
 #endif
 

Reply via email to