From: vsr Date: Fri, 21 Feb 2020 12:13:04 +0000 (+0300) Subject: Merge branch 'occ/shaper2smesh' X-Git-Tag: V9_5_0a1~5 X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=commitdiff_plain;h=6472eab132825fec572beda8276947593f85ffa1 Merge branch 'occ/shaper2smesh' --- 6472eab132825fec572beda8276947593f85ffa1 diff --cc resources/CMakeLists.txt index d0d99adcb,9a122695a..405c626f7 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@@ -180,63 -100,141 +180,64 @@@ SET(SMESH_RESOURCES_FILE mesh_tree_algo_hexa.png mesh_tree_algo_mefisto.png mesh_tree_algo_polygon.png - mesh_tree_algo.png - mesh_tree_algo_0D.png + mesh_tree_algo_prism.png + mesh_tree_algo_projection_2d.png mesh_tree_algo_quad.png + mesh_tree_algo_radial_prism.png + mesh_tree_algo_radial_quadrangle_1D2D.png mesh_tree_algo_regular.png mesh_tree_algo_tetra.png + mesh_tree_group.png + mesh_tree_group_on_filter.png + mesh_tree_hypo.png mesh_tree_hypo_area.png + mesh_tree_hypo_cartesian.png + mesh_tree_hypo_import_source_1d.png + mesh_tree_hypo_import_source_2d.png + mesh_tree_hypo_layers_distribution.png + mesh_tree_hypo_layers_distribution_2d.png mesh_tree_hypo_length.png - mesh_tree_hypo.png + mesh_tree_hypo_projection_2d.png + mesh_tree_hypo_projection_3d.png + mesh_tree_hypo_quadratic.png mesh_tree_hypo_segment.png + mesh_tree_hypo_source_3d_shape.png + mesh_tree_hypo_source_edge.png + mesh_tree_hypo_source_face.png + mesh_tree_hypo_viscous_layers.png mesh_tree_hypo_volume.png - mesh_tree_hypo_cartesian.png - mesh_tree_mesh.png mesh_tree_importedmesh.png - mesh_tree_mesh_warn.png + mesh_tree_mesh.png + mesh_tree_mesh_geom_modif.png + mesh_tree_mesh_partial.png + mesh_tree_mesh_warn.png + mesh_triangle.png mesh_triangle_n.png mesh_triquad_hexahedron.png - mesh_triangle.png + mesh_union2tri.png + mesh_unionGroups.png + mesh_uniontri.png mesh_update.png - mesh_vertex_n.png mesh_vertex.png - mesh_0D_elem.png - mesh_0D_on_all_nodes.png + mesh_vertex_n.png mesh_volume_3d.png - bare_border_volume.png - bare_border_face.png - over_constrained_volume.png - over_constrained_face.png + mesh_whatis.png mesh_wireframe.png - mesh_points.png mesh_wrap.png - mesh_group.png - mesh_tree_group.png - mesh_tree_group_on_filter.png - mesh_edit_group.png - mesh_make_group.png - mesh_groups_from_gemetry.png - mesh_union2tri.png - mesh_uniontri.png - mesh_cutquad.png - mesh_smoothing.png - mesh_renumbering_nodes.png - mesh_renumbering_elements.png - mesh_extrusion.png - mesh_extrusionpath.png - mesh_revolution.png - ModuleMesh.png - mesh_unionGroups.png - mesh_intersectGroups.png - mesh_cutGroups.png - mesh_deleteGroups.png - mesh_translation_vector.png - mesh_translation_points.png - mesh_rotation.png - mesh_symmetry_point.png - mesh_symmetry_axis.png - mesh_symmetry_plane.png - mesh_sew_freeborders.png - mesh_sew_conform_freeborders.png - mesh_sew_bordertoside.png - mesh_sew_sideelements.png - mesh_merge_nodes.png - mesh_merge_elements.png - select1.png open.png - mesh_pattern.png - mesh_pentahedron.png + over_constrained_face.png + over_constrained_volume.png pattern_sample_2d.png pattern_sample_3D.png - mesh_add.png - mesh_remove.png - mesh_quad_edge.png - mesh_quad_triangle.png - mesh_quad_quadrangle.png - mesh_quad_polygon.png - mesh_quad_tetrahedron.png - mesh_quad_pyramid.png - mesh_quad_pentahedron.png - mesh_quad_hexahedron.png - mesh_conv_to_quad.png - mesh_tree_hypo_layers_distribution.png - mesh_tree_algo_radial_prism.png - mesh_tree_algo_radial_quadrangle_1D2D.png - mesh_tree_algo_existing_2D.png - mesh_tree_algo_prism.png - mesh_tree_algo_projection_2d.png - mesh_hypo_source_edge.png - mesh_hypo_source_3d.png - mesh_hypo_layer_distribution.png - mesh_hypo_source_face.png - mesh_tree_hypo_source_face.png - mesh_tree_hypo_source_edge.png - mesh_tree_hypo_source_3d_shape.png - mesh_tree_hypo_projection_3d.png - mesh_tree_hypo_projection_2d.png - mesh_tree_hypo_quadratic.png - mesh_build_compound.png - copy_mesh.png - copy_mesh_with_geom.png - mesh_node_to_point.png - mesh_tree_mesh_partial.png - mesh_extractGroup.png - mesh_precompute.png - mesh_2d_from_3d.png - mesh_free_faces.png + reorient_faces_face.png + reorient_faces_point.png + reorient_faces_volume.png scale.png scale_along_axes.png - split_into_tetra.png + select1.png split_biquad.png - mesh_duplicate_nodes.png - mesh_duplicate_nodes_with_elem.png - mesh_duplicate_elem_only.png - mesh_duplicate_group_boundary.png - mesh_bounding_box.png - mesh_hypo_viscous_layers.png - mesh_tree_hypo_viscous_layers.png - mesh_min_dist.png - reorient_faces_point.png - reorient_faces_face.png - reorient_faces_volume.png - mesh_ball.png - mesh_measure_basic_props.png - mesh_measure_length.png - mesh_measure_area.png - mesh_measure_volume.png - mesh_extmeth_node_offset.png - mesh_extmeth_surf_offset_smooth.png - mesh_extmeth_face_offset.png - mesh_quality.png - mesh_show.png - mesh_hide.png - mesh_deflection.png - mesh_offset.png - mesh_face_groups_by_edges.png - mesh_angle_measure.png + split_into_tetra.png + standard_mesh_info.png ) INSTALL(FILES ${SMESH_RESOURCES_FILES} DESTINATION ${SALOME_SMESH_INSTALL_RES_DATA}) diff --cc src/SMESHGUI/SMESHGUI_MeshOp.cxx index 40fb8cb6c,36b530a39..ed9e8d63c --- a/src/SMESHGUI/SMESHGUI_MeshOp.cxx +++ b/src/SMESHGUI/SMESHGUI_MeshOp.cxx @@@ -1706,179 -1655,6 +1706,179 @@@ void SMESHGUI_MeshOp::onAlgoSelected( c return; } +//================================================================================ +/*! + * \brief Create a sub-mesh on internal edges in the case where the global algorithm + * is of type 1D-2D[-3D] so that the internal edges would remain not meshed. + */ +//================================================================================ + +void SMESHGUI_MeshOp::createSubMeshOnInternalEdges( SMESH::SMESH_Mesh_ptr theMesh, + GEOM::GEOM_Object_ptr theMainShape ) +{ + if ( theMesh->_is_nil() || theMainShape->_is_nil() ) + return; + + if ( isAccessibleDim( 1 )) + return; // global 1D algorithm is/can be assigned + + const HypothesesSet::SetType internSet = HypothesesSet::INTERN; + bool toCreate = true; + bool toCreateMandatory = ( myHypoSet && + myAverageSize > 0 && + ( myHypoSet->init( /*algo=*/ true, internSet ), myHypoSet->more()) && + ( myHypoSet->init( /*algo=*/false, internSet ), myHypoSet->more())); + if ( !toCreateMandatory ) // ask the user + toCreate = false; // can't pass both mesh and geometry to Create Submesh operation (so far?) + // toCreate = SUIT_MessageBox::warning( SMESHGUI::desktop(), + // QObject::tr("SMESH_WRN_WARNING"), + // QObject::tr("SMESH_CREATE_SUBMESH_ON_INTERNAL_EDGES"), + // QObject::tr("SMESH_BUT_YES"), + // QObject::tr("SMESH_BUT_NO"), 1, 0); + if ( !toCreate ) + return; + + TopoDS_Shape shape; + if ( !GEOMBase::GetShape( theMainShape, shape )) + return; + + std::vector< TopoDS_Shape > internalEdges; + for ( TopExp_Explorer edge( shape, TopAbs_EDGE, TopAbs_WIRE ); edge.More(); edge.Next() ) + internalEdges.push_back( edge.Current() ); + + if ( internalEdges.empty() ) + return; + + TopTools_IndexedMapOfShape shapeIDs; + TopExp::MapShapes( shape, shapeIDs ); + + std::set< int > intIDSet; + for ( size_t i = 0; i < internalEdges.size(); ++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; + + GEOM::GEOM_Object_var edgeGroup; + GEOM::GEOM_IShapesOperations_wrap sOp = geomGen->GetIShapesOperations(); + GEOM::GEOM_IGroupOperations_wrap gOp = geomGen->GetIGroupOperations(); + GEOM::ListOfGO_var geomGroups = sOp->GetExistingSubObjects( theMainShape, + /*groupsOnly=*/true ); + for ( CORBA::ULong i = 0; i < geomGroups->length(); ++i ) + { + GEOM::ListOfLong_var ids = gOp->GetObjects( geomGroups[ i ]); + std::set< int > idSet( & ids[0], & ids[0] + ids->length() ); + if ( idSet == intIDSet ) + { + edgeGroup = geomGroups[ i ]; + break; + } + } + + if ( edgeGroup->_is_nil() ) + { + GEOM::GEOM_Object_var edgeGroup = gOp->CreateGroup( theMainShape, TopAbs_EDGE ); + + GEOM::ListOfLong_var edgeIDs = new GEOM::ListOfLong; + edgeIDs->length( internalEdges.size() ); + std::set< int >::iterator id = intIDSet.begin(); + for ( size_t i = 0; i < intIDSet.size(); ++i, ++id ) + edgeIDs[ i ] = *id; + gOp->UnionIDs( edgeGroup, edgeIDs ); + + SALOMEDS::SObject_wrap so = geomGen->AddInStudy( edgeGroup, "Internal edges", theMainShape ); + } + + if ( !toCreateMandatory ) + { + // show Create Sub-mesh dislog + // _PTR(SObject) aMeshSO = SMESH::FindSObject( theMesh ); + // selectionMgr()->clearFilters(); + // selectObject( pSubmesh ); + // SMESHGUI::GetSMESHGUI()->switchToOperation( SMESHOp::OpEditMeshOrSubMesh ); + return; + } + + // create a sub-mesh using myAverageSize w/o GUI + + SMESH::SMESH_subMesh_var subMesh = theMesh->GetSubMesh( edgeGroup, "" ); + + for ( int isAlgo = 1; isAlgo >= 0; --isAlgo ) + for ( myHypoSet->init( isAlgo, internSet ); myHypoSet->more(); myHypoSet->next() ) + { + QString aHypoTypeName = myHypoSet->current(); + HypothesisData* aHypData = SMESH::GetHypothesisData( aHypoTypeName ); + if ( !aHypData ) + continue; + + myDim = aHypData->Dim[0]; + if ( myDim != 1 ) + continue; + + // create or/and set + SMESH::SMESH_Hypothesis_var newHypo; + if ( isAlgo ) + { + myAvailableHypData[ myDim ][ Algo ].clear(); + myAvailableHypData[ myDim ][ Algo ] << aHypData; + QStringList hypList; hypList << aHypoTypeName; + myDlg->tab( myDim )->setAvailableHyps( Algo, hypList ); + setCurrentHyp( myDim, Algo, 0 ); + newHypo = getAlgo( myDim ); + } + else + { + SMESH::HypInitParams params = { 2, myAverageSize, false }; + newHypo = getInitParamsHypothesis( aHypData->TypeName, aHypData->ServerLibName, & params ); + QString hypName = GetUniqueName( getHypoNames(), aHypData->Label ); + SALOMEDS::SObject_wrap so = + SMESHGUI::GetSMESHGen()->PublishInStudy( SALOMEDS::SObject::_nil(), newHypo, + hypName.toUtf8().data() ); + } + SMESH::AddHypothesisOnSubMesh( subMesh, newHypo ); + } + + return; +} + +//================================================================================ +/*! + * \brief Ask the user to enter an average size which will be used to create + * hypotheses of a hypo-set basing on this size + * \param [out] averageSize - average element size + * \return bool - false if the user canceled the dialog + */ +//================================================================================ + +bool SMESHGUI_MeshOp::getAverageSize( double & averageSize ) +{ + HypothesisData* hypData = SMESH::GetHypothesisData( "MaxLength" ); + if ( !hypData ) + return false; + + SMESH::SMESH_Hypothesis_var hyp = getInitParamsHypothesis( hypData->TypeName, + hypData->ServerLibName ); + if ( hyp->_is_nil() ) + return false; + + SMESHGUI_GenericHypothesisCreator* aCreator = SMESH::GetHypothesisCreator( hypData->TypeName ); + if ( !aCreator ) + return false; + + initHypCreator( aCreator ); + myDlg->setEnabled( false ); + + aCreator->edit( hyp.in(), HypothesesSet::getCommonHypoSetHypoType(), + dlg(), this, SLOT( onHypoEdited( int ))); + + StdMeshers::StdMeshers_MaxLength_var lenHyp = StdMeshers::StdMeshers_MaxLength::_narrow( hyp ); + if ( lenHyp->_is_nil() ) + return false; + + averageSize = lenHyp->GetLength(); + return true; +} + //================================================================================ /*! * \brief Creates and selects hypothesis of hypotheses set @@@ -2056,36 -1801,7 +2056,36 @@@ bool SMESHGUI_MeshOp::createMesh( QStri if ( !anAlgoVar->_is_nil() ) SMESH::AddHypothesisOnMesh( aMesh, anAlgoVar ); } + + + if ( myDlg->toCreateAllGroups() && !aGeomVar->_is_nil() ) + { + // 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::ListOfGO_var geomGroups = op->GetExistingSubObjects( aGeomVar, + /*groupsOnly=*/false ); + SMESH::SMESH_GroupOnGeom_var meshGroup; + for ( CORBA::ULong iG = 0; iG < geomGroups->length(); ++iG ) + { + SMESH::ElementType elemType = SMESHGUI_GroupOnShapeOp::ElementType( geomGroups[ iG ] ); + if ( elemType == SMESH::ALL ) + continue; + if ( elemType == SMESH::ELEM0D ) + elemType = SMESH::NODE; + + CORBA::String_var name = geomGroups[ iG ]->GetName(); + meshGroup = aMesh->CreateGroupFromGEOM( elemType, name, geomGroups[ iG ]); + // if ( elemType != SMESH::NODE ) + // meshGroup = aMesh->CreateGroupFromGEOM( SMESH::NODE, name, geomGroups[ iG ]); + } + } + + createSubMeshOnInternalEdges( aMesh, aGeomVar ); + } + return true; } @@@ -2138,11 -1854,11 +2138,11 @@@ bool SMESHGUI_MeshOp::createSubMesh( QS else if (aGEOMs.count() > 1) { // create a GEOM group - GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen(); - if (!geomGen->_is_nil()) { - GEOM::GEOM_IGroupOperations_wrap op = - geomGen->GetIGroupOperations(); - if (!op->_is_nil()) { - GEOM::GEOM_Gen_var geomGen = SMESH::GetGEOMGen( mainGeom ); ++ GEOM::GEOM_Gen_var geomGen = mainGeom->GetGen(); + if ( !geomGen->_is_nil() ) { + GEOM::GEOM_IGroupOperations_ptr op = geomGen->GetIGroupOperations(); + if ( !op->_is_nil() ) + { // check and add all selected GEOM objects: they must be // a sub-shapes of the main GEOM and must be of one type int iSubSh = 0;