+ else if (anEdge->isBSpline()) {
+ // check B-spline is periodic and planar
+ std::shared_ptr<GeomAPI_Curve> aCurve(new GeomAPI_Curve(anEdge));
+ std::shared_ptr<GeomAPI_BSpline> aBSpline(new GeomAPI_BSpline(aCurve));
+ if (aBSpline->isPeriodic()) {
+ GeomPlanePtr aBSplinePlane = GeomAlgoAPI_ShapeTools::findPlane(ListOfShape(1, anEdge));
+ if (aBSplinePlane) {
+ std::shared_ptr<GeomAPI_Dir> aBSplineNormal = aBSplinePlane->direction();
+ double aDot = fabs(aNormal->dot(aBSplineNormal));
+ aValid = aDot > tolerance * tolerance;
+ if (!aValid) {
+ // B-spline's plane is orthogonal to the sketch plane,
+ // thus, need to check whether B-spline is planar.
+ std::list<GeomPointPtr> aPoles = aBSpline->poles();
+ for (std::list<GeomPointPtr>::iterator it = aPoles.begin();
+ it != aPoles.end() && !aValid; ++it) {
+ if (aBSplinePlane->distance(*it) > tolerance)
+ aValid = true; // non-planar B-spline curve
+ }
+ if (!aValid)
+ theError = "Error: Periodic B-spline is orthogonal to the sketch plane.";
+ }
+ }
+ }
+ }