49
// returns the element at a given position in a vertex array (element
50
// pointers are not always stored: returning 0 is not an error)
51
MElement *getElement(GEntity *e, int va_type, int index)
55
if(e->va_lines && index < e->va_lines->getNumElementPointers())
56
return *e->va_lines->getElementPointerArray(index);
59
if(e->va_triangles && index < e->va_triangles->getNumElementPointers())
60
return *e->va_triangles->getElementPointerArray(index);
49
66
bool ProcessSelectionBuffer(int entityType,
50
bool multipleSelection, bool meshSelection,
51
int x, int y, int w, int h,
52
std::vector<GVertex*> &vertices,
53
std::vector<GEdge*> &edges,
54
std::vector<GFace*> &faces,
55
std::vector<GRegion*> ®ions,
56
std::vector<MElement*> &elements)
67
bool multipleSelection, bool meshSelection,
68
int x, int y, int w, int h,
69
std::vector<GVertex*> &vertices,
70
std::vector<GEdge*> &edges,
71
std::vector<GFace*> &faces,
72
std::vector<GRegion*> ®ions,
73
std::vector<MElement*> &elements)
64
81
// In our case the selection buffer size is equal to between 5 and 7
65
82
// times the maximum number of possible hits
66
int eles = (meshSelection && CTX.pick_elements) ? 4 * GMODEL->numElements() : 0;
67
int size = 7 * (GMODEL->numVertex() + GMODEL->numEdge() + GMODEL->numFace() +
68
GMODEL->numRegion() + eles) + 1000 ;
83
GModel *m = GModel::current();
84
int eles = (meshSelection && CTX.pick_elements) ? 4 * m->getNumMeshElements() : 0;
85
int size = 7 * (m->getNumVertices() + m->getNumEdges() + m->getNumFaces() +
86
m->getNumRegions() + eles) + 1000 ;
70
88
GLuint *selectionBuffer = new GLuint[size];
71
89
glSelectBuffer(size, selectionBuffer);
152
170
(entityType == ENT_VOLUME && hits[i].type == 3)){
153
171
switch (hits[i].type) {
156
GVertex *v = GMODEL->vertexByTag(hits[i].ient);
158
Msg(GERROR, "Problem in point selection processing");
161
vertices.push_back(v);
162
if(!multipleSelection) return true;
174
GVertex *v = m->getVertexByTag(hits[i].ient);
176
Msg(GERROR, "Problem in point selection processing");
179
vertices.push_back(v);
180
if(!multipleSelection) return true;
167
GEdge *e = GMODEL->edgeByTag(hits[i].ient);
169
Msg(GERROR, "Problem in line selection processing");
172
if(hits[i].type2 && e->meshRep){
173
MElement *ele = e->meshRep->getElement(hits[i].type2, hits[i].ient2);
174
if(ele) elements.push_back(ele);
177
if(!multipleSelection) return true;
185
GEdge *e = m->getEdgeByTag(hits[i].ient);
187
Msg(GERROR, "Problem in line selection processing");
191
MElement *ele = getElement(e, hits[i].type2, hits[i].ient2);
192
if(ele) elements.push_back(ele);
195
if(!multipleSelection) return true;
182
GFace *f = GMODEL->faceByTag(hits[i].ient);
184
Msg(GERROR, "Problem in surface selection processing");
187
if(hits[i].type2 && f->meshRep){
188
MElement *ele = f->meshRep->getElement(hits[i].type2, hits[i].ient2);
189
if(ele) elements.push_back(ele);
192
if(!multipleSelection) return true;
200
GFace *f = m->getFaceByTag(hits[i].ient);
202
Msg(GERROR, "Problem in surface selection processing");
206
MElement *ele = getElement(f, hits[i].type2, hits[i].ient2);
207
if(ele) elements.push_back(ele);
210
if(!multipleSelection) return true;
197
GRegion *r = GMODEL->regionByTag(hits[i].ient);
199
Msg(GERROR, "Problem in volume selection processing");
202
if(hits[i].type2 && r->meshRep){
203
MElement *ele = r->meshRep->getElement(hits[i].type2, hits[i].ient2);
204
if(ele) elements.push_back(ele);
206
regions.push_back(r);
207
if(!multipleSelection) return true;
215
GRegion *r = m->getRegionByTag(hits[i].ient);
217
Msg(GERROR, "Problem in volume selection processing");
221
MElement *ele = getElement(r, hits[i].type2, hits[i].ient2);
222
if(ele) elements.push_back(ele);
224
regions.push_back(r);
225
if(!multipleSelection) return true;
225
243
void HighlightEntityNum(int v, int c, int s, int r)
245
GModel *m = GModel::current();
228
GVertex *pv = GMODEL->vertexByTag(v);
247
GVertex *pv = m->getVertexByTag(v);
229
248
if(pv) HighlightEntity(pv);
232
GEdge *pc = GMODEL->edgeByTag(c);
251
GEdge *pc = m->getEdgeByTag(c);
233
252
if(pc) HighlightEntity(pc);
236
GFace *ps = GMODEL->faceByTag(s);
255
GFace *ps = m->getFaceByTag(s);
237
256
if(ps) HighlightEntity(ps);
240
GRegion *pr = GMODEL->regionByTag(r);
259
GRegion *pr = m->getRegionByTag(r);
241
260
if(pr) HighlightEntity(pr);
258
277
void ZeroHighlightEntityNum(int v, int c, int s, int r)
279
GModel *m = GModel::current();
261
GVertex *pv = GMODEL->vertexByTag(v);
281
GVertex *pv = m->getVertexByTag(v);
262
282
if(pv) ZeroHighlightEntity(pv);
265
GEdge *pc = GMODEL->edgeByTag(c);
285
GEdge *pc = m->getEdgeByTag(c);
266
286
if(pc) ZeroHighlightEntity(pc);
269
GFace *ps = GMODEL->faceByTag(s);
289
GFace *ps = m->getFaceByTag(s);
270
290
if(ps) ZeroHighlightEntity(ps);
273
GRegion *pr = GMODEL->regionByTag(r);
293
GRegion *pr = m->getRegionByTag(r);
274
294
if(pr) ZeroHighlightEntity(pr);
278
298
void ZeroHighlight()
280
for(GModel::viter it = GMODEL->firstVertex(); it != GMODEL->lastVertex(); it++)
281
ZeroHighlightEntity(*it);
282
for(GModel::eiter it = GMODEL->firstEdge(); it != GMODEL->lastEdge(); it++)
283
ZeroHighlightEntity(*it);
284
for(GModel::fiter it = GMODEL->firstFace(); it != GMODEL->lastFace(); it++)
285
ZeroHighlightEntity(*it);
286
for(GModel::riter it = GMODEL->firstRegion(); it != GMODEL->lastRegion(); it++)
287
ZeroHighlightEntity(*it);
289
for(GModel::eiter it = GMODEL->firstEdge(); it != GMODEL->lastEdge(); it++){
300
GModel *m = GModel::current();
302
for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); it++)
303
ZeroHighlightEntity(*it);
304
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++)
305
ZeroHighlightEntity(*it);
306
for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++)
307
ZeroHighlightEntity(*it);
308
for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++)
309
ZeroHighlightEntity(*it);
311
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); it++){
290
312
for(unsigned int i = 0; i < (*it)->lines.size(); i++)
291
313
if((*it)->lines[i]->getVisibility() == 2)
292
(*it)->lines[i]->setVisibility(1);
314
(*it)->lines[i]->setVisibility(1);
294
for(GModel::fiter it = GMODEL->firstFace(); it != GMODEL->lastFace(); it++){
316
for(GModel::fiter it = m->firstFace(); it != m->lastFace(); it++){
295
317
for(unsigned int i = 0; i < (*it)->triangles.size(); i++)
296
318
if((*it)->triangles[i]->getVisibility() == 2)
297
(*it)->triangles[i]->setVisibility(1);
319
(*it)->triangles[i]->setVisibility(1);
298
320
for(unsigned int i = 0; i < (*it)->quadrangles.size(); i++)
299
321
if((*it)->quadrangles[i]->getVisibility() == 2)
300
(*it)->quadrangles[i]->setVisibility(1);
322
(*it)->quadrangles[i]->setVisibility(1);
302
for(GModel::riter it = GMODEL->firstRegion(); it != GMODEL->lastRegion(); it++){
324
for(GModel::riter it = m->firstRegion(); it != m->lastRegion(); it++){
303
325
for(unsigned int i = 0; i < (*it)->tetrahedra.size(); i++)
304
326
if((*it)->tetrahedra[i]->getVisibility() == 2)
305
(*it)->tetrahedra[i]->setVisibility(1);
327
(*it)->tetrahedra[i]->setVisibility(1);
306
328
for(unsigned int i = 0; i < (*it)->hexahedra.size(); i++)
307
329
if((*it)->hexahedra[i]->getVisibility() == 2)
308
(*it)->hexahedra[i]->setVisibility(1);
330
(*it)->hexahedra[i]->setVisibility(1);
309
331
for(unsigned int i = 0; i < (*it)->prisms.size(); i++)
310
332
if((*it)->prisms[i]->getVisibility() == 2)
311
(*it)->prisms[i]->setVisibility(1);
333
(*it)->prisms[i]->setVisibility(1);
312
334
for(unsigned int i = 0; i < (*it)->pyramids.size(); i++)
313
335
if((*it)->pyramids[i]->getVisibility() == 2)
314
(*it)->pyramids[i]->setVisibility(1);
336
(*it)->pyramids[i]->setVisibility(1);