From 0dfe70852114dfec19f73515889a0a09dd094962 Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Tue, 5 Feb 2019 17:35:47 +0100 Subject: [PATCH 1/7] mat3x3 vis: implementation start --- Models/PropertyNameListModel.cc | 3 + Models/PropertyNameListModel.hh | 3 +- OpenVolumeMesh/OVMPropertyModelT.hh | 10 +- OpenVolumeMesh/OVMPropertyModelT_impl.hh | 20 ++ .../OVMPropertyVisualizerMatrix3x3.hh | 85 +++++ .../OVMPropertyVisualizerMatrix3x3_impl.hh | 113 +++++++ PropertyVisualizer/PropertyVisualizer.cc | 9 + PropertyVisualizer/PropertyVisualizer.hh | 1 + Widgets/BooleanWidget.hh | 2 +- Widgets/DoubleWidget.hh | 2 +- Widgets/IntegerWidget.hh | 2 +- Widgets/LoadSaveWidget.hh | 2 +- Widgets/Matrix3x3Widget.cc | 60 ++++ Widgets/Matrix3x3Widget.hh | 65 ++++ Widgets/Matrix3x3Widget.ui | 312 ++++++++++++++++++ Widgets/PickWidget.hh | 2 +- Widgets/SkinWeightsWidget.hh | 2 +- Widgets/VectorFieldDifferenceWidget.hh | 2 +- Widgets/VectorWidget.hh | 2 +- 19 files changed, 686 insertions(+), 11 deletions(-) create mode 100644 OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh create mode 100644 OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh create mode 100644 Widgets/Matrix3x3Widget.cc create mode 100644 Widgets/Matrix3x3Widget.hh create mode 100644 Widgets/Matrix3x3Widget.ui diff --git a/Models/PropertyNameListModel.cc b/Models/PropertyNameListModel.cc index b272718..b4a7fbb 100644 --- a/Models/PropertyNameListModel.cc +++ b/Models/PropertyNameListModel.cc @@ -45,6 +45,7 @@ #include #include +#include #include @@ -64,6 +65,8 @@ const PropertyNameListModel::TypeInfoWrapper PropertyNameListModel::proptype_Vec PropertyNameListModel::TypeInfoWrapper(typeid(OpenMesh::PropertyT), "Vec2d"); const PropertyNameListModel::TypeInfoWrapper PropertyNameListModel::proptype_Vec2f = PropertyNameListModel::TypeInfoWrapper(typeid(OpenMesh::PropertyT), "Vec2f"); +const PropertyNameListModel::TypeInfoWrapper PropertyNameListModel::proptype_Matrix3x3d = + PropertyNameListModel::TypeInfoWrapper(typeid(OpenMesh::PropertyT), "Matrix3x3d"); #ifdef ENABLE_SKELETON_SUPPORT #include diff --git a/Models/PropertyNameListModel.hh b/Models/PropertyNameListModel.hh index c4aa1b5..c2582f4 100644 --- a/Models/PropertyNameListModel.hh +++ b/Models/PropertyNameListModel.hh @@ -66,7 +66,7 @@ class PropertyNameListModel: public QAbstractListModel { class TypeInfoWrapper { public: TypeInfoWrapper(const std::type_info & ti, const char *friendlyName) : ti(&ti), friendlyName(friendlyName) {} - TypeInfoWrapper(const std::type_info & ti) : ti(&ti),friendlyName("") {} + explicit TypeInfoWrapper(const std::type_info & ti) : ti(&ti),friendlyName("") {} operator const std::type_info *() const { return ti; } operator const std::type_info &() const { return *ti; } @@ -215,6 +215,7 @@ class PropertyNameListModel: public QAbstractListModel { static const TypeInfoWrapper proptype_Vec3f; static const TypeInfoWrapper proptype_Vec2d; static const TypeInfoWrapper proptype_Vec2f; + static const TypeInfoWrapper proptype_Matrix3x3d; static const TypeInfoWrapper proptype_SkinWeights; private: diff --git a/OpenVolumeMesh/OVMPropertyModelT.hh b/OpenVolumeMesh/OVMPropertyModelT.hh index 132c4bf..7346881 100644 --- a/OpenVolumeMesh/OVMPropertyModelT.hh +++ b/OpenVolumeMesh/OVMPropertyModelT.hh @@ -48,6 +48,7 @@ #include "OVMPropertyVisualizerBoolean.hh" #include "OVMPropertyVisualizerDouble.hh" #include "OVMPropertyVisualizerInteger.hh" +#include "OVMPropertyVisualizerMatrix3x3.hh" #include "OVMPropertyVisualizerVector.hh" #include "OVMPropertyVisualizerVectorFieldDifference.hh" @@ -104,6 +105,8 @@ public: static bool isVec3fType(const TypeInfoWrapper& typeInfo); static bool isVectorType(const PropertyInfo& propInfo); static bool isVectorType(const TypeInfoWrapper& typeInfo); + static bool isMatrix3x3Type(const PropertyInfo& propInfo); + static bool isMatrix3x3Type(const TypeInfoWrapper& typeInfo); #define DECLARE_PROPTYPES(primitive) \ static const TypeInfoWrapper proptype_##primitive##_bool; \ @@ -111,7 +114,8 @@ public: static const TypeInfoWrapper proptype_##primitive##_uint; \ static const TypeInfoWrapper proptype_##primitive##_double; \ static const TypeInfoWrapper proptype_##primitive##_Vec3d; \ - static const TypeInfoWrapper proptype_##primitive##_Vec3f; + static const TypeInfoWrapper proptype_##primitive##_Vec3f; \ + static const TypeInfoWrapper proptype_##primitive##_Matrix3x3d; DECLARE_PROPTYPES(Cell) DECLARE_PROPTYPES(Face) @@ -206,7 +210,9 @@ template const TypeInfoWrapper OVMPropertyModel::proptype_##prim template const TypeInfoWrapper OVMPropertyModel::proptype_##primitive##_Vec3d \ = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT), "Vec3d"); \ template const TypeInfoWrapper OVMPropertyModel::proptype_##primitive##_Vec3f \ - = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT), "Vec3f"); + = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT), "Vec3f"); \ +template const TypeInfoWrapper OVMPropertyModel::proptype_##primitive##_Matrix3x3d \ + = TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT), "Matrix3x3d"); INITIALIZE_PROPTYPES(Cell) INITIALIZE_PROPTYPES(Face) diff --git a/OpenVolumeMesh/OVMPropertyModelT_impl.hh b/OpenVolumeMesh/OVMPropertyModelT_impl.hh index 4170704..92bf86c 100644 --- a/OpenVolumeMesh/OVMPropertyModelT_impl.hh +++ b/OpenVolumeMesh/OVMPropertyModelT_impl.hh @@ -646,6 +646,23 @@ bool OVMPropertyModel::isVectorType(const TypeInfoWrapper& typeInfo) return isVec3fType(typeInfo) || isVec3dType(typeInfo); } +template +bool OVMPropertyModel::isMatrix3x3Type(const PropertyInfo& propInfo) +{ + return isMatrix3x3Type(propInfo.typeinfo()); +} + +template +bool OVMPropertyModel::isMatrix3x3Type(const TypeInfoWrapper& typeInfo) +{ + return typeInfo == proptype_Cell_Matrix3x3d || + typeInfo == proptype_Face_Matrix3x3d || + typeInfo == proptype_HalfFace_Matrix3x3d || + typeInfo == proptype_Edge_Matrix3x3d || + typeInfo == proptype_HalfEdge_Matrix3x3d || + typeInfo == proptype_Vertex_Matrix3x3d; +} + template bool OVMPropertyModel::isEntityType(const TypeInfoWrapper& typeInfo, PropertyInfo::ENTITY_FILTER entity_type) const { @@ -732,6 +749,8 @@ void OVMPropertyModel::addPropertyVisualizer(OpenVolumeMesh::BaseProperty propertyVisualizers.push_back(new OVMPropertyVisualizerDouble(mesh, objectID_, propInfo)); else if (isVectorType(propInfo)) propertyVisualizers.push_back(new OVMPropertyVisualizerVector(mesh, objectID_, propInfo)); + else if (isMatrix3x3Type(propInfo)) + propertyVisualizers.push_back(new OVMPropertyVisualizerMatrix3x3(mesh, objectID_, propInfo)); connectLogs(propertyVisualizers.back()); } @@ -936,6 +955,7 @@ supportedPropertyTypes.insert(proptype_##primitive##_uint); \ supportedPropertyTypes.insert(proptype_##primitive##_double); \ supportedPropertyTypes.insert(proptype_##primitive##_Vec3d); \ supportedPropertyTypes.insert(proptype_##primitive##_Vec3f); \ +supportedPropertyTypes.insert(proptype_##primitive##_Matrix3x3d); \ INSERT_PROPTYPES(Cell) INSERT_PROPTYPES(Face) diff --git a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh new file mode 100644 index 0000000..8c06327 --- /dev/null +++ b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh @@ -0,0 +1,85 @@ +/*===========================================================================*\ +* * +* OpenFlipper * + * 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. * +* * +\*===========================================================================*/ + + +#pragma once + +#include "OVMPropertyVisualizer.hh" + +#include +#include + +#include +#include + +#include "Widgets/Matrix3x3Widget.hh" + +#include + +template +class OVMPropertyVisualizerMatrix3x3: public OVMPropertyVisualizer{ + +public: + OVMPropertyVisualizerMatrix3x3(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo); + virtual ~OVMPropertyVisualizerMatrix3x3(){ clear(); } + + void clear() override; + +protected: + void duplicateProperty() override; + + void visualizeFaceProp(bool _setDrawMode = true) override; + void visualizeEdgeProp(bool _setDrawMode = true) override; + void visualizeHalfedgeProp(bool _setDrawMode = true) override; + void visualizeVertexProp(bool _setDrawMode = true) override; + void visualizeCellProp(bool _setDrawMode = true) override; + void visualizeHalffaceProp(bool _setDrawMode = true) override; + + QString getPropertyText(unsigned int index) override; + + ACG::SceneGraph::LineNode* lineNode; + +}; + +#if defined(INCLUDE_TEMPLATES) && !defined(OVM_PROPERTY_VISUALIZER_MAT3X3_CC) +#include "OVMPropertyVisualizerMatrix3x3T.cc" +#endif + diff --git a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh new file mode 100644 index 0000000..5831307 --- /dev/null +++ b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh @@ -0,0 +1,113 @@ +/*===========================================================================*\ +* * +* OpenFlipper * + * 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. * +* * +\*===========================================================================*/ + + + + +#define OVM_PROPERTY_VISUALIZER_MAT3X3_CC + +#include +#include "OVMPropertyVisualizerMatrix3x3.hh" + + +template +OVMPropertyVisualizerMatrix3x3::OVMPropertyVisualizerMatrix3x3(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo) + : OVMPropertyVisualizer(_mesh, objectID, _propertyInfo) +{ + if (PropertyVisualizer::widget) delete PropertyVisualizer::widget; + Matrix3x3Widget* w = new Matrix3x3Widget(); + PropertyVisualizer::widget = w; + + BaseObjectData *bod; + PluginFunctions::getObject(objectID, bod); + lineNode = new ACG::SceneGraph::LineNode(ACG::SceneGraph::LineNode::LineSegmentsMode, bod->baseNode()); + this->connect(w->lineWidth, QOverload::of(&QDoubleSpinBox::valueChanged), + [this](double value) {lineNode->set_line_width(value);}); +} + +template +void OVMPropertyVisualizerMatrix3x3::clear() +{ + lineNode->clear(); + OVMPropertyVisualizer::clear(); +} + +template +void OVMPropertyVisualizerMatrix3x3::duplicateProperty() +{ + OVMPropertyVisualizer::template duplicateProperty_stage1(); +} + +template +void OVMPropertyVisualizerMatrix3x3::visualizeCellProp(bool _setDrawMode) +{ +} + +template +void OVMPropertyVisualizerMatrix3x3::visualizeFaceProp(bool _setDrawMode) +{} + + +template +void OVMPropertyVisualizerMatrix3x3::visualizeHalffaceProp(bool _setDrawMode) +{} + +template +void OVMPropertyVisualizerMatrix3x3::visualizeEdgeProp(bool _setDrawMode) +{ +} + +template +void OVMPropertyVisualizerMatrix3x3::visualizeHalfedgeProp(bool _setDrawMode) +{ + +} + +template +void OVMPropertyVisualizerMatrix3x3::visualizeVertexProp(bool _setDrawMode) +{} + +template +QString OVMPropertyVisualizerMatrix3x3::getPropertyText(unsigned int index) +{ + return OVMPropertyVisualizer::template getPropertyText_(index); +} + diff --git a/PropertyVisualizer/PropertyVisualizer.cc b/PropertyVisualizer/PropertyVisualizer.cc index 956b53a..6a43dbc 100644 --- a/PropertyVisualizer/PropertyVisualizer.cc +++ b/PropertyVisualizer/PropertyVisualizer.cc @@ -42,6 +42,7 @@ #include "PropertyVisualizer.hh" +#include "ACG/Math/Matrix3x3T.hh" /*! \brief Visualizes the property * @@ -107,6 +108,14 @@ QString PropertyVisualizer::toStr(OpenMesh::Vec2f v) return QObject::tr("∥(%1, %2)∥ = %3").arg(v[0]).arg(v[1]).arg(v.norm()); } +QString PropertyVisualizer::toStr(const ACG::Matrix3x3d &v) +{ + return QString("(%1, %2, %3); (%4, %5, %6); (%7, %8, %9) ") + .arg(v(0, 0)).arg(v(0, 1)).arg(v(0, 2)) + .arg(v(1, 0)).arg(v(1, 1)).arg(v(1, 2)) + .arg(v(2, 0)).arg(v(2, 1)).arg(v(2, 2)); +} + #ifdef ENABLE_SKELETON_SUPPORT QString PropertyVisualizer::toStr(BaseSkin::SkinWeights sw) { diff --git a/PropertyVisualizer/PropertyVisualizer.hh b/PropertyVisualizer/PropertyVisualizer.hh index 1199331..d8a0d0f 100644 --- a/PropertyVisualizer/PropertyVisualizer.hh +++ b/PropertyVisualizer/PropertyVisualizer.hh @@ -161,6 +161,7 @@ public: static QString toStr(OpenMesh::Vec3d v); static QString toStr(OpenMesh::Vec2d v); static QString toStr(OpenMesh::Vec2f v); + static QString toStr(const ACG::Matrix3x3d &v); #ifdef ENABLE_SKELETON_SUPPORT static QString toStr(BaseSkin::SkinWeights sw); #endif diff --git a/Widgets/BooleanWidget.hh b/Widgets/BooleanWidget.hh index d52a606..b7a41fe 100644 --- a/Widgets/BooleanWidget.hh +++ b/Widgets/BooleanWidget.hh @@ -48,7 +48,7 @@ class BooleanWidget : public QWidget, public Ui::BooleanWidget Q_OBJECT public: - explicit BooleanWidget(QWidget * parent = 0); + explicit BooleanWidget(QWidget * parent = nullptr); signals: void widgetShown(); diff --git a/Widgets/DoubleWidget.hh b/Widgets/DoubleWidget.hh index 215db3b..0d19fda 100644 --- a/Widgets/DoubleWidget.hh +++ b/Widgets/DoubleWidget.hh @@ -51,7 +51,7 @@ class DoubleWidget : public QWidget, public Ui::DoubleWidget Q_OBJECT public: - explicit DoubleWidget(QWidget * parent = 0); + explicit DoubleWidget(QWidget * parent = nullptr); /** * @brief Builds a color coder according to UI settings diff --git a/Widgets/IntegerWidget.hh b/Widgets/IntegerWidget.hh index eccddb0..7696bd2 100644 --- a/Widgets/IntegerWidget.hh +++ b/Widgets/IntegerWidget.hh @@ -53,7 +53,7 @@ class IntegerWidget : public QWidget, public Ui::IntegerWidget Q_OBJECT public: - explicit IntegerWidget(QWidget * parent = 0); + explicit IntegerWidget(QWidget * parent = nullptr); /** * @brief Builds a color coder according to UI settings diff --git a/Widgets/LoadSaveWidget.hh b/Widgets/LoadSaveWidget.hh index 1607979..2e02707 100644 --- a/Widgets/LoadSaveWidget.hh +++ b/Widgets/LoadSaveWidget.hh @@ -47,7 +47,7 @@ class LoadSaveWidget : public QWidget, public Ui::LoadSaveWidget Q_OBJECT public: - explicit LoadSaveWidget(QWidget * parent = 0); + explicit LoadSaveWidget(QWidget * parent = nullptr); signals: void widgetShown(); diff --git a/Widgets/Matrix3x3Widget.cc b/Widgets/Matrix3x3Widget.cc new file mode 100644 index 0000000..8b207e7 --- /dev/null +++ b/Widgets/Matrix3x3Widget.cc @@ -0,0 +1,60 @@ +/*===========================================================================*\ +* * +* OpenFlipper * + * 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. * +* * +\*===========================================================================*/ + + +#include "Matrix3x3Widget.hh" + +#include "ACG/Utils/ColorCoder.hh" +#include "ACG/Utils/LinearTwoColorCoder.hh" +#include + +Matrix3x3Widget::Matrix3x3Widget(QWidget * parent) +: QWidget(parent) +{ + setupUi(this); +} + +void Matrix3x3Widget::showEvent ( QShowEvent* /*event*/ ) { + emit widgetShown(); +} + + + diff --git a/Widgets/Matrix3x3Widget.hh b/Widgets/Matrix3x3Widget.hh new file mode 100644 index 0000000..7bb8eb3 --- /dev/null +++ b/Widgets/Matrix3x3Widget.hh @@ -0,0 +1,65 @@ +/*===========================================================================*\ +* * +* OpenFlipper * + * 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. * +* * +\*===========================================================================*/ + + + +#pragma once + +#include "ui_Matrix3x3Widget.h" + +#include "ACG/Utils/IColorCoder.hh" +#include + +class Matrix3x3Widget : public QWidget, public Ui::Mat3x3Widget +{ + Q_OBJECT + +public: + explicit Matrix3x3Widget(QWidget * parent = nullptr); + + signals: + void widgetShown(); + + protected: + void showEvent ( QShowEvent* /*event*/ ); +}; + + diff --git a/Widgets/Matrix3x3Widget.ui b/Widgets/Matrix3x3Widget.ui new file mode 100644 index 0000000..da5aeb1 --- /dev/null +++ b/Widgets/Matrix3x3Widget.ui @@ -0,0 +1,312 @@ + + + Mat3x3Widget + + + + 0 + 0 + 352 + 270 + + + + Property Visualization + + + Vectors are normalized and then transformed to the [0,1] range + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 3x3 Matrix Parameters + + + + + + false + + + false + + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + α = + + + 4 + + + 1.000000000000000 + + + 0.100000000000000 + + + 0.400000000000000 + + + + + + + + + + + + + + + 0 + 0 + + + + β = + + + 4 + + + 1.000000000000000 + + + 0.100000000000000 + + + 0.600000000000000 + + + + + + + + + + Visualize columns as: + + + + + + + + + Crosses + + + true + + + vector_buttonGroup + + + + + + + Boxes + + + vector_buttonGroup + + + + + + + + + + 0 + + + 0 + + + 0 + + + + + Normalize + + + false + + + + + + + + + 0.100000000000000 + + + 50.000000000000000 + + + 1.000000000000000 + + + + + + + Line width + + + + + + + Scale with factor + + + false + + + + + + + false + + + 7 + + + 1000.000000000000000 + + + 0.200000000000000 + + + + + + + + + Line color: + + + + 198 + 0 + 3 + + + + + + + + + + + true + + + false + + + <html><head/><body><p>Vectors are first normalized and then scaled to the [0,1] range</p></body></html> + + + Normalize + + + + + + + + + + Qt::Vertical + + + + 0 + 0 + + + + + + + + + QtColorChooserButton + QPushButton +
ACG/QtWidgets/QtColorChooserButton.hh
+
+
+ + as_crosses + as_boxes + normalize + scale + scaleBox + lineColor + vectors_edges_alpha + vectors_edges_beta + + + + + scale + toggled(bool) + scaleBox + setEnabled(bool) + + + 172 + 142 + + + 324 + 145 + + + + + + + +
diff --git a/Widgets/PickWidget.hh b/Widgets/PickWidget.hh index 8b3ffe7..cf4299a 100644 --- a/Widgets/PickWidget.hh +++ b/Widgets/PickWidget.hh @@ -48,7 +48,7 @@ class PickWidget : public QWidget, public Ui::PickWidget Q_OBJECT public: - explicit PickWidget(QWidget * parent = 0); + explicit PickWidget(QWidget * parent = nullptr); signals: void widgetShown(); diff --git a/Widgets/SkinWeightsWidget.hh b/Widgets/SkinWeightsWidget.hh index e28be1d..eec211a 100644 --- a/Widgets/SkinWeightsWidget.hh +++ b/Widgets/SkinWeightsWidget.hh @@ -48,7 +48,7 @@ class SkinWeightsWidget : public QWidget, public Ui::SkinWeightsWidget Q_OBJECT public: - explicit SkinWeightsWidget(QWidget * parent = 0); + explicit SkinWeightsWidget(QWidget * parent = nullptr); signals: void widgetShown(); diff --git a/Widgets/VectorFieldDifferenceWidget.hh b/Widgets/VectorFieldDifferenceWidget.hh index ce4eb09..e5cdd66 100644 --- a/Widgets/VectorFieldDifferenceWidget.hh +++ b/Widgets/VectorFieldDifferenceWidget.hh @@ -48,7 +48,7 @@ class VectorFieldDifferenceWidget : public QWidget, public Ui::VectorFieldDiffer Q_OBJECT public: - explicit VectorFieldDifferenceWidget(QWidget * parent = 0); + explicit VectorFieldDifferenceWidget(QWidget * parent = nullptr); signals: void widgetShown(); diff --git a/Widgets/VectorWidget.hh b/Widgets/VectorWidget.hh index 66d56a2..8ad03d5 100644 --- a/Widgets/VectorWidget.hh +++ b/Widgets/VectorWidget.hh @@ -48,7 +48,7 @@ class VectorWidget : public QWidget, public Ui::VectorWidget Q_OBJECT public: - explicit VectorWidget(QWidget * parent = 0); + explicit VectorWidget(QWidget * parent = nullptr); signals: void widgetShown(); -- GitLab From 51d944e8c0c10fc290c3a0522e3fcb4faca7fe95 Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Mon, 13 May 2019 13:41:11 +0200 Subject: [PATCH 2/7] mat3x3 vis: implement cross visualisation --- OpenVolumeMesh/EntityPosition.hh | 56 +++++++++++ .../OVMPropertyVisualizerMatrix3x3.hh | 12 ++- .../OVMPropertyVisualizerMatrix3x3_impl.hh | 94 ++++++++++++++++--- 3 files changed, 150 insertions(+), 12 deletions(-) create mode 100644 OpenVolumeMesh/EntityPosition.hh diff --git a/OpenVolumeMesh/EntityPosition.hh b/OpenVolumeMesh/EntityPosition.hh new file mode 100644 index 0000000..0ed13aa --- /dev/null +++ b/OpenVolumeMesh/EntityPosition.hh @@ -0,0 +1,56 @@ +#pragma once + +#include +#include +#include + +template +class EntityPosition +{ +public: + EntityPosition(MeshT &mesh) : mesh_(mesh) {} + ACG::Vec3d operator()(OpenVolumeMesh::VertexHandle vh) + { + return mesh_.vertex(vh); + } + ACG::Vec3d operator()(OpenVolumeMesh::EdgeHandle eh) + { + auto edge = mesh_.edge(eh); + return 0.5 * (mesh_.vertex(edge.from_vertex()) + mesh_.vertex(edge.to_vertex())); + } + ACG::Vec3d operator()(OpenVolumeMesh::HalfEdgeHandle heh) + { + auto edge = mesh_.halfedge(heh); + return (1./3.) * (2 * mesh_.vertex(edge.from_vertex()) + mesh_.vertex(edge.to_vertex())); + } + ACG::Vec3d operator()(OpenVolumeMesh::CellHandle ch) + { + int count = 0; + ACG::Vec3d sum{0.,0.,0.}; + for (auto vh: mesh_.cell_vertices(ch)) { + sum += mesh_.vertex(vh); + ++count; + } + return sum / count; + } + + ACG::Vec3d operator()(OpenVolumeMesh::FaceHandle fh) + { + return (*this)(mesh_.halfface_handle(fh, 0)); + } + + ACG::Vec3d operator()(OpenVolumeMesh::HalfFaceHandle hfh) + { + // TODO: maybe offset this slightly from the face barycenter? + int count = 0; + ACG::Vec3d sum{0.,0.,0.}; + for (auto vh: mesh_.halfface_vertices(hfh)) { + sum += mesh_.vertex(vh); + ++count; + } + return sum / count; + } +private: + MeshT &mesh_; +}; + diff --git a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh index 8c06327..c3d113c 100644 --- a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh +++ b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh @@ -66,6 +66,7 @@ public: protected: void duplicateProperty() override; + void visualizeFaceProp(bool _setDrawMode = true) override; void visualizeEdgeProp(bool _setDrawMode = true) override; void visualizeHalfedgeProp(bool _setDrawMode = true) override; @@ -77,9 +78,18 @@ protected: ACG::SceneGraph::LineNode* lineNode; +private: + template + void visualizeAsCrossForEntity(EntityIterator e_begin, EntityIterator e_end); + template + void visualizeAsBoxesForEntity(EntityIterator e_begin, EntityIterator e_end); + template + void visualizeForEntity(EntityIterator e_begin, EntityIterator e_end); + + Matrix3x3Widget* getWidget() {return static_cast(PropertyVisualizer::widget);} }; #if defined(INCLUDE_TEMPLATES) && !defined(OVM_PROPERTY_VISUALIZER_MAT3X3_CC) -#include "OVMPropertyVisualizerMatrix3x3T.cc" +#include "OVMPropertyVisualizerMatrix3x3_impl.hh" #endif diff --git a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh index 5831307..2ca12c4 100644 --- a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh +++ b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh @@ -46,7 +46,7 @@ #include #include "OVMPropertyVisualizerMatrix3x3.hh" - +#include "EntityPosition.hh" template OVMPropertyVisualizerMatrix3x3::OVMPropertyVisualizerMatrix3x3(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo) @@ -76,34 +76,106 @@ void OVMPropertyVisualizerMatrix3x3::duplicateProperty() OVMPropertyVisualizer::template duplicateProperty_stage1(); } +template +template +void OVMPropertyVisualizerMatrix3x3:: +visualizeAsCrossForEntity(EntityIterator e_begin, EntityIterator e_end) +{ + using ACG::Vec3d; + using ACG::Matrix3x3d; + using Color4f = ACG::SceneGraph::LineNode::Color4f; + + MeshT &m = * OVMPropertyVisualizer::mesh; + EntityPosition ep{m}; + auto prop = m.template request_property(OVMPropertyVisualizer::propertyInfo.propName()); + + if (!prop) + throw VizException("Getting PropHandle from mesh for selected property failed."); + + std::array dim_color { + Color4f{1.f,0.f,0.f,1.f}, + Color4f{0.f,1.f,0.f,1.f}, + Color4f{0.f,0.f,1.f,1.f} + }; + + lineNode->clear(); + + bool normalized = getWidget()->normalize_colors->isChecked(); + double scaleFactor = getWidget()->scale->isChecked() ? getWidget()->scaleBox->value() : 1.0; + for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) { + Matrix3x3d mat = prop[*e_it]; + Vec3d center_pos = ep(*e_it); + for (unsigned char dim = 0; dim < 3; ++dim) { + ACG::Vec3d v = mat.getCol(dim); + v *= (normalized ? (scaleFactor / v.norm()) : scaleFactor); + lineNode->add_line(center_pos - v, center_pos + v); + lineNode->add_color(dim_color[dim]); + } + } +} + +template +template +void OVMPropertyVisualizerMatrix3x3:: +visualizeAsBoxesForEntity(EntityIterator e_begin, EntityIterator e_end) +{ + +} + +template +template +void OVMPropertyVisualizerMatrix3x3:: +visualizeForEntity(EntityIterator e_begin, EntityIterator e_end) +{ + if (getWidget()->as_crosses->isChecked()) { + visualizeAsCrossForEntity(e_begin, e_end); + } else if (getWidget()->as_boxes->isChecked()) { + visualizeAsBoxesForEntity(e_begin, e_end); + } +} + template -void OVMPropertyVisualizerMatrix3x3::visualizeCellProp(bool _setDrawMode) +void OVMPropertyVisualizerMatrix3x3::visualizeCellProp(bool /*_setDrawMode*/) { + MeshT &m = * OVMPropertyVisualizer::mesh; + visualizeForEntity(m.cells_begin(), m.cells_end()); } template -void OVMPropertyVisualizerMatrix3x3::visualizeFaceProp(bool _setDrawMode) -{} +void OVMPropertyVisualizerMatrix3x3::visualizeFaceProp(bool /*_setDrawMode*/) +{ + MeshT &m = * OVMPropertyVisualizer::mesh; + visualizeForEntity(m.faces_begin(), m.faces_end()); +} template -void OVMPropertyVisualizerMatrix3x3::visualizeHalffaceProp(bool _setDrawMode) -{} +void OVMPropertyVisualizerMatrix3x3::visualizeHalffaceProp(bool /*_setDrawMode*/) +{ + MeshT &m = * OVMPropertyVisualizer::mesh; + visualizeForEntity(m.halffaces_begin(), m.halffaces_end()); +} template -void OVMPropertyVisualizerMatrix3x3::visualizeEdgeProp(bool _setDrawMode) +void OVMPropertyVisualizerMatrix3x3::visualizeEdgeProp(bool /*_setDrawMode*/) { + MeshT &m = * OVMPropertyVisualizer::mesh; + visualizeForEntity(m.edges_begin(), m.edges_end()); } template -void OVMPropertyVisualizerMatrix3x3::visualizeHalfedgeProp(bool _setDrawMode) +void OVMPropertyVisualizerMatrix3x3::visualizeHalfedgeProp(bool /*_setDrawMode*/) { - + MeshT &m = * OVMPropertyVisualizer::mesh; + visualizeForEntity(m.halfedges_begin(), m.halfedges_end()); } template -void OVMPropertyVisualizerMatrix3x3::visualizeVertexProp(bool _setDrawMode) -{} +void OVMPropertyVisualizerMatrix3x3::visualizeVertexProp(bool /*_setDrawMode*/) +{ + MeshT &m = * OVMPropertyVisualizer::mesh; + visualizeForEntity(m.vertices_begin(), m.vertices_end()); +} template QString OVMPropertyVisualizerMatrix3x3::getPropertyText(unsigned int index) -- GitLab From 39cc622be5f222253d6f139d7d50446fc5d28a95 Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Mon, 13 May 2019 15:07:01 +0200 Subject: [PATCH 3/7] mat3x3 vis: Implement box-based visualisation --- CMakeLists.txt | 4 +- Nodes/BoxesNode.cc | 200 ++++++++++++++++++ Nodes/BoxesNode.hh | 116 ++++++++++ .../OVMPropertyVisualizerMatrix3x3.hh | 13 +- .../OVMPropertyVisualizerMatrix3x3_impl.hh | 68 ++++-- .../OVMPropertyVisualizerVectorT_impl.hh | 2 +- Shaders/BoxesNode/vert.glsl | 38 ++++ Widgets/Matrix3x3Widget.hh | 12 +- Widgets/Matrix3x3Widget.ui | 65 +++--- 9 files changed, 459 insertions(+), 59 deletions(-) create mode 100644 Nodes/BoxesNode.cc create mode 100644 Nodes/BoxesNode.hh create mode 100644 Shaders/BoxesNode/vert.glsl diff --git a/CMakeLists.txt b/CMakeLists.txt index 863cea2..3778701 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,8 +7,8 @@ if(APPLE) add_definitions(-DOVM_FORCE_STATIC_CAST) endif() -openflipper_plugin (INSTALLDATA Icons - DIRS OpenMesh OpenVolumeMesh Widgets ScriptObjects Toolbars Models PropertyVisualizer +openflipper_plugin (INSTALLDATA Icons Shaders + DIRS OpenMesh OpenVolumeMesh Widgets ScriptObjects Toolbars Models Nodes PropertyVisualizer DEPS OpenMesh OPTDEPS OpenVolumeMesh OPT_TYPES SKELETON BSPLINECURVE POLYHEDRALMESH HEXAHEDRALMESH TETRAHEDRALMESH diff --git a/Nodes/BoxesNode.cc b/Nodes/BoxesNode.cc new file mode 100644 index 0000000..eacd653 --- /dev/null +++ b/Nodes/BoxesNode.cc @@ -0,0 +1,200 @@ +/*===========================================================================*\ + * * + * OpenFlipper * + * 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. * + * * +\*===========================================================================*/ + + +#include +#include "BoxesNode.hh" +#include + + +namespace ACG { +namespace SceneGraph { + +BoxesNode::BoxesNode(BaseNode* _parent, + std::string _name) : + MaterialNode(_parent, _name), + updateVBO_(true) +{ + const std::array dim_color = { + Vec4f{1.f,0.f,0.f,1.f}, + Vec4f{0.f,1.f,0.f,1.f}, + Vec4f{0.f,0.f,1.f,1.f} + }; + + const std::array vertices = { + Vec3f( 1.f, -1.f, -1.f), + Vec3f( 1.f, 1.f, -1.f), + Vec3f( 1.f, 1.f, 1.f), + Vec3f( 1.f, -1.f, 1.f), + Vec3f(-1.f, -1.f, -1.f), + Vec3f(-1.f, 1.f, -1.f), + Vec3f(-1.f, 1.f, 1.f), + Vec3f(-1.f, -1.f, 1.f)}; + + auto add_triangle = [this, &vertices, &dim_color] + (size_t v0, size_t v1, size_t v2, size_t dim) + { + triangles_.push_back({vertices[v0], vertices[v1], vertices[v2]}); + triangle_colors_.push_back(dim_color[dim]); + }; + + triangles_.reserve(6*2); + triangle_colors_.reserve(6*2); + add_triangle(0, 1, 2, 0); + add_triangle(0, 2, 3, 0); + add_triangle(4, 6, 5, 0); + add_triangle(4, 7, 6, 0); + + add_triangle(1, 5, 6, 1); + add_triangle(1, 6, 2, 1); + add_triangle(0, 3, 7, 1); + add_triangle(0, 7, 4, 1); + + add_triangle(2, 7, 3, 2); + add_triangle(2, 6, 7, 2); + add_triangle(0, 4, 1, 2); + add_triangle(1, 4, 5, 2); +} + +void +BoxesNode:: +boundingBox(Vec3d& _bbMin, Vec3d& _bbMax) +{ + for (const auto &be: elem_) { + _bbMax.maximize(be.pos + Vec3d(1.,1.,1.)); + _bbMin.minimize(be.pos + Vec3d(-1., -1., -1.)); + } +} + +void BoxesNode::createVBO() +{ + if (!updateVBO_) + return; + + // generate if needed: + geometry_vbo_.bind(); + instance_vbo_.bind(); + + vertexDecl_.clear(); + vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_POSITION, nullptr, nullptr, 0, geometry_vbo_.id()); + vertexDecl_.addElement(GL_FLOAT, 4, VERTEX_USAGE_COLOR, nullptr, nullptr, 0, geometry_vbo_.id()); + std::vector geom_vbo_data; geom_vbo_data.reserve(3 * (3+4) * triangles_.size()); + + vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_SHADER_INPUT, nullptr, "inst_v0", 1, instance_vbo_.id()); + vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_SHADER_INPUT, nullptr, "inst_v1", 1, instance_vbo_.id()); + vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_SHADER_INPUT, nullptr, "inst_v2", 1, instance_vbo_.id()); + vertexDecl_.addElement(GL_FLOAT, 3, VERTEX_USAGE_SHADER_INPUT, nullptr, "inst_pos", 1, instance_vbo_.id()); + std::vector instance_vbo_data; instance_vbo_data.reserve(3 * 4 * elem_.size()); + + assert(triangles_.size() == triangle_colors_.size()); + for (size_t i = 0; i < triangles_.size(); ++i) + { + auto &tri = triangles_[i]; + auto &color = triangle_colors_[i]; + for (const auto &point: tri) { + std::copy(point.begin(), point.end(), std::back_inserter(geom_vbo_data)); + std::copy(color.begin(), color.end(), std::back_inserter(geom_vbo_data)); + } + } + for (const auto &be: elem_) { + for (const auto &point: { + be.transform.getRow(0), + be.transform.getRow(1), + be.transform.getRow(2), + be.pos}) + { + std::copy(point.begin(), point.end(), std::back_inserter(instance_vbo_data)); + } + } + + geometry_vbo_.upload( + static_cast(geom_vbo_data.size()*sizeof(float)), + geom_vbo_data.data(), + GL_STATIC_DRAW_ARB); + instance_vbo_.upload( + static_cast(instance_vbo_data.size()*sizeof(float)), + instance_vbo_data.data(), + GL_STATIC_DRAW_ARB); + + // Update done. + updateVBO_ = false; + +} + +void +BoxesNode:: +getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawMode& /* _drawMode */, const ACG::SceneGraph::Material* _mat) +{ + if (elem_.empty()) + return; + + RenderObject ro; + ro.initFromState(&_state); + ro.setMaterial(_mat); + + boxesNodeName_ = std::string("BoxesNode: ")+name(); + ro.debugName = boxesNodeName_; + + ro.depthTest = true; + ro.depthWrite = true; + + ro.blending = true; + ro.blendSrc = GL_SRC_ALPHA; + ro.blendDest = GL_ONE_MINUS_SRC_ALPHA; + + ro.shaderDesc.shadeMode = SG_SHADE_UNLIT; + ro.shaderDesc.vertexColors = true; + ro.shaderDesc.vertexTemplateFile = "BoxesNode/vert.glsl"; + + ro.setUniform("scale", scaleFactor_); + + createVBO(); + ro.vertexBuffer = geometry_vbo_.id(); + ro.vertexDecl = &vertexDecl_; + + ro.glDrawInstancedArrays(GL_TRIANGLES, 0, + static_cast(3 * triangles_.size()), + static_cast(elem_.size())); + _renderer->addRenderObject(&ro); +} + +} // namespace SceneGraph +} // namespace ACG diff --git a/Nodes/BoxesNode.hh b/Nodes/BoxesNode.hh new file mode 100644 index 0000000..e9b56da --- /dev/null +++ b/Nodes/BoxesNode.hh @@ -0,0 +1,116 @@ +#pragma once +/*===========================================================================*\ + * * + * OpenFlipper * + * 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. * + * * +\*===========================================================================*/ + + +#include +#include +#include +#include +#include +#include +#include + +namespace ACG { +namespace SceneGraph { + +struct BoxElement { + Matrix3x3d transform; + Vec3d pos; +}; + +class ACGDLLEXPORT BoxesNode : public MaterialNode +{ +public: + ACG_CLASSNAME(BoxesNode) + + BoxesNode(BaseNode* _parent=nullptr, + std::string _name="" ); + + ~BoxesNode() = default; + + DrawModes::DrawMode availableDrawModes() const { + return DrawModes::SOLID_FACES_COLORED_FLAT_SHADED; + } + + void boundingBox(Vec3d& _bbMin, Vec3d& _bbMax); + + void clear() { elem_.clear(); updateVBO_ = true; } + + void reserve(size_t _n) { elem_.reserve(_n); } + + /// STL conformance + void push_back(const BoxElement& _v) { elem_.push_back(_v); updateVBO_ = true; } + typedef BoxElement value_type; + typedef BoxElement& reference; + typedef const BoxElement& const_reference; + + void getRenderObjects(IRenderer* _renderer, GLState& _state, const DrawModes::DrawMode& _drawMode, const ACG::SceneGraph::Material* _mat); + + void setScaleFactor(float _val) { scaleFactor_ = _val;} + +protected: + /// creates the vbo only if update was requested + void createVBO(); + + std::vector elem_; + float scaleFactor_ = 1.0f; + + // geometry of a single box + std::vector> triangles_; + std::vector triangle_colors_; + + GeometryBuffer geometry_vbo_; + GeometryBuffer instance_vbo_; + + // True if points changed and the vbo has to be updated + bool updateVBO_; + + ACG::VertexDeclaration vertexDecl_; + + std::string boxesNodeName_; +}; + + +//============================================================================= +} // namespace SceneGraph +} // namespace ACG +//============================================================================= diff --git a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh index c3d113c..25dd9e5 100644 --- a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh +++ b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh @@ -45,6 +45,9 @@ #include "OVMPropertyVisualizer.hh" #include +#include +#include "Nodes/BoxesNode.hh" + #include #include @@ -77,16 +80,18 @@ protected: QString getPropertyText(unsigned int index) override; ACG::SceneGraph::LineNode* lineNode; + ACG::SceneGraph::BoxesNode* boxesNode; private: - template - void visualizeAsCrossForEntity(EntityIterator e_begin, EntityIterator e_end); - template - void visualizeAsBoxesForEntity(EntityIterator e_begin, EntityIterator e_end); + template + void visualizeAsCrossesForEntity(Property prop, EntityIterator e_begin, EntityIterator e_end); + template + void visualizeAsBoxesForEntity(Property prop, EntityIterator e_begin, EntityIterator e_end); template void visualizeForEntity(EntityIterator e_begin, EntityIterator e_end); Matrix3x3Widget* getWidget() {return static_cast(PropertyVisualizer::widget);} + }; #if defined(INCLUDE_TEMPLATES) && !defined(OVM_PROPERTY_VISUALIZER_MAT3X3_CC) diff --git a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh index 2ca12c4..b8d87af 100644 --- a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh +++ b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh @@ -46,8 +46,16 @@ #include #include "OVMPropertyVisualizerMatrix3x3.hh" +#include "ACG/Scenegraph/DrawModes.hh" #include "EntityPosition.hh" +using Color4f = ACG::SceneGraph::LineNode::Color4f; +static std::array dim_color { + Color4f{1.f,0.f,0.f,1.f}, + Color4f{0.f,1.f,0.f,1.f}, + Color4f{0.f,0.f,1.f,1.f} +}; + template OVMPropertyVisualizerMatrix3x3::OVMPropertyVisualizerMatrix3x3(MeshT* _mesh, int objectID, PropertyInfo _propertyInfo) : OVMPropertyVisualizer(_mesh, objectID, _propertyInfo) @@ -58,7 +66,10 @@ OVMPropertyVisualizerMatrix3x3::OVMPropertyVisualizerMatrix3x3(MeshT* _me BaseObjectData *bod; PluginFunctions::getObject(objectID, bod); - lineNode = new ACG::SceneGraph::LineNode(ACG::SceneGraph::LineNode::LineSegmentsMode, bod->baseNode()); + + boxesNode = new ACG::SceneGraph::BoxesNode(bod->manipulatorNode()); + + lineNode = new ACG::SceneGraph::LineNode(ACG::SceneGraph::LineNode::LineSegmentsMode, bod->manipulatorNode()); this->connect(w->lineWidth, QOverload::of(&QDoubleSpinBox::valueChanged), [this](double value) {lineNode->set_line_width(value);}); } @@ -67,6 +78,7 @@ template void OVMPropertyVisualizerMatrix3x3::clear() { lineNode->clear(); + boxesNode->clear(); OVMPropertyVisualizer::clear(); } @@ -77,31 +89,20 @@ void OVMPropertyVisualizerMatrix3x3::duplicateProperty() } template -template +template void OVMPropertyVisualizerMatrix3x3:: -visualizeAsCrossForEntity(EntityIterator e_begin, EntityIterator e_end) +visualizeAsCrossesForEntity(Property prop, EntityIterator e_begin, EntityIterator e_end) { using ACG::Vec3d; using ACG::Matrix3x3d; - using Color4f = ACG::SceneGraph::LineNode::Color4f; - MeshT &m = * OVMPropertyVisualizer::mesh; + MeshT &m = *OVMPropertyVisualizer::mesh; EntityPosition ep{m}; - auto prop = m.template request_property(OVMPropertyVisualizer::propertyInfo.propName()); - - if (!prop) - throw VizException("Getting PropHandle from mesh for selected property failed."); - std::array dim_color { - Color4f{1.f,0.f,0.f,1.f}, - Color4f{0.f,1.f,0.f,1.f}, - Color4f{0.f,0.f,1.f,1.f} - }; - - lineNode->clear(); bool normalized = getWidget()->normalize_colors->isChecked(); - double scaleFactor = getWidget()->scale->isChecked() ? getWidget()->scaleBox->value() : 1.0; + double scaleFactor = getWidget()->getScaleFactor(); + for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) { Matrix3x3d mat = prop[*e_it]; Vec3d center_pos = ep(*e_it); @@ -115,11 +116,30 @@ visualizeAsCrossForEntity(EntityIterator e_begin, EntityIterator e_end) } template -template +template void OVMPropertyVisualizerMatrix3x3:: -visualizeAsBoxesForEntity(EntityIterator e_begin, EntityIterator e_end) +visualizeAsBoxesForEntity(Property prop, EntityIterator e_begin, EntityIterator e_end) { + using ACG::Vec3d; + using ACG::Matrix3x3d; + MeshT &m = *OVMPropertyVisualizer::mesh; + EntityPosition ep{m}; + + bool normalized = getWidget()->normalize_colors->isChecked(); + for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) { + const Matrix3x3d &mat = prop[*e_it]; + Vec3d center_pos = ep(*e_it); + std::array dir; + for (unsigned char dim = 0; dim < 3; ++dim) { + dir[dim] = mat.getCol(dim); + if (normalized) { + dir[dim].normalize(); + } + } + boxesNode->push_back({Matrix3x3d::fromColumns(dir[0], dir[1], dir[2]), center_pos}); + } + boxesNode->setScaleFactor(getWidget()->getScaleFactor()); } template @@ -127,10 +147,16 @@ template void OVMPropertyVisualizerMatrix3x3:: visualizeForEntity(EntityIterator e_begin, EntityIterator e_end) { + clear(); + MeshT &m = * OVMPropertyVisualizer::mesh; + auto prop = m.template request_property(OVMPropertyVisualizer::propertyInfo.propName()); + if (!prop) + throw VizException("Getting PropHandle from mesh for selected property failed."); + if (getWidget()->as_crosses->isChecked()) { - visualizeAsCrossForEntity(e_begin, e_end); + visualizeAsCrossesForEntity(prop, e_begin, e_end); } else if (getWidget()->as_boxes->isChecked()) { - visualizeAsBoxesForEntity(e_begin, e_end); + visualizeAsBoxesForEntity(prop, e_begin, e_end); } } diff --git a/OpenVolumeMesh/OVMPropertyVisualizerVectorT_impl.hh b/OpenVolumeMesh/OVMPropertyVisualizerVectorT_impl.hh index b9fb578..3390595 100644 --- a/OpenVolumeMesh/OVMPropertyVisualizerVectorT_impl.hh +++ b/OpenVolumeMesh/OVMPropertyVisualizerVectorT_impl.hh @@ -59,7 +59,7 @@ OVMPropertyVisualizerVector::OVMPropertyVisualizerVector(MeshT* _mesh, in BaseObjectData *bod; PluginFunctions::getObject(objectID, bod); - lineNode = new ACG::SceneGraph::LineNode(ACG::SceneGraph::LineNode::LineSegmentsMode, bod->baseNode()); + lineNode = new ACG::SceneGraph::LineNode(ACG::SceneGraph::LineNode::LineSegmentsMode, bod->manipulatorNode()); w->vectors_edges_rb->hide(); this->connect(w->lineWidth, QOverload::of(&QDoubleSpinBox::valueChanged), [this](double value) {lineNode->set_line_width(value);}); diff --git a/Shaders/BoxesNode/vert.glsl b/Shaders/BoxesNode/vert.glsl new file mode 100644 index 0000000..266632f --- /dev/null +++ b/Shaders/BoxesNode/vert.glsl @@ -0,0 +1,38 @@ +#version 140 + +in vec3 inst_v0; +in vec3 inst_v1; +in vec3 inst_v2; +in vec3 inst_pos; + +uniform float scale; + +void main() +{ + SG_VERTEX_BEGIN; + + vec4 pa_posOS = SG_INPUT_POSOS; + + vec4 pa_posWS; + pa_posWS.x = dot(inst_v0, pa_posOS.xyz); + pa_posWS.y = dot(inst_v1, pa_posOS.xyz); + pa_posWS.z = dot(inst_v2, pa_posOS.xyz); + pa_posWS.w = 1.0; + pa_posWS.xyz *= scale; + pa_posWS.xyz += inst_pos; + + +#ifdef SG_INPUT_NORMALOS + sg_vNormalVS.x = dot(pa_worldTransform0.xyz, SG_INPUT_NORMALOS.xyz); + sg_vNormalVS.y = dot(pa_worldTransform1.xyz, SG_INPUT_NORMALOS.xyz); + sg_vNormalVS.z = dot(pa_worldTransform2.xyz, SG_INPUT_NORMALOS.xyz); + + sg_vNormalVS = g_mWVIT * sg_vNormalVS; + sg_vNormalVS = normalize(sg_vNormalVS); +#endif + + sg_vPosVS = g_mWV * pa_posWS; + sg_vPosPS = g_mWVP * pa_posWS; + + SG_VERTEX_END; +} diff --git a/Widgets/Matrix3x3Widget.hh b/Widgets/Matrix3x3Widget.hh index 7bb8eb3..6d99555 100644 --- a/Widgets/Matrix3x3Widget.hh +++ b/Widgets/Matrix3x3Widget.hh @@ -50,15 +50,17 @@ class Matrix3x3Widget : public QWidget, public Ui::Mat3x3Widget { - Q_OBJECT + Q_OBJECT public: - explicit Matrix3x3Widget(QWidget * parent = nullptr); + explicit Matrix3x3Widget(QWidget * parent = nullptr); - signals: + double getScaleFactor() { return scale->isChecked() ? scaleBox->value() : 1.0; } + +signals: void widgetShown(); - - protected: + +protected: void showEvent ( QShowEvent* /*event*/ ); }; diff --git a/Widgets/Matrix3x3Widget.ui b/Widgets/Matrix3x3Widget.ui index da5aeb1..f168b25 100644 --- a/Widgets/Matrix3x3Widget.ui +++ b/Widgets/Matrix3x3Widget.ui @@ -116,7 +116,7 @@ - Visualize columns as: + Show transformation on: @@ -180,7 +180,7 @@ 50.000000000000000 - 1.000000000000000 + 3.000000000000000 @@ -197,6 +197,9 @@ Scale with factor + true + + false @@ -204,7 +207,7 @@ - false + true 7 @@ -213,26 +216,12 @@ 1000.000000000000000 - 0.200000000000000 + 0.050000000000000 - - - - Line color: - - - - 198 - 0 - 3 - - - - @@ -270,20 +259,12 @@ - - - QtColorChooserButton - QPushButton -
ACG/QtWidgets/QtColorChooserButton.hh
-
-
as_crosses as_boxes normalize scale scaleBox - lineColor vectors_edges_alpha vectors_edges_beta @@ -305,6 +286,38 @@ + + as_crosses + toggled(bool) + lineWidth + setEnabled(bool) + + + 93 + 62 + + + 260 + 147 + + + + + as_crosses + toggled(bool) + lineWidthLabel + setEnabled(bool) + + + 93 + 62 + + + 100 + 147 + + + -- GitLab From 0686606ab956609be0bfbb8bf1bd08179715ae08 Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Tue, 14 May 2019 15:22:21 +0200 Subject: [PATCH 4/7] mat3x3 vis: remove misguided normalize feature. --- .../OVMPropertyVisualizerMatrix3x3_impl.hh | 14 ++------------ Widgets/Matrix3x3Widget.ui | 11 ----------- 2 files changed, 2 insertions(+), 23 deletions(-) diff --git a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh index b8d87af..2d14f63 100644 --- a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh +++ b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh @@ -100,15 +100,13 @@ visualizeAsCrossesForEntity(Property prop, EntityIterator e_begin, EntityIterato EntityPosition ep{m}; - bool normalized = getWidget()->normalize_colors->isChecked(); double scaleFactor = getWidget()->getScaleFactor(); for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) { Matrix3x3d mat = prop[*e_it]; Vec3d center_pos = ep(*e_it); for (unsigned char dim = 0; dim < 3; ++dim) { - ACG::Vec3d v = mat.getCol(dim); - v *= (normalized ? (scaleFactor / v.norm()) : scaleFactor); + ACG::Vec3d v = mat.getCol(dim) * scaleFactor; lineNode->add_line(center_pos - v, center_pos + v); lineNode->add_color(dim_color[dim]); } @@ -125,19 +123,11 @@ visualizeAsBoxesForEntity(Property prop, EntityIterator e_begin, EntityIterator MeshT &m = *OVMPropertyVisualizer::mesh; EntityPosition ep{m}; - bool normalized = getWidget()->normalize_colors->isChecked(); for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) { const Matrix3x3d &mat = prop[*e_it]; Vec3d center_pos = ep(*e_it); - std::array dir; - for (unsigned char dim = 0; dim < 3; ++dim) { - dir[dim] = mat.getCol(dim); - if (normalized) { - dir[dim].normalize(); - } - } - boxesNode->push_back({Matrix3x3d::fromColumns(dir[0], dir[1], dir[2]), center_pos}); + boxesNode->push_back({mat, center_pos}); } boxesNode->setScaleFactor(getWidget()->getScaleFactor()); } diff --git a/Widgets/Matrix3x3Widget.ui b/Widgets/Matrix3x3Widget.ui index f168b25..e7309df 100644 --- a/Widgets/Matrix3x3Widget.ui +++ b/Widgets/Matrix3x3Widget.ui @@ -159,16 +159,6 @@ 0 - - - - Normalize - - - false - - - @@ -262,7 +252,6 @@ as_crosses as_boxes - normalize scale scaleBox vectors_edges_alpha -- GitLab From dc7420015e5fe6f5021f3632e566f830f8571362 Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Tue, 14 May 2019 16:23:24 +0200 Subject: [PATCH 5/7] fix build error and a warning --- Models/PropertyNameListModel.hh | 2 +- OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh | 2 +- OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Models/PropertyNameListModel.hh b/Models/PropertyNameListModel.hh index c2582f4..cd84af1 100644 --- a/Models/PropertyNameListModel.hh +++ b/Models/PropertyNameListModel.hh @@ -191,7 +191,7 @@ class PropertyNameListModel: public QAbstractListModel { OpenMesh::BaseProperty * const baseProp = *pit; if (!baseProp) continue; - TypeInfoWrapper bp_type = typeid(*baseProp); + TypeInfoWrapper bp_type {typeid(*baseProp)}; TYPE_INFO_SET::const_iterator sane_prop_it = sane_prop_types.find(bp_type); if ((typeIdFilter == 0 || TypeInfoWrapper(*typeIdFilter) == bp_type) && sane_prop_it != sane_prop_types.end()) { *oit++ = PROP_INFO(baseProp->name(), *sane_prop_it, entity); diff --git a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh index 25dd9e5..6a8f4ff 100644 --- a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh +++ b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3.hh @@ -90,7 +90,7 @@ private: template void visualizeForEntity(EntityIterator e_begin, EntityIterator e_end); - Matrix3x3Widget* getWidget() {return static_cast(PropertyVisualizer::widget);} + Matrix3x3Widget* getMatWidget() {return static_cast(PropertyVisualizer::widget);} }; diff --git a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh index 2d14f63..9be571a 100644 --- a/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh +++ b/OpenVolumeMesh/OVMPropertyVisualizerMatrix3x3_impl.hh @@ -100,7 +100,7 @@ visualizeAsCrossesForEntity(Property prop, EntityIterator e_begin, EntityIterato EntityPosition ep{m}; - double scaleFactor = getWidget()->getScaleFactor(); + double scaleFactor = getMatWidget()->getScaleFactor(); for (EntityIterator e_it = e_begin; e_it != e_end; ++e_it) { Matrix3x3d mat = prop[*e_it]; @@ -129,7 +129,7 @@ visualizeAsBoxesForEntity(Property prop, EntityIterator e_begin, EntityIterator Vec3d center_pos = ep(*e_it); boxesNode->push_back({mat, center_pos}); } - boxesNode->setScaleFactor(getWidget()->getScaleFactor()); + boxesNode->setScaleFactor(getMatWidget()->getScaleFactor()); } template @@ -143,9 +143,9 @@ visualizeForEntity(EntityIterator e_begin, EntityIterator e_end) if (!prop) throw VizException("Getting PropHandle from mesh for selected property failed."); - if (getWidget()->as_crosses->isChecked()) { + if (getMatWidget()->as_crosses->isChecked()) { visualizeAsCrossesForEntity(prop, e_begin, e_end); - } else if (getWidget()->as_boxes->isChecked()) { + } else if (getMatWidget()->as_boxes->isChecked()) { visualizeAsBoxesForEntity(prop, e_begin, e_end); } } -- GitLab From 1d530050eabbcfb1c31386fb2d8736909e97c10b Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Tue, 14 May 2019 17:11:43 +0200 Subject: [PATCH 6/7] Attempt to fix windows build --- Nodes/BoxesNode.hh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Nodes/BoxesNode.hh b/Nodes/BoxesNode.hh index e9b56da..30b0ce5 100644 --- a/Nodes/BoxesNode.hh +++ b/Nodes/BoxesNode.hh @@ -57,7 +57,7 @@ struct BoxElement { Vec3d pos; }; -class ACGDLLEXPORT BoxesNode : public MaterialNode +class BoxesNode : public MaterialNode { public: ACG_CLASSNAME(BoxesNode) -- GitLab From 1ed0bbec555812d69d80b1460f5d60a383e373ba Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Tue, 14 May 2019 17:23:03 +0200 Subject: [PATCH 7/7] BoxesNode: improve bounding box calculation, mention remaining issue --- Nodes/BoxesNode.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Nodes/BoxesNode.cc b/Nodes/BoxesNode.cc index eacd653..237ba2b 100644 --- a/Nodes/BoxesNode.cc +++ b/Nodes/BoxesNode.cc @@ -98,9 +98,10 @@ void BoxesNode:: boundingBox(Vec3d& _bbMin, Vec3d& _bbMax) { + // FIXME: this assumes matrices to only consist of vectors up to unit length for (const auto &be: elem_) { - _bbMax.maximize(be.pos + Vec3d(1.,1.,1.)); - _bbMin.minimize(be.pos + Vec3d(-1., -1., -1.)); + _bbMax.maximize(be.pos + Vec3d(scaleFactor_,scaleFactor_,scaleFactor_)); + _bbMin.minimize(be.pos + Vec3d(-scaleFactor_, -scaleFactor_, -scaleFactor_)); } } -- GitLab