]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
0054769: isCylinder with parameters generates UNKNOWN_UserException
authorazv <azv@opencascade.com>
Mon, 25 Jul 2022 09:30:58 +0000 (12:30 +0300)
committerazv <azv@opencascade.com>
Mon, 25 Jul 2022 09:30:58 +0000 (12:30 +0300)
src/GeomAlgoAPI/GeomAlgoAPI_CanonicalRecognition.cpp

index e910c0997a4ca3c2de1e176f569e87ef9acb1961..7e6e087e7ace7dcb7a5a20e360db6e839da3b177 100644 (file)
@@ -340,9 +340,12 @@ bool GeomAlgoAPI_CanonicalRecognition::isEllipse(const GeomShapePtr& theEdge, do
   gp_Elips aElips;
   if (aIsValidNormal && aIsValidOrigin && aIsValidDirX && aIsValidRad1 && aIsValidRad2)
   {
-    gp_Ax2 aAx2(gp_Pnt(theOrigin[0], theOrigin[1], theOrigin[2]),
-      gp_Dir(theNormal[0], theNormal[1], theNormal[2]),
-      gp_Dir(theDirX[0], theDirX[1], theDirX[2]));
+    gp_Pnt anOrigin(theOrigin[0], theOrigin[1], theOrigin[2]);
+    gp_XYZ aNormal(theNormal[0], theNormal[1], theNormal[2]);
+    gp_XYZ aDirX(theDirX[0], theDirX[1], theDirX[2]);
+    Standard_Boolean isCollinear =
+        aNormal.CrossSquareMagnitude(aDirX) < Precision::SquareConfusion();
+    gp_Ax2 aAx2 = isCollinear ? gp_Ax2(anOrigin, aNormal) : gp_Ax2(anOrigin, aNormal, aDirX);
     aElips = gp_Elips(aAx2, theMajorRadius, theMinorRadius);
   }
   else