1414#include < gmi.h>
1515#include < SimModel.h>
1616#include < vector>
17+ #include < set>
1718
1819#include " gmi_sim_config.h"
1920
@@ -182,8 +183,7 @@ static gmi_set* region_faces(pGRegion region)
182183 return s;
183184}
184185
185- /* getting the region adj to an edge. This version
186- * does not support non-manifold models
186+ /* getting the region adj to an edge.
187187 */
188188// NOTE: the corresponding functionality does not exist
189189// in gmi_base!
@@ -192,22 +192,23 @@ static gmi_set* edge_regions(pGEdge e)
192192{
193193 pPList list = GE_faces ((pGEdge)e);
194194
195- // do the first one outside of the loop
196- gmi_set* regions_set = face_regions ((pGFace)PList_item (list, 0 ));
197- if (regions_set->n > 1 )
198- gmi_fail (" no support for non-manifold surfaces!\n " );
199- pGRegion r = (pGRegion)regions_set->e [0 ];
200-
201- // do the rest inside of the loop
202- for (int i = 1 ; i < PList_size (list); i++) {
203- regions_set = face_regions ((pGFace)PList_item (list, i));
204- if (regions_set->n > 1 )
205- gmi_fail (" no support for non-manifold surfaces!\n " );
206- if (r != (pGRegion)regions_set->e [0 ])
207- gmi_fail (" no support for non-manifold surfaces!\n " );
195+ std::set<pGRegion> rgns;
196+ gmi_set* regions_set;
197+ for (int i = 0 ; i < PList_size (list); i++) {
198+ regions_set = face_regions ((pGFace)PList_item (list, i));
199+ for (int j = 0 ; j < regions_set->n ; j++) {
200+ rgns.insert ( (pGRegion) regions_set->e [j] );
201+ }
208202 }
209- PList_delete (list);
210- return regions_set;
203+
204+ int count = 0 ;
205+ gmi_set* s = gmi_make_set (rgns.size ());
206+ for (std::set<pGRegion>::iterator it=rgns.begin (); it!=rgns.end (); ++it) {
207+ s->e [count] = (gmi_ent*)*it;
208+ count++;
209+ }
210+
211+ return s;
211212}
212213
213214static gmi_set* adjacent (gmi_model* m, gmi_ent* e, int dim)
0 commit comments