#include "GeomAlgoAPI_CanonicalRecognition.h"
+#include <Standard_Version.hxx>
+// code from KERNEL_SRC/src/Basics/Basics_OCCTVersion.hxx
+#ifdef OCC_VERSION_SERVICEPACK
+# define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8 | OCC_VERSION_SERVICEPACK)
+#else
+# ifdef OCC_VERSION_DEVELOPMENT
+# define OCC_VERSION_LARGE ((OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)-1)
+# else
+# define OCC_VERSION_LARGE (OCC_VERSION_MAJOR << 24 | OCC_VERSION_MINOR << 16 | OCC_VERSION_MAINTENANCE << 8)
+# endif
+#endif
+
+#if OCC_VERSION_LARGE > 0x07050303
#include <ShapeAnalysis_CanonicalRecognition.hxx>
+#endif
+
+#include <TopoDS_Shape.hxx>
+
#include <gp_Pln.hxx>
#include <gp_Sphere.hxx>
#include <gp_Cone.hxx>
gp_Dir(theNormal[0], theNormal[1], theNormal[2]));
}
- ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
bool aResult = false;
+
+#if OCC_VERSION_LARGE > 0x07050303
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
try {
if (aRecognition.GetStatus() == 0)
aResult = aRecognition.IsPlane(theTolerance, aPln);
catch (...) {
return false;
}
+#endif
gp_Pnt aOrig = aPln.Location();
if (theOrigin.size() != 3)
}
else
aSphere.SetRadius(1.0);
- ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+
bool aResult = false;
+
+#if OCC_VERSION_LARGE > 0x07050303
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
try {
if (aRecognition.GetStatus() == 0)
aResult = aRecognition.IsSphere(theTolerance, aSphere);
catch (...) {
return false;
}
+#endif
gp_Pnt aLoc = aSphere.Location();
if (theOrigin.size() != 3)
}
else
aCone.SetRadius(1.0);
- ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+
bool aResult = false;
+
+#if OCC_VERSION_LARGE > 0x07050303
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
try {
if (aRecognition.GetStatus() == 0)
aResult = aRecognition.IsCone(theTolerance, aCone);
catch (...) {
return false;
}
+#endif
gp_Dir aDir = aCone.Axis().Direction();
if (theAxis.size() != 3)
}
else
aCylinder.SetRadius(1.0);
- ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+
bool aResult = false;
+
+#if OCC_VERSION_LARGE > 0x07050303
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
try {
if (aRecognition.GetStatus() == 0)
aResult = aRecognition.IsCylinder(theTolerance, aCylinder);
catch (...) {
return false;
}
+#endif
gp_Dir aDir = aCylinder.Axis().Direction();
if (theAxis.size() != 3)
aLine.SetLocation(gp_Pnt(theOrigin[0], theOrigin[1], theOrigin[2]));
aLine.SetDirection(gp_Dir(theDir[0], theDir[1], theDir[2]));
}
- ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+
bool aResult = false;
+
+#if OCC_VERSION_LARGE > 0x07050303
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
try {
if (aRecognition.GetStatus() == 0)
aResult = aRecognition.IsLine(theTolerance, aLine);
catch (...) {
return false;
}
+#endif
gp_Pnt aLoc = aLine.Location();
if (theOrigin.size() != 3)
}
else
aCircle.SetRadius(1.0);
- ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+
bool aResult = false;
+
+#if OCC_VERSION_LARGE > 0x07050303
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
try {
if (aRecognition.GetStatus() == 0)
aResult = aRecognition.IsCircle(theTolerance, aCircle);
catch (...) {
return false;
}
+#endif
gp_Pnt aLoc = aCircle.Location();
if (theOrigin.size() != 3)
}
else
aElips.SetMajorRadius(1.0);
- ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+
bool aResult = false;
+
+#if OCC_VERSION_LARGE > 0x07050303
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
try {
if (aRecognition.GetStatus() == 0)
aResult = aRecognition.IsEllipse(theTolerance, aElips);
catch (...) {
return false;
}
+#endif
gp_Pnt aLoc = aElips.Position().Location();
if (theOrigin.size() != 3)
return aResult;
}
+
+bool GeomAlgoAPI_CanonicalRecognition::isImplemented()
+{
+#if OCC_VERSION_LARGE > 0x07050303
+ return true;
+#else
+ return false;
+#endif
+}
-#!/usr/bin/env python
-
-###
-### This file is generated automatically by SALOME v9.9.0 with dump python functionality
-###
-
-
-###
-### SHAPER component
-###
+# Copyright (C) 2014-2022 CEA/DEN, EDF R&D
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
from salome.shaper import model, geom
+def isCRImplemented():
+ CR = geom.CanonicalRecognition()
+ return CR.isImplemented()
+
def GetShapeType(theShape):
CR = geom.CanonicalRecognition()
if CR.isLine(theShape, 0.1)[0]:
aEllipseShape = EllipseWire_1.defaultResult().shape()
### Check shapes types
-assert (GetShapeType(aPlaneShape) == "Plane")
-assert (GetShapeType(aCircleShape)[1] == "Circle")
-assert (GetShapeType(aLineShape) == "Line")
-assert (GetShapeType(aCylinderShape) == "Cylinder")
-assert (GetShapeType(aSphereShape) == "Sphere")
-assert (GetShapeType(aConeShape) == "Cone")
-assert (GetShapeType(aEllipseShape)[1] == "Ellipse")
+if isCRImplemented():
+ assert (GetShapeType(aPlaneShape) == "Plane")
+ assert (GetShapeType(aCircleShape)[1] == "Circle")
+ assert (GetShapeType(aLineShape) == "Line")
+ assert (GetShapeType(aCylinderShape) == "Cylinder")
+ assert (GetShapeType(aSphereShape) == "Sphere")
+ assert (GetShapeType(aConeShape) == "Cone")
+ assert (GetShapeType(aEllipseShape)[1] == "Ellipse")