Commit 5a9f7311 authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'OVMVec3dSupport' into 'master'

added support for OVM::Vec3d

See merge request !23
parents cc155c62 8b675e2b
......@@ -101,10 +101,14 @@ public:
static bool isUnsignedIntType(const TypeInfoWrapper& typeInfo);
static bool isVec3dType(const PropertyInfo& propInfo);
static bool isVec3dType(const TypeInfoWrapper& typeInfo);
static bool isVec3dOVMType(const PropertyInfo& propInfo);
static bool isVec3dOVMType(const TypeInfoWrapper& typeInfo);
static bool isVec3fType(const PropertyInfo& propInfo);
static bool isVec3fType(const TypeInfoWrapper& typeInfo);
static bool isVectorType(const PropertyInfo& propInfo);
static bool isVectorType(const TypeInfoWrapper& typeInfo);
static bool isVectorOVMType(const PropertyInfo& propInfo);
static bool isVectorOVMType(const TypeInfoWrapper& typeInfo);
static bool isMatrix3x3Type(const PropertyInfo& propInfo);
static bool isMatrix3x3Type(const TypeInfoWrapper& typeInfo);
......@@ -114,6 +118,7 @@ public:
static const TypeInfoWrapper proptype_##primitive##_uint; \
static const TypeInfoWrapper proptype_##primitive##_double; \
static const TypeInfoWrapper proptype_##primitive##_Vec3d; \
static const TypeInfoWrapper proptype_##primitive##_Vec3dOVM; \
static const TypeInfoWrapper proptype_##primitive##_Vec3f; \
static const TypeInfoWrapper proptype_##primitive##_Matrix3x3d;
......@@ -209,6 +214,8 @@ template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##prim
= TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<double>), "double"); \
template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_Vec3d \
= TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<ACG::Vec3d>), "Vec3d"); \
template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_Vec3dOVM \
= TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<OpenVolumeMesh::Vec3d>), "Vec3dOVM"); \
template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_Vec3f \
= TypeInfoWrapper(typeid(OpenVolumeMesh::primitive##PropertyT<ACG::Vec3f>), "Vec3f"); \
template <typename T> const TypeInfoWrapper OVMPropertyModel<T>::proptype_##primitive##_Matrix3x3d \
......
......@@ -458,7 +458,7 @@ bool OVMPropertyModel<MeshT>::isSupported(OpenVolumeMesh::BaseProperty* const ba
* @return True if the property type can be visualized, False if not.
*
* Currently supported are the types "bool", "int", "unsigned int", "double", "Vec3d"
* and "Vec3f"
* "Vec3dOVM" and "Vec3f"
*/
template<typename MeshT>
bool OVMPropertyModel<MeshT>::isSupported(QString friendlyName) const
......@@ -622,6 +622,23 @@ bool OVMPropertyModel<MeshT>::isVec3dType(const TypeInfoWrapper& typeInfo)
typeInfo == proptype_Vertex_Vec3d;
}
template<typename MeshT>
bool OVMPropertyModel<MeshT>::isVec3dOVMType(const PropertyInfo& propInfo)
{
return isVec3dOVMType(propInfo.typeinfo());
}
template<typename MeshT>
bool OVMPropertyModel<MeshT>::isVec3dOVMType(const TypeInfoWrapper& typeInfo)
{
return typeInfo == proptype_Cell_Vec3dOVM ||
typeInfo == proptype_Face_Vec3dOVM ||
typeInfo == proptype_HalfFace_Vec3dOVM ||
typeInfo == proptype_Edge_Vec3dOVM ||
typeInfo == proptype_HalfEdge_Vec3dOVM ||
typeInfo == proptype_Vertex_Vec3dOVM;
}
template<typename MeshT>
bool OVMPropertyModel<MeshT>::isVec3fType(const PropertyInfo& propInfo)
{
......@@ -642,7 +659,7 @@ bool OVMPropertyModel<MeshT>::isVec3fType(const TypeInfoWrapper& typeInfo)
template<typename MeshT>
bool OVMPropertyModel<MeshT>::isVectorType(const PropertyInfo& propInfo)
{
return isVec3fType(propInfo) || isVec3dType(propInfo);
return isVec3fType(propInfo) || isVec3dType(propInfo) ;
}
template<typename MeshT>
......@@ -651,6 +668,18 @@ bool OVMPropertyModel<MeshT>::isVectorType(const TypeInfoWrapper& typeInfo)
return isVec3fType(typeInfo) || isVec3dType(typeInfo);
}
template<typename MeshT>
bool OVMPropertyModel<MeshT>::isVectorOVMType(const PropertyInfo& propInfo)
{
return isVec3dOVMType(propInfo) ;
}
template<typename MeshT>
bool OVMPropertyModel<MeshT>::isVectorOVMType(const TypeInfoWrapper& typeInfo)
{
return isVec3dOVMType(typeInfo);
}
template<typename MeshT>
bool OVMPropertyModel<MeshT>::isMatrix3x3Type(const PropertyInfo& propInfo)
{
......@@ -679,6 +708,7 @@ bool OVMPropertyModel<MeshT>::isEntityType(const TypeInfoWrapper& typeInfo, Prop
|| (typeInfo == proptype_Cell_double)
|| (typeInfo == proptype_Cell_uint)
|| (typeInfo == proptype_Cell_Vec3d)
|| (typeInfo == proptype_Cell_Vec3dOVM)
|| (typeInfo == proptype_Cell_Vec3f);
}
if (entity_type & PropertyInfo::EF_FACE)
......@@ -688,6 +718,7 @@ bool OVMPropertyModel<MeshT>::isEntityType(const TypeInfoWrapper& typeInfo, Prop
|| (typeInfo == proptype_Face_double)
|| (typeInfo == proptype_Face_uint)
|| (typeInfo == proptype_Face_Vec3d)
|| (typeInfo == proptype_Face_Vec3dOVM)
|| (typeInfo == proptype_Face_Vec3f);
}
if (entity_type & PropertyInfo::EF_HALFFACE)
......@@ -697,6 +728,7 @@ bool OVMPropertyModel<MeshT>::isEntityType(const TypeInfoWrapper& typeInfo, Prop
|| (typeInfo == proptype_HalfFace_double)
|| (typeInfo == proptype_HalfFace_uint)
|| (typeInfo == proptype_HalfFace_Vec3d)
|| (typeInfo == proptype_HalfFace_Vec3dOVM)
|| (typeInfo == proptype_HalfFace_Vec3f);
}
if (entity_type & PropertyInfo::EF_EDGE)
......@@ -706,6 +738,7 @@ bool OVMPropertyModel<MeshT>::isEntityType(const TypeInfoWrapper& typeInfo, Prop
|| (typeInfo == proptype_Edge_double)
|| (typeInfo == proptype_Edge_uint)
|| (typeInfo == proptype_Edge_Vec3d)
|| (typeInfo == proptype_Edge_Vec3dOVM)
|| (typeInfo == proptype_Edge_Vec3f);
}
if (entity_type & PropertyInfo::EF_HALFEDGE)
......@@ -715,6 +748,7 @@ bool OVMPropertyModel<MeshT>::isEntityType(const TypeInfoWrapper& typeInfo, Prop
|| (typeInfo == proptype_HalfEdge_double)
|| (typeInfo == proptype_HalfEdge_uint)
|| (typeInfo == proptype_HalfEdge_Vec3d)
|| (typeInfo == proptype_HalfEdge_Vec3dOVM)
|| (typeInfo == proptype_HalfEdge_Vec3f);
}
if (entity_type & PropertyInfo::EF_VERTEX)
......@@ -724,6 +758,7 @@ bool OVMPropertyModel<MeshT>::isEntityType(const TypeInfoWrapper& typeInfo, Prop
|| (typeInfo == proptype_Vertex_double)
|| (typeInfo == proptype_Vertex_uint)
|| (typeInfo == proptype_Vertex_Vec3d)
|| (typeInfo == proptype_Vertex_Vec3dOVM)
|| (typeInfo == proptype_Vertex_Vec3f);
}
return result;
......@@ -753,7 +788,9 @@ void OVMPropertyModel<MeshT>::addPropertyVisualizer(OpenVolumeMesh::BaseProperty
else if (isDoubleType(propInfo))
propertyVisualizers.push_back(new OVMPropertyVisualizerDouble<MeshT>(mesh, objectID_, propInfo));
else if (isVectorType(propInfo))
propertyVisualizers.push_back(new OVMPropertyVisualizerVector<MeshT>(mesh, objectID_, propInfo));
propertyVisualizers.push_back(new OVMPropertyVisualizerVector<MeshT, ACG::Vec3d>(mesh, objectID_, propInfo));
else if (isVectorOVMType(propInfo))
propertyVisualizers.push_back(new OVMPropertyVisualizerVector<MeshT, OpenVolumeMesh::Vec3d>(mesh, objectID_, propInfo));
else if (isMatrix3x3Type(propInfo))
propertyVisualizers.push_back(new OVMPropertyVisualizerMatrix3x3<MeshT>(mesh, objectID_, propInfo));
connectLogs(propertyVisualizers.back());
......@@ -959,6 +996,7 @@ supportedPropertyTypes.insert(proptype_##primitive##_int); \
supportedPropertyTypes.insert(proptype_##primitive##_uint); \
supportedPropertyTypes.insert(proptype_##primitive##_double); \
supportedPropertyTypes.insert(proptype_##primitive##_Vec3d); \
supportedPropertyTypes.insert(proptype_##primitive##_Vec3dOVM); \
supportedPropertyTypes.insert(proptype_##primitive##_Vec3f); \
supportedPropertyTypes.insert(proptype_##primitive##_Matrix3x3d); \
......@@ -969,7 +1007,7 @@ supportedPropertyTypes.insert(proptype_##primitive##_Matrix3x3d); \
INSERT_PROPTYPES(HalfEdge)
INSERT_PROPTYPES(Vertex)
#undef INITIALIZE_PROPTYPES
#undef INSERT_PROPTYPES
......
......@@ -56,7 +56,7 @@
#include <iostream>
template <typename MeshT>
template <typename MeshT, typename VectorT>
class OVMPropertyVisualizerVector: public OVMPropertyVisualizer<MeshT>{
public:
......@@ -94,6 +94,8 @@ protected:
void setHalfedgePropertyFromText(unsigned int index, QString text) override;
void setVertexPropertyFromText(unsigned int index, QString text) override;
inline ACG::Vec3d convert_to_acg(const VectorT& _v) { return ACG::Vec3d(_v[0], _v[1], _v[2]);}
ACG::SceneGraph::LineNode* lineNode;
};
......
......@@ -131,6 +131,14 @@ QString PropertyVisualizer::toStr(BaseSkin::SkinWeights sw)
}
#endif
#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
QString PropertyVisualizer::toStr(OpenVolumeMesh::Vec3d v)
{
return QObject::tr("∥(%1, %2, %3)∥ = %4").arg(v[0]).arg(v[1]).arg(v[2])
.arg(v.norm());
}
#endif
OpenMesh::Vec3d PropertyVisualizer::strToVec3d (QString str)
{
......@@ -141,6 +149,7 @@ OpenMesh::Vec3d PropertyVisualizer::strToVec3d (QString str)
return OpenMesh::Vec3d(strList[0].toDouble(),strList[1].toDouble(),strList[2].toDouble());
}
OpenMesh::Vec2d PropertyVisualizer::strToVec2d (QString str)
{
QString s = str;
......
......@@ -165,6 +165,9 @@ public:
#ifdef ENABLE_SKELETON_SUPPORT
static QString toStr(BaseSkin::SkinWeights sw);
#endif
#ifdef ENABLE_POLYHEDRALMESH_SUPPORT
static QString toStr(OpenVolumeMesh::Vec3d v);
#endif
static inline bool strToBool (QString str) { return (str.compare(QObject::tr("True"))==0); }
static inline double strToDouble(QString str) { return str.toDouble() ; }
......@@ -174,6 +177,7 @@ public:
static OpenMesh::Vec2d strToVec2d (QString str);
static OpenMesh::Vec2f strToVec2f (QString str);
template <typename Vec3T> static Vec3T strToVec3 (QString str);
protected:
virtual std::unique_ptr<ACG::IColorCoder> buildColorCoder();
......@@ -198,4 +202,14 @@ void PropertyVisualizer::showHistogramT(
widget->setHistogram(ACG::create_histogram_auto(data));
}
template <typename Vec3T>
Vec3T PropertyVisualizer::strToVec3 (QString str)
{
QString s = str;
s.remove(0,2);
s.truncate(s.lastIndexOf(")"));
QStringList strList = s.split(QObject::tr(", "));
return Vec3T(strList[0].toDouble(),strList[1].toDouble(),strList[2].toDouble());
}
#endif /* PROPERTY_VISUALIZER_HH */
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment