bool operator==(const MCConstAuto& other) const { return _ptr==other._ptr; }
bool operator==(const T *other) const { return _ptr==other; }
MCConstAuto &operator=(const MCConstAuto& other) { if(_ptr!=other._ptr) { destroyPtr(); referPtr(other._ptr); } return *this; }
+ MCConstAuto &operator=(const typename MEDCoupling::MCAuto<T>& other) { if(_ptr!=(const T*)other) { destroyPtr(); referPtr((const T*)other); } return *this; }
MCConstAuto &operator=(const T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; } return *this; }
void takeRef(const T *ptr) { if(_ptr!=ptr) { destroyPtr(); _ptr=ptr; if(_ptr) _ptr->incrRef(); } }
const T *operator->() { return _ptr ; }
${MEDFILE_INCLUDE_DIRS}
${HDF5_INCLUDE_DIRS}
${LAPACKE_INCLUDE_DIRS}
- ${CMAKE_CURRENT_SOURCE_DIR}/../MEDLoader
${CMAKE_CURRENT_SOURCE_DIR}/../MEDCoupling
${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL
${CMAKE_CURRENT_SOURCE_DIR}/../INTERP_KERNEL/Bases
ADD_LIBRARY(shaperecogn ${shaperecogn_SOURCES})
SET_TARGET_PROPERTIES(shaperecogn PROPERTIES COMPILE_FLAGS "")
-TARGET_LINK_LIBRARIES(shaperecogn medcouplingcpp medloader ${MEDFILE_C_LIBRARIES} ${HDF5_LIBRARIES} ${LAPACK_LIBRARIES})
+TARGET_LINK_LIBRARIES(shaperecogn medcouplingcpp ${LAPACK_LIBRARIES})
INSTALL(TARGETS shaperecogn EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${MEDCOUPLING_INSTALL_LIBS})
FILE(GLOB shaperecogn_HEADERS_HXX "${CMAKE_CURRENT_SOURCE_DIR}/*.hxx")
>>
>> shape_recogn_builder = sr.ShapeRecognMeshBuilder("resources/ShapeRecognCone.med")
>> shape_recogn = shape_recogn_builder.recognize()
->> shape_recogn.save("ShapeRecognCone_areas.med")
+>> #shape_recogn.save("ShapeRecognCone_areas.med")
```
### Without output file
#include "ShapeRecognMesh.hxx"
-#include "MEDLoader.hxx"
-
using namespace MEDCoupling;
ShapeRecognMesh::ShapeRecognMesh()
- : nodeK1(0), nodeK2(0), nodePrimitiveType(0),
- nodeNormal(0), areaId(0), areaPrimitiveType(0),
- areaNormal(0), minorRadius(0), radius(0),
- angle(0), center(0), axis(0), apex(0)
+ : nodeK1(nullptr), nodeK2(nullptr), nodePrimitiveType(nullptr),
+ nodeNormal(nullptr), areaId(nullptr), areaPrimitiveType(nullptr),
+ areaNormal(nullptr), minorRadius(nullptr), radius(nullptr),
+ angle(nullptr), center(nullptr), axis(nullptr), apex(nullptr)
{
}
return new ShapeRecognMesh;
}
-void ShapeRecognMesh::save(const std::string &outputFile, bool writeFromScratch) const
-{
- // Nodes
- // - k1
- WriteField(outputFile, nodeK1, writeFromScratch);
- // - k2
- WriteField(outputFile, nodeK2, false);
- // - primitive types
- WriteField(outputFile, nodePrimitiveType, false);
- // - Normal
- WriteField(outputFile, nodeNormal, false);
- // Areas
- // - Area Id
- WriteField(outputFile, areaId, false);
- // - Primitive Types
- WriteField(outputFile, areaPrimitiveType, false);
- // - Normal
- WriteField(outputFile, areaNormal, false);
- // - Minor Radius
- WriteField(outputFile, minorRadius, false);
- // - Radius
- WriteField(outputFile, radius, false);
- // - Angle
- WriteField(outputFile, angle, false);
- // - Center
- WriteField(outputFile, center, false);
- // - Axis
- WriteField(outputFile, axis, false);
- // - Apex
- WriteField(outputFile, apex, false);
-}
-
const MEDCouplingFieldDouble *ShapeRecognMesh::getNodeK1() const
{
return nodeK1;
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
- void save(const std::string &outputFile, bool writeFromScratch = true) const;
-
// Node properties
const MEDCouplingFieldDouble *getNodeK1() const;
const MEDCouplingFieldDouble *getNodeK2() const;
#include "NodesBuilder.hxx"
#include "AreasBuilder.hxx"
-#include "MEDLoader.hxx"
#include "ShapeRecognMesh.hxx"
#include "MEDCouplingFieldDouble.hxx"
using namespace MEDCoupling;
-ShapeRecognMeshBuilder::ShapeRecognMeshBuilder(const std::string &fileName, int meshDimRelToMax)
+ShapeRecognMeshBuilder::ShapeRecognMeshBuilder(MCAuto< MEDCouplingUMesh > mesh)
{
- mesh = ReadUMeshFromFile(fileName, meshDimRelToMax);
+ this->mesh = mesh;
if (mesh->getMeshDimension() != 2)
throw INTERP_KERNEL::Exception("Expect a mesh with a dimension equal to 2");
if (mesh->getNumberOfCellsWithType(INTERP_KERNEL::NORM_TRI3) != mesh->getNumberOfCells())
class ShapeRecognMeshBuilder
{
public:
- ShapeRecognMeshBuilder(const std::string &fileName, int meshDimRelToMax = 0);
+ ShapeRecognMeshBuilder(MCAuto< MEDCouplingUMesh > mesh);
~ShapeRecognMeshBuilder() = default;
const Nodes *getNodes() const;
SET(TestShapeRecogn_SOURCES
TestShapeRecogn.cxx
MathOpsTest.cxx
+ ShapeRecognTest.cxx
PlaneTest.cxx
CylinderTest.cxx
ConeTest.cxx
SALOME_GENERATE_TESTS_ENVIRONMENT(tests_env)
ADD_EXECUTABLE(TestShapeRecogn ${TestShapeRecogn_SOURCES})
-TARGET_LINK_LIBRARIES(TestShapeRecogn shaperecogn InterpKernelTestUtils ${CPPUNIT_LIBRARIES} ${PLATFORM_LIBS})
+TARGET_LINK_LIBRARIES(TestShapeRecogn shaperecogn InterpKernelTestUtils medloader ${MEDFILE_C_LIBRARIES} ${HDF5_LIBRARIES} ${CPPUNIT_LIBRARIES} ${PLATFORM_LIBS})
INSTALL(TARGETS TestShapeRecogn DESTINATION ${MEDCOUPLING_INSTALL_BINS})
#include "MathOps.hxx"
#include "TestInterpKernelUtils.hxx" // getResourceFile()
+#include "ShapeRecognTest.hxx"
+
using namespace MEDCoupling;
void ConeTest::setUp()
{
std::string file = INTERP_TEST::getResourceFile("ShapeRecognCone.med", 3);
- srMesh.reset( new ShapeRecognMeshBuilder(file) );
+ srMesh = BuildShapeRecognMeshBuilderFromFile(file);
srMesh->recognize();
areas = srMesh->getAreas();
}
#include "MathOps.hxx"
#include "TestInterpKernelUtils.hxx" // getResourceFile()
+#include "ShapeRecognTest.hxx"
+
using namespace MEDCoupling;
void CylinderTest::setUp()
{
std::string file = INTERP_TEST::getResourceFile("ShapeRecognCylinder.med", 3);
- srMesh.reset( new ShapeRecognMeshBuilder(file) );
+ srMesh = BuildShapeRecognMeshBuilderFromFile(file);
srMesh->recognize();
areas = srMesh->getAreas();
}
#include "MathOps.hxx"
#include "TestInterpKernelUtils.hxx" // getResourceFile()
+#include "ShapeRecognTest.hxx"
+
using namespace MEDCoupling;
void PlaneTest::setUp()
{
std::string file = INTERP_TEST::getResourceFile("ShapeRecognPlane.med", 3);
- srMesh.reset( new ShapeRecognMeshBuilder(file) );
+ srMesh = BuildShapeRecognMeshBuilderFromFile(file);
srMesh->recognize();
areas = srMesh->getAreas();
}
#include <cppunit/extensions/HelperMacros.h>
#include "ShapeRecognMeshBuilder.hxx"
+#include "ShapeRecognTest.hxx"
#include <memory>
--- /dev/null
+// Copyright (C) 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
+//
+
+#include "ShapeRecognTest.hxx"
+
+#include "MEDLoader.hxx"
+
+std::unique_ptr<MEDCoupling::ShapeRecognMeshBuilder> BuildShapeRecognMeshBuilderFromFile(const std::string& fileName, int meshDimRelToMax)
+{
+ MEDCoupling::MCAuto<MEDCoupling::MEDCouplingUMesh> mesh = MEDCoupling::ReadUMeshFromFile(fileName, 0);
+ return std::make_unique<MEDCoupling::ShapeRecognMeshBuilder>(mesh);
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 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
+//
+
+#pragma once
+
+#include "ShapeRecognMeshBuilder.hxx"
+
+#include <string>
+#include <memory>
+
+std::unique_ptr<MEDCoupling::ShapeRecognMeshBuilder> BuildShapeRecognMeshBuilderFromFile(const std::string& fileName, int meshDimRelToMax = 0);
#include "MathOps.hxx"
#include "TestInterpKernelUtils.hxx" // getResourceFile()
+#include "ShapeRecognTest.hxx"
+
using namespace MEDCoupling;
void SphereTest::setUp()
{
std::string file = INTERP_TEST::getResourceFile("ShapeRecognSphere.med", 3);
- srMesh.reset( new ShapeRecognMeshBuilder(file) );
+ srMesh = BuildShapeRecognMeshBuilderFromFile(file);
srMesh->recognize();
areas = srMesh->getAreas();
}
#include "TestInterpKernelUtils.hxx" // getResourceFile()
#include "ShapeRecognMesh.hxx"
+#include "ShapeRecognTest.hxx"
+
using namespace MEDCoupling;
void TorusTest::setUp()
{
std::string file = INTERP_TEST::getResourceFile("ShapeRecognTorus.med", 3);
- srMesh.reset( new ShapeRecognMeshBuilder(file) );
+ srMesh = BuildShapeRecognMeshBuilderFromFile(file);
srMesh->recognize();
areas = srMesh->getAreas();
}