当前位置: 首页>>代码示例>>C++>>正文


C++ Handle_Geom_BezierCurve::Degree方法代码示例

本文整理汇总了C++中Handle_Geom_BezierCurve::Degree方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle_Geom_BezierCurve::Degree方法的具体用法?C++ Handle_Geom_BezierCurve::Degree怎么用?C++ Handle_Geom_BezierCurve::Degree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Handle_Geom_BezierCurve的用法示例。


在下文中一共展示了Handle_Geom_BezierCurve::Degree方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: c

BezierSegment::BezierSegment(const TopoDS_Edge &e)
{
    geomType = BEZIER;
    occEdge = e;
    BRepAdaptor_Curve c(e);
    Handle_Geom_BezierCurve bez = c.Bezier();
    poles = bez->NbPoles();
    degree = bez->Degree();
    if (poles > 4)  {
        Base::Console().Log("Warning - BezierSegment has degree > 3: %d\n",degree);
    }
    for (int i = 1; i <= poles; ++i) {
        gp_Pnt controlPoint = bez->Pole(i);
        pnts.push_back(Base::Vector2d(controlPoint.X(), controlPoint.Y()));
    }
}
开发者ID:abdullahtahiriyo,项目名称:FreeCAD_sf_master,代码行数:16,代码来源:Geometry.cpp

示例2: Int

Py::Int BezierCurve2dPy::getDegree(void) const
{
    Handle_Geom_BezierCurve curve = Handle_Geom_BezierCurve::DownCast
        (getGeometryPtr()->handle());
    return Py::Int(curve->Degree()); 
}
开发者ID:jobermayr,项目名称:FreeCAD,代码行数:6,代码来源:BezierCurve2dPyImp.cpp

示例3: c

BSpline::BSpline(const TopoDS_Edge &e)
{
    geomType = BSPLINE;
    BRepAdaptor_Curve c(e);
    occEdge = e;
    Handle_Geom_BSplineCurve spline = c.BSpline();
    bool fail = false;
    double f,l;
    gp_Pnt s,m,ePt;
    //if startpoint == endpoint conversion to BSpline will fail

    if (spline->Degree() > 3) {                                        //if spline is too complex, approximate it
        Standard_Real tol3D = 0.001;                                   //1/1000 of a mm? screen can't resolve this
        Standard_Integer maxDegree = 3, maxSegment = 10;
        Handle_BRepAdaptor_HCurve hCurve = new BRepAdaptor_HCurve(c);
        // approximate the curve using a tolerance
        //Approx_Curve3d approx(hCurve, tol3D, GeomAbs_C2, maxSegment, maxDegree);   //gives degree == 5  ==> too many poles ==> buffer overrun
        Approx_Curve3d approx(hCurve, tol3D, GeomAbs_C0, maxSegment, maxDegree);
        if (approx.IsDone() && approx.HasResult()) {
            spline = approx.Curve();
        } else {
            if (approx.HasResult()) {                   //result, but not within tolerance
                spline = approx.Curve();
                Base::Console().Log("Geometry::BSpline - result not within tolerance\n");
            } else {
                fail = true;
                f = c.FirstParameter();
                l = c.LastParameter();
                s = c.Value(f);
                m = c.Value((l+f)/2.0);
                ePt = c.Value(l);
                Base::Console().Log("Error - Geometry::BSpline - from:(%.3f,%.3f) to:(%.3f,%.3f) poles: %d\n",
                                     s.X(),s.Y(),ePt.X(),ePt.Y(),spline->NbPoles());
                //throw Base::Exception("Geometry::BSpline - could not approximate curve");
            }
        }
    }

    GeomConvert_BSplineCurveToBezierCurve crt(spline);

    BezierSegment tempSegment;
    gp_Pnt controlPoint;
    if (fail) {
        tempSegment.poles = 3;
        tempSegment.pnts[0] = Base::Vector2D(s.X(),s.Y());
        tempSegment.pnts[1] = Base::Vector2D(m.X(),m.Y());
        tempSegment.pnts[2] = Base::Vector2D(ePt.X(),ePt.Y());
        segments.push_back(tempSegment);
    } else {
        for (Standard_Integer i = 1; i <= crt.NbArcs(); ++i) {
            Handle_Geom_BezierCurve bezier = crt.Arc(i);
            if (bezier->Degree() > 3) {
                throw Base::Exception("Geometry::BSpline - converted curve degree > 3");
            }
            tempSegment.poles = bezier->NbPoles();
            // Note: We really only need to keep the pnts[0] for the first Bezier segment,
            // assuming this only gets used as in QGIViewPart::drawPainterPath
            // ...it also gets used in GeometryObject::calcBoundingBox(), similar note applies
            for (int pole = 1; pole <= tempSegment.poles; ++pole) {
                controlPoint = bezier->Pole(pole);
                tempSegment.pnts[pole - 1] = Base::Vector2D(controlPoint.X(), controlPoint.Y());
            }
            segments.push_back(tempSegment);
        }
    }
}
开发者ID:davidlni,项目名称:FreeCAD,代码行数:66,代码来源:Geometry.cpp

示例4: printBSpline

void DXFOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& out) //Not even close yet- DF 
{
    try {
        std::stringstream str;
        Handle_Geom_BSplineCurve spline = c.BSpline();
        if (spline->Degree() > 3) {
            Standard_Real tol3D = 0.001;
            Standard_Integer maxDegree = 3, maxSegment = 10;
            Handle_BRepAdaptor_HCurve hCurve = new BRepAdaptor_HCurve(c);
            // approximate the curve using a tolerance
            Approx_Curve3d approx(hCurve,tol3D,GeomAbs_C2,maxSegment,maxDegree);
            if (approx.IsDone() && approx.HasResult()) {
                // have the result
                spline = approx.Curve();
            }
        }
		
        GeomConvert_BSplineCurveToBezierCurve crt(spline);
		//GeomConvert_BSplineCurveKnotSplitting crt(spline,0);
        Standard_Integer arcs = crt.NbArcs();
		//Standard_Integer arcs = crt.NbSplits()-1;
        	str << 0 << endl
				<< "SECTION" << endl
				<< 2 << endl
				<< "ENTITIES" << endl
				<< 0 << endl
				<< "SPLINE" << endl;
				//<< 8 << endl
				//<< 0 << endl
				//<< 66 << endl
				//<< 1 << endl
				//<< 0 << endl;

        for (Standard_Integer i=1; i<=arcs; i++) {
            Handle_Geom_BezierCurve bezier = crt.Arc(i);
            Standard_Integer poles = bezier->NbPoles();
			//Standard_Integer poles = bspline->NbPoles();
			//gp_Pnt p1 = bspline->Pole(1);

            if (bezier->Degree() == 3) {
                if (poles != 4)
                    Standard_Failure::Raise("do it the generic way");
                gp_Pnt p1 = bezier->Pole(1);
                gp_Pnt p2 = bezier->Pole(2);
                gp_Pnt p3 = bezier->Pole(3);
                gp_Pnt p4 = bezier->Pole(4);
                if (i == 1) {
                    str 
						<< 10 << endl
						<< p1.X() << endl
						<< 20 << endl
						<< p1.Y() << endl
						<< 30 << endl
						<< 0 << endl
						
						<< 10 << endl
                        << p2.X() << endl
						<< 20 << endl
						<< p2.Y() << endl
						<< 30 << endl
						<< 0 << endl
						
						<< 10 << endl
                        << p3.X() << endl
						<< 20 << endl
						<< p3.Y() << endl
						<< 30 << endl
						<< 0 << endl
						
						<< 10 << endl
                        << p4.X() << endl
						<< 20 << endl
						<< p4.Y() << endl
						<< 30 << endl
						<< 0 << endl

						<< 12 << endl
						<< p1.X() << endl
						<< 22 << endl
						<< p1.Y() << endl
						<< 32 << endl
						<< 0 << endl

						<< 13 << endl
						<< p4.X() << endl
						<< 23 << endl
						<< p4.Y() << endl
						<< 33 << endl
						<< 0 << endl;
                }
                else {
                    str 
						<< 10 << endl
                        << p3.X() << endl
						<< 20 << endl
						<< p3.Y() << endl
						<< 30 << endl
						<< 0 << endl
						
						<< 10 << endl
//.........这里部分代码省略.........
开发者ID:Daedalus12,项目名称:FreeCAD_sf_master,代码行数:101,代码来源:DrawingExport.cpp


注:本文中的Handle_Geom_BezierCurve::Degree方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。