]> OCCT Git - occt-copy.git/commitdiff
Fix for the issue #28491
authornbv <nbv@opencascade.com>
Tue, 28 Feb 2017 15:13:56 +0000 (18:13 +0300)
committernbv <nbv@opencascade.com>
Thu, 2 Mar 2017 09:09:13 +0000 (12:09 +0300)
src/IntTools/IntTools_Context.cxx
tests/bugs/modalg_6/bug28491 [new file with mode: 0644]

index d4b72c7bd9582118e4a5ff70fbf5dd67ab8bce9f..32cfb7bfe3688af7fa6ce39562c3d0e2bbdeccfe 100644 (file)
@@ -705,7 +705,7 @@ Standard_Boolean IntTools_Context::IsValidPointForFace
 
   GeomAPI_ProjectPointOnSurf& aProjector=ProjPS(aF);
   aProjector.Perform(aP);
-  
+
   bFlag=aProjector.IsDone();
   if (bFlag) {
     
@@ -768,42 +768,46 @@ Standard_Boolean IntTools_Context::IsValidBlockForFace
 //function : IsValidBlockForFaces
 //purpose  : 
 //=======================================================================
-Standard_Boolean IntTools_Context::IsValidBlockForFaces 
-  (const Standard_Real aT1,
-   const Standard_Real aT2,
-   const IntTools_Curve& aC, 
-   const TopoDS_Face& aF1,
-   const TopoDS_Face& aF2,
-   const Standard_Real aTol) 
+Standard_Boolean IntTools_Context::IsValidBlockForFaces(const Standard_Real theT1,
+                                                        const Standard_Real theT2,
+                                                        const IntTools_Curve& theC,
+                                                        const TopoDS_Face& theF1,
+                                                        const TopoDS_Face& theF2,
+                                                        const Standard_Real theTol)
 {
-  Standard_Boolean bFlag1, bFlag2;
-  //
-  Handle(Geom2d_Curve) aPC1 = aC.FirstCurve2d();
-  Handle(Geom2d_Curve) aPC2 = aC.SecondCurve2d();
-  if( !aPC1.IsNull() && !aPC2.IsNull() ) {
-    Standard_Real aMidPar = IntTools_Tools::IntermediatePoint(aT1, aT2);
-    gp_Pnt2d aPnt2D;
+  const Standard_Integer aNbElem = 2;
+  const Handle(Geom2d_Curve) &aPC1 = theC.FirstCurve2d();
+  const Handle(Geom2d_Curve) &aPC2 = theC.SecondCurve2d();
+  const Handle(Geom_Curve)   &aC3D = theC.Curve();
 
+  const Handle(Geom2d_Curve)* anArrPC[aNbElem] = { &aPC1, &aPC2 };
+  const TopoDS_Face* anArrF[aNbElem] = { &theF1, &theF2 };
 
-    aPC1->D0(aMidPar, aPnt2D);
-    bFlag1 = IsPointInOnFace(aF1, aPnt2D);
+  const Standard_Real aMidPar = IntTools_Tools::IntermediatePoint(theT1, theT2);
+  const gp_Pnt aP(aC3D->Value(aMidPar));
 
-    if( !bFlag1 )
-      return bFlag1;
+  Standard_Boolean bFlag = Standard_True;
+  gp_Pnt2d aPnt2D;
 
-    aPC2->D0(aMidPar, aPnt2D);
-    bFlag2 = IsPointInOnFace(aF2, aPnt2D);
-    return bFlag2;
-  }
-  //
+  for (Standard_Integer i = 0; (i < 2) && bFlag; ++i)
+  {
+    const Handle(Geom2d_Curve) &aPC = *anArrPC[i];
+    const TopoDS_Face &aF = *anArrF[i];
 
-  bFlag1=IsValidBlockForFace (aT1, aT2, aC, aF1, aTol);
-  if (!bFlag1) {
-    return bFlag1;
+    if (!aPC.IsNull())
+    {
+      aPC->D0(aMidPar, aPnt2D);
+      bFlag = IsPointInOnFace(aF, aPnt2D);
+    }
+    else
+    {
+      bFlag = IsValidPointForFace(aP, aF, theTol);
+    }
   }
-  bFlag2=IsValidBlockForFace (aT1, aT2, aC, aF2, aTol);
-  return bFlag2;
+
+  return bFlag;
 }
+
 //=======================================================================
 //function : IsVertexOnLine
 //purpose  : 
diff --git a/tests/bugs/modalg_6/bug28491 b/tests/bugs/modalg_6/bug28491
new file mode 100644 (file)
index 0000000..6a7f047
--- /dev/null
@@ -0,0 +1,17 @@
+puts "========"
+puts "OCC28491"
+puts "========"
+puts ""
+##########################################
+## Incomplete section curve
+##########################################
+
+set GoodLength 4.617
+
+restore [locate_data_file bug28491_H0.brep] h0
+restore [locate_data_file bug28491_Prism.brep] s1
+explode h0 f
+
+bsection result h0_57 s1 -n2d2
+
+set length 4.60797
\ No newline at end of file