X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FPartSet%2FPartSet_Validators.cpp;h=55f0157b003a2ff8e9f36cdc1ec364f706b1d98f;hb=c55b14977783111c8b418b416c7f6c2fa545c5e5;hp=2837ba7bff93c2e5e183119e70b0f47e53b05d5d;hpb=97c6d9faa9466aadd9c3c43489d5f68c888a7be2;p=modules%2Fshaper.git diff --git a/src/PartSet/PartSet_Validators.cpp b/src/PartSet/PartSet_Validators.cpp index 2837ba7bf..55f0157b0 100644 --- a/src/PartSet/PartSet_Validators.cpp +++ b/src/PartSet/PartSet_Validators.cpp @@ -23,6 +23,7 @@ #include #include +#include #include #ifdef _DEBUG @@ -127,37 +128,53 @@ bool PartSet_HVDirSelection::isValid(const ModuleBase_ISelection* theSelection) return (aCount == 1); } +bool PartSet_FilletSelection::isValid(const ModuleBase_ISelection* theSelection) const +{ + int aCount = shapesNbLines(theSelection); + return (aCount > 0) && (aCount < 3); +} + bool PartSet_TangentSelection::isValid(const ModuleBase_ISelection* theSelection) const { QList aList = theSelection->getSelected(); - ModuleBase_ViewerPrs aPrs; - if (aList.size() != 2) + if ((aList.size() == 0) || (aList.size() > 2)) return false; - ModuleBase_ViewerPrs aPrs1 = aList.first(); - ModuleBase_ViewerPrs aPrs2 = aList.last(); - - const TopoDS_Shape& aShape1 = aPrs1.shape(); - const TopoDS_Shape& aShape2 = aPrs2.shape(); - if (aShape1.IsNull() || aShape2.IsNull()) + ModuleBase_ViewerPrs aPrs = aList.first(); + const TopoDS_Shape& aShape = aPrs.shape(); + if (aShape.IsNull()) return false; - if ((aShape1.ShapeType() != TopAbs_EDGE) || (aShape2.ShapeType() != TopAbs_EDGE)) + if (aShape.ShapeType() != TopAbs_EDGE) return false; - TopoDS_Edge aEdge1 = TopoDS::Edge(aShape1); - TopoDS_Edge aEdge2 = TopoDS::Edge(aShape2); - - Standard_Real aStart, aEnd; - Handle(Geom_Curve) aCurve1 = BRep_Tool::Curve(aEdge1, aStart, aEnd); - Handle(Geom_Curve) aCurve2 = BRep_Tool::Curve(aEdge2, aStart, aEnd); - - GeomAdaptor_Curve aAdaptor1(aCurve1); - GeomAdaptor_Curve aAdaptor2(aCurve2); - if (aAdaptor1.GetType() == GeomAbs_Circle) - return aAdaptor2.GetType() == GeomAbs_Line; - else if (aAdaptor2.GetType() == GeomAbs_Circle) - return aAdaptor1.GetType() == GeomAbs_Line; + std::shared_ptr aShapePtr(new GeomAPI_Shape); + aShapePtr->setImpl(new TopoDS_Shape(aShape)); + GeomAPI_Edge aEdge1(aShapePtr); + + if (aEdge1.isLine() || aEdge1.isArc()) { + if (aList.size() == 2) { + // Check second selection + aPrs = aList.last(); + const TopoDS_Shape& aShape2 = aPrs.shape(); + if (aShape2.IsNull()) + return false; + + if (aShape2.ShapeType() != TopAbs_EDGE) + return false; + + std::shared_ptr aShapePtr2(new GeomAPI_Shape); + aShapePtr2->setImpl(new TopoDS_Shape(aShape2)); + GeomAPI_Edge aEdge2(aShapePtr2); + if (aEdge1.isLine() && aEdge2.isArc()) + return true; + else if (aEdge1.isArc() && aEdge2.isLine()) + return true; + else + return false; + } else + return true; + } return false; }