Developer Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
VolumeMeshSelectionFunctions.cc
1 /*===========================================================================*\
2 * *
3 * OpenFlipper *
4  * Copyright (c) 2001-2015, RWTH-Aachen University *
5  * Department of Computer Graphics and Multimedia *
6  * All rights reserved. *
7  * www.openflipper.org *
8  * *
9  *---------------------------------------------------------------------------*
10  * This file is part of OpenFlipper. *
11  *---------------------------------------------------------------------------*
12  * *
13  * Redistribution and use in source and binary forms, with or without *
14  * modification, are permitted provided that the following conditions *
15  * are met: *
16  * *
17  * 1. Redistributions of source code must retain the above copyright notice, *
18  * this list of conditions and the following disclaimer. *
19  * *
20  * 2. Redistributions in binary form must reproduce the above copyright *
21  * notice, this list of conditions and the following disclaimer in the *
22  * documentation and/or other materials provided with the distribution. *
23  * *
24  * 3. Neither the name of the copyright holder nor the names of its *
25  * contributors may be used to endorse or promote products derived from *
26  * this software without specific prior written permission. *
27  * *
28  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS *
29  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
30  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A *
31  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
32  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, *
33  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, *
34  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR *
35  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF *
36  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING *
37  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS *
38  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
39 * *
40 \*===========================================================================*/
41 
42 /*===========================================================================*\
43 * *
44 * $Revision: 21016 $ *
45 * $LastChangedBy: schultz $ *
46 * $Date: 2015-07-16 16:48:42 +0200 (Do, 16 Jul 2015) $ *
47 * *
48 \*===========================================================================*/
49 
50 
51 #include "VolumeMeshSelectionPlugin.hh"
52 
53 /*
54  * Vertices
55  */
57 
58  BaseObjectData* object = 0;
59 
60  if(!PluginFunctions::getObject(_objectId, object)) {
61  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
62  return;
63  }
64 
65  PolyhedralMeshObject* polyMeshObj = NULL;
66  HexahedralMeshObject* hexMeshObj = NULL;
67  PluginFunctions::getObject(_objectId, polyMeshObj);
68  PluginFunctions::getObject(_objectId, hexMeshObj);
69  if(!polyMeshObj && !hexMeshObj) return;
70  if(!polyMeshObj && !hexMeshObj) return;
71  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
72  polyMeshObj->status() :
73  hexMeshObj->status());
74 
75  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
76  vst_it != status.vstatus_end(); ++vst_it) {
77  vst_it->set_selected(true);
78  }
79 
80  emit scriptInfo("selectAllVertices(ObjectId)");
81  emit updatedObject(_objectId, UPDATE_SELECTION);
82 }
83 
85 
86  BaseObjectData* object = 0;
87 
88  if(!PluginFunctions::getObject(_objectId, object)) {
89  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
90  return;
91  }
92 
93  PolyhedralMeshObject* polyMeshObj = NULL;
94  HexahedralMeshObject* hexMeshObj = NULL;
95  PluginFunctions::getObject(_objectId, polyMeshObj);
96  PluginFunctions::getObject(_objectId, hexMeshObj);
97  if(!polyMeshObj && !hexMeshObj) return;
98  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
99  polyMeshObj->status() :
100  hexMeshObj->status());
101 
102  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
103  vst_it != status.vstatus_end(); ++vst_it) {
104  vst_it->set_selected(false);
105  }
106 
107  emit scriptInfo("deselectAllVertices(ObjectId)");
108  emit updatedObject(_objectId, UPDATE_SELECTION);
109 }
110 
112 
113  BaseObjectData* object = 0;
114 
115  if(!PluginFunctions::getObject(_objectId, object)) {
116  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
117  return;
118  }
119 
120  PolyhedralMeshObject* polyMeshObj = NULL;
121  HexahedralMeshObject* hexMeshObj = NULL;
122  PluginFunctions::getObject(_objectId, polyMeshObj);
123  PluginFunctions::getObject(_objectId, hexMeshObj);
124  if(!polyMeshObj && !hexMeshObj) return;
125  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
126  polyMeshObj->status() :
127  hexMeshObj->status());
128 
129  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
130  vst_it != status.vstatus_end(); ++vst_it) {
131  vst_it->set_selected(!vst_it->selected());
132  }
133 
134  emit scriptInfo("invertVertexSelection(ObjectId)");
135  emit updatedObject(_objectId, UPDATE_SELECTION);
136 }
137 
138 void VolumeMeshSelectionPlugin::selectVertices(int _objectId, const IdList& _ids, bool _deselect) {
139 
140  if(_ids.empty()) return;
141 
142  BaseObjectData* object = 0;
143 
144  if(!PluginFunctions::getObject(_objectId, object)) {
145  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
146  return;
147  }
148 
149  PolyhedralMeshObject* polyMeshObj = NULL;
150  HexahedralMeshObject* hexMeshObj = NULL;
151  PluginFunctions::getObject(_objectId, polyMeshObj);
152  PluginFunctions::getObject(_objectId, hexMeshObj);
153  if(!polyMeshObj && !hexMeshObj) return;
154  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
155  polyMeshObj->status() :
156  hexMeshObj->status());
157 
158  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
159  status[OpenVolumeMesh::VertexHandle(*v_it)].set_selected(!_deselect);
160  }
161 
162  QString selection = "selectVertices(ObjectId, [ " + QString::number(_ids[0]);
163 
164  for (uint i = 1 ; i < _ids.size(); ++i) {
165  selection += ", " + QString::number(_ids[i]);
166  }
167 
168  selection += " ])";
169 
170  emit scriptInfo(selection);
171  emit updatedObject(_objectId, UPDATE_SELECTION);
172 }
173 
175 
176  BaseObjectData* object = 0;
177 
178  IdList list;
179 
180  if(!PluginFunctions::getObject(_objectId, object)) {
181  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
182  return list;
183  }
184 
185  PolyhedralMeshObject* polyMeshObj = NULL;
186  HexahedralMeshObject* hexMeshObj = NULL;
187  PluginFunctions::getObject(_objectId, polyMeshObj);
188  PluginFunctions::getObject(_objectId, hexMeshObj);
189  if(!polyMeshObj && !hexMeshObj) return list;
190  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
191  polyMeshObj->status() :
192  hexMeshObj->status());
193 
194  int id = 0;
195  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
196  vst_it != status.vstatus_end(); ++vst_it, ++id) {
197  if(vst_it->selected()) list.push_back(id);
198  }
199 
200  return list;
201 }
202 
203 void VolumeMeshSelectionPlugin::deleteSelectedVertices(int _objectId, bool _preserveManifoldness) {
204 
205  BaseObjectData* object = 0;
206 
207  if(!PluginFunctions::getObject(_objectId, object)) {
208  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
209  return;
210  }
211 
212  PolyhedralMeshObject* polyMeshObj = NULL;
213  HexahedralMeshObject* hexMeshObj = NULL;
214  PluginFunctions::getObject(_objectId, polyMeshObj);
215  PluginFunctions::getObject(_objectId, hexMeshObj);
216  if(!polyMeshObj && !hexMeshObj) return;
217  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
218  polyMeshObj->status() :
219  hexMeshObj->status());
220 
221  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
222  vst_it != status.vstatus_end(); ++vst_it) {
223  if(vst_it->selected()) vst_it->set_deleted(true);
224  }
225 
226  status.garbage_collection(_preserveManifoldness);
227 
228  emit scriptInfo("deleteSelectedVertices(ObjectId)");
229  emit updatedObject(_objectId, UPDATE_ALL);
230 }
231 
232 /*
233  * Edges
234  */
236 
237  BaseObjectData* object = 0;
238 
239  if(!PluginFunctions::getObject(_objectId, object)) {
240  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
241  return;
242  }
243 
244  PolyhedralMeshObject* polyMeshObj = NULL;
245  HexahedralMeshObject* hexMeshObj = NULL;
246  PluginFunctions::getObject(_objectId, polyMeshObj);
247  PluginFunctions::getObject(_objectId, hexMeshObj);
248  if(!polyMeshObj && !hexMeshObj) return;
249  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
250  polyMeshObj->status() :
251  hexMeshObj->status());
252 
253  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
254  est_it != status.estatus_end(); ++est_it) {
255  est_it->set_selected(true);
256  }
257 
258  emit scriptInfo("selectAllEdges(ObjectId)");
259  emit updatedObject(_objectId, UPDATE_SELECTION);
260 }
261 
263 
264  BaseObjectData* object = 0;
265 
266  if(!PluginFunctions::getObject(_objectId, object)) {
267  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
268  return;
269  }
270 
271  PolyhedralMeshObject* polyMeshObj = NULL;
272  HexahedralMeshObject* hexMeshObj = NULL;
273  PluginFunctions::getObject(_objectId, polyMeshObj);
274  PluginFunctions::getObject(_objectId, hexMeshObj);
275  if(!polyMeshObj && !hexMeshObj) return;
276  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
277  polyMeshObj->status() :
278  hexMeshObj->status());
279 
280  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
281  est_it != status.estatus_end(); ++est_it) {
282  est_it->set_selected(false);
283  }
284 
285  emit scriptInfo("deselectAllEdges(ObjectId)");
286  emit updatedObject(_objectId, UPDATE_SELECTION);
287 }
288 
290 
291  BaseObjectData* object = 0;
292 
293  if(!PluginFunctions::getObject(_objectId, object)) {
294  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
295  return;
296  }
297 
298  PolyhedralMeshObject* polyMeshObj = NULL;
299  HexahedralMeshObject* hexMeshObj = NULL;
300  PluginFunctions::getObject(_objectId, polyMeshObj);
301  PluginFunctions::getObject(_objectId, hexMeshObj);
302  if(!polyMeshObj && !hexMeshObj) return;
303  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
304  polyMeshObj->status() :
305  hexMeshObj->status());
306 
307  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
308  est_it != status.estatus_end(); ++est_it) {
309  est_it->set_selected(!est_it->selected());
310  }
311 
312  emit scriptInfo("invertEdgeSelection(ObjectId)");
313  emit updatedObject(_objectId, UPDATE_SELECTION);
314 }
315 
316 void VolumeMeshSelectionPlugin::selectEdges(int _objectId, const IdList& _ids, bool _deselect) {
317 
318  if(_ids.empty()) return;
319 
320  BaseObjectData* object = 0;
321 
322  if(!PluginFunctions::getObject(_objectId, object)) {
323  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
324  return;
325  }
326 
327  PolyhedralMeshObject* polyMeshObj = NULL;
328  HexahedralMeshObject* hexMeshObj = NULL;
329  PluginFunctions::getObject(_objectId, polyMeshObj);
330  PluginFunctions::getObject(_objectId, hexMeshObj);
331  if(!polyMeshObj && !hexMeshObj) return;
332  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
333  polyMeshObj->status() :
334  hexMeshObj->status());
335 
336  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
337  status[OpenVolumeMesh::EdgeHandle(*v_it)].set_selected(!_deselect);
338  }
339 
340  QString selection = "selectEdges(ObjectId, [ " + QString::number(_ids[0]);
341 
342  for (uint i = 1 ; i < _ids.size(); ++i) {
343  selection += ", " + QString::number(_ids[i]);
344  }
345 
346  selection += " ])";
347 
348  emit scriptInfo(selection);
349  emit updatedObject(_objectId, UPDATE_SELECTION);
350 }
351 
353 
354  BaseObjectData* object = 0;
355 
356  IdList list;
357 
358  if(!PluginFunctions::getObject(_objectId, object)) {
359  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
360  return list;
361  }
362 
363  PolyhedralMeshObject* polyMeshObj = NULL;
364  HexahedralMeshObject* hexMeshObj = NULL;
365  PluginFunctions::getObject(_objectId, polyMeshObj);
366  PluginFunctions::getObject(_objectId, hexMeshObj);
367  if(!polyMeshObj && !hexMeshObj) return list;
368  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
369  polyMeshObj->status() :
370  hexMeshObj->status());
371 
372  int id = 0;
373  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
374  est_it != status.estatus_end(); ++est_it, ++id) {
375  if(est_it->selected()) list.push_back(id);
376  }
377 
378  return list;
379 }
380 
381 void VolumeMeshSelectionPlugin::deleteSelectedEdges(int _objectId, bool _preserveManifoldness) {
382 
383  BaseObjectData* object = 0;
384 
385  if(!PluginFunctions::getObject(_objectId, object)) {
386  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
387  return;
388  }
389 
390  PolyhedralMeshObject* polyMeshObj = NULL;
391  HexahedralMeshObject* hexMeshObj = NULL;
392  PluginFunctions::getObject(_objectId, polyMeshObj);
393  PluginFunctions::getObject(_objectId, hexMeshObj);
394  if(!polyMeshObj && !hexMeshObj) return;
395  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
396  polyMeshObj->status() :
397  hexMeshObj->status());
398 
399  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
400  est_it != status.estatus_end(); ++est_it) {
401  if(est_it->selected()) est_it->set_deleted(true);
402  }
403 
404  status.garbage_collection(_preserveManifoldness);
405 
406  emit scriptInfo("deleteSelectedEdges(ObjectId)");
407  emit updatedObject(_objectId, UPDATE_ALL);
408 }
409 
410 /*
411  * HalfEdges
412  */
414 
415  BaseObjectData* object = 0;
416 
417  if(!PluginFunctions::getObject(_objectId, object)) {
418  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
419  return;
420  }
421 
422  PolyhedralMeshObject* polyMeshObj = NULL;
423  HexahedralMeshObject* hexMeshObj = NULL;
424  PluginFunctions::getObject(_objectId, polyMeshObj);
425  PluginFunctions::getObject(_objectId, hexMeshObj);
426  if(!polyMeshObj && !hexMeshObj) return;
427  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
428  polyMeshObj->status() :
429  hexMeshObj->status());
430 
431  for(OpenVolumeMesh::StatusAttrib::hestatus_iterator hest_it = status.hestatus_begin();
432  hest_it != status.hestatus_end(); ++hest_it) {
433  hest_it->set_selected(true);
434  }
435 
436  emit scriptInfo("selectAllHalfEdges(ObjectId)");
437  emit updatedObject(_objectId, UPDATE_SELECTION);
438 }
439 
441 
442  BaseObjectData* object = 0;
443 
444  if(!PluginFunctions::getObject(_objectId, object)) {
445  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
446  return;
447  }
448 
449  PolyhedralMeshObject* polyMeshObj = NULL;
450  HexahedralMeshObject* hexMeshObj = NULL;
451  PluginFunctions::getObject(_objectId, polyMeshObj);
452  PluginFunctions::getObject(_objectId, hexMeshObj);
453  if(!polyMeshObj && !hexMeshObj) return;
454  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
455  polyMeshObj->status() :
456  hexMeshObj->status());
457 
458  for(OpenVolumeMesh::StatusAttrib::hestatus_iterator hest_it = status.hestatus_begin();
459  hest_it != status.hestatus_end(); ++hest_it) {
460  hest_it->set_selected(false);
461  }
462 
463  emit scriptInfo("deselectAllHalfEdges(ObjectId)");
464  emit updatedObject(_objectId, UPDATE_SELECTION);
465 }
466 
468 
469  BaseObjectData* object = 0;
470 
471  if(!PluginFunctions::getObject(_objectId, object)) {
472  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
473  return;
474  }
475 
476  PolyhedralMeshObject* polyMeshObj = NULL;
477  HexahedralMeshObject* hexMeshObj = NULL;
478  PluginFunctions::getObject(_objectId, polyMeshObj);
479  PluginFunctions::getObject(_objectId, hexMeshObj);
480  if(!polyMeshObj && !hexMeshObj) return;
481  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
482  polyMeshObj->status() :
483  hexMeshObj->status());
484 
485  for(OpenVolumeMesh::StatusAttrib::hestatus_iterator hest_it = status.hestatus_begin();
486  hest_it != status.hestatus_end(); ++hest_it) {
487  hest_it->set_selected(!hest_it->selected());
488  }
489 
490  emit scriptInfo("invertHalfEdgeSelection(ObjectId)");
491  emit updatedObject(_objectId, UPDATE_SELECTION);
492 }
493 
494 void VolumeMeshSelectionPlugin::selectHalfEdges(int _objectId, const IdList& _ids, bool _deselect) {
495 
496  if(_ids.empty()) return;
497 
498  BaseObjectData* object = 0;
499 
500  if(!PluginFunctions::getObject(_objectId, object)) {
501  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
502  return;
503  }
504 
505  PolyhedralMeshObject* polyMeshObj = NULL;
506  HexahedralMeshObject* hexMeshObj = NULL;
507  PluginFunctions::getObject(_objectId, polyMeshObj);
508  PluginFunctions::getObject(_objectId, hexMeshObj);
509  if(!polyMeshObj && !hexMeshObj) return;
510  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
511  polyMeshObj->status() :
512  hexMeshObj->status());
513 
514  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
515  status[OpenVolumeMesh::HalfEdgeHandle(*v_it)].set_selected(!_deselect);
516  }
517 
518  QString selection = "selectHalfEdges(ObjectId, [ " + QString::number(_ids[0]);
519 
520  for (uint i = 1 ; i < _ids.size(); ++i) {
521  selection += ", " + QString::number(_ids[i]);
522  }
523 
524  selection += " ])";
525 
526  emit scriptInfo(selection);
527  emit updatedObject(_objectId, UPDATE_SELECTION);
528 }
529 
531 
532  BaseObjectData* object = 0;
533 
534  IdList list;
535 
536  if(!PluginFunctions::getObject(_objectId, object)) {
537  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
538  return list;
539  }
540 
541  PolyhedralMeshObject* polyMeshObj = NULL;
542  HexahedralMeshObject* hexMeshObj = NULL;
543  PluginFunctions::getObject(_objectId, polyMeshObj);
544  PluginFunctions::getObject(_objectId, hexMeshObj);
545  if(!polyMeshObj && !hexMeshObj) return list;
546  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
547  polyMeshObj->status() :
548  hexMeshObj->status());
549 
550  int id = 0;
551  for(OpenVolumeMesh::StatusAttrib::hestatus_iterator hest_it = status.hestatus_begin();
552  hest_it != status.hestatus_end(); ++hest_it, ++id) {
553  if(hest_it->selected()) list.push_back(id);
554  }
555 
556  return list;
557 }
558 
559 /*
560  * Faces
561  */
563 
564  BaseObjectData* object = 0;
565 
566  if(!PluginFunctions::getObject(_objectId, object)) {
567  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
568  return;
569  }
570 
571  PolyhedralMeshObject* polyMeshObj = NULL;
572  HexahedralMeshObject* hexMeshObj = NULL;
573  PluginFunctions::getObject(_objectId, polyMeshObj);
574  PluginFunctions::getObject(_objectId, hexMeshObj);
575  if(!polyMeshObj && !hexMeshObj) return;
576  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
577  polyMeshObj->status() :
578  hexMeshObj->status());
579 
580  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
581  fst_it != status.fstatus_end(); ++fst_it) {
582  fst_it->set_selected(true);
583  }
584 
585  emit scriptInfo("selectAllFaces(ObjectId)");
586  emit updatedObject(_objectId, UPDATE_SELECTION);
587 }
588 
590 
591  BaseObjectData* object = 0;
592 
593  if(!PluginFunctions::getObject(_objectId, object)) {
594  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
595  return;
596  }
597 
598  PolyhedralMeshObject* polyMeshObj = NULL;
599  HexahedralMeshObject* hexMeshObj = NULL;
600  PluginFunctions::getObject(_objectId, polyMeshObj);
601  PluginFunctions::getObject(_objectId, hexMeshObj);
602  if(!polyMeshObj && !hexMeshObj) return;
603  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
604  polyMeshObj->status() :
605  hexMeshObj->status());
606 
607  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
608  fst_it != status.fstatus_end(); ++fst_it) {
609  fst_it->set_selected(false);
610  }
611 
612  emit scriptInfo("deselectAllFaces(ObjectId)");
613  emit updatedObject(_objectId, UPDATE_SELECTION);
614 }
615 
617 
618  BaseObjectData* object = 0;
619 
620  if(!PluginFunctions::getObject(_objectId, object)) {
621  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
622  return;
623  }
624 
625  PolyhedralMeshObject* polyMeshObj = NULL;
626  HexahedralMeshObject* hexMeshObj = NULL;
627  PluginFunctions::getObject(_objectId, polyMeshObj);
628  PluginFunctions::getObject(_objectId, hexMeshObj);
629  if(!polyMeshObj && !hexMeshObj) return;
630  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
631  polyMeshObj->status() :
632  hexMeshObj->status());
633 
634  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
635  fst_it != status.fstatus_end(); ++fst_it) {
636  fst_it->set_selected(!fst_it->selected());
637  }
638 
639  emit scriptInfo("invertFaceSelection(ObjectId)");
640  emit updatedObject(_objectId, UPDATE_SELECTION);
641 }
642 
643 void VolumeMeshSelectionPlugin::selectFaces(int _objectId, const IdList& _ids, bool _deselect) {
644 
645  if(_ids.empty()) return;
646 
647  BaseObjectData* object = 0;
648 
649  if(!PluginFunctions::getObject(_objectId, object)) {
650  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
651  return;
652  }
653 
654  PolyhedralMeshObject* polyMeshObj = NULL;
655  HexahedralMeshObject* hexMeshObj = NULL;
656  PluginFunctions::getObject(_objectId, polyMeshObj);
657  PluginFunctions::getObject(_objectId, hexMeshObj);
658  if(!polyMeshObj && !hexMeshObj) return;
659  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
660  polyMeshObj->status() :
661  hexMeshObj->status());
662 
663  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
664  status[OpenVolumeMesh::FaceHandle(*v_it)].set_selected(!_deselect);
665  }
666 
667  QString selection = "selectFaces(ObjectId, [ " + QString::number(_ids[0]);
668 
669  for (uint i = 1 ; i < _ids.size(); ++i) {
670  selection += ", " + QString::number(_ids[i]);
671  }
672 
673  selection += " ])";
674 
675  emit scriptInfo(selection);
676  emit updatedObject(_objectId, UPDATE_SELECTION);
677 }
678 
680 
681  BaseObjectData* object = 0;
682 
683  IdList list;
684 
685  if(!PluginFunctions::getObject(_objectId, object)) {
686  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
687  return list;
688  }
689 
690  PolyhedralMeshObject* polyMeshObj = NULL;
691  HexahedralMeshObject* hexMeshObj = NULL;
692  PluginFunctions::getObject(_objectId, polyMeshObj);
693  PluginFunctions::getObject(_objectId, hexMeshObj);
694  if(!polyMeshObj && !hexMeshObj) return list;
695  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
696  polyMeshObj->status() :
697  hexMeshObj->status());
698 
699  int id = 0;
700  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
701  fst_it != status.fstatus_end(); ++fst_it, ++id) {
702  if(fst_it->selected()) list.push_back(id);
703  }
704 
705  return list;
706 }
707 
708 void VolumeMeshSelectionPlugin::deleteSelectedFaces(int _objectId, bool _preserveManifoldness) {
709 
710  BaseObjectData* object = 0;
711 
712  if(!PluginFunctions::getObject(_objectId, object)) {
713  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
714  return;
715  }
716 
717  PolyhedralMeshObject* polyMeshObj = NULL;
718  HexahedralMeshObject* hexMeshObj = NULL;
719  PluginFunctions::getObject(_objectId, polyMeshObj);
720  PluginFunctions::getObject(_objectId, hexMeshObj);
721  if(!polyMeshObj && !hexMeshObj) return;
722  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
723  polyMeshObj->status() :
724  hexMeshObj->status());
725 
726  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
727  fst_it != status.fstatus_end(); ++fst_it) {
728  if(fst_it->selected()) fst_it->set_deleted(true);
729  }
730 
731  status.garbage_collection(_preserveManifoldness);
732 
733  emit scriptInfo("deleteSelectedFaces(ObjectId)");
734  emit updatedObject(_objectId, UPDATE_ALL);
735 }
736 
737 /*
738  * HalfFaces
739  */
741 
742  BaseObjectData* object = 0;
743 
744  if(!PluginFunctions::getObject(_objectId, object)) {
745  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
746  return;
747  }
748 
749  PolyhedralMeshObject* polyMeshObj = NULL;
750  HexahedralMeshObject* hexMeshObj = NULL;
751  PluginFunctions::getObject(_objectId, polyMeshObj);
752  PluginFunctions::getObject(_objectId, hexMeshObj);
753  if(!polyMeshObj && !hexMeshObj) return;
754  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
755  polyMeshObj->status() :
756  hexMeshObj->status());
757 
758  for(OpenVolumeMesh::StatusAttrib::hfstatus_iterator hfst_it = status.hfstatus_begin();
759  hfst_it != status.hfstatus_end(); ++hfst_it) {
760  hfst_it->set_selected(true);
761  }
762 
763  emit scriptInfo("selectAllHalfFaces(ObjectId)");
764  emit updatedObject(_objectId, UPDATE_SELECTION);
765 }
766 
768 
769  BaseObjectData* object = 0;
770 
771  if(!PluginFunctions::getObject(_objectId, object)) {
772  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
773  return;
774  }
775 
776  PolyhedralMeshObject* polyMeshObj = NULL;
777  HexahedralMeshObject* hexMeshObj = NULL;
778  PluginFunctions::getObject(_objectId, polyMeshObj);
779  PluginFunctions::getObject(_objectId, hexMeshObj);
780  if(!polyMeshObj && !hexMeshObj) return;
781  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
782  polyMeshObj->status() :
783  hexMeshObj->status());
784 
785  for(OpenVolumeMesh::StatusAttrib::hfstatus_iterator hfst_it = status.hfstatus_begin();
786  hfst_it != status.hfstatus_end(); ++hfst_it) {
787  hfst_it->set_selected(false);
788  }
789 
790  emit scriptInfo("deselectAllHalfFaces(ObjectId)");
791  emit updatedObject(_objectId, UPDATE_SELECTION);
792 }
793 
795 
796  BaseObjectData* object = 0;
797 
798  if(!PluginFunctions::getObject(_objectId, object)) {
799  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
800  return;
801  }
802 
803  PolyhedralMeshObject* polyMeshObj = NULL;
804  HexahedralMeshObject* hexMeshObj = NULL;
805  PluginFunctions::getObject(_objectId, polyMeshObj);
806  PluginFunctions::getObject(_objectId, hexMeshObj);
807  if(!polyMeshObj && !hexMeshObj) return;
808  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
809  polyMeshObj->status() :
810  hexMeshObj->status());
811 
812  for(OpenVolumeMesh::StatusAttrib::hfstatus_iterator hfst_it = status.hfstatus_begin();
813  hfst_it != status.hfstatus_end(); ++hfst_it) {
814  hfst_it->set_selected(!hfst_it->selected());
815  }
816 
817  emit scriptInfo("invertHalfFaceSelection(ObjectId)");
818  emit updatedObject(_objectId, UPDATE_SELECTION);
819 }
820 
821 void VolumeMeshSelectionPlugin::selectHalfFaces(int _objectId, const IdList& _ids, bool _deselect) {
822 
823  if(_ids.empty()) return;
824 
825  BaseObjectData* object = 0;
826 
827  if(!PluginFunctions::getObject(_objectId, object)) {
828  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
829  return;
830  }
831 
832  PolyhedralMeshObject* polyMeshObj = NULL;
833  HexahedralMeshObject* hexMeshObj = NULL;
834  PluginFunctions::getObject(_objectId, polyMeshObj);
835  PluginFunctions::getObject(_objectId, hexMeshObj);
836  if(!polyMeshObj && !hexMeshObj) return;
837  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
838  polyMeshObj->status() :
839  hexMeshObj->status());
840 
841  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
842  status[OpenVolumeMesh::HalfFaceHandle(*v_it)].set_selected(!_deselect);
843  }
844 
845  QString selection = "selectHalfFaces(ObjectId, [ " + QString::number(_ids[0]);
846 
847  for (uint i = 1 ; i < _ids.size(); ++i) {
848  selection += ", " + QString::number(_ids[i]);
849  }
850 
851  selection += " ])";
852 
853  emit scriptInfo(selection);
854  emit updatedObject(_objectId, UPDATE_SELECTION);
855 }
856 
858 
859  BaseObjectData* object = 0;
860 
861  IdList list;
862 
863  if(!PluginFunctions::getObject(_objectId, object)) {
864  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
865  return list;
866  }
867 
868  PolyhedralMeshObject* polyMeshObj = NULL;
869  HexahedralMeshObject* hexMeshObj = NULL;
870  PluginFunctions::getObject(_objectId, polyMeshObj);
871  PluginFunctions::getObject(_objectId, hexMeshObj);
872  if(!polyMeshObj && !hexMeshObj) return list;
873  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
874  polyMeshObj->status() :
875  hexMeshObj->status());
876 
877  int id = 0;
878  for(OpenVolumeMesh::StatusAttrib::hfstatus_iterator hfst_it = status.hfstatus_begin();
879  hfst_it != status.hfstatus_end(); ++hfst_it, ++id) {
880  if(hfst_it->selected()) list.push_back(id);
881  }
882 
883  return list;
884 }
885 /*
886  * Cells
887  */
889 
890  BaseObjectData* object = 0;
891 
892  if(!PluginFunctions::getObject(_objectId, object)) {
893  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
894  return;
895  }
896 
897  PolyhedralMeshObject* polyMeshObj = NULL;
898  HexahedralMeshObject* hexMeshObj = NULL;
899  PluginFunctions::getObject(_objectId, polyMeshObj);
900  PluginFunctions::getObject(_objectId, hexMeshObj);
901  if(!polyMeshObj && !hexMeshObj) return;
902  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
903  polyMeshObj->status() :
904  hexMeshObj->status());
905 
906  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
907  cst_it != status.cstatus_end(); ++cst_it) {
908  cst_it->set_selected(true);
909  }
910 
911  emit scriptInfo("selectAllCells(ObjectId)");
912  emit updatedObject(_objectId, UPDATE_SELECTION);
913 }
914 
916 
917  BaseObjectData* object = 0;
918 
919  if(!PluginFunctions::getObject(_objectId, object)) {
920  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
921  return;
922  }
923 
924  PolyhedralMeshObject* polyMeshObj = NULL;
925  HexahedralMeshObject* hexMeshObj = NULL;
926  PluginFunctions::getObject(_objectId, polyMeshObj);
927  PluginFunctions::getObject(_objectId, hexMeshObj);
928  if(!polyMeshObj && !hexMeshObj) return;
929  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
930  polyMeshObj->status() :
931  hexMeshObj->status());
932 
933  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
934  cst_it != status.cstatus_end(); ++cst_it) {
935  cst_it->set_selected(false);
936  }
937 
938  emit scriptInfo("deselectAllCells(ObjectId)");
939  emit updatedObject(_objectId, UPDATE_SELECTION);
940 }
941 
943 
944  BaseObjectData* object = 0;
945 
946  if(!PluginFunctions::getObject(_objectId, object)) {
947  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
948  return;
949  }
950 
951  PolyhedralMeshObject* polyMeshObj = NULL;
952  HexahedralMeshObject* hexMeshObj = NULL;
953  PluginFunctions::getObject(_objectId, polyMeshObj);
954  PluginFunctions::getObject(_objectId, hexMeshObj);
955  if(!polyMeshObj && !hexMeshObj) return;
956  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
957  polyMeshObj->status() :
958  hexMeshObj->status());
959 
960  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
961  cst_it != status.cstatus_end(); ++cst_it) {
962  cst_it->set_selected(!cst_it->selected());
963  }
964 
965  emit scriptInfo("invertCellSelection(ObjectId)");
966  emit updatedObject(_objectId, UPDATE_SELECTION);
967 }
968 
969 void VolumeMeshSelectionPlugin::selectCells(int _objectId, const IdList& _ids, bool _deselect) {
970 
971  if(_ids.empty()) return;
972 
973  BaseObjectData* object = 0;
974 
975  if(!PluginFunctions::getObject(_objectId, object)) {
976  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
977  return;
978  }
979 
980  PolyhedralMeshObject* polyMeshObj = NULL;
981  HexahedralMeshObject* hexMeshObj = NULL;
982  PluginFunctions::getObject(_objectId, polyMeshObj);
983  PluginFunctions::getObject(_objectId, hexMeshObj);
984  if(!polyMeshObj && !hexMeshObj) return;
985  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
986  polyMeshObj->status() :
987  hexMeshObj->status());
988 
989  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
990  status[OpenVolumeMesh::CellHandle(*v_it)].set_selected(!_deselect);
991  }
992 
993  QString selection = "selectCells(ObjectId, [ " + QString::number(_ids[0]);
994 
995  for (uint i = 1 ; i < _ids.size(); ++i) {
996  selection += ", " + QString::number(_ids[i]);
997  }
998 
999  selection += " ])";
1000 
1001  emit scriptInfo(selection);
1002  emit updatedObject(_objectId, UPDATE_SELECTION);
1003 }
1004 
1006 
1007  BaseObjectData* object = 0;
1008 
1009  IdList list;
1010 
1011  if(!PluginFunctions::getObject(_objectId, object)) {
1012  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
1013  return list;
1014  }
1015 
1016  PolyhedralMeshObject* polyMeshObj = NULL;
1017  HexahedralMeshObject* hexMeshObj = NULL;
1018  PluginFunctions::getObject(_objectId, polyMeshObj);
1019  PluginFunctions::getObject(_objectId, hexMeshObj);
1020  if(!polyMeshObj && !hexMeshObj) return list;
1021  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
1022  polyMeshObj->status() :
1023  hexMeshObj->status());
1024 
1025  int id = 0;
1026  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
1027  cst_it != status.cstatus_end(); ++cst_it, ++id) {
1028  if(cst_it->selected()) list.push_back(id);
1029  }
1030 
1031  return list;
1032 }
1033 
1034 void VolumeMeshSelectionPlugin::deleteSelectedCells(int _objectId, bool _preserveManifoldness) {
1035 
1036  BaseObjectData* object = 0;
1037 
1038  if(!PluginFunctions::getObject(_objectId, object)) {
1039  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
1040  return;
1041  }
1042 
1043  PolyhedralMeshObject* polyMeshObj = NULL;
1044  HexahedralMeshObject* hexMeshObj = NULL;
1045  PluginFunctions::getObject(_objectId, polyMeshObj);
1046  PluginFunctions::getObject(_objectId, hexMeshObj);
1047  if(!polyMeshObj && !hexMeshObj) return;
1048  OpenVolumeMesh::StatusAttrib& status = (polyMeshObj != NULL ?
1049  polyMeshObj->status() :
1050  hexMeshObj->status());
1051 
1052  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
1053  cst_it != status.cstatus_end(); ++cst_it) {
1054  if(cst_it->selected()) cst_it->set_deleted(true);
1055  }
1056 
1057  status.garbage_collection(_preserveManifoldness);
1058 
1059  emit scriptInfo("deleteSelectedCells(ObjectId)");
1060  emit updatedObject(_objectId, UPDATE_ALL);
1061 }
IdList getCellSelection(int _objectId)
Get current cell selection.
void invertHalfFaceSelection(int _objectId)
Invert half-face selection.
void selectAllHalfFaces(int _objectId)
Select all half-faces of a volume mesh.
const UpdateType UPDATE_ALL(UpdateTypeSet(1))
Identifier for all updates.
void deleteSelectedVertices(int _objectId, bool _preserveManifoldness=true)
Delete selected vertices from mesh.
bool getObject(int _identifier, BSplineCurveObject *&_object)
void deselectAllFaces(int _objectId)
Deselect all faces of a volume mesh.
void invertCellSelection(int _objectId)
Invert cell selection.
void garbage_collection(bool _preserveManifoldness=false)
Delete all entities that have been marked as deleted.
const UpdateType UPDATE_SELECTION(UpdateTypeSet(1)<< 4)
Selection updated.
void selectAllHalfEdges(int _objectId)
Select all half-edges of a volume mesh.
void selectCells(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific cells of a volume mesh.
void selectHalfEdges(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific half-edges of a volume mesh.
void invertFaceSelection(int _objectId)
Invert face selection.
void selectAllVertices(int _objectId)
Select all vertices of a volume mesh.
void selectHalfFaces(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific half-faces of a volume mesh.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:192
void invertEdgeSelection(int _objectId)
Invert edge selection.
void deleteSelectedEdges(int _objectId, bool _preserveManifoldness=true)
Delete selected edges from mesh.
void deselectAllHalfEdges(int _objectId)
Deselect all half-edges of a volume mesh.
const StatusAttrib & status() const
return a pointer to the mesh
void selectAllFaces(int _objectId)
Select all faces of a volume mesh.
void selectFaces(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific faces of a volume mesh.
IdList getVertexSelection(int _objectId)
Get current vertex selection.
void selectEdges(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific edges of a volume mesh.
void deselectAllVertices(int _objectId)
Deselect all vertices of a volume mesh.
void selectVertices(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific vertices of a volume mesh.
IdList getHalfFaceSelection(int _objectId)
Get current half-face selection.
void deleteSelectedCells(int _objectId, bool _preserveManifoldness=true)
Delete selected cells from mesh.
void invertHalfEdgeSelection(int _objectId)
Invert half-edge selection.
IdList getHalfEdgeSelection(int _objectId)
Get current half-edge selection.
void selectAllEdges(int _objectId)
Select all edges of a volume mesh.
void selectAllCells(int _objectId)
Select all cells of a volume mesh.
IdList getEdgeSelection(int _objectId)
Get current edge selection.
void deleteSelectedFaces(int _objectId, bool _preserveManifoldness=true)
Delete selected faces from mesh.
void invertVertexSelection(int _objectId)
Invert vertex selection.
void deselectAllCells(int _objectId)
Deselect all cells of a volume mesh.
IdList getFaceSelection(int _objectId)
Get current face selection.
void deselectAllEdges(int _objectId)
Deselect all edges of a volume mesh.
void deselectAllHalfFaces(int _objectId)
Deselect all half-faces of a volume mesh.