Commit 97a5fb09 authored by Jan Möbius's avatar Jan Möbius
Browse files

Merge branch 'avoid_dynamic_cast' into 'master'

trust object type and avoid dynamic_cast due to cross-library RTTI trouble.

See merge request !5
parents 1df747d5 20dd7883
...@@ -108,7 +108,7 @@ bool getObject( int _identifier, HexahedralMeshObject*& _object ) { ...@@ -108,7 +108,7 @@ bool getObject( int _identifier, HexahedralMeshObject*& _object ) {
BaseObjectData* object = 0; BaseObjectData* object = 0;
PluginFunctions::getObject(_identifier,object); PluginFunctions::getObject(_identifier,object);
_object = dynamic_cast< HexahedralMeshObject* >(object); _object = object ? hexahedralMeshObject(object) : nullptr;
return ( _object != 0 ); return ( _object != 0 );
} }
...@@ -120,7 +120,7 @@ bool getObject( int _identifier, HexahedralMeshObject*& _object ) { ...@@ -120,7 +120,7 @@ bool getObject( int _identifier, HexahedralMeshObject*& _object ) {
HexahedralMesh* hexahedralMesh( BaseObjectData* _object ) { HexahedralMesh* hexahedralMesh( BaseObjectData* _object ) {
if ( _object->dataType(DATA_HEXAHEDRAL_MESH) ) { if ( _object->dataType(DATA_HEXAHEDRAL_MESH) ) {
HexahedralMeshObject* object = dynamic_cast< HexahedralMeshObject* >(_object); HexahedralMeshObject* object = static_cast< HexahedralMeshObject* >(_object);
return object->mesh(); return object->mesh();
} else } else
return 0; return 0;
...@@ -139,7 +139,7 @@ HexahedralMesh* hexahedralMesh( int _identifier ) { ...@@ -139,7 +139,7 @@ HexahedralMesh* hexahedralMesh( int _identifier ) {
HexahedralMeshObject* hexahedralMeshObject( BaseObjectData* _object ) { HexahedralMeshObject* hexahedralMeshObject( BaseObjectData* _object ) {
if ( ! _object->dataType(DATA_HEXAHEDRAL_MESH) ) if ( ! _object->dataType(DATA_HEXAHEDRAL_MESH) )
return 0; return 0;
return dynamic_cast< HexahedralMeshObject* >( _object ); return static_cast< HexahedralMeshObject* >( _object );
} }
......
...@@ -108,7 +108,7 @@ bool getObject( int _identifier, PolyhedralMeshObject*& _object ) { ...@@ -108,7 +108,7 @@ bool getObject( int _identifier, PolyhedralMeshObject*& _object ) {
BaseObjectData* object = 0; BaseObjectData* object = 0;
PluginFunctions::getObject(_identifier,object); PluginFunctions::getObject(_identifier,object);
_object = dynamic_cast< PolyhedralMeshObject* >(object); _object = object ? polyhedralMeshObject(object) : nullptr;
return ( _object != 0 ); return ( _object != 0 );
} }
...@@ -120,7 +120,7 @@ bool getObject( int _identifier, PolyhedralMeshObject*& _object ) { ...@@ -120,7 +120,7 @@ bool getObject( int _identifier, PolyhedralMeshObject*& _object ) {
PolyhedralMesh* polyhedralMesh( BaseObjectData* _object ) { PolyhedralMesh* polyhedralMesh( BaseObjectData* _object ) {
if ( _object->dataType(DATA_POLYHEDRAL_MESH) ) { if ( _object->dataType(DATA_POLYHEDRAL_MESH) ) {
PolyhedralMeshObject* object = dynamic_cast< PolyhedralMeshObject* >(_object); PolyhedralMeshObject* object = static_cast< PolyhedralMeshObject* >(_object);
return object->mesh(); return object->mesh();
} else } else
return 0; return 0;
...@@ -139,7 +139,7 @@ PolyhedralMesh* polyhedralMesh( int _identifier ) { ...@@ -139,7 +139,7 @@ PolyhedralMesh* polyhedralMesh( int _identifier ) {
PolyhedralMeshObject* polyhedralMeshObject( BaseObjectData* _object ) { PolyhedralMeshObject* polyhedralMeshObject( BaseObjectData* _object ) {
if ( ! _object->dataType(DATA_POLYHEDRAL_MESH) ) if ( ! _object->dataType(DATA_POLYHEDRAL_MESH) )
return 0; return 0;
return dynamic_cast< PolyhedralMeshObject* >( _object ); return static_cast< PolyhedralMeshObject* >( _object );
} }
......
...@@ -102,7 +102,7 @@ bool getObject( int _identifier, TetrahedralMeshObject*& _object ) { ...@@ -102,7 +102,7 @@ bool getObject( int _identifier, TetrahedralMeshObject*& _object ) {
BaseObjectData* object = 0; BaseObjectData* object = 0;
PluginFunctions::getObject(_identifier,object); PluginFunctions::getObject(_identifier,object);
_object = dynamic_cast< TetrahedralMeshObject* >(object); _object = object ? tetrahedralMeshObject(object) : nullptr;
return ( _object != 0 ); return ( _object != 0 );
} }
...@@ -114,7 +114,7 @@ bool getObject( int _identifier, TetrahedralMeshObject*& _object ) { ...@@ -114,7 +114,7 @@ bool getObject( int _identifier, TetrahedralMeshObject*& _object ) {
TetrahedralMesh* tetrahedralMesh( BaseObjectData* _object ) { TetrahedralMesh* tetrahedralMesh( BaseObjectData* _object ) {
if ( _object->dataType(DATA_TETRAHEDRAL_MESH) ) { if ( _object->dataType(DATA_TETRAHEDRAL_MESH) ) {
TetrahedralMeshObject* object = dynamic_cast< TetrahedralMeshObject* >(_object); TetrahedralMeshObject* object = static_cast< TetrahedralMeshObject* >(_object);
return object->mesh(); return object->mesh();
} else } else
return 0; return 0;
...@@ -133,7 +133,7 @@ TetrahedralMesh* tetrahedralMesh( int _identifier ) { ...@@ -133,7 +133,7 @@ TetrahedralMesh* tetrahedralMesh( int _identifier ) {
TetrahedralMeshObject* tetrahedralMeshObject( BaseObjectData* _object ) { TetrahedralMeshObject* tetrahedralMeshObject( BaseObjectData* _object ) {
if ( ! _object->dataType(DATA_TETRAHEDRAL_MESH) ) if ( ! _object->dataType(DATA_TETRAHEDRAL_MESH) )
return 0; return 0;
return dynamic_cast< TetrahedralMeshObject* >( _object ); return static_cast< TetrahedralMeshObject* >( _object );
} }
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include <ACG/GL/gl.hh> #include <ACG/GL/gl.hh>
#include <ACG/Utils/VSToolsT.hh> #include <ACG/Utils/VSToolsT.hh>
#include <vector> #include <vector>
#include <type_traits>
#include <ACG/GL/RenderObject.hh> #include <ACG/GL/RenderObject.hh>
#include <ACG/GL/VertexDeclaration.hh> #include <ACG/GL/VertexDeclaration.hh>
...@@ -208,7 +209,7 @@ DrawModes::DrawMode VolumeMeshNodeT<VolumeMeshT>::availableDrawModes() const { ...@@ -208,7 +209,7 @@ DrawModes::DrawMode VolumeMeshNodeT<VolumeMeshT>::availableDrawModes() const {
if (colorAttrib_.edge_colors_available()) if (colorAttrib_.edge_colors_available())
result |= drawModes_.edgesColoredPerEdge; result |= drawModes_.edgesColoredPerEdge;
if (dynamic_cast<const HexahedralMeshTopologyKernel*>(&mesh_) != NULL) if (std::is_base_of<HexahedralMeshTopologyKernel, VolumeMeshT>::value)
{ {
result |= drawModes_.irregularInnerEdges; result |= drawModes_.irregularInnerEdges;
result |= drawModes_.irregularOuterEdges; result |= drawModes_.irregularOuterEdges;
......
...@@ -303,7 +303,7 @@ void VolumeMeshObject<MeshT>::updateTopology() { ...@@ -303,7 +303,7 @@ void VolumeMeshObject<MeshT>::updateTopology() {
template<class MeshT> template<class MeshT>
BaseObject* VolumeMeshObject<MeshT>::copy() { BaseObject* VolumeMeshObject<MeshT>::copy() {
VolumeMeshObject< MeshT >* object = new VolumeMeshObject<MeshT>(*this); VolumeMeshObject< MeshT >* object = new VolumeMeshObject<MeshT>(*this);
return dynamic_cast<BaseObject*> (object); return static_cast<BaseObject*> (object);
} }
template<class MeshT> template<class MeshT>
......
...@@ -245,7 +245,7 @@ void TypeHexahedralMeshPlugin::switchRendering() { ...@@ -245,7 +245,7 @@ void TypeHexahedralMeshPlugin::switchRendering() {
if(!PluginFunctions::getObject(objectId, bod)) if(!PluginFunctions::getObject(objectId, bod))
return; return;
HexahedralMeshObject* hexMeshObject = dynamic_cast<HexahedralMeshObject*>(bod); HexahedralMeshObject* hexMeshObject = PluginFunctions::hexahedralMeshObject(bod);
if(hexMeshObject) { if(hexMeshObject) {
hexMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked()); hexMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked());
...@@ -267,7 +267,7 @@ void TypeHexahedralMeshPlugin::setTranslucencyFactor() { ...@@ -267,7 +267,7 @@ void TypeHexahedralMeshPlugin::setTranslucencyFactor() {
if(!PluginFunctions::getObject(objectId, bod)) if(!PluginFunctions::getObject(objectId, bod))
return; return;
HexahedralMeshObject* hexMeshObject = dynamic_cast<HexahedralMeshObject*>(bod); HexahedralMeshObject* hexMeshObject = PluginFunctions::hexahedralMeshObject(bod);
if(hexMeshObject) { if(hexMeshObject) {
......
...@@ -208,7 +208,7 @@ void TypePolyhedralMeshPlugin::switchRendering() { ...@@ -208,7 +208,7 @@ void TypePolyhedralMeshPlugin::switchRendering() {
if(!PluginFunctions::getObject(objectId, bod)) if(!PluginFunctions::getObject(objectId, bod))
return; return;
PolyhedralMeshObject* polyMeshObject = dynamic_cast<PolyhedralMeshObject*>(bod); PolyhedralMeshObject* polyMeshObject = PluginFunctions::polyhedralMeshObject(bod);
if(polyMeshObject) { if(polyMeshObject) {
polyMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked()); polyMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked());
...@@ -230,7 +230,7 @@ void TypePolyhedralMeshPlugin::setTranslucencyFactor() { ...@@ -230,7 +230,7 @@ void TypePolyhedralMeshPlugin::setTranslucencyFactor() {
if(!PluginFunctions::getObject(objectId, bod)) if(!PluginFunctions::getObject(objectId, bod))
return; return;
PolyhedralMeshObject* polyMeshObject = dynamic_cast<PolyhedralMeshObject*>(bod); PolyhedralMeshObject* polyMeshObject = PluginFunctions::polyhedralMeshObject(bod);
if(polyMeshObject) { if(polyMeshObject) {
......
...@@ -232,7 +232,7 @@ void TypeTetrahedralMeshPlugin::switchRendering() { ...@@ -232,7 +232,7 @@ void TypeTetrahedralMeshPlugin::switchRendering() {
if(!PluginFunctions::getObject(objectId, bod)) if(!PluginFunctions::getObject(objectId, bod))
return; return;
TetrahedralMeshObject* tetMeshObject = dynamic_cast<TetrahedralMeshObject*>(bod); TetrahedralMeshObject* tetMeshObject = PluginFunctions::tetrahedralMeshObject(bod);
if(tetMeshObject) { if(tetMeshObject) {
tetMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked()); tetMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked());
...@@ -254,7 +254,8 @@ void TypeTetrahedralMeshPlugin::setTranslucencyFactor() { ...@@ -254,7 +254,8 @@ void TypeTetrahedralMeshPlugin::setTranslucencyFactor() {
if(!PluginFunctions::getObject(objectId, bod)) if(!PluginFunctions::getObject(objectId, bod))
return; return;
TetrahedralMeshObject* tetMeshObject = dynamic_cast<TetrahedralMeshObject*>(bod); TetrahedralMeshObject* tetMeshObject = PluginFunctions::tetrahedralMeshObject(bod);
if(tetMeshObject) { if(tetMeshObject) {
......
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