1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Pipe.cpp
4 // Created: 09 June 2016
5 // Author: Dmitry Bobylev
7 #include "FeaturesAPI_Pipe.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
12 //==================================================================================================
13 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
19 //==================================================================================================
20 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21 const std::list<ModelHighAPI_Selection>& theBaseObjects,
22 const ModelHighAPI_Selection& thePath)
23 : ModelHighAPI_Interface(theFeature)
26 fillAttribute(theBaseObjects, mybaseObjects);
31 //==================================================================================================
32 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
33 const std::list<ModelHighAPI_Selection>& theBaseObjects,
34 const ModelHighAPI_Selection& thePath,
35 const ModelHighAPI_Selection& theBiNoramal)
36 : ModelHighAPI_Interface(theFeature)
39 setByBasePathBiNormal(theBaseObjects, thePath, theBiNoramal);
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 std::list<ModelHighAPI_Selection>& theLocations)
48 : ModelHighAPI_Interface(theFeature)
51 setByBasePathLocations(theBaseObjects, thePath, theLocations);
55 //==================================================================================================
56 FeaturesAPI_Pipe::~FeaturesAPI_Pipe()
61 //==================================================================================================
62 void FeaturesAPI_Pipe::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
64 fillAttribute(theBaseObjects, mybaseObjects);
69 //==================================================================================================
70 void FeaturesAPI_Pipe::setPath(const ModelHighAPI_Selection& thePath)
72 fillAttribute(thePath, mypath);
77 //==================================================================================================
78 void FeaturesAPI_Pipe::setByBasePath(const std::list<ModelHighAPI_Selection>& theBaseObjects,
79 const ModelHighAPI_Selection& thePath)
81 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE(), mycreationMethod);
82 fillAttribute(theBaseObjects, mybaseObjects);
83 fillAttribute(thePath, mypath);
88 //==================================================================================================
89 void FeaturesAPI_Pipe::setByBasePathBiNormal(const std::list<ModelHighAPI_Selection>& theBaseObjects,
90 const ModelHighAPI_Selection& thePath,
91 const ModelHighAPI_Selection& theBiNoramal)
93 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL(), mycreationMethod);
94 fillAttribute(theBaseObjects, mybaseObjects);
95 fillAttribute(thePath, mypath);
96 fillAttribute(theBiNoramal, mybiNormal);
101 //==================================================================================================
102 void FeaturesAPI_Pipe::setByBasePathLocations(const std::list<ModelHighAPI_Selection>& theBaseObjects,
103 const ModelHighAPI_Selection& thePath,
104 const std::list<ModelHighAPI_Selection>& theLocations)
106 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS(), mycreationMethod);
107 fillAttribute(theBaseObjects, mybaseObjects);
108 fillAttribute(thePath, mypath);
109 fillAttribute(theLocations, mylocations);
114 //==================================================================================================
115 void FeaturesAPI_Pipe::dump(ModelHighAPI_Dumper& theDumper) const
117 FeaturePtr aBase = feature();
118 const std::string& aDocName = theDumper.name(aBase->document());
120 AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Pipe::BASE_OBJECTS_ID());
121 AttributeSelectionPtr anAttrPath = aBase->selection(FeaturesPlugin_Pipe::PATH_OBJECT_ID());
123 theDumper << aBase << " = model.addPipe(" << aDocName << ", "
124 << anAttrObjects << ", " << anAttrPath;
126 std::string aCreationMethod = aBase->string(FeaturesPlugin_Pipe::CREATION_METHOD())->value();
128 if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE()) {
130 } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL()) {
131 AttributeSelectionPtr anAttrBiNormal = aBase->selection(FeaturesPlugin_Pipe::BINORMAL_ID());
133 theDumper << ", " << anAttrBiNormal;
134 } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS()) {
135 AttributeSelectionListPtr anAttrLocations = aBase->selectionList(FeaturesPlugin_Pipe::LOCATIONS_ID());
137 theDumper << ", " << anAttrLocations;
140 theDumper << ")" << std::endl;
143 //==================================================================================================
144 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
145 const std::list<ModelHighAPI_Selection>& theBaseObjects,
146 const ModelHighAPI_Selection& thePath)
148 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
149 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath));
152 //==================================================================================================
153 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
154 const std::list<ModelHighAPI_Selection>& theBaseObjects,
155 const ModelHighAPI_Selection& thePath,
156 const ModelHighAPI_Selection& theBiNoramal)
158 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
159 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theBiNoramal));
162 //==================================================================================================
163 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
164 const std::list<ModelHighAPI_Selection>& theBaseObjects,
165 const ModelHighAPI_Selection& thePath,
166 const std::list<ModelHighAPI_Selection>& theLocations)
168 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
169 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theLocations));