1 // Copyright (C) 2014-2017 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
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include "SketchAPI_SketchEntity.h"
22 #include <SketchAPI_Arc.h>
23 #include <SketchAPI_Circle.h>
24 #include <SketchAPI_IntersectionPoint.h>
25 #include <SketchAPI_Line.h>
26 #include <SketchAPI_Point.h>
27 //--------------------------------------------------------------------------------------
28 #include <ModelHighAPI_Dumper.h>
29 #include <ModelHighAPI_Tools.h>
31 #include <SketchPlugin_Arc.h>
32 #include <SketchPlugin_Circle.h>
33 #include <SketchPlugin_IntersectionPoint.h>
34 #include <SketchPlugin_Line.h>
35 #include <SketchPlugin_Point.h>
36 //--------------------------------------------------------------------------------------
37 SketchAPI_SketchEntity::SketchAPI_SketchEntity(
38 const std::shared_ptr<ModelAPI_Feature> & theFeature)
39 : ModelHighAPI_Interface(theFeature)
44 SketchAPI_SketchEntity::~SketchAPI_SketchEntity()
49 //--------------------------------------------------------------------------------------
50 bool SketchAPI_SketchEntity::initialize()
52 SET_ATTRIBUTE(Auxiliary, ModelAPI_AttributeBoolean, SketchPlugin_SketchEntity::AUXILIARY_ID())
57 //--------------------------------------------------------------------------------------
58 std::shared_ptr<ModelAPI_AttributeBoolean> SketchAPI_SketchEntity::auxiliary() const
63 void SketchAPI_SketchEntity::setAuxiliary(bool theAuxiliary)
65 fillAttribute(theAuxiliary, myAuxiliary);
70 //--------------------------------------------------------------------------------------
71 void SketchAPI_SketchEntity::dump(ModelHighAPI_Dumper& theDumper) const
73 FeaturePtr aBase = feature();
74 AttributeBooleanPtr anAux = aBase->boolean(SketchPlugin_SketchEntity::AUXILIARY_ID());
76 const std::string& aName = theDumper.name(aBase);
77 theDumper << aName << ".setAuxiliary(" << anAux << ")" <<std::endl;
81 bool SketchAPI_SketchEntity::isCopy() const
83 // check the feature is a copy of another entity
84 AttributeBooleanPtr isCopy = feature()->boolean(SketchPlugin_SketchEntity::COPY_ID());
85 return isCopy.get() && isCopy->value();
88 std::list<std::shared_ptr<SketchAPI_SketchEntity> >
89 SketchAPI_SketchEntity::wrap(const std::list<std::shared_ptr<ModelAPI_Feature> >& theFeatures)
91 std::list<std::shared_ptr<SketchAPI_SketchEntity> > aResult;
92 std::list<std::shared_ptr<ModelAPI_Feature> >::const_iterator anIt = theFeatures.begin();
93 for (; anIt != theFeatures.end(); ++anIt) {
94 if ((*anIt)->getKind() == SketchPlugin_Line::ID())
95 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Line(*anIt)));
96 else if ((*anIt)->getKind() == SketchPlugin_Arc::ID())
97 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Arc(*anIt)));
98 else if ((*anIt)->getKind() == SketchPlugin_Circle::ID())
99 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Circle(*anIt)));
100 else if ((*anIt)->getKind() == SketchPlugin_Point::ID())
101 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(new SketchAPI_Point(*anIt)));
102 else if ((*anIt)->getKind() == SketchPlugin_IntersectionPoint::ID())
103 aResult.push_back(std::shared_ptr<SketchAPI_SketchEntity>(
104 new SketchAPI_IntersectionPoint(*anIt)));