+ for ( int i = myNodes->Lower(); i <= myNodes->Upper(); ++i )
+ myBBox.Add( myNodes->Value(i).XYZ() );
+ }
+ }
+ //================================================================================
+ /*!
+ * \brief Prepare data for search of trinagles in GetMinDistInSphere()
+ */
+ //================================================================================
+
+ void TriaTreeData::PrepareToTriaSearch()
+ {
+ if ( !myTrias.empty() ) return; // already done
+ if ( !myPolyTrias ) return;
+
+ // get all boundary links and nodes on VERTEXes
+ map< NLink, Segment* > linkToSegMap;
+ map< NLink, Segment* >::iterator l2s;
+ set< int > vertexNodes;
+ TopLoc_Location loc;
+ Handle(Poly_Triangulation) tr = BRep_Tool::Triangulation( mySurface.Face(), loc );
+ if ( !tr.IsNull() )
+ {
+ TopTools_IndexedMapOfShape edgeMap;
+ TopExp::MapShapes( mySurface.Face(), TopAbs_EDGE, edgeMap );
+ for ( int iE = 1; iE <= edgeMap.Extent(); ++iE )
+ {
+ const TopoDS_Edge& edge = TopoDS::Edge( edgeMap( iE ));
+ Handle(Poly_PolygonOnTriangulation) polygon =
+ BRep_Tool::PolygonOnTriangulation( edge, tr, loc );
+ if ( polygon.IsNull() )
+ continue;
+ const TColStd_Array1OfInteger& nodes = polygon->Nodes();
+ for ( int i = nodes.Lower(); i < nodes.Upper(); ++i )
+ linkToSegMap.insert( make_pair( NLink( nodes(i), nodes(i+1)), (Segment*)0 ));
+ vertexNodes.insert( nodes( nodes.Lower()));
+ vertexNodes.insert( nodes( nodes.Upper()));
+ }
+ // fill mySegments by boundary links
+ mySegments.resize( linkToSegMap.size() );
+ int iS = 0;
+ for ( l2s = linkToSegMap.begin(); l2s != linkToSegMap.end(); ++l2s, ++iS )