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 setByBasePath(theBaseObjects, thePath);
30 //==================================================================================================
31 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
32 const std::list<ModelHighAPI_Selection>& theBaseObjects,
33 const ModelHighAPI_Selection& thePath,
34 const ModelHighAPI_Selection& theBiNoramal)
35 : ModelHighAPI_Interface(theFeature)
38 setByBasePathBiNormal(theBaseObjects, thePath, theBiNoramal);
42 //==================================================================================================
43 FeaturesAPI_Pipe::FeaturesAPI_Pipe(const std::shared_ptr<ModelAPI_Feature>& theFeature,
44 const std::list<ModelHighAPI_Selection>& theBaseObjects,
45 const ModelHighAPI_Selection& thePath,
46 const std::list<ModelHighAPI_Selection>& theLocations)
47 : ModelHighAPI_Interface(theFeature)
50 setByBasePathLocations(theBaseObjects, thePath, theLocations);
54 //==================================================================================================
55 FeaturesAPI_Pipe::~FeaturesAPI_Pipe()
60 //==================================================================================================
61 void FeaturesAPI_Pipe::setBase(const std::list<ModelHighAPI_Selection>& theBaseObjects)
63 fillAttribute(theBaseObjects, mybaseObjects);
68 //==================================================================================================
69 void FeaturesAPI_Pipe::setPath(const ModelHighAPI_Selection& thePath)
71 fillAttribute(thePath, mypath);
76 //==================================================================================================
77 void FeaturesAPI_Pipe::setByBasePath(const std::list<ModelHighAPI_Selection>& theBaseObjects,
78 const ModelHighAPI_Selection& thePath)
80 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE(), mycreationMethod);
81 fillAttribute(theBaseObjects, mybaseObjects);
82 fillAttribute(thePath, mypath);
87 //==================================================================================================
88 void FeaturesAPI_Pipe::setByBasePathBiNormal(const std::list<ModelHighAPI_Selection>& theBaseObjects,
89 const ModelHighAPI_Selection& thePath,
90 const ModelHighAPI_Selection& theBiNoramal)
92 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL(), mycreationMethod);
93 fillAttribute(theBaseObjects, mybaseObjects);
94 fillAttribute(thePath, mypath);
95 fillAttribute(theBiNoramal, mybiNormal);
100 //==================================================================================================
101 void FeaturesAPI_Pipe::setByBasePathLocations(const std::list<ModelHighAPI_Selection>& theBaseObjects,
102 const ModelHighAPI_Selection& thePath,
103 const std::list<ModelHighAPI_Selection>& theLocations)
105 fillAttribute(FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS(), mycreationMethod);
106 fillAttribute(theBaseObjects, mybaseObjects);
107 fillAttribute(thePath, mypath);
108 fillAttribute(theLocations, mylocations);
113 //==================================================================================================
114 void FeaturesAPI_Pipe::dump(ModelHighAPI_Dumper& theDumper) const
116 FeaturePtr aBase = feature();
117 const std::string& aDocName = theDumper.name(aBase->document());
119 AttributeSelectionListPtr anAttrObjects = aBase->selectionList(FeaturesPlugin_Pipe::BASE_OBJECTS_ID());
120 AttributeSelectionPtr anAttrPath = aBase->selection(FeaturesPlugin_Pipe::PATH_OBJECT_ID());
122 theDumper << aBase << " = model.addPipe(" << aDocName << ", "
123 << anAttrObjects << ", " << anAttrPath;
125 std::string aCreationMethod = aBase->string(FeaturesPlugin_Pipe::CREATION_METHOD())->value();
127 if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_SIMPLE()) {
129 } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_BINORMAL()) {
130 AttributeSelectionPtr anAttrBiNormal = aBase->selection(FeaturesPlugin_Pipe::BINORMAL_ID());
132 theDumper << ", " << anAttrBiNormal;
133 } else if(aCreationMethod == FeaturesPlugin_Pipe::CREATION_METHOD_LOCATIONS()) {
134 AttributeSelectionListPtr anAttrLocations = aBase->selectionList(FeaturesPlugin_Pipe::LOCATIONS_ID());
136 theDumper << ", " << anAttrLocations;
139 theDumper << ")" << std::endl;
142 //==================================================================================================
143 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
144 const std::list<ModelHighAPI_Selection>& theBaseObjects,
145 const ModelHighAPI_Selection& thePath)
147 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
148 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath));
151 //==================================================================================================
152 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
153 const std::list<ModelHighAPI_Selection>& theBaseObjects,
154 const ModelHighAPI_Selection& thePath,
155 const ModelHighAPI_Selection& theBiNoramal)
157 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
158 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theBiNoramal));
161 //==================================================================================================
162 PipePtr addPipe(const std::shared_ptr<ModelAPI_Document>& thePart,
163 const std::list<ModelHighAPI_Selection>& theBaseObjects,
164 const ModelHighAPI_Selection& thePath,
165 const std::list<ModelHighAPI_Selection>& theLocations)
167 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Pipe::ID());
168 return PipePtr(new FeaturesAPI_Pipe(aFeature, theBaseObjects, thePath, theLocations));