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 c4fd82e..b265ce2 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(); + } } @@ -62,7 +96,46 @@ 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); + + + 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 << "--- 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; + + return; + } }