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>
17 ResultPtr result(const ObjectPtr theObject)
19 return boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
22 TopoDS_Shape shape(ResultPtr theResult)
24 boost::shared_ptr<GeomAPI_Shape> aShape = ModuleBase_Tools::shape(theResult);
26 return aShape->impl<TopoDS_Shape>();
27 return TopoDS_Shape();
30 bool ModuleBase_ResultPointValidator::isValid(const ObjectPtr theObject) const
32 ResultPtr aResult = result(theObject);
35 TopoDS_Shape aShape = shape(aResult);
39 return aShape.ShapeType() == TopAbs_VERTEX;
42 bool ModuleBase_ResultLineValidator::isValid(const ObjectPtr theObject) const
44 ResultPtr aResult = result(theObject);
47 TopoDS_Shape aShape = shape(aResult);
51 if (aShape.ShapeType() == TopAbs_EDGE) {
52 TopoDS_Edge aEdge = TopoDS::Edge(aShape);
53 Standard_Real aStart, aEnd;
54 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
55 GeomAdaptor_Curve aAdaptor(aCurve);
56 return aAdaptor.GetType() == GeomAbs_Line;
61 bool ModuleBase_ResultArcValidator::isValid(const ObjectPtr theObject) const
63 ResultPtr aResult = result(theObject);
66 TopoDS_Shape aShape = shape(aResult);
70 TopAbs_ShapeEnum aa = aShape.ShapeType();
71 if (aShape.ShapeType() == TopAbs_EDGE) {
72 TopoDS_Edge aEdge = TopoDS::Edge(aShape);
73 Standard_Real aStart, aEnd;
74 Handle(Geom_Curve) aCurve = BRep_Tool::Curve(aEdge, aStart, aEnd);
75 GeomAdaptor_Curve aAdaptor(aCurve);
76 return aAdaptor.GetType() == GeomAbs_Circle;