Salome HOME
Merge from BR_V5_DEV 16Feb09
[modules/med.git] / src / MULTIPR / MULTIPR_PointOfField.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 // Partitioning/decimation module for the SALOME v3.2 platform
20 //
21 /**
22  * \file    MULTIPR_PointOfField.hxx
23  *
24  * \brief   Class PointOfField used for decimation. PointOfField = a point in a field = coordinates + value.
25  *
26  * \author  Olivier LE ROUX - CS, Virtual Reality Dpt
27  * 
28  * \date    01/2007
29  */
30
31 #ifndef MULTIPR_POINTOFFIELD_HXX
32 #define MULTIPR_POINTOFFIELD_HXX
33
34 //*****************************************************************************
35 // Includes section
36 //*****************************************************************************
37
38 extern "C"
39 {
40     #include "med.h"
41 }
42 #include <limits>
43
44 namespace multipr
45 {
46
47
48 //*****************************************************************************
49 // Class PointOfField
50 //*****************************************************************************
51
52 class PointOfField
53 {
54 public:
55
56     /** 
57      * Builds an empty set of elements (default constructor).
58      */
59     PointOfField() { reset(); }
60     
61     /**
62      * Constructor.
63      * \param  pX   x-coordinate of the point.
64      * \param  pY   y-coordinate of the point.
65      * \param  pZ   z-coordinate of the point.
66      * \param  pVal value of the field at the given point.
67      */
68     PointOfField(med_float pX, med_float pY, med_float pZ, med_float pVal)
69     {
70         mXYZ[0] = pX;
71         mXYZ[1] = pY;
72         mXYZ[2] = pZ;
73         mVal    = pVal;
74     }
75     
76     /**
77      * Destructor. Removes everything.
78      */
79     ~PointOfField() { reset(); }
80     
81     /**
82      * Resets this object in its state by default (empty).
83      */
84     void reset()
85     {
86         mXYZ[0] = std::numeric_limits<med_float>::quiet_NaN();
87         mXYZ[1] = std::numeric_limits<med_float>::quiet_NaN();
88         mXYZ[2] = std::numeric_limits<med_float>::quiet_NaN();
89         mVal    = std::numeric_limits<med_float>::quiet_NaN();
90     }
91
92     /**
93      * Dumps any PointOfField to the given output stream.
94      * \param  pOs any output stream.
95      * \param  pP  any PointOfField.
96      * \return the output stream pOs.
97      */
98     friend std::ostream& operator<<(std::ostream& pOs, PointOfField& pP)
99     {
100         pOs << "[ " << pP.mXYZ[0] << " ; " << pP.mXYZ[1] << " ; " << pP.mXYZ[2] << "]: " << pP.mVal;
101         return pOs;
102     }
103
104 public:
105
106     med_float  mXYZ[3];    /**< 3D-position. */
107     med_float  mVal;       /**< Value of the field at this point. */
108     
109 }; // class PointOfField
110
111
112 } // namespace multipr
113
114
115 #endif // MULTIPR_FIELDPOINT_HXX 
116
117 // EOF