1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name : SketchAPI_SketchEntity.cpp
6 // 07/06/16 - Sergey POKHODENKO - Creation of the file
8 //--------------------------------------------------------------------------------------
9 #include "SketchAPI_SketchEntity.h"
10 #include <SketchAPI_Arc.h>
11 #include <SketchAPI_Circle.h>
12 #include <SketchAPI_IntersectionPoint.h>
13 #include <SketchAPI_Line.h>
14 #include <SketchAPI_Point.h>
15 //--------------------------------------------------------------------------------------
16 #include <ModelHighAPI_Dumper.h>
17 #include <ModelHighAPI_Tools.h>
19 #include <SketchPlugin_Arc.h>
20 #include <SketchPlugin_Circle.h>
21 #include <SketchPlugin_IntersectionPoint.h>
22 #include <SketchPlugin_Line.h>
23 #include <SketchPlugin_Point.h>
24 //--------------------------------------------------------------------------------------
25 SketchAPI_SketchEntity::SketchAPI_SketchEntity(
26 const std::shared_ptr<ModelAPI_Feature> & theFeature)
27 : ModelHighAPI_Interface(theFeature)
32 SketchAPI_SketchEntity::~SketchAPI_SketchEntity()
37 //--------------------------------------------------------------------------------------
38 bool SketchAPI_SketchEntity::initialize()
40 SET_ATTRIBUTE(Auxiliary, ModelAPI_AttributeBoolean, SketchPlugin_SketchEntity::AUXILIARY_ID())
45 //--------------------------------------------------------------------------------------
46 std::shared_ptr<ModelAPI_AttributeBoolean> SketchAPI_SketchEntity::auxiliary() const
51 void SketchAPI_SketchEntity::setAuxiliary(bool theAuxiliary)
53 fillAttribute(theAuxiliary, myAuxiliary);
58 //--------------------------------------------------------------------------------------
59 void SketchAPI_SketchEntity::dump(ModelHighAPI_Dumper& theDumper) const
61 FeaturePtr aBase = feature();
62 AttributeBooleanPtr anAux = aBase->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
64 const std::string& aName = theDumper.name(aBase);
65 theDumper << aName << ".setAuxiliary(" << anAux << ")" <<std::endl;
69 bool SketchAPI_SketchEntity::isCopy() const
71 // check the feature is a copy of another entity
72 AttributeBooleanPtr isCopy = feature()->boolean(SketchPlugin_SketchEntity::COPY_ID());
73 return isCopy.get() && isCopy->value();
76 std::list<std::shared_ptr<SketchAPI_SketchEntity> >
77 SketchAPI_SketchEntity::wrap(const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures)
79 std::list<std::shared_ptr<SketchAPI_SketchEntity> > aResult;
80 std::list<std::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = theFeatures.begin();
81 for (; anIt != theFeatures.end(); ++anIt) {
82 if ((*anIt)->getKind() == SketchPlugin_Line::ID())
83 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Line(*anIt)));
84 else if ((*anIt)->getKind() == SketchPlugin_Arc::ID())
85 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Arc(*anIt)));
86 else if ((*anIt)->getKind() == SketchPlugin_Circle::ID())
87 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Circle(*anIt)));
88 else if ((*anIt)->getKind() == SketchPlugin_Point::ID())
89 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Point(*anIt)));
90 else if ((*anIt)->getKind() == SketchPlugin_IntersectionPoint::ID())
91 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(
92 new SketchAPI_IntersectionPoint(*anIt)));