Developer Documentation
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 #include "VolumeMeshSelectionPlugin.hh"
45 
46 /*
47  * Vertices
48  */
50 
51  BaseObjectData* object = 0;
52 
53  if(!PluginFunctions::getObject(_objectId, object)) {
54  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
55  return;
56  }
57 
58  if (getStatus(_objectId) == NULL)
59  return;
60 
61  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
62 
63  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
64  vst_it != status.vstatus_end(); ++vst_it) {
65  vst_it->set_selected(true);
66  }
67 
68  emit scriptInfo("selectAllVertices(ObjectId)");
69  emit updatedObject(_objectId, UPDATE_SELECTION);
70 }
71 
73 
74  BaseObjectData* object = 0;
75 
76  if(!PluginFunctions::getObject(_objectId, object)) {
77  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
78  return;
79  }
80 
81  if (getStatus(_objectId) == NULL)
82  return;
83 
84  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
85 
86  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
87  vst_it != status.vstatus_end(); ++vst_it) {
88  vst_it->set_selected(false);
89  }
90 
91  emit scriptInfo("deselectAllVertices(ObjectId)");
92  emit updatedObject(_objectId, UPDATE_SELECTION);
93 }
94 
96 
97  BaseObjectData* object = 0;
98 
99  if(!PluginFunctions::getObject(_objectId, object)) {
100  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
101  return;
102  }
103 
104  if (getStatus(_objectId) == NULL)
105  return;
106 
107  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
108 
109  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
110  vst_it != status.vstatus_end(); ++vst_it) {
111  vst_it->set_selected(!vst_it->selected());
112  }
113 
114  emit scriptInfo("invertVertexSelection(ObjectId)");
115  emit updatedObject(_objectId, UPDATE_SELECTION);
116 }
117 
118 void VolumeMeshSelectionPlugin::selectVertices(int _objectId, const IdList& _ids, bool _deselect) {
119 
120  if(_ids.empty()) return;
121 
122  BaseObjectData* object = 0;
123 
124  if(!PluginFunctions::getObject(_objectId, object)) {
125  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
126  return;
127  }
128 
129  if (getStatus(_objectId) == NULL)
130  return;
131 
132  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
133 
134  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
135  status[OpenVolumeMesh::VertexHandle(*v_it)].set_selected(!_deselect);
136  }
137 
138  QString selection = "selectVertices(ObjectId, [ " + QString::number(_ids[0]);
139 
140  for (uint i = 1 ; i < _ids.size(); ++i) {
141  selection += ", " + QString::number(_ids[i]);
142  }
143 
144  selection += " ])";
145 
146  emit scriptInfo(selection);
147  emit updatedObject(_objectId, UPDATE_SELECTION);
148 }
149 
151 
152  BaseObjectData* object = 0;
153 
154  IdList list;
155 
156  if(!PluginFunctions::getObject(_objectId, object)) {
157  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
158  return list;
159  }
160 
161  if (getStatus(_objectId) == NULL)
162  return list;
163 
164  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
165 
166  int id = 0;
167  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
168  vst_it != status.vstatus_end(); ++vst_it, ++id) {
169  if(vst_it->selected()) list.push_back(id);
170  }
171 
172  return list;
173 }
174 
175 void VolumeMeshSelectionPlugin::deleteSelectedVertices(int _objectId, bool _preserveManifoldness) {
176 
177  BaseObjectData* object = 0;
178 
179  if(!PluginFunctions::getObject(_objectId, object)) {
180  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
181  return;
182  }
183 
184  if (getStatus(_objectId) == NULL)
185  return;
186 
187  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
188 
189  for(OpenVolumeMesh::StatusAttrib::vstatus_iterator vst_it = status.vstatus_begin();
190  vst_it != status.vstatus_end(); ++vst_it) {
191  if(vst_it->selected()) vst_it->set_deleted(true);
192  }
193 
194  status.garbage_collection(_preserveManifoldness);
195 
196  emit scriptInfo("deleteSelectedVertices(ObjectId)");
197  emit updatedObject(_objectId, UPDATE_ALL);
198 }
199 
200 /*
201  * Edges
202  */
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  if (getStatus(_objectId) == NULL)
213  return;
214 
215  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
216 
217  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
218  est_it != status.estatus_end(); ++est_it) {
219  est_it->set_selected(true);
220  }
221 
222  emit scriptInfo("selectAllEdges(ObjectId)");
223  emit updatedObject(_objectId, UPDATE_SELECTION);
224 }
225 
227 
228  BaseObjectData* object = 0;
229 
230  if(!PluginFunctions::getObject(_objectId, object)) {
231  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
232  return;
233  }
234 
235  if (getStatus(_objectId) == NULL)
236  return;
237 
238  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
239 
240  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
241  est_it != status.estatus_end(); ++est_it) {
242  est_it->set_selected(false);
243  }
244 
245  emit scriptInfo("deselectAllEdges(ObjectId)");
246  emit updatedObject(_objectId, UPDATE_SELECTION);
247 }
248 
250 
251  BaseObjectData* object = 0;
252 
253  if(!PluginFunctions::getObject(_objectId, object)) {
254  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
255  return;
256  }
257 
258  if (getStatus(_objectId) == NULL)
259  return;
260 
261  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
262 
263  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
264  est_it != status.estatus_end(); ++est_it) {
265  est_it->set_selected(!est_it->selected());
266  }
267 
268  emit scriptInfo("invertEdgeSelection(ObjectId)");
269  emit updatedObject(_objectId, UPDATE_SELECTION);
270 }
271 
272 void VolumeMeshSelectionPlugin::selectEdges(int _objectId, const IdList& _ids, bool _deselect) {
273 
274  if(_ids.empty()) return;
275 
276  BaseObjectData* object = 0;
277 
278  if(!PluginFunctions::getObject(_objectId, object)) {
279  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
280  return;
281  }
282 
283  if (getStatus(_objectId) == NULL)
284  return;
285 
286  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
287 
288  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
289  status[OpenVolumeMesh::EdgeHandle(*v_it)].set_selected(!_deselect);
290  }
291 
292  QString selection = "selectEdges(ObjectId, [ " + QString::number(_ids[0]);
293 
294  for (uint i = 1 ; i < _ids.size(); ++i) {
295  selection += ", " + QString::number(_ids[i]);
296  }
297 
298  selection += " ])";
299 
300  emit scriptInfo(selection);
301  emit updatedObject(_objectId, UPDATE_SELECTION);
302 }
303 
305 
306  BaseObjectData* object = 0;
307 
308  IdList list;
309 
310  if(!PluginFunctions::getObject(_objectId, object)) {
311  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
312  return list;
313  }
314 
315  if (getStatus(_objectId) == NULL)
316  return list;
317 
318  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
319 
320  int id = 0;
321  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
322  est_it != status.estatus_end(); ++est_it, ++id) {
323  if(est_it->selected()) list.push_back(id);
324  }
325 
326  return list;
327 }
328 
329 void VolumeMeshSelectionPlugin::deleteSelectedEdges(int _objectId, bool _preserveManifoldness) {
330 
331  BaseObjectData* object = 0;
332 
333  if(!PluginFunctions::getObject(_objectId, object)) {
334  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
335  return;
336  }
337 
338  if (getStatus(_objectId) == NULL)
339  return;
340 
341  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
342 
343  for(OpenVolumeMesh::StatusAttrib::estatus_iterator est_it = status.estatus_begin();
344  est_it != status.estatus_end(); ++est_it) {
345  if(est_it->selected()) est_it->set_deleted(true);
346  }
347 
348  status.garbage_collection(_preserveManifoldness);
349 
350  emit scriptInfo("deleteSelectedEdges(ObjectId)");
351  emit updatedObject(_objectId, UPDATE_ALL);
352 }
353 
354 /*
355  * HalfEdges
356  */
358 
359  BaseObjectData* object = 0;
360 
361  if(!PluginFunctions::getObject(_objectId, object)) {
362  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
363  return;
364  }
365 
366  if (getStatus(_objectId) == NULL)
367  return;
368 
369  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
370 
371  for(OpenVolumeMesh::StatusAttrib::hestatus_iterator hest_it = status.hestatus_begin();
372  hest_it != status.hestatus_end(); ++hest_it) {
373  hest_it->set_selected(true);
374  }
375 
376  emit scriptInfo("selectAllHalfEdges(ObjectId)");
377  emit updatedObject(_objectId, UPDATE_SELECTION);
378 }
379 
381 
382  BaseObjectData* object = 0;
383 
384  if(!PluginFunctions::getObject(_objectId, object)) {
385  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
386  return;
387  }
388 
389  if (getStatus(_objectId) == NULL)
390  return;
391 
392  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
393 
394  for(OpenVolumeMesh::StatusAttrib::hestatus_iterator hest_it = status.hestatus_begin();
395  hest_it != status.hestatus_end(); ++hest_it) {
396  hest_it->set_selected(false);
397  }
398 
399  emit scriptInfo("deselectAllHalfEdges(ObjectId)");
400  emit updatedObject(_objectId, UPDATE_SELECTION);
401 }
402 
404 
405  BaseObjectData* object = 0;
406 
407  if(!PluginFunctions::getObject(_objectId, object)) {
408  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
409  return;
410  }
411 
412  if (getStatus(_objectId) == NULL)
413  return;
414 
415  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
416 
417  for(OpenVolumeMesh::StatusAttrib::hestatus_iterator hest_it = status.hestatus_begin();
418  hest_it != status.hestatus_end(); ++hest_it) {
419  hest_it->set_selected(!hest_it->selected());
420  }
421 
422  emit scriptInfo("invertHalfEdgeSelection(ObjectId)");
423  emit updatedObject(_objectId, UPDATE_SELECTION);
424 }
425 
426 void VolumeMeshSelectionPlugin::selectHalfEdges(int _objectId, const IdList& _ids, bool _deselect) {
427 
428  if(_ids.empty()) return;
429 
430  BaseObjectData* object = 0;
431 
432  if(!PluginFunctions::getObject(_objectId, object)) {
433  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
434  return;
435  }
436 
437  if (getStatus(_objectId) == NULL)
438  return;
439 
440  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
441 
442  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
443  status[OpenVolumeMesh::HalfEdgeHandle(*v_it)].set_selected(!_deselect);
444  }
445 
446  QString selection = "selectHalfEdges(ObjectId, [ " + QString::number(_ids[0]);
447 
448  for (uint i = 1 ; i < _ids.size(); ++i) {
449  selection += ", " + QString::number(_ids[i]);
450  }
451 
452  selection += " ])";
453 
454  emit scriptInfo(selection);
455  emit updatedObject(_objectId, UPDATE_SELECTION);
456 }
457 
459 
460  BaseObjectData* object = 0;
461 
462  IdList list;
463 
464  if(!PluginFunctions::getObject(_objectId, object)) {
465  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
466  return list;
467  }
468 
469  if (getStatus(_objectId) == NULL)
470  return list;
471 
472  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
473 
474  int id = 0;
475  for(OpenVolumeMesh::StatusAttrib::hestatus_iterator hest_it = status.hestatus_begin();
476  hest_it != status.hestatus_end(); ++hest_it, ++id) {
477  if(hest_it->selected()) list.push_back(id);
478  }
479 
480  return list;
481 }
482 
483 /*
484  * Faces
485  */
487 
488  BaseObjectData* object = 0;
489 
490  if(!PluginFunctions::getObject(_objectId, object)) {
491  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
492  return;
493  }
494 
495  if (getStatus(_objectId) == NULL)
496  return;
497 
498  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
499 
500  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
501  fst_it != status.fstatus_end(); ++fst_it) {
502  fst_it->set_selected(true);
503  }
504 
505  emit scriptInfo("selectAllFaces(ObjectId)");
506  emit updatedObject(_objectId, UPDATE_SELECTION);
507 }
508 
510 
511  BaseObjectData* object = 0;
512 
513  if(!PluginFunctions::getObject(_objectId, object)) {
514  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
515  return;
516  }
517 
518  if (getStatus(_objectId) == NULL)
519  return;
520 
521  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
522 
523  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
524  fst_it != status.fstatus_end(); ++fst_it) {
525  fst_it->set_selected(false);
526  }
527 
528  emit scriptInfo("deselectAllFaces(ObjectId)");
529  emit updatedObject(_objectId, UPDATE_SELECTION);
530 }
531 
533 
534  BaseObjectData* object = 0;
535 
536  if(!PluginFunctions::getObject(_objectId, object)) {
537  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
538  return;
539  }
540 
541  if (getStatus(_objectId) == NULL)
542  return;
543 
544  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
545 
546  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
547  fst_it != status.fstatus_end(); ++fst_it) {
548  fst_it->set_selected(!fst_it->selected());
549  }
550 
551  emit scriptInfo("invertFaceSelection(ObjectId)");
552  emit updatedObject(_objectId, UPDATE_SELECTION);
553 }
554 
555 void VolumeMeshSelectionPlugin::selectFaces(int _objectId, const IdList& _ids, bool _deselect) {
556 
557  if(_ids.empty()) return;
558 
559  BaseObjectData* object = 0;
560 
561  if(!PluginFunctions::getObject(_objectId, object)) {
562  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
563  return;
564  }
565 
566  if (getStatus(_objectId) == NULL)
567  return;
568 
569  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
570 
571  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
572  status[OpenVolumeMesh::FaceHandle(*v_it)].set_selected(!_deselect);
573  }
574 
575  QString selection = "selectFaces(ObjectId, [ " + QString::number(_ids[0]);
576 
577  for (uint i = 1 ; i < _ids.size(); ++i) {
578  selection += ", " + QString::number(_ids[i]);
579  }
580 
581  selection += " ])";
582 
583  emit scriptInfo(selection);
584  emit updatedObject(_objectId, UPDATE_SELECTION);
585 }
586 
588 
589  BaseObjectData* object = 0;
590 
591  IdList list;
592 
593  if(!PluginFunctions::getObject(_objectId, object)) {
594  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
595  return list;
596  }
597 
598  if (getStatus(_objectId) == NULL)
599  return list;
600 
601  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
602 
603  int id = 0;
604  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
605  fst_it != status.fstatus_end(); ++fst_it, ++id) {
606  if(fst_it->selected()) list.push_back(id);
607  }
608 
609  return list;
610 }
611 
612 void VolumeMeshSelectionPlugin::deleteSelectedFaces(int _objectId, bool _preserveManifoldness) {
613 
614  BaseObjectData* object = 0;
615 
616  if(!PluginFunctions::getObject(_objectId, object)) {
617  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
618  return;
619  }
620 
621  if (getStatus(_objectId) == NULL)
622  return;
623 
624  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
625 
626  for(OpenVolumeMesh::StatusAttrib::fstatus_iterator fst_it = status.fstatus_begin();
627  fst_it != status.fstatus_end(); ++fst_it) {
628  if(fst_it->selected()) fst_it->set_deleted(true);
629  }
630 
631  status.garbage_collection(_preserveManifoldness);
632 
633  emit scriptInfo("deleteSelectedFaces(ObjectId)");
634  emit updatedObject(_objectId, UPDATE_ALL);
635 }
636 
637 /*
638  * HalfFaces
639  */
641 
642  BaseObjectData* object = 0;
643 
644  if(!PluginFunctions::getObject(_objectId, object)) {
645  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
646  return;
647  }
648 
649  if (getStatus(_objectId) == NULL)
650  return;
651 
652  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
653 
654  for(OpenVolumeMesh::StatusAttrib::hfstatus_iterator hfst_it = status.hfstatus_begin();
655  hfst_it != status.hfstatus_end(); ++hfst_it) {
656  hfst_it->set_selected(true);
657  }
658 
659  emit scriptInfo("selectAllHalfFaces(ObjectId)");
660  emit updatedObject(_objectId, UPDATE_SELECTION);
661 }
662 
664 
665  BaseObjectData* object = 0;
666 
667  if(!PluginFunctions::getObject(_objectId, object)) {
668  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
669  return;
670  }
671 
672  if (getStatus(_objectId) == NULL)
673  return;
674 
675  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
676 
677  for(OpenVolumeMesh::StatusAttrib::hfstatus_iterator hfst_it = status.hfstatus_begin();
678  hfst_it != status.hfstatus_end(); ++hfst_it) {
679  hfst_it->set_selected(false);
680  }
681 
682  emit scriptInfo("deselectAllHalfFaces(ObjectId)");
683  emit updatedObject(_objectId, UPDATE_SELECTION);
684 }
685 
687 
688  BaseObjectData* object = 0;
689 
690  if(!PluginFunctions::getObject(_objectId, object)) {
691  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
692  return;
693  }
694 
695  if (getStatus(_objectId) == NULL)
696  return;
697 
698  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
699 
700  for(OpenVolumeMesh::StatusAttrib::hfstatus_iterator hfst_it = status.hfstatus_begin();
701  hfst_it != status.hfstatus_end(); ++hfst_it) {
702  hfst_it->set_selected(!hfst_it->selected());
703  }
704 
705  emit scriptInfo("invertHalfFaceSelection(ObjectId)");
706  emit updatedObject(_objectId, UPDATE_SELECTION);
707 }
708 
709 void VolumeMeshSelectionPlugin::selectHalfFaces(int _objectId, const IdList& _ids, bool _deselect) {
710 
711  if(_ids.empty()) return;
712 
713  BaseObjectData* object = 0;
714 
715  if(!PluginFunctions::getObject(_objectId, object)) {
716  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
717  return;
718  }
719 
720  if (getStatus(_objectId) == NULL)
721  return;
722 
723  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
724 
725  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
726  status[OpenVolumeMesh::HalfFaceHandle(*v_it)].set_selected(!_deselect);
727  }
728 
729  QString selection = "selectHalfFaces(ObjectId, [ " + QString::number(_ids[0]);
730 
731  for (uint i = 1 ; i < _ids.size(); ++i) {
732  selection += ", " + QString::number(_ids[i]);
733  }
734 
735  selection += " ])";
736 
737  emit scriptInfo(selection);
738  emit updatedObject(_objectId, UPDATE_SELECTION);
739 }
740 
742 
743  BaseObjectData* object = 0;
744 
745  IdList list;
746 
747  if(!PluginFunctions::getObject(_objectId, object)) {
748  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
749  return list;
750  }
751 
752  if (getStatus(_objectId) == NULL)
753  return list;
754 
755  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
756 
757  int id = 0;
758  for(OpenVolumeMesh::StatusAttrib::hfstatus_iterator hfst_it = status.hfstatus_begin();
759  hfst_it != status.hfstatus_end(); ++hfst_it, ++id) {
760  if(hfst_it->selected()) list.push_back(id);
761  }
762 
763  return list;
764 }
765 /*
766  * Cells
767  */
769 
770  BaseObjectData* object = 0;
771 
772  if(!PluginFunctions::getObject(_objectId, object)) {
773  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
774  return;
775  }
776 
777  if (getStatus(_objectId) == NULL)
778  return;
779 
780  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
781 
782  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
783  cst_it != status.cstatus_end(); ++cst_it) {
784  cst_it->set_selected(true);
785  }
786 
787  emit scriptInfo("selectAllCells(ObjectId)");
788  emit updatedObject(_objectId, UPDATE_SELECTION);
789 }
790 
792 
793  BaseObjectData* object = 0;
794 
795  if(!PluginFunctions::getObject(_objectId, object)) {
796  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
797  return;
798  }
799 
800  if (getStatus(_objectId) == NULL)
801  return;
802 
803  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
804 
805  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
806  cst_it != status.cstatus_end(); ++cst_it) {
807  cst_it->set_selected(false);
808  }
809 
810  emit scriptInfo("deselectAllCells(ObjectId)");
811  emit updatedObject(_objectId, UPDATE_SELECTION);
812 }
813 
815 
816  BaseObjectData* object = 0;
817 
818  if(!PluginFunctions::getObject(_objectId, object)) {
819  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
820  return;
821  }
822 
823  if (getStatus(_objectId) == NULL)
824  return;
825 
826  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
827 
828  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
829  cst_it != status.cstatus_end(); ++cst_it) {
830  cst_it->set_selected(!cst_it->selected());
831  }
832 
833  emit scriptInfo("invertCellSelection(ObjectId)");
834  emit updatedObject(_objectId, UPDATE_SELECTION);
835 }
836 
837 void VolumeMeshSelectionPlugin::selectCells(int _objectId, const IdList& _ids, bool _deselect) {
838 
839  if(_ids.empty()) return;
840 
841  BaseObjectData* object = 0;
842 
843  if(!PluginFunctions::getObject(_objectId, object)) {
844  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
845  return;
846  }
847 
848  if (getStatus(_objectId) == NULL)
849  return;
850 
851  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
852 
853  for(IdList::const_iterator v_it = _ids.begin(); v_it != _ids.end(); ++v_it) {
854  status[OpenVolumeMesh::CellHandle(*v_it)].set_selected(!_deselect);
855  }
856 
857  QString selection = "selectCells(ObjectId, [ " + QString::number(_ids[0]);
858 
859  for (uint i = 1 ; i < _ids.size(); ++i) {
860  selection += ", " + QString::number(_ids[i]);
861  }
862 
863  selection += " ])";
864 
865  emit scriptInfo(selection);
866  emit updatedObject(_objectId, UPDATE_SELECTION);
867 }
868 
870 
871  BaseObjectData* object = 0;
872 
873  IdList list;
874 
875  if(!PluginFunctions::getObject(_objectId, object)) {
876  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
877  return list;
878  }
879 
880  if (getStatus(_objectId) == NULL)
881  return list;
882 
883  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
884 
885  int id = 0;
886  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
887  cst_it != status.cstatus_end(); ++cst_it, ++id) {
888  if(cst_it->selected()) list.push_back(id);
889  }
890 
891  return list;
892 }
893 
894 void VolumeMeshSelectionPlugin::deleteSelectedCells(int _objectId, bool _preserveManifoldness) {
895 
896  BaseObjectData* object = 0;
897 
898  if(!PluginFunctions::getObject(_objectId, object)) {
899  emit log(LOGERR, tr("Could not get object with id %1").arg(_objectId));
900  return;
901  }
902 
903  if (getStatus(_objectId) == NULL)
904  return;
905 
906  OpenVolumeMesh::StatusAttrib& status = *getStatus(_objectId);
907 
908  for(OpenVolumeMesh::StatusAttrib::cstatus_iterator cst_it = status.cstatus_begin();
909  cst_it != status.cstatus_end(); ++cst_it) {
910  if(cst_it->selected()) cst_it->set_deleted(true);
911  }
912 
913  status.garbage_collection(_preserveManifoldness);
914 
915  emit scriptInfo("deleteSelectedCells(ObjectId)");
916  emit updatedObject(_objectId, UPDATE_ALL);
917 }
void selectAllHalfFaces(int _objectId)
Select all half-faces of a volume mesh.
void deselectAllHalfFaces(int _objectId)
Deselect 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.
void deselectAllFaces(int _objectId)
Deselect all faces of a volume mesh.
void deselectAllVertices(int _objectId)
Deselect all vertices of a volume mesh.
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 invertHalfFaceSelection(int _objectId)
Invert half-face selection.
void selectHalfEdges(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific half-edges of a volume mesh.
OpenVolumeMesh::StatusAttrib * getStatus(int _objectId)
Handle to selection environment.
IdList getHalfEdgeSelection(int _objectId)
Get current half-edge selection.
void invertHalfEdgeSelection(int _objectId)
Invert half-edge selection.
IdList getHalfFaceSelection(int _objectId)
Get current half-face selection.
void selectAllFaces(int _objectId)
Select all faces of a volume mesh.
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
void selectVertices(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific vertices of a volume mesh.
IdList getCellSelection(int _objectId)
Get current cell selection.
std::vector< int > IdList
Standard Type for id Lists used for scripting.
Definition: DataTypes.hh:179
void selectAllVertices(int _objectId)
Select all vertices of a volume mesh.
void deselectAllHalfEdges(int _objectId)
Deselect all half-edges of a volume mesh.
IdList getVertexSelection(int _objectId)
Get current vertex selection.
void deselectAllCells(int _objectId)
Deselect all cells of a volume mesh.
void deselectAllEdges(int _objectId)
Deselect all edges of a volume mesh.
void selectHalfFaces(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific half-faces of a volume mesh.
void deleteSelectedCells(int _objectId, bool _preserveManifoldness=true)
Delete selected cells from mesh.
void selectAllCells(int _objectId)
Select all cells of a volume mesh.
void selectFaces(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific faces of a volume mesh.
void invertEdgeSelection(int _objectId)
Invert edge selection.
IdList getFaceSelection(int _objectId)
Get current face selection.
void selectAllEdges(int _objectId)
Select all edges of a volume mesh.
void invertVertexSelection(int _objectId)
Invert vertex selection.
IdList getEdgeSelection(int _objectId)
Get current edge selection.
void selectCells(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific cells of a volume mesh.
void selectEdges(int _objectId, const IdList &_ids, bool _deselect=false)
Select specific edges of a volume mesh.
void deleteSelectedFaces(int _objectId, bool _preserveManifoldness=true)
Delete selected faces from mesh.
void invertCellSelection(int _objectId)
Invert cell selection.
void invertFaceSelection(int _objectId)
Invert face selection.
void deleteSelectedEdges(int _objectId, bool _preserveManifoldness=true)
Delete selected edges from mesh.