mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-03 14:00:35 +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 <QString>
|
||||||
|
|
||||||
|
#include <TopExp.hxx>
|
||||||
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
#include <TopoDS_Iterator.hxx>
|
||||||
|
|
||||||
namespace SMESH
|
namespace SMESH
|
||||||
{
|
{
|
||||||
GEOM::GEOM_Gen_var GetGEOMGen( GEOM::GEOM_Object_ptr go )
|
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
|
} // end of namespace SMESH
|
||||||
|
@ -59,6 +59,9 @@ namespace SMESH
|
|||||||
|
|
||||||
SMESHGUI_EXPORT bool GetGeomEntries( Handle(SALOME_InteractiveObject)& hypIO,
|
SMESHGUI_EXPORT bool GetGeomEntries( Handle(SALOME_InteractiveObject)& hypIO,
|
||||||
QString& subGeom, QString& meshGeom);
|
QString& subGeom, QString& meshGeom);
|
||||||
|
|
||||||
|
SMESHGUI_EXPORT bool ContainsSubShape( GEOM::GEOM_Object_ptr mainShape,
|
||||||
|
GEOM::GEOM_Object_ptr subShape );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SMESHGUI_GEOMGENUTILS_H
|
#endif // SMESHGUI_GEOMGENUTILS_H
|
||||||
|
@ -1405,72 +1405,23 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
|
|||||||
else if (myCurrentLineEdit == myGeomGroupLine)
|
else if (myCurrentLineEdit == myGeomGroupLine)
|
||||||
{
|
{
|
||||||
myGeomObjects = new GEOM::ListOfGO();
|
myGeomObjects = new GEOM::ListOfGO();
|
||||||
|
myGeomObjects->length( aNbSel );
|
||||||
|
|
||||||
// The mesh SObject
|
if ( aNbSel == 0 || myMesh->_is_nil() )
|
||||||
_PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh);
|
|
||||||
|
|
||||||
if (aNbSel == 0 || !aMeshSO)
|
|
||||||
{
|
{
|
||||||
myGeomObjects->length(0);
|
|
||||||
updateButtons();
|
updateButtons();
|
||||||
myIsBusy = false;
|
myIsBusy = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
myGeomObjects->length(aNbSel);
|
GEOM::GEOM_Object_var mainGeom = myMesh->GetShapeToMesh();
|
||||||
|
|
||||||
GEOM::GEOM_Object_var aGeomGroup;
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
for ( SALOME_ListIteratorOfListIO anIt( aList ); anIt.More(); anIt.Next() )
|
||||||
SALOME_ListIteratorOfListIO anIt (aList);
|
|
||||||
for (; 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
|
// Check if group constructed on the same shape as a mesh or on its child
|
||||||
|
GEOM::GEOM_Object_var geomGroup = SMESH::GetGeom( anIt.Value() );
|
||||||
// The main shape of the group
|
if ( SMESH::ContainsSubShape( mainGeom, geomGroup ))
|
||||||
GEOM::GEOM_Object_var aGroupMainShape;
|
myGeomObjects[ i++ ] = geomGroup;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
myGeomObjects->length(i);
|
myGeomObjects->length(i);
|
||||||
|
@ -211,9 +211,6 @@ private:
|
|||||||
GEOM::ListOfGO_var myGeomObjects;
|
GEOM::ListOfGO_var myGeomObjects;
|
||||||
|
|
||||||
int mySelectionMode;
|
int mySelectionMode;
|
||||||
//Handle(SMESH_TypeFilter) myMeshFilter;
|
|
||||||
//Handle(SMESH_TypeFilter) mySubMeshFilter;
|
|
||||||
//Handle(SMESH_TypeFilter) myGroupFilter;
|
|
||||||
SUIT_SelectionFilter* myMeshFilter;
|
SUIT_SelectionFilter* myMeshFilter;
|
||||||
SMESH_LogicalFilter* mySubMeshFilter;
|
SMESH_LogicalFilter* mySubMeshFilter;
|
||||||
SMESH_LogicalFilter* myGroupFilter;
|
SMESH_LogicalFilter* myGroupFilter;
|
||||||
|
@ -463,24 +463,21 @@ void SMESHGUI_GroupOnShapeOp::selectionDone()
|
|||||||
// study
|
// study
|
||||||
if (_PTR(Study) aStudy = SMESH::getStudy()) {
|
if (_PTR(Study) aStudy = SMESH::getStudy()) {
|
||||||
// mesh
|
// mesh
|
||||||
if (_PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toUtf8().data() )) {
|
if (_PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toUtf8().data() ))
|
||||||
|
{
|
||||||
// shape to mesh
|
// shape to mesh
|
||||||
_PTR(SObject) anObj, shapeToMesh;
|
GEOM::GEOM_Object_var mainGeom = SMESH::GetGeom( meshSO );
|
||||||
if (meshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(shapeToMesh)) {
|
|
||||||
// loop on selected
|
// loop on selected
|
||||||
QStringList::iterator name = names.begin(), id = ids.begin(), idEnd = ids.end();
|
QStringList::iterator name = names.begin(), id = ids.begin(), idEnd = ids.end();
|
||||||
for (; id != idEnd; ++id, ++name ) {
|
for (; id != idEnd; ++id, ++name )
|
||||||
|
{
|
||||||
|
if ( goodIds.contains( *id ))
|
||||||
|
continue;
|
||||||
// shape SO
|
// shape SO
|
||||||
if (_PTR(SObject) shapeSO = aStudy->FindObjectID( id->toUtf8().data() )) {
|
_PTR(SObject) shapeSO = aStudy->FindObjectID( id->toUtf8().data() );
|
||||||
// check if shape SO is a child of shape to mesh
|
GEOM::GEOM_Object_var subGeom = SMESH::GetGeom( shapeSO );
|
||||||
while ( shapeSO && shapeSO->GetID() != shapeToMesh->GetID() )
|
if ( SMESH::ContainsSubShape( mainGeom, subGeom ))
|
||||||
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 );
|
goodIds.append( *id );
|
||||||
goodNames.append( *name );
|
goodNames.append( *name );
|
||||||
}
|
}
|
||||||
@ -488,9 +485,6 @@ void SMESHGUI_GroupOnShapeOp::selectionDone()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( myDlg->myElemGeomBtn->isChecked() ) // elem geometry selection
|
if ( myDlg->myElemGeomBtn->isChecked() ) // elem geometry selection
|
||||||
{
|
{
|
||||||
|
@ -58,27 +58,15 @@ protected:
|
|||||||
virtual void startOperation();
|
virtual void startOperation();
|
||||||
virtual void selectionDone();
|
virtual void selectionDone();
|
||||||
virtual SUIT_SelectionFilter* createFilter( const int ) const;
|
virtual SUIT_SelectionFilter* createFilter( const int ) const;
|
||||||
//virtual bool isValid( SUIT_Operation* ) const;
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
||||||
bool onApply();
|
bool onApply();
|
||||||
void onButtonClick();
|
void onButtonClick();
|
||||||
|
|
||||||
|
|
||||||
// void onSelectColor();
|
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
// void setGroupColor( const SALOMEDS::Color& );
|
|
||||||
// SALOMEDS::Color getGroupColor() const;
|
|
||||||
|
|
||||||
// void setGroupQColor( const QColor& );
|
|
||||||
// QColor getGroupQColor() const;
|
|
||||||
|
|
||||||
// void setDefaultGroupColor();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -86,7 +74,6 @@ private:
|
|||||||
|
|
||||||
QString myMeshID;
|
QString myMeshID;
|
||||||
QStringList myElemGeoIDs, myNodeGeoIDs;
|
QStringList myElemGeoIDs, myNodeGeoIDs;
|
||||||
//GEOM::ListOfGO_var myElemGObj;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class SMESHGUI_EXPORT SMESHGUI_GroupOnShapeDlg : public SMESHGUI_Dialog
|
class SMESHGUI_EXPORT SMESHGUI_GroupOnShapeDlg : public SMESHGUI_Dialog
|
||||||
@ -104,8 +91,6 @@ public slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
//QLineEdit* myGrpNameLine;
|
|
||||||
|
|
||||||
QPushButton* myMeshBtn;
|
QPushButton* myMeshBtn;
|
||||||
QLineEdit* myMeshLine;
|
QLineEdit* myMeshLine;
|
||||||
|
|
||||||
@ -115,12 +100,6 @@ private:
|
|||||||
QPushButton* myNodeGeomBtn;
|
QPushButton* myNodeGeomBtn;
|
||||||
QListWidget* myNodeGeomList;
|
QListWidget* myNodeGeomList;
|
||||||
|
|
||||||
// QPushButton* myColorBtn;
|
|
||||||
|
|
||||||
// bool myCreate, myIsBusy;
|
|
||||||
|
|
||||||
// QString myHelpFileName;
|
|
||||||
|
|
||||||
friend class SMESHGUI_GroupOnShapeOp;
|
friend class SMESHGUI_GroupOnShapeOp;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -319,25 +319,6 @@ SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const
|
|||||||
return 0;
|
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
|
* \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;
|
QStringList aGEOMs;
|
||||||
myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, 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
|
// check all selected shapes
|
||||||
QStringList::const_iterator aSubShapesIter = aGEOMs.begin();
|
for ( QString& aSubGeomEntry : aGEOMs )
|
||||||
for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++)
|
|
||||||
{
|
{
|
||||||
QString aSubGeomEntry = (*aSubShapesIter);
|
|
||||||
_PTR(SObject) pSubGeom = SMESH::getStudy()->FindObjectID( aSubGeomEntry.toUtf8().data() );
|
_PTR(SObject) pSubGeom = SMESH::getStudy()->FindObjectID( aSubGeomEntry.toUtf8().data() );
|
||||||
if ( !pSubGeom ) return false;
|
if ( !pSubGeom ) return false;
|
||||||
|
|
||||||
GEOM::GEOM_Object_var aSubGeomVar =
|
GEOM::GEOM_Object_var subGeom =
|
||||||
GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
|
GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject());
|
||||||
if (aSubGeomVar->_is_nil()) return false;
|
|
||||||
|
|
||||||
// skl for NPAL14695 - implementation of searching of mainObj
|
if ( SMESH::ContainsSubShape( mainGeom, subGeom ))
|
||||||
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;
|
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user