1 // Copyright (C) 2014-2016 CEA/DEN, EDF R&D -->
3 // File: FeaturesAPI_Symmetry.cpp
4 // Created: 07 Dec 2016
5 // Author: Clarisse Genrault (CEA)
7 #include "FeaturesAPI_Symmetry.h"
9 #include <ModelHighAPI_Dumper.h>
10 #include <ModelHighAPI_Tools.h>
12 //==================================================================================================
13 FeaturesAPI_Symmetry::FeaturesAPI_Symmetry(const std::shared_ptr<ModelAPI_Feature>& theFeature)
14 : ModelHighAPI_Interface(theFeature)
19 //==================================================================================================
20 FeaturesAPI_Symmetry::FeaturesAPI_Symmetry(const std::shared_ptr<ModelAPI_Feature>& theFeature,
21 const std::list<ModelHighAPI_Selection>& theMainObjects,
22 const ModelHighAPI_Selection& theObject)
23 : ModelHighAPI_Interface(theFeature)
26 fillAttribute(theMainObjects, mainObjects());
27 GeomAPI_Shape::ShapeType aType = getShapeType(theObject);
28 if(aType == GeomAPI_Shape::VERTEX) {
30 } else if(aType == GeomAPI_Shape::EDGE) {
32 } else if(aType == GeomAPI_Shape::FACE) {
38 //==================================================================================================
39 FeaturesAPI_Symmetry::~FeaturesAPI_Symmetry()
43 //==================================================================================================
44 void FeaturesAPI_Symmetry::setMainObjects(
45 const std::list<ModelHighAPI_Selection>& theMainObjects)
47 fillAttribute(theMainObjects, mainObjects());
52 //==================================================================================================
53 void FeaturesAPI_Symmetry::setPoint(const ModelHighAPI_Selection& thePointObject)
55 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_POINT(), creationMethod());
56 fillAttribute(thePointObject, pointObject());
61 //==================================================================================================
62 void FeaturesAPI_Symmetry::setAxis(const ModelHighAPI_Selection& theAxisObject)
64 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_AXIS(), creationMethod());
65 fillAttribute(theAxisObject, axisObject());
70 //==================================================================================================
71 void FeaturesAPI_Symmetry::setPlane(const ModelHighAPI_Selection& thePlaneObject)
73 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_PLANE(), creationMethod());
74 fillAttribute(thePlaneObject, planeObject());
79 //==================================================================================================
80 void FeaturesAPI_Symmetry::dump(ModelHighAPI_Dumper& theDumper) const
82 FeaturePtr aBase = feature();
83 const std::string& aDocName = theDumper.name(aBase->document());
85 AttributeSelectionListPtr anAttrObjects =
86 aBase->selectionList(FeaturesPlugin_Symmetry::OBJECTS_LIST_ID());
87 theDumper << aBase << " = model.addSymmetry(" << aDocName << ", " << anAttrObjects;
89 std::string aCreationMethod =
90 aBase->string(FeaturesPlugin_Symmetry::CREATION_METHOD())->value();
92 if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_POINT()) {
93 AttributeSelectionPtr anAttrPoint =
94 aBase->selection(FeaturesPlugin_Symmetry::POINT_OBJECT_ID());
95 theDumper << ", " << anAttrPoint;
96 } else if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_AXIS()) {
97 AttributeSelectionPtr anAttrAxis =
98 aBase->selection(FeaturesPlugin_Symmetry::AXIS_OBJECT_ID());
99 theDumper << ", " << anAttrAxis;
100 } else if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_PLANE()) {
101 AttributeSelectionPtr anAttrPlane =
102 aBase->selection(FeaturesPlugin_Symmetry::PLANE_OBJECT_ID());
103 theDumper << ", " << anAttrPlane;
106 theDumper << ")" << std::endl;
109 //==================================================================================================
110 SymmetryPtr addSymmetry(const std::shared_ptr<ModelAPI_Document>& thePart,
111 const std::list<ModelHighAPI_Selection>& theMainObjects,
112 const ModelHighAPI_Selection& theObject)
114 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Symmetry::ID());
115 return SymmetryPtr(new FeaturesAPI_Symmetry(aFeature, theMainObjects, theObject));