1 // Copyright (C) 2014-2021 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_NormalToFace.h"
22 #include <ModelHighAPI_Dumper.h>
23 #include <ModelHighAPI_Selection.h>
24 #include <ModelHighAPI_Tools.h>
26 //=================================================================================================
27 FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
28 const std::shared_ptr<ModelAPI_Feature>& theFeature)
29 : ModelHighAPI_Interface(theFeature)
34 //=================================================================================================
35 FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
36 const std::shared_ptr<ModelAPI_Feature>& theFeature,
37 const ModelHighAPI_Selection& theBaseFace,
38 const ModelHighAPI_Selection& theOptionalPoint)
39 :ModelHighAPI_Interface(theFeature)
42 fillAttribute(theBaseFace, myfaceSelected);
43 fillAttribute(theOptionalPoint, myvertexSelected);
44 feature()->string(FeaturesPlugin_NormalToFace::VERTEX_OPTION_ID())->setValue("true");
49 //=================================================================================================
50 FeaturesAPI_NormalToFace::FeaturesAPI_NormalToFace(
51 const std::shared_ptr<ModelAPI_Feature>& theFeature,
52 const ModelHighAPI_Selection& theBaseFace)
53 :ModelHighAPI_Interface(theFeature)
56 fillAttribute(theBaseFace, myfaceSelected);
57 feature()->string(FeaturesPlugin_NormalToFace::VERTEX_OPTION_ID())->setValue("");
62 //=================================================================================================
63 FeaturesAPI_NormalToFace::~FeaturesAPI_NormalToFace()
67 //=================================================================================================
68 void FeaturesAPI_NormalToFace::dump(ModelHighAPI_Dumper& theDumper) const
70 FeaturePtr aBase = feature();
71 const std::string& aDocName = theDumper.name(aBase->document());
73 AttributeSelectionPtr anAttrObject;
74 anAttrObject = aBase->selection(FeaturesPlugin_NormalToFace::FACE_SELECTED_ID());
76 theDumper << aBase << " = model.getNormal(" << aDocName << ", " << anAttrObject;
78 if (!aBase->string(FeaturesPlugin_NormalToFace::VERTEX_OPTION_ID())->value().empty()) {
80 AttributeSelectionPtr anAttrVertex =
81 aBase->selection(FeaturesPlugin_NormalToFace::VERTEX_SELECTED_ID());
83 theDumper << ", " << anAttrVertex;
86 theDumper << ")" << std::endl;
89 //==================================================================================================
90 NormalPtr getNormal(const std::shared_ptr<ModelAPI_Document>& thePart,
91 const ModelHighAPI_Selection& theBaseFace,
92 const ModelHighAPI_Selection& theOptionalPoint)
95 FeaturePtr aFeature = thePart->addFeature(FeaturesPlugin_NormalToFace::ID());
96 NormalPtr aNormalToface;
97 aNormalToface.reset(new FeaturesAPI_NormalToFace(aFeature, theBaseFace, theOptionalPoint));
102 //=================================================================================================
103 NormalPtr getNormal(const std::shared_ptr<ModelAPI_Document>& thePart,
104 const ModelHighAPI_Selection& theBaseFace)
107 FeaturePtr aFeature = thePart->addFeature(FeaturesPlugin_NormalToFace::ID());
108 NormalPtr aNormalToface;
109 aNormalToface.reset(new FeaturesAPI_NormalToFace(aFeature, theBaseFace));
111 return aNormalToface;