Salome HOME
8e37e08f522472a9a682a07901f1b109e1af87e8
[modules/shaper.git] / src / SketchAPI / SketchAPI_IntersectionPoint.cpp
1 // Copyright (C) 2014-2017  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
18 //
19
20 #include "SketchAPI_IntersectionPoint.h"
21 //--------------------------------------------------------------------------------------
22 #include <GeomAPI_Pnt2d.h>
23 //--------------------------------------------------------------------------------------
24 #include <ModelHighAPI_Dumper.h>
25 #include <ModelHighAPI_Selection.h>
26 #include <ModelHighAPI_Tools.h>
27 //--------------------------------------------------------------------------------------
28 SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint(
29     const std::shared_ptr<ModelAPI_Feature> & theFeature)
30 : SketchAPI_SketchEntity(theFeature)
31 {
32   initialize();
33 }
34
35 SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint(
36     const std::shared_ptr<ModelAPI_Feature> & theFeature,
37     const ModelHighAPI_Selection & theExternal )
38 : SketchAPI_SketchEntity(theFeature)
39 {
40   if (initialize()) {
41     setByExternalLine(theExternal);
42   }
43 }
44
45 SketchAPI_IntersectionPoint::SketchAPI_IntersectionPoint(
46     const std::shared_ptr<ModelAPI_Feature> & theFeature,
47     const std::string & theExternalName )
48 : SketchAPI_SketchEntity(theFeature)
49 {
50   if (initialize()) {
51     setByExternalLineName(theExternalName);
52   }
53 }
54
55 SketchAPI_IntersectionPoint::~SketchAPI_IntersectionPoint()
56 {
57
58 }
59
60 //--------------------------------------------------------------------------------------
61 void SketchAPI_IntersectionPoint::setByExternalLine(const ModelHighAPI_Selection & theExternalLine)
62 {
63   fillAttribute(theExternalLine, externalLine());
64
65   execute();
66 }
67
68 void SketchAPI_IntersectionPoint::setByExternalLineName(const std::string & theExternalLineName)
69 {
70   fillAttribute(ModelHighAPI_Selection("EDGE", theExternalLineName), externalLine());
71
72   execute();
73 }
74
75 //--------------------------------------------------------------------------------------
76
77 void SketchAPI_IntersectionPoint::dump(ModelHighAPI_Dumper& theDumper) const
78 {
79   FeaturePtr aBase = feature();
80   const std::string& aSketchName = theDumper.parentName(aBase);
81
82   AttributeSelectionPtr aLine = externalLine();
83   theDumper << aBase << " = " <<
84     aSketchName << ".addIntersectionPoint(" << aLine << ")" << std::endl;
85   // dump "auxiliary" flag if necessary
86   SketchAPI_SketchEntity::dump(theDumper);
87 }