From 524a42c02b8ed8ffbf23da7b4ef6090685318b88 Mon Sep 17 00:00:00 2001 From: vsr Date: Thu, 22 Nov 2012 12:47:57 +0000 Subject: [PATCH] 0021993: EDF SMESH : Crash during extrusion of a mesh along a path --- src/SMESH/SMESH_MeshEditor.cxx | 56 +++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 15 deletions(-) diff --git a/src/SMESH/SMESH_MeshEditor.cxx b/src/SMESH/SMESH_MeshEditor.cxx index 191d7a4b3..f0d6a2c45 100644 --- a/src/SMESH/SMESH_MeshEditor.cxx +++ b/src/SMESH/SMESH_MeshEditor.cxx @@ -5173,10 +5173,16 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements, if ( BRep_Tool::Degenerated( aTrackEdge ) ) return EXTR_BAD_PATH_SHAPE; TopExp::Vertices( aTrackEdge, aV1, aV2 ); - aItN = theTrack->GetSubMesh( aV1 )->GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode* aN1 = aItN->next(); - aItN = theTrack->GetSubMesh( aV2 )->GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode* aN2 = aItN->next(); + const SMDS_MeshNode* aN1 = 0; + const SMDS_MeshNode* aN2 = 0; + if ( theTrack->GetSubMesh( aV1 ) && theTrack->GetSubMesh( aV1 )->GetSubMeshDS() ) { + aItN = theTrack->GetSubMesh( aV1 )->GetSubMeshDS()->GetNodes(); + aN1 = aItN->next(); + } + if ( theTrack->GetSubMesh( aV2 ) && theTrack->GetSubMesh( aV2 )->GetSubMeshDS() ) { + aItN = theTrack->GetSubMesh( aV2 )->GetSubMeshDS()->GetNodes(); + aN2 = aItN->next(); + } // starting node must be aN1 or aN2 if ( !( aN1 == theN1 || aN2 == theN1 ) ) return EXTR_BAD_STARTING_NODE; @@ -5206,7 +5212,7 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements, } } list< list > LLPPs; - int startNid = theN1->GetID(); + TopoDS_Vertex aVprev; TColStd_MapOfInteger UsedNums; int NbEdges = Edges.Length(); int i = 1; @@ -5220,13 +5226,33 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements, SMESH_subMesh* locTrack = *itLSM; SMESHDS_SubMesh* locMeshDS = locTrack->GetSubMeshDS(); TopExp::Vertices( aTrackEdge, aV1, aV2 ); - aItN = locTrack->GetFather()->GetSubMesh(aV1)->GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode* aN1 = aItN->next(); - aItN = locTrack->GetFather()->GetSubMesh(aV2)->GetSubMeshDS()->GetNodes(); - const SMDS_MeshNode* aN2 = aItN->next(); - // starting node must be aN1 or aN2 - if ( !( aN1->GetID() == startNid || aN2->GetID() == startNid ) ) continue; - // 2. Collect parameters on the track edge + bool aN1isOK = false, aN2isOK = false; + if ( aVprev.IsNull() ) { + // if previous vertex is not yet defined, it means that we in the beginning of wire + // and we have to find initial vertex corresponding to starting node theN1 + const SMDS_MeshNode* aN1 = 0; + const SMDS_MeshNode* aN2 = 0; + + if ( locTrack->GetFather()->GetSubMesh(aV1) && locTrack->GetFather()->GetSubMesh(aV1)->GetSubMeshDS() ) { + aItN = locTrack->GetFather()->GetSubMesh(aV1)->GetSubMeshDS()->GetNodes(); + aN1 = aItN->next(); + } + if ( locTrack->GetFather()->GetSubMesh(aV2) && locTrack->GetFather()->GetSubMesh(aV2)->GetSubMeshDS() ) { + aItN = locTrack->GetFather()->GetSubMesh(aV2)->GetSubMeshDS()->GetNodes(); + aN2 = aItN->next(); + } + // starting node must be aN1 or aN2 + aN1isOK = aN1 && aN1->GetID() == theN1->GetID(); + aN2isOK = aN2 && aN2->GetID() == theN1->GetID(); + } + else { + // we have specified ending vertex of the previous edge on the previous iteration + // and we have just to check that it corresponds to any vertex in current segment + aN1isOK = aVprev.IsSame( aV1 ); + aN2isOK = aVprev.IsSame( aV2 ); + } + if ( !aN1isOK && !aN2isOK ) continue; + // 2. Collect parameters on the track edge aPrms.clear(); aItN = locMeshDS->GetNodes(); while ( aItN->more() ) { @@ -5238,12 +5264,12 @@ SMESH_MeshEditor::ExtrusionAlongTrack (TIDSortedElemSet & theElements, } list LPP; //Extrusion_Error err = - MakeEdgePathPoints(aPrms, aTrackEdge,(aN1->GetID()==startNid), LPP); + MakeEdgePathPoints(aPrms, aTrackEdge, aN1isOK, LPP); LLPPs.push_back(LPP); UsedNums.Add(k); // update startN for search following egde - if( aN1->GetID() == startNid ) startNid = aN2->GetID(); - else startNid = aN1->GetID(); + if ( aN1isOK ) aVprev = aV2; + else aVprev = aV1; break; } } -- 2.39.2