@@ -94,17 +94,13 @@ inline bool TearingEngine<DataTypes>::computeIntersectionNeighborTriangle(Coord
9494}
9595
9696template <class DataTypes >
97- inline bool TearingEngine<DataTypes>::computeEndPointsNeighboringTriangles(Coord Pa, Coord direction , Coord& Pb, Coord& Pc)
97+ inline bool TearingEngine<DataTypes>::computeEndPointsNeighboringTriangles(const Coord& Pa, const Coord& fractureDirection , Coord& Pb, Coord& Pc)
9898{
9999 bool t_b_ok = false ;
100100 bool t_c_ok = false ;
101- // compute fracture direction perpendicular to the principal stress direction
102- Coord fractureDirection;
103- this ->computeFractureDirection (direction, fractureDirection);
104101
105- Real norm_fractureDirection = fractureDirection.norm ();
106- Coord dir_b = 1.0 / norm_fractureDirection * fractureDirection;
107-
102+ Coord dir_b = fractureDirection / fractureDirection.norm ();
103+
108104 Real t_b;
109105 if (computeIntersectionNeighborTriangle (dir_b,Pa, Pb, t_b))
110106 t_b_ok = true ;
@@ -163,33 +159,34 @@ void TearingEngine<DataTypes>::computeFracturePath()
163159 // frist clear ereything
164160 this ->clearFracturePath ();
165161
166- if (m_maxStressTriangleIndex != InvalidID) // we have triangle to start and also a vertex id
167- {
168- // Recording the endpoints of the fracture segment
169- helper::ReadAccessor< Data<VecCoord> > x (d_input_positions);
170-
171- Coord principalStressDirection = m_triangleInfoTearing[m_maxStressTriangleIndex].principalStressDirection ;
172- Coord Pa = x[m_maxStressVertexIndex];
173- Coord Pb, Pc;
162+ if (m_maxStressTriangleIndex == InvalidID) // no candidate to start fracture
163+ return ;
174164
175- if (this ->d_fractureMaxLength .getValue () == 0.0 ) {
176- computeEndPointsNeighboringTriangles (Pa, principalStressDirection, Pb, Pc);
177- }
178- else
179- {
180- this ->computeEndPoints (Pa, principalStressDirection, Pb, Pc);
181- }
165+ // Recording the endpoints of the fracture segment
166+ helper::ReadAccessor< Data<VecCoord> > x (d_input_positions);
182167
183- this ->m_fracturePath .ptA = type::Vec3 (Pa[0 ], Pa[1 ], Pa[2 ]);
184- this ->m_fracturePath .ptB = type::Vec3 (Pb[0 ], Pb[1 ], Pb[2 ]);
185- this ->m_fracturePath .ptC = type::Vec3 (Pc[0 ], Pc[1 ], Pc[2 ]);
186- this ->m_fracturePath .triIdA = m_maxStressTriangleIndex;
168+ const Coord fractureDirection = this ->computeFractureDirection (m_triangleInfoTearing[m_maxStressTriangleIndex].principalStressDirection );
187169
188- this -> m_tearingAlgo -> computeFracturePath ( this -> m_fracturePath ) ;
189- this -> m_stepCounter ++ ;
170+ const Coord Pa = x[m_maxStressVertexIndex] ;
171+ Coord Pb, Pc ;
190172
191- // this->m_tearingAlgo->computeFracturePath(Pa, m_maxStressTriangleIndex, Pb, Pc);
173+ if (this ->d_fractureMaxLength .getValue () == 0.0 )
174+ {
175+ this ->computeEndPointsNeighboringTriangles (Pa, fractureDirection, Pb, Pc);
176+ }
177+ else
178+ {
179+ this ->computeEndPoints (Pa, fractureDirection, Pb, Pc); // compute orthogonal fracture using d_fractureMaxLength
192180 }
181+
182+
183+ this ->m_fracturePath .ptA = type::Vec3 (DataTypes::getCPos (Pa));
184+ this ->m_fracturePath .ptB = type::Vec3 (DataTypes::getCPos (Pb));
185+ this ->m_fracturePath .ptC = type::Vec3 (DataTypes::getCPos (Pc));
186+ this ->m_fracturePath .triIdA = m_maxStressTriangleIndex;
187+
188+ this ->m_tearingAlgo ->computeFracturePath (this ->m_fracturePath );
189+ this ->m_stepCounter ++;
193190}
194191
195192
0 commit comments