1 // File: ModuleBase_ResultValidators.cpp
2 // Created: 23 July 2014
3 // Author: Vitaly SMETANNIKOV
5 #include "ModuleBase_ResultValidators.h"
6 #include "ModuleBase_Tools.h"
8 #include <ModelAPI_Result.h>
9 #include <GeomAPI_Shape.h>
11 #include <TopoDS_Shape.hxx>
12 #include <TopoDS_Edge.hxx>
14 #include <BRep_Tool.hxx>
15 #include <GeomAdaptor_Curve.hxx>
18 ResultPtr result(const ObjectPtr theObject)
20 return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
23 TopoDS_Shape shape(ResultPtr theResult)
25 boost::shared_ptr<GeomAPI_Shape> aShape = ModuleBase_Tools::shape(theResult);
27 return aShape->impl<TopoDS_Shape>();
28 return TopoDS_Shape();
32 bool ModuleBase_ResultPointValidator::isValid(const ObjectPtr theObject) const
34 ResultPtr aResult = result(theObject);
37 TopoDS_Shape aShape = shape(aResult);
41 return aShape.ShapeType() == TopAbs_VERTEX;
45 bool ModuleBase_ResultLineValidator::isValid(const ObjectPtr theObject) const
47 ResultPtr aResult = result(theObject);
50 TopoDS_Shape aShape = shape(aResult);
54 if (aShape.ShapeType() == TopAbs_EDGE) {
55 TopoDS_Edge aEdge = TopoDS::Edge(aShape);
56 Standard_Real aStart, aEnd;
57 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
58 GeomAdaptor_Curve aAdaptor(aCurve);
59 return aAdaptor.GetType() == GeomAbs_Line;
65 bool ModuleBase_ResultArcValidator::isValid(const ObjectPtr theObject) const
67 ResultPtr aResult = result(theObject);
70 TopoDS_Shape aShape = shape(aResult);
74 TopAbs_ShapeEnum aa = aShape.ShapeType();
75 if (aShape.ShapeType() == TopAbs_EDGE) {
76 TopoDS_Edge aEdge = TopoDS::Edge(aShape);
77 Standard_Real aStart, aEnd;
78 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
79 GeomAdaptor_Curve aAdaptor(aCurve);
80 return aAdaptor.GetType() == GeomAbs_Circle;