类BRepClass_FaceClassifier(它的基类是 BRepClass_FClassifier )提供有构造方法,提供一个ToppDS_Face F和一个该三维正则曲面上的点P(或者一个gp_Pnt2d通过u,v坐标指定的三维点),通过State() 返回值判断点是在边界上TopAbs_ON,在F里面TopAbs_IN,在F外TopAbs_OUT,如果点在F边界上,Edge()还返回该点所在的边。
它的实现经过review后分布在src/brepclass和src/topclass中,会用到很多2d line和2dcurve求交计算,调试时有intana2d intres2d geom2dint intcurve目录中实现代码的这类连续的调用堆栈。
基本上是平面射线法求和轮廓的交点,但是轮廓是有向的,轮廓边的left side right side是指示了轮廓的in side或者out side,可以通过沿着射线靠近P的最近交点和最近轮廓边判断点是否在polygon2d的in或者out,传统平面算法的通过射线交点总数的奇偶判断点在多边形里面,是由于polygon并没有要求保证手相性,即轮廓edge并没有指示哪边是in side,但是边界表达法的是拓扑上精确的,可以通过edge知道哪边是inside。
由于拓扑学上正则参数曲面F(u,v)和他的参数平面u-v是同胚的,它可以理解为像CGAL一样u-v参数平面点P,正则参数曲面的边界Loop在u-v参数平面对应的平面多边形Polygon,点集拓扑观点是所有的三维正则曲面上的一个点(x,y,z)和它的参数曲面上的点(u,v)是一一映射的,不仅如此,uv面上和领域内相邻点的关系这种拓扑性质在三维曲面上并没有被改变,所以我们虽然是在求一个三维点和一个三维曲面片的位置关系,其实只将三维轮廓变换为二维polygon,就可以去求该三维问题。
变换成一种point2d_polygon2d_side case分类问题,只不过这时的平面polygon 不像CGAL中都是由直线段组成的,它还有平面二次曲线例如圆弧或者平面样条曲线,二次曲线和直线求交点有代数解析方法,或者多项式曲线和直线求交的数值迭代法。实现的开始也是计算了平面多边形的AABB以尽快发现out side的情况。
class BRepClass_FClassifier
{
...
Standard_EXPORT BRepClass_FClassifier();
//! Returns the result of the classification.
Standard_EXPORT TopAbs_State State() const;
//! Returns True when the state was computed by a
//! rejection. The state is OUT.
Standard_Boolean Rejected() const;
//! Returns True if the face contains no wire. The
//! state is IN.
Standard_Boolean NoWires() const;
//! Returns the Edge used to determine the
//! classification. When the State is ON this is the
//! Edge containing the point.
Standard_EXPORT const BRepClass_Edge& Edge() const;
//! Returns the parameter on Edge() used to determine the
//! classification.
Standard_EXPORT Standard_Real EdgeParameter() const;
//! Returns the position of the point on the edge
//! returned by Edge.
IntRes2d_Position Position() const;
...
};
//! Provides Constructors with a Face.
class BRepClass_FaceClassifier : public BRepClass_FClassifier
{
public:
DEFINE_STANDARD_ALLOC
//! Empty constructor, undefined algorithm.
Standard_EXPORT BRepClass_FaceClassifier();
//! Creates an algorithm to classify the Point P with
//! Tolerance <T> on the face described by <F>.
Standard_EXPORT BRepClass_FaceClassifier(BRepClass_FaceExplorer& F, const gp_Pnt2d& P, const Standard_Real Tol);
//! Creates an algorithm to classify the Point P with
//! Tolerance <T> on the face <F>.
//! Recommended to use Bnd_Box if the number of edges > 10
//! and the geometry is mostly spline
Standard_EXPORT BRepClass_FaceClassifier(const TopoDS_Face& theF, const gp_Pnt2d& theP, const Standard_Real theTol,
const Standard_Boolean theUseBndBox = Standard_False, const Standard_Real theGapCheckTol = 0.1);
//! Classify the Point P with Tolerance <T> on the
//! face described by <F>.
//! Recommended to use Bnd_Box if the number of edges > 10
//! and the geometry is mostly spline
Standard_EXPORT void Perform (const TopoDS_Face& theF, const gp_Pnt2d& theP, const Standard_Real theTol,
const Standard_Boolean theUseBndBox = Standard_False, const Standard_Real theGapCheckTol = 0.1);
//! Creates an algorithm to classify the Point P with
//! Tolerance <T> on the face <F>.
//! Recommended to use Bnd_Box if the number of edges > 10
//! and the geometry is mostly spline
Standard_EXPORT BRepClass_FaceClassifier(const TopoDS_Face& theF, const gp_Pnt& theP, const Standard_Real theTol,
const Standard_Boolean theUseBndBox = Standard_False, const Standard_Real theGapCheckTol = 0.1);
//! Classify the Point P with Tolerance <T> on the
//! face described by <F>.
//! Recommended to use Bnd_Box if the number of edges > 10
//! and the geometry is mostly spline
Standard_EXPORT void Perform (const TopoDS_Face& theF, const gp_Pnt& theP, const Standard_Real theTol,
const Standard_Boolean theUseBndBox = Standard_False, const Standard_Real theGapCheckTol = 0.1);
...
};