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