Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
[modules/shaper.git] / src / SketchPlugin / SketchPlugin_ResultValidators.cpp
1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
2
3 // File:        Model_ResultValidators.cpp
4 // Created:     23 July 2014
5 // Author:      Vitaly SMETANNIKOV
6
7 #include "SketchPlugin_ResultValidators.h"
8
9 #include <ModelAPI_Result.h>
10 #include <ModelAPI_Tools.h>
11 #include <GeomAPI_Curve.h>
12
13 ResultPtr result(const ObjectPtr theObject)
14 {
15   return std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
16 }
17
18 bool SketchPlugin_ResultPointValidator::isValid(const ObjectPtr theObject) const
19 {
20   ResultPtr aResult = result(theObject);
21   if (!aResult)
22     return false;
23   std::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
24   return aShape && aShape->isVertex();
25 }
26
27 bool SketchPlugin_ResultLineValidator::isValid(const ObjectPtr theObject) const
28 {
29   ResultPtr aResult = result(theObject);
30   if (!aResult)
31     return false;
32   std::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
33   return aShape && aShape->isEdge() && GeomAPI_Curve(aShape).isLine();
34 }
35
36 bool SketchPlugin_ResultArcValidator::isValid(const ObjectPtr theObject) const
37 {
38   ResultPtr aResult = result(theObject);
39   if (!aResult)
40     return false;
41   std::shared_ptr<GeomAPI_Shape> aShape = ModelAPI_Tools::shape(aResult);
42   return aShape && aShape->isEdge() && GeomAPI_Curve(aShape).isCircle();
43 }