From 8304669ba4efae911681604a2fa90d8fe6ed03c9 Mon Sep 17 00:00:00 2001 From: Martin Heistermann Date: Sat, 13 Jan 2018 01:31:57 +0100 Subject: [PATCH] Avoid more uses of dynamic_cast. --- ObjectTypes/HexahedralMesh/PluginFunctionsHexahedralMesh.cc | 6 +++--- .../TetrahedralMesh/PluginFunctionsTetrahedralMesh.cc | 6 +++--- ObjectTypes/VolumeMeshObject/VolumeMeshObjectT.cc | 2 +- Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc | 4 ++-- Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc | 4 ++-- Plugin-TypeTetrahedralMesh/TypeTetrahedralMesh.cc | 5 +++-- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/ObjectTypes/HexahedralMesh/PluginFunctionsHexahedralMesh.cc b/ObjectTypes/HexahedralMesh/PluginFunctionsHexahedralMesh.cc index 844e73a..cc1c712 100644 --- a/ObjectTypes/HexahedralMesh/PluginFunctionsHexahedralMesh.cc +++ b/ObjectTypes/HexahedralMesh/PluginFunctionsHexahedralMesh.cc @@ -108,7 +108,7 @@ bool getObject( int _identifier, HexahedralMeshObject*& _object ) { BaseObjectData* object = 0; PluginFunctions::getObject(_identifier,object); - _object = dynamic_cast< HexahedralMeshObject* >(object); + _object = hexahedralMeshObject(object); return ( _object != 0 ); } @@ -120,7 +120,7 @@ bool getObject( int _identifier, HexahedralMeshObject*& _object ) { HexahedralMesh* hexahedralMesh( BaseObjectData* _object ) { if ( _object->dataType(DATA_HEXAHEDRAL_MESH) ) { - HexahedralMeshObject* object = dynamic_cast< HexahedralMeshObject* >(_object); + HexahedralMeshObject* object = static_cast< HexahedralMeshObject* >(_object); return object->mesh(); } else return 0; @@ -139,7 +139,7 @@ HexahedralMesh* hexahedralMesh( int _identifier ) { HexahedralMeshObject* hexahedralMeshObject( BaseObjectData* _object ) { if ( ! _object->dataType(DATA_HEXAHEDRAL_MESH) ) return 0; - return dynamic_cast< HexahedralMeshObject* >( _object ); + return static_cast< HexahedralMeshObject* >( _object ); } diff --git a/ObjectTypes/TetrahedralMesh/PluginFunctionsTetrahedralMesh.cc b/ObjectTypes/TetrahedralMesh/PluginFunctionsTetrahedralMesh.cc index a70a213..dcfa495 100644 --- a/ObjectTypes/TetrahedralMesh/PluginFunctionsTetrahedralMesh.cc +++ b/ObjectTypes/TetrahedralMesh/PluginFunctionsTetrahedralMesh.cc @@ -102,7 +102,7 @@ bool getObject( int _identifier, TetrahedralMeshObject*& _object ) { BaseObjectData* object = 0; PluginFunctions::getObject(_identifier,object); - _object = dynamic_cast< TetrahedralMeshObject* >(object); + _object = tetrahedralMeshObject(object); return ( _object != 0 ); } @@ -114,7 +114,7 @@ bool getObject( int _identifier, TetrahedralMeshObject*& _object ) { TetrahedralMesh* tetrahedralMesh( BaseObjectData* _object ) { if ( _object->dataType(DATA_TETRAHEDRAL_MESH) ) { - TetrahedralMeshObject* object = dynamic_cast< TetrahedralMeshObject* >(_object); + TetrahedralMeshObject* object = static_cast< TetrahedralMeshObject* >(_object); return object->mesh(); } else return 0; @@ -133,7 +133,7 @@ TetrahedralMesh* tetrahedralMesh( int _identifier ) { TetrahedralMeshObject* tetrahedralMeshObject( BaseObjectData* _object ) { if ( ! _object->dataType(DATA_TETRAHEDRAL_MESH) ) return 0; - return dynamic_cast< TetrahedralMeshObject* >( _object ); + return static_cast< TetrahedralMeshObject* >( _object ); } diff --git a/ObjectTypes/VolumeMeshObject/VolumeMeshObjectT.cc b/ObjectTypes/VolumeMeshObject/VolumeMeshObjectT.cc index 59c4766..b73cd88 100644 --- a/ObjectTypes/VolumeMeshObject/VolumeMeshObjectT.cc +++ b/ObjectTypes/VolumeMeshObject/VolumeMeshObjectT.cc @@ -298,7 +298,7 @@ void VolumeMeshObject::updateTopology() { template BaseObject* VolumeMeshObject::copy() { VolumeMeshObject< MeshT >* object = new VolumeMeshObject(*this); - return dynamic_cast (object); + return static_cast (object); } template diff --git a/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc b/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc index 51daa74..a9c84e5 100644 --- a/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc +++ b/Plugin-TypeHexahedralMesh/TypeHexahedralMesh.cc @@ -245,7 +245,7 @@ void TypeHexahedralMeshPlugin::switchRendering() { if(!PluginFunctions::getObject(objectId, bod)) return; - HexahedralMeshObject* hexMeshObject = dynamic_cast(bod); + HexahedralMeshObject* hexMeshObject = PluginFunctions::hexahedralMeshObject(bod); if(hexMeshObject) { hexMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked()); @@ -267,7 +267,7 @@ void TypeHexahedralMeshPlugin::setTranslucencyFactor() { if(!PluginFunctions::getObject(objectId, bod)) return; - HexahedralMeshObject* hexMeshObject = dynamic_cast(bod); + HexahedralMeshObject* hexMeshObject = PluginFunctions::hexahedralMeshObject(bod); if(hexMeshObject) { diff --git a/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc b/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc index 04a2d32..3b14a35 100644 --- a/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc +++ b/Plugin-TypePolyhedralMesh/TypePolyhedralMesh.cc @@ -208,7 +208,7 @@ void TypePolyhedralMeshPlugin::switchRendering() { if(!PluginFunctions::getObject(objectId, bod)) return; - PolyhedralMeshObject* polyMeshObject = dynamic_cast(bod); + PolyhedralMeshObject* polyMeshObject = PluginFunctions::polyhedralMeshObject(bod); if(polyMeshObject) { polyMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked()); @@ -230,7 +230,7 @@ void TypePolyhedralMeshPlugin::setTranslucencyFactor() { if(!PluginFunctions::getObject(objectId, bod)) return; - PolyhedralMeshObject* polyMeshObject = dynamic_cast(bod); + PolyhedralMeshObject* polyMeshObject = PluginFunctions::polyhedralMeshObject(bod); if(polyMeshObject) { diff --git a/Plugin-TypeTetrahedralMesh/TypeTetrahedralMesh.cc b/Plugin-TypeTetrahedralMesh/TypeTetrahedralMesh.cc index 67e9580..4426d70 100644 --- a/Plugin-TypeTetrahedralMesh/TypeTetrahedralMesh.cc +++ b/Plugin-TypeTetrahedralMesh/TypeTetrahedralMesh.cc @@ -232,7 +232,7 @@ void TypeTetrahedralMeshPlugin::switchRendering() { if(!PluginFunctions::getObject(objectId, bod)) return; - TetrahedralMeshObject* tetMeshObject = dynamic_cast(bod); + TetrahedralMeshObject* tetMeshObject = PluginFunctions::tetrahedralMeshObject(bod); if(tetMeshObject) { tetMeshObject->meshNode()->set_boundary_only(render_switch_->isChecked()); @@ -254,7 +254,8 @@ void TypeTetrahedralMeshPlugin::setTranslucencyFactor() { if(!PluginFunctions::getObject(objectId, bod)) return; - TetrahedralMeshObject* tetMeshObject = dynamic_cast(bod); + TetrahedralMeshObject* tetMeshObject = PluginFunctions::tetrahedralMeshObject(bod); + if(tetMeshObject) { -- GitLab