Merge branch 'occ/shaper2smesh'

This commit is contained in:
vsr 2020-02-21 15:13:04 +03:00
commit 6472eab132
34 changed files with 833 additions and 291 deletions

View File

@ -347,6 +347,12 @@ module SMESH
GEOM::GEOM_Object GetShapeToMesh() GEOM::GEOM_Object GetShapeToMesh()
raises (SALOME::SALOME_Exception); raises (SALOME::SALOME_Exception);
/*!
* Replaces a shape in the mesh
*/
void ReplaceShape(in GEOM::GEOM_Object theNewGeom)
raises (SALOME::SALOME_Exception);
/*! /*!
* Return false if the mesh is not yet fully loaded from the study file * Return false if the mesh is not yet fully loaded from the study file
*/ */

View File

@ -208,6 +208,7 @@ SET(SMESH_RESOURCES_FILES
mesh_tree_hypo_volume.png mesh_tree_hypo_volume.png
mesh_tree_importedmesh.png mesh_tree_importedmesh.png
mesh_tree_mesh.png mesh_tree_mesh.png
mesh_tree_mesh_geom_modif.png
mesh_tree_mesh_partial.png mesh_tree_mesh_partial.png
mesh_tree_mesh_warn.png mesh_tree_mesh_warn.png
mesh_triangle.png mesh_triangle.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -213,7 +213,7 @@ TopAbs_ShapeEnum GeomSelectionTools::entryToShapeType(std::string entry){
// if the Geom Object is a group // if the Geom Object is a group
if (aShape->GetType() == GEOM_GROUP){ if (aShape->GetType() == GEOM_GROUP){
// MESSAGE("It's a group"); // MESSAGE("It's a group");
GEOM::GEOM_IGroupOperations_wrap aGroupOp = GEOM::GEOM_IGroupOperations_ptr aGroupOp =
_geomEngine->GetIGroupOperations(); _geomEngine->GetIGroupOperations();
ShapeType= (TopAbs_ShapeEnum)aGroupOp->GetType(aShape); ShapeType= (TopAbs_ShapeEnum)aGroupOp->GetType(aShape);
} }

View File

@ -87,6 +87,9 @@ class SMESH_EXPORT SMESH_Mesh
* \brief Return true if there is a geometry to be meshed, not PseudoShape() * \brief Return true if there is a geometry to be meshed, not PseudoShape()
*/ */
bool HasShapeToMesh() const { return _isShapeToMesh; } bool HasShapeToMesh() const { return _isShapeToMesh; }
void UndefShapeToMesh() { _isShapeToMesh = false; }
/*! /*!
* \brief Return diagonal size of bounding box of shape to mesh. * \brief Return diagonal size of bounding box of shape to mesh.
*/ */

View File

@ -172,6 +172,7 @@
#include <SALOMEDS_Study.hxx> #include <SALOMEDS_Study.hxx>
#include <SALOMEDS_SObject.hxx> #include <SALOMEDS_SObject.hxx>
#include "utilities.h" #include "utilities.h"
#include <SALOME_LifeCycleCORBA.hxx>
// OCCT includes // OCCT includes
#include <Standard_ErrorHandler.hxx> #include <Standard_ErrorHandler.hxx>
@ -1382,6 +1383,108 @@ namespace
} }
} }
// Break link with Shaper model
void breakShaperLink()
{
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected;
if (aSel) {
aSel->selectedObjects(selected);
if (selected.Extent()) {
Handle(SALOME_InteractiveObject) anIObject = selected.First();
_PTR(Study) aStudy = SMESH::getStudy();
std::string aEntry = anIObject->getEntry();
_PTR(SObject) aSObj = aStudy->FindObjectID(aEntry);
if (aSObj) {
std::string aName = aSObj->GetName();
QMessageBox::StandardButton aRes = SUIT_MessageBox::warning(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("MSG_BREAK_SHAPER_LINK").arg(aName.c_str()),
SUIT_MessageBox::Yes | SUIT_MessageBox::No, SUIT_MessageBox::No);
if (aRes == SUIT_MessageBox::Yes) {
SUIT_DataOwnerPtrList aList;
aSel->selected(aList, "ObjectBrowser", true);
SUIT_DataOwner* aOwn = aList.first();
LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
QString aREntry = sowner->entry();
static GEOM::GEOM_Gen_var geomGen;
if (CORBA::is_nil(geomGen)) {
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
(SUIT_Session::session()->activeApplication());
if (app) {
SALOME_LifeCycleCORBA* ls = new SALOME_LifeCycleCORBA(app->namingService());
Engines::EngineComponent_var comp =
ls->FindOrLoad_Component("FactoryServer", "SHAPERSTUDY");
geomGen = GEOM::GEOM_Gen::_narrow(comp);
}
}
if (!CORBA::is_nil(geomGen))
{
geomGen->BreakLink(aREntry.toStdString().c_str());
SMESHGUI::GetSMESHGUI()->updateObjBrowser();
// remove actors whose objects are removed by BreakLink()
QList<SUIT_ViewWindow*> wndList = SMESHGUI::desktop()->windows();
SUIT_ViewWindow* wnd;
foreach(wnd, wndList)
SMESH::UpdateActorsAfterUpdateStudy(wnd);
}
}
}
}
}
}
//================================================================================
/*!
* \brief Return true if a mesh icon == ICON_SMESH_TREE_GEOM_MODIF
* which means that the mesh can't be modified. It should be either re-computed
* or breakShaperLink()'ed. Warn the user about it.
*/
//================================================================================
bool warnOnGeomModif()
{
SALOME_ListIO selected;
if ( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
aSel->selectedObjects(selected,"",/*convertReferences=*/false);
SALOME_ListIteratorOfListIO It( selected );
for ( ; It.More(); It.Next() )
{
Handle(SALOME_InteractiveObject) io = It.Value();
if ( !io->hasEntry() ) continue;
_PTR(SObject) so = SMESH::getStudy()->FindObjectID( io->getEntry() );
SMESH::SMESH_Mesh_var mesh;
while ( mesh->_is_nil() && so )
{
CORBA::Object_var obj = SMESH::SObjectToObject( so );
SMESH::SMESH_IDSource_var isrc = SMESH::SMESH_IDSource::_narrow( obj );
if ( isrc->_is_nil() )
so = so->GetFather();
else
mesh = isrc->GetMesh();
}
if ( mesh->_is_nil() ) continue;
so = SMESH::FindSObject( mesh );
if ( !so ) continue;
_PTR(GenericAttribute) attr;
so->FindAttribute( attr, "AttributePixMap" );
_PTR(AttributePixMap) pixmap = attr;
if ( !pixmap ) continue;
if ( pixmap->GetPixMap() == "ICON_SMESH_TREE_GEOM_MODIF" )
{
SUIT_MessageBox::warning(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("MSG_WARN_ON_GEOM_MODIF"));
return true;
}
}
return false;
}
void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap) void SetDisplayMode(int theCommandID, VTK::MarkerMap& theMarkerMap)
{ {
SALOME_ListIO selected; SALOME_ListIO selected;
@ -2754,16 +2857,19 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
break; break;
} }
case SMESHOp::OpCreateMesh:
case SMESHOp::OpCreateSubMesh:
case SMESHOp::OpEditMeshOrSubMesh: case SMESHOp::OpEditMeshOrSubMesh:
case SMESHOp::OpEditMesh: case SMESHOp::OpEditMesh:
case SMESHOp::OpEditSubMesh: case SMESHOp::OpEditSubMesh:
case SMESHOp::OpMeshOrder:
case SMESHOp::OpCreateSubMesh:
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
case SMESHOp::OpCreateMesh:
case SMESHOp::OpCompute: case SMESHOp::OpCompute:
case SMESHOp::OpComputeSubMesh: case SMESHOp::OpComputeSubMesh:
case SMESHOp::OpPreCompute: case SMESHOp::OpPreCompute:
case SMESHOp::OpEvaluate: case SMESHOp::OpEvaluate:
case SMESHOp::OpMeshOrder:
startOperation( theCommandID ); startOperation( theCommandID );
break; break;
case SMESHOp::OpCopyMesh: case SMESHOp::OpCopyMesh:
@ -2792,6 +2898,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
if ( isStudyLocked() ) if ( isStudyLocked() )
break; break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
/*Standard_Boolean aRes; /*Standard_Boolean aRes;
SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject); SMESH::SMESH_Mesh_var aMesh = SMESH::IObjectToInterface<SMESH::SMESH_Mesh>(IObject);
@ -2822,6 +2930,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
if ( isStudyLocked() ) if ( isStudyLocked() )
break; break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
SMESHGUI_MultiEditDlg* aDlg = NULL; SMESHGUI_MultiEditDlg* aDlg = NULL;
@ -2840,6 +2950,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpSmoothing: case SMESHOp::OpSmoothing:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if( vtkwnd ) { if( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_SmoothingDlg( this ) )->show(); ( new SMESHGUI_SmoothingDlg( this ) )->show();
@ -2852,6 +2964,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpExtrusion: case SMESHOp::OpExtrusion:
{ {
if (isStudyLocked()) break; if (isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if (vtkwnd) { if (vtkwnd) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_ExtrusionDlg ( this ) )->show(); ( new SMESHGUI_ExtrusionDlg ( this ) )->show();
@ -2863,6 +2977,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpExtrusionAlongAPath: case SMESHOp::OpExtrusionAlongAPath:
{ {
if (isStudyLocked()) break; if (isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if (vtkwnd) { if (vtkwnd) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show(); ( new SMESHGUI_ExtrusionAlongPathDlg( this ) )->show();
@ -2874,6 +2990,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpRevolution: case SMESHOp::OpRevolution:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if( vtkwnd ) { if( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_RevolutionDlg( this ) )->show(); ( new SMESHGUI_RevolutionDlg( this ) )->show();
@ -2887,6 +3005,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
{ {
if ( isStudyLocked() ) if ( isStudyLocked() )
break; break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) if ( vtkwnd )
{ {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
@ -2903,6 +3023,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpReorientFaces: case SMESHOp::OpReorientFaces:
case SMESHOp::OpCreateGeometryGroup: case SMESHOp::OpCreateGeometryGroup:
{ {
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
startOperation( theCommandID ); startOperation( theCommandID );
break; break;
} }
@ -2915,6 +3037,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
} }
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil(); SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_nil();
@ -2942,6 +3066,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
} }
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
@ -3019,6 +3145,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
} }
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
@ -3116,6 +3244,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
if ( isStudyLocked() ) if ( isStudyLocked() )
break; break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
@ -3136,6 +3266,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
{ {
if ( isStudyLocked() ) if ( isStudyLocked() )
break; break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this ); SMESHGUI_GroupOpDlg* aDlg = new SMESHGUI_DimGroupDlg( this );
@ -3148,6 +3280,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
{ {
if ( isStudyLocked() ) if ( isStudyLocked() )
break; break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this ); SMESHGUI_FaceGroupsSeparatedByEdgesDlg* aDlg = new SMESHGUI_FaceGroupsSeparatedByEdgesDlg( this );
@ -3207,6 +3341,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpEditHypothesis: case SMESHOp::OpEditHypothesis:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
SALOME_ListIO selected; SALOME_ListIO selected;
@ -3252,6 +3388,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS case SMESHOp::OpUnassign: // REMOVE HYPOTHESIS / ALGORITHMS
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
SUIT_OverrideCursor wc; SUIT_OverrideCursor wc;
LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr(); LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr();
@ -3283,6 +3421,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpHexagonalPrism: case SMESHOp::OpHexagonalPrism:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) { if ( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
SMDSAbs_EntityType type = SMDSEntity_Edge; SMDSAbs_EntityType type = SMDSEntity_Edge;
@ -3309,6 +3449,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpPolyhedron: case SMESHOp::OpPolyhedron:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) { if ( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show(); ( new SMESHGUI_CreatePolyhedralVolumeDlg( this ) )->show();
@ -3332,6 +3474,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpTriQuadraticHexahedron: case SMESHOp::OpTriQuadraticHexahedron:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) { if ( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
SMDSAbs_EntityType type = SMDSEntity_Last; SMDSAbs_EntityType type = SMDSEntity_Last;
@ -3363,6 +3507,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpRemoveNodes: case SMESHOp::OpRemoveNodes:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) { if ( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_RemoveNodesDlg( this ) )->show(); ( new SMESHGUI_RemoveNodesDlg( this ) )->show();
@ -3376,6 +3522,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS case SMESHOp::OpRemoveElements: // REMOVES ELEMENTS
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if( vtkwnd ) { if( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_RemoveElementsDlg( this ) )->show(); ( new SMESHGUI_RemoveElementsDlg( this ) )->show();
@ -3390,6 +3538,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpClearMesh: { case SMESHOp::OpClearMesh: {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
SALOME_ListIO selected; SALOME_ListIO selected;
if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() ) if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
@ -3429,6 +3579,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpRemoveOrphanNodes: case SMESHOp::OpRemoveOrphanNodes:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
SALOME_ListIO selected; SALOME_ListIO selected;
if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() ) if( LightApp_SelectionMgr *aSel = SMESHGUI::selectionMgr() )
aSel->selectedObjects( selected ); aSel->selectedObjects( selected );
@ -3468,6 +3620,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpRenumberingNodes: case SMESHOp::OpRenumberingNodes:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if( vtkwnd ) { if( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_RenumberingDlg( this, 0 ) )->show(); ( new SMESHGUI_RenumberingDlg( this, 0 ) )->show();
@ -3482,6 +3636,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpRenumberingElements: case SMESHOp::OpRenumberingElements:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) { if ( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_RenumberingDlg( this, 1 ) )->show(); ( new SMESHGUI_RenumberingDlg( this, 1 ) )->show();
@ -3496,6 +3652,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpTranslation: case SMESHOp::OpTranslation:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) { if ( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_TranslationDlg( this ) )->show(); ( new SMESHGUI_TranslationDlg( this ) )->show();
@ -3509,6 +3667,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpRotation: case SMESHOp::OpRotation:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if( vtkwnd ) { if( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_RotationDlg( this ) )->show(); ( new SMESHGUI_RotationDlg( this ) )->show();
@ -3522,6 +3682,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpSymmetry: case SMESHOp::OpSymmetry:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if(vtkwnd) { if(vtkwnd) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_SymmetryDlg( this ) )->show(); ( new SMESHGUI_SymmetryDlg( this ) )->show();
@ -3535,6 +3697,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpScale: case SMESHOp::OpScale:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) { if ( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_ScaleDlg( this ) )->show(); ( new SMESHGUI_ScaleDlg( this ) )->show();
@ -3549,6 +3713,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpOffset: case SMESHOp::OpOffset:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) { if ( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_OffsetDlg( this ) )->show(); ( new SMESHGUI_OffsetDlg( this ) )->show();
@ -3563,6 +3729,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpSewing: case SMESHOp::OpSewing:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if(vtkwnd) { if(vtkwnd) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_SewingDlg( this ) )->show(); ( new SMESHGUI_SewingDlg( this ) )->show();
@ -3576,6 +3744,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpMergeNodes: case SMESHOp::OpMergeNodes:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if(vtkwnd) { if(vtkwnd) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_MergeDlg( this, 0 ) )->show(); ( new SMESHGUI_MergeDlg( this, 0 ) )->show();
@ -3589,6 +3759,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpMergeElements: case SMESHOp::OpMergeElements:
{ {
if (isStudyLocked()) break; if (isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if (vtkwnd) { if (vtkwnd) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_MergeDlg( this, 1 ) )->show(); ( new SMESHGUI_MergeDlg( this, 1 ) )->show();
@ -3600,12 +3772,16 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
} }
case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT case SMESHOp::OpMoveNode: // MAKE MESH PASS THROUGH POINT
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
startOperation( SMESHOp::OpMoveNode ); startOperation( SMESHOp::OpMoveNode );
break; break;
case SMESHOp::OpDuplicateNodes: case SMESHOp::OpDuplicateNodes:
{ {
if(isStudyLocked()) break; if(isStudyLocked()) break;
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
if ( vtkwnd ) { if ( vtkwnd ) {
EmitSignalDeactivateDialog(); EmitSignalDeactivateDialog();
( new SMESHGUI_DuplicateNodesDlg( this ) )->show(); ( new SMESHGUI_DuplicateNodesDlg( this ) )->show();
@ -3618,6 +3794,8 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
} }
case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES case SMESHOp::OpElem0DOnElemNodes: // 0D_ON_ALL_NODES
if ( warnOnGeomModif() )
break; // action forbiden as geometry modified
startOperation( SMESHOp::OpElem0DOnElemNodes ); startOperation( SMESHOp::OpElem0DOnElemNodes );
break; break;
@ -3751,6 +3929,9 @@ bool SMESHGUI::OnGUIEvent( int theCommandID )
case SMESHOp::OpSortChild: case SMESHOp::OpSortChild:
::sortChildren(); ::sortChildren();
break; break;
case SMESHOp::OpBreakLink:
::breakShaperLink();
break;
} }
@ -4084,6 +4265,8 @@ void SMESHGUI::initialize( CAM_Application* app )
createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" ); createSMESHAction( SMESHOp::OpSortChild, "SORT_CHILD_ITEMS" );
createSMESHAction( SMESHOp::OpBreakLink, "BREAK_SHAPER_LINK" );
QList<int> aCtrlActions; QList<int> aCtrlActions;
aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode aCtrlActions << SMESHOp::OpFreeNode << SMESHOp::OpEqualNode
<< SMESHOp::OpNodeConnectivityNb // node controls << SMESHOp::OpNodeConnectivityNb // node controls
@ -4857,6 +5040,9 @@ void SMESHGUI::initialize( CAM_Application* app )
popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule ); popupMgr()->setRule( action( SMESHOp::OpSortChild ), "$component={'SMESH'} and client='ObjectBrowser' and isContainer and nbChildren>1", QtxPopupMgr::VisibleRule );
popupMgr()->insert( separator(), -1, -1 ); popupMgr()->insert( separator(), -1, -1 );
popupMgr()->insert( action( SMESHOp::OpBreakLink), -1, -1 );
popupMgr()->setRule( action( SMESHOp::OpBreakLink), "$component={'SHAPERSTUDY'} and client='ObjectBrowser' and canBreakLink", QtxPopupMgr::VisibleRule );
connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ), connect( application(), SIGNAL( viewManagerActivated( SUIT_ViewManager* ) ),
this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) ); this, SLOT( onViewManagerActivated( SUIT_ViewManager* ) ) );

View File

@ -951,7 +951,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
SMESH::SMESH_IDSource_var aSubMeshObj = SMESH::SMESH_IDSource_var aSubMeshObj =
SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( smSObj ); SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( smSObj );
SMESH_Actor *anActor = SMESH::FindActorByObject( aSubMeshObj ); SMESH_Actor *anActor = SMESH::FindActorByObject( aSubMeshObj );
if ( anActor && anActor->GetVisibility() ) if ( anActor /*&& anActor->GetVisibility()*/ )
aListToUpdate.append( TListOf_IDSrc_SObj::value_type( aSubMeshObj, smSObj )); aListToUpdate.append( TListOf_IDSrc_SObj::value_type( aSubMeshObj, smSObj ));
} }
// put Groups into list // put Groups into list
@ -967,7 +967,7 @@ void SMESHGUI_BaseComputeOp::computeMesh()
SMESH::SMESH_IDSource_var aGroupObj = SMESH::SMESH_IDSource_var aGroupObj =
SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aGroupSO ); SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aGroupSO );
SMESH_Actor *anActor = SMESH::FindActorByObject( aGroupObj ); SMESH_Actor *anActor = SMESH::FindActorByObject( aGroupObj );
if ( anActor && anActor->GetVisibility() ) if ( anActor /*&& anActor->GetVisibility()*/ )
aListToUpdate.append( TListOf_IDSrc_SObj::value_type( aGroupObj, aGroupSO )); aListToUpdate.append( TListOf_IDSrc_SObj::value_type( aGroupObj, aGroupSO ));
} }
@ -994,6 +994,13 @@ void SMESHGUI_BaseComputeOp::computeMesh()
//SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor ); -- 23615 //SMESH::DisplayActor( SMESH::GetActiveWindow(), anActor ); -- 23615
} }
} }
else
{
SMESH_Actor *anActor = SMESH::FindActorByEntry( entry.c_str() );
anActor->Update();
if ( !anActor->GetVisibility() )
continue;
}
SMESH::UpdateView( SMESH::eDisplay, entry.c_str() ); SMESH::UpdateView( SMESH::eDisplay, entry.c_str() );
if ( SVTK_ViewWindow* vtkWnd = SMESH::GetVtkViewWindow(SMESH::GetActiveWindow() )) if ( SVTK_ViewWindow* vtkWnd = SMESH::GetVtkViewWindow(SMESH::GetActiveWindow() ))
@ -1251,8 +1258,8 @@ void SMESHGUI_BaseComputeOp::stopOperation()
void SMESHGUI_BaseComputeOp::onPublishShape() void SMESHGUI_BaseComputeOp::onPublishShape()
{ {
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
GEOM::GEOM_Object_var meshShape = myMesh->GetShapeToMesh(); GEOM::GEOM_Object_var meshShape = myMesh->GetShapeToMesh();
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( meshShape );
QStringList entryList; QStringList entryList;
QList<int> rows; QList<int> rows;
@ -1273,7 +1280,7 @@ void SMESHGUI_BaseComputeOp::onPublishShape()
// look for myMainShape in the table // look for myMainShape in the table
for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) { for ( int r = 0, nr = table()->rowCount(); r < nr; ++r ) {
if ( table()->item( r, COL_SHAPEID )->text() == "1" ) { if ( table()->item( r, COL_SHAPEID )->text() == "1" ) {
if ( so->_is_nil() ) { if ( !so->_is_nil() ) {
CORBA::String_var name = so->GetName(); CORBA::String_var name = so->GetName();
CORBA::String_var entry = so->GetID(); CORBA::String_var entry = so->GetID();
QString shapeText = QString("%1 (%2)").arg( name.in() ).arg( entry.in() ); QString shapeText = QString("%1 (%2)").arg( name.in() ).arg( entry.in() );

View File

@ -92,9 +92,6 @@ GetAllFields(const QList< QPair< SMESH::SMESH_IDSource_var, QString > >& meshes,
myFields = & fields; myFields = & fields;
myTree->clear(); myTree->clear();
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen();
GEOM::GEOM_IFieldOperations_wrap fieldOp = geomGen->GetIFieldOperations();
for ( int iM = 0; iM < meshes.count(); ++iM ) for ( int iM = 0; iM < meshes.count(); ++iM )
{ {
GEOM::ListOfFields_var fields; GEOM::ListOfFields_var fields;
@ -109,6 +106,9 @@ GetAllFields(const QList< QPair< SMESH::SMESH_IDSource_var, QString > >& meshes,
QTreeWidgetItem* meshItem = createItem( myTree, meshes[iM].second, iM ); QTreeWidgetItem* meshItem = createItem( myTree, meshes[iM].second, iM );
GEOM::GEOM_Object_var shape = mesh->GetShapeToMesh(); GEOM::GEOM_Object_var shape = mesh->GetShapeToMesh();
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( shape );
GEOM::GEOM_IFieldOperations_wrap fieldOp = geomGen->GetIFieldOperations();
fields = fieldOp->GetFields( shape ); fields = fieldOp->GetFields( shape );
for ( size_t iF = 0; iF < fields->length(); ++iF ) for ( size_t iF = 0; iF < fields->length(); ++iF )
{ {

View File

@ -44,16 +44,12 @@
namespace SMESH namespace SMESH
{ {
GEOM::GEOM_Gen_var GetGEOMGen() GEOM::GEOM_Gen_var GetGEOMGen( GEOM::GEOM_Object_ptr go )
{ {
static GEOM::GEOM_Gen_var aGEOMGen; GEOM::GEOM_Gen_ptr gen;
if ( !CORBA::is_nil( go ))
if(CORBA::is_nil(aGEOMGen)) { gen = go->GetGen();
if ( GeometryGUI::GetGeomGen()->_is_nil() ) return gen;
GeometryGUI::InitGeomGen();
aGEOMGen = GeometryGUI::GetGeomGen();
}
return aGEOMGen;
} }
GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(_PTR(SObject) theMeshOrSubmesh, GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh(_PTR(SObject) theMeshOrSubmesh,
@ -155,14 +151,18 @@ namespace SMESH
GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape,
long theID) long theID)
{ {
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); if ( CORBA::is_nil( theMainShape ))
return GEOM::GEOM_Object::_nil();
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( theMainShape );
if (geomGen->_is_nil()) if (geomGen->_is_nil())
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
GEOM::GEOM_IShapesOperations_wrap aShapesOp =
geomGen->GetIShapesOperations(); GEOM::GEOM_IShapesOperations_wrap aShapesOp = geomGen->GetIShapesOperations();
if (aShapesOp->_is_nil()) if (aShapesOp->_is_nil())
return GEOM::GEOM_Object::_nil(); return GEOM::GEOM_Object::_nil();
GEOM::GEOM_Object_wrap subShape = aShapesOp->GetSubShape (theMainShape,theID);
GEOM::GEOM_Object_wrap subShape = aShapesOp->GetSubShape( theMainShape, theID );
return subShape._retn(); return subShape._retn();
} }

View File

@ -45,7 +45,7 @@ class QString;
namespace SMESH namespace SMESH
{ {
SMESHGUI_EXPORT GEOM::GEOM_Gen_var GetGEOMGen(); SMESHGUI_EXPORT GEOM::GEOM_Gen_var GetGEOMGen( GEOM::GEOM_Object_ptr go );
SMESHGUI_EXPORT GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh( _PTR(SObject), bool* isMesh=0 ); SMESHGUI_EXPORT GEOM::GEOM_Object_var GetShapeOnMeshOrSubMesh( _PTR(SObject), bool* isMesh=0 );

View File

@ -1055,27 +1055,27 @@ bool SMESHGUI_GroupDlg::onApply()
} }
else { else {
SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen(); SMESH::SMESH_Gen_var aSMESHGen = SMESHGUI::GetSMESHGen();
if ( aSMESHGen->_is_nil() ) if ( aSMESHGen->_is_nil() || myGeomObjects->length() == 0 )
return false; return false;
// create a geometry group // create a geometry group
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( myGeomObjects[0] );
if (geomGen->_is_nil()) if (geomGen->_is_nil())
return false; return false;
GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(); GEOM::GEOM_IGroupOperations_ptr op = geomGen->GetIGroupOperations();
if (op->_is_nil()) if (op->_is_nil())
return false; return false;
// check and add all selected GEOM objects: they must be // check and add all selected GEOM objects: they must be
// a sub-shapes of the main GEOM and must be of one type // a sub-shapes of the main GEOM and must be of one type
TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE; TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
for ( int i =0; i < (int)myGeomObjects->length(); i++) { for ( CORBA::ULong i =0; i < myGeomObjects->length(); i++)
{
TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType(); TopAbs_ShapeEnum aSubShapeType = (TopAbs_ShapeEnum)myGeomObjects[i]->GetShapeType();
if (i == 0) if ( i == 0 )
aGroupType = aSubShapeType; aGroupType = aSubShapeType;
else if (aSubShapeType != aGroupType) { else if ( aSubShapeType != aGroupType ) {
aGroupType = TopAbs_SHAPE; aGroupType = TopAbs_SHAPE;
break; break;
} }
@ -1083,6 +1083,8 @@ bool SMESHGUI_GroupDlg::onApply()
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh(); GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType); GEOM::GEOM_Object_wrap aGroupVar = op->CreateGroup(aMeshShape, aGroupType);
if ( aGroupVar->_is_nil() )
return false;
op->UnionList(aGroupVar, myGeomObjects); op->UnionList(aGroupVar, myGeomObjects);
if (op->IsDone()) { if (op->IsDone()) {
@ -1410,13 +1412,15 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged()
// The main shape of the group // The main shape of the group
GEOM::GEOM_Object_var aGroupMainShape; GEOM::GEOM_Object_var aGroupMainShape;
if (aGeomGroup->GetType() == 37) { if (aGeomGroup->GetType() == 37)
GEOM::GEOM_IGroupOperations_wrap anOp = {
SMESH::GetGEOMGen()->GetIGroupOperations(); GEOM::GEOM_IGroupOperations_ptr anOp =
aGroupMainShape = anOp->GetMainShape(aGeomGroup); SMESH::GetGEOMGen( aGeomGroup )->GetIGroupOperations();
aGroupMainShape = anOp->GetMainShape( aGeomGroup );
// aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap // aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap
} }
else { else
{
aGroupMainShape = aGeomGroup; aGroupMainShape = aGeomGroup;
aGroupMainShape->Register(); aGroupMainShape->Register();
} }
@ -1867,7 +1871,8 @@ void SMESHGUI_GroupDlg::onAdd()
QListWidgetItem* anItem = 0; QListWidgetItem* anItem = 0;
QList<QListWidgetItem*> listItemsToSel; QList<QListWidgetItem*> listItemsToSel;
if (myCurrentLineEdit == 0) { if ( myCurrentLineEdit == 0 )
{
//if (aNbSel != 1) { myIsBusy = false; return; } //if (aNbSel != 1) { myIsBusy = false; return; }
QString aListStr = ""; QString aListStr = "";
int aNbItems = 0; int aNbItems = 0;
@ -1910,7 +1915,9 @@ void SMESHGUI_GroupDlg::onAdd()
onListSelectionChanged(); onListSelectionChanged();
listItemsToSel.clear(); listItemsToSel.clear();
} }
} else if (myCurrentLineEdit == mySubMeshLine) { }
else if ( myCurrentLineEdit == mySubMeshLine )
{
//SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
SALOME_ListIO aList; SALOME_ListIO aList;
@ -1958,7 +1965,9 @@ void SMESHGUI_GroupDlg::onAdd()
myIsBusy = false; myIsBusy = false;
onListSelectionChanged(); onListSelectionChanged();
} else if (myCurrentLineEdit == myGroupLine) { }
else if ( myCurrentLineEdit == myGroupLine )
{
//SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects()); //SALOME_ListIteratorOfListIO anIt (mySelectionMgr->StoredIObjects());
SALOME_ListIO aList; SALOME_ListIO aList;
mySelectionMgr->selectedObjects( aList ); mySelectionMgr->selectedObjects( aList );
@ -2000,9 +2009,11 @@ void SMESHGUI_GroupDlg::onAdd()
myIsBusy = false; myIsBusy = false;
onListSelectionChanged(); onListSelectionChanged();
} else if (myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1) { }
GEOM::GEOM_IGroupOperations_wrap aGroupOp = else if ( myCurrentLineEdit == myGeomGroupLine && myGeomObjects->length() == 1 )
SMESH::GetGEOMGen()->GetIGroupOperations(); {
GEOM::GEOM_IGroupOperations_ptr aGroupOp =
SMESH::GetGEOMGen( myGeomObjects[0] )->GetIGroupOperations();
SMESH::ElementType aGroupType = SMESH::ALL; SMESH::ElementType aGroupType = SMESH::ALL;
switch(aGroupOp->GetType(myGeomObjects[0])) { switch(aGroupOp->GetType(myGeomObjects[0])) {

View File

@ -220,12 +220,12 @@ SMESH::ElementType SMESHGUI_GroupOnShapeOp::ElementType(GEOM::GEOM_Object_var ge
case GEOM::COMPOUND: break; case GEOM::COMPOUND: break;
default: return SMESH::ALL; default: return SMESH::ALL;
} }
GEOM::GEOM_IShapesOperations_wrap aShapeOp = GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( geom );
SMESH::GetGEOMGen()->GetIShapesOperations(); GEOM::GEOM_IShapesOperations_wrap aShapeOp = geomGen->GetIShapesOperations();
if ( geom->GetType() == 37 ) { // geom group if ( geom->GetType() == 37 ) // geom group
GEOM::GEOM_IGroupOperations_wrap aGroupOp = {
SMESH::GetGEOMGen()->GetIGroupOperations(); GEOM::GEOM_IGroupOperations_ptr aGroupOp = geomGen->GetIGroupOperations();
if ( !aGroupOp->_is_nil() ) { if ( !aGroupOp->_is_nil() ) {
// mainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap // mainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap
GEOM::GEOM_Object_var mainShape = aGroupOp->GetMainShape( geom ); GEOM::GEOM_Object_var mainShape = aGroupOp->GetMainShape( geom );
@ -236,7 +236,8 @@ SMESH::ElementType SMESHGUI_GroupOnShapeOp::ElementType(GEOM::GEOM_Object_var ge
} }
} }
} }
else if ( !aShapeOp->_is_nil() ) { // just a compoud shape else if ( !aShapeOp->_is_nil() ) // just a compoud shape
{
GEOM::ListOfLong_var ids = aShapeOp->SubShapeAllIDs( geom, GEOM::SHAPE, false ); GEOM::ListOfLong_var ids = aShapeOp->SubShapeAllIDs( geom, GEOM::SHAPE, false );
if ( ids->length() ) { if ( ids->length() ) {
GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( geom, ids[0] ); GEOM::GEOM_Object_wrap member = aShapeOp->GetSubShape( geom, ids[0] );

View File

@ -346,10 +346,10 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const
myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs); myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs);
if (aGEOMs.count() > 0) { if (aGEOMs.count() > 0) {
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); GEOM::GEOM_Gen_var geomGen = mainGeom->GetGen();
if (geomGen->_is_nil()) return false; if (geomGen->_is_nil()) return false;
GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(); GEOM::GEOM_IGroupOperations_ptr op = geomGen->GetIGroupOperations();
if (op->_is_nil()) return false; if (op->_is_nil()) return false;
// check all selected shapes // check all selected shapes
@ -1756,7 +1756,7 @@ void SMESHGUI_MeshOp::createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr theMes
for ( size_t i = 0; i < internalEdges.size(); ++i ) for ( size_t i = 0; i < internalEdges.size(); ++i )
intIDSet.insert( shapeIDs.FindIndex( internalEdges[ i ])); intIDSet.insert( shapeIDs.FindIndex( internalEdges[ i ]));
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); GEOM::GEOM_Gen_var geomGen = theMainShape->GetGen();
if (geomGen->_is_nil()) return; if (geomGen->_is_nil()) return;
GEOM::GEOM_Object_var edgeGroup; GEOM::GEOM_Object_var edgeGroup;
@ -2062,7 +2062,7 @@ bool SMESHGUI_MeshOp::createMesh( QString& theMess, QStringList& theEntryList )
{ {
// Create groups on all geom groups // Create groups on all geom groups
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); GEOM::GEOM_Gen_var geomGen = aGeomVar->GetGen();
GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations(); GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
GEOM::ListOfGO_var geomGroups = op->GetExistingSubObjects( aGeomVar, GEOM::ListOfGO_var geomGroups = op->GetExistingSubObjects( aGeomVar,
/*groupsOnly=*/false ); /*groupsOnly=*/false );
@ -2138,11 +2138,11 @@ bool SMESHGUI_MeshOp::createSubMesh( QString& theMess, QStringList& theEntryList
else if (aGEOMs.count() > 1) else if (aGEOMs.count() > 1)
{ {
// create a GEOM group // create a GEOM group
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); GEOM::GEOM_Gen_var geomGen = mainGeom->GetGen();
if (!geomGen->_is_nil()) { if ( !geomGen->_is_nil() ) {
GEOM::GEOM_IGroupOperations_wrap op = GEOM::GEOM_IGroupOperations_ptr op = geomGen->GetIGroupOperations();
geomGen->GetIGroupOperations(); if ( !op->_is_nil() )
if (!op->_is_nil()) { {
// check and add all selected GEOM objects: they must be // check and add all selected GEOM objects: they must be
// a sub-shapes of the main GEOM and must be of one type // a sub-shapes of the main GEOM and must be of one type
int iSubSh = 0; int iSubSh = 0;

View File

@ -230,6 +230,8 @@ namespace SMESHOp {
OpClipping = 6100, // POPUP MENU - CLIPPING OpClipping = 6100, // POPUP MENU - CLIPPING
// SortChild ----------------------//-------------------------------- // SortChild ----------------------//--------------------------------
OpSortChild = 6110, // POPUP MENU - SORT CHILDREN OpSortChild = 6110, // POPUP MENU - SORT CHILDREN
// Break link with Shaper object --//--------------------------------
OpBreakLink = 6120, // POPUP MENU - Break link with Shaper
// Advanced -----------------------//-------------------------------- // Advanced -----------------------//--------------------------------
OpAdvancedNoOp = 10000, // NO OPERATION (advanced operations base) OpAdvancedNoOp = 10000, // NO OPERATION (advanced operations base)
//@@ insert new functions before this line @@ do not remove this line @@// //@@ insert new functions before this line @@ do not remove this line @@//

View File

@ -43,6 +43,8 @@
#include <SalomeApp_Application.h> #include <SalomeApp_Application.h>
#include <LightApp_VTKSelector.h> #include <LightApp_VTKSelector.h>
#include <SVTK_ViewWindow.h> #include <SVTK_ViewWindow.h>
#include <LightApp_SelectionMgr.h>
#include <LightApp_DataOwner.h>
// IDL includes // IDL includes
#include <SALOMEconfig.h> #include <SALOMEconfig.h>
@ -77,6 +79,8 @@ void SMESHGUI_Selection::init( const QString& client, LightApp_SelectionMgr* mgr
if( mgr ) if( mgr )
{ {
myOwners.clear();
mgr->selected(myOwners, client);
for( int i=0, n=count(); i<n; i++ ) { for( int i=0, n=count(); i<n; i++ ) {
myTypes.append( typeName( type( entry( i ) ) ) ); myTypes.append( typeName( type( entry( i ) ) ) );
myControls.append( controlMode( i ) ); myControls.append( controlMode( i ) );
@ -140,6 +144,7 @@ QVariant SMESHGUI_Selection::parameter( const int ind, const QString& p ) const
else if ( p=="nbChildren") val = QVariant( nbChildren( ind ) ); else if ( p=="nbChildren") val = QVariant( nbChildren( ind ) );
else if ( p=="isContainer") val = QVariant( isContainer( ind ) ); else if ( p=="isContainer") val = QVariant( isContainer( ind ) );
else if ( p=="guiState") val = QVariant( guiState() ); else if ( p=="guiState") val = QVariant( guiState() );
else if ( p=="canBreakLink") val = QVariant( canBreakLink(ind) );
if ( val.isValid() ) if ( val.isValid() )
return val; return val;
@ -605,6 +610,33 @@ bool SMESHGUI_Selection::hasGeomReference( int ind ) const
return false; return false;
} }
//=======================================================================
//function : canBreakLink
//purpose : returns true if selected object is a Shaper object and it can break link
//=======================================================================
bool SMESHGUI_Selection::canBreakLink( int ind ) const
{
if ( ind >= 0 && ind < myTypes.count()) {
if (isReference(ind)) {
SUIT_DataOwner* aOwn = myOwners.at(ind);
LightApp_DataOwner* sowner = dynamic_cast<LightApp_DataOwner*>(aOwn);
QString aEntry = sowner->entry();
_PTR(SObject) aSObject = SMESH::getStudy()->FindObjectID(aEntry.toStdString());
_PTR(SObject) aFatherObj = aSObject->GetFather();
_PTR(SComponent) aComponent = aFatherObj->GetFatherComponent();
if (aComponent->ComponentDataType() == "SMESH") {
QString aObjEntry = entry(ind);
_PTR(SObject) aGeomSObject = SMESH::getStudy()->FindObjectID(aObjEntry.toStdString());
GEOM::GEOM_Object_var aObject = SMESH::SObjectToInterface<GEOM::GEOM_Object>(aGeomSObject);
if (!aObject->_is_nil())
return aObject->IsParametrical();
}
}
}
return false;
}
//======================================================================= //=======================================================================
//function : isEditableHyp //function : isEditableHyp
//purpose : //purpose :

View File

@ -32,6 +32,7 @@
// SALOME GUI includes // SALOME GUI includes
#include <LightApp_Selection.h> #include <LightApp_Selection.h>
#include <SUIT_DataOwner.h>
// SALOME KERNEL includes // SALOME KERNEL includes
#include <SALOMEDSClient_definitions.hxx> #include <SALOMEDSClient_definitions.hxx>
@ -61,6 +62,7 @@ public:
virtual bool hasGeomReference( int ) const; virtual bool hasGeomReference( int ) const;
virtual bool isEditableHyp( int ) const; virtual bool isEditableHyp( int ) const;
virtual bool isVisible( int ) const; virtual bool isVisible( int ) const;
virtual bool canBreakLink(int) const;
virtual bool isQuadratic( int ) const; virtual bool isQuadratic( int ) const;
virtual QString quadratic2DMode( int ) const; virtual QString quadratic2DMode( int ) const;
@ -95,6 +97,7 @@ private:
QStringList myTypes; QStringList myTypes;
QStringList myControls; QStringList myControls;
QList<SMESH_Actor*> myActors; QList<SMESH_Actor*> myActors;
SUIT_DataOwnerPtrList myOwners;
}; };
#endif // SMESHGUI_SELECTION_H #endif // SMESHGUI_SELECTION_H

View File

@ -318,14 +318,14 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
} }
else else
{ {
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
if (geomGen->_is_nil()) GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( aMeshShape );
if ( geomGen->_is_nil() )
return; return;
GEOM::GEOM_IShapesOperations_wrap aShapesOp = GEOM::GEOM_IShapesOperations_wrap aShapesOp = geomGen->GetIShapesOperations();
geomGen->GetIShapesOperations(); if ( aShapesOp->_is_nil() )
if (aShapesOp->_is_nil() )
return; return;
TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE; TopAbs_ShapeEnum aGroupType = TopAbs_SHAPE;
@ -333,8 +333,6 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
std::map<int, GEOM::GEOM_Object_wrap> aGeomObjectsMap; std::map<int, GEOM::GEOM_Object_wrap> aGeomObjectsMap;
GEOM::GEOM_Object_wrap aGeomObject; GEOM::GEOM_Object_wrap aGeomObject;
GEOM::GEOM_Object_var aMeshShape = myMesh->GetShapeToMesh();
for ( int i = 0; i < aListId.count(); i++ ) for ( int i = 0; i < aListId.count(); i++ )
{ {
aGeomObject = // received object need UnRegister()! aGeomObject = // received object need UnRegister()!
@ -362,9 +360,8 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
} }
else if (aNumberOfGO > 1) else if (aNumberOfGO > 1)
{ {
GEOM::GEOM_IGroupOperations_wrap aGroupOp = GEOM::GEOM_IGroupOperations_ptr aGroupOp = geomGen->GetIGroupOperations();
geomGen->GetIGroupOperations(); if ( aGroupOp->_is_nil() )
if(aGroupOp->_is_nil())
return; return;
GEOM::ListOfGO_var aGeomObjects = new GEOM::ListOfGO(); GEOM::ListOfGO_var aGeomObjects = new GEOM::ListOfGO();
@ -379,7 +376,7 @@ void SMESHGUI_ShapeByMeshOp::commitOperation()
aGeomObject = aGroupOp->CreateGroup(aMeshShape, aGroupType); aGeomObject = aGroupOp->CreateGroup(aMeshShape, aGroupType);
aGroupOp->UnionList(aGeomObject, aGeomObjects); aGroupOp->UnionList(aGeomObject, aGeomObjects);
if (!aGroupOp->IsDone()) if ( !aGroupOp->IsDone() )
return; return;
} }
@ -419,7 +416,7 @@ void SMESHGUI_ShapeByMeshOp::onSelectionDone()
try { try {
SALOME_ListIO aList; SALOME_ListIO aList;
selectionMgr()->selectedObjects(aList); selectionMgr()->selectedObjects(aList);
if (!myIsMultipleAllowed && aList.Extent() != 1) if ( aList.IsEmpty() || ( !myIsMultipleAllowed && aList.Extent() != 1) )
return; return;
SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First()); SMESH::SMESH_Mesh_var aMesh = SMESH::GetMeshByIO(aList.First());

View File

@ -281,7 +281,7 @@ namespace SMESH
_PTR(AttributePixMap) pixMap = attr; _PTR(AttributePixMap) pixMap = attr;
toShow = ( pixMap->GetPixMap() != emptyIcon ); toShow = ( pixMap->GetPixMap() != emptyIcon );
} }
smeshActor->Update(); //smeshActor->Update();
UpdateView( theWindow, toShow ? eDisplay : eErase, io->getEntry() ); UpdateView( theWindow, toShow ? eDisplay : eErase, io->getEntry() );
} }
} }

View File

@ -531,6 +531,10 @@
<source>ICON_SMESH_TREE_MESH_WARN</source> <source>ICON_SMESH_TREE_MESH_WARN</source>
<translation>mesh_tree_mesh_warn.png</translation> <translation>mesh_tree_mesh_warn.png</translation>
</message> </message>
<message>
<source>ICON_SMESH_TREE_GEOM_MODIF</source>
<translation>mesh_tree_mesh_geom_modif.png</translation>
</message>
<message> <message>
<source>ICON_STD_INFO</source> <source>ICON_STD_INFO</source>
<translation>standard_mesh_info.png</translation> <translation>standard_mesh_info.png</translation>

View File

@ -4503,6 +4503,24 @@ It can&apos;t be deleted </translation>
<source>STB_SORT_CHILD_ITEMS</source> <source>STB_SORT_CHILD_ITEMS</source>
<translation>Sort child items</translation> <translation>Sort child items</translation>
</message> </message>
<message>
<source>MEN_BREAK_SHAPER_LINK</source>
<translation>Break link</translation>
</message>
<message>
<source>STB_BREAK_SHAPER_LINK</source>
<translation>Break link with Shaper model</translation>
</message>
<message>
<source>MSG_BREAK_SHAPER_LINK</source>
<translation>A link with Shaper model for object %1 will be broken.
Continue?</translation>
</message>
<message>
<source>MSG_WARN_ON_GEOM_MODIF</source>
<translation>This action is prohibited since the geometry
was changed and the mesh needs to be recomputed.</translation>
</message>
<message> <message>
<source>SMESH_ADVANCED</source> <source>SMESH_ADVANCED</source>
<translation>Advanced</translation> <translation>Advanced</translation>

View File

@ -4470,6 +4470,21 @@ Il ne peut pas être supprimé.</translation>
<source>STB_SORT_CHILD_ITEMS</source> <source>STB_SORT_CHILD_ITEMS</source>
<translation>Trier les items enfants</translation> <translation>Trier les items enfants</translation>
</message> </message>
<message>
<source>MEN_BREAK_SHAPER_LINK</source>
<translation>Rompre le lien</translation>
</message>
<message>
<source>STB_BREAK_SHAPER_LINK</source>
<translation>Rupture du lien avec le modèle Shaper</translation>
</message>
<message>
<source>MSG_BREAK_SHAPER_LINK</source>
<translation>
Un lien avec le modèle Shaper pour l'objet %1 sera rompu.
Continuer?
</translation>
</message>
<message> <message>
<source>SMESH_ADVANCED</source> <source>SMESH_ADVANCED</source>
<translation>Avancé</translation> <translation>Avancé</translation>

View File

@ -567,7 +567,8 @@ _pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod
myRemovedObjIDs( theRemovedObjIDs ), myRemovedObjIDs( theRemovedObjIDs ),
myNbFilters( 0 ), myNbFilters( 0 ),
myToKeepAllCommands( theToKeepAllCommands ), myToKeepAllCommands( theToKeepAllCommands ),
myGeomIDNb(0), myGeomIDIndex(-1) myGeomIDNb(0), myGeomIDIndex(-1),
myShaperIDNb(0), myShaperIDIndex(-1)
{ {
// make that GetID() to return TPythonDump::SMESHGenName() // make that GetID() to return TPythonDump::SMESHGenName()
GetCreationCmd()->Clear(); GetCreationCmd()->Clear();
@ -575,29 +576,37 @@ _pyGen::_pyGen(Resource_DataMapOfAsciiStringAsciiString& theEntry2AccessorMethod
GetCreationCmd()->GetString() += "="; GetCreationCmd()->GetString() += "=";
// Find 1st digit of study entry by which a GEOM object differs from a SMESH object // Find 1st digit of study entry by which a GEOM object differs from a SMESH object
if ( !theObjectNames.IsEmpty() ) if (!theObjectNames.IsEmpty())
{ {
// find a GEOM entry // find a GEOM (aPass == 0) and SHAPERSTUDY (aPass == 1) entries
for(int aPass = 0; aPass < 2; aPass++) {
_pyID geomID; _pyID geomID;
SALOMEDS::SComponent_wrap geomComp = SMESH_Gen_i::getStudyServant()->FindComponent("GEOM"); SALOMEDS::SComponent_wrap geomComp = SMESH_Gen_i::getStudyServant()->
if ( geomComp->_is_nil() ) return; FindComponent(aPass == 0 ? "GEOM" : "SHAPERSTUDY");
if (geomComp->_is_nil()) continue;
CORBA::String_var entry = geomComp->GetID(); CORBA::String_var entry = geomComp->GetID();
geomID = entry.in(); geomID = entry.in();
// find a SMESH entry // find a SMESH entry
_pyID smeshID; _pyID smeshID;
Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString e2n( theObjectNames ); Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString e2n(theObjectNames);
for ( ; e2n.More() && smeshID.IsEmpty(); e2n.Next() ) for (; e2n.More() && smeshID.IsEmpty(); e2n.Next())
if ( _pyCommand::IsStudyEntry( e2n.Key() )) if (_pyCommand::IsStudyEntry(e2n.Key()))
smeshID = e2n.Key(); smeshID = e2n.Key();
// find 1st difference between smeshID and geomID // find 1st difference between smeshID and geomID
if ( !geomID.IsEmpty() && !smeshID.IsEmpty() ) if (!geomID.IsEmpty() && !smeshID.IsEmpty())
for ( int i = 1; i <= geomID.Length() && i <= smeshID.Length(); ++i ) for (int i = 1; i <= geomID.Length() && i <= smeshID.Length(); ++i)
if ( geomID.Value( i ) != smeshID.Value( i )) if (geomID.Value(i) != smeshID.Value(i))
{ {
myGeomIDNb = geomID.Value( i ); if (aPass == 0) {
myGeomIDNb = geomID.Value(i);
myGeomIDIndex = i; myGeomIDIndex = i;
} else {
myShaperIDNb = geomID.Value(i);
myShaperIDIndex = i;
}
}
} }
} }
} }
@ -1680,13 +1689,11 @@ Handle(_pyObject) _pyGen::FindObject( const _pyID& theObjID ) const
bool _pyGen::IsGeomObject(const _pyID& theObjID) const bool _pyGen::IsGeomObject(const _pyID& theObjID) const
{ {
if ( myGeomIDNb ) bool isGeom = myGeomIDNb && myGeomIDIndex <= theObjID.Length() &&
{ int( theObjID.Value( myGeomIDIndex )) == myGeomIDNb;
return ( myGeomIDIndex <= theObjID.Length() && bool isShaper = myShaperIDNb && myShaperIDIndex <= theObjID.Length() &&
int( theObjID.Value( myGeomIDIndex )) == myGeomIDNb && int( theObjID.Value( myShaperIDIndex )) == myShaperIDNb;
_pyCommand::IsStudyEntry( theObjID )); return ((isGeom || isShaper) && _pyCommand::IsStudyEntry( theObjID ));
}
return false;
} }
//================================================================================ //================================================================================
@ -3831,6 +3838,8 @@ bool _pyCommand::IsMethodCall()
return false; return false;
if ( myString.StartsWith("#") ) if ( myString.StartsWith("#") )
return false; return false;
if ( myString.StartsWith("SHAPERSTUDY") ) // skip shaperstudy specific dump string analysis
return false;
const char* s = myString.ToCString() + GetBegPos( METHOD_IND ) + myMeth.Length() - 1; const char* s = myString.ToCString() + GetBegPos( METHOD_IND ) + myMeth.Length() - 1;
return ( s[0] == '(' || s[1] == '(' ); return ( s[0] == '(' || s[1] == '(' );
} }

View File

@ -323,7 +323,10 @@ private:
Handle(_pyCommand) myLastCommand; Handle(_pyCommand) myLastCommand;
int myNbFilters; int myNbFilters;
bool myToKeepAllCommands; bool myToKeepAllCommands;
// difference of entry and index of this difference
int myGeomIDNb, myGeomIDIndex; int myGeomIDNb, myGeomIDIndex;
// difference of entry and index of this difference, specific for the SHAPER study
int myShaperIDNb, myShaperIDIndex;
std::map< _AString, ExportedMeshData > myFile2ExportedMesh; std::map< _AString, ExportedMeshData > myFile2ExportedMesh;
Handle( _pyHypothesisReader ) myHypReader; Handle( _pyHypothesisReader ) myHypReader;

View File

@ -903,9 +903,7 @@ void BelongToGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
{ {
if ( theGeom->_is_nil() ) if ( theGeom->_is_nil() )
return; return;
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom );
GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
myBelongToGeomPtr->SetGeom( aLocShape ); myBelongToGeomPtr->SetGeom( aLocShape );
TPythonDump()<<this<<".SetGeom("<<theGeom<<")"; TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
} }
@ -1001,9 +999,7 @@ void BelongToSurface_i::SetSurface( GEOM::GEOM_Object_ptr theGeom, ElementType t
{ {
if ( theGeom->_is_nil() ) if ( theGeom->_is_nil() )
return; return;
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom );
GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
if ( aLocShape.ShapeType() == TopAbs_FACE ) if ( aLocShape.ShapeType() == TopAbs_FACE )
{ {
@ -1173,9 +1169,7 @@ void LyingOnGeom_i::SetGeom( GEOM::GEOM_Object_ptr theGeom )
{ {
if ( theGeom->_is_nil() ) if ( theGeom->_is_nil() )
return; return;
SMESH_Gen_i* aSMESHGen = SMESH_Gen_i::GetSMESHGen(); TopoDS_Shape aLocShape = SMESH_Gen_i::GetSMESHGen()->GeomObjectToShape( theGeom );
GEOM::GEOM_Gen_ptr aGEOMGen = SMESH_Gen_i::GetGeomEngine();
TopoDS_Shape aLocShape = aSMESHGen->GetShapeReader()->GetShape( aGEOMGen, theGeom );
myLyingOnGeomPtr->SetGeom( aLocShape ); myLyingOnGeomPtr->SetGeom( aLocShape );
TPythonDump()<<this<<".SetGeom("<<theGeom<<")"; TPythonDump()<<this<<".SetGeom("<<theGeom<<")";
} }

View File

@ -157,7 +157,7 @@ static int MYDEBUG = 0;
#endif #endif
// Static variables definition // Static variables definition
GEOM::GEOM_Gen_var SMESH_Gen_i::myGeomGen = GEOM::GEOM_Gen::_nil(); GEOM::GEOM_Gen_var SMESH_Gen_i::myGeomGen;
CORBA::ORB_var SMESH_Gen_i::myOrb; CORBA::ORB_var SMESH_Gen_i::myOrb;
PortableServer::POA_var SMESH_Gen_i::myPoa; PortableServer::POA_var SMESH_Gen_i::myPoa;
SALOME_NamingService* SMESH_Gen_i::myNS = NULL; SALOME_NamingService* SMESH_Gen_i::myNS = NULL;
@ -258,14 +258,15 @@ SALOME_NamingService* SMESH_Gen_i::GetNS()
* Get SALOME_LifeCycleCORBA object * Get SALOME_LifeCycleCORBA object
*/ */
//============================================================================= //=============================================================================
SALOME_LifeCycleCORBA* SMESH_Gen_i::GetLCC() {
SALOME_LifeCycleCORBA* SMESH_Gen_i::GetLCC()
{
if ( myLCC == NULL ) { if ( myLCC == NULL ) {
myLCC = new SALOME_LifeCycleCORBA( GetNS() ); myLCC = new SALOME_LifeCycleCORBA( GetNS() );
} }
return myLCC; return myLCC;
} }
//============================================================================= //=============================================================================
/*! /*!
* GetGeomEngine [ static ] * GetGeomEngine [ static ]
@ -273,18 +274,33 @@ SALOME_LifeCycleCORBA* SMESH_Gen_i::GetLCC() {
* Get GEOM::GEOM_Gen reference * Get GEOM::GEOM_Gen reference
*/ */
//============================================================================= //=============================================================================
GEOM::GEOM_Gen_var SMESH_Gen_i::GetGeomEngine() {
//CCRT GEOM::GEOM_Gen_var aGeomEngine = GEOM::GEOM_Gen_var SMESH_Gen_i::GetGeomEngine( bool isShaper )
//CCRT GEOM::GEOM_Gen::_narrow( GetLCC()->FindOrLoad_Component("FactoryServer","GEOM") ); {
//CCRT return aGeomEngine._retn(); Engines::EngineComponent_ptr temp =
if(CORBA::is_nil(myGeomGen)) GetLCC()->FindOrLoad_Component( isShaper ? "FactoryServer" : "FactoryServer",
{ isShaper ? "SHAPERSTUDY" : "GEOM" );
Engines::EngineComponent_ptr temp=GetLCC()->FindOrLoad_Component("FactoryServer","GEOM"); myGeomGen = GEOM::GEOM_Gen::_narrow( temp );
myGeomGen=GEOM::GEOM_Gen::_narrow(temp);
}
return myGeomGen; return myGeomGen;
} }
//=============================================================================
/*!
* GetGeomEngine [ static ]
*
* Get GEOM::GEOM_Gen reference
*/
//=============================================================================
GEOM::GEOM_Gen_var SMESH_Gen_i::GetGeomEngine( GEOM::GEOM_Object_ptr go )
{
GEOM::GEOM_Gen_ptr gen;
if ( !CORBA::is_nil( go ))
gen = go->GetGen();
return gen;
}
//============================================================================= //=============================================================================
/*! /*!
* SMESH_Gen_i::SMESH_Gen_i * SMESH_Gen_i::SMESH_Gen_i
@ -687,11 +703,18 @@ void SMESH_Gen_i::UpdateStudy()
myStudyContext = new StudyContext; myStudyContext = new StudyContext;
SALOMEDS::Study_var aStudy = getStudyServant(); SALOMEDS::Study_var aStudy = getStudyServant();
if ( !CORBA::is_nil( aStudy ) ) { if ( !CORBA::is_nil( aStudy ) )
{
SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
SALOMEDS::SComponent_wrap GEOM_var = aStudy->FindComponent( "GEOM" ); SALOMEDS::SComponent_wrap GEOM_var = aStudy->FindComponent( "GEOM" );
if( !GEOM_var->_is_nil() ) if( !GEOM_var->_is_nil() )
aStudyBuilder->LoadWith( GEOM_var, GetGeomEngine() ); aStudyBuilder->LoadWith( GEOM_var, GetGeomEngine( /*isShaper=*/false ) );
GEOM_var = aStudy->FindComponent( "SHAPERSTUDY" );
if( !GEOM_var->_is_nil() )
aStudyBuilder->LoadWith( GEOM_var, GetGeomEngine( /*isShaper=*/true ) );
// NPAL16168, issue 0020210 // NPAL16168, issue 0020210
// Let meshes update their data depending on GEOM groups that could change // Let meshes update their data depending on GEOM groups that could change
CORBA::String_var compDataType = ComponentDataType(); CORBA::String_var compDataType = ComponentDataType();
@ -708,6 +731,63 @@ void SMESH_Gen_i::UpdateStudy()
} }
} }
//================================================================================
/*!
* \brief Return true if mesh has ICON_SMESH_TREE_GEOM_MODIF icon
*/
//================================================================================
bool SMESH_Gen_i::isGeomModifIcon( SMESH::SMESH_Mesh_ptr mesh )
{
SALOMEDS::SObject_wrap so = ObjectToSObject( mesh );
SALOMEDS::GenericAttribute_wrap attr;
if ( ! so->_is_nil() && so->FindAttribute( attr.inout(), "AttributePixMap" ))
{
SALOMEDS::AttributePixMap_wrap pm = attr;
CORBA::String_var ico = pm->GetPixMap();
return ( strcmp( ico.in(), "ICON_SMESH_TREE_GEOM_MODIF" ) == 0 );
}
return false;
}
//=================================================================================
// function : hasObjectInfo()
// purpose : shows if module provides information for its objects
//=================================================================================
bool SMESH_Gen_i::hasObjectInfo()
{
return true;
}
//=================================================================================
// function : getObjectInfo()
// purpose : returns an information for a given object by its entry
//=================================================================================
char* SMESH_Gen_i::getObjectInfo( const char* entry )
{
// for a mesh with icon == ICON_SMESH_TREE_GEOM_MODIF show a warning;
// for the rest, "module 'SMESH', ID=0:1:2:*"
SMESH_Comment txt;
SALOMEDS::SObject_wrap so = getStudyServant()->FindObjectID( entry );
CORBA::Object_var obj = SObjectToObject( so );
SMESH::SMESH_Mesh_var mesh = SMESH::SMESH_Mesh::_narrow( obj );
if ( isGeomModifIcon( mesh ))
{
txt << "The geometry was changed and the mesh needs to be recomputed";
}
if ( txt.empty() )
{
CORBA::String_var compType = ComponentDataType();
txt << "module '" << compType << "', ID=" << entry;
}
return CORBA::string_dup( txt );
}
//============================================================================= //=============================================================================
/*! /*!
* SMESH_Gen_i::GetStudyContext * SMESH_Gen_i::GetStudyContext
@ -1995,6 +2075,9 @@ CORBA::Boolean SMESH_Gen_i::Compute( SMESH::SMESH_Mesh_ptr theMesh,
SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh ); SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
ASSERT( meshServant ); ASSERT( meshServant );
if ( meshServant ) { if ( meshServant ) {
if ( isGeomModifIcon( theMesh ))
meshServant->Clear();
else
meshServant->Load(); meshServant->Load();
// NPAL16168: "geometrical group edition from a submesh don't modify mesh computation" // NPAL16168: "geometrical group edition from a submesh don't modify mesh computation"
meshServant->CheckGeomModif(); meshServant->CheckGeomModif();
@ -2351,7 +2434,7 @@ SMESH_Gen_i::GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr theMesh,
GEOM::GEOM_Object_wrap geom = FindGeometryByMeshElement(theMesh, theElementID); GEOM::GEOM_Object_wrap geom = FindGeometryByMeshElement(theMesh, theElementID);
if ( !geom->_is_nil() ) { if ( !geom->_is_nil() ) {
GEOM::GEOM_Object_var mainShape = theMesh->GetShapeToMesh(); GEOM::GEOM_Object_var mainShape = theMesh->GetShapeToMesh();
GEOM::GEOM_Gen_ptr geomGen = GetGeomEngine(); GEOM::GEOM_Gen_var geomGen = GetGeomEngine( geom );
// try to find the corresponding SObject // try to find the corresponding SObject
SALOMEDS::SObject_wrap SObj = ObjectToSObject( geom.in() ); SALOMEDS::SObject_wrap SObj = ObjectToSObject( geom.in() );
@ -2382,7 +2465,7 @@ SMESH_Gen_i::GetGeometryByMeshElement( SMESH::SMESH_Mesh_ptr theMesh,
} }
} }
} }
if ( SObj->_is_nil() ) // publish a new subshape if ( SObj->_is_nil() && !geomGen->_is_nil() ) // publish a new subshape
SObj = geomGen->AddInStudy( geom, theGeomName, mainShape ); SObj = geomGen->AddInStudy( geom, theGeomName, mainShape );
// return only published geometry // return only published geometry
@ -2415,7 +2498,7 @@ SMESH_Gen_i::FindGeometryByMeshElement( SMESH::SMESH_Mesh_ptr theMesh,
THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM ); THROW_SALOME_CORBA_EXCEPTION( "bad Mesh reference", SALOME::BAD_PARAM );
GEOM::GEOM_Object_var mainShape = theMesh->GetShapeToMesh(); GEOM::GEOM_Object_var mainShape = theMesh->GetShapeToMesh();
GEOM::GEOM_Gen_ptr geomGen = GetGeomEngine(); GEOM::GEOM_Gen_var geomGen = GetGeomEngine( mainShape );
// get a core mesh DS // get a core mesh DS
SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh ); SMESH_Mesh_i* meshServant = SMESH::DownCast<SMESH_Mesh_i*>( theMesh );
@ -3098,7 +3181,7 @@ namespace // utils for CopyMeshWithGeom()
std::string newMainEntry = newEntry.in(); std::string newMainEntry = newEntry.in();
SALOMEDS::Study_var study = myGen_i->getStudyServant(); SALOMEDS::Study_var study = myGen_i->getStudyServant();
GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine(); GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine( mainShapeNew );
GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations(); GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
mySubshapes = op->GetExistingSubObjects( mainShapeNew, mySubshapes = op->GetExistingSubObjects( mainShapeNew,
/*groupsOnly=*/false ); /*groupsOnly=*/false );
@ -3153,7 +3236,7 @@ namespace // utils for CopyMeshWithGeom()
return GEOM::GEOM_Object::_duplicate( oldShape ); // shape independent of the old shape return GEOM::GEOM_Object::_duplicate( oldShape ); // shape independent of the old shape
GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh(); GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh();
GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine(); GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine( mainShapeNew );
// try to find by entry or name // try to find by entry or name
if ( myToPublish ) if ( myToPublish )
@ -3213,7 +3296,7 @@ namespace // utils for CopyMeshWithGeom()
{ {
int groupType = getShapeType( myNewMesh_i, newIndices[0] ); int groupType = getShapeType( myNewMesh_i, newIndices[0] );
GEOM::GEOM_IGroupOperations_wrap grOp = geomGen->GetIGroupOperations(); GEOM::GEOM_IGroupOperations_ptr grOp = geomGen->GetIGroupOperations();
newShape = grOp->CreateGroup( mainShapeNew, groupType ); newShape = grOp->CreateGroup( mainShapeNew, groupType );
GEOM::ListOfLong_var newIndicesList = new GEOM::ListOfLong(); GEOM::ListOfLong_var newIndicesList = new GEOM::ListOfLong();
@ -3375,7 +3458,7 @@ namespace // utils for CopyMeshWithGeom()
GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh(); GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh();
GEOM::GEOM_Object_var mainShapeOld = mySrcMesh_i->GetShapeToMesh(); GEOM::GEOM_Object_var mainShapeOld = mySrcMesh_i->GetShapeToMesh();
GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine(); GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine( mainShapeNew );
GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations(); GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
try try
{ {
@ -3397,7 +3480,7 @@ namespace // utils for CopyMeshWithGeom()
GEOM::GEOM_Object_var newShape; GEOM::GEOM_Object_var newShape;
GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh(); GEOM::GEOM_Object_var mainShapeNew = myNewMesh_i->GetShapeToMesh();
GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine(); GEOM::GEOM_Gen_var geomGen = myGen_i->GetGeomEngine( mainShapeNew );
GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations(); GEOM::GEOM_IShapesOperations_wrap op = geomGen->GetIShapesOperations();
try try
{ {
@ -4392,6 +4475,14 @@ SALOMEDS::TMPFile* SMESH_Gen_i::Save( SALOMEDS::SComponent_ptr theComponent,
aDataset->WriteOnDisk( &meshPersistentId ); aDataset->WriteOnDisk( &meshPersistentId );
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
// Store SMESH_Mesh_i::_mainShapeTick
int shapeTick = myImpl->MainShapeTick();
aSize[ 0 ] = 1;
aDataset = new HDFdataset( "shapeTick", aTopGroup, HDF_INT32, aSize, 1 );
aDataset->CreateOnDisk();
aDataset->WriteOnDisk( &shapeTick );
aDataset->CloseOnDisk();
// write reference on a shape if exists // write reference on a shape if exists
SALOMEDS::SObject_wrap myRef; SALOMEDS::SObject_wrap myRef;
bool shapeRefFound = false; bool shapeRefFound = false;
@ -5067,23 +5158,6 @@ SALOMEDS::TMPFile* SMESH_Gen_i::SaveASCII( SALOMEDS::SComponent_ptr theComponent
return anAsciiStreamFile._retn(); return anAsciiStreamFile._retn();
} }
//=============================================================================
/*!
* SMESH_Gen_i::loadGeomData
*
* Load GEOM module data
*/
//=============================================================================
void SMESH_Gen_i::loadGeomData( SALOMEDS::SComponent_ptr theCompRoot )
{
if ( theCompRoot->_is_nil() )
return;
SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder();
aStudyBuilder->LoadWith( theCompRoot, GetGeomEngine() );
}
//============================================================================= //=============================================================================
/*! /*!
* SMESH_Gen_i::Load * SMESH_Gen_i::Load
@ -5097,17 +5171,10 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
const char* theURL, const char* theURL,
bool isMultiFile ) bool isMultiFile )
{ {
// localizing UpdateStudy(); // load geom data
Kernel_Utils::Localizer loc; Kernel_Utils::Localizer loc;
//if (!myStudyContext)
UpdateStudy();
SALOMEDS::Study_var aStudy = getStudyServant(); SALOMEDS::Study_var aStudy = getStudyServant();
/* if( !theComponent->_is_nil() )
{
if( !aStudy->FindComponent( "GEOM" )->_is_nil() )
loadGeomData( aStudy->FindComponent( "GEOM" ) );
}*/
// Get temporary files location // Get temporary files location
TCollection_AsciiString tmpDir = TCollection_AsciiString tmpDir =
@ -5429,10 +5496,6 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
aDataset->CloseOnDisk(); aDataset->CloseOnDisk();
if ( strlen( refFromFile ) > 0 ) { if ( strlen( refFromFile ) > 0 ) {
SALOMEDS::SObject_wrap shapeSO = aStudy->FindObjectID( refFromFile ); SALOMEDS::SObject_wrap shapeSO = aStudy->FindObjectID( refFromFile );
// Make sure GEOM data are loaded first
//loadGeomData( shapeSO->GetFatherComponent() );
CORBA::Object_var shapeObject = SObjectToObject( shapeSO ); CORBA::Object_var shapeObject = SObjectToObject( shapeSO );
if ( !CORBA::is_nil( shapeObject ) ) { if ( !CORBA::is_nil( shapeObject ) ) {
aShapeObject = GEOM::GEOM_Object::_narrow( shapeObject ); aShapeObject = GEOM::GEOM_Object::_narrow( shapeObject );
@ -5444,7 +5507,7 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
} }
// issue 20918. Restore Persistent Id of SMESHDS_Mesh // issue 20918. Restore Persistent Id of SMESHDS_Mesh
if( aTopGroup->ExistInternalObject( "meshPersistentId" ) ) if ( aTopGroup->ExistInternalObject( "meshPersistentId" ) )
{ {
aDataset = new HDFdataset( "meshPersistentId", aTopGroup ); aDataset = new HDFdataset( "meshPersistentId", aTopGroup );
aDataset->OpenOnDisk(); aDataset->OpenOnDisk();
@ -5456,6 +5519,16 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
delete [] meshPersistentId; delete [] meshPersistentId;
} }
// Restore SMESH_Mesh_i::_mainShapeTick
if ( aTopGroup->ExistInternalObject( "shapeTick" ))
{
aDataset = new HDFdataset( "shapeTick", aTopGroup );
aDataset->OpenOnDisk();
int* shapeTick = & myNewMeshImpl->MainShapeTick();
aDataset->ReadFromDisk( shapeTick );
aDataset->CloseOnDisk();
}
// Restore file info // Restore file info
if ( aTopGroup->ExistInternalObject( "file info" )) if ( aTopGroup->ExistInternalObject( "file info" ))
{ {

View File

@ -109,7 +109,8 @@ public:
// Get SALOME_LifeCycleCORBA object // Get SALOME_LifeCycleCORBA object
static SALOME_LifeCycleCORBA* GetLCC(); static SALOME_LifeCycleCORBA* GetLCC();
// Retrieve and get GEOM engine reference // Retrieve and get GEOM engine reference
static GEOM::GEOM_Gen_var GetGeomEngine(); static GEOM::GEOM_Gen_var GetGeomEngine( bool isShaper );
static GEOM::GEOM_Gen_var GetGeomEngine( GEOM::GEOM_Object_ptr );
// Get object of the CORBA reference // Get object of the CORBA reference
static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject ); static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
// Get CORBA object corresponding to the SALOMEDS::SObject // Get CORBA object corresponding to the SALOMEDS::SObject
@ -158,6 +159,12 @@ public:
// Update study // Update study
void UpdateStudy(); void UpdateStudy();
// Do provide info on objects
bool hasObjectInfo();
// Return an information for a given object
char* getObjectInfo(const char* entry);
// Create hypothesis/algorithm of given type // Create hypothesis/algorithm of given type
SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const char* theHypType, SMESH::SMESH_Hypothesis_ptr CreateHypothesis (const char* theHypType,
const char* theLibName) const char* theLibName)
@ -635,6 +642,9 @@ private:
SMESH::SMESH_Mesh_ptr createMesh() SMESH::SMESH_Mesh_ptr createMesh()
throw ( SALOME::SALOME_Exception ); throw ( SALOME::SALOME_Exception );
// Check mesh icon
bool isGeomModifIcon( SMESH::SMESH_Mesh_ptr mesh );
// Create a sub-mesh on a geometry that is not a sub-shape of the main shape // Create a sub-mesh on a geometry that is not a sub-shape of the main shape
// for the case where a valid sub-shape not found by CopyMeshWithGeom() // for the case where a valid sub-shape not found by CopyMeshWithGeom()
SMESH::SMESH_subMesh_ptr createInvalidSubMesh( SMESH::SMESH_Mesh_ptr mesh, SMESH::SMESH_subMesh_ptr createInvalidSubMesh( SMESH::SMESH_Mesh_ptr mesh,
@ -643,8 +653,6 @@ private:
void highLightInvalid( SALOMEDS::SObject_ptr theSObject, bool isInvalid ); void highLightInvalid( SALOMEDS::SObject_ptr theSObject, bool isInvalid );
static void loadGeomData( SALOMEDS::SComponent_ptr theCompRoot );
SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName, SMESH::mesh_array* CreateMeshesFromMEDorSAUV( const char* theFileName,
SMESH::DriverMED_ReadStatus& theStatus, SMESH::DriverMED_ReadStatus& theStatus,
const char* theCommandNameForPython, const char* theCommandNameForPython,

View File

@ -252,9 +252,10 @@ GEOM::GEOM_Object_ptr SMESH_Gen_i::ShapeToGeomObject (const TopoDS_Shape& theSha
TopoDS_Shape SMESH_Gen_i::GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject) TopoDS_Shape SMESH_Gen_i::GeomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject)
{ {
TopoDS_Shape S; TopoDS_Shape S;
if ( !theGeomObject->_is_nil() && !theGeomObject->_non_existent() ) { if ( !theGeomObject->_is_nil() && !theGeomObject->_non_existent() )
{
GEOM_Client* aClient = GetShapeReader(); GEOM_Client* aClient = GetShapeReader();
GEOM::GEOM_Gen_ptr aGeomEngine = GetGeomEngine(); GEOM::GEOM_Gen_var aGeomEngine = GetGeomEngine( theGeomObject );
if ( aClient && !aGeomEngine->_is_nil () ) if ( aClient && !aGeomEngine->_is_nil () )
S = aClient->GetShape( aGeomEngine, theGeomObject ); S = aClient->GetShape( aGeomEngine, theGeomObject );
} }

View File

@ -72,6 +72,7 @@
#include <TColStd_MapOfInteger.hxx> #include <TColStd_MapOfInteger.hxx>
#include <TopExp.hxx> #include <TopExp.hxx>
#include <TopExp_Explorer.hxx> #include <TopExp_Explorer.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx> #include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopTools_MapOfShape.hxx> #include <TopTools_MapOfShape.hxx>
#include <TopoDS_Compound.hxx> #include <TopoDS_Compound.hxx>
@ -255,6 +256,47 @@ GEOM::GEOM_Object_ptr SMESH_Mesh_i::GetShapeToMesh()
return aShapeObj._retn(); return aShapeObj._retn();
} }
//================================================================================
/*!
* \brief Replaces a shape in the mesh
*/
//================================================================================
void SMESH_Mesh_i::ReplaceShape(GEOM::GEOM_Object_ptr theNewGeom)
throw (SALOME::SALOME_Exception)
{
TopoDS_Shape S = _impl->GetShapeToMesh();
GEOM_Client* geomClient = _gen_i->GetShapeReader();
TCollection_AsciiString aIOR;
if (geomClient->Find(S, aIOR)) {
geomClient->RemoveShapeFromBuffer(aIOR);
}
// update the reference to theNewGeom (needed for correct execution of a dumped python script)
SMESH::SMESH_Mesh_var me = _this();
SALOMEDS::SObject_wrap aSO = _gen_i->ObjectToSObject( me );
CORBA::String_var entry = theNewGeom->GetStudyEntry();
if ( !aSO->_is_nil() )
{
SALOMEDS::SObject_wrap aShapeRefSO;
if ( aSO->FindSubObject( _gen_i->GetRefOnShapeTag(), aShapeRefSO.inout() ))
{
SALOMEDS::SObject_wrap aShapeSO = _gen_i->getStudyServant()->FindObjectID( entry );
SALOMEDS::StudyBuilder_var builder = _gen_i->getStudyServant()->NewBuilder();
builder->Addreference( aShapeRefSO, aShapeSO );
}
}
// re-assign global hypotheses to the new shape
_mainShapeTick = -1;
CheckGeomModif( true );
TPythonDump() << "SHAPERSTUDY.breakLinkForSubElements(salome.ObjectToSObject("
<< me <<".GetMesh()), " << entry.in() << ")";
TPythonDump() << me << ".ReplaceShape( " << entry.in() << " )";
}
//================================================================================ //================================================================================
/*! /*!
* \brief Return false if the mesh is not yet fully loaded from the study file * \brief Return false if the mesh is not yet fully loaded from the study file
@ -1986,9 +2028,8 @@ void SMESH_Mesh_i::addGeomGroupData(GEOM::GEOM_Object_ptr theGeomObj,
if ( groupSO->_is_nil() ) if ( groupSO->_is_nil() )
return; return;
// group indices // group indices
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine(); GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine( theGeomObj );
GEOM::GEOM_IGroupOperations_wrap groupOp = GEOM::GEOM_IGroupOperations_ptr groupOp = geomGen->GetIGroupOperations();
geomGen->GetIGroupOperations();
GEOM::ListOfLong_var ids = groupOp->GetObjects( theGeomObj ); GEOM::ListOfLong_var ids = groupOp->GetObjects( theGeomObj );
// store data // store data
@ -2030,11 +2071,29 @@ void SMESH_Mesh_i::removeGeomGroupData(CORBA::Object_ptr theSmeshObj)
* \brief Return new group contents if it has been changed and update group data * \brief Return new group contents if it has been changed and update group data
*/ */
//================================================================================ //================================================================================
enum { ONLY_IF_CHANGED, IS_BREAK_LINK, MAIN_TRANSFORMED };
TopoDS_Shape SMESH_Mesh_i::newGroupShape( TGeomGroupData & groupData) TopoDS_Shape SMESH_Mesh_i::newGroupShape( TGeomGroupData & groupData, int how )
{ {
TopoDS_Shape newShape; TopoDS_Shape newShape;
if ( how == IS_BREAK_LINK )
{
SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( groupData._smeshObject );
SALOMEDS::SObject_wrap geomRefSO, geomSO;
if ( !meshSO->_is_nil() &&
meshSO->FindSubObject( SMESH::Tag_RefOnShape, geomRefSO.inout() ) &&
geomRefSO->ReferencedObject( geomSO.inout() ))
{
CORBA::Object_var geomObj = _gen_i->SObjectToObject( geomSO );
GEOM::GEOM_Object_var geom = GEOM::GEOM_Object::_narrow( geomObj );
newShape = _gen_i->GeomObjectToShape( geom );
CORBA::String_var entry = geom->GetStudyEntry();
groupData._groupEntry = entry.in();
}
}
else
{
// get geom group // get geom group
SALOMEDS::SObject_wrap groupSO = SMESH_Gen_i::getStudyServant()->FindObjectID( groupData._groupEntry.c_str() ); SALOMEDS::SObject_wrap groupSO = SMESH_Gen_i::getStudyServant()->FindObjectID( groupData._groupEntry.c_str() );
if ( !groupSO->_is_nil() ) if ( !groupSO->_is_nil() )
@ -2045,14 +2104,13 @@ TopoDS_Shape SMESH_Mesh_i::newGroupShape( TGeomGroupData & groupData)
// get indices of group items // get indices of group items
set<int> curIndices; set<int> curIndices;
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine(); GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine( geomGroup );
GEOM::GEOM_IGroupOperations_wrap groupOp = GEOM::GEOM_IGroupOperations_ptr groupOp = geomGen->GetIGroupOperations();
geomGen->GetIGroupOperations();
GEOM::ListOfLong_var ids = groupOp->GetObjects( geomGroup ); GEOM::ListOfLong_var ids = groupOp->GetObjects( geomGroup );
for ( CORBA::ULong i = 0; i < ids->length(); ++i ) for ( CORBA::ULong i = 0; i < ids->length(); ++i )
curIndices.insert( ids[i] ); curIndices.insert( ids[i] );
if ( groupData._indices == curIndices ) if ( how == ONLY_IF_CHANGED && groupData._indices == curIndices )
return newShape; // group not changed return newShape; // group not changed
// update data // update data
@ -2064,7 +2122,7 @@ TopoDS_Shape SMESH_Mesh_i::newGroupShape( TGeomGroupData & groupData)
geomClient->RemoveShapeFromBuffer( groupIOR.in() ); geomClient->RemoveShapeFromBuffer( groupIOR.in() );
newShape = _gen_i->GeomObjectToShape( geomGroup ); newShape = _gen_i->GeomObjectToShape( geomGroup );
} }
}
if ( newShape.IsNull() ) { if ( newShape.IsNull() ) {
// geom group becomes empty - return empty compound // geom group becomes empty - return empty compound
TopoDS_Compound compound; TopoDS_Compound compound;
@ -2163,11 +2221,13 @@ namespace
*/ */
//============================================================================= //=============================================================================
void SMESH_Mesh_i::CheckGeomModif() void SMESH_Mesh_i::CheckGeomModif( bool isBreakLink )
{ {
SMESH::SMESH_Mesh_var me = _this(); SMESH::SMESH_Mesh_var me = _this();
GEOM::GEOM_Object_var mainGO = GetShapeToMesh(); GEOM::GEOM_Object_var mainGO = GetShapeToMesh();
TPythonDump dumpNothing; // prevent any dump
//bool removedFromClient = false; //bool removedFromClient = false;
if ( mainGO->_is_nil() ) // GEOM_Client cleared or geometry removed? (IPAL52735, PAL23636) if ( mainGO->_is_nil() ) // GEOM_Client cleared or geometry removed? (IPAL52735, PAL23636)
@ -2229,19 +2289,24 @@ void SMESH_Mesh_i::CheckGeomModif()
return; return;
} }
// Update after shape transformation like Translate // Update after shape modification
GEOM_Client* geomClient = _gen_i->GetShapeReader(); GEOM_Client* geomClient = _gen_i->GetShapeReader();
if ( !geomClient ) return; if ( !geomClient ) return;
GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine(); GEOM::GEOM_Gen_var geomGen = _gen_i->GetGeomEngine( mainGO );
if ( geomGen->_is_nil() ) return; if ( geomGen->_is_nil() ) return;
CORBA::String_var ior = geomGen->GetStringFromIOR( mainGO ); CORBA::String_var ior = geomGen->GetStringFromIOR( mainGO );
geomClient->RemoveShapeFromBuffer( ior.in() ); geomClient->RemoveShapeFromBuffer( ior.in() );
// Update data taking into account that // Update data taking into account that if topology doesn't change
// all sub-shapes change but IDs of sub-shapes remain (except for geom groups) // all sub-shapes change but IDs of sub-shapes remain (except for geom groups)
if ( _preMeshInfo )
_preMeshInfo->ForgetAllData();
if (isBreakLink)
_impl->Clear(); _impl->Clear();
TopoDS_Shape newShape = _gen_i->GeomObjectToShape( mainGO ); TopoDS_Shape newShape = _gen_i->GeomObjectToShape( mainGO );
if ( newShape.IsNull() ) if ( newShape.IsNull() )
@ -2255,6 +2320,7 @@ void SMESH_Mesh_i::CheckGeomModif()
std::vector< TGroupOnGeomData > groupsData; std::vector< TGroupOnGeomData > groupsData;
const std::set<SMESHDS_GroupBase*>& groups = meshDS->GetGroups(); const std::set<SMESHDS_GroupBase*>& groups = meshDS->GetGroups();
groupsData.reserve( groups.size() ); groupsData.reserve( groups.size() );
TopTools_DataMapOfShapeShape old2newShapeMap;
std::set<SMESHDS_GroupBase*>::const_iterator g = groups.begin(); std::set<SMESHDS_GroupBase*>::const_iterator g = groups.begin();
for ( ; g != groups.end(); ++g ) for ( ; g != groups.end(); ++g )
{ {
@ -2270,12 +2336,34 @@ void SMESH_Mesh_i::CheckGeomModif()
GEOM::GEOM_Object_var geom; GEOM::GEOM_Object_var geom;
if ( !gog->_is_nil() ) if ( !gog->_is_nil() )
{
if ( isBreakLink )
{
SALOMEDS::SObject_wrap grpSO = _gen_i->ObjectToSObject( gog );
SALOMEDS::SObject_wrap geomRefSO, geomSO;
if ( !grpSO->_is_nil() &&
grpSO->FindSubObject( SMESH::Tag_RefOnShape, geomRefSO.inout() ) &&
geomRefSO->ReferencedObject( geomSO.inout() ))
{
CORBA::Object_var geomObj = _gen_i->SObjectToObject( geomSO );
geom = GEOM::GEOM_Object::_narrow( geomObj );
}
}
else
{
geom = gog->GetShape(); geom = gog->GetShape();
}
}
if ( !geom->_is_nil() ) if ( !geom->_is_nil() )
{ {
CORBA::String_var ior = geomGen->GetStringFromIOR( geom ); CORBA::String_var ior = geomGen->GetStringFromIOR( geom );
geomClient->RemoveShapeFromBuffer( ior.in() ); geomClient->RemoveShapeFromBuffer( ior.in() );
groupsData.back()._shape = _gen_i->GeomObjectToShape( geom ); groupsData.back()._shape = _gen_i->GeomObjectToShape( geom );
old2newShapeMap.Bind( group->GetShape(), groupsData.back()._shape );
}
else if ( old2newShapeMap.IsBound( group->GetShape() ))
{
groupsData.back()._shape = old2newShapeMap( group->GetShape() );
} }
} }
} }
@ -2289,16 +2377,50 @@ void SMESH_Mesh_i::CheckGeomModif()
ids2Hyps.push_back( make_pair( meshDS->ShapeToIndex( s ), hyps )); ids2Hyps.push_back( make_pair( meshDS->ShapeToIndex( s ), hyps ));
} }
// change shape to mesh std::map< std::set<int>, int > ii2iMap; // group sub-ids to group id in SMESHDS
// count shapes excluding compounds corresponding to geom groups
int oldNbSubShapes = meshDS->MaxShapeIndex(); int oldNbSubShapes = meshDS->MaxShapeIndex();
for ( ; oldNbSubShapes > 0; --oldNbSubShapes )
{
const TopoDS_Shape& s = meshDS->IndexToShape( oldNbSubShapes );
if ( s.IsNull() || s.ShapeType() != TopAbs_COMPOUND )
break;
// fill ii2iMap
std::set<int> subIds;
for ( TopoDS_Iterator it( s ); it.More(); it.Next() )
subIds.insert( meshDS->ShapeToIndex( it.Value() ));
ii2iMap.insert( std::make_pair( subIds, oldNbSubShapes ));
}
// check if shape topology changes - save shape type per shape ID
std::vector< TopAbs_ShapeEnum > shapeTypes( Max( oldNbSubShapes + 1, 1 ));
for ( int shapeID = oldNbSubShapes; shapeID > 0; --shapeID )
shapeTypes[ shapeID ] = meshDS->IndexToShape( shapeID ).ShapeType();
// change shape to mesh
_impl->ShapeToMesh( TopoDS_Shape() ); _impl->ShapeToMesh( TopoDS_Shape() );
_impl->ShapeToMesh( newShape ); _impl->ShapeToMesh( newShape );
// re-add shapes of geom groups // check if shape topology changes - check new shape types
bool sameTopology = ( oldNbSubShapes == meshDS->MaxShapeIndex() );
for ( int shapeID = oldNbSubShapes; shapeID > 0 && sameTopology; --shapeID )
{
const TopoDS_Shape& s = meshDS->IndexToShape( shapeID );
sameTopology = ( !s.IsNull() && s.ShapeType() == shapeTypes[ shapeID ]);
}
// re-add shapes (compounds) of geom groups
std::map< int, int > old2newIDs; // group IDs
std::list<TGeomGroupData>::iterator data = _geomGroupData.begin(); std::list<TGeomGroupData>::iterator data = _geomGroupData.begin();
for ( ; data != _geomGroupData.end(); ++data ) for ( ; data != _geomGroupData.end(); ++data )
{ {
TopoDS_Shape newShape = newGroupShape( *data ); int oldID = 0;
std::map< std::set<int>, int >::iterator ii2i = ii2iMap.find( data->_indices );
if ( ii2i != ii2iMap.end() )
oldID = ii2i->second;
TopoDS_Shape newShape = newGroupShape( *data, isBreakLink ? IS_BREAK_LINK : MAIN_TRANSFORMED );
if ( !newShape.IsNull() ) if ( !newShape.IsNull() )
{ {
if ( meshDS->ShapeToIndex( newShape ) > 0 ) // a group reduced to one sub-shape if ( meshDS->ShapeToIndex( newShape ) > 0 ) // a group reduced to one sub-shape
@ -2308,23 +2430,35 @@ void SMESH_Mesh_i::CheckGeomModif()
BRep_Builder().Add( compound, newShape ); BRep_Builder().Add( compound, newShape );
newShape = compound; newShape = compound;
} }
_impl->GetSubMesh( newShape ); int newID = _impl->GetSubMesh( newShape )->GetId();
if ( oldID && oldID != newID )
old2newIDs.insert( std::make_pair( oldID, newID ));
} }
} }
if ( oldNbSubShapes != meshDS->MaxShapeIndex() )
THROW_SALOME_CORBA_EXCEPTION( "SMESH_Mesh_i::CheckGeomModif() bug",
SALOME::INTERNAL_ERROR );
// re-assign hypotheses // re-assign hypotheses
for ( size_t i = 0; i < ids2Hyps.size(); ++i ) for ( size_t i = 0; i < ids2Hyps.size(); ++i )
{ {
const TopoDS_Shape& s = meshDS->IndexToShape( ids2Hyps[i].first ); if ( !sameTopology && ids2Hyps[i].first != 1 )
continue; // assign only global hypos
int sID = ids2Hyps[i].first;
std::map< int, int >::iterator o2n = old2newIDs.find( sID );
if ( o2n != old2newIDs.end() )
sID = o2n->second;
const TopoDS_Shape& s = meshDS->IndexToShape( sID );
const THypList& hyps = ids2Hyps[i].second; const THypList& hyps = ids2Hyps[i].second;
THypList::const_iterator h = hyps.begin(); THypList::const_iterator h = hyps.begin();
for ( ; h != hyps.end(); ++h ) for ( ; h != hyps.end(); ++h )
_impl->AddHypothesis( s, (*h)->GetID() ); _impl->AddHypothesis( s, (*h)->GetID() );
} }
if ( !sameTopology )
{
// remove invalid study sub-objects
CheckGeomGroupModif();
}
else
{
// restore groups on geometry // restore groups on geometry
for ( size_t i = 0; i < groupsData.size(); ++i ) for ( size_t i = 0; i < groupsData.size(); ++i )
{ {
@ -2345,11 +2479,39 @@ void SMESH_Mesh_i::CheckGeomModif()
g->GetGroupDS()->SetColor( data._color ); g->GetGroupDS()->SetColor( data._color );
} }
std::map< int, int >::iterator o2n = old2newIDs.begin();
for ( ; o2n != old2newIDs.end(); ++o2n )
{
int newID = o2n->second, oldID = o2n->first;
if ( !_mapSubMesh.count( oldID ))
continue;
if ( newID > 0 )
{
_mapSubMesh [ newID ] = _impl->GetSubMeshContaining( newID );
_mapSubMesh_i [ newID ] = _mapSubMesh_i [ oldID ];
_mapSubMeshIor[ newID ] = _mapSubMeshIor[ oldID ];
}
_mapSubMesh. erase(oldID);
_mapSubMesh_i. erase(oldID);
_mapSubMeshIor.erase(oldID);
if ( newID > 0 )
_mapSubMesh_i [ newID ]->changeLocalId( newID );
}
// update _mapSubMesh // update _mapSubMesh
std::map<int, ::SMESH_subMesh*>::iterator i_sm = _mapSubMesh.begin(); std::map<int, ::SMESH_subMesh*>::iterator i_sm = _mapSubMesh.begin();
for ( ; i_sm != _mapSubMesh.end(); ++i_sm ) for ( ; i_sm != _mapSubMesh.end(); ++i_sm )
i_sm->second = _impl->GetSubMesh( meshDS->IndexToShape( i_sm->first )); i_sm->second = _impl->GetSubMesh( meshDS->IndexToShape( i_sm->first ));
}
_gen_i->UpdateIcons( me );
if ( !isBreakLink )
{
SALOMEDS::SObject_wrap meshSO = _gen_i->ObjectToSObject( me );
if ( !meshSO->_is_nil() )
_gen_i->SetPixMap(meshSO, "ICON_SMESH_TREE_GEOM_MODIF");
}
} }
//============================================================================= //=============================================================================
@ -2473,7 +2635,7 @@ void SMESH_Mesh_i::CheckGeomGroupModif()
bool processedGroup = !it_new.second; bool processedGroup = !it_new.second;
TopoDS_Shape& newShape = it_new.first->second; TopoDS_Shape& newShape = it_new.first->second;
if ( !processedGroup ) if ( !processedGroup )
newShape = newGroupShape( *data ); newShape = newGroupShape( *data, ONLY_IF_CHANGED );
if ( newShape.IsNull() ) if ( newShape.IsNull() )
continue; // no changes continue; // no changes

View File

@ -74,6 +74,9 @@ public:
GEOM::GEOM_Object_ptr GetShapeToMesh() GEOM::GEOM_Object_ptr GetShapeToMesh()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
virtual void ReplaceShape(GEOM::GEOM_Object_ptr theNewGeom)
throw (SALOME::SALOME_Exception);
CORBA::Boolean IsLoaded() CORBA::Boolean IsLoaded()
throw (SALOME::SALOME_Exception); throw (SALOME::SALOME_Exception);
@ -460,7 +463,7 @@ public:
* *
* Issue 0022501 * Issue 0022501
*/ */
void CheckGeomModif(); void CheckGeomModif( bool isBreakLink = false );
/*! /*!
* \brief Update hypotheses assigned to geom groups if the latter change * \brief Update hypotheses assigned to geom groups if the latter change
* *
@ -618,6 +621,12 @@ public:
std::string FileInfoToString(); std::string FileInfoToString();
void FileInfoFromString(const std::string& info); void FileInfoFromString(const std::string& info);
/*!
* Persistence of geometry tick
*/
int& MainShapeTick() { return _mainShapeTick; }
/*! /*!
* Sets list of notebook variables used for Mesh operations separated by ":" symbol * Sets list of notebook variables used for Mesh operations separated by ":" symbol
*/ */
@ -765,7 +774,7 @@ private:
/*! /*!
* Return new group contents if it has been changed and update group data * Return new group contents if it has been changed and update group data
*/ */
TopoDS_Shape newGroupShape( TGeomGroupData & groupData); TopoDS_Shape newGroupShape( TGeomGroupData & groupData, int how );
}; };

View File

@ -1061,12 +1061,15 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
isHistoricalDump ); isHistoricalDump );
bool importGeom = false; bool importGeom = false;
GEOM::GEOM_Gen_ptr geom = GetGeomEngine(); GEOM::GEOM_Gen_ptr geom[2];
for ( int isShaper = 0; isShaper < 2; ++isShaper )
{ {
geom[ isShaper ] = GetGeomEngine( isShaper );
if ( CORBA::is_nil( geom[ isShaper ]))
continue;
// Add names of GEOM objects to theObjectNames to exclude same names of SMESH objects // Add names of GEOM objects to theObjectNames to exclude same names of SMESH objects
GEOM::string_array_var aGeomNames = geom->GetAllDumpNames(); GEOM::string_array_var aGeomNames = geom[ isShaper ]->GetAllDumpNames();
int ign = 0, nbgn = aGeomNames->length(); for ( CORBA::ULong ign = 0; ign < aGeomNames->length(); ign++) {
for (; ign < nbgn; ign++) {
TCollection_AsciiString aName = aGeomNames[ign].in(); TCollection_AsciiString aName = aGeomNames[ign].in();
theObjectNames.Bind(aName, "1"); theObjectNames.Bind(aName, "1");
} }
@ -1100,7 +1103,11 @@ TCollection_AsciiString SMESH_Gen_i::DumpPython_impl
anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry anUpdatedScript += aLine.SubString( aStart, aSeq->Value(i) - 1 ); // line part before i-th entry
anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) ); anEntry = aLine.SubString( aSeq->Value(i), aSeq->Value(i + 1) );
// is a GEOM object? // is a GEOM object?
CORBA::String_var geomName = geom->GetDumpName( anEntry.ToCString() ); CORBA::String_var geomName;
if ( !CORBA::is_nil( geom[0] ))
geomName = geom[0]->GetDumpName( anEntry.ToCString() );
if (( !geomName.in() || !geomName.in()[0] ) && !CORBA::is_nil( geom[1] ))
geomName = geom[1]->GetDumpName( anEntry.ToCString() );
if ( !geomName.in() || !geomName.in()[0] ) { if ( !geomName.in() || !geomName.in()[0] ) {
// is a SMESH object // is a SMESH object
if ( theObjectNames.IsBound( anEntry )) { if ( theObjectNames.IsBound( anEntry )) {

View File

@ -123,6 +123,7 @@ protected:
void changeLocalId(int localId) { _localId = localId; } void changeLocalId(int localId) { _localId = localId; }
friend void SMESH_Mesh_i::CheckGeomGroupModif(); friend void SMESH_Mesh_i::CheckGeomGroupModif();
friend void SMESH_Mesh_i::CheckGeomModif(bool);
SMESH_PreMeshInfo* _preMeshInfo; // mesh info before full loading from study file SMESH_PreMeshInfo* _preMeshInfo; // mesh info before full loading from study file

View File

@ -305,7 +305,7 @@ def AssureGeomPublished(mesh, geom, name=''):
""" """
if not mesh.smeshpyD.IsEnablePublish(): if not mesh.smeshpyD.IsEnablePublish():
return return
if not isinstance( geom, geomBuilder.GEOM._objref_GEOM_Object ): if not hasattr( geom, "GetShapeType" ):
return return
if not geom.GetStudyEntry(): if not geom.GetStudyEntry():
## get a name ## get a name
@ -318,27 +318,13 @@ def AssureGeomPublished(mesh, geom, name=''):
mesh.geompyD.addToStudyInFather( mesh.geom, geom, name ) mesh.geompyD.addToStudyInFather( mesh.geom, geom, name )
return return
def FirstVertexOnCurve(mesh, edge): # def FirstVertexOnCurve(mesh, edge):
""" # """
Returns: # Returns:
the first vertex of a geometrical edge by ignoring orientation # the first vertex of a geometrical edge by ignoring orientation
""" # """
vv = mesh.geompyD.SubShapeAll( edge, geomBuilder.geomBuilder.ShapeType["VERTEX"]) # return mesh.geompyD.GetVertexByIndex( edge, 0, False )
if not vv:
raise TypeError("Given object has no vertices")
if len( vv ) == 1: return vv[0]
v0 = mesh.geompyD.MakeVertexOnCurve(edge,0.)
xyz = mesh.geompyD.PointCoordinates( v0 ) # coords of the first vertex
xyz1 = mesh.geompyD.PointCoordinates( vv[0] )
xyz2 = mesh.geompyD.PointCoordinates( vv[1] )
dist1, dist2 = 0,0
for i in range(3):
dist1 += abs( xyz[i] - xyz1[i] )
dist2 += abs( xyz[i] - xyz2[i] )
if dist1 < dist2:
return vv[0]
else:
return vv[1]
smeshInst = None smeshInst = None
""" """
@ -531,8 +517,8 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
Returns: Returns:
:class:`SMESH.PointStruct` :class:`SMESH.PointStruct`
""" """
geompyD = theVertex.GetGen()
[x, y, z] = self.geompyD.PointCoordinates(theVertex) [x, y, z] = geompyD.PointCoordinates(theVertex)
return PointStruct(x,y,z) return PointStruct(x,y,z)
def GetDirStruct(self,theVector): def GetDirStruct(self,theVector):
@ -545,13 +531,13 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
Returns: Returns:
:class:`SMESH.DirStruct` :class:`SMESH.DirStruct`
""" """
geompyD = theVector.GetGen()
vertices = self.geompyD.SubShapeAll( theVector, geomBuilder.geomBuilder.ShapeType["VERTEX"] ) vertices = geompyD.SubShapeAll( theVector, geomBuilder.geomBuilder.ShapeType["VERTEX"] )
if(len(vertices) != 2): if(len(vertices) != 2):
print("Error: vector object is incorrect.") print("Error: vector object is incorrect.")
return None return None
p1 = self.geompyD.PointCoordinates(vertices[0]) p1 = geompyD.PointCoordinates(vertices[0])
p2 = self.geompyD.PointCoordinates(vertices[1]) p2 = geompyD.PointCoordinates(vertices[1])
pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]) pnt = PointStruct(p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
dirst = DirStruct(pnt) dirst = DirStruct(pnt)
return dirst return dirst
@ -581,28 +567,29 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
:class:`SMESH.AxisStruct` :class:`SMESH.AxisStruct`
""" """
import GEOM import GEOM
edges = self.geompyD.SubShapeAll( theObj, geomBuilder.geomBuilder.ShapeType["EDGE"] ) geompyD = theObj.GetGen()
edges = geompyD.SubShapeAll( theObj, geomBuilder.geomBuilder.ShapeType["EDGE"] )
axis = None axis = None
if len(edges) > 1: if len(edges) > 1:
vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geomBuilder.geomBuilder.ShapeType["VERTEX"] ) vertex1, vertex2 = geompyD.SubShapeAll( edges[0], geomBuilder.geomBuilder.ShapeType["VERTEX"] )
vertex3, vertex4 = self.geompyD.SubShapeAll( edges[1], geomBuilder.geomBuilder.ShapeType["VERTEX"] ) vertex3, vertex4 = geompyD.SubShapeAll( edges[1], geomBuilder.geomBuilder.ShapeType["VERTEX"] )
vertex1 = self.geompyD.PointCoordinates(vertex1) vertex1 = geompyD.PointCoordinates(vertex1)
vertex2 = self.geompyD.PointCoordinates(vertex2) vertex2 = geompyD.PointCoordinates(vertex2)
vertex3 = self.geompyD.PointCoordinates(vertex3) vertex3 = geompyD.PointCoordinates(vertex3)
vertex4 = self.geompyD.PointCoordinates(vertex4) vertex4 = geompyD.PointCoordinates(vertex4)
v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]] v1 = [vertex2[0]-vertex1[0], vertex2[1]-vertex1[1], vertex2[2]-vertex1[2]]
v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]] v2 = [vertex4[0]-vertex3[0], vertex4[1]-vertex3[1], vertex4[2]-vertex3[2]]
normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ] normal = [ v1[1]*v2[2]-v2[1]*v1[2], v1[2]*v2[0]-v2[2]*v1[0], v1[0]*v2[1]-v2[0]*v1[1] ]
axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2]) axis = AxisStruct(vertex1[0], vertex1[1], vertex1[2], normal[0], normal[1], normal[2])
axis._mirrorType = SMESH.SMESH_MeshEditor.PLANE axis._mirrorType = SMESH.SMESH_MeshEditor.PLANE
elif len(edges) == 1: elif len(edges) == 1:
vertex1, vertex2 = self.geompyD.SubShapeAll( edges[0], geomBuilder.geomBuilder.ShapeType["VERTEX"] ) vertex1, vertex2 = geompyD.SubShapeAll( edges[0], geomBuilder.geomBuilder.ShapeType["VERTEX"] )
p1 = self.geompyD.PointCoordinates( vertex1 ) p1 = geompyD.PointCoordinates( vertex1 )
p2 = self.geompyD.PointCoordinates( vertex2 ) p2 = geompyD.PointCoordinates( vertex2 )
axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2]) axis = AxisStruct(p1[0], p1[1], p1[2], p2[0]-p1[0], p2[1]-p1[1], p2[2]-p1[2])
axis._mirrorType = SMESH.SMESH_MeshEditor.AXIS axis._mirrorType = SMESH.SMESH_MeshEditor.AXIS
elif theObj.GetShapeType() == GEOM.VERTEX: elif theObj.GetShapeType() == GEOM.VERTEX:
x,y,z = self.geompyD.PointCoordinates( theObj ) x,y,z = geompyD.PointCoordinates( theObj )
axis = AxisStruct( x,y,z, 1,0,0,) axis = AxisStruct( x,y,z, 1,0,0,)
axis._mirrorType = SMESH.SMESH_MeshEditor.POINT axis._mirrorType = SMESH.SMESH_MeshEditor.POINT
return axis return axis
@ -972,7 +959,8 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
name = aCriterion.ThresholdStr name = aCriterion.ThresholdStr
if not name: if not name:
name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000) name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000)
aCriterion.ThresholdID = self.geompyD.addToStudy( aThreshold, name ) geompyD = aThreshold.GetGen()
aCriterion.ThresholdID = geompyD.addToStudy( aThreshold, name )
# or a name of GEOM object # or a name of GEOM object
elif isinstance( aThreshold, str ): elif isinstance( aThreshold, str ):
aCriterion.ThresholdStr = aThreshold aCriterion.ThresholdStr = aThreshold
@ -1023,7 +1011,8 @@ class smeshBuilder( SMESH._objref_SMESH_Gen, object ):
name = aThreshold.GetName() name = aThreshold.GetName()
if not name: if not name:
name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000) name = "%s_%s"%(aThreshold.GetShapeType(), id(aThreshold)%10000)
aCriterion.ThresholdID = self.geompyD.addToStudy( aThreshold, name ) geompyD = aThreshold.GetGen()
aCriterion.ThresholdID = geompyD.addToStudy( aThreshold, name )
elif isinstance(aThreshold, int): # node id elif isinstance(aThreshold, int): # node id
aCriterion.Threshold = aThreshold aCriterion.Threshold = aThreshold
elif isinstance(aThreshold, list): # 3 point coordinates elif isinstance(aThreshold, list): # 3 point coordinates
@ -1654,14 +1643,15 @@ class Mesh(metaclass = MeshMeta):
Parameters: Parameters:
theMesh: a :class:`SMESH.SMESH_Mesh` object theMesh: a :class:`SMESH.SMESH_Mesh` object
""" """
# do not call Register() as this prevents mesh servant deletion at closing study # do not call Register() as this prevents mesh servant deletion at closing study
#if self.mesh: self.mesh.UnRegister() #if self.mesh: self.mesh.UnRegister()
self.mesh = theMesh self.mesh = theMesh
if self.mesh: if self.mesh:
#self.mesh.Register() #self.mesh.Register()
self.geom = self.mesh.GetShapeToMesh() self.geom = self.mesh.GetShapeToMesh()
if self.geom:
self.geompyD = self.geom.GetGen()
pass
pass pass
def GetMesh(self): def GetMesh(self):

View File

@ -413,12 +413,11 @@ class Mesh_Algorithm:
into a list acceptable to SetReversedEdges() of some 1D hypotheses into a list acceptable to SetReversedEdges() of some 1D hypotheses
""" """
from salome.smesh.smeshBuilder import FirstVertexOnCurve
resList = [] resList = []
geompy = self.mesh.geompyD geompy = self.mesh.geompyD
for i in reverseList: for i in reverseList:
if isinstance( i, int ): if isinstance( i, int ):
s = geompy.SubShapes(self.mesh.geom, [i])[0] s = geompy.GetSubShape(self.mesh.geom, [i])
if s.GetShapeType() != geomBuilder.GEOM.EDGE: if s.GetShapeType() != geomBuilder.GEOM.EDGE:
raise TypeError("Not EDGE index given") raise TypeError("Not EDGE index given")
resList.append( i ) resList.append( i )
@ -438,7 +437,7 @@ class Mesh_Algorithm:
if e.GetShapeType() != geomBuilder.GEOM.EDGE or \ if e.GetShapeType() != geomBuilder.GEOM.EDGE or \
v.GetShapeType() != geomBuilder.GEOM.VERTEX: v.GetShapeType() != geomBuilder.GEOM.VERTEX:
raise TypeError("A list item must be a tuple (edge, 1st_vertex_of_edge)") raise TypeError("A list item must be a tuple (edge, 1st_vertex_of_edge)")
vFirst = FirstVertexOnCurve( self.mesh, e ) vFirst = geompy.GetVertexByIndex( e, 0, False )
tol = geompy.Tolerance( vFirst )[-1] tol = geompy.Tolerance( vFirst )[-1]
if geompy.MinDistance( v, vFirst ) > 1.5*tol: if geompy.MinDistance( v, vFirst ) > 1.5*tol:
resList.append( geompy.GetSubShapeID(self.mesh.geom, e )) resList.append( geompy.GetSubShapeID(self.mesh.geom, e ))

View File

@ -464,7 +464,7 @@ bool StdMeshersGUI_StdHypothesisCreator::checkParams( QString& msg ) const
// then the FACE must have only one VERTEX // then the FACE must have only one VERTEX
GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >(); GEOM::GEOM_Object_var face = w->GetObject< GEOM::GEOM_Object >();
GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( face );
_PTR(Study) aStudy = SMESH::getStudy(); _PTR(Study) aStudy = SMESH::getStudy();
GEOM::GEOM_IShapesOperations_wrap shapeOp; GEOM::GEOM_IShapesOperations_wrap shapeOp;
if ( !geomGen->_is_nil() && aStudy ) if ( !geomGen->_is_nil() && aStudy )