- for (TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next()) {
- const TopoDS_Shape& aShapeFace = exp.Current();
- if(aShapeFace==NotCheckedFace)
- continue;
- const SMESHDS_SubMesh * aSubMeshDSFace = meshDS->MeshElements(aShapeFace);
- if ( aSubMeshDSFace ) {
- SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
- while ( iteratorElem->more() ) { // loop on elements on a face
- const SMDS_MeshElement* face = iteratorElem->next();
- Handle(TColgp_HSequenceOfPnt) aContour = new TColgp_HSequenceOfPnt;
- SMDS_ElemIteratorPtr nodeIt = face->nodesIterator();
- int nbN = face->NbNodes();
- if( face->IsQuadratic() )
- nbN /= 2;
- for ( int i = 0; i < nbN; ++i ) {
- const SMDS_MeshNode* node = static_cast<const SMDS_MeshNode*>( nodeIt->next() );
- aContour->Append(gp_Pnt(node->X(), node->Y(), node->Z()));
- }
- if( HasIntersection(P, PC, Pres, aContour) ) {
- res = true;
- double tmp = PC.Distance(Pres);
- if(tmp<dist) {
- Pint = Pres;
- dist = tmp;
- }
- }
+
+ gp_Ax1 line( P, gp_Vec(P,PC));
+ vector< const SMDS_MeshElement* > suspectElems;
+ searcher->GetElementsNearLine( line, SMDSAbs_Face, suspectElems);
+
+// for (TopExp_Explorer exp(aShape,TopAbs_FACE);exp.More();exp.Next()) {
+// const TopoDS_Shape& aShapeFace = exp.Current();
+// if(aShapeFace==NotCheckedFace)
+// continue;
+// const SMESHDS_SubMesh * aSubMeshDSFace = meshDS->MeshElements(aShapeFace);
+// if ( aSubMeshDSFace ) {
+// SMDS_ElemIteratorPtr iteratorElem = aSubMeshDSFace->GetElements();
+// while ( iteratorElem->more() ) { // loop on elements on a face
+// const SMDS_MeshElement* face = iteratorElem->next();
+ for ( int i = 0; i < suspectElems.size(); ++i )
+ {
+ const SMDS_MeshElement* face = suspectElems[i];
+ Handle(TColgp_HSequenceOfPnt) aContour = new TColgp_HSequenceOfPnt;
+ for ( int i = 0; i < face->NbCornerNodes(); ++i )
+ aContour->Append( SMESH_MeshEditor::TNodeXYZ( face->GetNode(i) ));
+ if( HasIntersection(P, PC, Pres, aContour) ) {
+ res = true;
+ double tmp = PC.Distance(Pres);
+ if(tmp<dist) {
+ Pint = Pres;
+ dist = tmp;