-// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2021 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
// SALOME GEOM includes
#include <GEOMBase.h>
#include <GEOMImpl_Types.hxx>
+#include <GEOM_Client.hxx>
#include <GEOM_SelectionFilter.h>
#include <GEOM_wrap.hxx>
#include <GeometryGUI.h>
//================================================================================
/*!
* \brief check if selected shape is a sub-shape of the shape to mesh
- * \retval bool - check result
+ * \retval bool - check result
*/
//================================================================================
bool SMESHGUI_MeshOp::isSubshapeOk() const
QStringList aGEOMs;
myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
- if (aGEOMs.count() > 0) {
- GEOM::GEOM_Gen_var geomGen = mainGeom->GetGen();
- if (geomGen->_is_nil()) return false;
-
- GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations();
- if (op->_is_nil()) return false;
-
- // check all selected shapes
- QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
- for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++) {
- QString aSubGeomEntry = (*aSubShapesIter);
- _PTR(SObject) pSubGeom = SMESH::getStudy()->FindObjectID(aSubGeomEntry.toUtf8().data());
- if (!pSubGeom) return false;
-
- GEOM::GEOM_Object_var aSubGeomVar =
- GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
- if (aSubGeomVar->_is_nil()) return false;
-
- // skl for NPAL14695 - implementation of searching of mainObj
- GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar); /* _var not _wrap as
- mainObj already exists! */
- while( !mainObj->_is_nil()) {
- CORBA::String_var entry1 = mainObj->GetEntry();
- CORBA::String_var entry2 = mainGeom->GetEntry();
- if (std::string( entry1.in() ) == entry2.in() )
- return true;
- mainObj = op->GetMainShape(mainObj);
- }
- if ( aSubGeomVar->GetShapeType() == GEOM::COMPOUND )
- {
- // is aSubGeomVar a compound of sub-shapes?
- GEOM::GEOM_IShapesOperations_wrap sop = geomGen->GetIShapesOperations();
- if (sop->_is_nil()) return false;
- GEOM::ListOfLong_var ids = sop->GetAllSubShapesIDs( aSubGeomVar,
- GEOM::SHAPE,/*sorted=*/false);
- if ( ids->length() > 0 )
- {
- ids->length( 1 );
- GEOM::GEOM_Object_var compSub = geomGen->AddSubShape( aSubGeomVar, ids );
- if ( !compSub->_is_nil() )
- {
- GEOM::ListOfGO_var shared = sop->GetSharedShapes( mainGeom,
- compSub,
- compSub->GetShapeType() );
- geomGen->RemoveObject( compSub );
- compSub->UnRegister();
- if ( shared->length() > 0 ) {
- geomGen->RemoveObject( shared[0] );
- shared[0]->UnRegister();
- }
- return ( shared->length() > 0 );
- }
- }
- }
- }
+ // check all selected shapes
+ for ( QString& aSubGeomEntry : aGEOMs )
+ {
+ _PTR(SObject) pSubGeom = SMESH::getStudy()->FindObjectID( aSubGeomEntry.toUtf8().data() );
+ if ( !pSubGeom ) return false;
+
+ GEOM::GEOM_Object_var subGeom =
+ GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
+
+ if ( SMESH::ContainsSubShape( mainGeom, subGeom ))
+ return true;
}
return false;