1 // Name : SketchAPI_Mirror.cpp
5 // 16/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_Mirror.h"
9 #include <SketchAPI_SketchEntity.h>
10 //--------------------------------------------------------------------------------------
11 #include <ModelHighAPI_Dumper.h>
12 #include <ModelHighAPI_Selection.h>
13 #include <ModelHighAPI_Tools.h>
14 //--------------------------------------------------------------------------------------
15 SketchAPI_Mirror::SketchAPI_Mirror(
16 const std::shared_ptr<ModelAPI_Feature> & theFeature)
17 : ModelHighAPI_Interface(theFeature)
22 SketchAPI_Mirror::SketchAPI_Mirror(
23 const std::shared_ptr<ModelAPI_Feature> & theFeature,
24 const ModelHighAPI_RefAttr & theMirrorLine,
25 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects)
26 : ModelHighAPI_Interface(theFeature)
29 fillAttribute(theMirrorLine, mirrorLine());
30 fillAttribute(theObjects, mirrorList());
36 SketchAPI_Mirror::~SketchAPI_Mirror()
41 std::list<std::shared_ptr<ModelHighAPI_Interface> > SketchAPI_Mirror::mirrored() const
43 std::list<ObjectPtr> aList = mirroredObjects()->list();
44 std::list<FeaturePtr> anIntermediate;
45 std::list<ObjectPtr>::const_iterator anIt = aList.begin();
46 for (; anIt != aList.end(); ++anIt) {
47 FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
48 anIntermediate.push_back(aFeature);
50 return SketchAPI_SketchEntity::wrap(anIntermediate);
53 //--------------------------------------------------------------------------------------
55 void SketchAPI_Mirror::dump(ModelHighAPI_Dumper& theDumper) const
57 FeaturePtr aBase = feature();
58 const std::string& aSketchName = theDumper.parentName(aBase);
60 AttributeRefAttrPtr aMirrorLine = mirrorLine();
61 AttributeRefListPtr aMirrorObjects = mirrorList();
62 theDumper << aBase << " = " << aSketchName << ".addMirror(" << aMirrorLine << ", "
63 << aMirrorObjects << ")" << std::endl;
65 // Dump variables for a list of mirrored features
67 std::list<std::shared_ptr<ModelHighAPI_Interface> > aList = mirrored();
68 std::list<std::shared_ptr<ModelHighAPI_Interface> >::const_iterator anIt = aList.begin();
69 for (; anIt != aList.end(); ++anIt) {
70 if (anIt != aList.begin())
72 theDumper << theDumper.name((*anIt)->feature(), false);
74 theDumper << "] = " << theDumper.name(aBase) << ".mirrored()" << std::endl;