Skip to content

Commit

Permalink
[src] Clean code, remove some comment and replace indentation
Browse files Browse the repository at this point in the history
  • Loading branch information
epernod committed Jun 6, 2024
1 parent 01c6bca commit 1218153
Show file tree
Hide file tree
Showing 5 changed files with 204 additions and 219 deletions.
32 changes: 3 additions & 29 deletions src/Tearing/BaseTearingEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ class BaseTearingEngine : public core::DataEngine
Coord principalStressDirection;
};

/// Link to be set to the topology container in the component graph
SingleLink<BaseTearingEngine<DataTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;

protected:
/// <summary>
/// put in d_triangleOverThresholdList triangle with a maxStress greater than a threshold value (d_seuilPrincipalStress)
Expand All @@ -127,35 +130,6 @@ class BaseTearingEngine : public core::DataEngine
/// @return Pb - one of the extremities of fracture
/// @return Pc - one of the extremities of fracture
virtual void computeEndPoints(Coord Pa, Coord direction, Coord& Pb, Coord& Pc);
/// <summary>
/// computes the extremities of fracture Pb and Pc on the edge of neighboring triangles
/// </summary>
/// @param Pa - the point where the fracture starts
/// @param direction - principle stress direction
/// @return Pb - one of the extremities of fracture
/// @return Pc - one of the extremities of fracture
//bool computeEndPointsNeighboringTriangles(Coord Pa, Coord direction, Coord& Pb, Coord& Pc);
/// <summary>
/// computes the extremities of the (normalized) fracture PbPa on the edge of the triangle
/// </summary>
/// @param Pa - the point where the fracture starts
/// @param normalizedFractureDirection - normalized fracture direction
/// @return Pb - one of the extremities of fracture
/// @return t - a parameter needed to calculate Pb
//bool computeIntersectionNeighborTriangle(Coord normalizedFractureDirection, Coord Pa, Coord& Pb, Real& t);
/// <summary>
/// computes the the intersection of a segment with one endpoint A with DC segment
/// </summary>
/// @param A - the point where the fracture starts
/// @param C,D - the other two vertices of the triangle
/// @param direction - normalized fracture direction
/// @return t - a parameter needed to calculate Pb
/// @return intersection - coordinate of the intersection point
//bool rayTriangleIntersection(Coord A, Coord C, Coord D, Coord direction, Real& t, Coord& intersection);


/// Link to be set to the topology container in the component graph
SingleLink<BaseTearingEngine<DataTypes>, sofa::core::topology::BaseMeshTopology, BaseLink::FLAG_STOREPATH | BaseLink::FLAG_STRONGLINK> l_topology;

/// <summary>
/// compute ignored triangle at start of the tearing algo
Expand Down
34 changes: 0 additions & 34 deletions src/Tearing/BaseTearingEngine.inl
Original file line number Diff line number Diff line change
Expand Up @@ -329,40 +329,6 @@ void BaseTearingEngine<DataTypes>::updateTriangleInformation()
}


//template <class DataTypes>
//void BaseTearingEngine<DataTypes>::algoFracturePath()
//{
// helper::ReadAccessor< Data<vector<Index>> > candidate(d_triangleIdsOverThreshold);
//
// if (candidate.empty())
// return;
//
// if (m_maxStressTriangleIndex == InvalidID) {
// msg_warning() << "m_maxStressTriangleIndex is invalid. Algo should not reach this point.";
// return;
// }
//
// helper::ReadAccessor< Data<VecCoord> > x(d_input_positions);
//
// //Calculate fracture starting point (Pa)
// int indexA = m_maxStressVertexIndex;
// Coord Pa = x[indexA];
// Coord principalStressDirection = m_triangleInfoTearing[m_maxStressTriangleIndex].principalStressDirection;
// //Calculate fracture end points (Pb and Pc)
// Coord Pb;
// Coord Pc;
//
// if (d_fractureMaxLength.getValue())
// computeEndPoints(Pa, principalStressDirection, Pb, Pc);
//
// m_tearingAlgo->algoFracturePath(Pa, indexA, Pb, Pc, m_maxStressTriangleIndex, principalStressDirection, d_input_positions.getValue());
// m_maxStressTriangleIndex = InvalidID;
//
// if (d_stepModulo.getValue() == 0) // reset to 0
// m_stepCounter = 0;
//}


template<class DataTypes>
inline void BaseTearingEngine<DataTypes>::computeFractureDirection(Coord principleStressDirection,Coord & fracture_direction)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Tearing/TearingScenarioEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@

namespace sofa::component::engine
{
using namespace sofa::defaulttype;
using namespace sofa::defaulttype;

int TearingScenarioEngineClass = core::RegisterObject("Tearing engine based on scenario.").add< TearingScenarioEngine<Vec3Types> >();
int TearingScenarioEngineClass = core::RegisterObject("Tearing engine based on scenario.").add< TearingScenarioEngine<Vec3Types> >();

template class TEARING_API TearingScenarioEngine<Vec3Types>;
template class TEARING_API TearingScenarioEngine<Vec3Types>;

}//namespace sofa::component::engine
92 changes: 56 additions & 36 deletions src/Tearing/TearingScenarioEngine.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
/*****************************************************************************
* - Copyright (C) - 2020 - InfinyTech3D - *
* *
* This file is part of the Tearing plugin for the SOFA framework. *
* *
* Commercial License Usage: *
* Licensees holding valid commercial license from InfinyTech3D may use this *
* file in accordance with the commercial license agreement provided with *
* the Software or, alternatively, in accordance with the terms contained in *
* a written agreement between you and InfinyTech3D. For further information *
* on the licensing terms and conditions, contact: [email protected] *
* *
* GNU General Public License Usage: *
* Alternatively, this file may be used under the terms of the GNU General *
* Public License version 3. The licenses are as published by the Free *
* Software Foundation and appearing in the file LICENSE.GPL3 included in *
* the packaging of this file. Please review the following information to *
* ensure the GNU General Public License requirements will be met: *
* https://www.gnu.org/licenses/gpl-3.0.html. *
* *
* Authors: see Authors.txt *
* Further information: https://infinytech3d.com *
****************************************************************************/
#pragma once

#include <Tearing/BaseTearingEngine.h>
Expand All @@ -13,57 +36,54 @@

namespace sofa::component::engine
{
using type::vector;

template <class DataTypes>
class TearingScenarioEngine : public BaseTearingEngine<DataTypes>
{
public:
using type::vector;

SOFA_CLASS(SOFA_TEMPLATE(TearingScenarioEngine, DataTypes), SOFA_TEMPLATE(BaseTearingEngine, DataTypes));
typedef typename DataTypes::Real Real;
typedef typename DataTypes::Coord Coord;
typedef typename DataTypes::VecCoord VecCoord;
using Vec3 = sofa::type::Vec3;
using VecTriangles = sofa::core::topology::BaseMeshTopology::SeqTriangles;
using Triangle = sofa::core::topology::BaseMeshTopology::Triangle;
template <class DataTypes>
class TearingScenarioEngine : public BaseTearingEngine<DataTypes>
{
public:

SOFA_CLASS(SOFA_TEMPLATE(TearingScenarioEngine, DataTypes), SOFA_TEMPLATE(BaseTearingEngine, DataTypes));
typedef typename DataTypes::Real Real;
typedef typename DataTypes::Coord Coord;
typedef typename DataTypes::VecCoord VecCoord;
using Vec3 = sofa::type::Vec3;
using VecTriangles = sofa::core::topology::BaseMeshTopology::SeqTriangles;
using Triangle = sofa::core::topology::BaseMeshTopology::Triangle;


Data<int> d_startVertexId; ///< vertex ID to start algofracture (scenario case)
Data<int> d_startTriId; ///< triangle ID to check junctions in algofracture
Data<Vec3> d_startDirection; ///< direction to start algofracture (scenario case)
Data<Real> d_startLength; ///< length of first fracture to start algofracture (scenario case)
Data<int> d_startVertexId; ///< vertex ID to start algofracture (scenario case)
Data<int> d_startTriId; ///< triangle ID to check junctions in algofracture
Data<Vec3> d_startDirection; ///< direction to start algofracture (scenario case)
Data<Real> d_startLength; ///< length of first fracture to start algofracture (scenario case)


protected:
TearingScenarioEngine();
~TearingScenarioEngine() override {}
protected:
TearingScenarioEngine();
~TearingScenarioEngine() override {}

using BaseTearingEngine<DataTypes>::addInput;
using BaseTearingEngine<DataTypes>::addInput;

public:
void init() override;
void draw(const core::visual::VisualParams* vparams) override;
public:
void init() override;
void draw(const core::visual::VisualParams* vparams) override;

protected:
protected:

void computePerpendicular(Coord dir, Coord& normal);
void algoFracturePath() override;
void computeEndPoints(Coord Pa, Coord direction, Coord& Pb, Coord& Pc) override;
void computePerpendicular(Coord dir, Coord& normal);
void algoFracturePath() override;
void computeEndPoints(Coord Pa, Coord direction, Coord& Pb, Coord& Pc) override;

/// Value to store scenario fracture path
Coord m_Pa, m_Pb, m_Pc;
/// Value to store scenario fracture path
Coord m_Pa, m_Pb, m_Pc;

bool m_fractureDone = false;
};
bool m_fractureDone = false;
};


#if !defined(SOFA_COMPONENT_ENGINE_TEARINGSCENARIOENGINE_CPP)
extern template class TEARING_API TearingScenarioEngine<defaulttype::Vec3Types>;
#endif

}//namespace sofa::component::engine




} // namespace sofa::component::engine
Loading

0 comments on commit 1218153

Please sign in to comment.