diff --git a/doc/salome/gui/SMESH/images/ctrlinfo.png b/doc/salome/gui/SMESH/images/ctrlinfo.png index 497adcd95..100fbe014 100644 Binary files a/doc/salome/gui/SMESH/images/ctrlinfo.png and b/doc/salome/gui/SMESH/images/ctrlinfo.png differ diff --git a/doc/salome/gui/SMESH/images/extrusion_along_path_dlg.png b/doc/salome/gui/SMESH/images/extrusion_along_path_dlg.png index 98e362f38..74176d889 100644 Binary files a/doc/salome/gui/SMESH/images/extrusion_along_path_dlg.png and b/doc/salome/gui/SMESH/images/extrusion_along_path_dlg.png differ diff --git a/doc/salome/gui/SMESH/images/extrusionalongaline1.png b/doc/salome/gui/SMESH/images/extrusionalongaline1.png index 761f09bda..cc9757709 100644 Binary files a/doc/salome/gui/SMESH/images/extrusionalongaline1.png and b/doc/salome/gui/SMESH/images/extrusionalongaline1.png differ diff --git a/doc/salome/gui/SMESH/images/revolution1.png b/doc/salome/gui/SMESH/images/revolution1.png index 5f75d5d74..18928d1d0 100644 Binary files a/doc/salome/gui/SMESH/images/revolution1.png and b/doc/salome/gui/SMESH/images/revolution1.png differ diff --git a/src/SMESH/MG_ADAPT.cxx b/src/SMESH/MG_ADAPT.cxx index 3530fe477..8f2a36a44 100644 --- a/src/SMESH/MG_ADAPT.cxx +++ b/src/SMESH/MG_ADAPT.cxx @@ -30,6 +30,7 @@ #include #include +#include "SMESH_TypeDefs.hxx" #ifndef WIN32 #include // getpid() diff --git a/src/SMESHGUI/SMESHGUI.cxx b/src/SMESHGUI/SMESHGUI.cxx index a4714beb7..ca9c78767 100644 --- a/src/SMESHGUI/SMESHGUI.cxx +++ b/src/SMESHGUI/SMESHGUI.cxx @@ -659,6 +659,7 @@ namespace bool toCreateGroups = resMgr->booleanValue( "SMESH", "auto_groups", false ); bool toOverwrite = true; bool toFindOutDim = true; + bool saveNumbers = resMgr->booleanValue( "SMESH", "med_save_numbers", true ); bool toRenumber = true; double zTol = resMgr->doubleValue( "SMESH", "med_ztolerance", 0. ); @@ -770,7 +771,9 @@ namespace aDefaultFilter = it.key(); } QStringList checkBoxes; - checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") << QObject::tr("SMESH_AUTO_DIM"); + checkBoxes << QObject::tr("SMESH_AUTO_GROUPS") + << QObject::tr("SMESH_AUTO_DIM") + << QObject::tr("SMESH_MED_SAVE_NUMS"); SMESHGUI_FieldSelectorWdg* fieldSelWdg = new SMESHGUI_FieldSelectorWdg(); QList< QWidget* > wdgList; @@ -798,6 +801,7 @@ namespace fd->selectNameFilter( aDefaultFilter ); fd->SetChecked( toCreateGroups, 0 ); fd->SetChecked( toFindOutDim, 1 ); + fd->SetChecked( saveNumbers, 2 ); if ( !anInitialPath.isEmpty() ) fd->setDirectory( anInitialPath ); fd->selectFile(aMeshName); @@ -888,6 +892,7 @@ namespace } toCreateGroups = fd->IsChecked(0); toFindOutDim = fd->IsChecked(1); + saveNumbers = fd->IsChecked(2); zTol = zTolCheck->isChecked() ? zTolSpin->value() : -1; fieldSelWdg->GetSelectedFields(); if ( resMgr ) resMgr->setValue( "SMESH", "enable_ztolerance", zTolCheck->isChecked() ); @@ -927,7 +932,6 @@ namespace // } if ( isMED && isOkToWrite ) { - const bool saveNumbers = resMgr->booleanValue( "SMESH", "med_save_numbers", true ); aMeshIter = aMeshList.begin(); for( int aMeshIndex = 0; aMeshIter != aMeshList.end(); aMeshIter++, aMeshIndex++ ) { diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx index 51627d0ac..9afbe218c 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionAlongPathDlg.cxx @@ -264,13 +264,15 @@ SMESHGUI_ExtrusionAlongPathDlg::SMESHGUI_ExtrusionAlongPathDlg( SMESHGUI* theMod myPreviewCheckBox = new QCheckBox(tr("PREVIEW"), GroupArguments); // layouting - GroupArgumentsLayout->addWidget(SelectorWdg, 0, 0, 1, 2); - GroupArgumentsLayout->addWidget(PathGrp, 1, 0, 1, 2); - GroupArgumentsLayout->addWidget(BasePointGrp, 2, 0, 1, 2); - GroupArgumentsLayout->addWidget(AnglesGrp, 3, 0); - GroupArgumentsLayout->addWidget(ScalesGrp, 3, 1); - GroupArgumentsLayout->addWidget(myPreviewCheckBox, 4, 0); - GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0); + GroupArgumentsLayout->addWidget(SelectorWdg, 0, 0, 3, 2); + GroupArgumentsLayout->addWidget(PathGrp, 0, 2, 1, 2); + GroupArgumentsLayout->addWidget(BasePointGrp, 1, 2, 1, 2); + GroupArgumentsLayout->addWidget(AnglesGrp, 2, 2); + GroupArgumentsLayout->addWidget(ScalesGrp, 2, 3); + GroupArgumentsLayout->addWidget(myPreviewCheckBox, 3, 0); + GroupArgumentsLayout->addWidget(MakeGroupsCheck, 3, 1); + SelectorWdg->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + SelectorWdg->setMinimumWidth(320); /***************************************************************/ // common buttons group box diff --git a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx index 13ce13deb..ce69ade5e 100644 --- a/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ExtrusionDlg.cxx @@ -766,38 +766,53 @@ SMESHGUI_ExtrusionDlg::SMESHGUI_ExtrusionDlg (SMESHGUI* theModule) AnglesGrpLayout->setRowMinimumHeight(1, 10); AnglesGrpLayout->setRowStretch(3, 10); + // Controls for advanced parameters + QGridLayout* AdvancedGrpLayout = new QGridLayout(); + AdvancedGrpLayout->setSpacing(SPACING); + // layouting - GroupArgumentsLayout->addWidget(SelectorWdg, 0, 0, 1, 9); - GroupArgumentsLayout->addWidget(ExtrMethod_RBut0, 1, 0, 1, 3); - GroupArgumentsLayout->addWidget(ExtrMethod_RBut1, 1, 3, 1, 3); - GroupArgumentsLayout->addWidget(ExtrMethod_RBut2, 1, 6, 1, 3); - GroupArgumentsLayout->addWidget(TextLabelDistance, 2, 0); - GroupArgumentsLayout->addWidget(TextLabelDx, 2, 2); - GroupArgumentsLayout->addWidget(SpinBox_Dx, 2, 3); - GroupArgumentsLayout->addWidget(TextLabelDy, 2, 4); - GroupArgumentsLayout->addWidget(SpinBox_Dy, 2, 5); - GroupArgumentsLayout->addWidget(TextLabelDz, 2, 6); - GroupArgumentsLayout->addWidget(SpinBox_Dz, 2, 7); - GroupArgumentsLayout->addWidget(TextLabelVector, 3, 0); - GroupArgumentsLayout->addWidget(SelectVectorButton, 3, 1); - GroupArgumentsLayout->addWidget(TextLabelVx, 3, 2); - GroupArgumentsLayout->addWidget(SpinBox_Vx, 3, 3); - GroupArgumentsLayout->addWidget(TextLabelVy, 3, 4); - GroupArgumentsLayout->addWidget(SpinBox_Vy, 3, 5); - GroupArgumentsLayout->addWidget(TextLabelVz, 3, 6); - GroupArgumentsLayout->addWidget(SpinBox_Vz, 3, 7); - GroupArgumentsLayout->addWidget(TextLabelDist, 4, 0); - GroupArgumentsLayout->addWidget(SpinBox_VDist, 4, 3); - GroupArgumentsLayout->addWidget(TextLabelNbSteps, 5, 0, 1, 3); - GroupArgumentsLayout->addWidget(SpinBox_NbSteps, 5, 3); - GroupArgumentsLayout->addWidget(ByAverageNormalCheck, 6, 0, 1, 4); - GroupArgumentsLayout->addWidget(UseInputElemsOnlyCheck, 6, 4, 1, 4); - GroupArgumentsLayout->addWidget(BasePointGrp, 7, 0, 1, 9); - GroupArgumentsLayout->addWidget(ScalesGrp, 8, 0, 1, 4); - GroupArgumentsLayout->addWidget(AnglesGrp, 8, 5, 1, 4); - GroupArgumentsLayout->addWidget(myPreviewCheckBox, 9, 0, 1, 8); - GroupArgumentsLayout->addWidget(MakeGroupsCheck, 10,0, 1, 8); - GroupArgumentsLayout->addItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Expanding), 10, 0); + AdvancedGrpLayout->addWidget(TextLabelDistance, 0, 0); + AdvancedGrpLayout->addWidget(TextLabelDx, 0, 2); + AdvancedGrpLayout->addWidget(SpinBox_Dx, 0, 3); + AdvancedGrpLayout->addWidget(TextLabelDy, 0, 4); + AdvancedGrpLayout->addWidget(SpinBox_Dy, 0, 5); + AdvancedGrpLayout->addWidget(TextLabelDz, 0, 6); + AdvancedGrpLayout->addWidget(SpinBox_Dz, 0, 7); + AdvancedGrpLayout->addWidget(TextLabelVector, 1, 0); + AdvancedGrpLayout->addWidget(SelectVectorButton, 1, 1); + AdvancedGrpLayout->addWidget(TextLabelVx, 1, 2); + AdvancedGrpLayout->addWidget(SpinBox_Vx, 1, 3); + AdvancedGrpLayout->addWidget(TextLabelVy, 1, 4); + AdvancedGrpLayout->addWidget(SpinBox_Vy, 1, 5); + AdvancedGrpLayout->addWidget(TextLabelVz, 1, 6); + AdvancedGrpLayout->addWidget(SpinBox_Vz, 1, 7); + AdvancedGrpLayout->addWidget(TextLabelDist, 2, 0); + AdvancedGrpLayout->addWidget(SpinBox_VDist, 2, 3); + AdvancedGrpLayout->addWidget(TextLabelNbSteps, 3, 0, 1, 3); + AdvancedGrpLayout->addWidget(SpinBox_NbSteps, 3, 3); + AdvancedGrpLayout->addWidget(ByAverageNormalCheck, 4, 0, 1, 4); + AdvancedGrpLayout->addWidget(UseInputElemsOnlyCheck, 4, 4, 1, 4); + + // Controls for advanced parameters + QGroupBox* RbGrp = new QGroupBox(); + QHBoxLayout* RBLayout = new QHBoxLayout(RbGrp); + RBLayout->setSpacing(SPACING); RBLayout->setMargin(MARGIN); + RBLayout->addWidget(ExtrMethod_RBut0); + RBLayout->addWidget(ExtrMethod_RBut1); + RBLayout->addWidget(ExtrMethod_RBut2); + + // layouting + GroupArgumentsLayout->addWidget(RbGrp, 0, 0, 1, 4); + GroupArgumentsLayout->addWidget(SelectorWdg, 1, 0, 3, 2); + GroupArgumentsLayout->addLayout(AdvancedGrpLayout, 1, 2, 1, 2); + GroupArgumentsLayout->addWidget(BasePointGrp, 2, 2, 1, 2); + GroupArgumentsLayout->addWidget(ScalesGrp, 3, 2, 1, 1); + GroupArgumentsLayout->addWidget(AnglesGrp, 3, 3, 1, 1); + GroupArgumentsLayout->addWidget(myPreviewCheckBox, 4, 0); + GroupArgumentsLayout->addWidget(MakeGroupsCheck, 4, 1); + GroupArgumentsLayout->setRowStretch(5, 10); + SelectorWdg->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + SelectorWdg->setMinimumWidth(320); /***************************************************************/ GroupButtons = new QGroupBox(this); diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx index 183d9468b..57fce1eea 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.cxx @@ -42,6 +42,11 @@ #include +#include +#include +#include +#include + namespace SMESH { GEOM::GEOM_Gen_var GetGEOMGen( GEOM::GEOM_Object_ptr go ) @@ -244,4 +249,80 @@ namespace SMESH } + //================================================================================ + /*! + * \brief Return type of shape contained in a group + */ + //================================================================================ + + TopAbs_ShapeEnum _getGroupType(const TopoDS_Shape& group) + { + if ( group.ShapeType() != TopAbs_COMPOUND ) + return group.ShapeType(); + + // iterate on a compound + TopoDS_Iterator it( group ); + if ( it.More() ) + return _getGroupType( it.Value() ); + + return TopAbs_SHAPE; + } + + + //================================================================================ + /*! + * \brief Check if a subGeom contains sub-shapes of a mainGeom + */ + //================================================================================ + + bool ContainsSubShape( GEOM::GEOM_Object_ptr mainGeom, + GEOM::GEOM_Object_ptr subGeom ) + { + if ( CORBA::is_nil( mainGeom ) || + CORBA::is_nil( subGeom )) + return false; + + GEOM::GEOM_Gen_var geomGen = mainGeom->GetGen(); + if ( geomGen->_is_nil() ) return false; + + GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(); + if ( op->_is_nil() ) return false; + + GEOM::GEOM_Object_var mainObj = op->GetMainShape( subGeom ); /* _var not _wrap as + mainObj already exists! */ + while ( !mainObj->_is_nil() ) + { + CORBA::String_var entry1 = mainObj->GetEntry(); + CORBA::String_var entry2 = mainGeom->GetEntry(); + if ( std::string( entry1.in() ) == entry2.in() ) + return true; + mainObj = op->GetMainShape( mainObj ); + } + if ( subGeom->GetShapeType() == GEOM::COMPOUND ) + { + // is subGeom a compound of sub-shapes? + GEOM::GEOM_IShapesOperations_wrap sop = geomGen->GetIShapesOperations(); + if ( sop->_is_nil() ) return false; + GEOM::ListOfLong_var ids = sop->GetAllSubShapesIDs( subGeom, + GEOM::SHAPE,/*sorted=*/false); + if ( ids->length() > 0 ) + { + GEOM_Client geomClient; + TopoDS_Shape subShape = geomClient.GetShape( geomGen, subGeom ); + TopoDS_Shape mainShape = geomClient.GetShape( geomGen, mainGeom ); + if ( subShape.IsNull() || mainShape.IsNull() ) + return false; + + TopAbs_ShapeEnum subType = _getGroupType( subShape ); + TopTools_IndexedMapOfShape subMap; + TopExp::MapShapes( subShape, subType, subMap ); + for ( TopExp_Explorer exp( mainShape, subType ); exp.More(); exp.Next() ) + if ( subMap.Contains( exp.Current() )) + return true; + + } + } + return false; + } + } // end of namespace SMESH diff --git a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h index 438e51846..04e8bfd93 100644 --- a/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h +++ b/src/SMESHGUI/SMESHGUI_GEOMGenUtils.h @@ -59,6 +59,9 @@ namespace SMESH SMESHGUI_EXPORT bool GetGeomEntries( Handle(SALOME_InteractiveObject)& hypIO, QString& subGeom, QString& meshGeom); + + SMESHGUI_EXPORT bool ContainsSubShape( GEOM::GEOM_Object_ptr mainShape, + GEOM::GEOM_Object_ptr subShape ); } #endif // SMESHGUI_GEOMGENUTILS_H diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx index a231ff18a..18f261234 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.cxx @@ -1405,72 +1405,23 @@ void SMESHGUI_GroupDlg::onObjectSelectionChanged() else if (myCurrentLineEdit == myGeomGroupLine) { myGeomObjects = new GEOM::ListOfGO(); + myGeomObjects->length( aNbSel ); - // The mesh SObject - _PTR(SObject) aMeshSO = SMESH::FindSObject(myMesh); - - if (aNbSel == 0 || !aMeshSO) + if ( aNbSel == 0 || myMesh->_is_nil() ) { - myGeomObjects->length(0); updateButtons(); myIsBusy = false; return; } - myGeomObjects->length(aNbSel); - - GEOM::GEOM_Object_var aGeomGroup; + GEOM::GEOM_Object_var mainGeom = myMesh->GetShapeToMesh(); int i = 0; - - SALOME_ListIteratorOfListIO anIt (aList); - for (; anIt.More(); anIt.Next()) + for ( SALOME_ListIteratorOfListIO anIt( aList ); anIt.More(); anIt.Next() ) { - CORBA::Object_var aGroupObj = SMESH::IObjectToObject(anIt.Value()); - if (CORBA::is_nil(aGroupObj)) - continue; - // Check if the object is a geometry group - aGeomGroup = GEOM::GEOM_Object::_narrow(aGroupObj); - if (CORBA::is_nil(aGeomGroup)) - continue; - // Check if group constructed on the same shape as a mesh or on its child - - // The main shape of the group - GEOM::GEOM_Object_var aGroupMainShape; - if (aGeomGroup->GetType() == 37) - { - GEOM::GEOM_IGroupOperations_wrap anOp = - SMESH::GetGEOMGen( aGeomGroup )->GetIGroupOperations(); - aGroupMainShape = anOp->GetMainShape( aGeomGroup ); - // aGroupMainShape is an existing servant => GEOM_Object_var not GEOM_Object_wrap - } - else - { - aGroupMainShape = aGeomGroup; - aGroupMainShape->Register(); - } - CORBA::String_var entry = aGroupMainShape->GetStudyEntry(); - _PTR(SObject) aGroupMainShapeSO = - SMESH::getStudy()->FindObjectID( entry.in() ); - - _PTR(SObject) anObj, aRef; - bool isRefOrSubShape = false; - if (aMeshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(aRef)) { - if (aRef->GetID() == aGroupMainShapeSO->GetID()) { - isRefOrSubShape = true; - } else { - _PTR(SObject) aFather = aGroupMainShapeSO->GetFather(); - _PTR(SComponent) aComponent = aGroupMainShapeSO->GetFatherComponent(); - while (!isRefOrSubShape && aFather->GetID() != aComponent->GetID()) { - if (aRef->GetID() == aFather->GetID()) - isRefOrSubShape = true; - else - aFather = aFather->GetFather(); - } - } - } - if (isRefOrSubShape) - myGeomObjects[i++] = aGeomGroup; + GEOM::GEOM_Object_var geomGroup = SMESH::GetGeom( anIt.Value() ); + if ( SMESH::ContainsSubShape( mainGeom, geomGroup )) + myGeomObjects[ i++ ] = geomGroup; } myGeomObjects->length(i); diff --git a/src/SMESHGUI/SMESHGUI_GroupDlg.h b/src/SMESHGUI/SMESHGUI_GroupDlg.h index 9344c62b4..606a0a732 100644 --- a/src/SMESHGUI/SMESHGUI_GroupDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupDlg.h @@ -178,7 +178,7 @@ private: QPushButton* myAddBtn; QPushButton* myRemoveBtn; QPushButton* mySortBtn; - + QGroupBox* mySelectBox; QCheckBox* mySelectSubMesh; QPushButton* mySubMeshBtn; @@ -186,9 +186,9 @@ private: QCheckBox* mySelectGroup; QPushButton* myGroupBtn; QLineEdit* myGroupLine; - + QtxColorButton* myColorBtn; - + QCheckBox* mySelectGeomGroup; QToolButton* myGeomGroupBtn; QLineEdit* myGeomGroupLine; @@ -198,9 +198,9 @@ private: QPushButton* myApplyBtn; QPushButton* myCloseBtn; QPushButton* myHelpBtn; - + SMESHGUI_ShapeByMeshOp* myShapeByMeshOp; - + SMESH::SMESH_Mesh_var myMesh; QList myActorsList; SMESH::SMESH_Group_var myGroup; @@ -209,22 +209,19 @@ private: SMESH::Filter_var myFilter; QList myIdList; GEOM::ListOfGO_var myGeomObjects; - + int mySelectionMode; - //Handle(SMESH_TypeFilter) myMeshFilter; - //Handle(SMESH_TypeFilter) mySubMeshFilter; - //Handle(SMESH_TypeFilter) myGroupFilter; SUIT_SelectionFilter* myMeshFilter; SMESH_LogicalFilter* mySubMeshFilter; SMESH_LogicalFilter* myGroupFilter; SUIT_SelectionFilter* myGeomFilter; - + SMESHGUI_FilterDlg* myFilterDlg; - + bool myCreate, myIsBusy; - + QString myHelpFileName; - + QMap myActions; bool myNameChanged; //added by skl for IPAL19574 diff --git a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx index b0137dd1f..f7dccaff4 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.cxx @@ -463,29 +463,23 @@ void SMESHGUI_GroupOnShapeOp::selectionDone() // study if (_PTR(Study) aStudy = SMESH::getStudy()) { // mesh - if (_PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toUtf8().data() )) { + if (_PTR(SObject) meshSO = aStudy->FindObjectID( myMeshID.toUtf8().data() )) + { // shape to mesh - _PTR(SObject) anObj, shapeToMesh; - if (meshSO->FindSubObject(1, anObj) && anObj->ReferencedObject(shapeToMesh)) { - // loop on selected - QStringList::iterator name = names.begin(), id = ids.begin(), idEnd = ids.end(); - for (; id != idEnd; ++id, ++name ) { - // shape SO - if (_PTR(SObject) shapeSO = aStudy->FindObjectID( id->toUtf8().data() )) { - // check if shape SO is a child of shape to mesh - while ( shapeSO && shapeSO->GetID() != shapeToMesh->GetID() ) - if ( shapeSO->Depth() < 2 ) - shapeSO.reset(); - else - shapeSO = shapeSO->GetFather(); - if ( shapeSO ) { - //printf( "selectionDone() %s %s\n", (*id).latin1(), (*name).latin1() ); - if ( !goodIds.contains( *id )) { - goodIds.append( *id ); - goodNames.append( *name ); - } - } - } + GEOM::GEOM_Object_var mainGeom = SMESH::GetGeom( meshSO ); + // loop on selected + QStringList::iterator name = names.begin(), id = ids.begin(), idEnd = ids.end(); + for (; id != idEnd; ++id, ++name ) + { + if ( goodIds.contains( *id )) + continue; + // shape SO + _PTR(SObject) shapeSO = aStudy->FindObjectID( id->toUtf8().data() ); + GEOM::GEOM_Object_var subGeom = SMESH::GetGeom( shapeSO ); + if ( SMESH::ContainsSubShape( mainGeom, subGeom )) + { + goodIds.append( *id ); + goodNames.append( *name ); } } } diff --git a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.h b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.h index 20f2a7ee6..157cbdf83 100644 --- a/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.h +++ b/src/SMESHGUI/SMESHGUI_GroupOnShapeDlg.h @@ -58,27 +58,15 @@ protected: virtual void startOperation(); virtual void selectionDone(); virtual SUIT_SelectionFilter* createFilter( const int ) const; - //virtual bool isValid( SUIT_Operation* ) const; private slots: bool onApply(); void onButtonClick(); - -// void onSelectColor(); - - private: void init(); -// void setGroupColor( const SALOMEDS::Color& ); -// SALOMEDS::Color getGroupColor() const; - -// void setGroupQColor( const QColor& ); -// QColor getGroupQColor() const; - -// void setDefaultGroupColor(); private: @@ -86,7 +74,6 @@ private: QString myMeshID; QStringList myElemGeoIDs, myNodeGeoIDs; - //GEOM::ListOfGO_var myElemGObj; }; class SMESHGUI_EXPORT SMESHGUI_GroupOnShapeDlg : public SMESHGUI_Dialog @@ -104,22 +91,14 @@ public slots: private: - //QLineEdit* myGrpNameLine; - QPushButton* myMeshBtn; QLineEdit* myMeshLine; QPushButton* myElemGeomBtn; - QListWidget* myElemGeomList; + QListWidget* myElemGeomList; QPushButton* myNodeGeomBtn; - QListWidget* myNodeGeomList; - -// QPushButton* myColorBtn; - -// bool myCreate, myIsBusy; - -// QString myHelpFileName; + QListWidget* myNodeGeomList; friend class SMESHGUI_GroupOnShapeOp; }; diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx index a6d6b3cda..37ed558db 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.cxx @@ -3432,6 +3432,9 @@ SMESHGUI_CtrlInfo::SMESHGUI_CtrlInfo( QWidget* parent ): SMESHGUI_Info( parent ) QIcon aComputeIcon( SUIT_Session::session()->resourceMgr()->loadPixmap( "SMESH", tr( "ICON_COMPUTE" ) ) ); SMESH::FilterManager_var aFilterMgr = SMESH::GetFilterManager(); + // QToolBox with MeshInfo + myMeshTB = new QToolBox(this); + // name QLabel* aNameLab = createLabel( tr( "NAME_LAB" ), this, Bold ); QLabel* aName = createField( this, "ctrlName" ); @@ -3547,50 +3550,82 @@ SMESHGUI_CtrlInfo::SMESHGUI_CtrlInfo( QWidget* parent ): SMESHGUI_Info( parent ) connect( aOverContVolumesBtn,SIGNAL( clicked() ), this, SLOT( computeOverConstrainedVolumesInfo() ) ); connect( myToleranceWidget, SIGNAL( valueChanged( double ) ), this, SLOT( setTolerance( double ) ) ); - l->addWidget( aNameLab, 0, 0 ); //0 - l->addWidget( aName, 0, 1, 1, 2 ); //1 - l->addWidget( aNodesLab, 1, 0, 1, 3 ); //2 - l->addWidget( aNodesFreeLab, 2, 0 ); //3 - l->addWidget( aNodesFree, 2, 1 ); //4 - l->addWidget( aFreeNodesBtn, 2, 2 ); //5 - l->addWidget( aNodesNbConnLab, 3, 0 ); //6 - l->addWidget( aNodesNbConn, 3, 1 ); //7 - l->addWidget( aNodesNbConnBtn, 3, 2 ); //8 - l->addWidget( aNodesDoubleLab, 4, 0 ); //9 - l->addWidget( aNodesDouble, 4, 1 ); //10 - l->addWidget( aDoubleNodesBtn, 4, 2 ); //11 - l->addWidget( aToleranceLab, 5, 0 ); //12 - l->addWidget( myToleranceWidget, 5, 1 ); //13 - l->addWidget( anEdgesLab, 6, 0, 1, 3 ); //14 - l->addWidget( anEdgesDoubleLab, 7, 0 ); //15 - l->addWidget( anEdgesDouble, 7, 1 ); //16 - l->addWidget( aDoubleEdgesBtn, 7, 2 ); //17 - l->addWidget( aFacesLab, 8, 0, 1, 3 ); //18 - l->addWidget( aFacesDoubleLab, 9, 0 ); //19 - l->addWidget( aFacesDouble, 9, 1 ); //20 - l->addWidget( aDoubleFacesBtn, 9, 2 ); //21 - l->addWidget( aFacesOverLab, 10, 0 ); //22 - l->addWidget( aFacesOver, 10, 1 ); //23 - l->addWidget( aOverContFacesBtn, 10, 2 ); //24 - l->addWidget( anAspectRatioLab, 11, 0 ); //25 - l->addWidget( aComputeFaceBtn, 11, 2 ); //26 - l->addWidget( myPlot, 12, 0, 1, 3 );//27 - l->addWidget( aVolumesLab, 13, 0, 1, 3 );//28 - l->addWidget( aVolumesDoubleLab, 14, 0 ); //29 - l->addWidget( aVolumesDouble, 14, 1 ); //30 - l->addWidget( aDoubleVolumesBtn, 14, 2 ); //31 - l->addWidget( aVolumesOverLab, 15, 0 ); //32 - l->addWidget( aVolumesOver, 15, 1 ); //33 - l->addWidget( aOverContVolumesBtn,15, 2 ); //34 - l->addWidget( anAspectRatio3DLab, 16, 0 ); //35 - l->addWidget( aComputeVolumeBtn, 16, 2 ); //36 - l->addWidget( myPlot3D, 17, 0, 1, 3 );//37 - - l->setColumnStretch( 0, 0 ); - l->setColumnStretch( 1, 5 ); - l->setRowStretch ( 12, 5 ); - l->setRowStretch ( 17, 5 ); - l->setRowStretch ( 18, 1 ); + l->addWidget( aNameLab, 0, 0 ); //0 + l->addWidget( aName, 0, 1 ); //1 + + // Node group + QWidget* NodeGrp = new QWidget(); + QGridLayout* NodeLayout = new QGridLayout(NodeGrp); + NodeLayout->setSpacing(SPACING); NodeLayout->setMargin(MARGIN); + + NodeLayout->addWidget( aNodesFreeLab, 0, 0 ); + NodeLayout->addWidget( aNodesFree, 0, 1 ); + NodeLayout->addWidget( aFreeNodesBtn, 0, 2 ); + NodeLayout->addWidget( aNodesNbConnLab, 1, 0 ); + NodeLayout->addWidget( aNodesNbConn, 1, 1 ); + NodeLayout->addWidget( aNodesNbConnBtn, 1, 2 ); + NodeLayout->addWidget( aNodesDoubleLab, 2, 0 ); + NodeLayout->addWidget( aNodesDouble, 2, 1 ); + NodeLayout->addWidget( aDoubleNodesBtn, 2, 2 ); + NodeLayout->addWidget( aToleranceLab, 3, 0 ); + NodeLayout->addWidget( myToleranceWidget, 3, 1 ); + NodeLayout->addWidget( myToleranceWidget, 3, 1 ); + NodeLayout->setRowStretch(4, 5); + + myMeshTB->addItem(NodeGrp, aNodesLab->text()); + aNodesLab->setVisible(false); + + // Edge group + QWidget* EdgeGrp = new QWidget(); + QGridLayout* EdgeLayout = new QGridLayout(EdgeGrp); + EdgeLayout->setSpacing(SPACING); EdgeLayout->setMargin(MARGIN); + + EdgeLayout->addWidget( anEdgesDoubleLab, 0, 0 ); + EdgeLayout->addWidget( anEdgesDouble, 0, 1 ); + EdgeLayout->addWidget( aDoubleEdgesBtn, 0, 2 ); + EdgeLayout->setRowStretch(1, 5); + + myMeshTB->addItem(EdgeGrp, anEdgesLab->text()); + anEdgesLab->setVisible(false); + + // Face group + QWidget* FaceGrp = new QWidget(); + QGridLayout* FaceLayout = new QGridLayout(FaceGrp); + FaceLayout->setSpacing(SPACING); FaceLayout->setMargin(MARGIN); + + FaceLayout->addWidget( aFacesDoubleLab, 0, 0 ); + FaceLayout->addWidget( aFacesDouble, 0, 1 ); + FaceLayout->addWidget( aDoubleFacesBtn, 0, 2 ); + FaceLayout->addWidget( aFacesOverLab, 1, 0 ); + FaceLayout->addWidget( aFacesOver, 1, 1 ); + FaceLayout->addWidget( aOverContFacesBtn, 1, 2 ); + FaceLayout->addWidget( anAspectRatioLab, 2, 0 ); + FaceLayout->addWidget( aComputeFaceBtn, 2, 2 ); + FaceLayout->addWidget( myPlot, 3, 0, 1, 3 ); + + myMeshTB->addItem(FaceGrp, aFacesLab->text()); + aFacesLab->setVisible(false); + + // Volume group + QWidget* VolumeGrp = new QWidget(); + QGridLayout* VolumeLayout = new QGridLayout(VolumeGrp); + VolumeLayout->setSpacing(SPACING); VolumeLayout->setMargin(MARGIN); + + VolumeLayout->addWidget( aVolumesDoubleLab, 0, 0 ); + VolumeLayout->addWidget( aVolumesDouble, 0, 1 ); + VolumeLayout->addWidget( aDoubleVolumesBtn, 0, 2 ); + VolumeLayout->addWidget( aVolumesOverLab, 1, 0 ); + VolumeLayout->addWidget( aVolumesOver, 1, 1 ); + VolumeLayout->addWidget( aOverContVolumesBtn,1, 2 ); + VolumeLayout->addWidget( anAspectRatio3DLab, 2, 0 ); + VolumeLayout->addWidget( aComputeVolumeBtn, 2, 2 ); + VolumeLayout->addWidget( myPlot3D, 3, 0, 1, 3 ); + + myMeshTB->addItem(VolumeGrp, aVolumesLab->text()); + aVolumesLab->setVisible(false); + + l->addWidget( myMeshTB, 1, 0, 1, 2 ); //2 + l->setRowStretch( 2, 5 ); clearInternal(); } @@ -3673,8 +3708,8 @@ void SMESHGUI_CtrlInfo::showInfo( const SMESH::SelectionProxy& proxy ) } } else { - for( int i=2; i<=13; i++) - dynamic_cast(layout())->itemAt(i)->widget()->setVisible( false ); + myMeshTB->setItemEnabled(0, false ); + myMeshTB->widget(0)->setVisible( false ); } // edges info @@ -3686,8 +3721,8 @@ void SMESHGUI_CtrlInfo::showInfo( const SMESH::SelectionProxy& proxy ) myButtons[3]->setEnabled( true ); } else { - for( int i=14; i<=17; i++) - dynamic_cast(layout())->itemAt(i)->widget()->setVisible( false ); + myMeshTB->setItemEnabled(1, false ); + myMeshTB->widget(1)->setVisible( false ); } // faces info @@ -3705,14 +3740,10 @@ void SMESHGUI_CtrlInfo::showInfo( const SMESH::SelectionProxy& proxy ) myButtons[5]->setEnabled( true ); myButtons[6]->setEnabled( true ); } -#ifdef DISABLE_PLOT2DVIEWER - for( int i=25; i<=27; i++) - dynamic_cast(layout())->itemAt(i)->widget()->setVisible( false ); -#endif } else { - for( int i=18; i<=27; i++) - dynamic_cast(layout())->itemAt(i)->widget()->setVisible( false ); + myMeshTB->setItemEnabled(2, false ); + myMeshTB->widget(2)->setVisible( false ); } // volumes info @@ -3730,15 +3761,15 @@ void SMESHGUI_CtrlInfo::showInfo( const SMESH::SelectionProxy& proxy ) myButtons[8]->setEnabled( true ); myButtons[9]->setEnabled( true ); } -#ifdef DISABLE_PLOT2DVIEWER - for( int i=35; i<=37; i++) - dynamic_cast(layout())->itemAt(i)->widget()->setVisible( false ); -#endif } else { - for( int i=28; i<=37; i++) - dynamic_cast(layout())->itemAt(i)->widget()->setVisible( false ); + myMeshTB->setItemEnabled(3, false ); + myMeshTB->widget(3)->setVisible( false ); } + myMeshTB->setCurrentIndex(0); + myMeshTB->setVisible( (nbNodes + nbElemsByType[ SMESH::EDGE ] + + nbElemsByType[ SMESH::FACE ] + + nbElemsByType[ SMESH::VOLUME ]) > 0 ); } //================================================================================ @@ -3892,8 +3923,10 @@ void SMESHGUI_CtrlInfo::computeAspectRatio3D() */ void SMESHGUI_CtrlInfo::clearInternal() { - for( int i=0; i<=37; i++) - dynamic_cast(layout())->itemAt(i)->widget()->setVisible( true ); + for (int i=0; i<=3;i++) { + myMeshTB->setItemEnabled(i, true ); + myMeshTB->widget(i)->setVisible( true ); + } for( int i=0; i<=9; i++) myButtons[i]->setEnabled( false ); myPlot->detachItems(); diff --git a/src/SMESHGUI/SMESHGUI_MeshInfo.h b/src/SMESHGUI/SMESHGUI_MeshInfo.h index 82e3adc6c..84700d488 100644 --- a/src/SMESHGUI/SMESHGUI_MeshInfo.h +++ b/src/SMESHGUI/SMESHGUI_MeshInfo.h @@ -36,6 +36,7 @@ #include #include #include +#include #include #include CORBA_SERVER_HEADER(SMESH_Filter) @@ -345,6 +346,7 @@ private: ObjectType myObjectType; SMESHGUI_SpinBox* myToleranceWidget; QList myWidgets; + QToolBox* myMeshTB; QwtPlot* myPlot; QwtPlot* myPlot3D; QList myButtons; diff --git a/src/SMESHGUI/SMESHGUI_MeshOp.cxx b/src/SMESHGUI/SMESHGUI_MeshOp.cxx index 68791630a..e0c88fa17 100644 --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@ -319,25 +319,6 @@ SUIT_SelectionFilter* SMESHGUI_MeshOp::createFilter( const int theId ) const return 0; } -//================================================================================ -/*! - * \brief Return type of shape contained in a group - */ -//================================================================================ - -TopAbs_ShapeEnum getGroupType(const TopoDS_Shape& group) -{ - if ( group.ShapeType() != TopAbs_COMPOUND ) - return group.ShapeType(); - - // iterate on a compound - TopoDS_Iterator it( group ); - if ( it.More() ) - return getGroupType( it.Value() ); - - return TopAbs_SHAPE; -} - //================================================================================ /*! * \brief check if selected shape is a sub-shape of the shape to mesh @@ -365,60 +346,17 @@ bool SMESHGUI_MeshOp::isSubshapeOk() const QStringList aGEOMs; myDlg->selectedObject(SMESHGUI_MeshDlg::Geom, aGEOMs); - if (aGEOMs.count() > 0) { - GEOM::GEOM_Gen_var geomGen = mainGeom->GetGen(); - if (geomGen->_is_nil()) return false; + // check all selected shapes + for ( QString& aSubGeomEntry : aGEOMs ) + { + _PTR(SObject) pSubGeom = SMESH::getStudy()->FindObjectID( aSubGeomEntry.toUtf8().data() ); + if ( !pSubGeom ) return false; - GEOM::GEOM_IGroupOperations_wrap op = geomGen->GetIGroupOperations(); - if (op->_is_nil()) return false; + GEOM::GEOM_Object_var subGeom = + GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject()); - // check all selected shapes - QStringList::const_iterator aSubShapesIter = aGEOMs.begin(); - for ( ; aSubShapesIter != aGEOMs.end(); aSubShapesIter++) - { - QString aSubGeomEntry = (*aSubShapesIter); - _PTR(SObject) pSubGeom = SMESH::getStudy()->FindObjectID(aSubGeomEntry.toUtf8().data()); - if (!pSubGeom) return false; - - GEOM::GEOM_Object_var aSubGeomVar = - GEOM::GEOM_Object::_narrow(_CAST(SObject,pSubGeom)->GetObject()); - if (aSubGeomVar->_is_nil()) return false; - - // skl for NPAL14695 - implementation of searching of mainObj - GEOM::GEOM_Object_var mainObj = op->GetMainShape(aSubGeomVar); /* _var not _wrap as - mainObj already exists! */ - while( !mainObj->_is_nil()) - { - CORBA::String_var entry1 = mainObj->GetEntry(); - CORBA::String_var entry2 = mainGeom->GetEntry(); - if (std::string( entry1.in() ) == entry2.in() ) - return true; - mainObj = op->GetMainShape(mainObj); - } - if ( aSubGeomVar->GetShapeType() == GEOM::COMPOUND ) - { - // is aSubGeomVar a compound of sub-shapes? - GEOM::GEOM_IShapesOperations_wrap sop = geomGen->GetIShapesOperations(); - if (sop->_is_nil()) return false; - GEOM::ListOfLong_var ids = sop->GetAllSubShapesIDs( aSubGeomVar, - GEOM::SHAPE,/*sorted=*/false); - if ( ids->length() > 0 ) - { - GEOM_Client geomClient; - TopoDS_Shape subShape = geomClient.GetShape( geomGen, aSubGeomVar ); - TopoDS_Shape mainShape = geomClient.GetShape( geomGen, mainGeom ); - if ( subShape.IsNull() || mainShape.IsNull() ) - return false; - - TopAbs_ShapeEnum subType = getGroupType( subShape ); - TopTools_IndexedMapOfShape subMap; - TopExp::MapShapes( subShape, subType, subMap ); - for ( TopExp_Explorer exp( mainShape, subType ); exp.More(); exp.Next() ) - if ( subMap.Contains( exp.Current() )) - return true; - } - } - } + if ( SMESH::ContainsSubShape( mainGeom, subGeom )) + return true; } return false; diff --git a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx index 717d747c1..768303fea 100644 --- a/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_RevolutionDlg.cxx @@ -202,13 +202,15 @@ SMESHGUI_RevolutionDlg::SMESHGUI_RevolutionDlg( SMESHGUI* theModule ) MakeGroupsCheck = new QCheckBox(tr("SMESH_MAKE_GROUPS"), GroupArguments); MakeGroupsCheck->setChecked(true); - GroupArgumentsLayout->addWidget(SelectorWdg, 0, 0, 1, 4); - GroupArgumentsLayout->addWidget(GroupAxis, 1, 0, 1, 4); - GroupArgumentsLayout->addWidget(GroupAngleBox, 2, 0, 1, 4); - GroupArgumentsLayout->addWidget(TextLabelTolerance, 3, 0, 1, 2); - GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 3, 2, 1, 2); - GroupArgumentsLayout->addWidget(myPreviewCheckBox, 4, 0, 1, 4); - GroupArgumentsLayout->addWidget(MakeGroupsCheck, 5, 0, 1, 4); + GroupArgumentsLayout->addWidget(SelectorWdg, 0, 0, 3, 4); + GroupArgumentsLayout->addWidget(GroupAxis, 0, 4, 1, 4); + GroupArgumentsLayout->addWidget(GroupAngleBox, 1, 4, 1, 4); + GroupArgumentsLayout->addWidget(TextLabelTolerance, 2, 4, 1, 2); + GroupArgumentsLayout->addWidget(SpinBox_Tolerance, 2, 6, 1, 2); + GroupArgumentsLayout->addWidget(myPreviewCheckBox, 3, 0, 1, 2); + GroupArgumentsLayout->addWidget(MakeGroupsCheck, 3, 2, 1, 2); + SelectorWdg->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding)); + SelectorWdg->setMinimumWidth(320); SelectorWdg->GetButtonGroup()->addButton( SelectVectorButton ); SelectorWdg->GetButtonGroup()->addButton( SelectPointButton ); diff --git a/src/SMESHGUI/SMESH_msg_en.ts b/src/SMESHGUI/SMESH_msg_en.ts index a4b6cfd7a..9c982d71e 100644 --- a/src/SMESHGUI/SMESH_msg_en.ts +++ b/src/SMESHGUI/SMESH_msg_en.ts @@ -1614,6 +1614,10 @@ Please enter correct values and try again SMESH_AUTO_DIM Automatically define space dimension + + SMESH_MED_SAVE_NUMS + Export indices + SMESH_ZTOLERANCE Z tolerance diff --git a/src/SMESH_I/SMESH_Gen_i_1.cxx b/src/SMESH_I/SMESH_Gen_i_1.cxx index 565fa023b..e4e3f5e85 100644 --- a/src/SMESH_I/SMESH_Gen_i_1.cxx +++ b/src/SMESH_I/SMESH_Gen_i_1.cxx @@ -535,7 +535,7 @@ SALOMEDS::SObject_ptr SMESH_Gen_i::PublishInStudy(SALOMEDS::SObject_ptr /*theSOb //======================================================================= //function : PublishComponent -//purpose : +//purpose : //======================================================================= SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent() @@ -547,7 +547,7 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent() SALOMEDS::StudyBuilder_var aStudyBuilder = getStudyServant()->NewBuilder(); SALOMEDS::UseCaseBuilder_wrap useCaseBuilder = getStudyServant()->GetUseCaseBuilder(); - std::string compDataType = ComponentDataType(); // SMESH module's data type + CORBA::String_var compDataType = ComponentDataType(); // SMESH module's data type std::string ior; { CORBA::String_var iorString = GetORB()->object_to_string( SMESH_Gen::_this() ); @@ -562,12 +562,13 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent() CORBA::String_var ior_i; bool ok = f_i->ComponentIOR(ior_i.out()); CORBA::String_var cdt(f_i->ComponentDataType()); - if ( ok && compDataType == cdt.in() && ior == ior_i.in()) { + if ( ok && strcmp( compDataType.in(), cdt.in() ) == 0 && ior == ior_i.in()) + { father = f_i; break; } } - + if ( !CORBA::is_nil( father ) ) { // check that the component is added to the use case browser if ( !useCaseBuilder->IsUseCaseNode( father ) ) { @@ -583,14 +584,14 @@ SALOMEDS::SComponent_ptr SMESH_Gen_i::PublishComponent() if ( CORBA::is_nil( aCat ) ) return father._retn(); - SALOME_ModuleCatalog::Acomponent_var aComp = aCat->GetComponent( compDataType.c_str() ); + SALOME_ModuleCatalog::Acomponent_var aComp = aCat->GetComponent( compDataType.in() ); if ( CORBA::is_nil( aComp ) ) return father._retn(); SALOMEDS::GenericAttribute_wrap anAttr; SALOMEDS::AttributePixMap_wrap aPixmap; - father = aStudyBuilder->NewComponent( compDataType.c_str() ); + father = aStudyBuilder->NewComponent( compDataType.in() ); aStudyBuilder->DefineComponentInstance( father, SMESH_Gen::_this() ); anAttr = aStudyBuilder->FindOrCreateAttribute( father, "AttributePixMap" ); aPixmap = anAttr; diff --git a/src/StdMeshers/StdMeshers_Hexa_3D.cxx b/src/StdMeshers/StdMeshers_Hexa_3D.cxx index 6fecaa293..a912dd8be 100644 --- a/src/StdMeshers/StdMeshers_Hexa_3D.cxx +++ b/src/StdMeshers/StdMeshers_Hexa_3D.cxx @@ -1118,7 +1118,7 @@ bool StdMeshers_Hexa_3D::IsApplicable( const TopoDS_Shape & aShape, bool toCheck if ( nbFoundShells != 1 ) { if ( toCheckAll ) return false; continue; - } + } exp1.Init( exp0.Current(), TopAbs_FACE ); int nbEdges = SMESH_MesherHelper::Count( exp1.Current(), TopAbs_EDGE, /*ignoreSame=*/true ); bool ok = ( nbEdges > 3 ); @@ -1130,7 +1130,7 @@ bool StdMeshers_Hexa_3D::IsApplicable( const TopoDS_Shape & aShape, bool toCheck //======================================================================= //function : ComputePentahedralMesh -//purpose : +//purpose : //======================================================================= SMESH_ComputeErrorPtr ComputePentahedralMesh(SMESH_Mesh & aMesh, @@ -1138,12 +1138,7 @@ SMESH_ComputeErrorPtr ComputePentahedralMesh(SMESH_Mesh & aMesh, SMESH_ProxyMesh* proxyMesh) { SMESH_ComputeErrorPtr err = SMESH_ComputeError::New(); - if ( proxyMesh ) - { - err->myName = COMPERR_BAD_INPUT_MESH; - err->myComment = "Can't build pentahedral mesh on viscous layers"; - return err; - } + bool bOK; StdMeshers_Penta_3D anAlgo; // @@ -1165,13 +1160,31 @@ SMESH_ComputeErrorPtr ComputePentahedralMesh(SMESH_Mesh & aMesh, err = aPrism3D->GetComputeError(); } } + if ( !bOK && proxyMesh ) + { + // check if VL elements are present on block FACEs + bool hasVLonFace = false; + for ( TopExp_Explorer exp( aShape, TopAbs_FACE ); exp.More(); exp.Next() ) + { + const SMESHDS_SubMesh* sm1 = aMesh.GetSubMesh( exp.Current() )->GetSubMeshDS(); + const SMESHDS_SubMesh* sm2 = proxyMesh->GetSubMesh( exp.Current() ); + if (( hasVLonFace = ( sm2 && sm1->NbElements() != sm2->NbElements() ))) + break; + } + if ( hasVLonFace ) + { + err->myName = COMPERR_BAD_INPUT_MESH; + err->myComment = "Can't build pentahedral mesh on viscous layers"; + } + } + return err; } //======================================================================= //function : EvaluatePentahedralMesh -//purpose : +//purpose : //======================================================================= bool EvaluatePentahedralMesh(SMESH_Mesh & aMesh, diff --git a/src/StdMeshers/StdMeshers_ViscousLayers.cxx b/src/StdMeshers/StdMeshers_ViscousLayers.cxx index 4ed66607a..fa4853668 100644 --- a/src/StdMeshers/StdMeshers_ViscousLayers.cxx +++ b/src/StdMeshers/StdMeshers_ViscousLayers.cxx @@ -101,7 +101,9 @@ #include #ifdef _DEBUG_ +#ifndef WIN32 #define __myDEBUG +#endif //#define __NOT_INVALIDATE_BAD_SMOOTH //#define __NODES_AT_POS #endif @@ -2775,13 +2777,12 @@ bool _ViscousBuilder::makeLayer(_SolidData& data) if ( !setEdgeData( *edge, edgesByGeom[ shapeID ], helper, data )) return false; - if ( edge->_nodes.size() < 2 ) - edge->Block( data ); - //data._noShrinkShapes.insert( shapeID ); + if ( edge->_nodes.size() < 2 && !noShrink ) + edge->Block( data ); // a sole node is moved only if noShrink } dumpMove(edge->_nodes.back()); - if ( edge->_cosin > faceMaxCosin && !edge->Is( _LayerEdge::BLOCKED )) + if ( edge->_cosin > faceMaxCosin && edge->_nodes.size() > 1 ) { faceMaxCosin = edge->_cosin; maxCosinEdge = edge; @@ -3905,7 +3906,7 @@ bool _ViscousBuilder::setEdgeData(_LayerEdge& edge, getMeshDS()->SetNodeOnFace( tgtNode, TopoDS::Face( eos._sWOL ), uv.X(), uv.Y() ); } - if ( edge._nodes.size() > 1 ) + //if ( edge._nodes.size() > 1 ) -- allow RISKY_SWOL on noShrink shape { // check if an angle between a FACE with layers and SWOL is sharp, // else the edge should not inflate @@ -3920,8 +3921,11 @@ bool _ViscousBuilder::setEdgeData(_LayerEdge& edge, geomNorm.Reverse(); // inside the SOLID if ( geomNorm * edge._normal < -0.001 ) { - getMeshDS()->RemoveFreeNode( tgtNode, 0, /*fromGroups=*/false ); - edge._nodes.resize( 1 ); + if ( edge._nodes.size() > 1 ) + { + getMeshDS()->RemoveFreeNode( tgtNode, 0, /*fromGroups=*/false ); + edge._nodes.resize( 1 ); + } } else if ( realLenFactor > 3 ) /// -- moved to SetCosin() //else if ( edge._lenFactor > 3 ) @@ -4739,7 +4743,7 @@ void _ViscousBuilder::computeGeomSize( _SolidData& data ) double thinkness = eos._hyp.GetTotalThickness(); for ( size_t i = 0; i < eos._edges.size(); ++i ) { - if ( eos._edges[i]->Is( _LayerEdge::BLOCKED )) continue; + if ( eos._edges[i]->_nodes.size() < 2 ) continue; eos._edges[i]->SetMaxLen( thinkness ); eos._edges[i]->FindIntersection( *searcher, intersecDist, data._epsilon, eos, &face ); if ( intersecDist > 0 && face ) @@ -4930,7 +4934,7 @@ bool _ViscousBuilder::inflate(_SolidData& data) if ( eos._edges[i]->_nodes.size() > 1 ) avgThick += Min( 1., eos._edges[i]->_len / shapeTgtThick ); else - avgThick += shapeTgtThick; + avgThick += 1; nbActiveEdges += ( ! eos._edges[i]->Is( _LayerEdge::BLOCKED )); } } @@ -5444,8 +5448,11 @@ bool _ViscousBuilder::smoothAndCheck(_SolidData& data, // intersection not ignored - if ( toBlockInfaltion && - dist < ( eos._edges[i]->_len * theThickToIntersection )) + double minDist = 0; + if ( eos._edges[i]->_maxLen < 0.99 * eos._hyp.GetTotalThickness() ) // limited length + minDist = eos._edges[i]->_len * theThickToIntersection; + + if ( toBlockInfaltion && dist < minDist ) { if ( is1stBlocked ) { is1stBlocked = false; // debug dumpFunction(SMESH_Comment("blockIntersected") <setXYZ( newPos.X(), newPos.Y(), newPos.Z() ); dumpMove( tgtNode ); - SMDS_FacePositionPtr pos = tgtNode->GetPosition(); - pos->SetUParameter( newUV.X() ); - pos->SetVParameter( newUV.Y() ); + if ( SMDS_FacePositionPtr pos = tgtNode->GetPosition() ) // NULL if F is noShrink + { + pos->SetUParameter( newUV.X() ); + pos->SetVParameter( newUV.Y() ); + } gp_XYZ newUV0( newUV.X(), newUV.Y(), 0 ); @@ -6304,10 +6313,11 @@ bool _Smoother1D::smoothAnalyticEdge( _SolidData& data, tgtNode->setXYZ( newPos.X(), newPos.Y(), newPos.Z() ); dumpMove( tgtNode ); - SMDS_FacePositionPtr pos = tgtNode->GetPosition(); - pos->SetUParameter( newUV.X() ); - pos->SetVParameter( newUV.Y() ); - + if ( SMDS_FacePositionPtr pos = tgtNode->GetPosition() ) // NULL if F is noShrink + { + pos->SetUParameter( newUV.X() ); + pos->SetVParameter( newUV.Y() ); + } _eos[i]->Set( _LayerEdge::SMOOTHED ); // to check in refine() (IPAL54237) } } @@ -6939,14 +6949,14 @@ void _SolidData::PrepareEdgesToSmoothOnFace( _EdgesOnShape* eos, bool substitute eos->_edgeForOffset = 0; double maxCosin = -1; - bool hasNoShrink = false; + //bool hasNoShrink = false; for ( TopExp_Explorer eExp( eos->_shape, TopAbs_EDGE ); eExp.More(); eExp.Next() ) { _EdgesOnShape* eoe = GetShapeEdges( eExp.Current() ); if ( !eoe || eoe->_edges.empty() ) continue; - if ( eos->GetData()._noShrinkShapes.count( eoe->_shapeID )) - hasNoShrink = true; + // if ( eos->GetData()._noShrinkShapes.count( eoe->_shapeID )) + // hasNoShrink = true; vector<_LayerEdge*>& eE = eoe->_edges; _LayerEdge* e = eE[ eE.size() / 2 ]; @@ -6984,8 +6994,8 @@ void _SolidData::PrepareEdgesToSmoothOnFace( _EdgesOnShape* eos, bool substitute // Try to initialize _Mapper2D - if ( hasNoShrink ) - return; + // if ( hasNoShrink ) + // return; SMDS_ElemIteratorPtr fIt = eos->_subMesh->GetSubMeshDS()->GetElements(); if ( !fIt->more() || fIt->next()->NbCornerNodes() != 4 ) @@ -10841,12 +10851,20 @@ namespace VISCOUS_3D std::vector< SMESH_NodeXYZ > _nodes; TopAbs_ShapeEnum _vertSWOLType[2]; // shrink part includes VERTEXes AverageHyp* _vertHyp[2]; + double _edgeWOLLen[2]; // length of wol EDGE + double _tol; // to compare _edgeWOLLen's BndPart(): _isShrink(0), _isReverse(0), _nbSegments(0), _hyp(0), - _vertSWOLType{ TopAbs_WIRE, TopAbs_WIRE }, _vertHyp{ 0, 0 } + _vertSWOLType{ TopAbs_WIRE, TopAbs_WIRE }, _vertHyp{ 0, 0 }, _edgeWOLLen{ 0., 0.} {} + bool IsEqualLengthEWOL( const BndPart& other ) const + { + return ( std::abs( _edgeWOLLen[0] - other._edgeWOLLen[0] ) < _tol && + std::abs( _edgeWOLLen[1] - other._edgeWOLLen[1] ) < _tol ); + } + bool operator==( const BndPart& other ) const { return ( _isShrink == other._isShrink && @@ -10857,7 +10875,8 @@ namespace VISCOUS_3D (( !_isShrink ) || ( *_hyp == *other._hyp && vertHyp1() == other.vertHyp1() && - vertHyp2() == other.vertHyp2() )) + vertHyp2() == other.vertHyp2() && + IsEqualLengthEWOL( other ))) ); } bool CanAppend( const BndPart& other ) @@ -10875,10 +10894,12 @@ namespace VISCOUS_3D bool hasCommonNode = ( _nodes.back()->GetID() == other._nodes.front()->GetID() ); _nodes.insert( _nodes.end(), other._nodes.begin() + hasCommonNode, other._nodes.end() ); _vertSWOLType[1] = other._vertSWOLType[1]; - if ( _isShrink ) - _vertHyp[1] = other._vertHyp[1]; + if ( _isShrink ) { + _vertHyp[1] = other._vertHyp[1]; + _edgeWOLLen[1] = other._edgeWOLLen[1]; + } } - const SMDS_MeshNode* Node(size_t i) const + const SMDS_MeshNode* Node(size_t i) const { return _nodes[ _isReverse ? ( _nodes.size() - 1 - i ) : i ]._node; } @@ -11026,6 +11047,11 @@ namespace VISCOUS_3D for ( int iE = 0; iE < nbEdgesInWire.front(); ++iE ) { BndPart bndPart; + + std::vector nodes = fSide.GetOrderedNodes( iE ); + bndPart._nodes.assign( nodes.begin(), nodes.end() ); + bndPart._nbSegments = bndPart._nodes.size() - 1; + _EdgesOnShape* eos = _data1->GetShapeEdges( fSide.EdgeID( iE )); bndPart._isShrink = ( eos->SWOLType() == TopAbs_FACE ); @@ -11054,10 +11080,14 @@ namespace VISCOUS_3D bndPart._vertSWOLType[iV] = eov[iV]->SWOLType(); } } + bndPart._edgeWOLLen[0] = fSide.EdgeLength( iE - 1 ); + bndPart._edgeWOLLen[1] = fSide.EdgeLength( iE + 1 ); + + bndPart._tol = std::numeric_limits::max(); // tolerance by segment size + for ( size_t i = 1; i < bndPart._nodes.size(); ++i ) + bndPart._tol = Min( bndPart._tol, + ( bndPart._nodes[i-1] - bndPart._nodes[i] ).SquareModulus() ); } - std::vector nodes = fSide.GetOrderedNodes( iE ); - bndPart._nodes.assign( nodes.begin(), nodes.end() ); - bndPart._nbSegments = bndPart._nodes.size() - 1; if ( _boundary.empty() || ! _boundary.back().CanAppend( bndPart )) _boundary.push_back( bndPart ); @@ -11164,6 +11194,9 @@ namespace VISCOUS_3D } SMESHDS_Mesh* meshDS = dataSrc->GetHelper().GetMeshDS(); + dumpFunction(SMESH_Comment("periodicMoveNodes_F") + << _shriFace[iSrc]->_subMesh->GetId() << "_F" + << _shriFace[iTgt]->_subMesh->GetId() ); TNode2Edge::iterator n2e; TNodeNodeMap::iterator n2n = _nnMap.begin(); for ( ; n2n != _nnMap.end(); ++n2n ) @@ -11193,6 +11226,8 @@ namespace VISCOUS_3D SMESH_NodeXYZ pSrc = leSrc->_nodes[ iN ]; gp_XYZ pTgt = trsf->Transform( pSrc ); meshDS->MoveNode( leTgt->_nodes[ iN ], pTgt.X(), pTgt.Y(), pTgt.Z() ); + + dumpMove( leTgt->_nodes[ iN ]); } } } @@ -11201,6 +11236,7 @@ namespace VISCOUS_3D << _shriFace[iSrc]->_subMesh->GetId() << " -> " << _shriFace[iTgt]->_subMesh->GetId() << " -- " << ( done ? "DONE" : "FAIL")); + dumpFunctionEnd(); return done; } @@ -11735,6 +11771,8 @@ bool _ViscousBuilder::shrink(_SolidData& theData) { _EdgesOnShape& eos = * subEOS[ iS ]; if ( eos.ShapeType() != TopAbs_EDGE ) continue; + if ( eos.size() == 0 ) + continue; const TopoDS_Edge& E = TopoDS::Edge( eos._shape ); data.SortOnEdge( E, eos._edges ); @@ -11757,8 +11795,8 @@ bool _ViscousBuilder::shrink(_SolidData& theData) uvPtVec[ i ].param = helper.GetNodeU( E, edges[i]->_nodes[0] ); uvPtVec[ i ].SetUV( helper.GetNodeUV( F, edges[i]->_nodes.back() )); } - if ( edges.empty() ) - continue; + // if ( edges.empty() ) + // continue; BRep_Tool::Range( E, uvPtVec[0].param, uvPtVec.back().param ); StdMeshers_FaceSide fSide( uvPtVec, F, E, _mesh ); StdMeshers_ViscousLayers2D::SetProxyMeshOfEdge( fSide );