in boolean isRelative, in double angularDeflection);
};
+ // # GEOM_ICanonicalRecognition:
+ /*!
+ * \brief Interface for canonical recognition operations.
+ */
+ interface GEOM_ICanonicalRecognition : GEOM_IOperations
+ {
+ /*!
+ * check if the shape is planar
+ */
+ boolean isPlane(in GEOM_Object shape, in double tolerance, inout ListOfDouble normal, inout ListOfDouble origin);
+
+ /*!
+ * check if shape is spherical
+ */
+ boolean isSphere(in GEOM_Object shape, in double tolerance, inout ListOfDouble origin, inout double radius);
+
+ /*!
+ * check if shape is conical
+ */
+ boolean isCone(in GEOM_Object shape, in double tolerance, inout ListOfDouble axis, inout ListOfDouble apex, inout double halfAngle);
+
+ /*!
+ * check if shape is cylinder
+ */
+ boolean isCylinder(in GEOM_Object shape, in double tolerance, inout ListOfDouble axis, inout ListOfDouble origin, inout double radius);
+
+ /*!
+ * check if edge / wire is line
+ */
+ boolean isLine(in GEOM_Object edge, in double tolerance, inout ListOfDouble direction, inout ListOfDouble origin);
+
+ /*!
+ * check if edge / wire is circle
+ */
+ boolean isCircle(in GEOM_Object edge, in double tolerance, inout ListOfDouble normal, inout ListOfDouble origin, inout double radius);
+
+ /*!
+ * check if edge / wire is ellipse
+ */
+ boolean isEllipse(in GEOM_Object edge, in double tolerance, inout ListOfDouble normal, inout ListOfDouble dirX, inout ListOfDouble origin, inout double majorRadius, inout double minorRadius);
+ };
+
// # GEOM_Gen:
/*!
* \brief Interface to access other GEOM interfaces.
// # Methods to access interfaces for objects creation and transformation
- GEOM_IBasicOperations GetIBasicOperations () raises (SALOME::SALOME_Exception);
- GEOM_ITransformOperations GetITransformOperations() raises (SALOME::SALOME_Exception);
- GEOM_I3DPrimOperations GetI3DPrimOperations () raises (SALOME::SALOME_Exception);
- GEOM_IShapesOperations GetIShapesOperations () raises (SALOME::SALOME_Exception);
- GEOM_IBooleanOperations GetIBooleanOperations () raises (SALOME::SALOME_Exception);
- GEOM_ICurvesOperations GetICurvesOperations () raises (SALOME::SALOME_Exception);
- GEOM_ILocalOperations GetILocalOperations () raises (SALOME::SALOME_Exception);
- GEOM_IHealingOperations GetIHealingOperations () raises (SALOME::SALOME_Exception);
- GEOM_IInsertOperations GetIInsertOperations () raises (SALOME::SALOME_Exception);
- GEOM_IMeasureOperations GetIMeasureOperations () raises (SALOME::SALOME_Exception);
- GEOM_IBlocksOperations GetIBlocksOperations () raises (SALOME::SALOME_Exception);
- GEOM_IGroupOperations GetIGroupOperations () raises (SALOME::SALOME_Exception);
- GEOM_IFieldOperations GetIFieldOperations () raises (SALOME::SALOME_Exception);
- GEOM_ITestOperations GetITestOperations () raises (SALOME::SALOME_Exception);
+ GEOM_IBasicOperations GetIBasicOperations () raises (SALOME::SALOME_Exception);
+ GEOM_ITransformOperations GetITransformOperations () raises (SALOME::SALOME_Exception);
+ GEOM_I3DPrimOperations GetI3DPrimOperations () raises (SALOME::SALOME_Exception);
+ GEOM_IShapesOperations GetIShapesOperations () raises (SALOME::SALOME_Exception);
+ GEOM_IBooleanOperations GetIBooleanOperations () raises (SALOME::SALOME_Exception);
+ GEOM_ICurvesOperations GetICurvesOperations () raises (SALOME::SALOME_Exception);
+ GEOM_ILocalOperations GetILocalOperations () raises (SALOME::SALOME_Exception);
+ GEOM_IHealingOperations GetIHealingOperations () raises (SALOME::SALOME_Exception);
+ GEOM_IInsertOperations GetIInsertOperations () raises (SALOME::SALOME_Exception);
+ GEOM_IMeasureOperations GetIMeasureOperations () raises (SALOME::SALOME_Exception);
+ GEOM_IBlocksOperations GetIBlocksOperations () raises (SALOME::SALOME_Exception);
+ GEOM_IGroupOperations GetIGroupOperations () raises (SALOME::SALOME_Exception);
+ GEOM_IFieldOperations GetIFieldOperations () raises (SALOME::SALOME_Exception);
+ GEOM_ITestOperations GetITestOperations () raises (SALOME::SALOME_Exception);
+ GEOM_ICanonicalRecognition GetICanonicalRecognition() raises (SALOME::SALOME_Exception);
GEOM_IOperations GetPluginOperations (in string theLibName) raises (SALOME::SALOME_Exception);
GEOMImpl_GlueDriver.hxx
GEOMImpl_Types.hxx
GEOM_GEOMImpl.hxx
+ GEOMImpl_ICanonicalRecognition.hxx
)
# --- sources ---
GEOMImpl_FillingDriver.cxx
GEOMImpl_GlueDriver.cxx
GEOMImpl_FieldDriver.cxx
+ GEOMImpl_ICanonicalRecognition.cxx
)
# --- rules ---
_GroupOperations = new GEOMImpl_IGroupOperations( this );
_FieldOperations = new GEOMImpl_IFieldOperations( this );
_TestOperations = new GEOMImpl_ITestOperations( this );
+ _CanonicalRecognition = new GEOMImpl_ICanonicalRecognition( this );
}
//=============================================================================
delete _MeasureOperations;
delete _GroupOperations;
delete _FieldOperations;
+ delete _CanonicalRecognition;
}
//=============================================================================
{
return _TestOperations;
}
+
+//=============================================================================
+/*!
+ * GetICanonicalRecognition
+ */
+//=============================================================================
+GEOMImpl_ICanonicalRecognition* GEOMImpl_Gen::GetICanonicalRecognition()
+{
+ return _CanonicalRecognition;
+}
#include "GEOMImpl_IGroupOperations.hxx"
#include "GEOMImpl_IFieldOperations.hxx"
#include "GEOMImpl_ITestOperations.hxx"
+#include "GEOMImpl_ICanonicalRecognition.hxx"
#include "GEOM_Engine.hxx"
class GEOMIMPL_EXPORT GEOMImpl_Gen : public GEOM_Engine
GEOMImpl_ITestOperations* GetITestOperations();
+ GEOMImpl_ICanonicalRecognition* GetICanonicalRecognition();
+
private:
- GEOMImpl_IBasicOperations* _BasicOperations;
- GEOMImpl_ITransformOperations* _TransformOperations;
- GEOMImpl_I3DPrimOperations* _3DPrimOperations;
- GEOMImpl_IShapesOperations* _ShapesOperations;
- GEOMImpl_IBlocksOperations* _BlocksOperations;
- GEOMImpl_IBooleanOperations* _BooleanOperations;
- GEOMImpl_IHealingOperations* _HealingOperations;
- GEOMImpl_ICurvesOperations* _CurvesOperations;
- GEOMImpl_ILocalOperations* _LocalOperations;
- GEOMImpl_IInsertOperations* _InsertOperations;
- GEOMImpl_IMeasureOperations* _MeasureOperations;
- GEOMImpl_IGroupOperations* _GroupOperations;
- GEOMImpl_IFieldOperations* _FieldOperations;
- GEOMImpl_ITestOperations* _TestOperations;
+ GEOMImpl_IBasicOperations* _BasicOperations;
+ GEOMImpl_ITransformOperations* _TransformOperations;
+ GEOMImpl_I3DPrimOperations* _3DPrimOperations;
+ GEOMImpl_IShapesOperations* _ShapesOperations;
+ GEOMImpl_IBlocksOperations* _BlocksOperations;
+ GEOMImpl_IBooleanOperations* _BooleanOperations;
+ GEOMImpl_IHealingOperations* _HealingOperations;
+ GEOMImpl_ICurvesOperations* _CurvesOperations;
+ GEOMImpl_ILocalOperations* _LocalOperations;
+ GEOMImpl_IInsertOperations* _InsertOperations;
+ GEOMImpl_IMeasureOperations* _MeasureOperations;
+ GEOMImpl_IGroupOperations* _GroupOperations;
+ GEOMImpl_IFieldOperations* _FieldOperations;
+ GEOMImpl_ITestOperations* _TestOperations;
+ GEOMImpl_ICanonicalRecognition* _CanonicalRecognition;
};
#endif
--- /dev/null
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "GEOMImpl_ICanonicalRecognition.hxx"
+
+#include "GEOM_Function.hxx"
+#include "GEOM_Object.hxx"
+#include "GEOM_PythonDump.hxx"
+
+#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
+#include <ShapeAnalysis_CanonicalRecognition.hxx>
+#include <gp_Pln.hxx>
+
+#include <utilities.h>
+
+
+//=============================================================================
+/*!
+ * constructor:
+ */
+//=============================================================================
+GEOMImpl_ICanonicalRecognition::GEOMImpl_ICanonicalRecognition (GEOM_Engine* theEngine)
+: GEOM_IOperations(theEngine)
+{
+ MESSAGE("GEOMImpl_ICanonicalRecognition::GEOMImpl_ICanonicalRecognition");
+}
+
+//=============================================================================
+/*!
+ * destructor
+ */
+//=============================================================================
+GEOMImpl_ICanonicalRecognition::~GEOMImpl_ICanonicalRecognition()
+{
+ MESSAGE("GEOMImpl_ICanonicalRecognition::~GEOMImpl_ICanonicalRecognition");
+}
+
+//=============================================================================
+/*!
+ * \brief Check if the shape is planar
+ */
+ //=============================================================================
+bool GEOMImpl_ICanonicalRecognition::isPlane(const Handle(GEOM_Object)& theShape, double theTolerance, gp_Pln& thePln)
+{
+ SetErrorCode(KO);
+ if (theShape.IsNull()) {
+ SetErrorCode("Error: NULL shape");
+ return false;
+ }
+ TopoDS_Shape aShape = theShape->GetValue();
+ if (aShape.IsNull())
+ {
+ return false;
+ }
+
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+ SetErrorCode(OK);
+ return aRecognition.IsPlane(theTolerance, thePln);
+}
+
+//=============================================================================
+/*!
+ * \brief Check if shape is spherical
+ */
+ //=============================================================================
+bool GEOMImpl_ICanonicalRecognition::isSphere(const Handle(GEOM_Object)& theShape, double theTolerance,
+ gp_Sphere& theSphere)
+{
+ SetErrorCode(KO);
+ if (theShape.IsNull()) {
+ SetErrorCode("Error: NULL shape");
+ return false;
+ }
+ TopoDS_Shape aShape = theShape->GetValue();
+ if (aShape.IsNull())
+ {
+ return false;
+ }
+
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+ SetErrorCode(OK);
+ return aRecognition.IsSphere(theTolerance, theSphere);
+}
+
+//=============================================================================
+/*!
+ * \brief Check if shape is conical
+ */
+ //=============================================================================
+bool GEOMImpl_ICanonicalRecognition::isCone(const Handle(GEOM_Object)& theShape, double theTolerance,
+ gp_Cone& theCone)
+{
+ SetErrorCode(KO);
+ if (theShape.IsNull()) {
+ SetErrorCode("Error: NULL shape");
+ return false;
+ }
+ TopoDS_Shape aShape = theShape->GetValue();
+ if (aShape.IsNull())
+ {
+ return false;
+ }
+
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+ SetErrorCode(OK);
+ return aRecognition.IsCone(theTolerance, theCone);
+}
+
+//=============================================================================
+/*!
+ * \brief Check if shape is cylinder
+ */
+ //=============================================================================
+bool GEOMImpl_ICanonicalRecognition::isCylinder(const Handle(GEOM_Object)& theShape, double theTolerance,
+ gp_Cylinder& theCylinder)
+{
+ SetErrorCode(KO);
+ if (theShape.IsNull()) {
+ SetErrorCode("Error: NULL shape");
+ return false;
+ }
+ TopoDS_Shape aShape = theShape->GetValue();
+ if (aShape.IsNull())
+ {
+ return false;
+ }
+
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+ SetErrorCode(OK);
+ return aRecognition.IsCylinder(theTolerance, theCylinder);
+}
+
+//=============================================================================
+/*!
+ * \brief Check if edge / wire is line
+ */
+ //=============================================================================
+bool GEOMImpl_ICanonicalRecognition::isLine(const Handle(GEOM_Object)& theEdge, double theTolerance,
+ gp_Lin& theLine)
+{
+ SetErrorCode(KO);
+ if (theEdge.IsNull()) {
+ SetErrorCode("Error: NULL edge");
+ return false;
+ }
+ TopoDS_Shape aShape = theEdge->GetValue();
+ if (aShape.IsNull())
+ {
+ return false;
+ }
+
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+ SetErrorCode(OK);
+ return aRecognition.IsLine(theTolerance, theLine);
+}
+
+//=============================================================================
+/*!
+ * \brief Check if edge / wire is circle
+ */
+ //=============================================================================
+bool GEOMImpl_ICanonicalRecognition::isCircle(const Handle(GEOM_Object)& theEdge, double theTolerance,
+ gp_Circ& theCircle)
+{
+ SetErrorCode(KO);
+ if (theEdge.IsNull()) {
+ SetErrorCode("Error: NULL edge");
+ return false;
+ }
+ TopoDS_Shape aShape = theEdge->GetValue();
+ if (aShape.IsNull())
+ {
+ return false;
+ }
+
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+ SetErrorCode(OK);
+ return aRecognition.IsCircle(theTolerance, theCircle);
+}
+
+//=============================================================================
+/*!
+ * \brief Check if edge / wire is ellipse
+ */
+ //=============================================================================
+bool GEOMImpl_ICanonicalRecognition::isEllipse(const Handle(GEOM_Object)& theEdge, double theTolerance,
+ gp_Elips& theElips)
+{
+ SetErrorCode(KO);
+ if (theEdge.IsNull()) {
+ SetErrorCode("Error: NULL edge");
+ return false;
+ }
+ TopoDS_Shape aShape = theEdge->GetValue();
+ if (aShape.IsNull())
+ {
+ return false;
+ }
+
+ ShapeAnalysis_CanonicalRecognition aRecognition(aShape);
+ SetErrorCode(OK);
+ return aRecognition.IsEllipse(theTolerance, theElips);
+}
--- /dev/null
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef _GEOMImpl_ICanonicalRecognition_HXX_
+#define _GEOMImpl_ICanonicalRecognition_HXX_
+
+#include "GEOM_IOperations.hxx"
+
+#include <GEOM_Field.hxx>
+
+#include <TColStd_HSequenceOfTransient.hxx>
+#include <TColStd_HArray1OfExtendedString.hxx>
+
+#include <vector>
+
+class GEOM_Object;
+
+class GEOMImpl_ICanonicalRecognition : public GEOM_IOperations {
+ public:
+ Standard_EXPORT GEOMImpl_ICanonicalRecognition(GEOM_Engine* theEngine);
+ Standard_EXPORT ~GEOMImpl_ICanonicalRecognition();
+
+ /*!
+ * \brief Check if the shape is planar
+ */
+ Standard_EXPORT bool isPlane(const Handle(GEOM_Object)& theShape, double theTolerance,
+ gp_Pln& thePln);
+
+ /*!
+ * \brief Check if shape is spherical
+ */
+ Standard_EXPORT bool isSphere(const Handle(GEOM_Object)& theShape, double theTolerance,
+ gp_Sphere& theSphere);
+
+ /*!
+ * \brief Check if shape is conical
+ */
+ Standard_EXPORT bool isCone(const Handle(GEOM_Object)& theShape, double theTolerance,
+ gp_Cone& theCone);
+
+ /*!
+ * \brief Check if shape is cylinder
+ */
+ Standard_EXPORT bool isCylinder(const Handle(GEOM_Object)& theShape, double theTolerance,
+ gp_Cylinder& theCylinder);
+
+ /*!
+ * \brief Check if edge / wire is line
+ */
+ Standard_EXPORT bool isLine(const Handle(GEOM_Object)& theEdge, double theTolerance,
+ gp_Lin& theLine);
+
+ /*!
+ * \brief Check if edge / wire is circle
+ */
+ Standard_EXPORT bool isCircle(const Handle(GEOM_Object)& theEdge, double theTolerance,
+ gp_Circ& theCircle);
+
+ /*!
+ * \brief Check if edge / wire is ellipse
+ */
+ Standard_EXPORT bool isEllipse(const Handle(GEOM_Object)& theEdge, double theTolerance,
+ gp_Elips& theElips);
+
+};
+
+#endif
GEOM_IMeasureOperations_i.hh
GEOM_IGroupOperations_i.hh
GEOM_ITestOperations_i.hh
+ GEOM_ICanonicalRecognition_i.hh
GEOM_Gen_i.hh
GEOM_Gen_Session_i.hh
GEOM_Gen_No_Session_i.hh
GEOM_IGroupOperations_i.cc
GEOM_IFieldOperations_i.cc
GEOM_ITestOperations_i.cc
+ GEOM_ICanonicalRecognition_i.cc
GEOM_Gen_i.cc
GEOM_Gen_Session_i.cc
GEOM_Gen_No_Session_i.cc
return operations._retn();
}
+//============================================================================
+// function : GetICanonicalRecognition
+// purpose :
+//============================================================================
+GEOM::GEOM_ICanonicalRecognition_ptr GEOM_Gen_i::GetICanonicalRecognition()
+{
+ Unexpect aCatch(SALOME_SalomeException);
+ MESSAGE("GEOM_Gen_i::GetICanonicalRecognition");
+
+ GEOM::GEOM_Gen_ptr engine = _this();
+
+ GEOM_ICanonicalRecognition_i* aServant =
+ new GEOM_ICanonicalRecognition_i(_poa, engine, _impl->GetICanonicalRecognition());
+
+ // activate the CORBA servant
+ GEOM::GEOM_ICanonicalRecognition_var operations = aServant->_this();
+ return operations._retn();
+}
+
//============================================================================
// function : GetPluginOperations
// purpose :
#include "GEOM_IGroupOperations_i.hh"
#include "GEOM_IFieldOperations_i.hh"
#include "GEOM_ITestOperations_i.hh"
+#include "GEOM_ICanonicalRecognition_i.hh"
#include "GEOMUtils.hxx"
#include <TopTools_IndexedMapOfShape.hxx>
virtual GEOM::GEOM_ITestOperations_ptr GetITestOperations()
;
+ virtual GEOM::GEOM_ICanonicalRecognition_ptr GetICanonicalRecognition();
+
//Returns a pointer to corresponding plugin operations interface
virtual GEOM::GEOM_IOperations_ptr GetPluginOperations (const char* theLibName)
;
--- /dev/null
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#include "GEOM_ICanonicalRecognition_i.hh"
+
+#include "utilities.h"
+#include "OpUtil.hxx"
+#include "Utils_ExceptHandlers.hxx"
+
+#include "GEOM_Engine.hxx"
+#include "GEOM_Object.hxx"
+#include "GEOM_Field.hxx"
+
+#include "gp_Pln.hxx"
+#include "gp_Sphere.hxx"
+#include "gp_Cone.hxx"
+#include "gp_Cylinder.hxx"
+#include "gp_Circ.hxx"
+#include "gp_Elips.hxx"
+
+//=============================================================================
+/*
+ * constructor:
+ */
+//=============================================================================
+GEOM_ICanonicalRecognition_i::GEOM_ICanonicalRecognition_i (PortableServer::POA_ptr thePOA,
+ GEOM::GEOM_Gen_ptr theEngine,
+ ::GEOMImpl_ICanonicalRecognition* theImpl)
+ :GEOM_IOperations_i(thePOA, theEngine, theImpl)
+{
+ MESSAGE("GEOM_ICanonicalRecognition_i::GEOM_ICanonicalRecognition_i");
+}
+
+//=============================================================================
+/*
+ * destructor
+ */
+//=============================================================================
+GEOM_ICanonicalRecognition_i::~GEOM_ICanonicalRecognition_i()
+{
+ MESSAGE("GEOM_ICanonicalRecognition_i::~GEOM_ICanonicalRecognition_i");
+}
+
+//=============================================================================
+/*
+ * \brief Check if the shape is planar
+ */
+ //=============================================================================
+CORBA::Boolean GEOM_ICanonicalRecognition_i::isPlane(GEOM::GEOM_Object_ptr theShape, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theNormal, GEOM::ListOfDouble& theOrigin)
+{
+ Handle(::GEOM_Object) go = GetObjectImpl(theShape);
+
+ bool aIsValidNormal = theNormal.length() == 3;
+ bool aIsValidOrigin = theOrigin.length() == 3;
+ gp_Pln aPln;
+ if (aIsValidNormal && aIsValidOrigin) {
+ aPln = gp_Pln(gp_Pnt(theOrigin[0], theOrigin[1], theOrigin[2]),
+ gp_Dir(theNormal[0], theNormal[1], theNormal[2]));
+ }
+ bool aResult = GetOperation()->isPlane(go, theTolerance, aPln);
+ if (aResult && aIsValidNormal && aIsValidOrigin)
+ {
+ gp_Pnt aOrig = aPln.Location();
+ theOrigin[0] = aOrig.X();
+ theOrigin[1] = aOrig.Y();
+ theOrigin[2] = aOrig.Z();
+
+ gp_Dir aNorm = aPln.Axis().Direction();
+ theNormal[0] = aNorm.X();
+ theNormal[1] = aNorm.Y();
+ theNormal[2] = aNorm.Z();
+ }
+ return aResult;
+}
+
+//=============================================================================
+/*
+ * \brief Check if shape is spherical
+ */
+ //=============================================================================
+CORBA::Boolean GEOM_ICanonicalRecognition_i::isSphere(GEOM::GEOM_Object_ptr theShape, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theOrigin, CORBA::Double& theRadius)
+{
+ Handle(::GEOM_Object) go = GetObjectImpl(theShape);
+
+ bool aIsValidOrigin = theOrigin.length() == 3;
+ bool aIsValidRadius = theRadius > 0;
+ gp_Sphere aSphere;
+ if (aIsValidOrigin && aIsValidRadius)
+ {
+ aSphere.SetLocation(gp_Pnt(theOrigin[0], theOrigin[1], theOrigin[2]));
+ aSphere.SetRadius(theRadius);
+ }
+ bool aResult = GetOperation()->isSphere(go, theTolerance, aSphere);
+ if (aResult && aIsValidOrigin && aIsValidRadius)
+ {
+ gp_Pnt aLoc = aSphere.Location();
+ theOrigin[0] = aLoc.X();
+ theOrigin[1] = aLoc.Y();
+ theOrigin[2] = aLoc.Z();
+ theRadius = aSphere.Radius();
+ }
+ return aResult;
+}
+
+//=============================================================================
+/*
+ * \brief Check if shape is conical
+ */
+ //=============================================================================
+CORBA::Boolean GEOM_ICanonicalRecognition_i::isCone(GEOM::GEOM_Object_ptr theShape, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theAxis, GEOM::ListOfDouble& theApex, CORBA::Double& theHalfAngle)
+{
+ Handle(::GEOM_Object) go = GetObjectImpl(theShape);
+
+ bool aIsValidAxis = theAxis.length() == 3;
+ bool aIsValidApex = theApex.length() == 3;
+ bool aIsValidAngle = theHalfAngle > 0;
+ gp_Cone aCone;
+ if (aIsValidAxis && aIsValidApex && aIsValidAngle)
+ {
+ gp_Pnt aLoc(theApex[0], theApex[1], theApex[2]);
+ aCone.SetLocation(aLoc);
+ aCone.SetAxis(gp_Ax1(aLoc, gp_Dir(theAxis[0], theAxis[1], theAxis[2])));
+ }
+ bool aResult = GetOperation()->isCone(go, theTolerance, aCone);
+ if (aResult && aIsValidAxis && aIsValidApex && aIsValidAngle)
+ {
+ gp_Dir aDir = aCone.Axis().Direction();
+ theAxis[0] = aDir.X();
+ theAxis[1] = aDir.Y();
+ theAxis[2] = aDir.Z();
+
+ gp_Pnt aApex = aCone.Apex();
+ theApex[0] = aApex.X();
+ theApex[1] = aApex.Y();
+ theApex[2] = aApex.Z();
+
+ theHalfAngle = aCone.SemiAngle();
+ }
+ return aResult;
+}
+
+//=============================================================================
+/*!
+ * \brief Check if shape is cylinder
+ */
+ //=============================================================================
+CORBA::Boolean GEOM_ICanonicalRecognition_i::isCylinder(GEOM::GEOM_Object_ptr theShape, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theAxis, GEOM::ListOfDouble& theOrigin, CORBA::Double& theRadius)
+{
+ Handle(::GEOM_Object) go = GetObjectImpl(theShape);
+
+ bool aIsValidAxis = theAxis.length() == 3;
+ bool aIsValidOrigin = theOrigin.length() == 3;
+ bool aIsValidRadius = theRadius > 0;
+ gp_Cylinder aCylinder;
+ if (aIsValidAxis && aIsValidOrigin && aIsValidRadius)
+ {
+ gp_Pnt aLoc(theOrigin[0], theOrigin[0], theOrigin[0]);
+ aCylinder.SetLocation(aLoc);
+ aCylinder.SetAxis(gp_Ax1(aLoc, gp_Dir(theAxis[0], theAxis[1], theAxis[2])));
+ aCylinder.SetRadius(theRadius);
+ }
+ bool aResult = GetOperation()->isCylinder(go, theTolerance, aCylinder);
+ if (aResult && aIsValidAxis && aIsValidOrigin && aIsValidRadius)
+ {
+ gp_Dir aDir = aCylinder.Axis().Direction();
+ theAxis[0] = aDir.X();
+ theAxis[1] = aDir.Y();
+ theAxis[2] = aDir.Z();
+
+ gp_Pnt aLoc = aCylinder.Location();
+ theOrigin[0] = aLoc.X();
+ theOrigin[1] = aLoc.Y();
+ theOrigin[2] = aLoc.Z();
+
+ theRadius = aCylinder.Radius();
+ }
+ return aResult;
+}
+
+//=============================================================================
+/*!
+ * \brief Check if edge / wire is line
+ */
+ //=============================================================================
+CORBA::Boolean GEOM_ICanonicalRecognition_i::isLine(GEOM::GEOM_Object_ptr theEdge, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theDir, GEOM::ListOfDouble& theOrigin)
+{
+ Handle(::GEOM_Object) go = GetObjectImpl(theEdge);
+
+ bool aIsValidDir = theDir.length() == 3;
+ bool aIsValidOrigin = theOrigin.length() == 3;
+ gp_Lin aLine;
+ if (aIsValidDir && aIsValidOrigin)
+ {
+ aLine.SetLocation(gp_Pnt(theOrigin[0], theOrigin[1], theOrigin[2]));
+ aLine.SetDirection(gp_Dir(theDir[0], theDir[1], theDir[2]));
+ }
+ bool aResult = GetOperation()->isLine(go, theTolerance, aLine);
+ if (aResult && aIsValidDir && aIsValidOrigin)
+ {
+ gp_Pnt aLoc = aLine.Location();
+ theOrigin[0] = aLoc.X();
+ theOrigin[1] = aLoc.Y();
+ theOrigin[2] = aLoc.Z();
+
+ gp_Dir aDir = aLine.Direction();
+ theDir[0] = aDir.X();
+ theDir[1] = aDir.Y();
+ theDir[2] = aDir.Z();
+ }
+ return aResult;
+}
+
+//=============================================================================
+/*!
+ * \brief Check if edge / wire is circle
+ */
+ //=============================================================================
+CORBA::Boolean GEOM_ICanonicalRecognition_i::isCircle(GEOM::GEOM_Object_ptr theEdge, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theNormal, GEOM::ListOfDouble& theOrigin, CORBA::Double& theRadius)
+{
+ Handle(::GEOM_Object) go = GetObjectImpl(theEdge);
+ bool aIsValidNormal = theNormal.length() == 3;
+ bool aIsValidOrigin = theOrigin.length() == 3;
+ bool aIsValidRadius = theRadius > 0;
+ gp_Circ aCircle;
+ if (aIsValidNormal && aIsValidOrigin && aIsValidRadius)
+ {
+ aCircle.SetAxis(gp_Ax1(gp_Pnt(theOrigin[0], theOrigin[1], theOrigin[2]),
+ gp_Dir(theNormal[0], theNormal[1], theNormal[2])));
+ aCircle.SetRadius(theRadius);
+ }
+ bool aResult = GetOperation()->isCircle(go, theTolerance, aCircle);
+ if (aResult && aIsValidNormal && aIsValidOrigin && aIsValidRadius)
+ {
+ gp_Pnt aLoc = aCircle.Location();
+ theOrigin[0] = aLoc.X();
+ theOrigin[1] = aLoc.Y();
+ theOrigin[2] = aLoc.Z();
+
+ gp_Dir aDir = aCircle.Axis().Direction();
+ theNormal[0] = aDir.X();
+ theNormal[1] = aDir.Y();
+ theNormal[2] = aDir.Z();
+ theRadius = aCircle.Radius();
+ }
+ return aResult;
+}
+
+//=============================================================================
+/*!
+ * \brief Check if edge / wire is ellipse
+ */
+ //=============================================================================
+CORBA::Boolean GEOM_ICanonicalRecognition_i::isEllipse(GEOM::GEOM_Object_ptr theEdge, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theNormal, GEOM::ListOfDouble& theDirX, GEOM::ListOfDouble& theOrigin,
+ CORBA::Double& theMajorRadius, CORBA::Double& theMinorRadius)
+{
+ Handle(::GEOM_Object) go = GetObjectImpl(theEdge);
+ bool aIsValidNormal = theNormal.length() == 3;
+ bool aIsValidOrigin = theOrigin.length() == 3;
+ bool aIsValidDirX = theDirX.length() == 3;
+ bool aIsValidRad1 = (theMajorRadius > 0) && (theMajorRadius > theMinorRadius);
+ bool aIsValidRad2 = (theMinorRadius > 0) && (theMajorRadius > theMinorRadius);
+
+ 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]));
+ aElips = gp_Elips(aAx2, theMajorRadius, theMinorRadius);
+ }
+ bool aResult = GetOperation()->isEllipse(go, theTolerance, aElips);
+ if (aResult && aIsValidNormal && aIsValidOrigin && aIsValidDirX && aIsValidRad1 && aIsValidRad2)
+ {
+ gp_Pnt aLoc = aElips.Position().Location();
+ theOrigin[0] = aLoc.X();
+ theOrigin[1] = aLoc.Y();
+ theOrigin[2] = aLoc.Z();
+
+ gp_Dir aNorm = aElips.Position().Direction();
+ theNormal[0] = aNorm.X();
+ theNormal[1] = aNorm.Y();
+ theNormal[2] = aNorm.Z();
+
+ gp_Dir aDirX = aElips.Position().XDirection();
+ theDirX[0] = aDirX.X();
+ theDirX[1] = aDirX.Y();
+ theDirX[2] = aDirX.Z();
+
+ theMajorRadius = aElips.MajorRadius();
+ theMinorRadius = aElips.MinorRadius();
+ }
+ return aResult;
+}
--- /dev/null
+// Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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
+//
+
+#ifndef _GEOM_ICanonicalRecognition_i_HeaderFile
+#define _GEOM_ICanonicalRecognition_i_HeaderFile
+
+#include "GEOMImpl_Gen.hxx"
+
+#include <SALOMEconfig.h>
+
+#include CORBA_SERVER_HEADER(GEOM_Gen)
+#include "GEOM_IOperations_i.hh"
+#include "GEOM_Object_i.hh"
+
+#include "GEOMImpl_ICanonicalRecognition.hxx"
+
+class GEOM_I_EXPORT GEOM_ICanonicalRecognition_i :
+ public virtual POA_GEOM::GEOM_ICanonicalRecognition,
+ public virtual GEOM_IOperations_i
+{
+ public:
+ GEOM_ICanonicalRecognition_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine,
+ ::GEOMImpl_ICanonicalRecognition* theImpl);
+ ~GEOM_ICanonicalRecognition_i();
+
+ /*!
+ * \brief Check if the shape is planar
+ */
+ CORBA::Boolean isPlane(GEOM::GEOM_Object_ptr theShape, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theNormal, GEOM::ListOfDouble& theOrigin);
+
+ /*!
+ * \brief Check if shape is spherical
+ */
+ CORBA::Boolean isSphere(GEOM::GEOM_Object_ptr theShape, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theOrigin, CORBA::Double& theRadius);
+
+ /*!
+ * \brief Check if shape is conical
+ */
+ CORBA::Boolean isCone(GEOM::GEOM_Object_ptr theShape, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theAxis, GEOM::ListOfDouble& theApex,
+ CORBA::Double& theHalfAngle);
+
+ /*!
+ * \brief Check if shape is cylinder
+ */
+ CORBA::Boolean isCylinder(GEOM::GEOM_Object_ptr theShape, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theAxis, GEOM::ListOfDouble& theOrigin,
+ CORBA::Double& theRadius);
+
+ /*!
+ * \brief Check if edge / wire is line
+ */
+ CORBA::Boolean isLine(GEOM::GEOM_Object_ptr theEdge, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theDir, GEOM::ListOfDouble& theOrigin);
+
+ /*!
+ * \brief Check if edge / wire is circle
+ */
+ CORBA::Boolean isCircle(GEOM::GEOM_Object_ptr theEdge, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theNormal, GEOM::ListOfDouble& theOrigin,
+ CORBA::Double& theRadius);
+
+ /*!
+ * \brief Check if edge / wire is ellipse
+ */
+ CORBA::Boolean isEllipse(GEOM::GEOM_Object_ptr theEdge, CORBA::Double theTolerance,
+ GEOM::ListOfDouble& theNormal, GEOM::ListOfDouble& theDirX,
+ GEOM::ListOfDouble& theOrigin,
+ CORBA::Double& theMajorRadius, CORBA::Double& theMinorRadius);
+
+ ::GEOMImpl_ICanonicalRecognition* GetOperation()
+ { return (::GEOMImpl_ICanonicalRecognition*)GetImpl(); }
+};
+
+#endif
GEOM_Nut.py
GEOM_Sketcher.py
GEOM_ObjectInfo.py
+ GEOM_TestCR.py
PAL_MESH_019_020_geometry.py
PAL_MESH_028_geometry.py
PAL_MESH_030_geometry.py
SET(_python_SCRIPTS
geomBuilder.py
gsketcher.py
+ canonicalrecognition.py
)
# Advanced scripts
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# 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
+#
+
+import salome
+
+salome.salome_init()
+
+import GEOM
+from salome.geom import geomBuilder
+import math
+import SALOMEDS
+
+geompy = geomBuilder.New()
+
+def GetShapeType(theShape):
+ CR = geompy.CanonicalRecognition()
+ if CR.isPlane(theShape, 0.1)[0]:
+ return "Plane"
+ if CR.isSphere(theShape, 0.1)[0]:
+ return "Sphere"
+ if CR.isCone(theShape, 0.1)[0]:
+ return "Cone"
+ if CR.isCylinder(theShape, 0.1)[0]:
+ return "Cylinder"
+ if CR.isLine(theShape, 0.1)[0]:
+ return "Line"
+ if CR.isCircle(theShape, 0.1)[0]:
+ return "Circle"
+ if CR.isEllipse(theShape, 0.1)[0]:
+ return "Ellipse"
+ return "Not defined"
+
+O = geompy.MakeVertex(0, 0, 0)
+OX = geompy.MakeVectorDXDYDZ(1, 0, 0)
+OY = geompy.MakeVectorDXDYDZ(0, 1, 0)
+OZ = geompy.MakeVectorDXDYDZ(0, 0, 1)
+Cylinder_1 = geompy.MakeCylinderRH(100, 300)
+[Face_1,Face_2,Face_3] = geompy.ExtractShapes(Cylinder_1, geompy.ShapeType["FACE"], True)
+[Edge_1,Edge_2,Edge_3] = geompy.ExtractShapes(Cylinder_1, geompy.ShapeType["EDGE"], True)
+Sphere_1 = geompy.MakeSphereR(100)
+[Shell_1] = geompy.ExtractShapes(Sphere_1, geompy.ShapeType["SHELL"], True)
+Cone_1 = geompy.MakeConeR1R2H(100, 0, 300)
+[Shell_2] = geompy.ExtractShapes(Cone_1, geompy.ShapeType["SHELL"], True)
+[Face_4,Face_5] = geompy.ExtractShapes(Shell_2, geompy.ShapeType["FACE"], True)
+
+## Create ellips
+Cylinder_2 = geompy.MakeCylinderRH(100, 300)
+Plane_1 = geompy.MakePlaneLCS(None, 350, 1)
+Translation_1 = geompy.MakeTranslation(Plane_1, 0, 0, 150)
+Rotation_1 = geompy.MakeRotation(Translation_1, OX, 20*math.pi/180.0)
+Partition_1 = geompy.MakePartition([Cylinder_2], [Rotation_1], [], [], geompy.ShapeType["SOLID"], 0, [], 0)
+[Edge_4,Edge_5,Edge_6,Edge_7,Edge_8] = geompy.ExtractShapes(Partition_1, geompy.ShapeType["EDGE"], True)
+
+assert GetShapeType(Face_1) == "Plane"
+assert GetShapeType(Face_2) == "Cylinder"
+assert GetShapeType(Edge_3) == "Line"
+assert GetShapeType(Edge_2) == "Circle"
+assert GetShapeType(Shell_1) == "Sphere"
+assert GetShapeType(Shell_2) == "Cone"
+assert GetShapeType(Edge_5) == "Ellipse"
--- /dev/null
+import salome
+salome.salome_init()
+import GEOM
+from salome.geom import geomBuilder
+
+geompy = geomBuilder.New()
+aCircle = geompy.MakeCircleR(150.)
+aCylinder = geompy.MakeCylinderRH(100.,200.)
+
+aCR = geompy.CanonicalRecognition()
+aCR.isCylinder(aCylinder, 0.1)
--- /dev/null
+# -*- coding: iso-8859-1 -*-
+# Copyright (C) 2007-2022 CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# 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
+#
+# File : GEOM_CanonicalRecognition.py
+# Author : Vitaly SMETANNIKOV, Open CASCADE S.A.S.
+# Module : GEOM_SWIG
+
+
+class CanonicalRecognition:
+ "The class provides recognition of canonical shapes"
+
+ def __init__(self, geompyD):
+ self.CR = geompyD.GetICanonicalRecognition()
+
+ def isPlane(self, shape, tolerance, normal = [], origin = []):
+ "Check if shape is planar"
+ return self.CR.isPlane(shape, tolerance, normal, origin)
+
+ def isSphere(self, shape, tolerance, origin = [], radius = 0.0):
+ "Check if shape is spherical"
+ return self.CR.isSphere(shape, tolerance, origin, radius)
+
+ def isCone(self, shape, tolerance, axis = [], apex = [], halfAngle = 0.0):
+ "Check if shape is conical"
+ return self.CR.isCone(shape, tolerance, axis, apex, halfAngle)
+
+ def isCylinder(self, shape, tolerance, axis = [], origin = [], radius = 0.0):
+ "Check if shape is cylinder"
+ return self.CR.isCylinder(shape, tolerance, axis, origin, radius)
+
+ def isLine(self, edge, tolerance, direction = [], origin = []):
+ "Check if edge/wire is line"
+ return self.CR.isLine(edge, tolerance, direction, origin)
+
+ def isCircle(self, edge, tolerance, normal = [], origin = [], radius = 0.0):
+ "Check if edge/wire is circle"
+ return self.CR.isCircle(edge, tolerance, normal, origin, radius)
+
+ def isEllipse(self, edge, tolerance, normal = [], dirX = [], origin = [], majorRadius = 0.0, minorRadius = 0.0):
+ "Check if edge/wire is ellipse"
+ return self.CR.isEllipse(edge, tolerance, normal, dirX, origin, majorRadius, minorRadius)
import functools
from salome.geom.gsketcher import Sketcher3D, Sketcher2D, Polyline2D
+from salome.geom.canonicalrecognition import CanonicalRecognition
# In case the omniORBpy EnumItem class does not fully support Python 3
# (for instance in version 4.2.1-2), the comparison ordering methods must be
pl = Polyline2D (self)
return pl
+ ## Obtain a 2D polyline creation interface
+ # @return An instance of @ref gsketcher.Polyline2D "Polyline2D" interface
+ #
+ # @ref tui_3dsketcher_page "Example"
+ def CanonicalRecognition (self):
+ """
+ Obtain a canonical recognition interface.
+
+ Example of usage:
+ cr = geompy.CanonicalRecognition()
+ cr.isLine(aLine, tolerance)
+ """
+ cr = CanonicalRecognition (self)
+ return cr
+
# end of l3_sketcher
## @}