ShapeRecognCylinder.med
ShapeRecognCone.med
ShapeRecognSphere.med
+ ShapeRecognTorus.med
)
SET(MED_RESOURCES_FILES ${MED_test_fig_files})
CylinderTest.cxx
ConeTest.cxx
SphereTest.cxx
+ TorusTest.cxx
)
SALOME_ACCUMULATE_ENVIRONMENT(MEDCOUPLING_RESOURCE_DIR "${CMAKE_BINARY_DIR}/resources")
#include "CylinderTest.hxx"
#include "ConeTest.hxx"
#include "SphereTest.hxx"
+#include "TorusTest.hxx"
CPPUNIT_TEST_SUITE_REGISTRATION(MEDCoupling::MathOpsTest);
CPPUNIT_TEST_SUITE_REGISTRATION(MEDCoupling::PlaneTest);
CPPUNIT_TEST_SUITE_REGISTRATION(MEDCoupling::CylinderTest);
CPPUNIT_TEST_SUITE_REGISTRATION(MEDCoupling::ConeTest);
CPPUNIT_TEST_SUITE_REGISTRATION(MEDCoupling::SphereTest);
+CPPUNIT_TEST_SUITE_REGISTRATION(MEDCoupling::TorusTest);
#include "BasicMainTest.hxx"
--- /dev/null
+#include "TorusTest.hxx"
+
+#include "ShapeRecognMesh.hxx"
+#include "Areas.hxx"
+#include "MathOps.hxx"
+#include "TestInterpKernelUtils.hxx" // getResourceFile()
+
+using namespace MEDCoupling;
+
+void TorusTest::setUp()
+{
+ std::string file = INTERP_TEST::getResourceFile("ShapeRecognTorus.med", 3);
+ srMesh = new ShapeRecognMesh(file);
+ srMesh->recognize();
+ areas = srMesh->getAreas();
+}
+
+void TorusTest::tearDown()
+{
+ if (srMesh != 0)
+ delete srMesh;
+ areas = 0;
+}
+
+void TorusTest::testArea()
+{
+ CPPUNIT_ASSERT_EQUAL(275, (int)srMesh->getNodes()->getNbNodes());
+ CPPUNIT_ASSERT_EQUAL(1, (int)areas->getNumberOfAreas());
+ CPPUNIT_ASSERT_EQUAL(PrimitiveType::Torus, areas->getPrimitiveType(0));
+ // Some nodes are unknown
+ CPPUNIT_ASSERT_EQUAL(272, (int)areas->getNumberOfNodes(0));
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.843297, areas->getMinorRadius(0), 1E-2);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.156428, areas->getRadius(0), 1E-1);
+ std::array<double, 3> centerRef = {7.687022, -3.726887, -9.02};
+ std::array<double, 3> center = areas->getCenter(0);
+ for (size_t j = 0; j < 3; ++j)
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(centerRef[j], center[j], 1E-2);
+}
--- /dev/null
+// Copyright (C) 2007-2024 CEA, EDF
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef __TORUSTEST_HXX__
+#define __TORUSTEST_HXX__
+
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace MEDCoupling
+{
+ class ShapeRecognMesh;
+ class Areas;
+
+ class TorusTest : public CppUnit::TestFixture
+ {
+ CPPUNIT_TEST_SUITE(TorusTest);
+ CPPUNIT_TEST(testArea);
+ CPPUNIT_TEST_SUITE_END();
+
+ public:
+ void setUp() override;
+ void tearDown() override;
+
+ void testArea();
+
+ private:
+ ShapeRecognMesh *srMesh = 0;
+ const Areas *areas;
+ };
+};
+
+#endif // __TORUSTEST_HXX__