1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name : SketchAPI_Mirror.cpp
6 // 16/06/16 - Sergey POKHODENKO - Creation of the file
8 //--------------------------------------------------------------------------------------
9 #include "SketchAPI_Mirror.h"
10 #include <SketchAPI_SketchEntity.h>
11 //--------------------------------------------------------------------------------------
12 #include <ModelHighAPI_Dumper.h>
13 #include <ModelHighAPI_Selection.h>
14 #include <ModelHighAPI_Tools.h>
15 //--------------------------------------------------------------------------------------
16 SketchAPI_Mirror::SketchAPI_Mirror(
17 const std::shared_ptr<ModelAPI_Feature> & theFeature)
18 : ModelHighAPI_Interface(theFeature)
23 SketchAPI_Mirror::SketchAPI_Mirror(
24 const std::shared_ptr<ModelAPI_Feature> & theFeature,
25 const ModelHighAPI_RefAttr & theMirrorLine,
26 const std::list<std::shared_ptr<ModelAPI_Object> > & theObjects)
27 : ModelHighAPI_Interface(theFeature)
30 fillAttribute(theMirrorLine, mirrorLine());
31 fillAttribute(theObjects, mirrorList());
37 SketchAPI_Mirror::~SketchAPI_Mirror()
42 std::list<std::shared_ptr<ModelHighAPI_Interface> > SketchAPI_Mirror::mirrored() const
44 std::list<ObjectPtr> aList = mirroredObjects()->list();
45 std::list<FeaturePtr> anIntermediate;
46 std::list<ObjectPtr>::const_iterator anIt = aList.begin();
47 for (; anIt != aList.end(); ++anIt) {
48 FeaturePtr aFeature = ModelAPI_Feature::feature(*anIt);
49 anIntermediate.push_back(aFeature);
51 return SketchAPI_SketchEntity::wrap(anIntermediate);
54 //--------------------------------------------------------------------------------------
56 void SketchAPI_Mirror::dump(ModelHighAPI_Dumper& theDumper) const
58 FeaturePtr aBase = feature();
59 const std::string& aSketchName = theDumper.parentName(aBase);
61 AttributeRefAttrPtr aMirrorLine = mirrorLine();
62 AttributeRefListPtr aMirrorObjects = mirrorList();
63 theDumper << aBase << " = " << aSketchName << ".addMirror(" << aMirrorLine << ", "
64 << aMirrorObjects << ")" << std::endl;
66 // Dump variables for a list of mirrored features
68 std::list<std::shared_ptr<ModelHighAPI_Interface> > aList = mirrored();
69 std::list<std::shared_ptr<ModelHighAPI_Interface> >::const_iterator anIt = aList.begin();
70 for (; anIt != aList.end(); ++anIt) {
71 if (anIt != aList.begin())
73 theDumper << theDumper.name((*anIt)->feature(), false);
75 theDumper << "] = " << theDumper.name(aBase) << ".mirrored()" << std::endl;