Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions Sofa/Component/Engine/Generate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ set(HEADER_FILES
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/NormalsFromPoints.inl
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/RandomPointDistributionInSurface.h
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/RandomPointDistributionInSurface.inl
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/VolumeFromTetrahedrons.h
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/VolumeFromTetrahedrons.inl
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/VolumeFromVolumetricElements.h
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/VolumeFromVolumetricElements.inl
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/VolumeFromTriangles.h
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/VolumeFromTriangles.inl
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/Spiral.h
Expand Down Expand Up @@ -72,15 +72,26 @@ set(SOURCE_FILES
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/NormEngine.cpp
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/NormalsFromPoints.cpp
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/RandomPointDistributionInSurface.cpp
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/VolumeFromTetrahedrons.cpp
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/VolumeFromVolumetricElements.cpp
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/VolumeFromTriangles.cpp
${SOFACOMPONENTENGINEGENERATE_SOURCE_DIR}/Spiral.cpp
)

set(DEPRECATED_DIR "compat/sofa/component/engine/generate")
set(DEPRECATED_HEADER_FILES
${DEPRECATED_DIR}/VolumeFromTetrahedrons.h
${DEPRECATED_DIR}/VolumeFromTetrahedrons.inl
)


sofa_find_package(Sofa.Simulation.Core REQUIRED)

add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} PUBLIC Sofa.Simulation.Core)
target_include_directories(${PROJECT_NAME} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/compat>
$<INSTALL_INTERFACE:include/${PROJECT_NAME}_compat>
)

sofa_create_package_with_targets(
PACKAGE_NAME ${PROJECT_NAME}
Expand All @@ -90,6 +101,8 @@ sofa_create_package_with_targets(
INCLUDE_INSTALL_DIR "${PROJECT_NAME}"
)

install(DIRECTORY compat/ DESTINATION include/${PROJECT_NAME}_compat COMPONENT headers)

# Tests
# If SOFA_BUILD_TESTS exists and is OFF, then these tests will be auto-disabled
cmake_dependent_option(SOFA_COMPONENT_ENGINE_GENERATE_BUILD_TESTS "Compile the automatic tests" ON "SOFA_BUILD_TESTS OR NOT DEFINED SOFA_BUILD_TESTS" OFF)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program 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 program 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 program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once
#include <sofa/component/engine/generate/VolumeFromVolumetricElements.h>
SOFA_HEADER_DEPRECATED("v26.12", "v27.06", "sofa/component/engine/generate/VolumeFromVolumetricElements.h")

namespace sofa::component::engine::generate
{

template <class DataTypes>
using VolumeFromTetrahedrons SOFA_ATTRIBUTE_DEPRECATED__VOLUMEFROMTETRAHEDRONS() = VolumeFromVolumetricElements<DataTypes>;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/******************************************************************************
* SOFA, Simulation Open-Framework Architecture *
* (c) 2006 INRIA, USTL, UJF, CNRS, MGH *
* *
* This program 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 program 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 program. If not, see <http://www.gnu.org/licenses/>. *
*******************************************************************************
* Authors: The SOFA Team and external contributors (see Authors.txt) *
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#pragma once
#include <sofa/component/engine/generate/VolumeFromTetrahedrons.h>
#include <sofa/component/engine/generate/VolumeFromVolumetricElements.inl>
SOFA_HEADER_DEPRECATED("v26.12", "v27.06", "sofa/component/engine/generate/VolumeFromVolumetricElements.inl")
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
* *
* Contact information: contact@sofa-framework.org *
******************************************************************************/
#define SOFA_COMPONENT_ENGINE_VOLUMEFROMTETRAHEDRONS_CPP
#define SOFA_COMPONENT_ENGINE_VOLUMEFROMVOLUMETRICELEMENTS_CPP

#include <sofa/component/engine/generate/VolumeFromTetrahedrons.inl>
#include <sofa/component/engine/generate/VolumeFromVolumetricElements.inl>
#include <sofa/core/ObjectFactory.h>

namespace sofa::component::engine::generate
Expand All @@ -30,13 +30,13 @@ namespace sofa::component::engine::generate
using namespace sofa::defaulttype;
using namespace sofa::helper;

void registerVolumeFromTetrahedrons(sofa::core::ObjectFactory* factory)
void registerVolumeFromVolumetricElements(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(sofa::core::ObjectRegistrationData("This component computes the volume of a given volumetric mesh.")
.add< VolumeFromTetrahedrons<Vec3Types> >(true));
.add< VolumeFromVolumetricElements<Vec3Types> >(true));
}

template class SOFA_COMPONENT_ENGINE_GENERATE_API VolumeFromTetrahedrons<Vec3Types>;
template class SOFA_COMPONENT_ENGINE_GENERATE_API VolumeFromVolumetricElements<Vec3Types>;


} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ namespace sofa::component::engine::generate
* This class returns the volumes of a given volumic mesh.
*/
template <class DataTypes>
class VolumeFromTetrahedrons : public sofa::core::DataEngine
class VolumeFromVolumetricElements : public sofa::core::DataEngine
{
public:
SOFA_CLASS(SOFA_TEMPLATE(VolumeFromTetrahedrons,DataTypes), sofa::core::DataEngine);
SOFA_CLASS(SOFA_TEMPLATE(VolumeFromVolumetricElements,DataTypes), sofa::core::DataEngine);

typedef typename DataTypes::VecCoord VecCoord;

Expand All @@ -54,8 +54,8 @@ class VolumeFromTetrahedrons : public sofa::core::DataEngine

public:

VolumeFromTetrahedrons();
~VolumeFromTetrahedrons() override;
VolumeFromVolumetricElements();
~VolumeFromVolumetricElements() override;

////////////////////////// Inherited from BaseObject ///////////////////
void init() override;
Expand All @@ -71,8 +71,8 @@ class VolumeFromTetrahedrons : public sofa::core::DataEngine

protected:

SingleLink<VolumeFromTetrahedrons<DataTypes>, BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;
SingleLink<VolumeFromTetrahedrons<DataTypes>, MechanicalState, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_state;
SingleLink<VolumeFromVolumetricElements<DataTypes>, BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;
SingleLink<VolumeFromVolumetricElements<DataTypes>, MechanicalState, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_state;

sofa::Data<VecCoord> d_positions;
sofa::Data<VecTetras> d_tetras;
Expand All @@ -89,8 +89,8 @@ class VolumeFromTetrahedrons : public sofa::core::DataEngine
void checkTopology();
};

#if !defined(SOFA_COMPONENT_ENGINE_VOLUMEFROMTETRAHEDRONS_CPP)
extern template class VolumeFromTetrahedrons<sofa::defaulttype::Vec3Types>;
#if !defined(SOFA_COMPONENT_ENGINE_VOLUMEFROMVOLUMETRICELEMENTS_CPP)
extern template class VolumeFromVolumetricElements<sofa::defaulttype::Vec3Types>;
#endif

} // namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#pragma once

#include <sofa/config.h>
#include <sofa/component/engine/generate/VolumeFromTetrahedrons.h>
#include <sofa/component/engine/generate/VolumeFromVolumetricElements.h>
#include <sofa/geometry/Hexahedron.h>
#include <sofa/geometry/Tetrahedron.h>

Expand All @@ -37,7 +37,7 @@ using sofa::core::objectmodel::BaseData;


template <class DataTypes>
VolumeFromTetrahedrons<DataTypes>::VolumeFromTetrahedrons()
VolumeFromVolumetricElements<DataTypes>::VolumeFromVolumetricElements()
:
l_topology(initLink("topology", "link to the topology"))
, l_state(initLink("mechanical", "link to the mechanical"))
Expand All @@ -51,7 +51,7 @@ VolumeFromTetrahedrons<DataTypes>::VolumeFromTetrahedrons()
}

template <class DataTypes>
void VolumeFromTetrahedrons<DataTypes>::parse(core::objectmodel::BaseObjectDescription* arg)
void VolumeFromVolumetricElements<DataTypes>::parse(core::objectmodel::BaseObjectDescription* arg)
{
Inherit1::parse(arg);

Expand All @@ -63,13 +63,13 @@ void VolumeFromTetrahedrons<DataTypes>::parse(core::objectmodel::BaseObjectDescr
}

template <class DataTypes>
VolumeFromTetrahedrons<DataTypes>::~VolumeFromTetrahedrons()
VolumeFromVolumetricElements<DataTypes>::~VolumeFromVolumetricElements()
{
}


template <class DataTypes>
void VolumeFromTetrahedrons<DataTypes>::init()
void VolumeFromVolumetricElements<DataTypes>::init()
{
Inherit1::init();

Expand Down Expand Up @@ -107,7 +107,7 @@ void VolumeFromTetrahedrons<DataTypes>::init()


template <class DataTypes>
void VolumeFromTetrahedrons<DataTypes>::reinit()
void VolumeFromVolumetricElements<DataTypes>::reinit()
{
if(d_componentState.getValue() != ComponentState::Valid)
return ;
Expand All @@ -117,7 +117,7 @@ void VolumeFromTetrahedrons<DataTypes>::reinit()


template <class DataTypes>
void VolumeFromTetrahedrons<DataTypes>::initTopology()
void VolumeFromVolumetricElements<DataTypes>::initTopology()
{
if (!l_topology.get())
{
Expand Down Expand Up @@ -145,7 +145,7 @@ void VolumeFromTetrahedrons<DataTypes>::initTopology()


template <class DataTypes>
void VolumeFromTetrahedrons<DataTypes>::checkTopology()
void VolumeFromVolumetricElements<DataTypes>::checkTopology()
{
ReadAccessor<sofa::Data<VecCoord> > positions = d_positions;
ReadAccessor<sofa::Data<VecTetras> > tetras = d_tetras;
Expand Down Expand Up @@ -194,7 +194,7 @@ void VolumeFromTetrahedrons<DataTypes>::checkTopology()


template <class DataTypes>
void VolumeFromTetrahedrons<DataTypes>::doUpdate()
void VolumeFromVolumetricElements<DataTypes>::doUpdate()
{
if(d_componentState.getValue() != ComponentState::Valid)
return ;
Expand All @@ -210,7 +210,7 @@ void VolumeFromTetrahedrons<DataTypes>::doUpdate()


template <class DataTypes>
void VolumeFromTetrahedrons<DataTypes>::updateVolume()
void VolumeFromVolumetricElements<DataTypes>::updateVolume()
{
Real volume = 0.;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,11 @@ namespace sofa::component::engine::generate
constexpr const char* MODULE_NAME = "@PROJECT_NAME@";
constexpr const char* MODULE_VERSION = "@PROJECT_VERSION@";
} // namespace sofa::component::engine::generate


#ifdef SOFA_BUILD_SOFA_COMPONENT_ENGINE_GENERATE
#define SOFA_ATTRIBUTE_DEPRECATED__VOLUMEFROMTETRAHEDRONS()
#else
#define SOFA_ATTRIBUTE_DEPRECATED__VOLUMEFROMTETRAHEDRONS() \
SOFA_ATTRIBUTE_DEPRECATED("v26.12", "v27.06", "Use the VolumeFromVolumetricElements instead")
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ extern void registerNormEngine(sofa::core::ObjectFactory* factory);
extern void registerRandomPointDistributionInSurface(sofa::core::ObjectFactory* factory);
extern void registerSpiral(sofa::core::ObjectFactory* factory);
extern void registerVolumeFromTriangles(sofa::core::ObjectFactory* factory);
extern void registerVolumeFromTetrahedrons(sofa::core::ObjectFactory* factory);
extern void registerVolumeFromVolumetricElements(sofa::core::ObjectFactory* factory);

extern "C" {
SOFA_EXPORT_DYNAMIC_LIBRARY void initExternalModule();
Expand Down Expand Up @@ -94,7 +94,7 @@ void registerObjects(sofa::core::ObjectFactory* factory)
registerRandomPointDistributionInSurface(factory);
registerSpiral(factory);
registerVolumeFromTriangles(factory);
registerVolumeFromTetrahedrons(factory);
registerVolumeFromVolumetricElements(factory);
}

void init()
Expand Down
2 changes: 1 addition & 1 deletion Sofa/Component/Engine/Generate/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ set(SOURCE_FILES
MergePoints_test.cpp
RandomPointDistributionInSurface_test.cpp
VolumeFromTriangles_test.cpp
VolumeFromTetrahedrons_test.cpp
VolumeFromVolumetricElements_test.cpp
)

find_package(Sofa.Component.StateContainer REQUIRED)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ using sofa::component::statecontainer::MechanicalObject ;
using sofa::core::topology::BaseMeshTopology ;
using sofa::core::objectmodel::Data ;

#include <sofa/component/engine/generate/VolumeFromTetrahedrons.h>
using sofa::component::engine::generate::VolumeFromTetrahedrons ;
#include <sofa/component/engine/generate/VolumeFromVolumetricElements.h>
using sofa::component::engine::generate::VolumeFromVolumetricElements ;

#include <sofa/helper/system/FileRepository.h>
using sofa::helper::system::DataRepository;
Expand All @@ -60,9 +60,9 @@ namespace sofa
{

template <typename _DataTypes>
struct VolumeFromTetrahedronsTest : public sofa::testing::BaseTest, VolumeFromTetrahedrons<_DataTypes>
struct VolumeFromVolumetricElementsTest : public sofa::testing::BaseTest, VolumeFromVolumetricElements<_DataTypes>
{
typedef VolumeFromTetrahedrons<_DataTypes> ThisClass ;
typedef VolumeFromVolumetricElements<_DataTypes> ThisClass ;
typedef _DataTypes DataTypes;
typedef typename DataTypes::Coord Coord;
typedef typename DataTypes::VecCoord VecCoord;
Expand All @@ -76,9 +76,9 @@ struct VolumeFromTetrahedronsTest : public sofa::testing::BaseTest, VolumeFromTe
///////////////////////////////////////////////////////////////
// Bring parents members in the current lookup context.
// more info at: https://gcc.gnu.org/onlinedocs/gcc/Name-lookup.html
using VolumeFromTetrahedrons<_DataTypes>::d_volume ;
using VolumeFromTetrahedrons<_DataTypes>::d_tetras ;
using VolumeFromTetrahedrons<_DataTypes>::d_hexas ;
using VolumeFromVolumetricElements<_DataTypes>::d_volume ;
using VolumeFromVolumetricElements<_DataTypes>::d_tetras ;
using VolumeFromVolumetricElements<_DataTypes>::d_hexas ;
///////////////////////////////////////////////////////////////


Expand Down Expand Up @@ -111,7 +111,7 @@ struct VolumeFromTetrahedronsTest : public sofa::testing::BaseTest, VolumeFromTe
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 0 0' time='0' animate='0'> "
" <MechanicalObject/> "
" <VolumeFromTetrahedrons/> "
" <VolumeFromVolumetricElements/> "
"</Node> " ;
EXPECT_NO_THROW(SceneLoaderXML::loadFromMemory ( "test", scene.c_str())) ;
}
Expand Down Expand Up @@ -139,18 +139,18 @@ struct VolumeFromTetrahedronsTest : public sofa::testing::BaseTest, VolumeFromTe
using ::testing::Types;
typedef Types<Vec3Types> DataTypes;

TYPED_TEST_SUITE(VolumeFromTetrahedronsTest, DataTypes);
TYPED_TEST_SUITE(VolumeFromVolumetricElementsTest, DataTypes);


TYPED_TEST(VolumeFromTetrahedronsTest, NormalBehavior) {
TYPED_TEST(VolumeFromVolumetricElementsTest, NormalBehavior) {
ASSERT_NO_THROW(this->normalTests()) ;
}

TYPED_TEST(VolumeFromTetrahedronsTest, SimpleScene) {
TYPED_TEST(VolumeFromVolumetricElementsTest, SimpleScene) {
ASSERT_NO_THROW(this->simpleSceneTest()) ;
}

TYPED_TEST(VolumeFromTetrahedronsTest, VolumeComputation) {
TYPED_TEST(VolumeFromVolumetricElementsTest, VolumeComputation) {
ASSERT_DOUBLE_EQ(12.5,this->volumeComputationTest());
}
}
4 changes: 2 additions & 2 deletions examples/Component/Engine/Generate/VolumeFromTetrahedrons.scn

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are at renaming, I would suggest to rename this example like VolumeFromVolumetricElements_Tetrahedra. scn or something like that, to keep the (unwritten?) convention: name of scene = name of the component

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<Node name="root" gravity="0 0 0" dt="1" >
<RequiredPlugin pluginName="Sofa.Component.Engine.Generate"/> <!-- Needed to use components [VolumeFromTetrahedrons] -->
<RequiredPlugin pluginName="Sofa.Component.Engine.Generate"/> <!-- Needed to use components [VolumeFromVolumetricElements] -->
<RequiredPlugin pluginName="Sofa.Component.IO.Mesh"/> <!-- Needed to use components [MeshVTKLoader] -->
<RequiredPlugin pluginName="Sofa.Component.Setting"/> <!-- Needed to use components [BackgroundSetting] -->
<RequiredPlugin pluginName="Sofa.Component.StateContainer"/> <!-- Needed to use components [MechanicalObject] -->
Expand All @@ -14,7 +14,7 @@
<MeshVTKLoader name="mesh" filename="mesh/Bunny.vtk"/>
<MeshTopology src="@mesh" name="topology"/>
<MechanicalObject />
<VolumeFromTetrahedrons/>
<VolumeFromVolumetricElements/>
<Node name="Visual" >
<OglModel src="@../topology" color="0.5 0.5 0.5 0.1"/>
</Node>
Expand Down
Loading