Skip to content

Commit

Permalink
[Topology.Mapping] Edge2QuadTopologicalMapping: use States directly (s…
Browse files Browse the repository at this point in the history
…ofa-framework#4388)

* use directly states for edge2quad

* apply to example scene

* clean/format includes
  • Loading branch information
fredroy authored Dec 27, 2023
1 parent d04ef4b commit 32d5e29
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,16 @@
* Contact information: [email protected] *
******************************************************************************/
#include <sofa/component/topology/mapping/Edge2QuadTopologicalMapping.h>
#include <sofa/core/visual/VisualParams.h>

#include <sofa/core/ObjectFactory.h>

#include <sofa/component/topology/container/dynamic/QuadSetTopologyModifier.h>
#include <sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h>

#include <sofa/core/topology/TopologyChange.h>

#include <sofa/type/Vec.h>
#include <map>
#include <sofa/defaulttype/VecTypes.h>

#include <sofa/core/behavior/MechanicalState.h>

#include <cmath>

#include <sofa/defaulttype/RigidTypes.h>

#include <sofa/component/topology/container/dynamic/QuadSetTopologyModifier.h>
#include <sofa/component/topology/container/dynamic/QuadSetTopologyContainer.h>


namespace sofa::component::topology::mapping
{
Expand Down Expand Up @@ -112,8 +103,8 @@ void Edge2QuadTopologicalMapping::init()


// INITIALISATION of QUADULAR mesh from EDGE mesh :
const core::behavior::MechanicalState<Rigid3Types>* from_mstate = dynamic_cast<core::behavior::MechanicalState<Rigid3Types>*>(fromModel->getContext()->getMechanicalState());
core::behavior::MechanicalState<Vec3Types>* to_mstate = dynamic_cast<core::behavior::MechanicalState<Vec3Types>*>(toModel->getContext()->getMechanicalState());
const core::State<Rigid3Types>* from_mstate = dynamic_cast<core::State<Rigid3Types>*>(fromModel->getContext()->getState());
core::State<Vec3Types>* to_mstate = dynamic_cast<core::State<Vec3Types>*>(toModel->getContext()->getState());

if (fromModel)
{
Expand Down Expand Up @@ -299,8 +290,8 @@ void Edge2QuadTopologicalMapping::init()
}
else
{
// Check type Rigid3 of input mechanical object (required)
msg_error() << "Mechanical object associated with the input is not of type Rigid. Edge2QuadTopologicalMapping only supports Rigid3Types to Vec3Types";
// Check type Rigid3 of input state object (required)
msg_error() << "State object associated with the input is not of type Rigid. Edge2QuadTopologicalMapping only supports Rigid3Types to Vec3Types";
d_componentState.setValue(sofa::core::objectmodel::ComponentState::Invalid);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,11 @@
#pragma once

#include <sofa/component/topology/mapping/config.h>
#include <sofa/core/topology/TopologicalMapping.h>

#include <sofa/type/Vec.h>
#include <sofa/defaulttype/RigidTypes.h>
#include <map>
#include <sofa/core/topology/TopologicalMapping.h>
#include <sofa/core/State.h>

#include <sofa/core/BaseMapping.h>
#include <sofa/core/behavior/MechanicalState.h>


namespace sofa::component::topology::container::dynamic
Expand All @@ -54,10 +51,7 @@ class SOFA_COMPONENT_TOPOLOGY_MAPPING_API Edge2QuadTopologicalMapping : public s
{
public:
SOFA_CLASS(Edge2QuadTopologicalMapping,sofa::core::topology::TopologicalMapping);

using RigidCoord = sofa::core::State<defaulttype::Rigid3Types>::Coord;
using Vec3Coord = sofa::core::State<defaulttype::Vec3Types>::Coord;


using Index = sofa::core::topology::BaseMeshTopology::Index;
using Edge = sofa::core::topology::BaseMeshTopology::Edge;
using Quad = sofa::core::topology::BaseMeshTopology::Quad;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,13 @@


<Node name="VisuBeam" activated="true">
<MechanicalObject template="Vec3" name="SurfDof" />
<OglModel template="Vec3" name="SurfDof" color="0.7 0.7 0.7" />
<QuadSetTopologyContainer name="Container" />
<QuadSetTopologyModifier name="Modifier" />
<QuadSetGeometryAlgorithms name="GeomAlgo" template="Vec3" drawQuads="1"/>
<Edge2QuadTopologicalMapping nbPointsOnEachCircle="10" radius="2" input="@../MeshLines" output="@Container" flipNormals="true"/>
<TubularMapping nbPointsOnEachCircle="10" radius="2" input="@../BeamDof" output="@SurfDof" />

<Node name="VisuOgl" activated="true">
<OglModel name="Visual" color="0.7 0.7 0.7" />
<IdentityMapping input="@../SurfDof" output="@Visual"/>
</Node>
</Node>
</Node>
</Node>
Expand Down

0 comments on commit 32d5e29

Please sign in to comment.