From b0a962d83d6318f800df0cf9a21fdda9baed80ad Mon Sep 17 00:00:00 2001 From: eap Date: Tue, 31 Mar 2015 19:42:12 +0300 Subject: [PATCH] 22573: [CEA 1154] Regression on a blsurf mesh (crash on test_periodicity_LR_ONLY.py) + IMP 22264: EDF 2648 GEOM: Propagate edges automatic orientation (fix Number of Segments dlg) + bad STL files are written on Windows (reported by YFR) + 22874: [CEA 1425] Performance SMESH Module ( refix ~SMESH_Mesh() ) --- src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx | 8 +-- src/SMESH/SMESH_Mesh.cxx | 20 ++----- src/SMESH/SMESH_subMesh.cxx | 4 +- src/SMESH_I/SMESH_MeshEditor_i.cxx | 2 - .../StdMeshersGUI_NbSegmentsCreator.cxx | 14 +++-- .../StdMeshersGUI_NbSegmentsCreator.h | 3 +- .../StdMeshersGUI_PropagationHelperWdg.cxx | 57 ++++++++++++++----- .../StdMeshersGUI_PropagationHelperWdg.h | 15 +++-- 8 files changed, 75 insertions(+), 48 deletions(-) diff --git a/src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx b/src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx index 8ddbfd0dd..78a068e57 100644 --- a/src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx +++ b/src/DriverSTL/DriverSTL_W_SMDS_Mesh.cxx @@ -305,7 +305,7 @@ Driver_Mesh::Status DriverSTL_W_SMDS_Mesh::writeAscii() const { const SMDS_MeshElement* aFace = itFaces->next(); int nbTria = getTriangles( aFace, triaNodes ); - + for ( int iT = 0, iN = 0; iT < nbTria; ++iT ) { gp_XYZ normale = getNormale( triaNodes[iN], @@ -315,7 +315,7 @@ Driver_Mesh::Status DriverSTL_W_SMDS_Mesh::writeAscii() const " facet normal % 12e % 12e % 12e\n" " outer loop\n" , normale.X(), normale.Y(), normale.Z()); - aFile.writeRaw ( sval, 70 ); + aFile.writeRaw ( sval, 70 + strlen( sval + 70 )); // at least 70 but can be more (WIN) for ( int jN = 0; jN < 3; ++jN, ++iN ) { @@ -323,11 +323,11 @@ Driver_Mesh::Status DriverSTL_W_SMDS_Mesh::writeAscii() const sprintf (sval, " vertex % 12e % 12e % 12e\n", node.X(), node.Y(), node.Z() ); - aFile.writeRaw ( sval, 54 ); + aFile.writeRaw ( sval, 54 + strlen( sval + 54 )); } aFile.writeRaw (" endloop\n" " endfacet\n", 21 ); - } + } } aFile.writeRaw ("endsolid\n" , 9 ); diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index aac87a540..24042d9da 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -181,22 +181,10 @@ SMESH_Mesh::~SMESH_Mesh() { MESSAGE("SMESH_Mesh::~SMESH_Mesh"); - // Unassign algorithms in order to have all SMESH_subMeshEventListenerData deleted (22874) + // avoid usual removal of elements while processing RemoveHypothesis( algo ) event SMESHDS_SubMeshIteratorPtr smIt = _myMeshDS->SubMeshes(); - while ( smIt->more() ) { - // avoid usual removal of elements while processing RemoveHypothesis( algo ) event + while ( smIt->more() ) const_cast( smIt->next() )->Clear(); - } - const ShapeToHypothesis & hyps = _myMeshDS->GetHypotheses(); - for ( ShapeToHypothesis::Iterator s2hyps( hyps ); s2hyps.More(); s2hyps.Next() ) - { - const TopoDS_Shape& s = s2hyps.Key(); - THypList hyps = s2hyps.ChangeValue(); // copy - THypList::const_iterator h = hyps.begin(); - for ( ; h != hyps.end(); ++h ) - if ( (*h)->GetType() != SMESHDS_Hypothesis::PARAM_ALGO ) - RemoveHypothesis( s, (*h)->GetID() ); - } // issue 0020340: EDF 1022 SMESH : Crash with FindNodeClosestTo in a second new study // Notify event listeners at least that something happens @@ -2276,8 +2264,8 @@ void SMESH_Mesh::fillAncestorsMap(const TopoDS_Shape& theShape) TopTools_ListIteratorOfListOfShape ancIt (ancList); while ( ancIt.More() && ancIt.Value().ShapeType() >= memberType ) ancIt.Next(); - if ( ancIt.More() ) - ancList.InsertBefore( theShape, ancIt ); + if ( ancIt.More() ) ancList.InsertBefore( theShape, ancIt ); + else ancList.Append( theShape ); } } else // else added for 52457: Addition of hypotheses is 8 time longer than meshing diff --git a/src/SMESH/SMESH_subMesh.cxx b/src/SMESH/SMESH_subMesh.cxx index a7b015260..6545ef40c 100644 --- a/src/SMESH/SMESH_subMesh.cxx +++ b/src/SMESH/SMESH_subMesh.cxx @@ -2469,7 +2469,9 @@ void SMESH_subMesh::deleteOwnListeners() { if ( !_father->MeshExists( d->myMeshID )) continue; - if ( _father->GetId() == d->myMeshID && !_father->GetSubMeshContaining( d->mySubMeshID )) + if ( _father->GetId() == d->myMeshID && + this->GetId() != d->mySubMeshID && + !_father->GetSubMeshContaining( d->mySubMeshID )) continue; d->mySubMesh->DeleteEventListener( d->myListener ); } diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index 519478d30..ec4cb02c6 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -114,8 +114,6 @@ namespace MeshEditor_I { _myMeshDS = new SMESHDS_Mesh( _id, true ); myPreviewType = previewElements; } - //!< Destructor - virtual ~TPreviewMesh() { delete _myMeshDS; _myMeshDS = 0; } //!< Copy a set of elements void Copy(const TIDSortedElemSet & theElements, TIDSortedElemSet& theCopyElements, diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx index ec15db30b..cfb80164e 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.cxx @@ -225,7 +225,7 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() if ( !aGeomEntry.isEmpty() || !aMainEntry.isEmpty() ) { - myReversedEdgesHelper = new StdMeshersGUI_PropagationHelperWdg( myDirectionWidget, fr ); + myReversedEdgesHelper = new StdMeshersGUI_PropagationHelperWdg( myDirectionWidget, fr, false ); lay->addWidget( myReversedEdgesHelper ); lay->setStretchFactor( myReversedEdgesHelper, 1 ); } @@ -236,6 +236,8 @@ QFrame* StdMeshersGUI_NbSegmentsCreator::buildFrame() connect( myExpr, SIGNAL( textChanged( const QString& ) ), this, SLOT( onValueChanged() ) ); connect( myConv, SIGNAL( buttonClicked( int ) ), this, SLOT( onValueChanged() ) ); + onValueChanged(); + return fr; } @@ -438,10 +440,12 @@ void StdMeshersGUI_NbSegmentsCreator::onValueChanged() myScale->setShown( distr==1 ); myLScale->setShown( distr==1 ); - myReversedEdgesBox->setShown( !distr==0 ); - myDirectionWidget->ShowPreview( !distr==0 ); - if ( myReversedEdgesHelper ) - myReversedEdgesHelper->setShown( !distr==0 ); + myReversedEdgesBox->setShown( distr!=0 ); + if ( myReversedEdgesHelper ) { + myReversedEdgesHelper->Clear(); + myReversedEdgesHelper->setShown( distr!=0 ); + } + myDirectionWidget->ShowPreview( distr!=0 ); bool isFunc = distr==2 || distr==3; myPreview->setShown( isFunc ); diff --git a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h index 61dc6047b..f39b2feb9 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h +++ b/src/StdMeshersGUI/StdMeshersGUI_NbSegmentsCreator.h @@ -46,6 +46,7 @@ class QGroupBox; class QGridLayout; class QRadioButton; class StdMeshersGUI_SubShapeSelectorWdg; +class StdMeshersGUI_PropagationHelperWdg; typedef struct { @@ -96,7 +97,7 @@ private: QGroupBox* myReversedEdgesBox; StdMeshersGUI_SubShapeSelectorWdg* myDirectionWidget; - QWidget* myReversedEdgesHelper; + StdMeshersGUI_PropagationHelperWdg* myReversedEdgesHelper; }; #endif // STDMESHERSGUI_NBSEGMENTSCREATOR_H diff --git a/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.cxx b/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.cxx index 1105299a9..9f9dbd002 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.cxx +++ b/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.cxx @@ -64,20 +64,21 @@ StdMeshersGUI_PropagationHelperWdg:: StdMeshersGUI_PropagationHelperWdg( StdMeshersGUI_SubShapeSelectorWdg* subSelectWdg, - QWidget* parent ): + QWidget* parent, + bool show ): QWidget( parent ), mySubSelectWdg( subSelectWdg ), myActor( 0 ), myModelActor( 0 ) { - QGroupBox* helperBox = new QGroupBox( tr("HELPER"), this ); - QCheckBox* showGeomChkBox = new QCheckBox( tr("SHOW_GEOMETRY"), helperBox ); - QGroupBox* chainBox = new QGroupBox( tr("PROPAGATION_CHAINS"), helperBox ); - chainBox->setCheckable( true ); - chainBox->setChecked( false ); - myListWidget = new QListWidget( helperBox ); + QGroupBox* helperBox = new QGroupBox( tr("HELPER"), this ); + myShowGeomChkBox = new QCheckBox( tr("SHOW_GEOMETRY"), helperBox ); + myChainBox = new QGroupBox( tr("PROPAGATION_CHAINS"), helperBox ); + myChainBox->setCheckable( true ); + myChainBox->setChecked( false ); + myListWidget = new QListWidget( helperBox ); myListWidget->setSelectionMode( QAbstractItemView::SingleSelection ); - myAddButton = new QPushButton( tr("ADD"), helperBox ); - myReverseButton = new QPushButton( tr("REVERSE"), helperBox ); + myAddButton = new QPushButton( tr("ADD"), helperBox ); + myReverseButton = new QPushButton( tr("REVERSE"), helperBox ); - QGridLayout* chainsLayout = new QGridLayout( chainBox ); + QGridLayout* chainsLayout = new QGridLayout( myChainBox ); chainsLayout->setMargin( MARGIN ); chainsLayout->setSpacing( SPACING ); chainsLayout->addWidget(myListWidget, 0, 0, 3, 3); @@ -87,21 +88,22 @@ StdMeshersGUI_PropagationHelperWdg( StdMeshersGUI_SubShapeSelectorWdg* subSelect QVBoxLayout* helperLayout = new QVBoxLayout( helperBox ); helperLayout->setMargin( MARGIN ); helperLayout->setSpacing( SPACING ); - helperLayout->addWidget( showGeomChkBox ); - helperLayout->addWidget( chainBox ); + helperLayout->addWidget( myShowGeomChkBox ); + helperLayout->addWidget( myChainBox ); QVBoxLayout* lay = new QVBoxLayout( this ); lay->setMargin( 0 ); lay->setSpacing( SPACING ); lay->addWidget( helperBox ); - connect( showGeomChkBox, SIGNAL( toggled(bool)), SLOT( onShowGeometry(bool))); - connect( chainBox, SIGNAL( toggled(bool)), SLOT( updateList(bool))); + connect( myShowGeomChkBox,SIGNAL( toggled(bool)), SLOT( onShowGeometry(bool))); + connect( myChainBox, SIGNAL( toggled(bool)), SLOT( updateList(bool))); connect( myListWidget, SIGNAL( itemSelectionChanged()), SLOT( onListSelectionChanged() )); connect( myAddButton, SIGNAL( clicked(bool)), SLOT( onAdd() )); connect( myReverseButton, SIGNAL( clicked(bool)), SLOT( onReverse() )); - onListSelectionChanged(); + if ( show ) + onListSelectionChanged(); } //================================================================================ @@ -126,6 +128,31 @@ StdMeshersGUI_PropagationHelperWdg::~StdMeshersGUI_PropagationHelperWdg() } } +//================================================================================ +/*! + * \brief Switch off all buttons and previews + */ +//================================================================================ + +void StdMeshersGUI_PropagationHelperWdg::Clear() +{ + myShowGeomChkBox->setChecked( false ); + + myListWidget->blockSignals( true ); + myListWidget->clear(); + myListWidget->blockSignals( false ); + + myChainBox->blockSignals( true ); + myChainBox->setChecked( false ); + myChainBox->blockSignals( false ); + + if ( myActor ) + myActor->SetVisibility( false ); + + if ( myModelActor ) + myModelActor->SetVisibility( false ); +} + //================================================================================ /*! * \brief SLOT called when 'Show Geometry' is checked diff --git a/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.h b/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.h index b0b5ad99b..241e4070d 100644 --- a/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.h +++ b/src/StdMeshersGUI/StdMeshersGUI_PropagationHelperWdg.h @@ -30,6 +30,8 @@ class QListWidget; class StdMeshersGUI_SubShapeSelectorWdg; class vtkRenderer; class GEOM_Actor; +class QCheckBox; +class QGroupBox; /*! * \brief A widget showing a list of propagation chains of EDGEs. @@ -43,9 +45,12 @@ class STDMESHERSGUI_EXPORT StdMeshersGUI_PropagationHelperWdg : public QWidget public: StdMeshersGUI_PropagationHelperWdg( StdMeshersGUI_SubShapeSelectorWdg* subSelectWdg, - QWidget* parent = 0 ); + QWidget* parent = 0, + bool show = true); ~StdMeshersGUI_PropagationHelperWdg(); + void Clear(); + private slots: void onShowGeometry(bool toShow); @@ -64,9 +69,11 @@ class STDMESHERSGUI_EXPORT StdMeshersGUI_PropagationHelperWdg : public QWidget GEOM_Actor* myActor; GEOM_Actor* myModelActor; - QListWidget* myListWidget; - QPushButton* myAddButton; - QPushButton* myReverseButton; + QListWidget* myListWidget; + QPushButton* myAddButton; + QPushButton* myReverseButton; + QCheckBox* myShowGeomChkBox; + QGroupBox* myChainBox; std::vector< std::vector > myChains; }; -- 2.39.2