Description
Thanks to @KennethEJansen for providing an initiail implementation of the topo model's function for gmi_is_in_closure_of
. I think it could be added to gmi_base.c
. test/inClosureOf_test.cc should then be supported by Simmetrix SimModSuite models and dmg
models (it currently crashes when a .dmg
model is loaded).
Below is closure test that replaces the calls with adjacencies and gives the same results. I have left the calls to gmi_is_in_closure_of commented with my replacement code just above it. The face check is trivial. The edge check is a single loop and finally the vertex check is a double loop. I am sure a reasonably skilled C++ programmer could make a function like that found in gmi_sim.cc to take these branches based on the dim of the entity being checked.
43 gmi_ent* g;
44 int ff;
45
46 // go through the model vertexes and check if they are in closure of gf
47 printf("checking verts against face with tag %d\n",
48 gmi_tag(model, gf));
49 gi = gmi_begin(model, 0);
50 while( (g = gmi_next(model, gi)) ){
51 ff=-1;
52 gmi_set* Edges = gmi_adjacent(model,gf,1);
53 for (int i = 0; i < ((Edges->n)); i++) {
54 gmi_set* Verts = gmi_adjacent(model,Edges->e[i],0);
55 for (int j = 0; j < Verts->n; j++)
56 if(g==Verts->e[j]) ff=j;
57 }
58 // int res = gmi_is_in_closure_of(model, g, gf);
59 if (ff!=-1)
60 printf("vertex with tag %d IS inside the face with tag %d\n",
61 gmi_tag(model, g), gmi_tag(model, gf));
62 else
63 printf("vertex with tag %d IS NOT inside the face with tag %d\n",
64 gmi_tag(model, g), gmi_tag(model, gf));
65 }
66 gmi_end(model, gi); // end the iterator
67
68 // go through the model edges and check if they are in closure of gf
69 printf("checking edges against face with tag %d\n",
70 gmi_tag(model, gf));
71 gi = gmi_begin(model, 1);
72 while( (g = gmi_next(model, gi)) ){
73 ff=-1;
74 gmi_set* Edges = gmi_adjacent(model,gf,1);
75 for (int i = 0; i < ((Edges->n)); i++)
76 if(g==Edges->e[i]) ff=i;
77 // int res = gmi_is_in_closure_of(model, g, gf);
78
79 if (ff!=-1)
80 printf("edge with tag %d IS inside the face with tag %d\n",
81 gmi_tag(model, g), gmi_tag(model, gf));
82 else
83 printf("edge with tag %d IS NOT inside the face with tag %d\n",
84 gmi_tag(model, g), gmi_tag(model, gf));
85 }
86 gmi_end(model, gi); // end the iterator
87
88 // go through the model faces and check if they are in closure of gf
89 printf("checking faces against face with tag %d\n",
90 gmi_tag(model, gf));
91 gi = gmi_begin(model, 2);
92 int ifcnt=0;
93 while( (g = gmi_next(model, gi)) ){
94 ff=-1;
95 if(g==gf) ff=ifcnt;
96 ifcnt++;
97 // int res = gmi_is_in_closure_of(model, g, gf);
98 if (ff!=-1)
99 printf("face with tag %d IS inside the face with tag %d\n",
100 gmi_tag(model, g), gmi_tag(model, gf));
101 else
102 printf("face with tag %d IS NOT inside the face with tag %d\n",
103 gmi_tag(model, g), gmi_tag(model, gf));
104 }
105 gmi_end(model, gi); // end the iterator
106
107 gmi_destroy(model); // deleting the model