From 1d7a2999a3f62cec9e7dcd8adadd65beafc224af Mon Sep 17 00:00:00 2001 From: epernod Date: Wed, 26 Feb 2025 01:27:21 +0100 Subject: [PATCH 1/4] Backup work on new fracture path --- src/Tearing/TearingAlgorithms.inl | 34 +++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/Tearing/TearingAlgorithms.inl b/src/Tearing/TearingAlgorithms.inl index c4fd82e..dec8d47 100644 --- a/src/Tearing/TearingAlgorithms.inl +++ b/src/Tearing/TearingAlgorithms.inl @@ -54,7 +54,41 @@ TearingAlgorithms::~TearingAlgorithms() template void TearingAlgorithms::computeFracturePath(const Coord& pA, Index triId, const Coord pB, const Coord pC) { + SReal snapThreshold = 0.8; + SReal snapThresholdBorder = 0.8; + sofa::type::vector< TriangleID > triangles_list; + sofa::type::vector< EdgeID > edges_list; + sofa::type::vector< Real > coords_list; + type::vector< std::shared_ptr > _pointsToAdd; + + type::Vec3 ptA = type::Vec3(pA[0], pA[1], pA[2]); + type::Vec3 ptB = type::Vec3(pB[0], pB[1], pB[2]); + type::Vec3 ptC = type::Vec3(pC[0], pC[1], pC[2]); + + bool validPath = m_triangleGeo->computeSegmentTriangulationIntersections(ptA, ptB, triId, sofa::InvalidID, triangles_list, edges_list, coords_list); + + sofa::type::vector< TriangleID > triangles_list2; + sofa::type::vector< EdgeID > edges_list2; + sofa::type::vector< Real > coords_list2; + bool validPath2 = m_triangleGeo->computeSegmentTriangulationIntersections(ptA, ptC, triId, sofa::InvalidID, triangles_list2, edges_list2, coords_list2); + + std::cout << "--- computeFracturePath --- " << std::endl; + std::cout << "triangles_list: " << triangles_list << std::endl; + std::cout << "edges_list: " << edges_list << " | " << coords_list << std::endl; + std::cout << "triangles_list2: " << triangles_list2 << std::endl; + std::cout << "edges_list2: " << edges_list2 << " | " << coords_list2 << std::endl; + + + TriangleID triIdB = triangles_list.back(); + TriangleID triIdC = triangles_list2.back(); + + _pointsToAdd = m_triangleGeo->computeIncisionPath(ptB, ptC, triIdB, triIdC); + + for (auto pta : _pointsToAdd) + { + pta->printValue(); + } } From e2261fd29d8af6e79809d8ecae4f150448f672a5 Mon Sep 17 00:00:00 2001 From: epernod Date: Wed, 26 Feb 2025 17:07:02 +0100 Subject: [PATCH 2/4] [src] Backup handling of new fracture path using subdividers --- .../SquareTissue_11_MiddlePressure .scn | 2 +- src/Tearing/TearingAlgorithms.inl | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn b/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn index 20da601..82e8810 100644 --- a/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn +++ b/scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn @@ -41,7 +41,7 @@ - + diff --git a/src/Tearing/TearingAlgorithms.inl b/src/Tearing/TearingAlgorithms.inl index dec8d47..21c9e50 100644 --- a/src/Tearing/TearingAlgorithms.inl +++ b/src/Tearing/TearingAlgorithms.inl @@ -96,7 +96,34 @@ void TearingAlgorithms::computeFracturePath(const Coord& pA, Index tr template void TearingAlgorithms::computeFracturePath(FracturePath& my_fracturePath) { + SReal snapThreshold = 0.8; + SReal snapThresholdBorder = 0.8; + + sofa::type::vector< TriangleID > triangles_list; + sofa::type::vector< EdgeID > edges_list; + sofa::type::vector< Real > coords_list; + bool validPath = m_triangleGeo->computeSegmentTriangulationIntersections(my_fracturePath.ptA, my_fracturePath.ptB, my_fracturePath.triIdA, sofa::InvalidID, triangles_list, edges_list, coords_list); + + sofa::type::vector< TriangleID > triangles_list2; + sofa::type::vector< EdgeID > edges_list2; + sofa::type::vector< Real > coords_list2; + bool validPath2 = m_triangleGeo->computeSegmentTriangulationIntersections(my_fracturePath.ptA, my_fracturePath.ptC, my_fracturePath.triIdA, sofa::InvalidID, triangles_list2, edges_list2, coords_list2); + std::cout << "--- computeFracturePath --- " << std::endl; + std::cout << "triangles_list: " << triangles_list << std::endl; + std::cout << "edges_list: " << edges_list << " | " << coords_list << std::endl; + std::cout << "triangles_list2: " << triangles_list2 << std::endl; + std::cout << "edges_list2: " << edges_list2 << " | " << coords_list2 << std::endl; + + my_fracturePath.triIdB = triangles_list.back(); + my_fracturePath.triIdC = triangles_list2.back(); + + my_fracturePath.pointsToAdd = m_triangleGeo->computeIncisionPath(my_fracturePath.ptB, my_fracturePath.ptC, my_fracturePath.triIdB, my_fracturePath.triIdC); + my_fracturePath.pathOk = true; + for (auto pta : my_fracturePath.pointsToAdd) + { + pta->printValue(); + } } From 391abfefebb7460a10e073b489f63906c00f96c3 Mon Sep 17 00:00:00 2001 From: epernod Date: Fri, 7 Mar 2025 11:21:13 +0100 Subject: [PATCH 3/4] [src] Backup cleaning --- src/Tearing/TearingAlgorithms.inl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Tearing/TearingAlgorithms.inl b/src/Tearing/TearingAlgorithms.inl index 21c9e50..9dcdc2c 100644 --- a/src/Tearing/TearingAlgorithms.inl +++ b/src/Tearing/TearingAlgorithms.inl @@ -96,6 +96,8 @@ void TearingAlgorithms::computeFracturePath(const Coord& pA, Index tr template void TearingAlgorithms::computeFracturePath(FracturePath& my_fracturePath) { + std::cout << "--- computeFracturePath --- " << std::endl; + std::cout << "my_fracturePath.ptA: " << my_fracturePath.ptA << " | " << my_fracturePath.triIdA << std::endl; SReal snapThreshold = 0.8; SReal snapThresholdBorder = 0.8; @@ -109,12 +111,18 @@ void TearingAlgorithms::computeFracturePath(FracturePath& my_fracture sofa::type::vector< Real > coords_list2; bool validPath2 = m_triangleGeo->computeSegmentTriangulationIntersections(my_fracturePath.ptA, my_fracturePath.ptC, my_fracturePath.triIdA, sofa::InvalidID, triangles_list2, edges_list2, coords_list2); - std::cout << "--- computeFracturePath --- " << std::endl; + std::cout << "triangles_list: " << triangles_list << std::endl; std::cout << "edges_list: " << edges_list << " | " << coords_list << std::endl; std::cout << "triangles_list2: " << triangles_list2 << std::endl; std::cout << "edges_list2: " << edges_list2 << " | " << coords_list2 << std::endl; + if (!validPath || !validPath2) { + my_fracturePath.pathOk = false; + return; + } + + std::cout << "-- computeIncisionPath -- " << std::endl; my_fracturePath.triIdB = triangles_list.back(); my_fracturePath.triIdC = triangles_list2.back(); @@ -124,6 +132,7 @@ void TearingAlgorithms::computeFracturePath(FracturePath& my_fracture { pta->printValue(); } + std::cout << "--- computeFracturePath END --- " << std::endl; } From a3e9511cc8e6b31fb22364f0be3f9fc1e27d6d01 Mon Sep 17 00:00:00 2001 From: epernod Date: Wed, 19 Mar 2025 19:28:53 +0100 Subject: [PATCH 4/4] [src] Remove logs and restore computeFracturePAth using PTA --- src/Tearing/TearingAlgorithms.inl | 41 +++++++++++++++++-------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/Tearing/TearingAlgorithms.inl b/src/Tearing/TearingAlgorithms.inl index 9dcdc2c..b265ce2 100644 --- a/src/Tearing/TearingAlgorithms.inl +++ b/src/Tearing/TearingAlgorithms.inl @@ -96,8 +96,7 @@ void TearingAlgorithms::computeFracturePath(const Coord& pA, Index tr template void TearingAlgorithms::computeFracturePath(FracturePath& my_fracturePath) { - std::cout << "--- computeFracturePath --- " << std::endl; - std::cout << "my_fracturePath.ptA: " << my_fracturePath.ptA << " | " << my_fracturePath.triIdA << std::endl; + SReal snapThreshold = 0.8; SReal snapThresholdBorder = 0.8; @@ -112,27 +111,31 @@ void TearingAlgorithms::computeFracturePath(FracturePath& my_fracture bool validPath2 = m_triangleGeo->computeSegmentTriangulationIntersections(my_fracturePath.ptA, my_fracturePath.ptC, my_fracturePath.triIdA, sofa::InvalidID, triangles_list2, edges_list2, coords_list2); - std::cout << "triangles_list: " << triangles_list << std::endl; - std::cout << "edges_list: " << edges_list << " | " << coords_list << std::endl; - std::cout << "triangles_list2: " << triangles_list2 << std::endl; - std::cout << "edges_list2: " << edges_list2 << " | " << coords_list2 << std::endl; - - if (!validPath || !validPath2) { - my_fracturePath.pathOk = false; - return; + if (validPath && validPath2) + { + my_fracturePath.triIdB = triangles_list.back(); + my_fracturePath.triIdC = triangles_list2.back(); + + my_fracturePath.pointsToAdd = m_triangleGeo->computeIncisionPath(my_fracturePath.ptB, my_fracturePath.ptC, my_fracturePath.triIdB, my_fracturePath.triIdC); + my_fracturePath.pathOk = true; + //for (auto pta : my_fracturePath.pointsToAdd) + //{ + // pta->printValue(); + //} } + else + { + my_fracturePath.pathOk = false; - std::cout << "-- computeIncisionPath -- " << std::endl; - my_fracturePath.triIdB = triangles_list.back(); - my_fracturePath.triIdC = triangles_list2.back(); + std::cout << "--- computeFracturePath --- " << std::endl; + std::cout << "my_fracturePath.ptA: " << my_fracturePath.ptA << " | " << my_fracturePath.triIdA << std::endl; + std::cout << "triangles_list: " << triangles_list << std::endl; + std::cout << "edges_list: " << edges_list << " | " << coords_list << std::endl; + std::cout << "triangles_list2: " << triangles_list2 << std::endl; + std::cout << "edges_list2: " << edges_list2 << " | " << coords_list2 << std::endl; - my_fracturePath.pointsToAdd = m_triangleGeo->computeIncisionPath(my_fracturePath.ptB, my_fracturePath.ptC, my_fracturePath.triIdB, my_fracturePath.triIdC); - my_fracturePath.pathOk = true; - for (auto pta : my_fracturePath.pointsToAdd) - { - pta->printValue(); + return; } - std::cout << "--- computeFracturePath END --- " << std::endl; }