1 // Name : SketchAPI_SketchEntity.cpp
5 // 07/06/16 - Sergey POKHODENKO - Creation of the file
7 //--------------------------------------------------------------------------------------
8 #include "SketchAPI_SketchEntity.h"
9 #include <SketchAPI_Arc.h>
10 #include <SketchAPI_Circle.h>
11 #include <SketchAPI_IntersectionPoint.h>
12 #include <SketchAPI_Line.h>
13 #include <SketchAPI_Point.h>
14 //--------------------------------------------------------------------------------------
15 #include <ModelHighAPI_Dumper.h>
16 #include <ModelHighAPI_Tools.h>
18 #include <SketchPlugin_Arc.h>
19 #include <SketchPlugin_Circle.h>
20 #include <SketchPlugin_IntersectionPoint.h>
21 #include <SketchPlugin_Line.h>
22 #include <SketchPlugin_Point.h>
23 //--------------------------------------------------------------------------------------
24 SketchAPI_SketchEntity::SketchAPI_SketchEntity(
25 const std::shared_ptr<ModelAPI_Feature> & theFeature)
26 : ModelHighAPI_Interface(theFeature)
31 SketchAPI_SketchEntity::~SketchAPI_SketchEntity()
36 //--------------------------------------------------------------------------------------
37 bool SketchAPI_SketchEntity::initialize()
39 SET_ATTRIBUTE(Auxiliary, ModelAPI_AttributeBoolean, SketchPlugin_SketchEntity::AUXILIARY_ID())
44 //--------------------------------------------------------------------------------------
45 std::shared_ptr<ModelAPI_AttributeBoolean> SketchAPI_SketchEntity::auxiliary() const
50 void SketchAPI_SketchEntity::setAuxiliary(bool theAuxiliary)
52 fillAttribute(theAuxiliary, myAuxiliary);
57 //--------------------------------------------------------------------------------------
58 void SketchAPI_SketchEntity::dump(ModelHighAPI_Dumper& theDumper) const
60 FeaturePtr aBase = feature();
61 AttributeBooleanPtr anAux = aBase->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
63 const std::string& aName = theDumper.name(aBase);
64 theDumper << aName << ".setAuxiliary(" << anAux << ")" <<std::endl;
68 bool SketchAPI_SketchEntity::isCopy() const
70 // check the feature is a copy of another entity
71 AttributeBooleanPtr isCopy = feature()->boolean(SketchPlugin_SketchEntity::COPY_ID());
72 return isCopy.get() && isCopy->value();
75 std::list<std::shared_ptr<ModelHighAPI_Interface> >
76 SketchAPI_SketchEntity::wrap(const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures)
78 std::list<std::shared_ptr<ModelHighAPI_Interface> > aResult;
79 std::list<std::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = theFeatures.begin();
80 for (; anIt != theFeatures.end(); ++anIt) {
81 if ((*anIt)->getKind() == SketchPlugin_Line::ID())
82 aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Line(*anIt)));
83 else if ((*anIt)->getKind() == SketchPlugin_Arc::ID())
84 aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Arc(*anIt)));
85 else if ((*anIt)->getKind() == SketchPlugin_Circle::ID())
86 aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Circle(*anIt)));
87 else if ((*anIt)->getKind() == SketchPlugin_Point::ID())
88 aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_Point(*anIt)));
89 else if ((*anIt)->getKind() == SketchPlugin_IntersectionPoint::ID())
90 aResult.push_back(std::shared_ptr<ModelHighAPI_Interface>(new SketchAPI_IntersectionPoint(*anIt)));