- //=============================================================================
- /*
- * Checks if the face is encosed by the grid
- */
- bool FaceGridIntersector::IsInGrid(const Bnd_Box& gridBox)
- {
- // double x0,y0,z0, x1,y1,z1;
- // const Bnd_Box& faceBox = GetFaceBndBox();
- // faceBox.Get(x0,y0,z0, x1,y1,z1);
-
- // if ( !gridBox.IsOut( gp_Pnt( x0,y0,z0 )) &&
- // !gridBox.IsOut( gp_Pnt( x1,y1,z1 )))
- // return true;
-
- // double X0,Y0,Z0, X1,Y1,Z1;
- // gridBox.Get(X0,Y0,Z0, X1,Y1,Z1);
- // double faceP[6] = { x0,y0,z0, x1,y1,z1 };
- // double gridP[6] = { X0,Y0,Z0, X1,Y1,Z1 };
- // gp_Dir axes[3] = { gp::DX(), gp::DY(), gp::DZ() };
- // for ( int iDir = 0; iDir < 6; ++iDir )
- // {
- // if ( iDir < 3 && gridP[ iDir ] <= faceP[ iDir ] ) continue;
- // if ( iDir >= 3 && gridP[ iDir ] >= faceP[ iDir ] ) continue;
-
- // // check if the face intersects a side of a gridBox
-
- // gp_Pnt p = iDir < 3 ? gp_Pnt( X0,Y0,Z0 ) : gp_Pnt( X1,Y1,Z1 );
- // gp_Ax1 norm( p, axes[ iDir % 3 ] );
- // if ( iDir < 3 ) norm.Reverse();
-
- // gp_XYZ O = norm.Location().XYZ(), N = norm.Direction().XYZ();
-
- // TopLoc_Location loc = _face.Location();
- // Handle(Poly_Triangulation) aPoly = BRep_Tool::Triangulation(_face,loc);
- // if ( !aPoly.IsNull() )
- // {
- // if ( !loc.IsIdentity() )
- // {
- // norm.Transform( loc.Transformation().Inverted() );
- // O = norm.Location().XYZ(), N = norm.Direction().XYZ();
- // }
- // const double deflection = aPoly->Deflection();
-
- // const TColgp_Array1OfPnt& nodes = aPoly->Nodes();
- // for ( int i = nodes.Lower(); i <= nodes.Upper(); ++i )
- // if (( nodes( i ).XYZ() - O ) * N > _grid->_tol + deflection )
- // return false;
- // }
- // else
- // {
- // BRepAdaptor_Surface surf( _face );
- // double u0, u1, v0, v1, du, dv, u, v;
- // BRepTools::UVBounds( _face, u0, u1, v0, v1);
- // if ( surf.GetType() == GeomAbs_Plane ) {
- // du = u1 - u0, dv = v1 - v0;
- // }
- // else {
- // du = surf.UResolution( _grid->_minCellSize / 10. );
- // dv = surf.VResolution( _grid->_minCellSize / 10. );
- // }
- // for ( u = u0, v = v0; u <= u1 && v <= v1; u += du, v += dv )
- // {
- // gp_Pnt p = surf.Value( u, v );
- // if (( p.XYZ() - O ) * N > _grid->_tol )
- // {
- // TopAbs_State state = GetCurveFaceIntersector()->ClassifyUVPoint(gp_Pnt2d( u, v ));
- // if ( state == TopAbs_IN || state == TopAbs_ON )
- // return false;
- // }
- // }
- // }
- // }
- return true;
- }