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 email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
20 #include "FeaturesAPI_Symmetry.h"
22 #include <ModelHighAPI_Dumper.h>
23 #include <ModelHighAPI_Tools.h>
25 //==================================================================================================
26 FeaturesAPI_Symmetry::FeaturesAPI_Symmetry(const std::shared_ptr<ModelAPI_Feature>& theFeature)
27 : ModelHighAPI_Interface(theFeature)
32 //==================================================================================================
33 FeaturesAPI_Symmetry::FeaturesAPI_Symmetry(const std::shared_ptr<ModelAPI_Feature>& theFeature,
34 const std::list<ModelHighAPI_Selection>& theMainObjects,
35 const ModelHighAPI_Selection& theObject)
36 : ModelHighAPI_Interface(theFeature)
39 fillAttribute(theMainObjects, mainObjects());
40 GeomAPI_Shape::ShapeType aType = getShapeType(theObject);
41 if(aType == GeomAPI_Shape::VERTEX) {
43 } else if(aType == GeomAPI_Shape::EDGE) {
45 } else if(aType == GeomAPI_Shape::FACE) {
51 //==================================================================================================
52 FeaturesAPI_Symmetry::~FeaturesAPI_Symmetry()
56 //==================================================================================================
57 void FeaturesAPI_Symmetry::setMainObjects(
58 const std::list<ModelHighAPI_Selection>& theMainObjects)
60 fillAttribute(theMainObjects, mainObjects());
65 //==================================================================================================
66 void FeaturesAPI_Symmetry::setPoint(const ModelHighAPI_Selection& thePointObject)
68 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_POINT(), creationMethod());
69 fillAttribute(thePointObject, pointObject());
74 //==================================================================================================
75 void FeaturesAPI_Symmetry::setAxis(const ModelHighAPI_Selection& theAxisObject)
77 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_AXIS(), creationMethod());
78 fillAttribute(theAxisObject, axisObject());
83 //==================================================================================================
84 void FeaturesAPI_Symmetry::setPlane(const ModelHighAPI_Selection& thePlaneObject)
86 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_PLANE(), creationMethod());
87 fillAttribute(thePlaneObject, planeObject());
92 //==================================================================================================
93 void FeaturesAPI_Symmetry::dump(ModelHighAPI_Dumper& theDumper) const
95 FeaturePtr aBase = feature();
96 const std::string& aDocName = theDumper.name(aBase->document());
98 AttributeSelectionListPtr anAttrObjects =
99 aBase->selectionList(FeaturesPlugin_Symmetry::OBJECTS_LIST_ID());
100 theDumper << aBase << " = model.addSymmetry(" << aDocName << ", " << anAttrObjects;
102 std::string aCreationMethod =
103 aBase->string(FeaturesPlugin_Symmetry::CREATION_METHOD())->value();
105 if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_POINT()) {
106 AttributeSelectionPtr anAttrPoint =
107 aBase->selection(FeaturesPlugin_Symmetry::POINT_OBJECT_ID());
108 theDumper << ", " << anAttrPoint;
109 } else if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_AXIS()) {
110 AttributeSelectionPtr anAttrAxis =
111 aBase->selection(FeaturesPlugin_Symmetry::AXIS_OBJECT_ID());
112 theDumper << ", " << anAttrAxis;
113 } else if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_PLANE()) {
114 AttributeSelectionPtr anAttrPlane =
115 aBase->selection(FeaturesPlugin_Symmetry::PLANE_OBJECT_ID());
116 theDumper << ", " << anAttrPlane;
119 theDumper << ")" << std::endl;
122 //==================================================================================================
123 SymmetryPtr addSymmetry(const std::shared_ptr<ModelAPI_Document>& thePart,
124 const std::list<ModelHighAPI_Selection>& theMainObjects,
125 const ModelHighAPI_Selection& theObject)
127 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Symmetry::ID());
128 return SymmetryPtr(new FeaturesAPI_Symmetry(aFeature, theMainObjects, theObject));