1 // Copyright (C) 2014-2023 CEA, EDF
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "FeaturesAPI_Pipe.h"
22 #include <ModelHighAPI_Dumper.h>
23 #include <ModelHighAPI_Tools.h>
25 //==================================================================================================
26 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature)
27 : ModelHighAPI_Interface(theFeature)
32 //==================================================================================================
33 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
34 const std::list<ModelHighAPI_Selection>& theBaseObjects,
35 const ModelHighAPI_Selection& thePath)
36 : ModelHighAPI_Interface(theFeature)
39 setByBasePath(theBaseObjects, thePath);
43 //==================================================================================================
44 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
45 const std::list<ModelHighAPI_Selection>& theBaseObjects,
46 const ModelHighAPI_Selection& thePath,
47 const ModelHighAPI_Selection& theBiNoramal)
48 : ModelHighAPI_Interface(theFeature)
51 setByBasePathBiNormal(theBaseObjects, thePath, theBiNoramal);
55 //==================================================================================================
56 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
57 const std::list<ModelHighAPI_Selection>& theBaseObjects,
58 const ModelHighAPI_Selection& thePath,
59 const std::list<ModelHighAPI_Selection>& theLocations)
60 : ModelHighAPI_Interface(theFeature)
63 setByBasePathLocations(theBaseObjects, thePath, theLocations);
67 //==================================================================================================
68 FeaturesAPI_Pipe::~FeaturesAPI_Pipe()
73 //==================================================================================================
74 void FeaturesAPI_Pipe::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
76 fillAttribute(theBaseObjects, mybaseObjects);
81 //==================================================================================================
82 void FeaturesAPI_Pipe::setPath(const ModelHighAPI_Selection& thePath)
84 fillAttribute(thePath, mypath);
89 //==================================================================================================
90 void FeaturesAPI_Pipe::setByBasePath(const std::list<ModelHighAPI_Selection>& theBaseObjects,
91 const ModelHighAPI_Selection& thePath)
93 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE(), mycreationMethod);
94 fillAttribute(theBaseObjects, mybaseObjects);
95 fillAttribute(thePath, mypath);
100 //==================================================================================================
101 void FeaturesAPI_Pipe::setByBasePathBiNormal(
102 const std::list<ModelHighAPI_Selection>& theBaseObjects,
103 const ModelHighAPI_Selection& thePath,
104 const ModelHighAPI_Selection& theBiNoramal)
106 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL(), mycreationMethod);
107 fillAttribute(theBaseObjects, mybaseObjects);
108 fillAttribute(thePath, mypath);
109 fillAttribute(theBiNoramal, mybiNormal);
114 //==================================================================================================
115 void FeaturesAPI_Pipe::setByBasePathLocations(
116 const std::list<ModelHighAPI_Selection>& theBaseObjects,
117 const ModelHighAPI_Selection& thePath,
118 const std::list<ModelHighAPI_Selection>& theLocations)
120 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS(), mycreationMethod);
121 fillAttribute(theBaseObjects, mybaseObjects);
122 fillAttribute(thePath, mypath);
123 fillAttribute(theLocations, mylocations);
128 //==================================================================================================
129 void FeaturesAPI_Pipe::dump(ModelHighAPI_Dumper& theDumper) const
131 FeaturePtr aBase = feature();
132 const std::string& aDocName = theDumper.name(aBase->document());
134 AttributeSelectionListPtr anAttrObjects =
135 aBase->selectionList(FeaturesPlugin_Pipe::BASE_OBJECTS_ID());
136 AttributeSelectionPtr anAttrPath = aBase->selection(FeaturesPlugin_Pipe::PATH_OBJECT_ID());
138 theDumper << aBase << " = model.addPipe(" << aDocName << ", "
139 << anAttrObjects << ", " << anAttrPath;
141 std::string aCreationMethod = aBase->string(FeaturesPlugin_Pipe::CREATION_METHOD())->value();
143 if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE()) {
145 } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL()) {
146 AttributeSelectionPtr anAttrBiNormal = aBase->selection(FeaturesPlugin_Pipe::BINORMAL_ID());
148 theDumper << ", " << anAttrBiNormal;
149 } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS()) {
150 AttributeSelectionListPtr anAttrLocations =
151 aBase->selectionList(FeaturesPlugin_Pipe::LOCATIONS_ID());
153 theDumper << ", " << anAttrLocations;
156 theDumper << ")" << std::endl;
159 //==================================================================================================
160 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
161 const std::list<ModelHighAPI_Selection>& theBaseObjects,
162 const ModelHighAPI_Selection& thePath)
164 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
165 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath));
168 //==================================================================================================
169 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
170 const std::list<ModelHighAPI_Selection>& theBaseObjects,
171 const ModelHighAPI_Selection& thePath,
172 const ModelHighAPI_Selection& theBiNoramal)
174 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
175 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theBiNoramal));
178 //==================================================================================================
179 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
180 const std::list<ModelHighAPI_Selection>& theBaseObjects,
181 const ModelHighAPI_Selection& thePath,
182 const std::list<ModelHighAPI_Selection>& theLocations)
184 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
185 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theLocations));