X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESH%2FSMESH_MeshEditor.cxx;h=d25f3321b85f28d6ce4bfc085a020542a76ef4f5;hp=fc554be484a9ace88e500120584735d23d33a633;hb=a4f4aea8461cff9a6cf72ff1704d7ca7d6a0f2b2;hpb=b0a908c0d20341651771d0249fb10882f54b2aad diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index fc554be48..d25f3321b 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -1174,7 +1174,7 @@ int SMESH_MeshEditor::Reorient2D (TIDSortedElemSet & theFaces, avoidSet.clear(); avoidSet.insert(theFace); - NLink link( theFace->GetNode( 0 ), 0 ); + NLink link( theFace->GetNode( 0 ), (SMDS_MeshNode *) 0 ); const int nbNodes = theFace->NbCornerNodes(); for ( int i = 0; i < nbNodes; ++i ) // loop on links of theFace @@ -1615,7 +1615,7 @@ namespace }; const int theHexTo4Prisms_FB[6*4+1] = // front-back { - 0, 3, 8, 1, 2, 9, 3, 7, 8, 2, 6, 9, 7, 4, 8, 6, 5, 9, 4, 0, 8, 5, 1, 9, -1 + 0, 3, 9, 1, 2, 8, 3, 7, 9, 2, 6, 8, 7, 4, 9, 6, 5, 8, 4, 0, 9, 5, 1, 8, -1 }; const int theHexTo2Prisms_BT_1[6*2+1] = @@ -2157,7 +2157,7 @@ void SMESH_MeshEditor::SplitVolumes (const TFacetOfElem & theElems, helper.SetIsQuadratic( false ); } vector nodes( volTool.GetNodes(), - volTool.GetNodes() + elem->NbCornerNodes() ); + volTool.GetNodes() + elem->NbNodes() ); helper.SetElementsOnShape( true ); if ( splitMethod._baryNode ) { @@ -6453,7 +6453,9 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens, // Sort existing groups by types and collect their names - // to store an old group and a generated new ones + // containers to store an old group and generated new ones; + // 1st new group is for result elems of different type than a source one; + // 2nd new group is for same type result elems ("top" group at extrusion) using boost::tuple; using boost::make_tuple; typedef tuple< SMESHDS_GroupBase*, SMESHDS_Group*, SMESHDS_Group* > TOldNewGroup; @@ -6483,6 +6485,11 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens, // Loop on nodes and elements to add them in new groups + // is there elements of different types generated from one source element; + // it is false for transformations and true for sweeping + bool isTwoTypesResult = false; + + vector< const SMDS_MeshElement* > resultElems; for ( int isNodes = 0; isNodes < 2; ++isNodes ) { const SMESH_SequenceOfElemPtr& gens = isNodes ? nodeGens : elemGens; @@ -6505,7 +6512,7 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens, continue; } // collect all elements made by the iElem-th sourceElem - list< const SMDS_MeshElement* > resultElems; + resultElems.clear(); if ( const SMDS_MeshElement* resElem = elems( iElem )) if ( resElem != sourceElem ) resultElems.push_back( resElem ); @@ -6523,12 +6530,12 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens, } else { - list< const SMDS_MeshElement* >::reverse_iterator resElemIt = resultElems.rbegin(); + vector< const SMDS_MeshElement* >::reverse_iterator resElemIt = resultElems.rbegin(); for ( ; resElemIt != resultElems.rend() ; ++resElemIt ) if ( (*resElemIt)->GetType() == sourceElem->GetType() ) { topElem = *resElemIt; - resultElems.erase( --(resElemIt.base()) ); // erase *resElemIt + *resElemIt = 0; // erase *resElemIt break; } } @@ -6542,15 +6549,19 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens, { // fill in a new group SMDS_MeshGroup & newGroup = gOldNew->get<1>()->SMDSGroup(); - list< const SMDS_MeshElement* >::iterator resLast = resultElems.end(), resElemIt; + vector< const SMDS_MeshElement* >::iterator resLast = resultElems.end(), resElemIt; for ( resElemIt = resultElems.begin(); resElemIt != resLast; ++resElemIt ) - newGroup.Add( *resElemIt ); + if ( *resElemIt ) + newGroup.Add( *resElemIt ); // fill a "top" group if ( topElem ) { SMDS_MeshGroup & newTopGroup = gOldNew->get<2>()->SMDSGroup(); newTopGroup.Add( topElem ); + + if ( !newGroup.IsEmpty() ) + isTwoTypesResult = true; } } } @@ -6565,7 +6576,6 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens, SMESHDS_GroupBase* oldGroupDS = orderedOldNewGroups[i]->get<0>(); SMESHDS_Group* newGroups[2] = { orderedOldNewGroups[i]->get<1>(), orderedOldNewGroups[i]->get<2>() }; - const int nbNewGroups = !newGroups[0]->IsEmpty() + !newGroups[1]->IsEmpty(); for ( int is2nd = 0; is2nd < 2; ++is2nd ) { SMESHDS_Group* newGroupDS = newGroups[ is2nd ]; @@ -6579,11 +6589,21 @@ SMESH_MeshEditor::generateGroups(const SMESH_SequenceOfElemPtr& nodeGens, newGroupDS->SetType( newGroupDS->GetElements()->next()->GetType() ); // make a name - const bool isTop = ( nbNewGroups == 2 && + const bool isTop = ( isTwoTypesResult && newGroupDS->GetType() == oldGroupDS->GetType() && is2nd ); string name = oldGroupDS->GetStoreName(); + { // remove trailing whitespaces (issue 22599) + size_t size = name.size(); + while ( size > 1 && isspace( name[ size-1 ])) + --size; + if ( size != name.size() ) + { + name.resize( size ); + oldGroupDS->SetStoreName( name.c_str() ); + } + } if ( !targetMesh ) { string suffix = ( isTop ? "top": postfix.c_str() ); name += "_"; @@ -8751,6 +8771,7 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d, const bool theT aHelper.SetIsQuadratic( true ); aHelper.SetIsBiQuadratic( theToBiQuad ); aHelper.SetElementsOnShape(true); + aHelper.ToFixNodeParameters( true ); // convert elements assigned to sub-meshes int nbCheckedElems = 0; @@ -10563,7 +10584,12 @@ double SMESH_MeshEditor::OrientedAngle(const gp_Pnt& p0, const gp_Pnt& p1, const gp_Vec v2(p0, g2); gp_Vec n1 = vref.Crossed(v1); gp_Vec n2 = vref.Crossed(v2); - return n2.AngleWithRef(n1, vref); + try { + return n2.AngleWithRef(n1, vref); + } + catch ( Standard_Failure ) { + } + return Max( v1.Magnitude(), v2.Magnitude() ); } /*! @@ -10576,13 +10602,16 @@ double SMESH_MeshEditor::OrientedAngle(const gp_Pnt& p0, const gp_Pnt& p1, const * If there is no shared faces between the group #n and the group #p in the list, the group j_n_p is not created. * All the flat elements are gathered into the group named "joints3D" (or "joints2D" in 2D situation). * The flat element of the multiple junctions between the simple junction are stored in a group named "jointsMultiples". - * @param theElems - list of groups of volumes, where a group of volume is a set of - * SMDS_MeshElements sorted by Id. - * @param createJointElems - if TRUE, create the elements - * @return TRUE if operation has been completed successfully, FALSE otherwise + * \param theElems - list of groups of volumes, where a group of volume is a set of + * SMDS_MeshElements sorted by Id. + * \param createJointElems - if TRUE, create the elements + * \param onAllBoundaries - if TRUE, the nodes and elements are also created on + * the boundary between \a theDomains and the rest mesh + * \return TRUE if operation has been completed successfully, FALSE otherwise */ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vector& theElems, - bool createJointElems) + bool createJointElems, + bool onAllBoundaries) { MESSAGE("----------------------------------------------"); MESSAGE("SMESH_MeshEditor::doubleNodesOnGroupBoundaries"); @@ -10611,15 +10640,20 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vector volume to modify) @@ -10648,7 +10682,7 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vectorgetVtkId(); @@ -10661,26 +10695,30 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vectorfromVtkToSmds(neighborsVtkIds[n]); const SMDS_MeshElement* elem = meshDS->FindElement(smdsId); - if (! domain.count(elem)) // neighbor is in another domain : face is shared + if (elem && ! domain.count(elem)) // neighbor is in another domain : face is shared { bool ok = false ; - for (int idombis = 0; idombis < theElems.size(); idombis++) // check if the neighbor belongs to another domain of the list + for (int idombis = 0; idombis < theElems.size() && !ok; idombis++) // check if the neighbor belongs to another domain of the list { // MESSAGE("Domain " << idombis); const TIDSortedElemSet& domainbis = theElems[idombis]; if ( domainbis.count(elem)) ok = true ; // neighbor is in a correct domain : face is kept } - if ( ok ) // the characteristics of the face is stored + if ( ok || onAllBoundaries ) // the characteristics of the face is stored { DownIdType face(downIds[n], downTypes[n]); - if (!faceDomains.count(face)) - faceDomains[face] = emptyMap; // create an empty entry for face if (!faceDomains[face].count(idom)) { faceDomains[face][idom] = vtkId; // volume associated to face in this domain celldom[vtkId] = idom; //MESSAGE(" cell with a border " << vtkId << " domain " << idom); } + if ( !ok ) + { + theRestDomElems.insert( elem ); + faceDomains[face][iRestDom] = neighborsVtkIds[n]; + celldom[neighborsVtkIds[n]] = iRestDom; + } } } } @@ -10694,14 +10732,14 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vector domvol = itface->second; + const std::map& domvol = itface->second; if (!domvol.count(idomain)) continue; DownIdType face = itface->first; @@ -10730,8 +10768,6 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vector > mutipleNodesToFace; // nodes multi domains with domain order to transform in Face (junction between 3 or more 2D domains) MESSAGE(".. Duplication of the nodes"); - for (int idomain = 0; idomain < theElems.size(); idomain++) + for (int idomain = idom0; idomain < nbDomains; idomain++) { itface = faceDomains.begin(); for (; itface != faceDomains.end(); ++itface) { - std::map domvol = itface->second; + const std::map& domvol = itface->second; if (!domvol.count(idomain)) continue; DownIdType face = itface->first; @@ -10770,15 +10806,12 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vector::iterator itdom = domvol.begin(); + std::map::const_iterator itdom = domvol.begin(); for (; itdom != domvol.end(); ++itdom) { int idom = itdom->first; @@ -10816,7 +10849,7 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vectorfromVtkToSmds(vtkVolIds[ivol]); SMDS_MeshElement* elem = (SMDS_MeshElement*)meshDS->FindElement(smdsId); - if (theElems[idom].count(elem)) + if (domain.count(elem)) { SMDS_VtkVolume* svol = dynamic_cast(elem); domvol[idom] = svol; @@ -11070,7 +11104,7 @@ bool SMESH_MeshEditor::DoubleNodesOnGroupBoundaries( const std::vector >::const_iterator itnod = nodeDomains.begin(); for (; itnod != nodeDomains.end(); ++itnod)