1 // Copyright (C) 2014-2022 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 email : webmaster.salome@opencascade.com
20 #include "FeaturesAPI_Sewing.h"
22 #include <ModelHighAPI_Double.h>
23 #include <ModelHighAPI_Dumper.h>
24 #include <ModelHighAPI_Tools.h>
26 //==================================================================================================
27 FeaturesAPI_Sewing::FeaturesAPI_Sewing(const std::shared_ptr<ModelAPI_Feature>& theFeature)
28 : ModelHighAPI_Interface(theFeature)
33 //==================================================================================================
34 FeaturesAPI_Sewing::FeaturesAPI_Sewing(const std::shared_ptr<ModelAPI_Feature>& theFeature,
35 const std::list<ModelHighAPI_Selection>& theMainObjects,
36 const ModelHighAPI_Double& theTolerance,
37 bool theIsAllowNonManifold/*=false*/,
38 bool theIsAlwaysCreateResult/*=true*/)
39 : ModelHighAPI_Interface(theFeature)
42 fillAttribute(theMainObjects, mainObjects());
43 setTolerance(theTolerance);
44 setIsAllowNonManifold(theIsAllowNonManifold);
45 setIsAlwaysCreateResult(theIsAlwaysCreateResult);
49 //==================================================================================================
50 FeaturesAPI_Sewing::~FeaturesAPI_Sewing()
54 //==================================================================================================
55 void FeaturesAPI_Sewing::setMainObjects(const std::list<ModelHighAPI_Selection>& theMainObjects)
57 fillAttribute(theMainObjects, mainObjects());
61 //==================================================================================================
62 void FeaturesAPI_Sewing::setTolerance(const ModelHighAPI_Double& theTolerance)
64 fillAttribute(theTolerance, tolerance());
68 //==================================================================================================
69 void FeaturesAPI_Sewing::setIsAllowNonManifold(bool theFlag)
71 fillAttribute(theFlag, isAllowNonManifold());
75 //==================================================================================================
76 void FeaturesAPI_Sewing::setIsAlwaysCreateResult(bool theFlag)
78 fillAttribute(theFlag, isAlwaysCreateResult());
82 //==================================================================================================
83 void FeaturesAPI_Sewing::dump(ModelHighAPI_Dumper& theDumper) const
85 FeaturePtr aBase = feature();
86 const std::string& aDocName = theDumper.name(aBase->document());
88 AttributeSelectionListPtr anAttrObjects =
89 aBase->selectionList(FeaturesPlugin_Sewing::OBJECTS_LIST_ID());
90 theDumper << aBase << " = model.addSewing(" << aDocName << ", " << anAttrObjects;
92 AttributeDoublePtr anAttrTolerance = aBase->real(FeaturesPlugin_Sewing::TOLERANCE_ID());
93 theDumper << ", " << anAttrTolerance;
95 AttributeBooleanPtr anAttrAllowNonMFold = aBase->boolean(FeaturesPlugin_Sewing::ALLOW_NON_MANIFOLD_ID());
96 theDumper << ", " << anAttrAllowNonMFold;
98 AttributeBooleanPtr anAttrAlwaysResult = aBase->boolean(FeaturesPlugin_Sewing::ALWAYS_CREATE_RESULT_ID());
99 theDumper << ", " << anAttrAlwaysResult;
101 theDumper << ")" << std::endl;
104 //==================================================================================================
105 SewingPtr addSewing(const std::shared_ptr<ModelAPI_Document>& thePart,
106 const std::list<ModelHighAPI_Selection>& theMainObjects,
107 const ModelHighAPI_Double& theTolerance,
108 const bool theIsAllowNonManifold,
109 const bool theIsAlwaysCreateResult)
111 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Sewing::ID());
113 aSewing.reset(new FeaturesAPI_Sewing(aFeature, theMainObjects, theTolerance, theIsAllowNonManifold, theIsAlwaysCreateResult));