1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "FeaturesAPI_Pipe.h"
23 #include <ModelHighAPI_Dumper.h>
24 #include <ModelHighAPI_Tools.h>
26 //==================================================================================================
27 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature)
28 : ModelHighAPI_Interface(theFeature)
33 //==================================================================================================
34 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
35 const std::list<ModelHighAPI_Selection>& theBaseObjects,
36 const ModelHighAPI_Selection& thePath)
37 : ModelHighAPI_Interface(theFeature)
40 setByBasePath(theBaseObjects, thePath);
44 //==================================================================================================
45 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
46 const std::list<ModelHighAPI_Selection>& theBaseObjects,
47 const ModelHighAPI_Selection& thePath,
48 const ModelHighAPI_Selection& theBiNoramal)
49 : ModelHighAPI_Interface(theFeature)
52 setByBasePathBiNormal(theBaseObjects, thePath, theBiNoramal);
56 //==================================================================================================
57 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
58 const std::list<ModelHighAPI_Selection>& theBaseObjects,
59 const ModelHighAPI_Selection& thePath,
60 const std::list<ModelHighAPI_Selection>& theLocations)
61 : ModelHighAPI_Interface(theFeature)
64 setByBasePathLocations(theBaseObjects, thePath, theLocations);
68 //==================================================================================================
69 FeaturesAPI_Pipe::~FeaturesAPI_Pipe()
74 //==================================================================================================
75 void FeaturesAPI_Pipe::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
77 fillAttribute(theBaseObjects, mybaseObjects);
82 //==================================================================================================
83 void FeaturesAPI_Pipe::setPath(const ModelHighAPI_Selection& thePath)
85 fillAttribute(thePath, mypath);
90 //==================================================================================================
91 void FeaturesAPI_Pipe::setByBasePath(const std::list<ModelHighAPI_Selection>& theBaseObjects,
92 const ModelHighAPI_Selection& thePath)
94 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE(), mycreationMethod);
95 fillAttribute(theBaseObjects, mybaseObjects);
96 fillAttribute(thePath, mypath);
101 //==================================================================================================
102 void FeaturesAPI_Pipe::setByBasePathBiNormal(
103 const std::list<ModelHighAPI_Selection>& theBaseObjects,
104 const ModelHighAPI_Selection& thePath,
105 const ModelHighAPI_Selection& theBiNoramal)
107 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL(), mycreationMethod);
108 fillAttribute(theBaseObjects, mybaseObjects);
109 fillAttribute(thePath, mypath);
110 fillAttribute(theBiNoramal, mybiNormal);
115 //==================================================================================================
116 void FeaturesAPI_Pipe::setByBasePathLocations(
117 const std::list<ModelHighAPI_Selection>& theBaseObjects,
118 const ModelHighAPI_Selection& thePath,
119 const std::list<ModelHighAPI_Selection>& theLocations)
121 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS(), mycreationMethod);
122 fillAttribute(theBaseObjects, mybaseObjects);
123 fillAttribute(thePath, mypath);
124 fillAttribute(theLocations, mylocations);
129 //==================================================================================================
130 void FeaturesAPI_Pipe::dump(ModelHighAPI_Dumper& theDumper) const
132 FeaturePtr aBase = feature();
133 const std::string& aDocName = theDumper.name(aBase->document());
135 AttributeSelectionListPtr anAttrObjects =
136 aBase->selectionList(FeaturesPlugin_Pipe::BASE_OBJECTS_ID());
137 AttributeSelectionPtr anAttrPath = aBase->selection(FeaturesPlugin_Pipe::PATH_OBJECT_ID());
139 theDumper << aBase << " = model.addPipe(" << aDocName << ", "
140 << anAttrObjects << ", " << anAttrPath;
142 std::string aCreationMethod = aBase->string(FeaturesPlugin_Pipe::CREATION_METHOD())->value();
144 if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE()) {
146 } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL()) {
147 AttributeSelectionPtr anAttrBiNormal = aBase->selection(FeaturesPlugin_Pipe::BINORMAL_ID());
149 theDumper << ", " << anAttrBiNormal;
150 } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS()) {
151 AttributeSelectionListPtr anAttrLocations =
152 aBase->selectionList(FeaturesPlugin_Pipe::LOCATIONS_ID());
154 theDumper << ", " << anAttrLocations;
157 theDumper << ")" << std::endl;
160 //==================================================================================================
161 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
162 const std::list<ModelHighAPI_Selection>& theBaseObjects,
163 const ModelHighAPI_Selection& thePath)
165 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
166 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath));
169 //==================================================================================================
170 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
171 const std::list<ModelHighAPI_Selection>& theBaseObjects,
172 const ModelHighAPI_Selection& thePath,
173 const ModelHighAPI_Selection& theBiNoramal)
175 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
176 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theBiNoramal));
179 //==================================================================================================
180 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
181 const std::list<ModelHighAPI_Selection>& theBaseObjects,
182 const ModelHighAPI_Selection& thePath,
183 const std::list<ModelHighAPI_Selection>& theLocations)
185 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
186 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theLocations));