Salome HOME
c6cb0c91160dafb16a841ad1db8b7eee8f390e56
[modules/shaper_study.git] / src / StudyData / StudyData_XAO.h
1 // Copyright (C) 2019-2020  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, 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
20 #ifndef StudyData_Object_H
21
22 #include "StudyData.h"
23 #include <XAO_Xao.hxx>
24 #include <XAO_Step.hxx>
25 #include <XAO_Field.hxx>
26
27 #include <list>
28 #include <map>
29
30 class TopoDS_Shape;
31
32 class StudyData_XAO
33 {
34   TopoDS_Shape* myShape; ///< the shape, part of XAO
35   XAO::Xao* myExport; ///< the XAO instance for export
36   XAO::Xao* myImport; ///< the XAO instance for export
37   std::map<int, XAO::Group*> myGroups; ///< id of group to the group structure
38   std::map<int, XAO::Field*> myFields; ///< id of field to the field structure
39   std::map<int, std::map<int, XAO::Step*> > mySteps; ///< id of field to the field structure
40   int myCurrentElementID; ///< to add elements of step one by one
41   XAO::stepIterator myStepIterator; ///< contains a current steps iterator (on import)
42
43 public:
44   StudyData_EXPORT StudyData_XAO();
45
46   // defines the shape for XAO export
47   StudyData_EXPORT void SetShape(const long long theShapePtr);
48
49   // add a new group for export to XAO; returns id of this group
50   StudyData_EXPORT int AddGroup(const int theSelType, const std::string theGroupName);
51   // sets the selection for an already added group
52   StudyData_EXPORT void AddGroupSelection(const int theGroupID, const int theSelection);
53
54   // add a new field for export to XAO; returns id of this field
55   StudyData_EXPORT int AddField(const int theValType, const int theSelType,
56                                 const int theCompsNum, const std::string theFieldName);
57   // set the component name for the exported field
58   StudyData_EXPORT void SetFieldComponent(const int theFieldID, const int theCompIndex,
59                                           const std::string theCompName);
60   // adds a step to the exported field
61   StudyData_EXPORT void AddStep(const int theFieldID, const int theStepID, const int theStampID);
62   // adds the value to the step of the exported field. values must come one by one (row by row)
63   StudyData_EXPORT void AddStepValue(
64     const int theFieldID, const int theStepID, std::string theValue);
65
66   // performs the export to XAO
67   StudyData_EXPORT void Export(const std::string theFileName);
68
69   // Imports the XAO data, returns the error string or empty one if it is ok.
70   StudyData_EXPORT std::string Import(const std::string theFileName);
71
72   // Returns a pointer to the shape from XAO after import
73   StudyData_EXPORT long long GetShape();
74
75   // Returns a selection type of the group
76   StudyData_EXPORT int GetGroupDimension(const int theGroupID);
77
78   // Returns a selection list of indices of the group
79   StudyData_EXPORT std::list<long> GetGroupSelection(const int theGroupID);
80
81   // Returns a value type of the imported field
82   StudyData_EXPORT int GetValuesType(const int theFieldID);
83   // Returns a selection type of the imported field
84   StudyData_EXPORT int GetSelectionType(const int theFieldID);
85   // Returns components names of the imported field
86   StudyData_EXPORT std::list<std::string> GetComponents(const int theFieldID);
87   // Starts iteration of steps
88   StudyData_EXPORT void BeginSteps(const int theFieldID);
89   // Returns true if steps iteration contains a current step
90   StudyData_EXPORT bool More(const int theFieldID);
91   // Iterates the step iterator contains a current step
92   StudyData_EXPORT void Next();
93   // Returns a stamp ID of the imported field step
94   StudyData_EXPORT int GetStamp();
95   // Returns a step ID of the imported field step
96   StudyData_EXPORT int GetStepIndex();
97   // Returns string values of the imported field step
98   StudyData_EXPORT std::list<std::string> GetValues();
99 };
100
101 #endif // !StudyData_XAO_H