#define MY_BSPLINE (*(implPtr<Handle_Geom_BSplineCurve>()))
-GeomAPI_BSpline::GeomAPI_BSpline (const GeomCurvePtr& theCurve,
- const bool isForced)
+GeomAPI_BSpline::GeomAPI_BSpline (const GeomCurvePtr& theCurve)
{
GeomCurvePtr anUntrimmedCurve = theCurve->basisCurve();
Handle(Geom_Curve) aCurve = anUntrimmedCurve->impl<Handle(Geom_Curve)>();
Handle(Geom_BSplineCurve) aBSpl = Handle(Geom_BSplineCurve)::DownCast(aCurve);
- if (aBSpl.IsNull() && isForced) {
- // convert to b-spline
- aBSpl = GeomConvert::CurveToBSplineCurve(aCurve);
- }
if (aBSpl.IsNull())
throw Standard_ConstructionError("GeomAPI_BSpline: Curve is not a B-spline");
setImpl(new Handle_Geom_BSplineCurve(aBSpl));
{
return MY_BSPLINE->IsPeriodic();
}
+
+GeomBSplinePtr GeomAPI_BSpline::convertToBSpline (const GeomCurvePtr& theCurve)
+{
+ GeomCurvePtr anUntrimmedCurve = theCurve->basisCurve();
+ Handle(Geom_Curve) aCurve = anUntrimmedCurve->impl<Handle(Geom_Curve)>();
+ Handle(Geom_BSplineCurve) aBSpl = Handle(Geom_BSplineCurve)::DownCast(aCurve);
+ if (aBSpl.IsNull()) {
+ // convert to b-spline
+ aBSpl = GeomConvert::CurveToBSplineCurve(aCurve);
+ }
+ if (aBSpl.IsNull())
+ throw Standard_ConstructionError("GeomAPI_BSpline: Conversion to B-spline failed");
+ GeomCurvePtr aResCurve (new GeomAPI_Curve());
+ aResCurve->setImpl(new Handle_Geom_BSplineCurve(aBSpl));
+ GeomBSplinePtr aResult (new GeomAPI_BSpline(aResCurve));
+ return aResult;
+}
#include <memory>
class GeomAPI_Pnt;
+class GeomAPI_BSpline;
+
+//! Pointer on the object
+typedef std::shared_ptr<GeomAPI_BSpline> GeomBSplinePtr;
/**\class GeomAPI_BSpline
* \ingroup DataModel
{
public:
/// Creation of B-spline defined by a curve
- /// \param isForced if true and theCurve is not a b-spline
- /// curve, theCurve is converted to b-spline
- GEOMAPI_EXPORT GeomAPI_BSpline (const GeomCurvePtr& theCurve,
- const bool isForced = false);
+ GEOMAPI_EXPORT GeomAPI_BSpline (const GeomCurvePtr& theCurve);
/// Degree of B-spline curve
GEOMAPI_EXPORT int degree() const;
/// Return \c true if the curve is periodic
GEOMAPI_EXPORT bool isPeriodic() const;
-};
-//! Pointer on the object
-typedef std::shared_ptr<GeomAPI_BSpline> GeomBSplinePtr;
+ /// Convert any curve into a B-spline curve
+ GEOMAPI_EXPORT static GeomBSplinePtr convertToBSpline (const GeomCurvePtr& theCurve);
+};
#endif
setImpl(aParal);
setBuilderType(OCCT_BRepBuilderAPI_MakeShape);
- aParal->Init(aFace, GeomAbs_Arc, Standard_True);
+ Standard_Boolean isOpenResult = !aWire.Closed();
+ aParal->Init(aFace, GeomAbs_Arc, isOpenResult);
aParal->Perform(theOffsetValue, 0.);
if (aParal->IsDone()) {
TopoDS_Shape anOffset = aParal->Shape();
{
GeomCurvePtr aCurve (new GeomAPI_Curve (theEdge));
// Forced conversion to b-spline, if aCurve is not b-spline
- GeomAPI_BSpline aBSpline (aCurve, /*isForced*/true);
+ GeomBSplinePtr aBSpline = GeomAPI_BSpline::convertToBSpline(aCurve);
- const std::string& aBSplineKind = aBSpline.isPeriodic() ? SketchPlugin_BSplinePeriodic::ID()
- : SketchPlugin_BSpline::ID();
+ const std::string& aBSplineKind = aBSpline->isPeriodic() ? SketchPlugin_BSplinePeriodic::ID()
+ : SketchPlugin_BSpline::ID();
findOrCreateFeatureByKind(sketch(), aBSplineKind, theResult, thePoolOfFeatures);
- theResult->integer(SketchPlugin_BSpline::DEGREE_ID())->setValue(aBSpline.degree());
+ theResult->integer(SketchPlugin_BSpline::DEGREE_ID())->setValue(aBSpline->degree());
AttributePoint2DArrayPtr aPolesAttr = std::dynamic_pointer_cast<GeomDataAPI_Point2DArray>
(theResult->attribute(SketchPlugin_BSpline::POLES_ID()));
- std::list<GeomPointPtr> aPoles = aBSpline.poles();
+ std::list<GeomPointPtr> aPoles = aBSpline->poles();
aPolesAttr->setSize((int)aPoles.size());
std::list<GeomPointPtr>::iterator anIt = aPoles.begin();
for (int anIndex = 0; anIt != aPoles.end(); ++anIt, ++anIndex) {
AttributeDoubleArrayPtr aWeightsAttr =
theResult->data()->realArray(SketchPlugin_BSpline::WEIGHTS_ID());
- std::list<double> aWeights = aBSpline.weights();
+ std::list<double> aWeights = aBSpline->weights();
if (aWeights.empty()) { // rational B-spline
int aSize = (int)aPoles.size();
aWeightsAttr->setSize(aSize);
AttributeDoubleArrayPtr aKnotsAttr =
theResult->data()->realArray(SketchPlugin_BSpline::KNOTS_ID());
- std::list<double> aKnots = aBSpline.knots();
+ std::list<double> aKnots = aBSpline->knots();
int aSize = (int)aKnots.size();
aKnotsAttr->setSize(aSize);
std::list<double>::iterator aKIt = aKnots.begin();
AttributeIntArrayPtr aMultsAttr =
theResult->data()->intArray(SketchPlugin_BSpline::MULTS_ID());
- std::list<int> aMultiplicities = aBSpline.mults();
+ std::list<int> aMultiplicities = aBSpline->mults();
aSize = (int)aMultiplicities.size();
aMultsAttr->setSize(aSize);
std::list<int>::iterator aMIt = aMultiplicities.begin();