From 91fd43c14e8cfd9f0983a4dd464abc4c0eb3c4ea Mon Sep 17 00:00:00 2001 From: Jean-Francois Remacle <jean-francois.remacle@uclouvain.be> Date: Tue, 16 Jun 2009 14:30:54 +0000 Subject: [PATCH] allow multiple holes selection to define surfaces in the GUI --- Common/ListUtils.cpp | 17 +++++++++++++++++ Common/ListUtils.h | 1 + Fltk/menuWindow.cpp | 26 ++++++++++++++++---------- Geo/SOrientedBoundingBox.cpp | 1 + 4 files changed, 35 insertions(+), 10 deletions(-) diff --git a/Common/ListUtils.cpp b/Common/ListUtils.cpp index 6a4ac5c9b0..922e13aebd 100644 --- a/Common/ListUtils.cpp +++ b/Common/ListUtils.cpp @@ -154,6 +154,23 @@ void List_Sort(List_T * liste, int (*fcmp) (const void *a, const void *b)) qsort(liste->array, liste->n, liste->size, fcmp); } +void List_Unique(List_T * liste, int (*fcmp) (const void *a, const void *b)) +{ + if(liste->isorder != 1) { + List_Sort(liste, fcmp); + liste->isorder = 1; + } + if(!List_Nbr(liste)) + return; + int write_index=0; + for( int i=1; i < List_Nbr(liste); i++){ + void *data=List_Pointer(liste,i); + if((fcmp(data,(void*)List_Pointer(liste,write_index)))) + List_Write(liste,++write_index,data); + } + liste->n=write_index+1; +} + int List_Search(List_T * liste, void *data, int (*fcmp) (const void *a, const void *b)) { diff --git a/Common/ListUtils.h b/Common/ListUtils.h index e08b0a2908..ebf2d4220b 100644 --- a/Common/ListUtils.h +++ b/Common/ListUtils.h @@ -35,6 +35,7 @@ void *List_Pointer_NoChange(List_T *liste, int index); void *List_Pointer_Fast(List_T *liste, int index); void *List_Pointer_Test(List_T *liste, int index); void List_Sort(List_T *liste, int (*fcmp)(const void *a, const void *b)); +void List_Unique(List_T *liste, int (*fcmp)(const void *a, const void *b)); int List_Search(List_T *liste, void *data, int (*fcmp)(const void *a, const void *b)); int List_ISearch(List_T *liste, void *data, int (*fcmp)(const void *a, const void *b)); int List_ISearchSeq(List_T *liste, void * data, int (*fcmp)(const void *a, const void *b)); diff --git a/Fltk/menuWindow.cpp b/Fltk/menuWindow.cpp index 1afbfd1dc6..4945a130a7 100644 --- a/Fltk/menuWindow.cpp +++ b/Fltk/menuWindow.cpp @@ -940,16 +940,21 @@ static void add_new_surface_volume(int mode) } } if(ib == 'l') { - int num = (type == ENT_LINE) ? - GUI::instance()->selectedEdges[0]->tag() : - GUI::instance()->selectedFaces[0]->tag(); - if(select_contour(type, num, List1)) { - if(type == ENT_LINE) - add_lineloop(List1, GModel::current()->getFileName(), &num); - else - add_surfloop(List1, GModel::current()->getFileName(), &num); - List_Reset(List1); - List_Add(List2, &num); + int size = (type == ENT_LINE) ? + GUI::instance()->selectedEdges.size() : + GUI::instance()->selectedFaces.size(); + for(int i=0;i<size;i++){ + int num = (type == ENT_LINE) ? + GUI::instance()->selectedEdges[i]->tag() : + GUI::instance()->selectedFaces[i]->tag(); + if(select_contour(type, num, List1)) { + if(type == ENT_LINE) + add_lineloop(List1, GModel::current()->getFileName(), &num); + else + add_surfloop(List1, GModel::current()->getFileName(), &num); + List_Reset(List1); + List_Add(List2, &num); + } } } if(ib == 'r') { @@ -957,6 +962,7 @@ static void add_new_surface_volume(int mode) "surface/volume creation"); } } + List_Unique(List2,fcmp_absint); if(List_Nbr(List2)) { switch (mode) { case 0: add_surf("Plane Surface", List2, diff --git a/Geo/SOrientedBoundingBox.cpp b/Geo/SOrientedBoundingBox.cpp index e140152361..494566f8af 100644 --- a/Geo/SOrientedBoundingBox.cpp +++ b/Geo/SOrientedBoundingBox.cpp @@ -6,6 +6,7 @@ // Contributed by Bastien Gorissen #include <math.h> +#include <stdlib.h> #include "SOrientedBoundingBox.h" #include "GmshMatrix.h" -- GitLab