]> SALOME platform Git repositories - modules/geom.git/blob - src/XAO/XAO_Field.hxx
Salome HOME
Merge from BR_V7_main_Field branch (02/09/2013)
[modules/geom.git] / src / XAO / XAO_Field.hxx
1 // Copyright (C) 2013  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 // Author : Frederic Pons (OpenCascade)
20
21 #ifndef __XAO_FIELD_HXX__
22 #define __XAO_FIELD_HXX__
23
24 #include <string>
25 #include <vector>
26
27 #include "XAO_XaoUtils.hxx"
28 #include "XAO_Step.hxx"
29
30 namespace XAO
31 {
32     typedef std::vector<Step*>::iterator stepIterator;
33
34     /**
35      * @class Field
36      * A geometrical Field.
37      */
38     class Field
39     {
40     protected:
41         /**
42          * Constructor.
43          * @param dimension the dimension ot the field.
44          * @param nbElements the number of elements.
45          * @param nbComponents the number of components.
46          * @param name the name of the field.
47          */
48         Field(const XAO::Dimension& dimension,
49               const int& nbElements, const int& nbComponents, const std::string& name);
50
51     public:
52         /**
53         /**
54          * Creates a Field of the given type.
55          * @param type the type of the field to create.
56          * @param dimension the dimension.
57          * @param nbElements the number of geometrical elements.
58          * @param nbComponents the number of components.
59          * @name the name of the field.
60          * @return the created field.
61          */
62         static Field* createField(const XAO::Type& type, const XAO::Dimension& dimension,
63                                   const int& nbElements, const int& nbComponents,
64                                   const std::string& name = std::string(""))
65         throw (XAO_Exception);
66
67         /**
68          * Destructor.
69          */
70         virtual ~Field();
71
72         /**
73          * Gets the Type of the field.
74          * @return the Type of the field.
75          */
76         virtual const XAO::Type getType() = 0;
77
78         /**
79          * Gets the name of the Field.
80          * @return the name of the Field.
81          */
82         const std::string getName() const
83         {
84             return m_name;
85         }
86
87         /**
88          * Sets the name of the Field.
89          * @param name the name to set.
90          */
91         void setName(const std::string& name)
92         {
93             m_name = name;
94         }
95
96         /**
97          * Gets the Dimension of the Field.
98          * @return the Dimension of the Field.
99          */
100         const XAO::Dimension getDimension() const
101         {
102             return m_dimension;
103         }
104
105         /**
106          * Gets the number of elements of each step.
107          * @return the number of elements of each step.
108          */
109         const int countElements() const
110         {
111             return m_nbElements;
112         }
113
114         /**
115          * Gets the number of components.
116          * @return the number of components.
117          */
118         const int countComponents() const
119         {
120             return m_nbComponents;
121         }
122
123         /**
124          * Gets the number of values for each step.
125          * @return the number of values for each step.
126          */
127         const int countValues() const
128         {
129             return m_nbElements * m_nbComponents;
130         }
131
132         /**
133          * Gets the number of the steps.
134          * @return the number of steps.
135          */
136         const int countSteps() const { return m_steps.size(); }
137
138         /**
139          * Gets the name of a component.
140          * @param index the index of the component to get.
141          * @return the name of the component for the given index.
142          */
143         const std::string getComponentName(const int& index) throw (XAO_Exception);
144
145         /**
146          * Sets the name of a component.
147          * @param componentIndex the index of the component to set.
148          * @param name the name to set.
149          */
150         void setComponentName(const int& componentIndex, const std::string& name) throw (XAO_Exception);
151
152         /**
153          * Sets the name of the components.
154          * @param names the names to set.
155          */
156         void setComponentsNames(const std::vector<std::string>& names) throw (XAO_Exception);
157
158         /**
159          * Adds a new step of the same type than the field.
160          * @param number the numer of the step.
161          * @return the new create step.
162          */
163         virtual Step* addNewStep(const int& number) throw (XAO_Exception) = 0;
164
165         /**
166          * Remove a step.
167          * @param step the step to remove.
168          * @return true if the step has been removed, false otherwise.
169          */
170         bool removeStep(Step* step);
171
172         /**
173          * Verifies if the field has a step with the given step number.
174          * @param step the step number.
175          * @return true if the field has a step for the given number.
176          */
177         bool hasStep(const int& step);
178
179         /**
180          * Returns the first step.
181          * @return an iterator on the first step.
182          */
183         stepIterator begin() { return m_steps.begin(); }
184
185         /**
186          * Returns the last step.
187          * @return an iterator on the last step.
188          */
189         stepIterator end() { return m_steps.end(); }
190
191     protected:
192         void checkComponent(const int& component) throw (XAO_Exception);
193         void checkStepIndex(const int& step) throw (XAO_Exception);
194
195     protected:
196         /** The name of the Field. */
197         std::string m_name;
198         /** The dimension of the Field. */
199         XAO::Dimension m_dimension;
200
201         /** The number of components. */
202         int m_nbComponents;
203         /** The components of the field. */
204         std::vector<std::string> m_components;
205         /** The number of elements. */
206         int m_nbElements;
207
208         /** The list of steps. */
209         std::vector<Step*> m_steps;
210     };
211 }
212
213 #endif