]> SALOME platform Git repositories - modules/multipr.git/blob - src/MULTIPR/MULTIPR_Nodes.hxx
Salome HOME
ed39c9d76af7b30b3c3b32df7685729ff6e53eb9
[modules/multipr.git] / src / MULTIPR / MULTIPR_Nodes.hxx
1 // Project MULTIPR, IOLS WP1.2.1 - EDF/CS
2 // Partitioning/decimation module for the SALOME v3.2 platform
3
4 /**
5  * \file    MULTIPR_Nodes.hxx
6  *
7  * \brief   Class Nodes = table of nodes.
8  *
9  * \author  Olivier LE ROUX - CS, Virtual Reality Dpt
10  * 
11  * \date    01/2007
12  */
13
14 #ifndef MULTIPR_NODES_HXX
15 #define MULTIPR_NODES_HXX
16
17 //*****************************************************************************
18 // Includes section
19 //*****************************************************************************
20
21 extern "C"
22 {
23         #include "med.h"
24 }
25
26 #include <iostream>
27 #include <set>
28
29
30 namespace multipr
31 {
32
33
34 //*****************************************************************************
35 // Class Nodes
36 //*****************************************************************************
37
38 class Nodes
39 {
40 public:
41
42         /** 
43          * Builds an empty set of nodes (default constructor).
44          */
45         Nodes();
46         
47         /**
48          * Destructor. Removes everything.
49          */
50         ~Nodes();
51         
52         /**
53          * Resets this object in its state by default (empty). Cleans memory.
54          */
55         void reset();
56         
57         //---------------------------------------------------------------------
58         // Basic accessors/mutators
59         //---------------------------------------------------------------------
60         
61         /**
62          * Returns true if nodes have a name.
63          * \return true if nodes have a name.
64          */
65         bool isNames() const { return (mNames != NULL); }
66         
67         /**
68          * Returns true if elements have an identifier (= a number).
69          * \return true if elements have an identifier (= a number).
70          */
71         bool isIdentifiers() const { return (mId != NULL); }
72           
73         /**
74          * Returns the coordinates of one node according to its index.
75          * \param  pIndexNode index of node in [0..NUMBER_OF_NODES-1].
76          * \return the coordinates of one node.
77          * \throw  IndexOutOfBoundsException if pIndexNode is invalid.
78          */
79         const med_float* getCoordinates(med_int pIndexNode) const;
80         
81         /**
82          * Returns the family of one node.
83          * \param  pIndexNode index of node in [0..NUMBER_OF_NODES-1].
84          * \return the family of the given node.
85          * \throw  IndexOutOfBoundsException if pIndexNode is invalid.
86          */
87         med_int getFamIdent(med_int pIndexNode) const;
88         
89         /**
90          * Returns the number of nodes.
91          * \return the number of nodes.
92          */
93         int getNumberOfNodes() const { return mNum; }
94         
95         //---------------------------------------------------------------------
96         // Algorithms
97         //---------------------------------------------------------------------
98         
99         /**
100          * Returns the axis-aligned bounding box (CARTESIAN coordinates system) of this set of nodes.
101          * \param  pMin (out) coordinates of the min-corner of the bbox.
102          * \param  pMin (out) coordinates of the max-corner of the bbox.
103          */
104         void getBBox(med_float pMin[3], med_float pMax[3]) const;
105
106         /**
107          * Returns the set of families referenced by this set of nodes.
108          * Each family is described by its identifier.
109          * \return the set of families referenced by this set of nodes.
110          */
111         std::set<med_int> getSetOfFamilies() const;
112         
113         /**
114          * Constructor. Creates a subset of this set of nodes from a set of indices.
115          * \param  pSetOfIndices set of indices; each index must be >= 1.
116          * \return a subset of this set of nodes from a set of indices.
117          */
118         Nodes* extractSubSet(const std::set<med_int>& pSetIndices) const;
119         
120         //---------------------------------------------------------------------
121         // I/O
122         //---------------------------------------------------------------------
123
124         /**
125          * Reads all nodes of a mesh from a MED file.
126          * \param  pMEDfile   any valid MED file opened for reading.
127          * \param  pMeshName  name of the mesh to be read.
128          * \param  pDim       dimension of the mesh.
129          * \throw  IOException if any i/o error occurs.
130          */
131         void readMED(med_idt pMEDfile, char* pMeshName, med_int pDim);
132         
133         /**
134          * Writes this set of nodes to a MED file. Nodes are associated with the given mesh.
135          * WARNING: mesh must have been created and added to the MED file before.
136          * \param  pMEDfile  any valid MED file opened for writing.
137          * \param  pMeshName any mesh of the MED file. 
138          * \throw  IOException if any i/o error occurs.
139          */
140         void writeMED(med_idt pMEDfile, char* pMeshName) const;
141          
142         /**
143          * Sets the flag which control the stream operator <<.
144          * \param  pFlag new flag value.
145          */
146         void setPrintAll(bool pFlag) { mFlagPrintAll = pFlag; } 
147          
148         /**
149          * Dumps any Nodes to the given output stream.
150          * \param  pOs any output stream.
151          * \param  pN  any Nodes.
152          * \return the output stream pOs.
153          */
154         friend std::ostream& operator<<(std::ostream& pOs, Nodes& pN);
155         
156 private:
157         
158         med_int     mNum;            /**< Number of nodes in this set. */
159         med_int     mDim;            /**< Dimension of nodes. */
160         med_repere  mCoordSystem;    /**< Type of coordinates system; should be MED_CART for cartesian. */
161         
162         med_int*    mId;             /**< Optional; for each node, its identifier; NULL if undefined. */
163         med_int*    mFamIdent;       /**< For each node, its identifier of its family. */
164         char*       mNames;          /**< Optional; for each node, its name; NULL if undefined. */
165         med_float*  mCoo;            /**< For each node, coordinates of node; array is interlaced: x1 y1 z1 x2 y2 z2 ...*/
166         char*       mNamesCoo;       /**< Names of axis of the coordinates system. */     
167         char*       mNamesUnitCoo;   /**< Unit of axis of the coordinates system.  */
168         
169         bool        mFlagPrintAll;   /** Flag to control the behaviour of the stream operator <<. */
170         
171 private:
172
173         // do not allow copy constructor
174         Nodes(const Nodes&);
175         
176         // do not allow copy
177         Nodes& operator=(const Nodes&);
178         
179         // do not allow operator ==
180         bool operator==(const Nodes&); 
181         
182 }; // class Nodes
183
184
185 } // namespace MULTIPR
186
187
188 #endif // MULTIPR_NODES_HXX
189
190 // EOF