From: eap Date: Wed, 26 Apr 2006 12:17:48 +0000 (+0000) Subject: Add ConvertFromQuadratic() X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=3b932ed49d239d0b65279cdf91d16fa66906b41f;p=modules%2Fsmesh.git Add ConvertFromQuadratic() --- diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 8ac703787..ec4331f59 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -6023,6 +6023,62 @@ void SMESH_MeshEditor::ConvertToQuadratic(const bool theForce3d) delete aHelper; } +//======================================================================= +//function : ConvertFromQuadratic +//purpose : +//======================================================================= +bool SMESH_MeshEditor::ConvertFromQuadratic() +{ + SMESHDS_Mesh* meshDS = GetMeshDS(); + SMDS_ElemIteratorPtr aElemItr = meshDS->elementsIterator(); + while(aElemItr->more()) + { + const SMDS_MeshElement* elem = aElemItr->next(); + if(elem) + { + if(!elem->IsQuadratic()) + continue; + + int id = elem->GetID(); + + int nbNodes = elem->NbNodes(); + vector aNds (nbNodes); + + for(int i = 0; i < nbNodes; i++) + { + const SMDS_MeshNode* n = elem->GetNode(i); + if( elem->IsMediumNode( n ) ) + meshDS->SMDS_Mesh::RemoveFreeElement( n ); + else + aNds[i] = n; + } + + SMDSAbs_ElementType aType = elem->GetType(); + RemoveElemFromGroups (elem, meshDS); + meshDS->SMDS_Mesh::RemoveFreeElement(elem); + + SMDS_MeshElement * NewElem = 0; + switch(aType) + { + case SMDSAbs_Edge: + NewElem = meshDS->AddEdgeWithID( ,id ); + break; + case SMDSAbs_Face: + if( nbNds==3 )NewElem = meshDS->AddFaceWithID( ,id ); + if( nbNds==4 )NewElem = meshDS->AddFaceWithID( ,id ); + break; + case SMDSAbs_Volume: + break; + default: + break; + } + + AddToSameGroups(NewElem, elem, meshDS); + } + } + return true; +} + //======================================================================= //function : SewSideElements //purpose : diff --git a/src/SMESH/SMESH_MeshEditor.hxx b/src/SMESH/SMESH_MeshEditor.hxx index 3c41fe01a..bd284c574 100644 --- a/src/SMESH/SMESH_MeshEditor.hxx +++ b/src/SMESH/SMESH_MeshEditor.hxx @@ -344,6 +344,11 @@ class SMESH_MeshEditor { //converts all mesh to quadratic one, deletes old elements, replacing //them with quadratic ones with the same id. + bool ConvertFromQuadratic(); + //converts all mesh from quadratic to ordinary ones, deletes old quadratic elements, replacing + //them with ordinary mesh elements with the same id. + + // static int SortQuadNodes (const SMDS_Mesh * theMesh, // int theNodeIds[] ); // // Set 4 nodes of a quadrangle face in a good order.