1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SMESH_MeshAlgos.hxx
23 // Created : Tue Apr 30 18:00:36 2013
24 // Author : Edward AGAPOV (eap)
26 // This file holds some low level algorithms extracted from SMESH_MeshEditor
27 // to make them accessible from Controls package
30 #ifndef __SMESH_MeshAlgos_HXX__
31 #define __SMESH_MeshAlgos_HXX__
33 #include "SMDSAbs_ElementType.hxx"
34 #include "SMDS_ElemIterator.hxx"
35 #include "SMESH_TypeDefs.hxx"
37 #include <TopAbs_State.hxx>
43 class SMDS_MeshElement;
46 //=======================================================================
48 * \brief Searcher for the node closest to a point
50 //=======================================================================
52 struct SMESH_NodeSearcher
54 virtual const SMDS_MeshNode* FindClosestTo( const gp_Pnt& pnt ) = 0;
55 virtual void MoveNode( const SMDS_MeshNode* node, const gp_Pnt& toPnt ) = 0;
58 //=======================================================================
60 * \brief Searcher for elements
62 //=======================================================================
64 struct SMESH_ElementSearcher
67 * \brief Find elements of given type where the given point is IN or ON.
68 * Returns nb of found elements and elements them-selves.
70 * 'ALL' type means elements of any type excluding nodes and 0D elements
72 virtual int FindElementsByPoint(const gp_Pnt& point,
73 SMDSAbs_ElementType type,
74 std::vector< const SMDS_MeshElement* >& foundElems) = 0;
76 * \brief Return an element most close to the given point
78 virtual const SMDS_MeshElement* FindClosestTo( const gp_Pnt& point,
79 SMDSAbs_ElementType type) = 0;
81 * \brief Return elements possibly intersecting the line
83 virtual void GetElementsNearLine( const gp_Ax1& line,
84 SMDSAbs_ElementType type,
85 std::vector< const SMDS_MeshElement* >& foundElems) = 0;
87 * \brief Find out if the given point is out of closed 2D mesh.
89 virtual TopAbs_State GetPointState(const gp_Pnt& point) = 0;
90 virtual ~SMESH_ElementSearcher();
93 namespace SMESH_MeshAlgos
96 * \brief Return true if the point is IN or ON of the element
98 bool IsOut( const SMDS_MeshElement* element, const gp_Pnt& point, double tol );
100 double GetDistance( const SMDS_MeshFace* face, const gp_Pnt& point );
103 * Return a face having linked nodes n1 and n2 and which is
105 * - in elemSet provided that !elemSet.empty()
106 * i1 and i2 optionally returns indices of n1 and n2
108 const SMDS_MeshElement* FindFaceInSet(const SMDS_MeshNode* n1,
109 const SMDS_MeshNode* n2,
110 const TIDSortedElemSet& elemSet,
111 const TIDSortedElemSet& avoidSet,
115 * \brief Calculate normal of a mesh face
117 bool FaceNormal(const SMDS_MeshElement* F, gp_XYZ& normal, bool normalized=true);
120 * \brief Return nodes common to two elements
122 std::vector< const SMDS_MeshNode*> GetCommonNodes(const SMDS_MeshElement* e1,
123 const SMDS_MeshElement* e2);
126 * \brief Return SMESH_NodeSearcher. The caller is responsible for deleteing it
128 SMESH_NodeSearcher* GetNodeSearcher( SMDS_Mesh& mesh );
131 * \brief Return SMESH_ElementSearcher. The caller is responsible for deleting it
133 SMESH_ElementSearcher* GetElementSearcher( SMDS_Mesh& mesh );
134 SMESH_ElementSearcher* GetElementSearcher( SMDS_Mesh& mesh,
135 SMDS_ElemIteratorPtr elemIt );