-// Copyright (C) 2007-2019 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2020 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
#include <vtkActorCollection.h>
// OCCT includes
+#include <TColStd_MapOfAsciiString.hxx>
#include <TColStd_MapOfInteger.hxx>
// Qt includes
return aName;
}
+//=======================================================================
+//function : setDefaultName
+//purpose :
+//=======================================================================
+
void SMESHGUI_GroupDlg::setDefaultName() const
{
QString aResName;
- int i=1;
- QString aPrefix ="Group_";
- _PTR(SObject) anObj;
- do
+ const QString aPrefix ="Group_";
+
+ if ( myMesh->_is_nil() )
{
- aResName = aPrefix + QString::number( i++ );
- anObj = SMESH::getStudy()->FindObject( aResName.toUtf8().constData() );
+ aResName = aPrefix + "1";
+ }
+ else
+ {
+ SMESH::ListOfGroups_var allGroups = myMesh->GetGroups();
+ TColStd_MapOfAsciiString allNames( allGroups->length() );
+ for ( CORBA::ULong i = 0; i < allGroups->length(); ++i )
+ {
+ CORBA::String_var name = allGroups[i]->GetName();
+ allNames.Add( name.in() );
+ }
+ int i = 1;
+ while ( true )
+ {
+ aResName = aPrefix + QString::number( i++ );
+ if ( !allNames.Contains( aResName.toUtf8().constData() ))
+ break;
+ }
}
- while ( anObj );
- myName->setText(aResName);
+ myName->setText(aResName);
}
//=================================================================================
if (myGroup->_is_nil()) { // creation or conversion
// check if group on geometry is not null
- if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil()) {
+ if (!myGroupOnGeom->_is_nil() || !myGroupOnFilter->_is_nil())
+ {
if (myMesh->_is_nil())
return false;
if ( myGroupOnGeom->_is_nil() )
}
}
- if (myGroup->_is_nil()) { // creation
+ if (myGroup->_is_nil()) // creation
+ {
if (myMesh->_is_nil())
return false;
myGroup->Add(anIdList.inout());
}
}
+ }
-
- } else { // edition
-
+ else // edition
+ {
resultGroup = SMESH::SMESH_GroupBase::_narrow( myGroup );
isCreation = false;
if (geomGen->_is_nil())
return false;
- GEOM::GEOM_IGroupOperations_ptr op = geomGen->GetIGroupOperations();
+ GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations();
if (op->_is_nil())
return false;
}
anIsOk = true;
}
+
if (myGrpTypeId == 2) // group on filter
{
if ( myFilter->_is_nil() ) return false;
Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
if ( isConversion ) { // need to reset TVisualObj and actor
SMESH::RemoveVisualObjectWithActors( anIO->getEntry(), true );
- SMESH::Update( anIO,true);
+ SMESH::Update( anIO, true );
myActorsList.clear();
anActor = SMESH::FindActorByEntry( anIO->getEntry() );
if ( !anActor ) return false;
SALOME_ListIteratorOfListIO anIt (aList);
for (; anIt.More(); anIt.Next())
{
- aGeomGroup = GEOMBase::ConvertIOinGEOMObject(anIt.Value());
-
+ CORBA::Object_var aGroupObj = SMESH::IObjectToObject(anIt.Value());
+ if (CORBA::is_nil(aGroupObj))
+ continue;
// Check if the object is a geometry group
+ aGeomGroup = GEOM::GEOM_Object::_narrow(aGroupObj);
if (CORBA::is_nil(aGeomGroup))
continue;
GEOM::GEOM_Object_var aGroupMainShape;
if (aGeomGroup->GetType() == 37)
{
- GEOM::GEOM_IGroupOperations_ptr anOp =
+ GEOM::GEOM_IGroupOperations_wrap anOp =
SMESH::GetGEOMGen( aGeomGroup )->GetIGroupOperations();
aGroupMainShape = anOp->GetMainShape( aGeomGroup );
// aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap
}
else if ( myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1 )
{
- GEOM::GEOM_IGroupOperations_ptr aGroupOp =
+ GEOM::GEOM_IGroupOperations_wrap aGroupOp =
SMESH::GetGEOMGen( myGeomObjects[0] )->GetIGroupOperations();
SMESH::ElementType aGroupType = SMESH::ALL;