1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
2 // Name : SketchAPI_Point.cpp
6 // 15/06/16 - Sergey POKHODENKO - Creation of the file
8 //--------------------------------------------------------------------------------------
9 #include "SketchAPI_Point.h"
10 //--------------------------------------------------------------------------------------
11 #include <GeomAPI_Pnt2d.h>
12 //--------------------------------------------------------------------------------------
13 #include <ModelHighAPI_Dumper.h>
14 #include <ModelHighAPI_Selection.h>
15 #include <ModelHighAPI_Tools.h>
16 //--------------------------------------------------------------------------------------
17 SketchAPI_Point::SketchAPI_Point(
18 const std::shared_ptr<ModelAPI_Feature> & theFeature)
19 : SketchAPI_SketchEntity(theFeature)
24 SketchAPI_Point::SketchAPI_Point(
25 const std::shared_ptr<ModelAPI_Feature> & theFeature,
26 double theX, double theY)
27 : SketchAPI_SketchEntity(theFeature)
30 setCoordinates(theX, theY);
34 SketchAPI_Point::SketchAPI_Point(
35 const std::shared_ptr<ModelAPI_Feature> & theFeature,
36 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
37 : SketchAPI_SketchEntity(theFeature)
40 setCoordinates(thePoint);
44 SketchAPI_Point::SketchAPI_Point(
45 const std::shared_ptr<ModelAPI_Feature> & theFeature,
46 const ModelHighAPI_Selection & theExternal )
47 : SketchAPI_SketchEntity(theFeature)
50 setByExternal(theExternal);
54 SketchAPI_Point::SketchAPI_Point(
55 const std::shared_ptr<ModelAPI_Feature> & theFeature,
56 const std::string & theExternalName )
57 : SketchAPI_SketchEntity(theFeature)
60 setByExternalName(theExternalName);
64 SketchAPI_Point::~SketchAPI_Point()
69 //--------------------------------------------------------------------------------------
70 void SketchAPI_Point::setCoordinates(
71 double theX, double theY)
73 fillAttribute(coordinates(), theX, theY);
78 void SketchAPI_Point::setCoordinates(
79 const std::shared_ptr<GeomAPI_Pnt2d> & thePoint)
81 fillAttribute(thePoint, coordinates());
86 void SketchAPI_Point::setByExternal(const ModelHighAPI_Selection & theExternal)
88 fillAttribute(theExternal, external());
93 void SketchAPI_Point::setByExternalName(const std::string & theExternalName)
95 fillAttribute(ModelHighAPI_Selection("VERTEX", theExternalName), external());
100 //--------------------------------------------------------------------------------------
102 void SketchAPI_Point::dump(ModelHighAPI_Dumper& theDumper) const
105 return; // no need to dump copied feature
107 FeaturePtr aBase = feature();
108 const std::string& aSketchName = theDumper.parentName(aBase);
110 AttributeSelectionPtr anExternal = aBase->selection(SketchPlugin_SketchEntity::EXTERNAL_ID());
111 if (anExternal->context()) {
113 theDumper << aBase << " = " << aSketchName << ".addPoint(" << anExternal << ")" << std::endl;
115 // point given by coordinates
116 std::shared_ptr<GeomDataAPI_Point2D> aPoint = coordinates();
117 theDumper << aBase << " = " << aSketchName << ".addPoint(" << aPoint << ")" << std::endl;
119 // dump "auxiliary" flag if necessary
120 SketchAPI_SketchEntity::dump(theDumper);