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


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

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


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

示例1: arcLengthSb

/** Reparameterise M to have unit speed.
 \param M the Element.
 \param tol the maximum error allowed.
 \param order the maximum degree to use for approximation
 \relates Piecewise, D2
*/
Piecewise<D2<SBasis> >
Geom::arc_length_parametrization(D2<SBasis> const &M,
                           unsigned order,
                           double tol){
    Piecewise<D2<SBasis> > u;
    u.push_cut(0);

    Piecewise<SBasis> s = arcLengthSb(Piecewise<D2<SBasis> >(M),tol);
    for (unsigned i=0; i < s.size();i++){
        double t0=s.cuts[i],t1=s.cuts[i+1];
        if ( are_near(s(t0),s(t1)) ) {
            continue;
        }
        D2<SBasis> sub_M = compose(M,Linear(t0,t1));
        D2<SBasis> sub_u;
        for (unsigned dim=0;dim<2;dim++){
            SBasis sub_s = s.segs[i];
            sub_s-=sub_s.at0();
            sub_s/=sub_s.at1();
            sub_u[dim]=compose_inverse(sub_M[dim],sub_s, order, tol);
        }
        u.push(sub_u,s(t1));
    }
    return u;
}
开发者ID:abrock,项目名称:lib2geom,代码行数:31,代码来源:sbasis-geometric.cpp

示例2: draw

    void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save) {
        Geom::Point dir(1,-2);

	D2<Piecewise<SBasis> > B = make_cuts_independent(path_a_pw);

	cairo_set_source_rgba (cr, 0., 0.125, 0, 1);

        if(0) {
            D2<Piecewise<SBasis> > tB(cos(B[0]*0.1)*(brush_handle.pos[0]/100) + B[0], 
                                      cos(B[1]*0.1)*(brush_handle.pos[1]/100) + B[1]);
	
            cairo_d2_pw_sb(cr, tB);
        } else  {
            Piecewise<SBasis> r2 = (dot(path_a_pw - brush_handle.pos, path_a_pw - brush_handle.pos));
            Piecewise<SBasis> rc;
            rc.push_cut(0);
            rc.push(SBasis(Linear(1, 1)), 2);
            rc.push(SBasis(Linear(1, 0)), 4);
            rc.push(SBasis(Linear(0, 0)), 30);
            rc *= 10;
            rc.scaleDomain(1000);
            Piecewise<SBasis> swr;
            swr.push_cut(0);
            swr.push(SBasis(Linear(0, 1)), 2);
            swr.push(SBasis(Linear(1, 0)), 4);
            swr.push(SBasis(Linear(0, 0)), 30);
            swr *= 10;
            swr.scaleDomain(1000);
            cairo_pw(cr, swr);// + (height - 100));
            D2<Piecewise<SBasis> >  uB = make_cuts_independent(unitVector(path_a_pw - brush_handle.pos));
        
            D2<Piecewise<SBasis> > tB(compose(rc, (r2))*uB[0] + B[0], 
                                      compose(rc, (r2))*uB[1] + B[1]);
            cairo_d2_pw_sb(cr, tB);
            //path_a_pw = sectionize(tB);
	}
	cairo_stroke(cr);
        
        *notify << path_a_pw.size();
        
        Toy::draw(cr, notify, width, height, save);
    }
开发者ID:mental,项目名称:lib2geom,代码行数:42,代码来源:center-warp.cpp

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