1 // Copyright (C) 2014-2019 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "SketchAPI_SketchEntity.h"
21 #include <SketchAPI_Arc.h>
22 #include <SketchAPI_Circle.h>
23 #include <SketchAPI_Ellipse.h>
24 #include <SketchAPI_EllipticArc.h>
25 #include <SketchAPI_IntersectionPoint.h>
26 #include <SketchAPI_Line.h>
27 #include <SketchAPI_Point.h>
28 //--------------------------------------------------------------------------------------
29 #include <ModelHighAPI_Dumper.h>
30 #include <ModelHighAPI_Tools.h>
32 #include <SketchPlugin_Arc.h>
33 #include <SketchPlugin_Circle.h>
34 #include <SketchPlugin_Ellipse.h>
35 #include <SketchPlugin_IntersectionPoint.h>
36 #include <SketchPlugin_Line.h>
37 #include <SketchPlugin_Point.h>
38 //--------------------------------------------------------------------------------------
39 SketchAPI_SketchEntity::SketchAPI_SketchEntity(
40 const std::shared_ptr<ModelAPI_Feature> & theFeature)
41 : ModelHighAPI_Interface(theFeature)
46 SketchAPI_SketchEntity::~SketchAPI_SketchEntity()
51 //--------------------------------------------------------------------------------------
52 bool SketchAPI_SketchEntity::initialize()
54 SET_ATTRIBUTE(Auxiliary, ModelAPI_AttributeBoolean, SketchPlugin_SketchEntity::AUXILIARY_ID())
59 //--------------------------------------------------------------------------------------
60 std::shared_ptr<ModelAPI_AttributeBoolean> SketchAPI_SketchEntity::auxiliary() const
65 void SketchAPI_SketchEntity::setAuxiliary(bool theAuxiliary)
67 fillAttribute(theAuxiliary, myAuxiliary);
72 //--------------------------------------------------------------------------------------
73 void SketchAPI_SketchEntity::dump(ModelHighAPI_Dumper& theDumper) const
75 FeaturePtr aBase = feature();
76 AttributeBooleanPtr anAux = aBase->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
78 const std::string& aName = theDumper.name(aBase);
79 theDumper << aName << ".setAuxiliary(" << anAux << ")" <<std::endl;
83 bool SketchAPI_SketchEntity::isCopy() const
85 // check the feature is a copy of another entity
86 AttributeBooleanPtr isCopy = feature()->boolean(SketchPlugin_SketchEntity::COPY_ID());
87 return isCopy.get() && isCopy->value();
90 std::list<std::shared_ptr<SketchAPI_SketchEntity> >
91 SketchAPI_SketchEntity::wrap(const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures)
93 std::list<std::shared_ptr<SketchAPI_SketchEntity> > aResult;
94 std::list<std::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = theFeatures.begin();
95 for (; anIt != theFeatures.end(); ++anIt) {
96 if ((*anIt)->getKind() == SketchPlugin_Line::ID())
97 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Line(*anIt)));
98 else if ((*anIt)->getKind() == SketchPlugin_Arc::ID())
99 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Arc(*anIt)));
100 else if ((*anIt)->getKind() == SketchPlugin_Circle::ID())
101 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Circle(*anIt)));
102 else if ((*anIt)->getKind() == SketchPlugin_Ellipse::ID())
103 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Ellipse(*anIt)));
104 else if ((*anIt)->getKind() == SketchPlugin_EllipticArc::ID())
105 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_EllipticArc(*anIt)));
106 else if ((*anIt)->getKind() == SketchPlugin_Point::ID())
107 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Point(*anIt)));
108 else if ((*anIt)->getKind() == SketchPlugin_IntersectionPoint::ID())
109 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(
110 new SketchAPI_IntersectionPoint(*anIt)));