diff --git a/Sofa/Component/Topology/Mapping/src/sofa/component/topology/mapping/Hexa2TetraTopologicalMapping.cpp b/Sofa/Component/Topology/Mapping/src/sofa/component/topology/mapping/Hexa2TetraTopologicalMapping.cpp index 28e13d64e9b..e42d04d76a0 100644 --- a/Sofa/Component/Topology/Mapping/src/sofa/component/topology/mapping/Hexa2TetraTopologicalMapping.cpp +++ b/Sofa/Component/Topology/Mapping/src/sofa/component/topology/mapping/Hexa2TetraTopologicalMapping.cpp @@ -68,34 +68,17 @@ void Hexa2TetraTopologicalMapping::init() Inherit1::init(); - if (!this->checkTopologyInputTypes()) // method will display error message if false + if (toModel == nullptr) { - this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); - return; - } - - TetrahedronSetTopologyModifier* to_tstm { nullptr }; - toModel->getContext()->get(to_tstm); - if (!to_tstm) - { - msg_error() << "No TetrahedronSetTopologyModifier found in the Tetrahedron topology Node."; + msg_error() << "No target topology container found."; this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); return; } // INITIALISATION of TETRAHEDRAL mesh from HEXAHEDRAL mesh : - TetrahedronSetTopologyContainer *to_tstc { nullptr }; - toModel->getContext()->get(to_tstc); - if (!to_tstc) - { - msg_error() << "No TetrahedronSetTopologyContainer found in the Tetrahedron topology Node."; - this->d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid); - return; - } - // Clear output topology - to_tstc->clear(); + toModel->clear(); // Set the same number of points toModel->setNbPoints(fromModel->getNbPoints()); @@ -165,21 +148,21 @@ void Hexa2TetraTopologicalMapping::init() if(!swapped) { - to_tstc->addTetra(c[0],c[5],c[1],c[6]); - to_tstc->addTetra(c[0],c[1],c[3],c[6]); - to_tstc->addTetra(c[1],c[3],c[6],c[2]); - to_tstc->addTetra(c[6],c[3],c[0],c[7]); - to_tstc->addTetra(c[6],c[7],c[0],c[5]); - to_tstc->addTetra(c[7],c[5],c[4],c[0]); + toModel->addTetra(c[0],c[5],c[1],c[6]); + toModel->addTetra(c[0],c[1],c[3],c[6]); + toModel->addTetra(c[1],c[3],c[6],c[2]); + toModel->addTetra(c[6],c[3],c[0],c[7]); + toModel->addTetra(c[6],c[7],c[0],c[5]); + toModel->addTetra(c[7],c[5],c[4],c[0]); } else { - to_tstc->addTetra(c[0],c[5],c[6],c[1]); - to_tstc->addTetra(c[0],c[1],c[6],c[3]); - to_tstc->addTetra(c[1],c[3],c[2],c[6]); - to_tstc->addTetra(c[6],c[3],c[7],c[0]); - to_tstc->addTetra(c[6],c[7],c[5],c[0]); - to_tstc->addTetra(c[7],c[5],c[0],c[4]); + toModel->addTetra(c[0],c[5],c[6],c[1]); + toModel->addTetra(c[0],c[1],c[6],c[3]); + toModel->addTetra(c[1],c[3],c[2],c[6]); + toModel->addTetra(c[6],c[3],c[7],c[0]); + toModel->addTetra(c[6],c[7],c[5],c[0]); + toModel->addTetra(c[7],c[5],c[0],c[4]); } for (int j = 0; j < numberTetraInHexa; j++) { diff --git a/examples/Component/SolidMechanics/FEM/TetrahedronHyperelasticityFEMForceField.scn b/examples/Component/SolidMechanics/FEM/TetrahedronHyperelasticityFEMForceField.scn index 278dcc80140..fa3fdef7756 100644 --- a/examples/Component/SolidMechanics/FEM/TetrahedronHyperelasticityFEMForceField.scn +++ b/examples/Component/SolidMechanics/FEM/TetrahedronHyperelasticityFEMForceField.scn @@ -51,9 +51,7 @@ - - - + @@ -75,9 +73,7 @@ - - - + @@ -100,9 +96,7 @@ - - - + @@ -125,9 +119,7 @@ - - - + @@ -149,9 +141,7 @@ - - - +