From 5b3023e6cb8002da05c9cbd36fac7ce1b67bc461 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 3 Feb 2016 14:43:37 +0300 Subject: [PATCH] Enable splitting bi-quad quadrangles by QuadToTri() --- src/Controls/SMESH_Controls.cxx | 13 +++++----- src/SMESH/SMESH_MeshEditor.cxx | 41 ++++++++++-------------------- src/SMESH_I/SMESH_MeshEditor_i.cxx | 2 +- 3 files changed, 20 insertions(+), 36 deletions(-) diff --git a/src/Controls/SMESH_Controls.cxx b/src/Controls/SMESH_Controls.cxx index 3f612a24f..0623399e9 100644 --- a/src/Controls/SMESH_Controls.cxx +++ b/src/Controls/SMESH_Controls.cxx @@ -3212,14 +3212,13 @@ bool RangeOfIds::SetRangeStr( const TCollection_AsciiString& theStr ) myIds.Clear(); TCollection_AsciiString aStr = theStr; - //aStr.RemoveAll( ' ' ); - //aStr.RemoveAll( '\t' ); for ( int i = 1; i <= aStr.Length(); ++i ) - if ( isspace( aStr.Value( i ))) - aStr.SetValue( i, ','); - - for ( int aPos = aStr.Search( ",," ); aPos != -1; aPos = aStr.Search( ",," ) ) - aStr.Remove( aPos, 1 ); + { + char c = aStr.Value( i ); + if ( !isdigit( c ) && c != ',' && c != '-' ) + aStr.SetValue( i, ' '); + } + aStr.RemoveAll( ' ' ); TCollection_AsciiString tmpStr = aStr.Token( ",", 1 ); int i = 1; diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 79ecf615d..0f2f1ad71 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -2979,7 +2979,7 @@ bool SMESH_MeshEditor::QuadToTri (TIDSortedElemSet & theElems, // Quadratic quadrangle - else if ( elem->NbNodes() == 8 ) + else if ( elem->NbNodes() >= 8 ) { // get surface elem is on int aShapeId = FindShape( elem ); @@ -2996,49 +2996,34 @@ bool SMESH_MeshEditor::QuadToTri (TIDSortedElemSet & theElems, } } - const SMDS_MeshNode* aNodes [8]; + const SMDS_MeshNode* aNodes [9]; aNodes[8] = 0; SMDS_ElemIteratorPtr itN = elem->nodesIterator(); for ( int i = 0; itN->more(); ++i ) aNodes[ i ] = static_cast( itN->next() ); - const SMDS_MeshNode* inFaceNode = 0; - if ( helper.GetNodeUVneedInFaceNode() ) - for ( int i = 0; i < 8 && !inFaceNode; ++i ) - if ( aNodes[ i ]->GetPosition()->GetTypeOfPosition() == SMDS_TOP_FACE ) - inFaceNode = aNodes[ i ]; - - // find middle point for (0,1,2,3) - // and create a node in this point; - gp_XYZ p( 0,0,0 ); - if ( surface.IsNull() ) { - for ( int i = 0; i < 4; i++ ) p += SMESH_TNodeXYZ( aNodes[i] ); - p /= 4; - } - else { - TopoDS_Face geomFace = TopoDS::Face( helper.GetSubShape() ); - gp_XY uv( 0,0 ); - for ( int i = 0; i < 4; i++ ) - uv += helper.GetNodeUV( geomFace, aNodes[i], inFaceNode ); - uv /= 4.; - p = surface->Value( uv.X(), uv.Y() ).XYZ(); + const SMDS_MeshNode* centrNode = aNodes[8]; + if ( centrNode == 0 ) + { + centrNode = helper.GetCentralNode( aNodes[0], aNodes[1], aNodes[2], aNodes[3], + aNodes[4], aNodes[5], aNodes[6], aNodes[7], + surface.IsNull() ); + myLastCreatedNodes.Append(centrNode); } - const SMDS_MeshNode* newN = aMesh->AddNode( p.X(), p.Y(), p.Z() ); - myLastCreatedNodes.Append(newN); // create a new element const SMDS_MeshElement* newElem1 = 0; const SMDS_MeshElement* newElem2 = 0; if ( the13Diag ) { newElem1 = aMesh->AddFace(aNodes[2], aNodes[3], aNodes[0], - aNodes[6], aNodes[7], newN ); + aNodes[6], aNodes[7], centrNode ); newElem2 = aMesh->AddFace(aNodes[2], aNodes[0], aNodes[1], - newN, aNodes[4], aNodes[5] ); + centrNode, aNodes[4], aNodes[5] ); } else { newElem1 = aMesh->AddFace(aNodes[3], aNodes[0], aNodes[1], - aNodes[7], aNodes[4], newN ); + aNodes[7], aNodes[4], centrNode ); newElem2 = aMesh->AddFace(aNodes[3], aNodes[1], aNodes[2], - newN, aNodes[5], aNodes[6] ); + centrNode, aNodes[5], aNodes[6] ); } myLastCreatedElems.Append(newElem1); myLastCreatedElems.Append(newElem2); diff --git a/src/SMESH_I/SMESH_MeshEditor_i.cxx b/src/SMESH_I/SMESH_MeshEditor_i.cxx index f31e583eb..bd08f9d67 100644 --- a/src/SMESH_I/SMESH_MeshEditor_i.cxx +++ b/src/SMESH_I/SMESH_MeshEditor_i.cxx @@ -5304,7 +5304,7 @@ bool SMESH_MeshEditor_i::idSourceToSet(SMESH::SMESH_IDSource_ptr theIDSource, { if ( error ) *error = IDSource_OK; - if ( CORBA::is_nil( theIDSource ) ) + if ( CORBA::is_nil( theIDSource )) { if ( error ) *error = IDSource_INVALID; return false; -- 2.39.2