Developer Documentation

OVMPropertyVisualizerVectorT_impl.hh
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
45 #define OVM_PROPERTY_VISUALIZER_VECTOR_CC
46
47 #include <ACG/Utils/ColorConversion.hh>
48 #include "OVMPropertyVisualizerVector.hh"
49
50
51 template <typename MeshT>
52 OVMPropertyVisualizerVector<MeshT>::OVMPropertyVisualizerVector(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo)
53 : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
54 {
55 if (PropertyVisualizer::widget) delete PropertyVisualizer::widget;
56 VectorWidget* w = new VectorWidget();
57 w->paramVector->setTitle(QString("3D Vector Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
58 PropertyVisualizer::widget = w;
59
60 BaseObjectData *bod;
61 PluginFunctions::getObject(objectID, bod);
62 lineNode = new ACG::SceneGraph::LineNode(ACG::SceneGraph::LineNode::LineSegmentsMode, bod->manipulatorNode());
63 w->vectors_edges_rb->hide();
64 this->connect(w->lineWidth, QOverload<double>::of(&QDoubleSpinBox::valueChanged),
65 [this](double value) {lineNode->set_line_width(value);});
66 }
67
68 template <typename MeshT>
69 void OVMPropertyVisualizerVector<MeshT>::clear()
70 {
71 lineNode->clear();
72 OVMPropertyVisualizer<MeshT>::clear();
73 }
74
75 template <typename MeshT>
76 void OVMPropertyVisualizerVector<MeshT>::duplicateProperty()
77 {
78 OVMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<ACG::Vec3d>();
79 }
80
81 template<typename MeshT>
82 template<typename PropType, typename EntityIterator>
83 void OVMPropertyVisualizerVector<MeshT>::visualizeVectorAsColorForEntity(PropType prop, EntityIterator e_begin, EntityIterator e_end, bool normalized) {
84 if (!prop)
85 throw VizException("Getting PropHandle from mesh for selected property failed.");
86 VolumeMeshObject<MeshT>* object;
87 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
88 for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) {
89 ACG::Vec3d v = prop[*e_it];
90 if (normalized)
91 v = v.normalized() * 0.5 + ACG::Vec3d(0.5);
92 else
93 v = v.min(ACG::Vec3d(1, 1, 1)).max(ACG::Vec3d(0, 0, 0));
94 object->colors()[*e_it] = ACG::Vec4f(v[0], v[1], v[2], 1.0);
95 }
96 }
97
98 template <typename MeshT>
99 void OVMPropertyVisualizerVector<MeshT>::visualizeCellProp(bool _setDrawMode)
100 {
101 VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
102 if (w->vectors_colors_rb->isChecked())
103 {
104 OpenVolumeMesh::CellPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_cell_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
105 visualizeVectorAsColorForEntity(prop,
106 OVMPropertyVisualizer<MeshT>::mesh->cells_begin(),
107 OVMPropertyVisualizer<MeshT>::mesh->cells_end(),
108 w->normalize_colors->isChecked());
109 if (_setDrawMode)
110 {
111 VolumeMeshObject<MeshT>* object;
112 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
113 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.cellsColoredPerCell);
114 }
115 }
116 else visualizeCellPropAsStrokes();
117 }
118
119 template <typename MeshT>
120 void OVMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode)
121 {
122 VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
123 if (w->vectors_colors_rb->isChecked())
124 {
125 OpenVolumeMesh::FacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_face_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
126 visualizeVectorAsColorForEntity(prop,
127 OVMPropertyVisualizer<MeshT>::mesh->faces_begin(),
128 OVMPropertyVisualizer<MeshT>::mesh->faces_end(),
129 w->normalize_colors->isChecked());
130 if (_setDrawMode)
131 {
132 VolumeMeshObject<MeshT>* object;
133 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
134 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.facesColoredPerFace);
135 }
136 }
137 else visualizeFacePropAsStrokes();
138 }
139
140
141 template <typename MeshT>
142 void OVMPropertyVisualizerVector<MeshT>::visualizeHalffaceProp(bool _setDrawMode)
143 {
144 VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
145 if (w->vectors_colors_rb->isChecked())
146 {
147 OpenVolumeMesh::HalfFacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfface_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
148 visualizeVectorAsColorForEntity(prop,
149 OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin(),
150 OVMPropertyVisualizer<MeshT>::mesh->halffaces_end(),
151 w->normalize_colors->isChecked());
152 if (_setDrawMode)
153 {
154 VolumeMeshObject<MeshT>* object;
155 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
156 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halffacesColoredPerHalfface);
157 }
158 }
159 else visualizeHalffacePropAsStrokes();
160 }
161
162 template <typename MeshT>
163 void OVMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode)
164 {
165 VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
166 if (w->vectors_colors_rb->isChecked())
167 {
168 OpenVolumeMesh::EdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_edge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
169 visualizeVectorAsColorForEntity(prop,
170 OVMPropertyVisualizer<MeshT>::mesh->edges_begin(),
171 OVMPropertyVisualizer<MeshT>::mesh->edges_end(),
172 w->normalize_colors->isChecked());
173 if (_setDrawMode)
174 {
175 VolumeMeshObject<MeshT>* object;
176 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
177 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.edgesColoredPerEdge);
178 }
179 }
180 else visualizeEdgePropAsStrokes();
181 }
182
183 template <typename MeshT>
184 void OVMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode)
185 {
186 VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
187 if (w->vectors_colors_rb->isChecked())
188 {
189 OpenVolumeMesh::HalfEdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfedge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
190 visualizeVectorAsColorForEntity(prop,
191 OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin(),
192 OVMPropertyVisualizer<MeshT>::mesh->halfedges_end(),
193 w->normalize_colors->isChecked());
194 if (_setDrawMode)
195 {
196 VolumeMeshObject<MeshT>* object;
197 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
198 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halfedgesColoredPerHalfedge);
199 }
200 }
201 else visualizeHalfedgePropAsStrokes();
202 }
203
204 template <typename MeshT>
205 void OVMPropertyVisualizerVector<MeshT>::visualizeVertexProp(bool _setDrawMode)
206 {
207 VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
208 if (w->vectors_colors_rb->isChecked())
209 {
210 OpenVolumeMesh::VertexPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_vertex_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
211 visualizeVectorAsColorForEntity(prop,
212 OVMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
213 OVMPropertyVisualizer<MeshT>::mesh->vertices_end(),
214 w->normalize_colors->isChecked());
215 if (_setDrawMode)
216 {
217 VolumeMeshObject<MeshT>* object;
218 PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
219 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.verticesColored);
220 }
221 }
222 else visualizeVertexPropAsStrokes();
223 }
224
225 template <typename MeshT>
226 void OVMPropertyVisualizerVector<MeshT>::visualizeFacePropAsStrokes()
227 {
228 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
229
230 lineNode->clear();
231
232 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
233
234 OpenVolumeMesh::FacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_face_property<ACG::Vec3d>(PropertyVisualizer::propertyInfo.propName());
235
236 if ( !prop )
237 return;
238
239 OpenVolumeMesh::FaceIter f_begin(OVMPropertyVisualizer<MeshT>::mesh->faces_begin()), f_end(OVMPropertyVisualizer<MeshT>::mesh->faces_end());
240 for (OpenVolumeMesh::FaceIter f_it = f_begin; f_it != f_end; ++f_it){
241
242 ACG::Vec3d center(0.0, 0.0, 0.0);
243 int vCount = 0;
244
245 OpenVolumeMesh::HalfFaceHandle hfh = OVMPropertyVisualizer<MeshT>::mesh->halfface_handle(*f_it, 0);
246 for (OpenVolumeMesh::HalfFaceVertexIter hfv_it = OVMPropertyVisualizer<MeshT>::mesh->hfv_iter(hfh); hfv_it; ++hfv_it){
247 vCount++;
248 center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*hfv_it);
249 }
250
251 center /= vCount;
252
253 ACG::Vec3d v = prop[*f_it];
254
255 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
256 v.normalize();
257
258 if(vectorWidget->scale->isChecked())
259 v *= vectorWidget->scaleBox->value();
260
261 lineNode->add_line( center, (center+v) );
262 lineNode->add_color(color);
263 }
264 }
265
266 template <typename MeshT>
267 void OVMPropertyVisualizerVector<MeshT>::visualizeEdgePropAsStrokes()
268 {
269 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
270
271 lineNode->clear();
272
273 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
274
275 OpenVolumeMesh::EdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_edge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
276 if ( !prop )
277 return;
278
279 OpenVolumeMesh::EdgeIter e_begin(OVMPropertyVisualizer<MeshT>::mesh->edges_begin()), e_end(OVMPropertyVisualizer<MeshT>::mesh->edges_end());
280 for (OpenVolumeMesh::EdgeIter e_it = e_begin; e_it != e_end; ++e_it){
281
282 OpenVolumeMesh::OpenVolumeMeshEdge edge = OVMPropertyVisualizer<MeshT>::mesh->edge(*e_it);
283 ACG::Vec3d v1 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.from_vertex());
284 ACG::Vec3d v2 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.to_vertex());
285 ACG::Vec3d start = 0.5*(v1+v2);
286
287 ACG::Vec3d v = prop[*e_it];
288
289 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
290 v.normalize();
291
292
293
294 if(vectorWidget->scale->isChecked())
295 v *= vectorWidget->scaleBox->value();
296
297 lineNode->add_line( start, (start+v) );
298 lineNode->add_color(color);
299 }
300 }
301
302 template <typename MeshT>
303 void OVMPropertyVisualizerVector<MeshT>::visualizeHalfedgePropAsStrokes()
304 {
305 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
306
307 lineNode->clear();
308
309 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
310
311 OpenVolumeMesh::HalfEdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfedge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
312 if ( !prop )
313 return;
314
315 OpenVolumeMesh::HalfEdgeIter he_begin(OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin()), he_end(OVMPropertyVisualizer<MeshT>::mesh->halfedges_end());
316 for (OpenVolumeMesh::HalfEdgeIter he_it = he_begin; he_it != he_end; ++he_it){
317
318 OpenVolumeMesh::OpenVolumeMeshEdge edge = OVMPropertyVisualizer<MeshT>::mesh->halfedge(*he_it);
319
320 ACG::Vec3d v1 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.from_vertex());
321 ACG::Vec3d v2 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.to_vertex());
322 ACG::Vec3d start = (2.0*v1+v2)/3.0;
323
324 ACG::Vec3d v = prop[*he_it];
325
326 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
327 v.normalize();
328
329 if(vectorWidget->scale->isChecked())
330 v *= vectorWidget->scaleBox->value();
331
332 lineNode->add_line( start, (start+v) );
333 lineNode->add_color(color);
334 }
335 }
336
337 template <typename MeshT>
338 void OVMPropertyVisualizerVector<MeshT>::visualizeVertexPropAsStrokes()
339 {
340 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
341
342 lineNode->clear();
343
344 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
345
346 OpenVolumeMesh::VertexPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_vertex_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
347 if ( !prop )
348 return;
349
350 OpenVolumeMesh::VertexIter v_begin(OVMPropertyVisualizer<MeshT>::mesh->vertices_begin()), v_end(OVMPropertyVisualizer<MeshT>::mesh->vertices_end());
351 for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it != v_end; ++v_it){
352
353 ACG::Vec3d start = OVMPropertyVisualizer<MeshT>::mesh->vertex(*v_it);
354
355 ACG::Vec3d v = prop[*v_it];
356
357 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
358 v.normalize();
359
360 if(vectorWidget->scale->isChecked())
361 v *= vectorWidget->scaleBox->value();
362
363 lineNode->add_line( start, (start+v) );
364 lineNode->add_color(color);
365 }
366 }
367
368 template <typename MeshT>
369 void OVMPropertyVisualizerVector<MeshT>::visualizeCellPropAsStrokes()
370 {
371 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
372
373 lineNode->clear();
374
375 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
376
377 OpenVolumeMesh::CellPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_cell_property<ACG::Vec3d>(PropertyVisualizer::propertyInfo.propName());
378
379 if ( !prop )
380 return;
381
382 OpenVolumeMesh::CellIter c_begin(OVMPropertyVisualizer<MeshT>::mesh->cells_begin()), c_end(OVMPropertyVisualizer<MeshT>::mesh->cells_end());
383 for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it){
384
385 // Compute cell's center
386 ACG::Vec3d center(0.0, 0.0, 0.0);
387 unsigned int vCount = OVMPropertyVisualizer<MeshT>::mesh->n_vertices_in_cell(*c_it);
388 for(OpenVolumeMesh::CellVertexIter cv_it = OVMPropertyVisualizer<MeshT>::mesh->cv_iter(*c_it); cv_it.valid(); ++cv_it) {
389 center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*cv_it) / (double)vCount;
390 }
391
392 ACG::Vec3d v = prop[*c_it];
393
394 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
395 v.normalize();
396
397 if(vectorWidget->scale->isChecked())
398 v *= vectorWidget->scaleBox->value();
399
400 lineNode->add_line( center, (center+v) );
401 lineNode->add_color(color);
402 }
403 }
404
405 template <typename MeshT>
406 void OVMPropertyVisualizerVector<MeshT>::visualizeHalffacePropAsStrokes()
407 {
408 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
409
410 lineNode->clear();
411
412 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
413
414 OpenVolumeMesh::HalfFacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfface_property<ACG::Vec3d>(PropertyVisualizer::propertyInfo.propName());
415
416 if ( !prop )
417 return;
418
419 OpenVolumeMesh::HalfFaceIter hf_begin(OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin()), hf_end(OVMPropertyVisualizer<MeshT>::mesh->halffaces_end());
420 for (OpenVolumeMesh::HalfFaceIter hf_it = hf_begin; hf_it != hf_end; ++hf_it){
421
422 ACG::Vec3d center(0.0, 0.0, 0.0);
423 int vCount = 0;
424
425 for (OpenVolumeMesh::HalfFaceVertexIter hfv_it = OVMPropertyVisualizer<MeshT>::mesh->hfv_iter(*hf_it); hfv_it; ++hfv_it){
426 vCount++;
427 center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*hfv_it);
428 }
429
430 center /= vCount;
431
432 ACG::Vec3d v = prop[*hf_it];
433
434 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
435 v.normalize();
436
437 if(vectorWidget->scale->isChecked())
438 v *= vectorWidget->scaleBox->value();
439
440 lineNode->add_line( center, (center+v) );
441 lineNode->add_color(color);
442 }
443 }
444
445 template <typename MeshT>
446 QString OVMPropertyVisualizerVector<MeshT>::getPropertyText(unsigned int index)
447 {
448 return OVMPropertyVisualizer<MeshT>::template getPropertyText_<ACG::Vec3d>(index);
449 }
450
451
452 template <typename MeshT>
453 void OVMPropertyVisualizerVector<MeshT>::setCellPropertyFromText(unsigned int index, QString text)
454 {
455 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
456
457 OpenVolumeMesh::CellPropertyT<ACG::Vec3d> prop = mesh->template request_cell_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
458 if ( !prop )
459 {
460 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
461 return;
462 }
463
464 OpenVolumeMesh::CellHandle ch(index);
465
466 prop[ch] = this->strToVec3d(text);
467 }
468
469 template <typename MeshT>
470 void OVMPropertyVisualizerVector<MeshT>::setFacePropertyFromText(unsigned int index, QString text)
471 {
472 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
473
474 OpenVolumeMesh::FacePropertyT<ACG::Vec3d> prop = mesh->template request_face_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
475 if ( !prop )
476 {
477 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
478 return;
479 }
480
481 OpenVolumeMesh::FaceHandle fh(index);
482
483 prop[fh] = this->strToVec3d(text);
484 }
485
486 template <typename MeshT>
487 void OVMPropertyVisualizerVector<MeshT>::setHalffacePropertyFromText(unsigned int index, QString text)
488 {
489 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
490
491 OpenVolumeMesh::HalfFacePropertyT<ACG::Vec3d> prop = mesh->template request_halfface_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
492 if ( !prop )
493 {
494 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
495 return;
496 }
497
498 OpenVolumeMesh::HalfFaceHandle hfh(index);
499
500 prop[hfh] = this->strToVec3d(text);
501 }
502
503 template <typename MeshT>
504 void OVMPropertyVisualizerVector<MeshT>::setEdgePropertyFromText(unsigned int index, QString text)
505 {
506 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
507
508 OpenVolumeMesh::EdgePropertyT<ACG::Vec3d> prop = mesh->template request_edge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
509 if ( !prop )
510 {
511 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
512 return;
513 }
514
515 OpenVolumeMesh::EdgeHandle eh(index);
516
517 prop[eh] = this->strToVec3d(text);
518 }
519
520 template <typename MeshT>
521 void OVMPropertyVisualizerVector<MeshT>::setHalfedgePropertyFromText(unsigned int index, QString text)
522 {
523 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
524
525 OpenVolumeMesh::HalfEdgePropertyT<ACG::Vec3d> prop = mesh->template request_halfedge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
526 if ( !prop )
527 {
528 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
529 return;
530 }
531
532 OpenVolumeMesh::HalfEdgeHandle heh(index);
533
534 prop[heh] = this->strToVec3d(text);
535 }
536
537 template <typename MeshT>
538 void OVMPropertyVisualizerVector<MeshT>::setVertexPropertyFromText(unsigned int index, QString text)
539 {
540 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
541
542 OpenVolumeMesh::VertexPropertyT<ACG::Vec3d> prop = mesh->template request_vertex_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
543 if ( !prop )
544 {
545 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
546 return;
547 }
548
549 OpenVolumeMesh::VertexHandle vh(index);
550
551 prop[vh] = this->strToVec3d(text);
552 }
553
LOGERR
Definition: LoggingInterface.hh:96
OVMPropertyVisualizerVector::clear
void clear() override
Clears a property.
Definition: OVMPropertyVisualizerVectorT_impl.hh:69
OVMPropertyVisualizer::clear
virtual void clear()
Clears a property.
Definition: OVMPropertyVisualizerT_impl.hh:347
OpenVolumeMesh::HalfEdgeIter
Definition: Iterators.hh:945
OVMPropertyVisualizerVector::getPropertyText
QString getPropertyText(unsigned int index) override
Returns the value of a property in text form.
Definition: OVMPropertyVisualizerVectorT_impl.hh:446
OpenVolumeMesh::VertexIter
Definition: Iterators.hh:837
OpenVolumeMesh::EdgeIter
Definition: Iterators.hh:891
OpenVolumeMesh::HandleT< Entity::HalfFace >
ACG::Vec4f
VectorT< float, 4 > Vec4f
Definition: VectorT.hh:138
PluginFunctions::getObject
bool getObject(const int _identifier, BaseObject *&_object)
Get the object which has the given identifier.
Definition: PluginFunctions.cc:296
OpenMesh::VectorT::normalized
auto normalized() const -> decltype(*this/std::declval< VectorT< S, DIM >>().norm())
Definition: Vector11T.hh:445
VectorWidget
Definition: VectorWidget.hh:46
OVMPropertyVisualizer
Definition: OVMPropertyVisualizer.hh:61
OpenMesh::VectorT::min
Scalar min() const
return the minimal component
Definition: Vector11T.hh:512
OpenMesh::VectorT
Definition: Vector11T.hh:83
OpenVolumeMesh::HalfFaceIter
Definition: Iterators.hh:1053
ACG::SceneGraph::LineNode
Definition: LineNode.hh:84
OpenVolumeMesh::CellVertexIter
Definition: Iterators.hh:603
BaseObjectData::manipulatorNode
QtTranslationManipulatorNode * manipulatorNode()
Definition: BaseObjectData.cc:255
OpenVolumeMesh::PropertyTT
Definition: ForwardDeclarations.hh:15
PropertyInfo
Cellection of information about a property.
Definition: Utils.hh:109
BaseObjectData
Definition: BaseObjectData.hh:102
VolumeMeshObject
Definition: VolumeMeshObject.hh:63
OpenVolumeMesh::OpenVolumeMeshEdge
Definition: BaseEntities.hh:52
VizException
Definition: PropertyVisualizer.hh:63
OpenVolumeMesh::FaceIter
Definition: Iterators.hh:999
OpenMesh::VectorT::sqrnorm
decltype(std::declval< S >() *std::declval< S >()) sqrnorm() const
compute squared euclidean norm
Definition: Vector11T.hh:402
OVMPropertyVisualizerVector
Definition: OVMPropertyVisualizerVector.hh:60
OpenVolumeMesh::HalfFaceVertexIter
Definition: Iterators.hh:719
OpenMesh::VectorT::normalize
auto normalize() -> decltype(*this/=std::declval< VectorT< S, DIM >>().norm())
Definition: Vector11T.hh:434
OpenVolumeMesh::CellIter
Definition: Iterators.hh:1107
OVMPropertyVisualizerVector::duplicateProperty
void duplicateProperty() override
Duplicates a property.
Definition: OVMPropertyVisualizerVectorT_impl.hh:76
ACG::Vec3d
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:121