Skip to content
Snippets Groups Projects
Commit 611f2477 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

generalize previous fix
parent 8cd426c1
No related branches found
No related tags found
No related merge requests found
// $Id: GeoUtils.cpp,v 1.11 2006-04-16 02:42:23 geuzaine Exp $ // $Id: GeoUtils.cpp,v 1.12 2006-04-16 03:27:30 geuzaine Exp $
// //
// Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2006 C. Geuzaine, J.-F. Remacle
// //
...@@ -43,27 +43,36 @@ void sortEdgesInLoop(int num, List_T *edges) ...@@ -43,27 +43,36 @@ void sortEdgesInLoop(int num, List_T *edges)
List_Read(edges, i, &j); List_Read(edges, i, &j);
if((c = FindCurve(j, THEM))){ if((c = FindCurve(j, THEM))){
List_Add(temp, &c); List_Add(temp, &c);
// FIXME: if the loop is composed of a single curve and if the if(c->Typ == MSH_SEGM_DISCRETE){
// curve is already discretized, we check if the first vertex // fill-in vertices in reverse discrete curves
// and the last vertex are the same. If not, we assume that they if(c->Num < 0 && !List_Nbr(c->Vertices)){
// should, and we add the missing end vertex. (This situation Curve *rc = FindCurve(-c->Num, THEM);
// can arise due to a limitation in Read_Mesh, where we do a if(rc)
// List_Insert() to add the vertices in discrete curves--so that for(int k = List_Nbr(rc->Vertices) - 1; k >= 0; k--)
// we never get the last vertex for single, closed curves.) List_Add(c->Vertices, List_Pointer(rc->Vertices, k));
if(c->Typ == MSH_SEGM_DISCRETE && nbEdges == 1 && List_Nbr(c->Vertices)){ }
Vertex *first = *(Vertex**)List_Pointer(c->Vertices, 0); // if the loop is composed of a single discrete curve we check
Vertex *last = *(Vertex**)List_Pointer(c->Vertices, List_Nbr(c->Vertices) - 1); // if the first vertex and the last vertex are the same. If
if(first != last){ // not, we assume that they should, and we add the missing end
Msg(INFO, "Adding last vertex in closed discrete curve %d", c->Num); // vertex. (This situation can arise due to a limitation in
List_Add(c->Vertices, &first); // Read_Mesh, where we do a List_Insert() to add the vertices
// in discrete curves--so that we never get the last vertex
// for single, closed curves.)
if(nbEdges == 1 && List_Nbr(c->Vertices)){
Vertex *first = *(Vertex**)List_Pointer(c->Vertices, 0);
Vertex *last = *(Vertex**)List_Pointer(c->Vertices, List_Nbr(c->Vertices) - 1);
if(first != last){
Msg(INFO, "Adding last vertex in closed discrete curve %d", c->Num);
List_Add(c->Vertices, &first);
}
}
// setting end points for discrete curves
if(!c->beg && !c->end && List_Nbr(c->Vertices)){
Vertex *first = *(Vertex**)List_Pointer(c->Vertices, 0);
Vertex *last = *(Vertex**)List_Pointer(c->Vertices, List_Nbr(c->Vertices) - 1);
c->beg = FindPoint(first->Num, THEM);
c->end = FindPoint(last->Num, THEM);
} }
}
// setting end points for discrete curves
if(c->Typ == MSH_SEGM_DISCRETE && !c->beg && !c->end && List_Nbr(c->Vertices)){
Vertex *first = *(Vertex**)List_Pointer(c->Vertices, 0);
Vertex *last = *(Vertex**)List_Pointer(c->Vertices, List_Nbr(c->Vertices) - 1);
c->beg = FindPoint(first->Num, THEM);
c->end = FindPoint(last->Num, THEM);
} }
} }
else else
......
...@@ -16,5 +16,5 @@ Line(1)={1,2}; ...@@ -16,5 +16,5 @@ Line(1)={1,2};
Line(2)={2,3}; Line(2)={2,3};
Line(3)={3,4}; Line(3)={3,4};
Line Loop(1) = {1,2,3,4}; Line Loop(1) = {1,2,3,-4};
Plane Surface(1) = {1}; Plane Surface(1) = {1};
...@@ -8,6 +8,6 @@ $ELM ...@@ -8,6 +8,6 @@ $ELM
4 4
1 15 1 1 1 1 1 15 1 1 1 1
4 15 4 4 1 4 4 15 4 4 1 4
10 1 4 4 2 4 5 10 1 4 4 2 1 5
11 1 4 4 2 5 1 11 1 4 4 2 5 4
$ENDELM $ENDELM
...@@ -6,6 +6,6 @@ $NOD ...@@ -6,6 +6,6 @@ $NOD
$ENDNOD $ENDNOD
$ELM $ELM
2 2
10 1 4 4 2 4 5 10 1 4 4 2 1 5
11 1 4 4 2 5 1 11 1 4 4 2 5 4
$ENDELM $ENDELM
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment