Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Topology] Apply new factory registration mechanism #5012

Merged
merged 7 commits into from
Oct 4, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
6 changes: 3 additions & 3 deletions Sofa/Component/Engine/Select/tests/MeshROI_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ struct MeshROI_test : public BaseSimulationTest,
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <Node name='node'> "
" <MeshOBJLoader name='loader' filename='mesh/cube.obj'/> "
" <Mesh name='topology' src='@loader'/> "
" <MeshTopology name='topology' src='@loader'/> "
" <MeshROI template='Vec3d' name='MeshROI'/> "
" </Node> "
"</Node> " ;
Expand Down Expand Up @@ -136,7 +136,7 @@ struct MeshROI_test : public BaseSimulationTest,
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <Node name='node'> "
" <MeshOBJLoader name='loader' filename='mesh/dragon.obj'/> "
" <Mesh name='topology' src='@loader'/> "
" <MeshTopology name='topology' src='@loader'/> "
" <MeshROI template='Vec3d' name='MeshROI'/> "
" </Node> "
"</Node> " ;
Expand All @@ -157,7 +157,7 @@ struct MeshROI_test : public BaseSimulationTest,
<Node name='Root' gravity='0 0 0' time='0' animate='0' >
<Node name='node'>
<MeshOBJLoader name='loader' filename='mesh/cube.obj'/>
<Mesh name='topology' src='@loader'/>
<MeshTopology name='topology' src='@loader'/>
<MeshROI template='Vec3d' name='MeshROI' position='0. 0. 0. 2. 0. 0.' />
</Node>
</Node>
Expand Down
8 changes: 4 additions & 4 deletions Sofa/Component/Mass/tests/DiagonalMass_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class DiagonalMass_test : public BaseTest
"<?xml version='1.0'?>"
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <MechanicalObject /> "
" <RegularGrid nx='2' ny='2' nz='2' xmin='0' xmax='2' ymin='0' ymax='2' zmin='0' zmax='2' /> "
" <RegularGridTopology nx='2' ny='2' nz='2' xmin='0' xmax='2' ymin='0' ymax='2' zmin='0' zmax='2' /> "
" <HexahedronSetGeometryAlgorithms /> "
" <DiagonalMass name='m_mass'/> "
"</Node> " ;
Expand Down Expand Up @@ -188,7 +188,7 @@ class DiagonalMass_test : public BaseTest
"<?xml version='1.0'?> "
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <MechanicalObject /> "
" <RegularGrid nx='2' ny='2' nz='2' xmin='0' xmax='2' ymin='0' ymax='2' zmin='0' zmax='2' /> "
" <RegularGridTopology nx='2' ny='2' nz='2' xmin='0' xmax='2' ymin='0' ymax='2' zmin='0' zmax='2' /> "
" <HexahedronSetGeometryAlgorithms /> "
" <DiagonalMass name='m_mass' massDensity='1.0' /> "
"</Node> " ;
Expand Down Expand Up @@ -219,7 +219,7 @@ class DiagonalMass_test : public BaseTest
"<?xml version='1.0'?> "
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <MechanicalObject /> "
" <RegularGrid nx='2' ny='2' nz='2' xmin='0' xmax='2' ymin='0' ymax='2' zmin='0' zmax='2' /> "
" <RegularGridTopology nx='2' ny='2' nz='2' xmin='0' xmax='2' ymin='0' ymax='2' zmin='0' zmax='2' /> "
" <HexahedronSetGeometryAlgorithms/> "
" <DiagonalMass name='m_mass' totalMass='10'/> "
"</Node> " ;
Expand Down Expand Up @@ -249,7 +249,7 @@ class DiagonalMass_test : public BaseTest
"<?xml version='1.0'?> "
"<Node name='Root' gravity='0 0 0' time='0' animate='0' > "
" <MechanicalObject /> "
" <RegularGrid nx='2' ny='2' nz='2' xmin='0' xmax='2' ymin='0' ymax='2' zmin='0' zmax='2' /> "
" <RegularGridTopology nx='2' ny='2' nz='2' xmin='0' xmax='2' ymin='0' ymax='2' zmin='0' zmax='2' /> "
" <HexahedronSetGeometryAlgorithms /> "
" <DiagonalMass name='m_mass' massDensity='1.0' totalMass='10'/> "
"</Node> " ;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ void CubeTopology::parse(core::objectmodel::BaseObjectDescription* arg)
this->setPos(d_min.getValue()[0], d_max.getValue()[0], d_min.getValue()[1], d_max.getValue()[1], d_min.getValue()[2], d_max.getValue()[2]);
}

int CubeTopologyClass = core::RegisterObject("Surface of a cube in 3D")
.add< CubeTopology >()
;
void registerCubeTopology(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Surface of a cube in 3D.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< CubeTopology >());
}

CubeTopology::CubeTopology(int _nx, int _ny, int _nz)
: d_nx(initData(&d_nx, _nx, "nx", "x grid resolution"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -478,11 +478,11 @@ void MeshTopology::QuadUpdate::doUpdate()
using namespace sofa::defaulttype;
using core::topology::BaseMeshTopology;


int MeshTopologyClass = core::RegisterObject("Generic mesh topology")
.addAlias("Mesh")
.add< MeshTopology >()
;
void registerMeshTopology(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Generic mesh topology.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< MeshTopology >());
}

MeshTopology::MeshTopology()
: d_seqPoints(initData(&d_seqPoints, "position", "List of point positions"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,11 @@ namespace sofa::component::topology::container::constant
using namespace sofa::type;
using namespace sofa::defaulttype;

int SphereQuadTopologyClass = core::RegisterObject("Sphere topology constructed with deformed quads")
.addAlias("SphereQuad")
.add< SphereQuadTopology >()
;
void registerSphereQuadTopology(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Sphere topology constructed with deformed quads.")
.add< SphereQuadTopology >());
}

SphereQuadTopology::SphereQuadTopology(int nx, int ny, int nz)
: CubeTopology(nx, ny, nz),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,20 @@
******************************************************************************/
#include <sofa/component/topology/container/constant/init.h>
#include <sofa/core/ObjectFactory.h>
#include <sofa/helper/system/PluginManager.h>

namespace sofa::component::topology::container::constant
{


extern void registerCubeTopology(sofa::core::ObjectFactory* factory);
extern void registerMeshTopology(sofa::core::ObjectFactory* factory);
extern void registerSphereQuadTopology(sofa::core::ObjectFactory* factory);

extern "C" {
SOFA_EXPORT_DYNAMIC_LIBRARY void initExternalModule();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleName();
SOFA_EXPORT_DYNAMIC_LIBRARY const char* getModuleVersion();
SOFA_EXPORT_DYNAMIC_LIBRARY void registerObjects(sofa::core::ObjectFactory* factory);
}

void initExternalModule()
Expand All @@ -45,11 +52,21 @@ const char* getModuleVersion()
return MODULE_VERSION;
}

void registerObjects(sofa::core::ObjectFactory* factory)
{
registerCubeTopology(factory);
registerMeshTopology(factory);
registerSphereQuadTopology(factory);
}

void init()
{
static bool first = true;
if (first)
{
// make sure that this plugin is registered into the PluginManager
sofa::helper::system::PluginManager::getInstance().registerPlugin(MODULE_NAME);

first = false;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ namespace sofa::component::topology::container::dynamic
{

using namespace sofa::defaulttype;
int DynamicSparseGridGeometryAlgorithmsClass = core::RegisterObject ( "Hexahedron set geometry algorithms" )
.add< DynamicSparseGridGeometryAlgorithms<Vec3Types> > ( true ) // default template
.add< DynamicSparseGridGeometryAlgorithms<Vec2Types> >()

;
void registerDynamicSparseGridGeometryAlgorithms(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Dynamic Sparse grid geometry algorithms.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< DynamicSparseGridGeometryAlgorithms<Vec3Types> >(true) // default template
.add< DynamicSparseGridGeometryAlgorithms<Vec2Types> >());
}

template <>
int DynamicSparseGridGeometryAlgorithms<Vec2Types>::findNearestElementInRestPos(const Coord& pos, sofa::type::Vec3& baryC, Real& distance) const
Expand All @@ -43,5 +45,4 @@ int DynamicSparseGridGeometryAlgorithms<Vec2Types>::findNearestElementInRestPos(
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API DynamicSparseGridGeometryAlgorithms<Vec3Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API DynamicSparseGridGeometryAlgorithms<Vec2Types>;


} // namespace sofa::component::topology::container::dynamic
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,14 @@
namespace sofa::component::topology::container::dynamic
{

using namespace std;
using namespace sofa::type;
using namespace sofa::defaulttype;

int DynamicSparseGridTopologyContainerClass = core::RegisterObject ( "Hexahedron set topology container" )
.add< DynamicSparseGridTopologyContainer >()
;
void registerDynamicSparseGridTopologyContainer(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Dynamic Sparse grid geometry container.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< DynamicSparseGridTopologyContainer >());
}

DynamicSparseGridTopologyContainer::DynamicSparseGridTopologyContainer()
: d_resolution (initData (&d_resolution, type::Vec3i (0, 0, 0 ), "resolution", "voxel grid resolution" ) )
Expand Down Expand Up @@ -78,7 +79,7 @@ void DynamicSparseGridTopologyContainer::init()

for( unsigned int i = 0; i < iirg.size(); i++)
{
idrg2tpo.insert( make_pair( iirg[i], i ));
idrg2tpo.insert( std::make_pair( iirg[i], i ));
}

// Init values
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@
namespace sofa::component::topology::container::dynamic
{

int DynamicSparseGridTopologyModifierClass = core::RegisterObject ( "Hexahedron set topology modifier" )
.add< DynamicSparseGridTopologyModifier >();

void registerDynamicSparseGridTopologyModifier(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Dynamic Sparse grid geometry modifier.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< DynamicSparseGridTopologyModifier >());
}

void DynamicSparseGridTopologyModifier::init()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,23 @@

namespace sofa::component::topology::container::dynamic
{

using namespace sofa::defaulttype;
int EdgeSetGeometryAlgorithmsClass = core::RegisterObject("Edge set geometry algorithms")

void registerEdgeSetGeometryAlgorithms(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Edge set geometry algorithms.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< EdgeSetGeometryAlgorithms<Vec3Types> >(true) // default template
.add< EdgeSetGeometryAlgorithms<Vec2Types> >()
.add< EdgeSetGeometryAlgorithms<Vec1Types> >()
.add< EdgeSetGeometryAlgorithms<Rigid3Types> >()
.add< EdgeSetGeometryAlgorithms<Rigid2Types> >()

;
.add< EdgeSetGeometryAlgorithms<Rigid2Types> >());
}

template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API EdgeSetGeometryAlgorithms<Vec3Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API EdgeSetGeometryAlgorithms<Vec2Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API EdgeSetGeometryAlgorithms<Vec1Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API EdgeSetGeometryAlgorithms<Rigid3Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API EdgeSetGeometryAlgorithms<Rigid2Types>;


} //namespace sofa::component::topology::container::dynamic
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@
namespace sofa::component::topology::container::dynamic
{

using namespace std;
using namespace sofa::defaulttype;
int EdgeSetTopologyContainerClass = core::RegisterObject("Edge set topology container")
.add< EdgeSetTopologyContainer >()
;

void registerEdgeSetTopologyContainer(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Edge set topology container.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< EdgeSetTopologyContainer >());
}

EdgeSetTopologyContainer::EdgeSetTopologyContainer()
: PointSetTopologyContainer( )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@

namespace sofa::component::topology::container::dynamic
{
using namespace sofa::defaulttype;
int EdgeSetTopologyModifierClass = core::RegisterObject("Edge set topology modifier")
.add< EdgeSetTopologyModifier >();

using namespace std;
using namespace sofa::defaulttype;
void registerEdgeSetTopologyModifier(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Edge set topology modifier.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< EdgeSetTopologyModifier >());
}

using namespace sofa::core::topology;

void EdgeSetTopologyModifier::init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,17 @@

namespace sofa::component::topology::container::dynamic
{

using namespace sofa::defaulttype;
int HexahedronSetGeometryAlgorithmsClass = core::RegisterObject("Hexahedron set geometry algorithms")
.add< HexahedronSetGeometryAlgorithms<Vec3Types> >(true) // default template
.add< HexahedronSetGeometryAlgorithms<Vec2Types> >()

;
void registerHexahedronSetGeometryAlgorithms(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Hexahedron set geometry algorithms.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< HexahedronSetGeometryAlgorithms<Vec3Types> >(true) // default template
.add< HexahedronSetGeometryAlgorithms<Vec2Types> >());
}

template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API HexahedronSetGeometryAlgorithms<Vec3Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API HexahedronSetGeometryAlgorithms<Vec2Types>;


} //namespace sofa::component::topology::container::dynamic
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
namespace sofa::component::topology::container::dynamic
{

using namespace std;
using namespace sofa::defaulttype;
using sofa::core::topology::edgesInHexahedronArray;
using sofa::core::topology::quadsOrientationInHexahedronArray;
using sofa::core::topology::verticesInHexahedronArray;

int HexahedronSetTopologyContainerClass = core::RegisterObject("Hexahedron set topology container")
.add< HexahedronSetTopologyContainer >()
;
void registerHexahedronSetTopologyContainer(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Hexahedron set topology container.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< HexahedronSetTopologyContainer >());
}

HexahedronSetTopologyContainer::HexahedronSetTopologyContainer()
: QuadSetTopologyContainer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,13 @@

namespace sofa::component::topology::container::dynamic
{
int HexahedronSetTopologyModifierClass = core::RegisterObject("Hexahedron set topology modifier")
.add< HexahedronSetTopologyModifier >();

using namespace std;
using namespace sofa::defaulttype;
void registerHexahedronSetTopologyModifier(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Hexahedron set topology modifier.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< HexahedronSetTopologyModifier >());
}

using namespace sofa::core::topology;

void HexahedronSetTopologyModifier::init()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
namespace sofa::component::topology::container::dynamic
{

using namespace std;
using namespace sofa::type;
using namespace sofa::defaulttype;

int MultilevelHexahedronSetTopologyContainerClass = core::RegisterObject("Hexahedron set topology container")
.add< MultilevelHexahedronSetTopologyContainer >()
;
void registerMultilevelHexahedronSetTopologyContainer(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Multilevel Hexahedron set topology container.")
.add< MultilevelHexahedronSetTopologyContainer >());
}

MultilevelHexahedronSetTopologyContainer::MultilevelHexahedronSetTopologyContainer()
: HexahedronSetTopologyContainer(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@ namespace sofa::component::topology::container::dynamic
{

using namespace sofa::defaulttype;
int PointSetGeometryAlgorithmsClass = core::RegisterObject("Point set geometry algorithms")

void registerPointSetGeometryAlgorithms(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Point set geometry algorithms.")
fredroy marked this conversation as resolved.
Show resolved Hide resolved
.add< PointSetGeometryAlgorithms<Vec3Types> >(true) // default template
.add< PointSetGeometryAlgorithms<Vec2Types> >()
.add< PointSetGeometryAlgorithms<Vec1Types> >()

;
.add< PointSetGeometryAlgorithms<Vec1Types> >());
}

template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API PointSetGeometryAlgorithms<Vec3Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API PointSetGeometryAlgorithms<Vec2Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API PointSetGeometryAlgorithms<Vec1Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API PointSetGeometryAlgorithms<Rigid3Types>;
template class SOFA_COMPONENT_TOPOLOGY_CONTAINER_DYNAMIC_API PointSetGeometryAlgorithms<Rigid2Types>;


} //namespace sofa::component::topology::container::dynamic
Loading
Loading