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


C++ Piecewise::push_seg方法代码示例

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


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

示例1: draw

    void draw( cairo_t *cr,	std::ostringstream *notify,
               int width, int height, bool save )
    {

        Point p = ph.pos;
        Point np = p;
        std::vector<Point> nps;

        cairo_set_line_width (cr, 0.3);
        cairo_set_source_rgb(cr, 0,0,0);
        switch ( choice )
        {
        case '1':
        {
            LineSegment seg(psh.pts[0], psh.pts[1]);
            cairo_move_to(cr, psh.pts[0]);
            cairo_curve(cr, seg);
            double t = seg.nearestPoint(p);
            np = seg.pointAt(t);
            if ( toggles[0].on )
            {
                nps.push_back(np);
            }
            break;
        }
        case '2':
        {
            SVGEllipticalArc earc;
            bool earc_constraints_satisfied = true;
            try
            {
                earc.set(psh.pts[0], 200, 150, 0, true, true, psh.pts[1]);
            }
            catch( RangeError e )
            {
                earc_constraints_satisfied = false;
            }
            if ( earc_constraints_satisfied )
            {
                cairo_d2_sb(cr, earc.toSBasis());
                if ( toggles[0].on )
                {
                    std::vector<double> t = earc.allNearestPoints(p);
                    for ( unsigned int i = 0; i < t.size(); ++i )
                        nps.push_back(earc.pointAt(t[i]));
                }
                else
                {
                    double t = earc.nearestPoint(p);
                    np = earc.pointAt(t);
                }
            }
            break;
        }
        case '3':
        {
            D2<SBasis> A = psh.asBezier();
            cairo_d2_sb(cr, A);
            if ( toggles[0].on )
            {
                std::vector<double> t = Geom::all_nearest_points(p, A);
                for ( unsigned int i = 0; i < t.size(); ++i )
                    nps.push_back(A(t[i]));
            }
            else
            {
                double t = nearest_point(p, A);
                np = A(t);
            }
            break;
        }
        case '4':
        {
            D2<SBasis> A = handles_to_sbasis(psh.pts.begin(), 3);
            D2<SBasis> B = handles_to_sbasis(psh.pts.begin() + 3, 3);
            D2<SBasis> C = handles_to_sbasis(psh.pts.begin() + 6, 3);
            D2<SBasis> D = handles_to_sbasis(psh.pts.begin() + 9, 3);
            cairo_d2_sb(cr, A);
            cairo_d2_sb(cr, B);
            cairo_d2_sb(cr, C);
            cairo_d2_sb(cr, D);
            Piecewise< D2<SBasis> > pwc;
            pwc.push_cut(0);
            pwc.push_seg(A);
            pwc.push_cut(0.25);
            pwc.push_seg(B);
            pwc.push_cut(0.50);
            pwc.push_seg(C);
            pwc.push_cut(0.75);
            pwc.push_seg(D);
            pwc.push_cut(1);
            if ( toggles[0].on )
            {
                std::vector<double> t = Geom::all_nearest_points(p, pwc);
                for ( unsigned int i = 0; i < t.size(); ++i )
                    nps.push_back(pwc(t[i]));
            }
            else
            {
                double t = Geom::nearest_point(p, pwc);
//.........这里部分代码省略.........
开发者ID:mental,项目名称:lib2geom,代码行数:101,代码来源:point-curve-nearest-point.cpp


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