From 98ec6be586ce93a33c242c6ce1f90b609ce31493 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 6 Mar 2019 16:59:54 +0300 Subject: [PATCH] Fix MinDistance for node-group (SALOME_TESTS/Grids/smesh/imps_09/K0) + Minor doc improvement --- doc/salome/gui/SMESH/input/modules.rst | 12 ++++-- doc/salome/gui/SMESH/input/smesh_module.rst | 6 ++- .../gui/SMESH/input/smeshpy_interface.rst | 6 +-- src/SMESHUtils/SMESH_MeshAlgos.cxx | 39 +++++++++++++++++++ src/SMESHUtils/SMESH_PolyLine.cxx | 5 ++- src/SMESH_SWIG/smeshBuilder.py | 9 +++-- 6 files changed, 64 insertions(+), 13 deletions(-) diff --git a/doc/salome/gui/SMESH/input/modules.rst b/doc/salome/gui/SMESH/input/modules.rst index 6c673f6db..88d2d2dc4 100644 --- a/doc/salome/gui/SMESH/input/modules.rst +++ b/doc/salome/gui/SMESH/input/modules.rst @@ -169,14 +169,16 @@ Creating groups Mesh.MakeGroupByCriteria Mesh.MakeGroupByFilter Mesh.FaceGroupsSeparatedByEdges + Mesh.CreateDimGroup + Mesh.ConvertToStandalone Mesh.GetGroups Mesh.NbGroups Mesh.GetGroupNames Mesh.GetGroupByName -Using operations on groups -========================== +Operations on groups +==================== .. autosummary:: @@ -186,8 +188,6 @@ Using operations on groups Mesh.IntersectListOfGroups Mesh.CutGroups Mesh.CutListOfGroups - Mesh.CreateDimGroup - Mesh.ConvertToStandalone Deleting Groups =============== @@ -204,6 +204,8 @@ Mesh Information .. autosummary:: smeshBuilder.GetMeshInfo + Mesh.GetEngine + Mesh.GetGeomEngine Mesh.GetGeometryByMeshElement Mesh.MeshDimension Mesh.GetMeshInfo @@ -269,6 +271,7 @@ Mesh Information Mesh.FindNodeClosestTo Mesh.FindElementsByPoint Mesh.GetPointState + Mesh.Get1DBranches Mesh.Dump ****************************** @@ -352,6 +355,7 @@ Adding nodes and elements Mesh.Make2DMeshFrom3D Mesh.MakeBoundaryMesh Mesh.MakeBoundaryElements + Mesh.Append Mesh.GetLastCreatedNodes Mesh.GetLastCreatedElems Mesh.ClearLastCreated diff --git a/doc/salome/gui/SMESH/input/smesh_module.rst b/doc/salome/gui/SMESH/input/smesh_module.rst index 1178488c8..831452e43 100644 --- a/doc/salome/gui/SMESH/input/smesh_module.rst +++ b/doc/salome/gui/SMESH/input/smesh_module.rst @@ -791,7 +791,11 @@ SMESH_GroupBase .. py:class:: SMESH_GroupBase - :doc:`Mesh group ` + :doc:`Mesh group `. + Base class of :class:`standalone group `, + :class:`group on geometry ` and + :class:`group on filter `. + Inherit all methods from :class:`SMESH_IDSource`. .. py:function:: SetName( name ) diff --git a/doc/salome/gui/SMESH/input/smeshpy_interface.rst b/doc/salome/gui/SMESH/input/smeshpy_interface.rst index 922a1e2b7..a08cb2d0a 100644 --- a/doc/salome/gui/SMESH/input/smeshpy_interface.rst +++ b/doc/salome/gui/SMESH/input/smeshpy_interface.rst @@ -55,7 +55,7 @@ A usual workflow to generate a mesh on geometry is following: netgen.SetMaxSize( 20. ) netgen.SetFineness( smeshBuilder.VeryCoarse ) -#. :ref:`compute_anchor` the mesh (generate mesh nodes and elements): +#. :ref:`Compute the mesh ` (generate mesh nodes and elements): .. code-block:: python mesh.Compute() @@ -66,10 +66,10 @@ GUI and then to get a corresponding Python script via all methods of any object in hand (e.g. a mesh group or a hypothesis) by calling *dir()* Python built-in function. -All methods of the Mesh Group can be found in :ref:`tui_create_standalone_group` sample script. +All methods of the :class:`Mesh Group ` can be found in :ref:`tui_create_standalone_group` sample script. An example below demonstrates usage of the Python API for 3D mesh -generation and for retrieving information on mesh nodes and elements. +generation and for retrieving basic information on mesh nodes, elements and groups. .. _example_3d_mesh: diff --git a/src/SMESHUtils/SMESH_MeshAlgos.cxx b/src/SMESHUtils/SMESH_MeshAlgos.cxx index 55c5f5025..a2c9c1036 100644 --- a/src/SMESHUtils/SMESH_MeshAlgos.cxx +++ b/src/SMESHUtils/SMESH_MeshAlgos.cxx @@ -238,6 +238,7 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint() void getElementsInBox ( const Bnd_B3d& box, TElemSeq& foundElems ); void getElementsInSphere ( const gp_XYZ& center, const double radius, TElemSeq& foundElems ); ElementBndBoxTree* getLeafAtPoint( const gp_XYZ& point ); + int getNbElements(); protected: ElementBndBoxTree() {} @@ -466,6 +467,27 @@ namespace // Utils used in SMESH_ElementSearcherImpl::FindElementsByPoint() return 0; } + //================================================================================ + /*! + * \brief Return number of elements + */ + //================================================================================ + + int ElementBndBoxTree::getNbElements() + { + int nb = 0; + if ( isLeaf() ) + { + nb = _elements.size(); + } + else + { + for (int i = 0; i < 8; i++) + nb += ((ElementBndBoxTree*) myChildren[i])->getNbElements(); + } + return nb; + } + //================================================================================ /*! * \brief Construct the element box @@ -1302,6 +1324,23 @@ gp_XYZ SMESH_ElementSearcherImpl::Project(const gp_Pnt& point, minDist = d; } } + if ( minDist > radius ) + { + ElementBndBoxTree::TElemSeq elems2; + ebbTree->getElementsInSphere( p, minDist, elems2 ); + for ( e = elems2.begin(); e != elems2.end(); ++e ) + { + if ( elems.count( *e )) + continue; + double d = SMESH_MeshAlgos::GetDistance( *e, point, &proj ); + if ( d < minDist ) + { + bestProj = proj; + elem = *e; + minDist = d; + } + } + } if ( closestElem ) *closestElem = elem; return bestProj; diff --git a/src/SMESHUtils/SMESH_PolyLine.cxx b/src/SMESHUtils/SMESH_PolyLine.cxx index b244a7560..82ace2859 100644 --- a/src/SMESHUtils/SMESH_PolyLine.cxx +++ b/src/SMESHUtils/SMESH_PolyLine.cxx @@ -154,7 +154,10 @@ namespace if ( !path.SetCutAtCorner( cornerNode, fIt->next(), plnNorm, plnOrig )) continue; - if ( !myAvoidSet.insert( path.myNode1.Node() ).second || + if ( path.myDot1 == 0 && + !myAvoidSet.insert( path.myNode1.Node() ).second ) + continue; + if ( path.myDot2 == 0 && !myAvoidSet.insert( path.myNode2.Node() ).second ) continue; diff --git a/src/SMESH_SWIG/smeshBuilder.py b/src/SMESH_SWIG/smeshBuilder.py index 64ee3091f..cf5facce8 100644 --- a/src/SMESH_SWIG/smeshBuilder.py +++ b/src/SMESH_SWIG/smeshBuilder.py @@ -4384,7 +4384,8 @@ class Mesh(metaclass = MeshMeta): Returns: A list of edge groups and a list of corresponding node groups, - where the group is a list of IDs of edges or elements. + where the group is a list of IDs of edges or elements, like follows + [[[branch_edges_1],[branch_edges_2]], [[branch_nodes_1],[branch_nodes_2]]]. If a group is closed, the first and last nodes of the group are same. """ if isinstance( edges, Mesh ): @@ -6947,7 +6948,7 @@ class Mesh(metaclass = MeshMeta): def GetLength(self, elemId=None): """ - Get length of all given 1D elements or sum length of all 1D mesh elements + Get length of given 1D elements or of all 1D mesh elements Parameters: elemId: either a mesh element ID or a list of IDs or :class:`sub-mesh, group or filter `. By default sum length of all 1D elements will be calculated. @@ -6977,7 +6978,7 @@ class Mesh(metaclass = MeshMeta): def GetArea(self, elemId=None): """ - Get area of given 2D elements or sum area of all 2D mesh elements + Get area of given 2D elements or of all 2D mesh elements Parameters: elemId: either a mesh element ID or a list of IDs or :class:`sub-mesh, group or filter `. By default sum area of all 2D elements will be calculated. @@ -7007,7 +7008,7 @@ class Mesh(metaclass = MeshMeta): def GetVolume(self, elemId=None): """ - Get volume of a 3D element or sum of volumes of all 3D mesh elements + Get volume of given 3D elements or of all 3D mesh elements Parameters: elemId: either a mesh element ID or a list of IDs or :class:`sub-mesh, group or filter `. By default sum volume of all 3D elements will be calculated.