Skip to content

Commit 4d53aa9

Browse files
committed
backup work on special cases
1 parent cbe2743 commit 4d53aa9

1 file changed

Lines changed: 11 additions & 4 deletions

File tree

Sofa/Component/Topology/Container/Dynamic/src/sofa/component/topology/container/dynamic/TriangleSetGeometryAlgorithms.inl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1992,9 +1992,15 @@ bool TriangleSetGeometryAlgorithms< DataTypes >::computeSegmentTriangulationInte
19921992
const sofa::type::Vec<3, Real> pG{ cG[0], cG[1], cG[2] };
19931993

19941994
computeSegmentTriangleIntersectionInPlane(pG, ptB, current_triID, tmp_intersectedEdges, tmp_baryCoefs);
1995-
if (tmp_intersectedEdges.size() != 1) // only one edge should be intersected to find the next edge in cut direction
1995+
if (tmp_intersectedEdges.empty()) // intersection stay inside the first triangle
1996+
{
1997+
triangles_list.push_back(current_triID);
1998+
break;
1999+
}
2000+
else if (tmp_intersectedEdges.size() != 1) // only one edge should be intersected to find the next edge in cut direction
19962001
{
19972002
msg_error() << "Impossible to determine cut direction at start due to snapping. Between input segment A: " << ptA << " - B: " << ptB << " and triangle: " << current_triID;
2003+
msg_error() << "Found tmp_intersectedEdges: " << tmp_intersectedEdges << " with barycoordinates: " << tmp_baryCoefs;
19982004
return false;
19992005
}
20002006

@@ -2015,7 +2021,7 @@ bool TriangleSetGeometryAlgorithms< DataTypes >::computeSegmentTriangulationInte
20152021
current_edgeID = intersectedEdges[nextLocalId];
20162022
}
20172023

2018-
2024+
std::cout << "Tri: " << current_triID << " |intersectedEdges.size(): " << intersectedEdges.size() << "| intersectedEdges: " << intersectedEdges << " | " << baryCoefs << std::endl;
20192025
if (intersectedEdges.size() == 2) // triangle fully traversed, look for the next edge
20202026
{
20212027
if (current_edgeID == intersectedEdges[0])
@@ -2036,6 +2042,7 @@ bool TriangleSetGeometryAlgorithms< DataTypes >::computeSegmentTriangulationInte
20362042
}
20372043
else if (intersectedEdges.size() == 3) // triangle fully traversed and going in/out through a vertex
20382044
{
2045+
20392046
// double check that one edge is the previous one and the 2 others have a baryCoef equal to 0 or 1
20402047
sofa::Index curLocalId = sofa::InvalidID;
20412048
sofa::Index localNoSnapId = sofa::InvalidID;
@@ -2101,8 +2108,8 @@ bool TriangleSetGeometryAlgorithms< DataTypes >::computeSegmentTriangulationInte
21012108
sofa::type::Vec<3, Real> p1 = { c1[0], c1[1], c1[2] };
21022109

21032110
// update pA with the intersection point on the new edge
2104-
sofa::type::Vec<3, Real> newIntersection = p0 * current_bary + p1 * (1.0 - current_bary);
2105-
current_point = current_point + (newIntersection - current_point) * 0.8; // add a small threshold to make sure point is out of next triangle
2111+
//sofa::type::Vec<3, Real> newIntersection = p0 * current_bary + p1 * (1.0 - current_bary);
2112+
//current_point = current_point + (newIntersection - current_point) * 0.8; // add a small threshold to make sure point is out of next triangle
21062113

21072114

21082115
// search for next triangle to be intersected

0 commit comments

Comments
 (0)