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