SHAPER  9.15.0
ModelHighAPI_Interface.h
1 // Copyright (C) 2014-2025 CEA, EDF
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 SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
21 #define SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_
22 
23 //--------------------------------------------------------------------------------------
24 #include "ModelHighAPI.h"
25 
26 #include <list>
27 #include <map>
28 #include <memory>
29 #include <string>
30 #include <iostream>
31 //--------------------------------------------------------------------------------------
32 class ModelAPI_Feature;
33 class ModelAPI_Result;
36 
37 class GeomAPI_Shape;
38 
39 typedef std::list<std::shared_ptr<GeomAPI_Shape> > ListOfShape;
40 //--------------------------------------------------------------------------------------
46 {
47 public:
49  MODELHIGHAPI_EXPORT
50  explicit ModelHighAPI_Interface(const std::shared_ptr<ModelAPI_Feature> & theFeature);
52  MODELHIGHAPI_EXPORT
53  virtual ~ModelHighAPI_Interface();
54 
56  MODELHIGHAPI_EXPORT
57  std::shared_ptr<ModelAPI_Feature> feature() const;
58 
61  MODELHIGHAPI_EXPORT
62  std::shared_ptr<ModelHighAPI_Interface> subFeature(const int theIndex) const;
63 
65  MODELHIGHAPI_EXPORT
66  const std::string& getKind() const;
67 
70  MODELHIGHAPI_EXPORT
71  void execute(bool isForce = false);
72 
74  MODELHIGHAPI_EXPORT
75  void setName(const std::wstring& theName);
76 
78  MODELHIGHAPI_EXPORT
79  std::wstring name() const;
80 
82  MODELHIGHAPI_EXPORT
83  virtual ModelHighAPI_Selection result() const;
84 
86  MODELHIGHAPI_EXPORT
87  virtual std::list<ModelHighAPI_Selection> results() const;
88 
90  MODELHIGHAPI_EXPORT
91  virtual std::shared_ptr<ModelAPI_Result> defaultResult() const;
92 
94  MODELHIGHAPI_EXPORT
95  void throwException(const std::string & theDescription);
96 
98  MODELHIGHAPI_EXPORT
99  const std::string& attributeGetter(const std::string& theAttrName);
100 
102  MODELHIGHAPI_EXPORT
103  virtual void dump(ModelHighAPI_Dumper& /*theDumper*/) const {}
104 
106  MODELHIGHAPI_EXPORT virtual ListOfShape
107  vertices(const bool theOnlyUnique = false);
108 
110  MODELHIGHAPI_EXPORT virtual ListOfShape
111  edges(const bool theOnlyUnique = false);
112 
114  MODELHIGHAPI_EXPORT virtual ListOfShape
115  wires(const bool theOnlyUnique = false);
116 
118  MODELHIGHAPI_EXPORT virtual ListOfShape
119  faces(const bool theOnlyUnique = false);
120 
122  MODELHIGHAPI_EXPORT virtual ListOfShape
123  shells(const bool theOnlyUnique = false);
124 
126  MODELHIGHAPI_EXPORT virtual ListOfShape
127  solids(const bool theOnlyUnique = false);
128 
129 protected:
130  std::shared_ptr<ModelAPI_Feature> myFeature;
131 
132  std::map<std::string, std::string> myAttrGetter;
133 };
134 
136 typedef std::shared_ptr<ModelHighAPI_Interface> InterfacePtr;
137 
138 //--------------------------------------------------------------------------------------
139 //--------------------------------------------------------------------------------------
140 #endif /* SRC_MODELHIGHAPI_MODELHIGHAPI_INTERFACE_H_ */
Interface to the topological shape object.
Definition: GeomAPI_Shape.h:43
Feature function that represents the particular functionality of this operation.
Definition: ModelAPI_Feature.h:41
The result of a feature.
Definition: ModelAPI_Result.h:37
Dump engine for the model.
Definition: ModelHighAPI_Dumper.h:81
Base class for feature interfaces.
Definition: ModelHighAPI_Interface.h:46
const std::string & attributeGetter(const std::string &theAttrName)
Return name of getter for specified attribute.
Definition: ModelHighAPI_Interface.cpp:140
std::shared_ptr< ModelHighAPI_Interface > subFeature(const int theIndex) const
If feature is composite return intefrace for sub-feature by zero-based index, or empty pointer if fea...
Definition: ModelHighAPI_Interface.cpp:51
std::shared_ptr< ModelAPI_Feature > myFeature
feature of this interface
Definition: ModelHighAPI_Interface.h:130
std::shared_ptr< ModelAPI_Feature > feature() const
Return ModelAPI_Feature.
Definition: ModelHighAPI_Interface.cpp:46
std::map< std::string, std::string > myAttrGetter
names of attributes and their getters
Definition: ModelHighAPI_Interface.h:132
const std::string & getKind() const
Shortcut for feature()->getKind()
Definition: ModelHighAPI_Interface.cpp:67
ModelHighAPI_Interface(const std::shared_ptr< ModelAPI_Feature > &theFeature)
Constructor.
Definition: ModelHighAPI_Interface.cpp:33
virtual ListOfShape faces(const bool theOnlyUnique=false)
Returns all the faces produced by this feature.
Definition: ModelHighAPI_Interface.cpp:163
virtual ListOfShape wires(const bool theOnlyUnique=false)
Returns all the wires produced by this feature.
Definition: ModelHighAPI_Interface.cpp:157
virtual ModelHighAPI_Selection result() const
Return firts object of the feature.
Definition: ModelHighAPI_Interface.cpp:103
void setName(const std::wstring &theName)
Shortcut for feature()->data()->setName()
Definition: ModelHighAPI_Interface.cpp:89
virtual std::shared_ptr< ModelAPI_Result > defaultResult() const
Return default result. Default implementation feature()->lastResult()
Definition: ModelHighAPI_Interface.cpp:128
std::wstring name() const
Shortcut for feature()->data()->name()
Definition: ModelHighAPI_Interface.cpp:98
virtual void dump(ModelHighAPI_Dumper &) const
Dump wrapped feature.
Definition: ModelHighAPI_Interface.h:103
virtual ListOfShape edges(const bool theOnlyUnique=false)
Returns all the edges produced by this feature.
Definition: ModelHighAPI_Interface.cpp:151
virtual ~ModelHighAPI_Interface()
Destructor.
Definition: ModelHighAPI_Interface.cpp:40
virtual ListOfShape shells(const bool theOnlyUnique=false)
Returns all the shells produced by this feature.
Definition: ModelHighAPI_Interface.cpp:169
virtual std::list< ModelHighAPI_Selection > results() const
Return all objects of the feature.
Definition: ModelHighAPI_Interface.cpp:111
void throwException(const std::string &theDescription)
Throw exception to event loop.
Definition: ModelHighAPI_Interface.cpp:135
void execute(bool isForce=false)
Shortcut for feature()->execute()
Definition: ModelHighAPI_Interface.cpp:72
virtual ListOfShape vertices(const bool theOnlyUnique=false)
Returns all the vertices produced by this feature.
Definition: ModelHighAPI_Interface.cpp:145
virtual ListOfShape solids(const bool theOnlyUnique=false)
Returns all the solids produced by this feature.
Definition: ModelHighAPI_Interface.cpp:175
Class for filling ModelAPI_AttributeSelection.
Definition: ModelHighAPI_Selection.h:49