@@ -41,57 +41,6 @@ using sofa::type::Vec3;
4141// --------------------------------------------------------------------------------------
4242// --- Computation methods
4343// --------------------------------------------------------------------------------------
44- template <class DataTypes >
45- inline bool TearingEngine<DataTypes>::computeIntersectionNeighborTriangle(Coord normalizedFractureDirection, Coord Pa, Coord& Pb, Real& t)
46- {
47- SOFA_UNUSED (Pa);
48-
49- if (m_maxStressVertexIndex == InvalidID)
50- return false ;
51-
52- // Get Geometry Algorithm
53- TriangleSetGeometryAlgorithms<DataTypes>* _triangleGeo = nullptr ;
54- this ->m_topology ->getContext ()->get (_triangleGeo);
55- if (!_triangleGeo)
56- {
57- msg_error () << " Missing component: Unable to get TriangleSetGeometryAlgorithms from the current context." ;
58- sofa::core::objectmodel::BaseObject::d_componentState.setValue (sofa::core::objectmodel::ComponentState::Invalid);
59- return false ;
60- }
61-
62-
63- Index triangle_id = _triangleGeo->getTriangleInDirection (m_maxStressVertexIndex, normalizedFractureDirection);
64- if (triangle_id > this ->m_topology ->getNbTriangles () - 1 )
65- return false ;
66-
67-
68- const Triangle& VertexIndicies = this ->m_topology ->getTriangle (triangle_id);
69-
70- constexpr size_t numVertices = 3 ;
71- Index B_id = -1 , C_id = -1 ;
72-
73- for (unsigned int vertex_id = 0 ; vertex_id < numVertices; vertex_id++)
74- {
75- if (VertexIndicies[vertex_id] == m_maxStressVertexIndex)
76- {
77- B_id = VertexIndicies[(vertex_id + 1 ) % 3 ];
78- C_id = VertexIndicies[(vertex_id + 2 ) % 3 ];
79- break ;
80- }
81-
82- }
83-
84- helper::ReadAccessor< Data<VecCoord> > x (d_input_positions);
85- Coord A = x[m_maxStressVertexIndex];
86- Coord B = x[B_id];
87- Coord C = x[C_id];
88-
89- if (rayTriangleIntersection (A, B, C, normalizedFractureDirection, t, Pb))
90- return true ;
91- else
92- return false ;
93-
94- }
9544
9645template <class DataTypes >
9746inline bool TearingEngine<DataTypes>::computeEndPointsNeighboringTriangles(const Coord& Pa, const Coord& fractureDirection, Coord& Pb, Coord& Pc)
@@ -100,22 +49,18 @@ inline bool TearingEngine<DataTypes>::computeEndPointsNeighboringTriangles(const
10049 bool t_c_ok = false ;
10150
10251 Coord dir_b = fractureDirection / fractureDirection.norm ();
103-
104- Real t_b;
105- if (computeIntersectionNeighborTriangle (dir_b,Pa, Pb, t_b))
106- t_b_ok = true ;
52+ TriangleID t_b = this ->m_tearingAlgo ->computeIntersectionNeighborTriangle (m_maxStressVertexIndex, Pa, dir_b, Pb);
10753
108-
10954 Coord dir_c = -dir_b;
110- Real t_c;
111- if (computeIntersectionNeighborTriangle (dir_c,Pa,Pc, t_c))
112- t_c_ok = true ;
55+ TriangleID t_c = this ->m_tearingAlgo ->computeIntersectionNeighborTriangle (m_maxStressVertexIndex, Pa, dir_c, Pc);
56+
11357
114- if (!(t_b_ok && t_c_ok) )
58+ if (t_b == sofa::InvalidID || t_c == sofa::InvalidID )
11559 {
11660 msg_warning () << " Not able to build the fracture path through neighboring triangles." ;
11761 return false ;
11862 }
63+
11964 return true ;
12065}
12166
@@ -172,7 +117,9 @@ void TearingEngine<DataTypes>::computeFracturePath()
172117
173118 if (this ->d_fractureMaxLength .getValue () == 0.0 )
174119 {
175- this ->computeEndPointsNeighboringTriangles (Pa, fractureDirection, Pb, Pc);
120+ bool checkEndsPoints = this ->computeEndPointsNeighboringTriangles (Pa, fractureDirection, Pb, Pc);
121+ if (!checkEndsPoints)
122+ return ;
176123 }
177124 else
178125 {
0 commit comments