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

[Mapping] Apply new factory registration mechanism #5053

Merged
merged 4 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
2 changes: 2 additions & 0 deletions Sofa/Component/LinearSystem/tests/MappingGraph_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ TEST(MappingGraph, diamondMapping)
sofa::simulation::Node::SPtr root = simulation->createNewGraph("root");
EXPECT_EQ(root->getName(), "root");

sofa::simpleapi::importPlugin("Sofa.Component.Mapping.Linear");

const auto top = sofa::core::objectmodel::New<sofa::component::statecontainer::MechanicalObject<sofa::defaulttype::Vec3Types> >();
root->addObject(top);
top->setName("top");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,11 @@ namespace sofa::component::mapping::linear

using namespace sofa::defaulttype;

// Register in the Factory
int BarycentricMappingClass = core::RegisterObject("Mapping using barycentric coordinates of the child with respect to cells of its parent")
.add< BarycentricMapping< Vec3Types, Vec3Types > >(true)


;
void registerBarycentricMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Mapping using barycentric coordinates of the child with respect to cells of its parent.")
.add< BarycentricMapping< Vec3Types, Vec3Types > >(true));
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API BarycentricMapping< Vec3Types, Vec3Types >;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ namespace sofa::component::mapping::linear

using namespace sofa::defaulttype;

// Register in the Factory
int BarycentricMappingRigidClass = core::RegisterObject("")
.add< BarycentricMapping< Vec3Types, Rigid3Types > >()


;

void registerBarycentricMappingRigid(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Mapping using barycentric coordinates of the child with respect to cells of its parent.")
.add< BarycentricMapping< Vec3Types, Rigid3Types > >());
}

template <>
void BarycentricMapperHexahedronSetTopology<defaulttype::Vec3Types, defaulttype::Rigid3Types>::handleTopologyChange(core::topology::Topology* t)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,12 @@ namespace sofa::component::mapping::linear

using namespace defaulttype;

// Register in the Factory
int BeamLinearMappingClass = core::RegisterObject("Set the positions and velocities of points attached to a beam using linear interpolation between DOFs")

.add< BeamLinearMapping< Rigid3Types, Vec3Types > >()



;
void registerBeamLinearMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Set the positions and velocities of points attached to a beam using linear interpolation between DOFs.")
.add< BeamLinearMapping< Rigid3Types, Vec3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API BeamLinearMapping< Rigid3Types, Vec3Types >;


} // namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ namespace sofa::component::mapping::linear

using namespace sofa::defaulttype;

// Register in the Factory
int CenterOfMassMappingClass = core::RegisterObject("Set the point to the center of mass of the DOFs it is attached to")
void registerCenterOfMassMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Set the point to the center of mass of the DOFs it is attached to")
.add< CenterOfMassMapping< Rigid3Types, Vec3Types > >()
.add< CenterOfMassMapping< Rigid2Types, Vec2Types > >()
;
.add< CenterOfMassMapping< Rigid2Types, Vec2Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API CenterOfMassMapping< Rigid3Types, Vec3Types >;
template class SOFA_COMPONENT_MAPPING_LINEAR_API CenterOfMassMapping< Rigid2Types, Vec2Types >;


} // namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,12 @@ namespace sofa::component::mapping::linear

using namespace sofa::defaulttype;

// Register in the Factory
int CenterOfMassMulti2MappingClass = core::RegisterObject("Set the point to the center of mass of the DOFs it is attached to")
.add< CenterOfMassMulti2Mapping< Vec3Types, Rigid3Types, Vec3Types > >()

;
void registerCenterOfMassMulti2Mapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Set the point to the center of mass of the DOFs it is attached to.")
.add< CenterOfMassMulti2Mapping< Vec3Types, Rigid3Types, Vec3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API CenterOfMassMulti2Mapping< Vec3Types, Rigid3Types, Vec3Types >;


} // namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,16 @@ namespace sofa::component::mapping::linear

using namespace sofa::defaulttype;


// Register in the Factory
int CenterOfMassMultiMappingClass = core::RegisterObject("Set the point to the center of mass of the DOFs it is attached to")
void registerCenterOfMassMultiMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Set the point to the center of mass of the DOFs it is attached to.")
.add< CenterOfMassMultiMapping< Vec3Types, Vec3Types > >()
.add< CenterOfMassMultiMapping< Rigid3Types, Rigid3Types > >()
.add< CenterOfMassMultiMapping< Rigid3Types, Vec3Types > >()

;
.add< CenterOfMassMultiMapping< Rigid3Types, Vec3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API CenterOfMassMultiMapping< Vec3Types, Vec3Types >;
template class SOFA_COMPONENT_MAPPING_LINEAR_API CenterOfMassMultiMapping< Rigid3Types, Rigid3Types >;
template class SOFA_COMPONENT_MAPPING_LINEAR_API CenterOfMassMultiMapping< Rigid3Types, Vec3Types >;


} // namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,12 @@ namespace sofa::component::mapping::linear

using namespace defaulttype;

// Register in the Factory
int DeformableOnRigidFrameMappingClass = core::RegisterObject("Set the positions and velocities of points attached to a rigid parent")
.add< DeformableOnRigidFrameMapping< Vec3Types, Rigid3Types, Vec3Types > >()

;
void registerDeformableOnRigidFrameMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Set the positions and velocities of points attached to a rigid parent.")
.add< DeformableOnRigidFrameMapping< Vec3Types, Rigid3Types, Vec3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API DeformableOnRigidFrameMapping< Vec3Types, Rigid3Types, Vec3Types >;


} // namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -30,25 +30,20 @@ namespace sofa::component::mapping::linear
{

using namespace sofa::defaulttype;
using namespace core;
using namespace core::behavior;


// Register in the Factory
int IdentityMappingClass = core::RegisterObject("Special case of mapping where the child points are the same as the parent points")
void registerIdentityMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Special case of mapping where the child DOFs are the same as the parent ones")
.add< IdentityMapping< Vec3Types, Vec3Types > >()
.add< IdentityMapping< Vec2Types, Vec2Types > >()
.add< IdentityMapping< Vec1Types, Vec1Types > >()
.add< IdentityMapping< Vec6Types, Vec3Types > >()
.add< IdentityMapping< Vec6Types, Vec6Types > >()
.add< IdentityMapping< Rigid3Types, Rigid3Types > >()
.add< IdentityMapping< Rigid2Types, Rigid2Types > >()

// Rigid -> Vec
.add< IdentityMapping< Rigid3Types, Vec3Types > >()
.add< IdentityMapping< Rigid2Types, Vec2Types > >()

;
.add< IdentityMapping< Rigid2Types, Vec2Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API IdentityMapping< Vec3Types, Vec3Types >;
template class SOFA_COMPONENT_MAPPING_LINEAR_API IdentityMapping< Vec2Types, Vec2Types >;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,14 @@ using namespace sofa::defaulttype;
namespace sofa::component::mapping::linear
{

// Register in the Factory
int IdentityMultiMappingClass = core::RegisterObject("Concatenate several States together")
.add< IdentityMultiMapping< Vec3Types, Vec3Types > >()
.add< IdentityMultiMapping< Rigid3Types, Rigid3Types > >()

;
void registerIdentityMultiMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Concatenate several mechanical states together.")
.add< IdentityMultiMapping< Vec3Types, Vec3Types > >()
.add< IdentityMultiMapping< Rigid3Types, Rigid3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API IdentityMultiMapping< Vec3Types, Vec3Types >;
template class SOFA_COMPONENT_MAPPING_LINEAR_API IdentityMultiMapping< Rigid3Types, Rigid3Types >;


} // namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,12 @@ namespace sofa::component::mapping::linear

using namespace sofa::defaulttype;

// Register in the Factory
int HandMappingClass = core::RegisterObject("skin a model from a set of rigid lines")
.add< LineSetSkinningMapping< Rigid3Types, Vec3Types > >()


;

void registerLineSetSkinningMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Skin a model from a set of rigid lines.")
.add< LineSetSkinningMapping< Rigid3Types, Vec3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API LineSetSkinningMapping< Rigid3Types, Vec3Types >;




} //namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,12 @@ namespace sofa::component::mapping::linear

using namespace sofa::defaulttype;


int Mesh2PointMechanicalMappingClass = core::RegisterObject("Mechanical mapping between a set of mesh primitives (point, edge, triangle...) and a set of points generated by Mesh2PointTopologicalMapping")
.add< Mesh2PointMechanicalMapping< Vec3Types, Vec3Types > >()
;

void registerMesh2PointMechanicalMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Mechanical mapping between a set of mesh primitives (point, edge, triangle...) and a set of points generated by Mesh2PointTopologicalMapping.")
.add< Mesh2PointMechanicalMapping< Vec3Types, Vec3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API Mesh2PointMechanicalMapping< Vec3Types, Vec3Types >;




} //namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ using namespace sofa::component::topology::container::dynamic;
using namespace sofa::core::topology;
using type::vector;

// Register in the Factory
int Mesh2PointTopologicalMappingClass = core::RegisterObject ( "This class maps any mesh primitive (point, edge, triangle...) into a point using a relative position from the primitive" )
.add< Mesh2PointTopologicalMapping >()
;
void registerMesh2PointTopologicalMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("This class maps any mesh primitive (point, edge, triangle...) into a point using a relative position from the primitive.")
.add< Mesh2PointTopologicalMapping >());
}

// Implementation
Mesh2PointTopologicalMapping::Mesh2PointTopologicalMapping ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,11 @@ using namespace sofa::defaulttype;
using namespace sofa::component::mapping::linear;
using namespace sofa::core::topology;

// Register in the Factory
int SimpleTesselatedHexaTopologicalMappingClass = core::RegisterObject ( "Special case of mapping where HexahedronSetTopology is converted into a finer HexahedronSetTopology" )
.add< SimpleTesselatedHexaTopologicalMapping >()
;
void registerSimpleTesselatedHexaTopologicalMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Special case of mapping where HexahedronSetTopology is converted into a finer HexahedronSetTopology.")
.add< SimpleTesselatedHexaTopologicalMapping >());
}

// Implementation
SimpleTesselatedHexaTopologicalMapping::SimpleTesselatedHexaTopologicalMapping()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,23 +32,12 @@ using namespace sofa::defaulttype;
using namespace core;
using namespace core::behavior;

int SimpleTesselatedTetraMechanicalMappingClass = core::RegisterObject("Mechanical mapping between two TetrahedronSetTopologies generated by SimpleTesselatedTetraTopologicalMapping")
.add< SimpleTesselatedTetraMechanicalMapping< Vec3Types ,Vec3Types > >()



;

void registerSimpleTesselatedTetraMechanicalMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Mechanical mapping between two TetrahedronSetTopologies generated by SimpleTesselatedTetraTopologicalMapping.")
.add< SimpleTesselatedTetraMechanicalMapping< Vec3Types, Vec3Types > >());
}

template class SimpleTesselatedTetraMechanicalMapping< Vec3Types, Vec3Types >;




// Mech -> Mech

// Mech -> Mapped

// Mech -> ExtMapped

} //namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ using namespace sofa::component::topology::container::dynamic;
using namespace sofa::core::topology;
using sofa::type::fixed_array;

// Register in the Factory
int SimpleTesselatedTetraTopologicalMappingClass = core::RegisterObject ( "Special case of mapping where TetrahedronSetTopology is converted into a finer TetrahedronSetTopology" )
.add< SimpleTesselatedTetraTopologicalMapping >()
;
void registerSimpleTesselatedTetraTopologicalMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Special case of mapping where TetrahedronSetTopology is converted into a finer TetrahedronSetTopology.")
.add< SimpleTesselatedTetraTopologicalMapping >());
}

// Implementation
SimpleTesselatedTetraTopologicalMapping::SimpleTesselatedTetraTopologicalMapping ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,13 @@ namespace sofa::component::mapping::linear
{

using namespace defaulttype;
using namespace core;


// Register in the Factory
int SkinningMappingClass = core::RegisterObject("skin a model from a set of rigid dofs")

// Rigid Types
.add< SkinningMapping< Rigid3Types, Vec3Types > >()



;
void registerSkinningMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Skin a model from a set of rigid DOFs.")
.add< SkinningMapping< Rigid3Types, Vec3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API SkinningMapping< Rigid3Types, Vec3Types >;




} //namespace sofa::component::mapping::linear
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ namespace sofa::component::mapping::linear
{

using namespace sofa::defaulttype;

int SubsetMappingClass = core::RegisterObject("TODO-SubsetMappingClass")
;
void registerSubsetMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Compute a subset of input DOFs.")
.add< SubsetMapping< Vec3Types, Vec3Types > >()
.add< SubsetMapping< Vec1Types, Vec1Types > >()
.add< SubsetMapping< Rigid3Types, Rigid3Types > >()
.addAlias("SurfaceIdentityMapping")
;
.add< SubsetMapping< Rigid3Types, Rigid3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API SubsetMapping< Vec3Types, Vec3Types >;
template class SOFA_COMPONENT_MAPPING_LINEAR_API SubsetMapping< Vec1Types, Vec1Types >;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ using namespace sofa::defaulttype;
namespace sofa::component::mapping::linear
{

// Register in the Factory
int SubsetMultiMappingClass = core::RegisterObject("Compute a subset of the input MechanicalObjects according to a dof index list")
.add< SubsetMultiMapping< Vec3Types, Vec3Types > >()
.add< SubsetMultiMapping< Vec2Types, Vec2Types > >()
.add< SubsetMultiMapping< Vec1Types, Vec1Types > >()
.add< SubsetMultiMapping< Rigid3Types, Rigid3Types > >()
.add< SubsetMultiMapping< Rigid3Types, Vec3Types > >()

;
void registerSubsetMultiMapping(sofa::core::ObjectFactory* factory)
{
factory->registerObjects(core::ObjectRegistrationData("Compute a subset of the input MechanicalObjects according to a dof index list.")
.add< SubsetMultiMapping< Vec3Types, Vec3Types > >()
.add< SubsetMultiMapping< Vec2Types, Vec2Types > >()
.add< SubsetMultiMapping< Vec1Types, Vec1Types > >()
.add< SubsetMultiMapping< Rigid3Types, Rigid3Types > >()
.add< SubsetMultiMapping< Rigid3Types, Vec3Types > >());
}

template class SOFA_COMPONENT_MAPPING_LINEAR_API SubsetMultiMapping< Vec3Types, Vec3Types >;
template class SOFA_COMPONENT_MAPPING_LINEAR_API SubsetMultiMapping< Vec2Types, Vec2Types >;
Expand Down
Loading
Loading