diff --git a/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn b/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn
index 814e03e..20da601 100644
--- a/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn
+++ b/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn
@@ -39,9 +39,9 @@
-
+
-
+
@@ -51,15 +51,15 @@
-
+
-
+
diff --git a/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn.qglviewer.view b/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn.qglviewer.view
index c0ee5b3..80c5b28 100644
--- a/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn.qglviewer.view
+++ b/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn.qglviewer.view
@@ -1,2 +1,2 @@
-2.39377 7.2768 19.272
+5.18732 3.91825 1.3
-0.0438528 -0.046858 0.00673547 0.997916
diff --git a/src/Tearing/BaseTearingEngine.inl b/src/Tearing/BaseTearingEngine.inl
index eccb860..b404c99 100644
--- a/src/Tearing/BaseTearingEngine.inl
+++ b/src/Tearing/BaseTearingEngine.inl
@@ -162,7 +162,7 @@ void BaseTearingEngine::doUpdate()
if (sofa::core::objectmodel::BaseObject::d_componentState.getValue() != sofa::core::objectmodel::ComponentState::Valid)
return;
- m_stepCounter++;
+
if (d_ignoreTriangles.getValue())
{
@@ -215,7 +215,6 @@ void BaseTearingEngine::triangleOverThresholdPrincipalStress()
candidate.clear();
maxStress = 0;
helper::WriteAccessor< Data> >triangleToSkip(d_trianglesToIgnore);
-
m_maxStressTriangleIndex = InvalidID;
for (unsigned int i = 0; i < triangleList.size(); i++)
{
@@ -639,6 +638,9 @@ void BaseTearingEngine::handleEvent(sofa::core::objectmodel::Event* e
return; // We only launch computation at end of a simulation step
}
+ if (m_tearingAlgo->getFractureNumber() > d_nbFractureMax.getValue())
+ return;
+
computeFracturePath();
// Hack: we access one output value to force the engine to call doUpdate()
@@ -647,14 +649,9 @@ void BaseTearingEngine::handleEvent(sofa::core::objectmodel::Event* e
// Perform fracture every d_stepModulo
int step = d_stepModulo.getValue();
- if (step == 0) // interactive version
- {
- if (m_stepCounter > 200 && (m_tearingAlgo->getFractureNumber() < d_nbFractureMax.getValue())){
- algoFracturePath();
- }
- }
- else if (((m_stepCounter % step) == 0) && (m_tearingAlgo->getFractureNumber() < d_nbFractureMax.getValue()))
+ if (m_stepCounter > step)
{
+ m_stepCounter = 0;
algoFracturePath();
}
}
diff --git a/src/Tearing/TearingAlgorithms.h b/src/Tearing/TearingAlgorithms.h
index 5fd775f..fdcda41 100644
--- a/src/Tearing/TearingAlgorithms.h
+++ b/src/Tearing/TearingAlgorithms.h
@@ -29,6 +29,7 @@
#include
#include
+
namespace sofa::component
{
using sofa::component::topology::container::dynamic::TriangleSetTopologyModifier;
@@ -46,6 +47,7 @@ class TearingAlgorithms
using Edge = sofa::core::topology::BaseMeshTopology::Edge;
using Triangle = sofa::core::topology::BaseMeshTopology::Triangle;
using VecIds = sofa::type::vector;
+
TearingAlgorithms(sofa::core::topology::BaseMeshTopology* _topology,
TriangleSetTopologyModifier* _modifier,
@@ -53,7 +55,6 @@ class TearingAlgorithms
virtual ~TearingAlgorithms();
-
///
/// compute fracture path intersection point and cut through them
///
@@ -158,6 +159,7 @@ class TearingAlgorithms
/// path created by algoFracturePath
sofa::type::vector m_fracturePath;
+
};
diff --git a/src/Tearing/TearingAlgorithms.inl b/src/Tearing/TearingAlgorithms.inl
index 6000a98..f5673a7 100644
--- a/src/Tearing/TearingAlgorithms.inl
+++ b/src/Tearing/TearingAlgorithms.inl
@@ -24,6 +24,7 @@
#pragma once
#include
+
namespace sofa::component
{
diff --git a/src/Tearing/TearingEngine.inl b/src/Tearing/TearingEngine.inl
index de1a724..cd2f619 100644
--- a/src/Tearing/TearingEngine.inl
+++ b/src/Tearing/TearingEngine.inl
@@ -96,14 +96,12 @@ inline bool TearingEngine::computeIntersectionNeighborTriangle(Coord
template
inline bool TearingEngine::computeEndPointsNeighboringTriangles(Coord Pa, Coord direction, Coord& Pb, Coord& Pc)
{
-
bool t_b_ok = false;
bool t_c_ok = false;
//compute fracture direction perpendicular to the principal stress direction
Coord fractureDirection;
this->computeFractureDirection(direction, fractureDirection);
-
Real norm_fractureDirection = fractureDirection.norm();
Coord dir_b = 1.0 / norm_fractureDirection * fractureDirection;
@@ -151,12 +149,6 @@ void TearingEngine::algoFracturePath()
Coord Pb;
Coord Pc;
- if (this->d_fractureMaxLength.getValue())
- this->computeEndPoints(Pa, principalStressDirection, Pb, Pc);
- else if (!(computeEndPointsNeighboringTriangles(Pa, principalStressDirection, Pb, Pc)))
- return;
-
-
this->m_tearingAlgo->algoFracturePath(Pa, indexA, Pb, Pc, m_maxStressTriangleIndex, principalStressDirection, d_input_positions.getValue());
m_maxStressTriangleIndex = InvalidID;
@@ -168,7 +160,7 @@ void TearingEngine::algoFracturePath()
template
void TearingEngine::computeFracturePath()
{
- if (!this->d_fractureMaxLength.getValue() && m_maxStressTriangleIndex != InvalidID)
+ if (m_maxStressTriangleIndex != InvalidID)
{
//Recording the endpoints of the fracture segment
helper::ReadAccessor< Data > x(d_input_positions);
@@ -179,11 +171,20 @@ void TearingEngine::computeFracturePath()
Coord Pb, Pc;
fractureSegmentEndpoints.clear();
- if (computeEndPointsNeighboringTriangles(Pa, principalStressDirection, Pb, Pc))
+ if (this->d_fractureMaxLength.getValue() == 0.0) {
+ computeEndPointsNeighboringTriangles(Pa, principalStressDirection, Pb, Pc);
+ }
+ else
{
- fractureSegmentEndpoints.push_back(Pb);
- fractureSegmentEndpoints.push_back(Pc);
+ this->computeEndPoints(Pa, principalStressDirection, Pb, Pc);
}
+
+ fractureSegmentEndpoints.push_back(Pb);
+ fractureSegmentEndpoints.push_back(Pc);
+
+ this->m_stepCounter++;
+
+ //this->m_tearingAlgo->computeFracturePath(Pa, m_maxStressTriangleIndex, Pb, Pc);
}
}