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(
14 const std::shared_ptr<ModelAPI_Feature>& theFeature)
15 : ModelHighAPI_Interface(theFeature)
20 //==================================================================================================
21 FeaturesAPI_Symmetry::FeaturesAPI_Symmetry(const std::shared_ptr<ModelAPI_Feature>& theFeature,
22 const std::list<ModelHighAPI_Selection>& theMainObjects,
23 const ModelHighAPI_Selection& theObject)
24 : ModelHighAPI_Interface(theFeature)
27 fillAttribute(theMainObjects, mymainObjects);
28 GeomAPI_Shape::ShapeType aType = getShapeType(theObject);
29 if(aType == GeomAPI_Shape::VERTEX) {
31 } else if(aType == GeomAPI_Shape::EDGE) {
33 } else if(aType == GeomAPI_Shape::FACE) {
39 //==================================================================================================
40 FeaturesAPI_Symmetry::~FeaturesAPI_Symmetry()
45 //==================================================================================================
46 void FeaturesAPI_Symmetry::setMainObjects(
47 const std::list<ModelHighAPI_Selection>& theMainObjects)
49 fillAttribute(theMainObjects, mainObjects());
54 //==================================================================================================
55 void FeaturesAPI_Symmetry::setPoint(const ModelHighAPI_Selection& thePointObject)
57 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_POINT(), creationMethod());
58 fillAttribute(thePointObject, pointObject());
63 //==================================================================================================
64 void FeaturesAPI_Symmetry::setAxis(const ModelHighAPI_Selection& theAxisObject)
66 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_AXIS(), creationMethod());
67 fillAttribute(theAxisObject, axisObject());
72 //==================================================================================================
73 void FeaturesAPI_Symmetry::setPlane(const ModelHighAPI_Selection& thePlaneObject)
75 fillAttribute(FeaturesPlugin_Symmetry::CREATION_METHOD_BY_PLANE(), creationMethod());
76 fillAttribute(thePlaneObject, planeObject());
81 //==================================================================================================
82 void FeaturesAPI_Symmetry::dump(ModelHighAPI_Dumper& theDumper) const
84 std::cout << "DUMP SYMMETRY" << std::endl;
85 FeaturePtr aBase = feature();
86 const std::string& aDocName = theDumper.name(aBase->document());
88 AttributeSelectionListPtr anAttrObjects =
89 aBase->selectionList(FeaturesPlugin_Symmetry::OBJECTS_LIST_ID());
90 theDumper << aBase << " = model.addSymmetry(" << aDocName << ", " << anAttrObjects;
92 std::string aCreationMethod =
93 aBase->string(FeaturesPlugin_Symmetry::CREATION_METHOD())->value();
95 if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_POINT()) {
96 AttributeSelectionPtr anAttrPoint =
97 aBase->selection(FeaturesPlugin_Symmetry::POINT_OBJECT_ID());
98 theDumper << ", " << anAttrPoint;
99 } else if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_AXIS()) {
100 AttributeSelectionPtr anAttrAxis =
101 aBase->selection(FeaturesPlugin_Symmetry::AXIS_OBJECT_ID());
102 theDumper << ", " << anAttrAxis;
103 } else if (aCreationMethod == FeaturesPlugin_Symmetry::CREATION_METHOD_BY_PLANE()) {
104 AttributeSelectionPtr anAttrPlane =
105 aBase->selection(FeaturesPlugin_Symmetry::PLANE_OBJECT_ID());
106 theDumper << ", " << anAttrPlane;
109 theDumper << ")" << std::endl;
112 //==================================================================================================
113 SymmetryPtr addSymmetry(const std::shared_ptr<ModelAPI_Document>& thePart,
114 const std::list<ModelHighAPI_Selection>& theMainObjects,
115 const ModelHighAPI_Selection& theObject)
117 std::shared_ptr<ModelAPI_Feature> aFeature = thePart->addFeature(FeaturesAPI_Symmetry::ID());
118 return SymmetryPtr(new FeaturesAPI_Symmetry(aFeature, theMainObjects, theObject));