]> SALOME platform Git repositories - modules/med.git/blob - src/MEDMEM/MEDMEM_Extractor.hxx
Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MEDMEM / MEDMEM_Extractor.hxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // File      : MEDMEM_Extractor.hxx
20 // Created   : Thu Dec 18 10:52:01 2008
21 // Author    : Edward AGAPOV (eap)
22
23 #ifndef __MEDMEM_EXTRACTOR_HXX__
24 #define __MEDMEM_EXTRACTOR_HXX__
25
26 #include "MEDMEM_Exception.hxx"
27 #include "MEDMEM_Mesh.hxx"
28 #include "MEDMEM_Field.hxx"
29
30 #include <map>
31 #include <vector>
32 #include <set>
33
34 namespace MEDMEM
35 {
36   /*!
37    * \brief Tool taking an input field and making a field of lower dimension
38    * by cutting the given field by a plane or a line.
39    *
40    * The following extractions are possible: <ul>
41    *<li>  3D -> 2D (3D mesh cut by plane)</li>
42    *<li>  3D -> 1D (3D mesh cut by line)</li>
43    *<li>  2D -> 1D (2D mesh cut by line in 2D space or by plane in 3D space)</li></ul>
44    */
45   class Extractor
46   {
47   /*!
48    * \brief Creates a tool
49    *  \param inputField - input field
50    *
51    * The input field is supposed to comply with following conditions <ul>
52    *<li>  it is constant by element (i.e. has 1 gauss point),</li>
53    *<li>  it's support mesh does not contain poly elements,</li>
54    *<li>  volumic elements have planar faces,</li>
55    *<li>  surfasic elements have linear edges.</li></ul>
56    */
57   public:
58     Extractor(const FIELD<double>& inputField) throw (MEDEXCEPTION);
59
60     /*!
61      * \brief Creates a field by cutting inputField by a plane
62      *  \param coords - give a point to pass through by the plane
63      *  \param normal - gives the plane normal
64      *  \retval FIELD<double>* - resulting field holding ownership of its support,
65      *                           which in its turn holds ownership of its mesh
66      */
67     FIELD<double>* extractPlane(const double* coords, const double* normal) throw (MEDEXCEPTION);
68
69     /*!
70      * \brief Creates a field by cutting inputField by a line
71      *  \param coords - give a point to pass through by the line
72      *  \param direction - gives a vector collinear to the line
73      *  \retval FIELD<double>* - resulting field holding ownership of its support,
74      *                           which in its turn holds ownership of its mesh
75      */
76     FIELD<double>* extractLine(const double* coords, const double* direction) throw (MEDEXCEPTION);
77
78   private:
79
80     MESH* divideEdges(const double*       coords,
81                       const double*       normal,
82                       std::map<int,std::set<int> >& new2oldCells);
83                      
84     MESH* transfixFaces( const double*       coords,
85                          const double*       direction,
86                          std::map<int,std::set<int> >& new2oldCells);
87
88     FIELD<double>* makeField( const std::map<int,std::set<int> >& new2oldCells,
89                               MESH*                               mesh) const;
90
91     void computeDistanceOfNodes(const double* point, const double* normal);
92
93     void sortNodes( std::map< int, std::vector< int > >& connByNbNodes,
94                     const double* nodeCoords,
95                     const double* point,
96                     const double* normal,
97                     const std::list<int> & nbNodesPerPolygon);
98
99
100     const FIELD<double>* _myInputField; //!<  input field
101     std::vector<double>  _myNodeDistance; //!< distance of input nodes to cutting tool
102   };
103 }
104
105 #endif