Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion scenes/TearingEngine/SquareTissue_11_MiddlePressure .scn
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

<TriangleSetTopologyContainer name="Container" src="@meshLoader" />
<TriangleSetTopologyModifier name="Modifier" />
<TriangleSetGeometryAlgorithms name="GeomAlgo" template="Vec3d" showEdgeIndices="1" showTriangleIndices="1" showIndicesScale="0.001"/>
<TriangleSetGeometryAlgorithms name="GeomAlgo" template="Vec3d" showEdgeIndices="1" showTriangleIndices="1" showIndicesScale="0.001" showPointIndices="1"/>

<MechanicalObject name="Mo"/>
<DiagonalMass massDensity="0.15" />
Expand Down
73 changes: 73 additions & 0 deletions src/Tearing/TearingAlgorithms.inl
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,88 @@ TearingAlgorithms<DataTypes>::~TearingAlgorithms()
template <class DataTypes>
void TearingAlgorithms<DataTypes>::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<PointToAdd> > _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();
}
}



template <class DataTypes>
void TearingAlgorithms<DataTypes>::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;
}
}


Expand Down
Loading