Developer Documentation

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
OMPropertyVisualizerVector2T.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: 13620 $ *
45 * $LastChangedBy: moebius $ *
46 * $Date: 2012-02-01 14:51:25 +0100 (Mi, 01 Feb 2012) $ *
47 * *
48 \*===========================================================================*/
49
50 #define OM_PROPERTY_VISUALIZER_VECTOR2_CC
51
52 #include "OMPropertyVisualizerVector2.hh"
53 #include <OpenMesh/Core/Utils/Property.hh>
54
55 template <typename MeshT, typename VectorType>
56 OMPropertyVisualizerVector2<MeshT, VectorType>::OMPropertyVisualizerVector2(MeshT* _mesh, PropertyInfo _propertyInfo)
57 : OMPropertyVisualizer<MeshT>(_mesh, _propertyInfo)
58 {
59 if (PropertyVisualizer::widget) delete PropertyVisualizer::widget;
60 VectorWidget* w = new VectorWidget();
61 w->paramVector->setTitle(QString("2D Vector Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
62 PropertyVisualizer::widget = w;
63
64 lineNode = new ACG::SceneGraph::LineNode( ACG::SceneGraph::LineNode::LineSegmentsMode, dynamic_cast < ACG::SceneGraph::SeparatorNode* >( PluginFunctions::getRootNode() ) );
65
66 if (!_propertyInfo.isFaceProp())
67 {
68 w->vectors_edges_rb->hide();
69 }
70 }
71
72 template <typename MeshT, typename VectorType>
73 void OMPropertyVisualizerVector2<MeshT, VectorType>::clear()
74 {
75 lineNode->clear();
76 OMPropertyVisualizer<MeshT>::clear();
77 }
78
79 template <typename MeshT, typename VectorType>
80 QString OMPropertyVisualizerVector2<MeshT, VectorType>::getPropertyText(unsigned int index)
81 {
82 return OMPropertyVisualizer<MeshT>::template getPropertyText_<VectorType>(index);
83 }
84
85
86 namespace {
87
88 template<typename PROPTYPE, typename VectorType, typename MeshT, typename ENTITY_IT, typename PROPINFO_TYPE>
89 void visualizeVectorAsColorForEntity2(MeshT *mesh, const ENTITY_IT e_begin, const ENTITY_IT e_end,
90 const PROPINFO_TYPE &propinfo) {
91 PROPTYPE prop;
92 if (!mesh->get_property_handle(prop, propinfo.propName()))
93 throw VizException("Getting PropHandle from mesh for selected property failed.");
94 for (ENTITY_IT e_it = e_begin; e_it != e_end; ++e_it) {
95 VectorType v = mesh->property(prop, *e_it).normalized() * .5 + VectorType(0.5);
96 mesh->set_color(*e_it, typename MeshT::Color(v[0], v[1], 0.0, 1.0));
97 }
98 }
99
100 template<typename PROPTYPE, typename MeshT, typename ENTITY_IT, typename PROPINFO_TYPE>
101 void visualizeVectorLengthAsColorForEntity2(
102 MeshT *mesh, const ENTITY_IT e_begin, const ENTITY_IT e_end,
103 const PROPINFO_TYPE &propinfo) {
104 PROPTYPE prop;
105 if (!mesh->get_property_handle(prop, propinfo.propName()))
106 throw VizException("Getting PropHandle from mesh for selected "
107 "property failed.");
108
109 double min = std::numeric_limits<double>::infinity();
110 double max = -std::numeric_limits<double>::infinity();
111
112 for (ENTITY_IT e_it = e_begin; e_it != e_end; ++e_it) {
113 const double val = mesh->property(prop, *e_it).norm();
114 min = std::min(min, val);
115 max = std::max(max, val);
116 }
117
118 ACG::ColorCoder color_coder(min, max);
119
120 for (ENTITY_IT e_it = e_begin; e_it != e_end; ++e_it) {
121 mesh->set_color(*e_it, color_coder(mesh->property(prop, *e_it).norm()));
122 }
123 }
124
125 template <typename VectorType> ACG::Vec3d generateVec3AtLocation(VectorType uv, ACG::Vec3d normal)
126 {
127 ACG::Vec3d tan;
128 if(std::abs(normal[0]) > std::abs(normal[1]))
129 tan = ACG::Vec3d(-normal[2], 0, normal[0]);
130 else tan = ACG::Vec3d(0, normal[2], -normal[1]);
131 ACG::Vec3d bi = normal % tan;
132 return double(uv[0]) * tan.normalize() + double(uv[1]) * bi.normalize();
133 }
134
135 }
136
137 template <typename MeshT, typename VectorType>
138 void OMPropertyVisualizerVector2<MeshT, VectorType>::visualizeFaceProp(bool _setDrawMode)
139 {
140 VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
141 if (w->vectors_edges_rb->isChecked()) {
142 visualizeFacePropOnEdges();
143 } else if (w->vectors_colors_rb->isChecked() ||
144 w->vectors_length_color_rb->isChecked()) {
145 if ( !OMPropertyVisualizer<MeshT>::mesh->has_face_colors() )
146 OMPropertyVisualizer<MeshT>::mesh->request_face_colors();
147
148 if (w->vectors_colors_rb->isChecked()) {
149 visualizeVectorAsColorForEntity2<OpenMesh::FPropHandleT<VectorType>, VectorType >(
150 OMPropertyVisualizer<MeshT>::mesh,
151 OMPropertyVisualizer<MeshT>::mesh->faces_begin(),
152 OMPropertyVisualizer<MeshT>::mesh->faces_end(),
153 PropertyVisualizer::propertyInfo);
154 } else {
155 visualizeVectorLengthAsColorForEntity2<OpenMesh::FPropHandleT<VectorType> >(
156 OMPropertyVisualizer<MeshT>::mesh,
157 OMPropertyVisualizer<MeshT>::mesh->faces_begin(),
158 OMPropertyVisualizer<MeshT>::mesh->faces_end(),
159 PropertyVisualizer::propertyInfo);
160 }
161 if (_setDrawMode)
162 PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED);
163 }
164 else visualizeFacePropAsStrokes();
165 }
166
167 template <typename MeshT, typename VectorType>
168 void OMPropertyVisualizerVector2<MeshT, VectorType>::visualizeEdgeProp(bool _setDrawMode)
169 {
170 VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
171 if (w->vectors_colors_rb->isChecked() ||
172 w->vectors_length_color_rb->isChecked()) {
173 if ( !OMPropertyVisualizer<MeshT>::mesh->has_edge_colors() )
174 OMPropertyVisualizer<MeshT>::mesh->request_edge_colors();
175 MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
176 if ( !mesh->has_edge_colors() )
177 mesh->request_edge_colors();
178 if (w->vectors_colors_rb->isChecked()) {
179 visualizeVectorAsColorForEntity2<
180 OpenMesh::EPropHandleT<VectorType>, VectorType >(
181 mesh,
182 mesh->edges_begin(),
183 mesh->edges_end(),
184 PropertyVisualizer::propertyInfo);
185 } else {
186 visualizeVectorLengthAsColorForEntity2<
187 OpenMesh::EPropHandleT<VectorType> >(
188 mesh,
189 mesh->edges_begin(),
190 mesh->edges_end(),
191 PropertyVisualizer::propertyInfo);
192 }
193 if (_setDrawMode)
194 PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::EDGES_COLORED);
195 }
196 else visualizeEdgePropAsStrokes();
197 }
198
199 template <typename MeshT, typename VectorType>
200 void OMPropertyVisualizerVector2<MeshT, VectorType>::visualizeHalfedgeProp(bool _setDrawMode)
201 {
202 VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
203 if (w->vectors_colors_rb->isChecked() ||
204 w->vectors_length_color_rb->isChecked()) {
205 if ( !OMPropertyVisualizer<MeshT>::mesh->has_halfedge_colors() )
206 OMPropertyVisualizer<MeshT>::mesh->request_halfedge_colors();
207 MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
208 if ( ! mesh->has_halfedge_colors() )
209 mesh->request_halfedge_colors();
210
211 if (w->vectors_colors_rb->isChecked()) {
212 visualizeVectorAsColorForEntity2<
213 OpenMesh::HPropHandleT<VectorType>, VectorType >(
214 mesh,
215 mesh->halfedges_begin(),
216 mesh->halfedges_end(),
217 PropertyVisualizer::propertyInfo);
218 } else {
219 visualizeVectorLengthAsColorForEntity2<
220 OpenMesh::HPropHandleT<VectorType> >(
221 mesh,
222 mesh->halfedges_begin(),
223 mesh->halfedges_end(),
224 PropertyVisualizer::propertyInfo);
225 }
226
227 if (_setDrawMode)
228 PluginFunctions::setDrawMode(
229 ACG::SceneGraph::DrawModes::HALFEDGES_COLORED);
230 }
231 else visualizeHalfedgePropAsStrokes();
232 }
233
234 template <typename MeshT, typename VectorType>
235 void OMPropertyVisualizerVector2<MeshT, VectorType>::visualizeVertexProp(bool _setDrawMode)
236 {
237 VectorWidget* const w = (VectorWidget*)PropertyVisualizer::widget;
238 if (w->vectors_colors_rb->isChecked() ||
239 w->vectors_length_color_rb->isChecked()) {
240 if ( !OMPropertyVisualizer<MeshT>::mesh->has_vertex_colors() )
241 OMPropertyVisualizer<MeshT>::mesh->request_vertex_colors();
242
243 if (w->vectors_colors_rb->isChecked()) {
244 visualizeVectorAsColorForEntity2<
245 OpenMesh::VPropHandleT<VectorType>, VectorType >(
246 OMPropertyVisualizer<MeshT>::mesh,
247 OMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
248 OMPropertyVisualizer<MeshT>::mesh->vertices_end(),
249 PropertyVisualizer::propertyInfo);
250 } else {
251 visualizeVectorLengthAsColorForEntity2<
252 OpenMesh::VPropHandleT<VectorType> >(
253 OMPropertyVisualizer<MeshT>::mesh,
254 OMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
255 OMPropertyVisualizer<MeshT>::mesh->vertices_end(),
256 PropertyVisualizer::propertyInfo);
257 }
258 if (_setDrawMode)
259 PluginFunctions::setDrawMode(
260 ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED);
261 }
262 else visualizeVertexPropAsStrokes();
263 }
264
265 template <typename MeshT, typename VectorType>
266 void OMPropertyVisualizerVector2<MeshT, VectorType>::visualizeFacePropOnEdges() {
267 VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
268 MeshT* _mesh = OMPropertyVisualizer<MeshT>::mesh;
269
270
271 const double thresh_1 = w->vectors_edges_alpha->value();
272 const double thresh_2 = std::min(thresh_1, w->vectors_edges_alpha->value());
273
274 OpenMesh::FPropHandleT<VectorType> prop;
275 if (!_mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName()))
276 throw VizException("Getting PropHandle from mesh for selected property failed.");
277
278 if (!_mesh->has_edge_colors())
279 _mesh->request_edge_colors();
280 const ACG::Vec4f cold(0, 0, 0, 1.0), hot(0, 1, 0, 1.0), degen(1, 1, 0, 1.0);
281 for (typename MeshT::EdgeIter e_it = _mesh->edges_begin(), e_end = _mesh->edges_end();
282 e_it != e_end; ++e_it) {
283 VectorType p1 = _mesh->property(prop, _mesh->face_handle(_mesh->halfedge_handle(*e_it, 0)));
284 VectorType p2 = _mesh->property(prop, _mesh->face_handle(_mesh->halfedge_handle(*e_it, 1)));
285
286 ACG::Vec4f color;
287
288 const char degenerate = ((p1.sqrnorm() < 1e-6) ? 1 : 0) | ((p2.sqrnorm() < 1e-6) ? 2 : 0);
289 if (degenerate == 3) {
290 color = cold;
291 } else if (degenerate == 0) {
292 p1.normalize(); p2.normalize();
293 const double alpha = std::min(1.0, double(std::abs(p1 | p2)));
294 if (alpha < thresh_1)
295 color = hot;
296 else if (alpha > thresh_2)
297 color = cold;
298 else {
299 const double beta = (alpha - thresh_1) / (thresh_2 - thresh_1);
300 color = cold * beta + hot * (1.0 - beta);
301 }
302 } else {
303 color = degen;
304 }
305 _mesh->set_color(*e_it, color);
306 }
307 PluginFunctions::setDrawMode(ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED | ACG::SceneGraph::DrawModes::EDGES_COLORED);
308 }
309
310 template <typename MeshT, typename VectorType>
311 void OMPropertyVisualizerVector2<MeshT, VectorType>::visualizeFacePropAsStrokes()
312 {
313 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
314
315 lineNode->clear();
316
317 typename MeshT::Color color = OMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
318
319 OpenMesh::FPropHandleT< VectorType > prop;
320
321 if ( !OMPropertyVisualizer<MeshT>::mesh->get_property_handle(prop, OMPropertyVisualizer<MeshT>::propertyInfo.propName() ) )
322 return;
323
324 for (typename MeshT::FaceIter f_it = OMPropertyVisualizer<MeshT>::mesh->faces_begin() ; f_it != OMPropertyVisualizer<MeshT>::mesh->faces_end() ; ++f_it){
325
326 typename MeshT::Point center(0.0, 0.0, 0.0);
327 int vCount = 0;
328
329 for (typename MeshT::FaceVertexIter fv_it(*(OMPropertyVisualizer<MeshT>::mesh),*f_it); fv_it.is_valid(); ++fv_it){
330 vCount++;
331 center += OMPropertyVisualizer<MeshT>::mesh->point(*fv_it);
332 }
333
334 center /= vCount;
335
336 VectorType v = (OMPropertyVisualizer<MeshT>::mesh->property(prop, *f_it));
337 ACG::Vec3d normal = OMPropertyVisualizer<MeshT>::mesh->normal(*f_it);
338
339 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
340 v.normalize();
341
342 if(vectorWidget->scale->isChecked())
343 v *= vectorWidget->scaleBox->value();
344
345 lineNode->add_line( center, (center+generateVec3AtLocation<VectorType>(v, normal)) );
346 lineNode->add_color(color);
347 }
348 }
349
350 template <typename MeshT, typename VectorType>
351 void OMPropertyVisualizerVector2<MeshT, VectorType>::visualizeEdgePropAsStrokes()
352 {
353 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
354
355 lineNode->clear();
356
357 typename MeshT::Color color = OMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
358
359 //TODO check if this also works if the property is Vec3f
360 OpenMesh::EPropHandleT< VectorType > prop;
361
362 if ( !OMPropertyVisualizer<MeshT>::mesh->get_property_handle(prop, OMPropertyVisualizer<MeshT>::propertyInfo.propName() ) )
363 return;
364
365 for (typename MeshT::EdgeIter e_it = OMPropertyVisualizer<MeshT>::mesh->edges_begin() ; e_it != OMPropertyVisualizer<MeshT>::mesh->edges_end() ; ++e_it){
366
367 typename MeshT::HalfedgeHandle hh = OMPropertyVisualizer<MeshT>::mesh->halfedge_handle( *e_it, 0 );
368
369 typename MeshT::VertexHandle vh0 = OMPropertyVisualizer<MeshT>::mesh->from_vertex_handle( hh );
370 typename MeshT::VertexHandle vh1 = OMPropertyVisualizer<MeshT>::mesh->to_vertex_handle( hh );
371
372 typename MeshT::Point v1 = OMPropertyVisualizer<MeshT>::mesh->point(vh0) + 0.5 * (OMPropertyVisualizer<MeshT>::mesh->point(vh1) - OMPropertyVisualizer<MeshT>::mesh->point(vh0));
373 VectorType v = OMPropertyVisualizer<MeshT>::mesh->property(prop, *e_it);
374 ACG::Vec3d normal = OMPropertyVisualizer<MeshT>::mesh->normal(OMPropertyVisualizer<MeshT>::mesh->halfedge_handle(*e_it, 0));
375
376 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
377 v.normalize();
378
379 if(vectorWidget->scale->isChecked())
380 v *= vectorWidget->scaleBox->value();
381
382 lineNode->add_line( v1, (v1+generateVec3AtLocation<VectorType>(v, normal)) );
383 lineNode->add_color(color);
384 }
385 }
386
387 template <typename MeshT, typename VectorType>
388 void OMPropertyVisualizerVector2<MeshT, VectorType>::visualizeHalfedgePropAsStrokes()
389 {
390 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
391
392 lineNode->clear();
393
394 typename MeshT::Color color = OMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
395
396 //TODO check if this also works if the property is Vec3f
397 OpenMesh::HPropHandleT< VectorType > prop;
398
399 if ( !OMPropertyVisualizer<MeshT>::mesh->get_property_handle(prop, OMPropertyVisualizer<MeshT>::propertyInfo.propName() ) )
400 return;
401
402 for (typename MeshT::HalfedgeIter he_it = OMPropertyVisualizer<MeshT>::mesh->halfedges_begin() ; he_it != OMPropertyVisualizer<MeshT>::mesh->halfedges_end() ; ++he_it){
403
404 typename MeshT::VertexHandle vh0 = OMPropertyVisualizer<MeshT>::mesh->from_vertex_handle( *he_it );
405 typename MeshT::VertexHandle vh1 = OMPropertyVisualizer<MeshT>::mesh->to_vertex_handle( *he_it );
406
407 typename MeshT::Point v1 = OMPropertyVisualizer<MeshT>::mesh->point(vh0) + 0.5 * (OMPropertyVisualizer<MeshT>::mesh->point(vh1) - OMPropertyVisualizer<MeshT>::mesh->point(vh0));
408 VectorType v = OMPropertyVisualizer<MeshT>::mesh->property(prop, *he_it);
409 ACG::Vec3d normal = OMPropertyVisualizer<MeshT>::mesh->normal(*he_it);
410
411 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
412 v.normalize();
413
414 if(vectorWidget->scale->isChecked())
415 v *= vectorWidget->scaleBox->value();
416
417 lineNode->add_line( v1, (v1+generateVec3AtLocation<VectorType>(v, normal)) );
418 lineNode->add_color(color);
419 }
420 }
421
422 template <typename MeshT, typename VectorType>
423 void OMPropertyVisualizerVector2<MeshT, VectorType>::visualizeVertexPropAsStrokes()
424 {
425 VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);
426
427 lineNode->clear();
428
429 typename MeshT::Color color = OMPropertyVisualizer<MeshT>::convertColor(vectorWidget->lineColor->color());
430
431 //TODO check if this also works if the property is Vec3f
432 OpenMesh::VPropHandleT< VectorType > prop;
433
434 if ( !OMPropertyVisualizer<MeshT>::mesh->get_property_handle(prop, OMPropertyVisualizer<MeshT>::propertyInfo.propName() ) )
435 return;
436
437 for (typename MeshT::VertexIter v_it = OMPropertyVisualizer<MeshT>::mesh->vertices_begin() ; v_it != OMPropertyVisualizer<MeshT>::mesh->vertices_end() ; ++v_it){
438
439 typename MeshT::Point v1 = OMPropertyVisualizer<MeshT>::mesh->point( *v_it );
440 VectorType v = OMPropertyVisualizer<MeshT>::mesh->property(prop, *v_it);
441 ACG::Vec3d normal = OMPropertyVisualizer<MeshT>::mesh->normal(*v_it);
442
443 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
444 v.normalize();
445
446 if(vectorWidget->scale->isChecked())
447 v *= vectorWidget->scaleBox->value();
448
449 lineNode->add_line( v1, (v1+generateVec3AtLocation<VectorType>(v, normal)) );
450 lineNode->add_color(color);
451 }
452 }
453
454 template <typename MeshT, typename VectorType>
455 void OMPropertyVisualizerVector2<MeshT, VectorType>::setFacePropertyFromText(unsigned int index, QString text)
456 {
457 OpenMesh::FPropHandleT< VectorType > prop;
458 MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
459
460 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
461 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
462
463
464 typename MeshT::FaceHandle fh = mesh->face_handle(index);
465
466 mesh->property(prop, fh) = this->strToVec2f(text);
467 }
468
469 template <typename MeshT, typename VectorType>
470 void OMPropertyVisualizerVector2<MeshT, VectorType>::setEdgePropertyFromText(unsigned int index, QString text)
471 {
472 OpenMesh::EPropHandleT< VectorType > prop;
473 MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
474
475 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
476 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
477
478
479 typename MeshT::EdgeHandle eh = mesh->edge_handle(index);
480
481 mesh->property(prop, eh) = this->strToVec2f(text);
482 }
483
484 template <typename MeshT, typename VectorType>
485 void OMPropertyVisualizerVector2<MeshT, VectorType>::setHalfedgePropertyFromText(unsigned int index, QString text)
486 {
487 OpenMesh::HPropHandleT< VectorType > prop;
488 MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
489
490 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
491 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
492
493
494 typename MeshT::HalfedgeHandle heh = mesh->halfedge_handle(index);
495
496 mesh->property(prop, heh) = this->strToVec2f(text);
497 }
498
499 template <typename MeshT, typename VectorType>
500 void OMPropertyVisualizerVector2<MeshT, VectorType>::setVertexPropertyFromText(unsigned int index, QString text)
501 {
502 OpenMesh::VPropHandleT< VectorType> prop;
503 MeshT* mesh = OMPropertyVisualizer<MeshT>::mesh;
504
505 if ( !mesh->get_property_handle(prop, PropertyVisualizer::propertyInfo.propName() ) )
506 emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
507
508
509 typename MeshT::VertexHandle vh = mesh->vertex_handle(index);
510
511 mesh->property(prop, vh) = this->strToVec2f(text);
512 }
513
514
515 template <typename MeshT, typename VectorType>
516 void OMPropertyVisualizerVector2<MeshT, VectorType>::removeProperty()
517 {
518 OMPropertyVisualizer<MeshT>::template removeProperty_stage1<VectorType>();
519 }
520
521 template <typename MeshT, typename VectorType>
522 void OMPropertyVisualizerVector2<MeshT, VectorType>::duplicateProperty()
523 {
524 OMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<VectorType>();
525 }
526
OpenMesh::Attributes::Color
Add colors to mesh item (vertices/faces/edges)
Definition: Attributes.hh:88
OpenMesh::HPropHandleT
Definition: Property.hh:501
ACG::SceneGraph::DrawModes::EDGES_COLORED
DrawMode EDGES_COLORED
draw edges with colors (without shading)
Definition: DrawModes.cc:83
LOGERR
Definition: LoggingInterface.hh:107
PluginFunctions::setDrawMode
void setDrawMode(const ACG::SceneGraph::DrawModes::DrawMode &_mode, int _viewer)
Set the draw Mode of a Viewer. .
Definition: PluginFunctions.cc:435
ACG::SceneGraph::DrawModes::SOLID_FLAT_SHADED
DrawMode SOLID_FLAT_SHADED
draw flat shaded faces (requires face normals)
Definition: DrawModes.cc:87
ACG::Vec3d
VectorT< double, 3 > Vec3d
Definition: VectorT.hh:127
OpenMesh::EPropHandleT
Definition: Property.hh:515
OMPropertyVisualizer::clear
virtual void clear()
Clears the property.
Definition: OMPropertyVisualizerT.cc:339
OpenMesh::VPropHandleT
Definition: Property.hh:487
OMPropertyVisualizerVector2::duplicateProperty
virtual void duplicateProperty()
Duplicates the property.
Definition: OMPropertyVisualizerVector2T.cc:522
VizException
Definition: PropertyVisualizer.hh:66
OpenMesh::VectorT
Definition: Vector11T.hh:83
PluginFunctions::getRootNode
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
Definition: PluginFunctions.cc:965
ACG::SceneGraph::DrawModes::SOLID_POINTS_COLORED
DrawMode SOLID_POINTS_COLORED
draw colored, but not lighted faces using interpolated vertex colors
Definition: DrawModes.cc:91
VectorWidget
Definition: VectorWidget.hh:62
OMPropertyVisualizerVector2::clear
virtual void clear()
Clears the property.
Definition: OMPropertyVisualizerVector2T.cc:73
ACG::ColorCoder
Class for generating nice colors for doubles.
Definition: ColorCoder.hh:75
OMPropertyVisualizerVector2::removeProperty
virtual void removeProperty()
Removes the property.
Definition: OMPropertyVisualizerVector2T.cc:516
OMPropertyVisualizer
Definition: OMPropertyVisualizer.hh:61
ACG::SceneGraph::DrawModes::SOLID_FACES_COLORED
DrawMode SOLID_FACES_COLORED
draw colored, but not lighted faces using face colors
Definition: DrawModes.cc:90
OpenMesh::FPropHandleT
Definition: Property.hh:529
ACG::SceneGraph::LineNode
Definition: LineNode.hh:90
PropertyInfo
Cellection of information about a property.
Definition: Utils.hh:115
OMPropertyVisualizerVector2
Definition: OMPropertyVisualizerVector2.hh:67
ACG::SceneGraph::DrawModes::HALFEDGES_COLORED
DrawMode HALFEDGES_COLORED
draw halfedges with colors (without shading)
Definition: DrawModes.cc:109
OMPropertyVisualizerVector2::getPropertyText
virtual QString getPropertyText(unsigned int index)
Returns the value of a property in text form.
Definition: OMPropertyVisualizerVector2T.cc:80