50 #ifdef ENABLE_OPENVOLUMEMESH_SUPPORT
52 #define OVM_PROPERTY_VISZUALIZTER_VECTOR_FIELD_DIFFERENCE_CC
54 #include "OVMPropertyVisualizerVectorFieldDifference.hh"
56 template <
typename MeshT>
57 OVMPropertyVisualizerVectorFieldDifference<MeshT>::OVMPropertyVisualizerVectorFieldDifference(MeshT* _mesh,
int objectID,
PropertyInfo _propertyInfo1,
PropertyInfo _propertyInfo2)
58 : OVMPropertyVisualizer<MeshT>(_mesh, objectID, _propertyInfo1),
59 propertyInfo2(_propertyInfo2)
61 if (PropertyVisualizer::widget)
delete PropertyVisualizer::widget;
63 w->paramVectorFieldDifference->setTitle(QString(
"3D Vector Field Difference Parameters of ").append(PropertyVisualizer::propertyInfo.propName().c_str()));
64 PropertyVisualizer::widget = w;
69 template <
typename MeshT>
71 return (a - b).norm();
74 template <
typename MeshT>
76 return std::fabs(a.norm() - b.norm());
79 template <
typename MeshT>
81 double alpha = std::acos((a|b) / a.norm() / b.norm());
82 alpha -= std::floor((alpha + M_PI_4) / M_PI_2) * M_PI_2;
83 return std::fabs(alpha);
87 template<
typename Prop1,
typename Prop2,
float (*ScalarFn)(const
typename Prop1::value_type &, const
typename Prop2::value_type &)>
88 class ScalarAssigner {
90 ScalarAssigner(
const Prop1 &prop1,
const Prop2 &prop2) :
91 prop1(prop1), prop2(prop2) { }
93 template<
typename Handle>
94 float operator() (
const Handle &handle)
const {
95 return ScalarFn(prop1[handle], prop2[handle]);
103 template<
typename MeshT,
typename IteratorT,
typename PropHandle,
float (*ScalarFn)(const ACG::Vec3d &, const ACG::Vec3d &)>
104 void colorElements(
int objectID,
107 IteratorT primitivesBegin,
108 IteratorT primitivesEnd)
111 std::vector<float> scalars;
112 std::transform(primitivesBegin, primitivesEnd, std::back_inserter(scalars),
113 ScalarAssigner<PropHandle, PropHandle, ScalarFn >(prop1, prop2));
115 const float min = *std::min_element(scalars.begin(), scalars.end());
116 const float max = *std::max_element(scalars.begin(), scalars.end());
122 for (std::vector<float>::iterator i = scalars.begin(); i != scalars.end(); ++i)
123 object->colors()[*(primitivesBegin++)] = colCod(*i);
129 template <
typename MeshT>
130 void OVMPropertyVisualizerVectorFieldDifference<MeshT>::visualizeCellProp(
bool _setDrawMode)
132 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
139 if (w->vecFieldDiff_4symm_rb->isChecked())
141 if (w->vecFieldDiff_diff_norm_rb->isChecked())
143 if (w->vecFieldDiff_norm_diff_rb->isChecked())
149 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.cellsColoredPerCell);
153 template <
typename MeshT>
154 void OVMPropertyVisualizerVectorFieldDifference<MeshT>::visualizeFaceProp(
bool _setDrawMode)
156 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
163 if (w->vecFieldDiff_4symm_rb->isChecked())
165 if (w->vecFieldDiff_diff_norm_rb->isChecked())
167 if (w->vecFieldDiff_norm_diff_rb->isChecked())
173 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.facesColoredPerFace);
177 template <
typename MeshT>
178 void OVMPropertyVisualizerVectorFieldDifference<MeshT>::visualizeHalffaceProp(
bool _setDrawMode)
180 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
187 if (w->vecFieldDiff_4symm_rb->isChecked())
189 if (w->vecFieldDiff_diff_norm_rb->isChecked())
191 if (w->vecFieldDiff_norm_diff_rb->isChecked())
197 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halffacesColoredPerHalfface);
201 template <
typename MeshT>
202 void OVMPropertyVisualizerVectorFieldDifference<MeshT>::visualizeEdgeProp(
bool _setDrawMode)
204 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
211 if (w->vecFieldDiff_4symm_rb->isChecked())
213 if (w->vecFieldDiff_diff_norm_rb->isChecked())
215 if (w->vecFieldDiff_norm_diff_rb->isChecked())
221 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.edgesColoredPerEdge);
225 template <
typename MeshT>
226 void OVMPropertyVisualizerVectorFieldDifference<MeshT>::visualizeHalfedgeProp(
bool _setDrawMode)
228 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
235 if (w->vecFieldDiff_4symm_rb->isChecked())
237 if (w->vecFieldDiff_diff_norm_rb->isChecked())
239 if (w->vecFieldDiff_norm_diff_rb->isChecked())
245 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.halfedgesColoredPerHalfedge);
249 template <
typename MeshT>
250 void OVMPropertyVisualizerVectorFieldDifference<MeshT>::visualizeVertexProp(
bool _setDrawMode)
252 MeshT* mesh = OVMPropertyVisualizer<MeshT>::mesh;
259 if (w->vecFieldDiff_4symm_rb->isChecked())
261 if (w->vecFieldDiff_diff_norm_rb->isChecked())
263 if (w->vecFieldDiff_norm_diff_rb->isChecked())
269 object->setObjectDrawMode(OVMPropertyVisualizer<MeshT>::drawModes.verticesColored);
bool getObject(int _identifier, BSplineCurveObject *&_object)
Class for generating nice colors for doubles.
Property classes for the different entity types.
Cellection of information about a property.