From 0eea513c934f0925f9b9ec6cc56892feafc04c0d Mon Sep 17 00:00:00 2001 From: jfa Date: Mon, 15 Jan 2024 13:40:33 +0000 Subject: [PATCH] Porting to OCCT 7.8.0 --- src/Controls/SMESH_Controls.cxx | 2 +- src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx | 13 ++++++ src/SMESH/SMESH_MeshEditor.cxx | 25 +++++++++-- src/SMESH/SMESH_MesherHelper.cxx | 14 +++++- src/SMESHDS/CMakeLists.txt | 1 - src/SMESHDS/SMESHDS_Mesh.hxx | 30 ++++++++++++- src/SMESHGUI/SMESHGUI.cxx | 16 +++++++ src/SMESHUtils/SMESH_FreeBorders.cxx | 4 +- src/SMESHUtils/SMESH_MeshAlgos.cxx | 10 ++--- src/SMESHUtils/SMESH_Offset.cxx | 48 ++++++++++++++++++--- src/SMESHUtils/SMESH_TypeDefs.hxx | 44 +++++++++++++++++-- src/StdMeshers/StdMeshers_Quadrangle_2D.cxx | 2 +- src/Tools/blocFissure/gmu/fissureCoude.py | 5 ++- test/ex_MakePolyLine.py | 13 +++++- test/netgen_runner_2D.py | 4 +- 15 files changed, 200 insertions(+), 31 deletions(-) diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 578557775..55d5c19a8 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -3445,7 +3445,7 @@ void CoplanarFaces::SetMesh( const SMDS_Mesh* theMesh ) return; 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; faceQueue.push_back( std::make_pair( face, myNorm )); diff --git a/src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx b/src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx index c838ec806..c2fd53597 100644 --- a/src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx +++ b/src/DriverSTL/DriverSTL_R_SMDS_Mesh.cxx @@ -23,6 +23,7 @@ #include "DriverSTL_R_SMDS_Mesh.h" #include +#include #include #include @@ -41,8 +42,12 @@ namespace //function : HashCode //purpose : //======================================================================= +#if OCC_VERSION_LARGE < 0x07080000 inline static Standard_Integer HashCode (const gp_Pnt& point, Standard_Integer Upper) +#else + size_t operator()(const gp_Pnt& point) const +#endif { union { @@ -52,14 +57,22 @@ namespace 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); +#else + return static_cast(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 //purpose : //======================================================================= +#if OCC_VERSION_LARGE < 0x07080000 inline static Standard_Boolean IsEqual (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]; point1.Coord(tab1[0],tab1[1],tab1[2]); diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 8c940322e..125bbaa2e 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -103,6 +103,7 @@ #include "SMESH_TryCatch.hxx" // include after OCCT headers! #include +#include #define cast2Node(elem) static_cast( elem ) @@ -1507,7 +1508,7 @@ int SMESH_MeshEditor::Reorient2D( TIDSortedElemSet & theFaces, vector< const SMDS_MeshElement* > facesNearLink; vector< std::pair< int, int > > nodeIndsOfFace; TIDSortedElemSet avoidSet, emptySet; - NCollection_Map< SMESH_TLink, SMESH_TLink > checkedLinks; + NCollection_Map< SMESH_TLink, SMESH_TLinkHasher > checkedLinks; while ( !theRefFaces.empty() ) { @@ -7906,6 +7907,8 @@ bool SMESH_MeshEditor::applyMerge( const SMDS_MeshElement* elem, // purpose : allow comparing elements basing on their nodes // ======================================================== +struct ComparableElementHasher; + class ComparableElement : public boost::container::flat_set< smIdType > { typedef boost::container::flat_set< smIdType > int_set; @@ -7914,6 +7917,8 @@ class ComparableElement : public boost::container::flat_set< smIdType > smIdType mySumID; mutable int myGroupID; + friend ComparableElementHasher; + public: ComparableElement( const SMDS_MeshElement* theElem ): @@ -7942,7 +7947,11 @@ public: mySumID = src.mySumID; myGroupID = src.myGroupID; } +}; +struct ComparableElementHasher +{ +#if OCC_VERSION_LARGE < 0x07080000 static int HashCode(const ComparableElement& se, int limit ) { return ::HashCode( FromSmIdType(se.mySumID), limit ); @@ -7951,7 +7960,17 @@ public: { return ( se1 == se2 ); } +#else + size_t operator()(const ComparableElement& se) const + { + return static_cast(FromSmIdType(se.mySumID)); + } + bool operator()(const ComparableElement& se1, const ComparableElement& se2) const + { + return ( se1 == se2 ); + } +#endif }; //======================================================================= @@ -7969,8 +7988,8 @@ void SMESH_MeshEditor::FindEqualElements( TIDSortedElemSet & theElements, if ( theElements.empty() ) elemIt = GetMeshDS()->elementsIterator(); else elemIt = SMESHUtils::elemSetIterator( theElements ); - typedef NCollection_Map< ComparableElement, ComparableElement > TMapOfElements; - typedef std::list TGroupOfElems; + typedef NCollection_Map< ComparableElement, ComparableElementHasher > TMapOfElements; + typedef std::list TGroupOfElems; TMapOfElements mapOfElements; std::vector< TGroupOfElems > arrayOfGroups; TGroupOfElems groupOfElems; diff --git a/src/SMESH/SMESH_MesherHelper.cxx b/src/SMESH/SMESH_MesherHelper.cxx index 1be97fb72..49a115281 100644 --- a/src/SMESH/SMESH_MesherHelper.cxx +++ b/src/SMESH/SMESH_MesherHelper.cxx @@ -3279,6 +3279,16 @@ double SMESH_MesherHelper::getFaceMaxTol( const TopoDS_Shape& face ) const return tol; } +bool CheckAlmostZero(gp_Vec & vec1,gp_Vec & vec2, gp_Vec & vecref) +{ + auto v1 = gp_Dir(vec1); + auto v2 = gp_Dir(vec2); + auto vref = gp_Dir(vecref); + auto XYZ = v1.Crossed (v2); + double cond = XYZ.X()*vref.X()+XYZ.Y()*vref.Y()+XYZ.Z()*vref.Z(); + return (Abs(cond) <= 1e-12); +} + //================================================================================ /*! * \brief Return an angle between two EDGEs sharing a common VERTEX with reference @@ -3341,7 +3351,9 @@ double SMESH_MesherHelper::GetAngle( const TopoDS_Edge & theE1, if ( theE2.Orientation() /*GetSubShapeOri( F, theE2 )*/ == TopAbs_REVERSED ) vec2.Reverse(); angle = vec1.AngleWithRef( vec2, vecRef ); - + if ( angle < 0. && CheckAlmostZero(vec1,vec2,vecRef)) + angle*=-1; + if ( Abs ( angle ) >= 0.99 * M_PI ) { BRep_Tool::Range( theE1, f, l ); diff --git a/src/SMESHDS/CMakeLists.txt b/src/SMESHDS/CMakeLists.txt index 4d058b84d..56e87ef7b 100644 --- a/src/SMESHDS/CMakeLists.txt +++ b/src/SMESHDS/CMakeLists.txt @@ -67,7 +67,6 @@ SET(SMESHDS_HEADERS SMESHDS_GroupOnGeom.hxx SMESHDS_GroupOnFilter.hxx SMESH_SMESHDS.hxx - SMESHDS_DataMapOfShape.hxx SMESH_Controls.hxx ) diff --git a/src/SMESHDS/SMESHDS_Mesh.hxx b/src/SMESHDS/SMESHDS_Mesh.hxx index c90ba3e25..1b8d2e2fd 100644 --- a/src/SMESHDS/SMESHDS_Mesh.hxx +++ b/src/SMESHDS/SMESHDS_Mesh.hxx @@ -32,6 +32,8 @@ #include "SMDS_Mesh.hxx" #include "SMESHDS_SubMesh.hxx" +#include + #include #include @@ -57,8 +59,34 @@ class SMDS_BallElement; * So this functionality implement on new NCollection_DataMap technology */ #include -#include "SMESHDS_DataMapOfShape.hxx" typedef std::list THypList; + +struct SMESHDS_Hasher +{ +#if OCC_VERSION_LARGE < 0x07080000 + 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); + } +#else + bool operator()(const TopoDS_Shape& S1, const TopoDS_Shape& S2) const + { + // for the purpose of ShapeToHypothesis map we don't consider shapes orientation + return S1.IsSame(S2); + } + size_t operator()(const TopoDS_Shape& S) const + { + return std::hash{}(S); + } +#endif +}; + typedef NCollection_DataMap< TopoDS_Shape, THypList, SMESHDS_Hasher > ShapeToHypothesis; class SMESHDS_GroupBase; diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index 5f1d4549a..90f0b230d 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -22,7 +22,23 @@ // File : SMESHGUI.cxx // Author : Nicolas REJNERI, Open CASCADE S.A.S. +#include + +#if OCC_VERSION_LARGE < 0x07080000 + #include // 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 +#endif + +#endif + #ifdef HAVE_FINITE #undef HAVE_FINITE // VSR: avoid compilation warning on Linux : "HAVE_FINITE" redefined #endif diff --git a/src/SMESHUtils/SMESH_FreeBorders.cxx b/src/SMESHUtils/SMESH_FreeBorders.cxx index ce7fb230f..f1575ca25 100644 --- a/src/SMESHUtils/SMESH_FreeBorders.cxx +++ b/src/SMESHUtils/SMESH_FreeBorders.cxx @@ -444,7 +444,7 @@ void SMESH_MeshAlgos::FindCoincidentFreeBorders(SMDS_Mesh& mesh, CoincidentFreeBorders & foundFreeBordes) { // find free links - typedef NCollection_DataMap TLink2FaceMap; + typedef NCollection_DataMap TLink2FaceMap; TLink2FaceMap linkMap; int nbSharedLinks = 0; SMDS_FaceIteratorPtr faceIt = mesh.facesIterator(); @@ -840,7 +840,7 @@ void SMESH_MeshAlgos::FindFreeBorders(SMDS_Mesh& theMesh, bool isManifold = true; // find free links - typedef NCollection_DataMap TLink2FaceMap; + typedef NCollection_DataMap TLink2FaceMap; TLink2FaceMap linkMap; int nbSharedLinks = 0; SMDS_FaceIteratorPtr faceIt = theMesh.facesIterator(); diff --git a/src/SMESHUtils/SMESH_MeshAlgos.cxx b/src/SMESHUtils/SMESH_MeshAlgos.cxx index 24958cc81..fac231ec8 100644 --- a/src/SMESHUtils/SMESH_MeshAlgos.cxx +++ b/src/SMESHUtils/SMESH_MeshAlgos.cxx @@ -1989,8 +1989,8 @@ SMESH_MeshAlgos::FindSharpEdges( SMDS_Mesh* theMesh, std::vector< Edge > resultEdges; if ( !theMesh ) return resultEdges; - typedef std::pair< bool, const SMDS_MeshNode* > TIsSharpAndMedium; - typedef NCollection_DataMap< SMESH_TLink, TIsSharpAndMedium, SMESH_TLink > TLinkSharpMap; + typedef std::pair< bool, const SMDS_MeshNode* > TIsSharpAndMedium; + typedef NCollection_DataMap< SMESH_TLink, TIsSharpAndMedium, SMESH_TLinkHasher > TLinkSharpMap; TLinkSharpMap linkIsSharp; Standard_Integer nbBuckets = FromSmIdType( theMesh->NbFaces() ); @@ -2101,8 +2101,8 @@ SMESH_MeshAlgos::SeparateFacesByEdges( SMDS_Mesh* theMesh, const std::vector< Ed // build map of face edges (SMESH_TLink) and their faces - typedef std::vector< const SMDS_MeshElement* > TFaceVec; - typedef NCollection_DataMap< SMESH_TLink, TFaceVec, SMESH_TLink > TFacesByLinks; + typedef std::vector< const SMDS_MeshElement* > TFaceVec; + typedef NCollection_DataMap< SMESH_TLink, TFaceVec, SMESH_TLinkHasher > TFacesByLinks; TFacesByLinks facesByLink; Standard_Integer nbBuckets = FromSmIdType( theMesh->NbFaces() ); 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, 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 ); int nbFreeLinks = 0; diff --git a/src/SMESHUtils/SMESH_Offset.cxx b/src/SMESHUtils/SMESH_Offset.cxx index 754411be8..3b0ba7a21 100644 --- a/src/SMESHUtils/SMESH_Offset.cxx +++ b/src/SMESHUtils/SMESH_Offset.cxx @@ -29,6 +29,7 @@ #include "SMDS_Mesh.hxx" #include +#include #include #include @@ -43,7 +44,7 @@ namespace 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_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* Node1() 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, const Standard_Integer upper) { @@ -90,9 +95,23 @@ namespace link1.myNode[1] == link2.myNode[1] && 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; void InitLinks() 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) { return ::HashCode( FromSmIdType(f.myInitFace->GetID()), upper ); @@ -283,14 +311,20 @@ namespace { return f1.myInitFace == f2.myInitFace; } - void Dump() const; +#else + size_t operator()(const CutFace& f) const + { + return FromSmIdType(f.myInitFace->GetID()); + } - private: - - EdgePart* getTwin( const EdgePart* edge ) const; + bool operator()(const CutFace& f1, const CutFace& f2) const + { + return f1.myInitFace == f2.myInitFace; + } +#endif }; - typedef NCollection_Map< CutFace, CutFace > TCutFaceMap; + typedef NCollection_Map< CutFace, CutFaceHasher > TCutFaceMap; //-------------------------------------------------------------------------------- /*! diff --git a/src/SMESHUtils/SMESH_TypeDefs.hxx b/src/SMESHUtils/SMESH_TypeDefs.hxx index 2e920132d..9ae5a4ce2 100644 --- a/src/SMESHUtils/SMESH_TypeDefs.hxx +++ b/src/SMESHUtils/SMESH_TypeDefs.hxx @@ -27,6 +27,8 @@ #ifndef __SMESH_TypeDefs_HXX__ #define __SMESH_TypeDefs_HXX__ +#include + #include "SMESH_Utils.hxx" #include "SMDS_SetIterator.hxx" @@ -36,6 +38,7 @@ #include #include +#include #include #include @@ -156,6 +159,19 @@ struct SMESH_TLink: public NLink const SMDS_MeshNode* node2() const { return second; } // 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) { 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() ); } +#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; @@ -218,6 +244,7 @@ typedef SMESH_TNodeXYZ SMESH_NodeXYZ; struct SMESH_Hasher { +#if OCC_VERSION_LARGE < 0x07080000 static Standard_Integer HashCode(const SMDS_MeshElement* e, const Standard_Integer upper) { return smIdHasher::HashCode( e->GetID(), upper ); @@ -226,6 +253,17 @@ struct SMESH_Hasher { 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 -#include -typedef const SMDS_MeshNode* SMDS_MeshNodePtr; -DEFINE_SEQUENCE(SMESH_SequenceOfNode, - SMESH_BaseCollectionNodePtr, SMDS_MeshNodePtr) +typedef const SMDS_MeshNode* SMDS_MeshNodePtr; +typedef NCollection_Sequence< SMDS_MeshNodePtr > SMESH_SequenceOfNode; #endif diff --git a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx index e05279c35..1abd26595 100644 --- a/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx +++ b/src/StdMeshers/StdMeshers_Quadrangle_2D.cxx @@ -49,7 +49,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/Tools/blocFissure/gmu/fissureCoude.py b/src/Tools/blocFissure/gmu/fissureCoude.py index f8ce927f0..014ab56fe 100644 --- a/src/Tools/blocFissure/gmu/fissureCoude.py +++ b/src/Tools/blocFissure/gmu/fissureCoude.py @@ -106,7 +106,10 @@ class fissureCoude(fissureGenerique): # --- tube coude sain - geometrieSaine = geompy.MakePartition([tube_1, coude, tube_2, P1, P2], [plan_y], [], [], geompy.ShapeType["SOLID"], 0, [], 1) + #Refactor to perform the partition in two steps to avoid break from occt (reported bug#) + #geometrieSaine = geompy.MakePartition([tube_1, coude, tube_2, P1, P2], [plan_y], [], [], geompy.ShapeType["SOLID"], 0, [], 1) + geometrieSaine0 = geompy.MakePartition([tube_1, coude], [plan_y], [], [], geompy.ShapeType["SOLID"], 0, [], 1) + geometrieSaine = geompy.MakePartition([geometrieSaine0, tube_2, P1, P2], [plan_y], [], [], geompy.ShapeType["SOLID"], 0, [], 1) geomPublish(initLog.debug, geometrieSaine, self.nomCas, self.numeroCas ) [P1, P2] = geompy.RestoreGivenSubShapes(geometrieSaine, [P1, P2], GEOM.FSM_GetInPlaceByHistory, False, True) diff --git a/test/ex_MakePolyLine.py b/test/ex_MakePolyLine.py index a7fb6a7e7..46115fccf 100644 --- a/test/ex_MakePolyLine.py +++ b/test/ex_MakePolyLine.py @@ -25,12 +25,21 @@ if not isDone: # define arguments for MakePolyLine segments = [] + # between nodes 20 and 1, default plane segments.append( SMESH.PolySegment( 20, 0, SMESH.PointStruct(-1, -1, -1), 1, 0, SMESH.PointStruct(-1, -1, -1), smesh.MakeDirStruct(0,0,0) )) + # between nodes 1 and 100, default plane segments.append( SMESH.PolySegment( 1, 0, SMESH.PointStruct(-1, -1, -1), 200, 0, SMESH.PointStruct(-1, -1, -1), smesh.MakeDirStruct(0,0,0) )) -# between nodes 200 and edge (578, 577), plane includes vector (1,1,1) -segments.append( SMESH.PolySegment( 200, 0, SMESH.PointStruct(-1, -1, -1), 578, 577, SMESH.PointStruct(-1, -1, -1), smesh.MakeDirStruct(1,1,1) )) + +# between node 200 and edge (578, 577), plane includes vector (1,1,1) +#segments.append( SMESH.PolySegment( 200, 0, SMESH.PointStruct(-1, -1, -1), 578, 577, SMESH.PointStruct(-1, -1, -1), smesh.MakeDirStruct(1,1,1) )) +# nodes 578 and 577 are not always neighbour, so, use another approach + +# between node 200 and an edge, close to point (200, 90, 70), plane includes vector (1,1,1) +elems = Mesh_1.FindElementsByPoint(200, 90, 70, SMESH.FACE) +nodes = Mesh_1.GetElemNodes(elems[0]) +segments.append( SMESH.PolySegment( 200, 0, SMESH.PointStruct(-1, -1, -1), nodes[0], nodes[1], SMESH.PointStruct(-1, -1, -1), smesh.MakeDirStruct(1,1,1) )) Mesh_1.MakePolyLine( segments, "1D group") diff --git a/test/netgen_runner_2D.py b/test/netgen_runner_2D.py index 36be1b717..255a4a61a 100644 --- a/test/netgen_runner_2D.py +++ b/test/netgen_runner_2D.py @@ -169,8 +169,8 @@ def test_netgen2dLenghtFromEdge(): print("Nb Segments:", nb_segments) print("Nb Points:", nb_points) - assert nb_triangles == 12 - assert nb_points == 8 + assert nb_triangles == 12*2 + assert nb_points == 14 assert nb_segments == 12 if __name__ == "__main__":