50 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
52 #define OVM_PROPERTY_VISUALIZER_VECTOR_CC
54 #include <ACG/Utils/ColorConversion.hh>
55 #include "OVMPropertyVisualizerVector.hh"
58 template <
typename MeshT>
59 OVMPropertyVisualizerVector<MeshT>::OVMPropertyVisualizerVector(MeshT* _mesh,
int objectID,
PropertyInfo _propertyInfo)
60 : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo)
62 if (PropertyVisualizer::widget)
delete PropertyVisualizer::widget;
64 w->paramVector->setTitle(QString(
"3D Vector Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
65 PropertyVisualizer::widget = w;
69 w->vectors_edges_rb->hide();
72 template <
typename MeshT>
73 void OVMPropertyVisualizerVector<MeshT>::clear()
76 OVMPropertyVisualizer<MeshT>::clear();
79 template <
typename MeshT>
80 void OVMPropertyVisualizerVector<MeshT>::duplicateProperty()
82 OVMPropertyVisualizer<MeshT>::template duplicateProperty_stage1<ACG::Vec3d>();
85 template<
typename MeshT>
86 template<
typename PropType,
typename EntityIterator>
87 void OVMPropertyVisualizerVector<MeshT>::visualizeVectorAsColorForEntity(PropType prop, EntityIterator e_begin, EntityIterator e_end) {
89 throw VizException(
"Getting PropHandle from mesh for selected property failed.");
92 for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) {
94 object->colors()[*e_it] =
ACG::Vec4f(v[0], v[1], v[2], 1.0);
98 template <
typename MeshT>
99 void OVMPropertyVisualizerVector<MeshT>::visualizeCellProp(
bool _setDrawMode)
102 if (w->vectors_colors_rb->isChecked())
105 visualizeVectorAsColorForEntity(prop,
106 OVMPropertyVisualizer<MeshT>::mesh->cells_begin(),
107 OVMPropertyVisualizer<MeshT>::mesh->cells_end());
112 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.cellsColoredPerCell);
115 else visualizeCellPropAsStrokes();
118 template <
typename MeshT>
119 void OVMPropertyVisualizerVector<MeshT>::visualizeFaceProp(
bool _setDrawMode)
122 if (w->vectors_colors_rb->isChecked())
125 visualizeVectorAsColorForEntity(prop,
126 OVMPropertyVisualizer<MeshT>::mesh->faces_begin(),
127 OVMPropertyVisualizer<MeshT>::mesh->faces_end());
132 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.facesColoredPerFace);
135 else visualizeFacePropAsStrokes();
139 template <
typename MeshT>
140 void OVMPropertyVisualizerVector<MeshT>::visualizeHalffaceProp(
bool _setDrawMode)
143 if (w->vectors_colors_rb->isChecked())
146 visualizeVectorAsColorForEntity(prop,
147 OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin(),
148 OVMPropertyVisualizer<MeshT>::mesh->halffaces_end());
153 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halffacesColoredPerHalfface);
156 else visualizeHalffacePropAsStrokes();
159 template <
typename MeshT>
160 void OVMPropertyVisualizerVector<MeshT>::visualizeEdgeProp(
bool _setDrawMode)
163 if (w->vectors_colors_rb->isChecked())
166 visualizeVectorAsColorForEntity(prop,
167 OVMPropertyVisualizer<MeshT>::mesh->edges_begin(),
168 OVMPropertyVisualizer<MeshT>::mesh->edges_end());
173 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.edgesColoredPerEdge);
176 else visualizeEdgePropAsStrokes();
179 template <
typename MeshT>
180 void OVMPropertyVisualizerVector<MeshT>::visualizeHalfedgeProp(
bool _setDrawMode)
183 if (w->vectors_colors_rb->isChecked())
186 visualizeVectorAsColorForEntity(prop,
187 OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin(),
188 OVMPropertyVisualizer<MeshT>::mesh->halfedges_end());
193 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halfedgesColoredPerHalfedge);
196 else visualizeHalfedgePropAsStrokes();
199 template <
typename MeshT>
200 void OVMPropertyVisualizerVector<MeshT>::visualizeVertexProp(
bool _setDrawMode)
203 if (w->vectors_colors_rb->isChecked())
206 visualizeVectorAsColorForEntity(prop,
207 OVMPropertyVisualizer<MeshT>::mesh->vertices_begin(),
208 OVMPropertyVisualizer<MeshT>::mesh->vertices_end());
213 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.verticesColored);
216 else visualizeVertexPropAsStrokes();
219 template <
typename MeshT>
220 void OVMPropertyVisualizerVector<MeshT>::visualizeFacePropAsStrokes()
226 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
233 OpenVolumeMesh::FaceIter f_begin(OVMPropertyVisualizer<MeshT>::mesh->faces_begin()), f_end(OVMPropertyVisualizer<MeshT>::mesh->faces_end());
242 center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*hfv_it);
249 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
252 if(vectorWidget->scale->isChecked())
253 v *= vectorWidget->scaleBox->value();
255 lineNode->add_line( center, (center+v) );
256 lineNode->add_color(color);
260 template <
typename MeshT>
261 void OVMPropertyVisualizerVector<MeshT>::visualizeEdgePropAsStrokes()
267 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
273 OpenVolumeMesh::EdgeIter e_begin(OVMPropertyVisualizer<MeshT>::mesh->edges_begin()), e_end(OVMPropertyVisualizer<MeshT>::mesh->edges_end());
277 ACG::Vec3d v1 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.from_vertex());
278 ACG::Vec3d v2 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.to_vertex());
283 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
288 if(vectorWidget->scale->isChecked())
289 v *= vectorWidget->scaleBox->value();
291 lineNode->add_line( start, (start+v) );
292 lineNode->add_color(color);
296 template <
typename MeshT>
297 void OVMPropertyVisualizerVector<MeshT>::visualizeHalfedgePropAsStrokes()
303 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
309 OpenVolumeMesh::HalfEdgeIter he_begin(OVMPropertyVisualizer<MeshT>::mesh->halfedges_begin()), he_end(OVMPropertyVisualizer<MeshT>::mesh->halfedges_end());
314 ACG::Vec3d v1 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.from_vertex());
315 ACG::Vec3d v2 = OVMPropertyVisualizer<MeshT>::mesh->vertex(edge.to_vertex());
320 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
323 if(vectorWidget->scale->isChecked())
324 v *= vectorWidget->scaleBox->value();
326 lineNode->add_line( start, (start+v) );
327 lineNode->add_color(color);
331 template <
typename MeshT>
332 void OVMPropertyVisualizerVector<MeshT>::visualizeVertexPropAsStrokes()
338 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
344 OpenVolumeMesh::VertexIter v_begin(OVMPropertyVisualizer<MeshT>::mesh->vertices_begin()), v_end(OVMPropertyVisualizer<MeshT>::mesh->vertices_end());
347 ACG::Vec3d start = OVMPropertyVisualizer<MeshT>::mesh->vertex(*v_it);
351 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
354 if(vectorWidget->scale->isChecked())
355 v *= vectorWidget->scaleBox->value();
357 lineNode->add_line( start, (start+v) );
358 lineNode->add_color(color);
362 template <
typename MeshT>
363 void OVMPropertyVisualizerVector<MeshT>::visualizeCellPropAsStrokes()
369 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
376 OpenVolumeMesh::CellIter c_begin(OVMPropertyVisualizer<MeshT>::mesh->cells_begin()), c_end(OVMPropertyVisualizer<MeshT>::mesh->cells_end());
381 unsigned int vCount = OVMPropertyVisualizer<MeshT>::mesh->n_vertices_in_cell(*c_it);
383 center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*cv_it) / (double)vCount;
388 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
391 if(vectorWidget->scale->isChecked())
392 v *= vectorWidget->scaleBox->value();
394 lineNode->add_line( center, (center+v) );
395 lineNode->add_color(color);
399 template <
typename MeshT>
400 void OVMPropertyVisualizerVector<MeshT>::visualizeHalffacePropAsStrokes()
406 ACG::Vec4f color = ACG::to_Vec4f(vectorWidget->lineColor->color());
413 OpenVolumeMesh::HalfFaceIter hf_begin(OVMPropertyVisualizer<MeshT>::mesh->halffaces_begin()), hf_end(OVMPropertyVisualizer<MeshT>::mesh->halffaces_end());
421 center += OVMPropertyVisualizer<MeshT>::mesh->vertex(*hfv_it);
428 if (vectorWidget->normalize->isChecked() && v.sqrnorm() > 1e-12)
431 if(vectorWidget->scale->isChecked())
432 v *= vectorWidget->scaleBox->value();
434 lineNode->add_line( center, (center+v) );
435 lineNode->add_color(color);
439 template <
typename MeshT>
440 QString OVMPropertyVisualizerVector<MeshT>::getPropertyText(
unsigned int index)
442 return OVMPropertyVisualizer<MeshT>::template getPropertyText_<ACG::Vec3d>(index);
446 template <
typename MeshT>
447 void OVMPropertyVisualizerVector<MeshT>::setCellPropertyFromText(
unsigned int index, QString text)
449 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
454 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
460 prop[ch] = this->strToVec3d(text);
463 template <
typename MeshT>
464 void OVMPropertyVisualizerVector<MeshT>::setFacePropertyFromText(
unsigned int index, QString text)
466 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
471 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
477 prop[fh] = this->strToVec3d(text);
480 template <
typename MeshT>
481 void OVMPropertyVisualizerVector<MeshT>::setHalffacePropertyFromText(
unsigned int index, QString text)
483 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
488 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
494 prop[hfh] = this->strToVec3d(text);
497 template <
typename MeshT>
498 void OVMPropertyVisualizerVector<MeshT>::setEdgePropertyFromText(
unsigned int index, QString text)
500 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
505 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
511 prop[eh] = this->strToVec3d(text);
514 template <
typename MeshT>
515 void OVMPropertyVisualizerVector<MeshT>::setHalfedgePropertyFromText(
unsigned int index, QString text)
517 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
522 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
528 prop[heh] = this->strToVec3d(text);
531 template <
typename MeshT>
532 void OVMPropertyVisualizerVector<MeshT>::setVertexPropertyFromText(
unsigned int index, QString text)
534 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
539 emit this->log(
LOGERR, QObject::tr(
"Error: No property with name ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
545 prop[vh] = this->strToVec3d(text);
bool getObject(int _identifier, BSplineCurveObject *&_object)
Property classes for the different entity types.
ACG::SceneGraph::BaseNode * getRootNode()
Get the root node for data objects.
VectorT< float, 4 > Vec4f
VectorT< double, 3 > Vec3d
Cellection of information about a property.