mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-01-24 10:20:32 +05:00
bos #24761 EDF 24020 - Difference of behavior between submesh and group from geom
Enable group creation on a group sharing items with another group, which is the shape to mesh
This commit is contained in:
parent
52762f2639
commit
735f27e37f
@ -42,6 +42,11 @@
|
||||
|
||||
#include <QString>
|
||||
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <TopTools_IndexedMapOfShape.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
|
||||
namespace SMESH
|
||||
{
|
||||
GEOM::GEOM_Gen_var GetGEOMGen( GEOM::GEOM_Object_ptr go )
|
||||
@ -244,4 +249,80 @@ namespace SMESH
|
||||
}
|
||||
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return type of shape contained in a group
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
TopAbs_ShapeEnum _getGroupType(const TopoDS_Shape& group)
|
||||
{
|
||||
if ( group.ShapeType() != TopAbs_COMPOUND )
|
||||
return group.ShapeType();
|
||||
|
||||
// iterate on a compound
|
||||
TopoDS_Iterator it( group );
|
||||
if ( it.More() )
|
||||
return _getGroupType( it.Value() );
|
||||
|
||||
return TopAbs_SHAPE;
|
||||
}
|
||||
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Check if a subGeom contains sub-shapes of a mainGeom
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
bool ContainsSubShape( GEOM::GEOM_Object_ptr mainGeom,
|
||||
GEOM::GEOM_Object_ptr subGeom )
|
||||
{
|
||||
if ( CORBA::is_nil( mainGeom ) ||
|
||||
CORBA::is_nil( subGeom ))
|
||||
return false;
|
||||
|
||||
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;
|
||||
|
||||
GEOM::GEOM_Object_var mainObj = op->GetMainShape( subGeom ); /* _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 ( subGeom->GetShapeType() == GEOM::COMPOUND )
|
||||
{
|
||||
// is subGeom a compound of sub-shapes?
|
||||
GEOM::GEOM_IShapesOperations_wrap sop = geomGen->GetIShapesOperations();
|
||||
if ( sop->_is_nil() ) return false;
|
||||
GEOM::ListOfLong_var ids = sop->GetAllSubShapesIDs( subGeom,
|
||||
GEOM::SHAPE,/*sorted=*/false);
|
||||
if ( ids->length() > 0 )
|
||||
{
|
||||
GEOM_Client geomClient;
|
||||
TopoDS_Shape subShape = geomClient.GetShape( geomGen, subGeom );
|
||||
TopoDS_Shape mainShape = geomClient.GetShape( geomGen, mainGeom );
|
||||
if ( subShape.IsNull() || mainShape.IsNull() )
|
||||
return false;
|
||||
|
||||
TopAbs_ShapeEnum subType = _getGroupType( subShape );
|
||||
TopTools_IndexedMapOfShape subMap;
|
||||
TopExp::MapShapes( subShape, subType, subMap );
|
||||
for ( TopExp_Explorer exp( mainShape, subType ); exp.More(); exp.Next() )
|
||||
if ( subMap.Contains( exp.Current() ))
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
} // end of namespace SMESH
|
||||
|
@ -59,6 +59,9 @@ namespace SMESH
|
||||
|
||||
SMESHGUI_EXPORT bool GetGeomEntries( Handle(SALOME_InteractiveObject)& hypIO,
|
||||
QString& subGeom, QString& meshGeom);
|
||||
|
||||
SMESHGUI_EXPORT bool ContainsSubShape( GEOM::GEOM_Object_ptr mainShape,
|
||||
GEOM::GEOM_Object_ptr subShape );
|
||||
}
|
||||
|
||||
#endif // SMESHGUI_GEOMGENUTILS_H
|
||||
|
@ -1405,72 +1405,23 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
||||
else if (myCurrentLineEdit == myGeomGroupLine)
|
||||
{
|
||||
myGeomObjects = new GEOM::ListOfGO();
|
||||
myGeomObjects->length( aNbSel );
|
||||
|
||||
// The mesh SObject
|
||||
_PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
|
||||
|
||||
if (aNbSel == 0 || !aMeshSO)
|
||||
if ( aNbSel == 0 || myMesh->_is_nil() )
|
||||
{
|
||||
myGeomObjects->length(0);
|
||||
updateButtons();
|
||||
myIsBusy = false;
|
||||
return;
|
||||
}
|
||||
|
||||
myGeomObjects->length(aNbSel);
|
||||
|
||||
GEOM::GEOM_Object_var aGeomGroup;
|
||||
GEOM::GEOM_Object_var mainGeom = myMesh->GetShapeToMesh();
|
||||
int i = 0;
|
||||
|
||||
SALOME_ListIteratorOfListIO anIt (aList);
|
||||
for (; anIt.More(); anIt.Next())
|
||||
for ( SALOME_ListIteratorOfListIO anIt( aList ); anIt.More(); anIt.Next() )
|
||||
{
|
||||
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;
|
||||
|
||||
// Check if group constructed on the same shape as a mesh or on its child
|
||||
|
||||
// The main shape of the group
|
||||
GEOM::GEOM_Object_var aGroupMainShape;
|
||||
if (aGeomGroup->GetType() == 37)
|
||||
{
|
||||
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
|
||||
{
|
||||
aGroupMainShape = aGeomGroup;
|
||||
aGroupMainShape->Register();
|
||||
}
|
||||
CORBA::String_var entry = aGroupMainShape->GetStudyEntry();
|
||||
_PTR(SObject) aGroupMainShapeSO =
|
||||
SMESH::getStudy()->FindObjectID( entry.in() );
|
||||
|
||||
_PTR(SObject) anObj, aRef;
|
||||
bool isRefOrSubShape = false;
|
||||
if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) {
|
||||
if (aRef->GetID() == aGroupMainShapeSO->GetID()) {
|
||||
isRefOrSubShape = true;
|
||||
} else {
|
||||
_PTR(SObject) aFather = aGroupMainShapeSO->GetFather();
|
||||
_PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent();
|
||||
while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) {
|
||||
if (aRef->GetID() == aFather->GetID())
|
||||
isRefOrSubShape = true;
|
||||
else
|
||||
aFather = aFather->GetFather();
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isRefOrSubShape)
|
||||
myGeomObjects[i++] = aGeomGroup;
|
||||
GEOM::GEOM_Object_var geomGroup = SMESH::GetGeom( anIt.Value() );
|
||||
if ( SMESH::ContainsSubShape( mainGeom, geomGroup ))
|
||||
myGeomObjects[ i++ ] = geomGroup;
|
||||
}
|
||||
|
||||
myGeomObjects->length(i);
|
||||
|
@ -178,7 +178,7 @@ private:
|
||||
QPushButton* myAddBtn;
|
||||
QPushButton* myRemoveBtn;
|
||||
QPushButton* mySortBtn;
|
||||
|
||||
|
||||
QGroupBox* mySelectBox;
|
||||
QCheckBox* mySelectSubMesh;
|
||||
QPushButton* mySubMeshBtn;
|
||||
@ -186,9 +186,9 @@ private:
|
||||
QCheckBox* mySelectGroup;
|
||||
QPushButton* myGroupBtn;
|
||||
QLineEdit* myGroupLine;
|
||||
|
||||
|
||||
QtxColorButton* myColorBtn;
|
||||
|
||||
|
||||
QCheckBox* mySelectGeomGroup;
|
||||
QToolButton* myGeomGroupBtn;
|
||||
QLineEdit* myGeomGroupLine;
|
||||
@ -198,9 +198,9 @@ private:
|
||||
QPushButton* myApplyBtn;
|
||||
QPushButton* myCloseBtn;
|
||||
QPushButton* myHelpBtn;
|
||||
|
||||
|
||||
SMESHGUI_ShapeByMeshOp* myShapeByMeshOp;
|
||||
|
||||
|
||||
SMESH::SMESH_Mesh_var myMesh;
|
||||
QList<SMESH_Actor*> myActorsList;
|
||||
SMESH::SMESH_Group_var myGroup;
|
||||
@ -209,22 +209,19 @@ private:
|
||||
SMESH::Filter_var myFilter;
|
||||
QList<int> myIdList;
|
||||
GEOM::ListOfGO_var myGeomObjects;
|
||||
|
||||
|
||||
int mySelectionMode;
|
||||
//Handle(SMESH_TypeFilter) myMeshFilter;
|
||||
//Handle(SMESH_TypeFilter) mySubMeshFilter;
|
||||
//Handle(SMESH_TypeFilter) myGroupFilter;
|
||||
SUIT_SelectionFilter* myMeshFilter;
|
||||
SMESH_LogicalFilter* mySubMeshFilter;
|
||||
SMESH_LogicalFilter* myGroupFilter;
|
||||
SUIT_SelectionFilter* myGeomFilter;
|
||||
|
||||
|
||||
SMESHGUI_FilterDlg* myFilterDlg;
|
||||
|
||||
|
||||
bool myCreate, myIsBusy;
|
||||
|
||||
|
||||
QString myHelpFileName;
|
||||
|
||||
|
||||
QMap<QAction*, int> myActions;
|
||||
|
||||
bool myNameChanged; //added by skl for IPAL19574
|
||||
|
@ -463,29 +463,23 @@ void SMESHGUI_GroupOnShapeOp::selectionDone()
|
||||
// study
|
||||
if (_PTR(Study) aStudy = SMESH::getStudy()) {
|
||||
// mesh
|
||||
if (_PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toUtf8().data() )) {
|
||||
if (_PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toUtf8().data() ))
|
||||
{
|
||||
// shape to mesh
|
||||
_PTR(SObject) anObj, shapeToMesh;
|
||||
if (meshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(shapeToMesh)) {
|
||||
// loop on selected
|
||||
QStringList::iterator name = names.begin(), id = ids.begin(), idEnd = ids.end();
|
||||
for (; id != idEnd; ++id, ++name ) {
|
||||
// shape SO
|
||||
if (_PTR(SObject) shapeSO = aStudy->FindObjectID( id->toUtf8().data() )) {
|
||||
// check if shape SO is a child of shape to mesh
|
||||
while ( shapeSO && shapeSO->GetID() != shapeToMesh->GetID() )
|
||||
if ( shapeSO->Depth() < 2 )
|
||||
shapeSO.reset();
|
||||
else
|
||||
shapeSO = shapeSO->GetFather();
|
||||
if ( shapeSO ) {
|
||||
//printf( "selectionDone() %s %s\n", (*id).latin1(), (*name).latin1() );
|
||||
if ( !goodIds.contains( *id )) {
|
||||
goodIds.append( *id );
|
||||
goodNames.append( *name );
|
||||
}
|
||||
}
|
||||
}
|
||||
GEOM::GEOM_Object_var mainGeom = SMESH::GetGeom( meshSO );
|
||||
// loop on selected
|
||||
QStringList::iterator name = names.begin(), id = ids.begin(), idEnd = ids.end();
|
||||
for (; id != idEnd; ++id, ++name )
|
||||
{
|
||||
if ( goodIds.contains( *id ))
|
||||
continue;
|
||||
// shape SO
|
||||
_PTR(SObject) shapeSO = aStudy->FindObjectID( id->toUtf8().data() );
|
||||
GEOM::GEOM_Object_var subGeom = SMESH::GetGeom( shapeSO );
|
||||
if ( SMESH::ContainsSubShape( mainGeom, subGeom ))
|
||||
{
|
||||
goodIds.append( *id );
|
||||
goodNames.append( *name );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -58,27 +58,15 @@ protected:
|
||||
virtual void startOperation();
|
||||
virtual void selectionDone();
|
||||
virtual SUIT_SelectionFilter* createFilter( const int ) const;
|
||||
//virtual bool isValid( SUIT_Operation* ) const;
|
||||
|
||||
private slots:
|
||||
|
||||
bool onApply();
|
||||
void onButtonClick();
|
||||
|
||||
|
||||
// void onSelectColor();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
// void setGroupColor( const SALOMEDS::Color& );
|
||||
// SALOMEDS::Color getGroupColor() const;
|
||||
|
||||
// void setGroupQColor( const QColor& );
|
||||
// QColor getGroupQColor() const;
|
||||
|
||||
// void setDefaultGroupColor();
|
||||
|
||||
private:
|
||||
|
||||
@ -86,7 +74,6 @@ private:
|
||||
|
||||
QString myMeshID;
|
||||
QStringList myElemGeoIDs, myNodeGeoIDs;
|
||||
//GEOM::ListOfGO_var myElemGObj;
|
||||
};
|
||||
|
||||
class SMESHGUI_EXPORT SMESHGUI_GroupOnShapeDlg : public SMESHGUI_Dialog
|
||||
@ -104,22 +91,14 @@ public slots:
|
||||
|
||||
private:
|
||||
|
||||
//QLineEdit* myGrpNameLine;
|
||||
|
||||
QPushButton* myMeshBtn;
|
||||
QLineEdit* myMeshLine;
|
||||
|
||||
QPushButton* myElemGeomBtn;
|
||||
QListWidget* myElemGeomList;
|
||||
QListWidget* myElemGeomList;
|
||||
|
||||
QPushButton* myNodeGeomBtn;
|
||||
QListWidget* myNodeGeomList;
|
||||
|
||||
// QPushButton* myColorBtn;
|
||||
|
||||
// bool myCreate, myIsBusy;
|
||||
|
||||
// QString myHelpFileName;
|
||||
QListWidget* myNodeGeomList;
|
||||
|
||||
friend class SMESHGUI_GroupOnShapeOp;
|
||||
};
|
||||
|
@ -319,25 +319,6 @@ SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const
|
||||
return 0;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief Return type of shape contained in a group
|
||||
*/
|
||||
//================================================================================
|
||||
|
||||
TopAbs_ShapeEnum getGroupType(const TopoDS_Shape& group)
|
||||
{
|
||||
if ( group.ShapeType() != TopAbs_COMPOUND )
|
||||
return group.ShapeType();
|
||||
|
||||
// iterate on a compound
|
||||
TopoDS_Iterator it( group );
|
||||
if ( it.More() )
|
||||
return getGroupType( it.Value() );
|
||||
|
||||
return TopAbs_SHAPE;
|
||||
}
|
||||
|
||||
//================================================================================
|
||||
/*!
|
||||
* \brief check if selected shape is a sub-shape of the shape to mesh
|
||||
@ -365,60 +346,17 @@ 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;
|
||||
// check all selected shapes
|
||||
for ( QString& aSubGeomEntry : aGEOMs )
|
||||
{
|
||||
_PTR(SObject) pSubGeom = SMESH::getStudy()->FindObjectID( aSubGeomEntry.toUtf8().data() );
|
||||
if ( !pSubGeom ) return false;
|
||||
|
||||
GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations();
|
||||
if (op->_is_nil()) return false;
|
||||
GEOM::GEOM_Object_var subGeom =
|
||||
GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
|
||||
|
||||
// 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 )
|
||||
{
|
||||
GEOM_Client geomClient;
|
||||
TopoDS_Shape subShape = geomClient.GetShape( geomGen, aSubGeomVar );
|
||||
TopoDS_Shape mainShape = geomClient.GetShape( geomGen, mainGeom );
|
||||
if ( subShape.IsNull() || mainShape.IsNull() )
|
||||
return false;
|
||||
|
||||
TopAbs_ShapeEnum subType = getGroupType( subShape );
|
||||
TopTools_IndexedMapOfShape subMap;
|
||||
TopExp::MapShapes( subShape, subType, subMap );
|
||||
for ( TopExp_Explorer exp( mainShape, subType ); exp.More(); exp.Next() )
|
||||
if ( subMap.Contains( exp.Current() ))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( SMESH::ContainsSubShape( mainGeom, subGeom ))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
Loading…
Reference in New Issue
Block a user