OVMPropertyVisualizerVectorT.cc 23 KB
Newer Older
1
2
3
/*===========================================================================*\
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
39
40
41
*                                                                            *
\*===========================================================================*/

42
43
44
45
46
47
48
49
/*===========================================================================*\
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
\*===========================================================================*/

50
51
52
53
#ifdef ENABLE_OPENVOLUMEMESH_SUPPORT

#define OVM_PROPERTY_VISUALIZER_VECTOR_CC

54
#include <ACG/Utils/ColorConversion.hh>
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#include "OVMPropertyVisualizerVector.hh"


template <typename MeshT>
OVMPropertyVisualizerVector<MeshT>::OVMPropertyVisualizerVector(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo)
    : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
{
    if (PropertyVisualizer::widget) delete PropertyVisualizer::widget;
    VectorWidget* w = new VectorWidget();
    w->paramVector->setTitle(QString("3D Vector Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
    PropertyVisualizer::widget = w;

    lineNode = new ACG::SceneGraph::LineNode( ACG::SceneGraph::LineNode::LineSegmentsMode, dynamic_cast < ACG::SceneGraph::SeparatorNode* >( PluginFunctions::getRootNode() ) );

    w->vectors_edges_rb->hide();
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::clear()
{
    lineNode->clear();
    OVMPropertyVisualizer<MeshT>::clear();
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::duplicateProperty()
{
    OVMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<ACG::Vec3d>();
}

template<typename MeshT>
template<typename PropType, typename EntityIterator>
void OVMPropertyVisualizerVector<MeshT>::visualizeVectorAsColorForEntity(PropType prop, EntityIterator e_begin, EntityIterator e_end) {
    if (!prop)
        throw VizException("Getting PropHandle from mesh for selected property failed.");
    VolumeMeshObject<MeshT>* object;
    PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
    for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) {
        ACG::Vec3d v = prop[*e_it].normalized() * .5 + ACG::Vec3d(.5, .5, .5);
        object->colors()[*e_it] = ACG::Vec4f(v[0], v[1], v[2], 1.0);
    }
}

template <typename MeshT>
99
void OVMPropertyVisualizerVector<MeshT>::visualizeCellProp(bool _setDrawMode)
100
101
102
103
104
105
106
107
{
    VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
    if (w->vectors_colors_rb->isChecked())
    {
        OpenVolumeMesh::CellPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_cell_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
        visualizeVectorAsColorForEntity(prop,
                                        OVMPropertyVisualizer<MeshT>::mesh->cells_begin(),
                                        OVMPropertyVisualizer<MeshT>::mesh->cells_end());
108
109
110
111
112
113
        if (_setDrawMode)
        {
            VolumeMeshObject<MeshT>* object;
            PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
            object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.cellsColoredPerCell);
        }
114
115
116
117
118
    }
    else visualizeCellPropAsStrokes();
}

template <typename MeshT>
119
void OVMPropertyVisualizerVector<MeshT>::visualizeFaceProp(bool _setDrawMode)
120
121
122
123
124
125
126
127
{
    VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
    if (w->vectors_colors_rb->isChecked())
    {
        OpenVolumeMesh::FacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_face_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
        visualizeVectorAsColorForEntity(prop,
                                        OVMPropertyVisualizer<MeshT>::mesh->faces_begin(),
                                        OVMPropertyVisualizer<MeshT>::mesh->faces_end());
128
129
130
131
132
133
        if (_setDrawMode)
        {
            VolumeMeshObject<MeshT>* object;
            PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
            object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.facesColoredPerFace);
        }
134
135
136
137
138
139
    }
    else visualizeFacePropAsStrokes();
}


template <typename MeshT>
140
void OVMPropertyVisualizerVector<MeshT>::visualizeHalffaceProp(bool _setDrawMode)
141
142
143
144
145
146
147
148
{
    VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
    if (w->vectors_colors_rb->isChecked())
    {
        OpenVolumeMesh::HalfFacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfface_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
        visualizeVectorAsColorForEntity(prop,
                                        OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin(),
                                        OVMPropertyVisualizer<MeshT>::mesh->halffaces_end());
149
150
151
152
153
154
        if (_setDrawMode)
        {
            VolumeMeshObject<MeshT>* object;
            PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
            object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halffacesColoredPerHalfface);
        }
155
    }
156
    else visualizeHalffacePropAsStrokes();
157
158
159
}

template <typename MeshT>
160
void OVMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(bool _setDrawMode)
161
162
163
164
165
166
167
168
{
    VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
    if (w->vectors_colors_rb->isChecked())
    {
        OpenVolumeMesh::EdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_edge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
        visualizeVectorAsColorForEntity(prop,
                                        OVMPropertyVisualizer<MeshT>::mesh->edges_begin(),
                                        OVMPropertyVisualizer<MeshT>::mesh->edges_end());
169
170
171
172
173
174
        if (_setDrawMode)
        {
            VolumeMeshObject<MeshT>* object;
            PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
            object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.edgesColoredPerEdge);
        }
175
176
177
178
179
    }
    else visualizeEdgePropAsStrokes();
}

template <typename MeshT>
180
void OVMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(bool _setDrawMode)
181
182
183
184
185
186
187
188
{
    VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
    if (w->vectors_colors_rb->isChecked())
    {
        OpenVolumeMesh::HalfEdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfedge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
        visualizeVectorAsColorForEntity(prop,
                                        OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin(),
                                        OVMPropertyVisualizer<MeshT>::mesh->halfedges_end());
189
190
191
192
193
194
        if (_setDrawMode)
        {
            VolumeMeshObject<MeshT>* object;
            PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
            object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halfedgesColoredPerHalfedge);
        }
195
196
197
198
199
    }
    else visualizeHalfedgePropAsStrokes();
}

template <typename MeshT>
200
void OVMPropertyVisualizerVector<MeshT>::visualizeVertexProp(bool _setDrawMode)
201
202
203
204
205
206
207
208
{
    VectorWidget* w = (VectorWidget*)PropertyVisualizer::widget;
    if (w->vectors_colors_rb->isChecked())
    {
        OpenVolumeMesh::VertexPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_vertex_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
        visualizeVectorAsColorForEntity(prop,
                                        OVMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
                                        OVMPropertyVisualizer<MeshT>::mesh->vertices_end());
209
210
211
212
213
214
        if (_setDrawMode)
        {
            VolumeMeshObject<MeshT>* object;
            PluginFunctions::getObject(OVMPropertyVisualizer<MeshT>::mObjectID, object);
            object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.verticesColored);
        }
215
216
217
218
219
220
221
222
223
224
225
    }
    else visualizeVertexPropAsStrokes();
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::visualizeFacePropAsStrokes()
{
    VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);

    lineNode->clear();

226
    ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266

    OpenVolumeMesh::FacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_face_property<ACG::Vec3d>(PropertyVisualizer::propertyInfo.propName());

    if ( !prop )
        return;

    OpenVolumeMesh::FaceIter f_begin(OVMPropertyVisualizer<MeshT>::mesh->faces_begin()), f_end(OVMPropertyVisualizer<MeshT>::mesh->faces_end());
    for (OpenVolumeMesh::FaceIter f_it = f_begin; f_it != f_end; ++f_it){

        ACG::Vec3d center(0.0, 0.0, 0.0);
        int vCount = 0;

        OpenVolumeMesh::HalfFaceHandle hfh = OVMPropertyVisualizer<MeshT>::mesh->halfface_handle(*f_it, 0);
        for (OpenVolumeMesh::HalfFaceVertexIter hfv_it = OVMPropertyVisualizer<MeshT>::mesh->hfv_iter(hfh); hfv_it; ++hfv_it){
            vCount++;
            center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*hfv_it);
        }

        center /= vCount;

        ACG::Vec3d v  = prop[*f_it];

        if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
            v.normalize();

        if(vectorWidget->scale->isChecked())
            v *= vectorWidget->scaleBox->value();

        lineNode->add_line( center, (center+v) );
        lineNode->add_color(color);
    }
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::visualizeEdgePropAsStrokes()
{
    VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);

    lineNode->clear();

267
    ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302

    OpenVolumeMesh::EdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_edge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
    if ( !prop )
        return;

    OpenVolumeMesh::EdgeIter e_begin(OVMPropertyVisualizer<MeshT>::mesh->edges_begin()), e_end(OVMPropertyVisualizer<MeshT>::mesh->edges_end());
    for (OpenVolumeMesh::EdgeIter e_it = e_begin; e_it != e_end; ++e_it){

        OpenVolumeMesh::OpenVolumeMeshEdge edge = OVMPropertyVisualizer<MeshT>::mesh->edge(*e_it);
        ACG::Vec3d v1 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.from_vertex());
        ACG::Vec3d v2 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.to_vertex());
        ACG::Vec3d start = 0.5*(v1+v2);

        ACG::Vec3d v  = prop[*e_it];

        if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
            v.normalize();



        if(vectorWidget->scale->isChecked())
        v *= vectorWidget->scaleBox->value();

        lineNode->add_line( start, (start+v) );
        lineNode->add_color(color);
    }
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::visualizeHalfedgePropAsStrokes()
{
    VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);

    lineNode->clear();

303
    ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337

    OpenVolumeMesh::HalfEdgePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfedge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
    if ( !prop )
        return;

    OpenVolumeMesh::HalfEdgeIter he_begin(OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin()), he_end(OVMPropertyVisualizer<MeshT>::mesh->halfedges_end());
    for (OpenVolumeMesh::HalfEdgeIter he_it = he_begin; he_it != he_end; ++he_it){

        OpenVolumeMesh::OpenVolumeMeshEdge edge = OVMPropertyVisualizer<MeshT>::mesh->halfedge(*he_it);

        ACG::Vec3d v1 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.from_vertex());
        ACG::Vec3d v2 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.to_vertex());
        ACG::Vec3d start = (2.0*v1+v2)/3.0;

        ACG::Vec3d v  = prop[*he_it];

        if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
            v.normalize();

        if(vectorWidget->scale->isChecked())
        v *= vectorWidget->scaleBox->value();

        lineNode->add_line( start, (start+v) );
        lineNode->add_color(color);
    }
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::visualizeVertexPropAsStrokes()
{
    VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);

    lineNode->clear();

338
    ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368

    OpenVolumeMesh::VertexPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_vertex_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
    if ( !prop )
        return;

    OpenVolumeMesh::VertexIter v_begin(OVMPropertyVisualizer<MeshT>::mesh->vertices_begin()), v_end(OVMPropertyVisualizer<MeshT>::mesh->vertices_end());
    for (OpenVolumeMesh::VertexIter v_it = v_begin; v_it != v_end; ++v_it){

        ACG::Vec3d start = OVMPropertyVisualizer<MeshT>::mesh->vertex(*v_it);

        ACG::Vec3d v  = prop[*v_it];

        if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
            v.normalize();

        if(vectorWidget->scale->isChecked())
        v *= vectorWidget->scaleBox->value();

        lineNode->add_line( start, (start+v) );
        lineNode->add_color(color);
    }
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::visualizeCellPropAsStrokes()
{
    VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);

    lineNode->clear();

369
    ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405

    OpenVolumeMesh::CellPropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_cell_property<ACG::Vec3d>(PropertyVisualizer::propertyInfo.propName());

    if ( !prop )
        return;

    OpenVolumeMesh::CellIter c_begin(OVMPropertyVisualizer<MeshT>::mesh->cells_begin()), c_end(OVMPropertyVisualizer<MeshT>::mesh->cells_end());
    for (OpenVolumeMesh::CellIter c_it = c_begin; c_it != c_end; ++c_it){

        // Compute cell's center
        ACG::Vec3d center(0.0, 0.0, 0.0);
        unsigned int vCount = OVMPropertyVisualizer<MeshT>::mesh->n_vertices_in_cell(*c_it);
        for(OpenVolumeMesh::CellVertexIter cv_it = OVMPropertyVisualizer<MeshT>::mesh->cv_iter(*c_it); cv_it.valid(); ++cv_it) {
            center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*cv_it) / (double)vCount;
        }

        ACG::Vec3d v  = prop[*c_it];

        if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
            v.normalize();

        if(vectorWidget->scale->isChecked())
            v *= vectorWidget->scaleBox->value();

        lineNode->add_line( center, (center+v) );
        lineNode->add_color(color);
    }
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::visualizeHalffacePropAsStrokes()
{
    VectorWidget* vectorWidget = static_cast<VectorWidget*>(PropertyVisualizer::widget);

    lineNode->clear();

406
    ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444

    OpenVolumeMesh::HalfFacePropertyT<ACG::Vec3d> prop = OVMPropertyVisualizer<MeshT>::mesh->template request_halfface_property<ACG::Vec3d>(PropertyVisualizer::propertyInfo.propName());

    if ( !prop )
        return;

    OpenVolumeMesh::HalfFaceIter hf_begin(OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin()), hf_end(OVMPropertyVisualizer<MeshT>::mesh->halffaces_end());
    for (OpenVolumeMesh::HalfFaceIter hf_it = hf_begin; hf_it != hf_end; ++hf_it){

        ACG::Vec3d center(0.0, 0.0, 0.0);
        int vCount = 0;

        for (OpenVolumeMesh::HalfFaceVertexIter hfv_it = OVMPropertyVisualizer<MeshT>::mesh->hfv_iter(*hf_it); hfv_it; ++hfv_it){
            vCount++;
            center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*hfv_it);
        }

        center /= vCount;

        ACG::Vec3d v  = prop[*hf_it];

        if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
            v.normalize();

        if(vectorWidget->scale->isChecked())
            v *= vectorWidget->scaleBox->value();

        lineNode->add_line( center, (center+v) );
        lineNode->add_color(color);
    }
}

template <typename MeshT>
QString OVMPropertyVisualizerVector<MeshT>::getPropertyText(unsigned int index)
{
    return OVMPropertyVisualizer<MeshT>::template getPropertyText_<ACG::Vec3d>(index);
}

445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::setCellPropertyFromText(unsigned int index, QString text)
{
    MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;

    OpenVolumeMesh::CellPropertyT<ACG::Vec3d> prop = mesh->template request_cell_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
    if ( !prop )
    {
        emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
        return;
    }

    OpenVolumeMesh::CellHandle ch(index);

    prop[ch] = this->strToVec3d(text);
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::setFacePropertyFromText(unsigned int index, QString text)
{
    MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;

    OpenVolumeMesh::FacePropertyT<ACG::Vec3d> prop = mesh->template request_face_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
    if ( !prop )
    {
        emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
        return;
    }

    OpenVolumeMesh::FaceHandle fh(index);

    prop[fh] = this->strToVec3d(text);
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::setHalffacePropertyFromText(unsigned int index, QString text)
{
    MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;

    OpenVolumeMesh::HalfFacePropertyT<ACG::Vec3d> prop = mesh->template request_halfface_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
    if ( !prop )
    {
        emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
        return;
    }

    OpenVolumeMesh::HalfFaceHandle hfh(index);

    prop[hfh] = this->strToVec3d(text);
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::setEdgePropertyFromText(unsigned int index, QString text)
{
    MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;

    OpenVolumeMesh::EdgePropertyT<ACG::Vec3d> prop = mesh->template request_edge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
    if ( !prop )
    {
        emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
        return;
    }

    OpenVolumeMesh::EdgeHandle eh(index);

    prop[eh] = this->strToVec3d(text);
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::setHalfedgePropertyFromText(unsigned int index, QString text)
{
    MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;

    OpenVolumeMesh::HalfEdgePropertyT<ACG::Vec3d> prop = mesh->template request_halfedge_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
    if ( !prop )
    {
        emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
        return;
    }

    OpenVolumeMesh::HalfEdgeHandle heh(index);

    prop[heh] = this->strToVec3d(text);
}

template <typename MeshT>
void OVMPropertyVisualizerVector<MeshT>::setVertexPropertyFromText(unsigned int index, QString text)
{
    MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;

    OpenVolumeMesh::VertexPropertyT<ACG::Vec3d> prop = mesh->template request_vertex_property<ACG::Vec3d>(OVMPropertyVisualizer<MeshT>::propertyInfo.propName());
    if ( !prop )
    {
        emit this->log(LOGERR, QObject::tr("Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
        return;
    }

    OpenVolumeMesh::VertexHandle vh(index);

    prop[vh] = this->strToVec3d(text);
}

548
#endif /* ENABLE_OPENVOLUMEMESH_SUPPORT */