Porting to OCCT 7.8.0

This commit is contained in:
jfa 2024-01-15 13:40:33 +00:00
parent d2955ae6fb
commit 50d7a465b6
11 changed files with 165 additions and 25 deletions

View File

@ -3353,7 +3353,7 @@ void CoplanarFaces::SetMesh( const SMDS_Mesh* theMesh )
return; return;
const double cosTol = Cos( myToler * M_PI / 180. ); const double cosTol = Cos( myToler * M_PI / 180. );
NCollection_Map< SMESH_TLink, SMESH_TLink > checkedLinks; NCollection_Map< SMESH_TLink, SMESH_TLinkHasher > checkedLinks;
std::list< std::pair< const SMDS_MeshElement*, gp_Vec > > faceQueue; std::list< std::pair< const SMDS_MeshElement*, gp_Vec > > faceQueue;
faceQueue.push_back( std::make_pair( face, myNorm )); faceQueue.push_back( std::make_pair( face, myNorm ));

View File

@ -23,6 +23,7 @@
#include "DriverSTL_R_SMDS_Mesh.h" #include "DriverSTL_R_SMDS_Mesh.h"
#include <Basics_Utils.hxx> #include <Basics_Utils.hxx>
#include <Basics_OCCTVersion.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
#include <NCollection_DataMap.hxx> #include <NCollection_DataMap.hxx>
@ -41,8 +42,12 @@ namespace
//function : HashCode //function : HashCode
//purpose : //purpose :
//======================================================================= //=======================================================================
#if OCC_VERSION_LARGE < 0x07080000
inline static Standard_Integer HashCode inline static Standard_Integer HashCode
(const gp_Pnt& point, Standard_Integer Upper) (const gp_Pnt& point, Standard_Integer Upper)
#else
size_t operator()(const gp_Pnt& point) const
#endif
{ {
union union
{ {
@ -52,14 +57,22 @@ namespace
point.Coord( U.R[0], U.R[1], U.R[2] ); point.Coord( U.R[0], U.R[1], U.R[2] );
#if OCC_VERSION_LARGE < 0x07080000
return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper); return ::HashCode(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7,Upper);
#else
return static_cast<size_t>(U.I[0]/23+U.I[1]/19+U.I[2]/17+U.I[3]/13+U.I[4]/11+U.I[5]/7);
#endif
} }
//======================================================================= //=======================================================================
//function : IsEqual //function : IsEqual
//purpose : //purpose :
//======================================================================= //=======================================================================
#if OCC_VERSION_LARGE < 0x07080000
inline static Standard_Boolean IsEqual inline static Standard_Boolean IsEqual
(const gp_Pnt& point1, const gp_Pnt& point2) (const gp_Pnt& point1, const gp_Pnt& point2)
#else
bool operator()(const gp_Pnt& point1, const gp_Pnt& point2) const
#endif
{ {
static Standard_Real tab1[3], tab2[3]; static Standard_Real tab1[3], tab2[3];
point1.Coord(tab1[0],tab1[1],tab1[2]); point1.Coord(tab1[0],tab1[1],tab1[2]);

View File

@ -101,6 +101,7 @@
#include "SMESH_TryCatch.hxx" // include after OCCT headers! #include "SMESH_TryCatch.hxx" // include after OCCT headers!
#include <smIdType.hxx> #include <smIdType.hxx>
#include <Basics_OCCTVersion.hxx>
#define cast2Node(elem) static_cast<const SMDS_MeshNode*>( elem ) #define cast2Node(elem) static_cast<const SMDS_MeshNode*>( elem )
@ -1505,7 +1506,7 @@ int SMESH_MeshEditor::Reorient2D( TIDSortedElemSet & theFaces,
vector< const SMDS_MeshElement* > facesNearLink; vector< const SMDS_MeshElement* > facesNearLink;
vector< std::pair< int, int > > nodeIndsOfFace; vector< std::pair< int, int > > nodeIndsOfFace;
TIDSortedElemSet avoidSet, emptySet; TIDSortedElemSet avoidSet, emptySet;
NCollection_Map< SMESH_TLink, SMESH_TLink > checkedLinks; NCollection_Map< SMESH_TLink, SMESH_TLinkHasher > checkedLinks;
while ( !theRefFaces.empty() ) while ( !theRefFaces.empty() )
{ {
@ -7789,6 +7790,8 @@ bool SMESH_MeshEditor::applyMerge( const SMDS_MeshElement* elem,
// purpose : allow comparing elements basing on their nodes // purpose : allow comparing elements basing on their nodes
// ======================================================== // ========================================================
struct ComparableElementHasher;
class ComparableElement : public boost::container::flat_set< smIdType > class ComparableElement : public boost::container::flat_set< smIdType >
{ {
typedef boost::container::flat_set< smIdType > int_set; typedef boost::container::flat_set< smIdType > int_set;
@ -7797,6 +7800,8 @@ class ComparableElement : public boost::container::flat_set< smIdType >
smIdType mySumID; smIdType mySumID;
mutable int myGroupID; mutable int myGroupID;
friend ComparableElementHasher;
public: public:
ComparableElement( const SMDS_MeshElement* theElem ): ComparableElement( const SMDS_MeshElement* theElem ):
@ -7825,7 +7830,11 @@ public:
mySumID = src.mySumID; mySumID = src.mySumID;
myGroupID = src.myGroupID; myGroupID = src.myGroupID;
} }
};
struct ComparableElementHasher
{
#if OCC_VERSION_LARGE < 0x07080000
static int HashCode(const ComparableElement& se, int limit ) static int HashCode(const ComparableElement& se, int limit )
{ {
return ::HashCode( FromSmIdType<int>(se.mySumID), limit ); return ::HashCode( FromSmIdType<int>(se.mySumID), limit );
@ -7834,7 +7843,17 @@ public:
{ {
return ( se1 == se2 ); return ( se1 == se2 );
} }
#else
size_t operator()(const ComparableElement& se) const
{
return static_cast<size_t>(FromSmIdType<int>(se.mySumID));
}
bool operator()(const ComparableElement& se1, const ComparableElement& se2) const
{
return ( se1 == se2 );
}
#endif
}; };
//======================================================================= //=======================================================================
@ -7852,7 +7871,7 @@ void SMESH_MeshEditor::FindEqualElements( TIDSortedElemSet & theElements,
if ( theElements.empty() ) elemIt = GetMeshDS()->elementsIterator(); if ( theElements.empty() ) elemIt = GetMeshDS()->elementsIterator();
else elemIt = SMESHUtils::elemSetIterator( theElements ); else elemIt = SMESHUtils::elemSetIterator( theElements );
typedef NCollection_Map< ComparableElement, ComparableElement > TMapOfElements; typedef NCollection_Map< ComparableElement, ComparableElementHasher > TMapOfElements;
typedef std::list<smIdType> TGroupOfElems; typedef std::list<smIdType> TGroupOfElems;
TMapOfElements mapOfElements; TMapOfElements mapOfElements;
std::vector< TGroupOfElems > arrayOfGroups; std::vector< TGroupOfElems > arrayOfGroups;

View File

@ -67,7 +67,6 @@ SET(SMESHDS_HEADERS
SMESHDS_GroupOnGeom.hxx SMESHDS_GroupOnGeom.hxx
SMESHDS_GroupOnFilter.hxx SMESHDS_GroupOnFilter.hxx
SMESH_SMESHDS.hxx SMESH_SMESHDS.hxx
SMESHDS_DataMapOfShape.hxx
SMESH_Controls.hxx SMESH_Controls.hxx
) )

View File

@ -32,6 +32,8 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include "SMESHDS_SubMesh.hxx" #include "SMESHDS_SubMesh.hxx"
#include <Basics_OCCTVersion.hxx>
#include <TopTools_IndexedMapOfShape.hxx> #include <TopTools_IndexedMapOfShape.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
@ -57,10 +59,31 @@ class SMDS_BallElement;
* So this functionality implement on new NCollection_DataMap technology * So this functionality implement on new NCollection_DataMap technology
*/ */
#include <NCollection_DataMap.hxx> #include <NCollection_DataMap.hxx>
#include "SMESHDS_DataMapOfShape.hxx"
typedef std::list<const SMESHDS_Hypothesis*> THypList; typedef std::list<const SMESHDS_Hypothesis*> THypList;
#if OCC_VERSION_LARGE < 0x07080000
struct SMESHDS_Hasher
{
static inline Standard_Boolean IsEqual(const TopoDS_Shape& S1,
const TopoDS_Shape& S2)
{
return S1.IsSame(S2);
}
static inline Standard_Integer HashCode(const TopoDS_Shape& S,
const Standard_Integer Upper)
{
return ::HashCode( S, Upper);
}
};
typedef NCollection_DataMap< TopoDS_Shape, THypList, SMESHDS_Hasher > ShapeToHypothesis; typedef NCollection_DataMap< TopoDS_Shape, THypList, SMESHDS_Hasher > ShapeToHypothesis;
#else
typedef NCollection_DataMap< TopoDS_Shape, THypList > ShapeToHypothesis;
#endif
class SMESHDS_GroupBase; class SMESHDS_GroupBase;
class DownIdType; class DownIdType;

View File

@ -22,7 +22,23 @@
// File : SMESHGUI.cxx // File : SMESHGUI.cxx
// Author : Nicolas REJNERI, Open CASCADE S.A.S. // Author : Nicolas REJNERI, Open CASCADE S.A.S.
#include <Basics_OCCTVersion.hxx>
#if OCC_VERSION_LARGE < 0x07080000
#include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows #include <Standard_math.hxx> // E.A. must be included before Python.h to fix compilation on windows
#else
#ifdef _MSC_VER
#ifndef _USE_MATH_DEFINES
#define _USE_MATH_DEFINES
#endif
#include <math.h>
#endif
#endif
#ifdef HAVE_FINITE #ifdef HAVE_FINITE
#undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined
#endif #endif

View File

@ -444,7 +444,7 @@ void SMESH_MeshAlgos::FindCoincidentFreeBorders(SMDS_Mesh& mesh,
CoincidentFreeBorders & foundFreeBordes) CoincidentFreeBorders & foundFreeBordes)
{ {
// find free links // find free links
typedef NCollection_DataMap<SMESH_TLink, const SMDS_MeshElement*, SMESH_TLink > TLink2FaceMap; typedef NCollection_DataMap<SMESH_TLink, const SMDS_MeshElement*, SMESH_TLinkHasher > TLink2FaceMap;
TLink2FaceMap linkMap; TLink2FaceMap linkMap;
int nbSharedLinks = 0; int nbSharedLinks = 0;
SMDS_FaceIteratorPtr faceIt = mesh.facesIterator(); SMDS_FaceIteratorPtr faceIt = mesh.facesIterator();
@ -840,7 +840,7 @@ void SMESH_MeshAlgos::FindFreeBorders(SMDS_Mesh& theMesh,
bool isManifold = true; bool isManifold = true;
// find free links // find free links
typedef NCollection_DataMap<SMESH_TLink, const SMDS_MeshElement*, SMESH_TLink > TLink2FaceMap; typedef NCollection_DataMap<SMESH_TLink, const SMDS_MeshElement*, SMESH_TLinkHasher > TLink2FaceMap;
TLink2FaceMap linkMap; TLink2FaceMap linkMap;
int nbSharedLinks = 0; int nbSharedLinks = 0;
SMDS_FaceIteratorPtr faceIt = theMesh.facesIterator(); SMDS_FaceIteratorPtr faceIt = theMesh.facesIterator();

View File

@ -1990,7 +1990,7 @@ SMESH_MeshAlgos::FindSharpEdges( SMDS_Mesh* theMesh,
if ( !theMesh ) return resultEdges; if ( !theMesh ) return resultEdges;
typedef std::pair< bool, const SMDS_MeshNode* > TIsSharpAndMedium; typedef std::pair< bool, const SMDS_MeshNode* > TIsSharpAndMedium;
typedef NCollection_DataMap< SMESH_TLink, TIsSharpAndMedium, SMESH_TLink > TLinkSharpMap; typedef NCollection_DataMap< SMESH_TLink, TIsSharpAndMedium, SMESH_TLinkHasher > TLinkSharpMap;
TLinkSharpMap linkIsSharp; TLinkSharpMap linkIsSharp;
Standard_Integer nbBuckets = FromSmIdType<Standard_Integer>( theMesh->NbFaces() ); Standard_Integer nbBuckets = FromSmIdType<Standard_Integer>( theMesh->NbFaces() );
@ -2102,7 +2102,7 @@ SMESH_MeshAlgos::SeparateFacesByEdges( SMDS_Mesh* theMesh, const std::vector< Ed
// build map of face edges (SMESH_TLink) and their faces // build map of face edges (SMESH_TLink) and their faces
typedef std::vector< const SMDS_MeshElement* > TFaceVec; typedef std::vector< const SMDS_MeshElement* > TFaceVec;
typedef NCollection_DataMap< SMESH_TLink, TFaceVec, SMESH_TLink > TFacesByLinks; typedef NCollection_DataMap< SMESH_TLink, TFaceVec, SMESH_TLinkHasher > TFacesByLinks;
TFacesByLinks facesByLink; TFacesByLinks facesByLink;
Standard_Integer nbBuckets = FromSmIdType<Standard_Integer>( theMesh->NbFaces() ); Standard_Integer nbBuckets = FromSmIdType<Standard_Integer>( theMesh->NbFaces() );
if ( nbBuckets > 0 ) if ( nbBuckets > 0 )
@ -2270,7 +2270,7 @@ std::vector< const SMDS_MeshNode*> SMESH_MeshAlgos::GetCommonNodes(const SMDS_Me
bool SMESH_MeshAlgos::IsOn2DBoundary( const SMDS_MeshNode* theNode, bool SMESH_MeshAlgos::IsOn2DBoundary( const SMDS_MeshNode* theNode,
std::vector< const SMDS_MeshNode*> * theNeibors ) std::vector< const SMDS_MeshNode*> * theNeibors )
{ {
typedef NCollection_DataMap< SMESH_TLink, int, SMESH_TLink > TLinkCountMap; typedef NCollection_DataMap< SMESH_TLink, int, SMESH_TLinkHasher > TLinkCountMap;
TLinkCountMap linkCountMap( 10 ); TLinkCountMap linkCountMap( 10 );
int nbFreeLinks = 0; int nbFreeLinks = 0;

View File

@ -29,6 +29,7 @@
#include "SMDS_Mesh.hxx" #include "SMDS_Mesh.hxx"
#include <Utils_SALOME_Exception.hxx> #include <Utils_SALOME_Exception.hxx>
#include <Basics_OCCTVersion.hxx>
#include <Bnd_B3d.hxx> #include <Bnd_B3d.hxx>
#include <NCollection_Map.hxx> #include <NCollection_Map.hxx>
@ -43,7 +44,7 @@ namespace
const int theMaxNbFaces = 256; // max number of faces sharing a node const int theMaxNbFaces = 256; // max number of faces sharing a node
typedef NCollection_DataMap< const SMDS_MeshNode*, const SMDS_MeshNode*, SMESH_Hasher > TNNMap; typedef NCollection_DataMap< const SMDS_MeshNode*, const SMDS_MeshNode*, SMESH_Hasher > TNNMap;
typedef NCollection_Map< SMESH_Link, SMESH_Link > TLinkMap; typedef NCollection_Map< SMESH_Link, SMESH_TLinkHasher > TLinkMap;
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/*! /*!
@ -75,7 +76,11 @@ namespace
const SMDS_MeshNode* IntNode() const { return myIntNode.Node(); } const SMDS_MeshNode* IntNode() const { return myIntNode.Node(); }
const SMDS_MeshNode* Node1() const { return myNode[ myReverse ]; } const SMDS_MeshNode* Node1() const { return myNode[ myReverse ]; }
const SMDS_MeshNode* Node2() const { return myNode[ !myReverse ]; } const SMDS_MeshNode* Node2() const { return myNode[ !myReverse ]; }
};
struct CutLinkHasher
{
#if OCC_VERSION_LARGE < 0x07080000
static Standard_Integer HashCode(const CutLink& link, static Standard_Integer HashCode(const CutLink& link,
const Standard_Integer upper) const Standard_Integer upper)
{ {
@ -90,9 +95,23 @@ namespace
link1.myNode[1] == link2.myNode[1] && link1.myNode[1] == link2.myNode[1] &&
link1.myIndex == link2.myIndex ); link1.myIndex == link2.myIndex );
} }
#else
size_t operator()(const CutLink& link) const
{
return size_t( link.myNode[0]->GetID() +
link.myNode[1]->GetID() +
link.myIndex );
}
bool operator()(const CutLink& link1, const CutLink& link2 ) const
{
return ( link1.myNode[0] == link2.myNode[0] &&
link1.myNode[1] == link2.myNode[1] &&
link1.myIndex == link2.myIndex );
}
#endif
}; };
typedef NCollection_Map< CutLink, CutLink > TCutLinkMap; typedef NCollection_Map< CutLink, CutLinkHasher > TCutLinkMap;
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/*! /*!
@ -274,7 +293,16 @@ namespace
TLinkMap& theCutOffCoplanarLinks) const; TLinkMap& theCutOffCoplanarLinks) const;
void InitLinks() const; void InitLinks() const;
bool IsCoplanar( const EdgePart* edge ) const; bool IsCoplanar( const EdgePart* edge ) const;
void Dump() const;
private:
EdgePart* getTwin( const EdgePart* edge ) const;
};
struct CutFaceHasher
{
#if OCC_VERSION_LARGE < 0x07080000
static Standard_Integer HashCode(const CutFace& f, const Standard_Integer upper) static Standard_Integer HashCode(const CutFace& f, const Standard_Integer upper)
{ {
return ::HashCode( FromSmIdType<int>(f.myInitFace->GetID()), upper ); return ::HashCode( FromSmIdType<int>(f.myInitFace->GetID()), upper );
@ -283,14 +311,20 @@ namespace
{ {
return f1.myInitFace == f2.myInitFace; return f1.myInitFace == f2.myInitFace;
} }
void Dump() const; #else
size_t operator()(const CutFace& f) const
{
return FromSmIdType<int>(f.myInitFace->GetID());
}
private: bool operator()(const CutFace& f1, const CutFace& f2) const
{
EdgePart* getTwin( const EdgePart* edge ) const; return f1.myInitFace == f2.myInitFace;
}
#endif
}; };
typedef NCollection_Map< CutFace, CutFace > TCutFaceMap; typedef NCollection_Map< CutFace, CutFaceHasher > TCutFaceMap;
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
/*! /*!

View File

@ -27,6 +27,8 @@
#ifndef __SMESH_TypeDefs_HXX__ #ifndef __SMESH_TypeDefs_HXX__
#define __SMESH_TypeDefs_HXX__ #define __SMESH_TypeDefs_HXX__
#include <Basics_OCCTVersion.hxx>
#include "SMESH_Utils.hxx" #include "SMESH_Utils.hxx"
#include "SMDS_SetIterator.hxx" #include "SMDS_SetIterator.hxx"
@ -36,6 +38,7 @@
#include <gp_XYZ.hxx> #include <gp_XYZ.hxx>
#include <gp_XY.hxx> #include <gp_XY.hxx>
#include <NCollection_Sequence.hxx>
#include <map> #include <map>
#include <list> #include <list>
@ -156,6 +159,19 @@ struct SMESH_TLink: public NLink
const SMDS_MeshNode* node2() const { return second; } const SMDS_MeshNode* node2() const { return second; }
// methods for usage of SMESH_TLink as a hasher in NCollection maps // methods for usage of SMESH_TLink as a hasher in NCollection maps
//static int HashCode(const SMESH_TLink& link, int aLimit)
//{
// return smIdHasher::HashCode( link.node1()->GetID() + link.node2()->GetID(), aLimit );
//}
//static Standard_Boolean IsEqual(const SMESH_TLink& l1, const SMESH_TLink& l2)
//{
// return ( l1.node1() == l2.node1() && l1.node2() == l2.node2() );
//}
};
// a hasher in NCollection maps
struct SMESH_TLinkHasher
{
#if OCC_VERSION_LARGE < 0x07080000
static int HashCode(const SMESH_TLink& link, int aLimit) static int HashCode(const SMESH_TLink& link, int aLimit)
{ {
return smIdHasher::HashCode( link.node1()->GetID() + link.node2()->GetID(), aLimit ); return smIdHasher::HashCode( link.node1()->GetID() + link.node2()->GetID(), aLimit );
@ -164,6 +180,16 @@ struct SMESH_TLink: public NLink
{ {
return ( l1.node1() == l2.node1() && l1.node2() == l2.node2() ); return ( l1.node1() == l2.node1() && l1.node2() == l2.node2() );
} }
#else
size_t operator()(const SMESH_TLink& link) const
{
return smIdHasher()( link.node1()->GetID() + link.node2()->GetID() );
}
bool operator()(const SMESH_TLink& l1, const SMESH_TLink& l2) const
{
return ( l1.node1() == l2.node1() && l1.node2() == l2.node2() );
}
#endif
}; };
typedef SMESH_TLink SMESH_Link; typedef SMESH_TLink SMESH_Link;
@ -218,6 +244,7 @@ typedef SMESH_TNodeXYZ SMESH_NodeXYZ;
struct SMESH_Hasher struct SMESH_Hasher
{ {
#if OCC_VERSION_LARGE < 0x07080000
static Standard_Integer HashCode(const SMDS_MeshElement* e, const Standard_Integer upper) static Standard_Integer HashCode(const SMDS_MeshElement* e, const Standard_Integer upper)
{ {
return smIdHasher::HashCode( e->GetID(), upper ); return smIdHasher::HashCode( e->GetID(), upper );
@ -226,6 +253,17 @@ struct SMESH_Hasher
{ {
return ( e1 == e2 ); return ( e1 == e2 );
} }
#else
size_t operator()(const SMDS_MeshElement* e) const
{
return smIdHasher()( e->GetID() );
}
bool operator()(const SMDS_MeshElement* e1, const SMDS_MeshElement* e2) const
{
return ( e1 == e2 );
}
#endif
}; };
//-------------------------------------------------- //--------------------------------------------------
@ -262,10 +300,8 @@ typedef std::vector< const SMDS_MeshElement* > SMESH_SequenceOfElemPtr;
// -------------------------------------------------------------------------------- // --------------------------------------------------------------------------------
// class SMESH_SequenceOfNode // class SMESH_SequenceOfNode
#include <NCollection_DefineSequence.hxx>
typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
DEFINE_SEQUENCE(SMESH_SequenceOfNode, typedef const SMDS_MeshNode* SMDS_MeshNodePtr;
SMESH_BaseCollectionNodePtr, SMDS_MeshNodePtr) typedef NCollection_Sequence< SMDS_MeshNodePtr > SMESH_SequenceOfNode;
#endif #endif

View File

@ -49,7 +49,7 @@
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <GeomAPI_ProjectPointOnSurf.hxx> #include <GeomAPI_ProjectPointOnSurf.hxx>
#include <Geom_Surface.hxx> #include <Geom_Surface.hxx>
#include <NCollection_DefineArray2.hxx> #include <NCollection_Array2.hxx>
#include <Precision.hxx> #include <Precision.hxx>
#include <ShapeAnalysis.hxx> #include <ShapeAnalysis.hxx>
#include <TColStd_SequenceOfInteger.hxx> #include <TColStd_SequenceOfInteger.hxx>