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_Symmetry.h"
23 #include <ModelHighAPI_Dumper.h>
24 #include <ModelHighAPI_Tools.h>
26 //==================================================================================================
27 FeaturesAPI_Symmetry::FeaturesAPI_Symmetry(const std::shared_ptr<ModelAPI_Feature>& theFeature)
28 : ModelHighAPI_Interface(theFeature)
33 //==================================================================================================
34 FeaturesAPI_Symmetry::FeaturesAPI_Symmetry(const std::shared_ptr<ModelAPI_Feature>& theFeature,
35 const std::list<ModelHighAPI_Selection>& theMainObjects,
36 const ModelHighAPI_Selection& theObject,
38 : ModelHighAPI_Interface(theFeature)
41 fillAttribute(theMainObjects, mainObjects());
42 fillAttribute(theKeepOriginal, keepOriginal());
43 GeomAPI_Shape::ShapeType aType = getShapeType(theObject);
44 if(aType == GeomAPI_Shape::VERTEX) {
46 } else if(aType == GeomAPI_Shape::EDGE) {
48 } else if(aType == GeomAPI_Shape::FACE) {
54 //==================================================================================================
55 FeaturesAPI_Symmetry::~FeaturesAPI_Symmetry()
59 //==================================================================================================
60 void FeaturesAPI_Symmetry::setMainObjects(
61 const std::list<ModelHighAPI_Selection>& theMainObjects)
63 fillAttribute(theMainObjects, mainObjects());
68 //==================================================================================================
69 void FeaturesAPI_Symmetry::setPoint(const ModelHighAPI_Selection& thePointObject)
71 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_POINT(), creationMethod());
72 fillAttribute(thePointObject, pointObject());
77 //==================================================================================================
78 void FeaturesAPI_Symmetry::setAxis(const ModelHighAPI_Selection& theAxisObject)
80 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_AXIS(), creationMethod());
81 fillAttribute(theAxisObject, axisObject());
86 //==================================================================================================
87 void FeaturesAPI_Symmetry::setPlane(const ModelHighAPI_Selection& thePlaneObject)
89 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_PLANE(), creationMethod());
90 fillAttribute(thePlaneObject, planeObject());
95 //==================================================================================================
96 void FeaturesAPI_Symmetry::dump(ModelHighAPI_Dumper& theDumper) const
98 FeaturePtr aBase = feature();
99 const std::string& aDocName = theDumper.name(aBase->document());
101 AttributeSelectionListPtr anAttrObjects =
102 aBase->selectionList(FeaturesPlugin_Symmetry::OBJECTS_LIST_ID());
103 theDumper << aBase << " = model.addSymmetry(" << aDocName << ", " << anAttrObjects;
105 std::string aCreationMethod =
106 aBase->string(FeaturesPlugin_Symmetry::CREATION_METHOD())->value();
108 if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_POINT()) {
109 AttributeSelectionPtr anAttrPoint =
110 aBase->selection(FeaturesPlugin_Symmetry::POINT_OBJECT_ID());
111 theDumper << ", " << anAttrPoint;
112 } else if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_AXIS()) {
113 AttributeSelectionPtr anAttrAxis =
114 aBase->selection(FeaturesPlugin_Symmetry::AXIS_OBJECT_ID());
115 theDumper << ", " << anAttrAxis;
116 } else if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_PLANE()) {
117 AttributeSelectionPtr anAttrPlane =
118 aBase->selection(FeaturesPlugin_Symmetry::PLANE_OBJECT_ID());
119 theDumper << ", " << anAttrPlane;
122 theDumper << ", " << keepOriginal() << ")" << std::endl;
125 //==================================================================================================
126 SymmetryPtr addSymmetry(const std::shared_ptr<ModelAPI_Document>& thePart,
127 const std::list<ModelHighAPI_Selection>& theMainObjects,
128 const ModelHighAPI_Selection& theObject,
129 bool theKeepOriginal)
131 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Symmetry::ID());
132 return SymmetryPtr(new FeaturesAPI_Symmetry(
133 aFeature, theMainObjects, theObject, theKeepOriginal));