本文整理汇总了C++中PointSetHandle类的典型用法代码示例。如果您正苦于以下问题:C++ PointSetHandle类的具体用法?C++ PointSetHandle怎么用?C++ PointSetHandle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PointSetHandle类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw( cairo_t *cr, std::ostringstream *notify,
int width, int height, bool save )
{
cairo_set_line_width (cr, 0.3);
m_selection_kind = (unsigned int) (sliders[0].value());
for (unsigned int i = 0; i < m_pathvector_coll.size(); ++i)
{
cairo_set_source_rgba(cr, 0.0, 0.4*(i+1), 0.8/(i+1), 1.0);
for (unsigned int j = 0; j < m_pathvector_coll[i].size(); ++j)
{
m_pathvector_coll[i][j].clear();
for (unsigned int k = 0; k < m_curves_per_path; ++k)
{
PointSetHandle psh;
psh.pts.resize(m_handles_per_curve);
for (unsigned int h = 0; h < m_handles_per_curve; ++h)
{
unsigned int kk = k * (m_handles_per_curve-1) + h;
psh.pts[h] = m_pathvector_coll_handles[i][j].pts[kk];
}
m_pathvector_coll[i][j].append(psh.asBezier());
}
cairo_path(cr, m_pathvector_coll[i][j]);
}
cairo_stroke(cr);
}
Rect bound;
if ( (m_selection_kind == CURVE) && (m_selected_curve != -1) )
{
const Curve & curve = m_pathvector_coll[m_selected_pathvector][m_selected_path][m_selected_curve];
bound = toggles[0].on ? *curve.boundsExact()
: *curve.boundsFast();
}
else if ( (m_selection_kind == PATH) && (m_selected_path != -1) )
{
const Path & path = m_pathvector_coll[m_selected_pathvector][m_selected_path];
bound = toggles[0].on ? *path.boundsExact()
: *path.boundsFast();
}
else if ( (m_selection_kind == PATHVECTOR) && (m_selected_pathvector != -1) )
{
const PathVector & pathvector = m_pathvector_coll[m_selected_pathvector];
bound = toggles[0].on ? *bounds_exact(pathvector)
: *bounds_fast(pathvector);
}
cairo_set_source_rgba(cr, 0.5, 0.0, 0.0, 1.0);
cairo_set_line_width (cr, 0.4);
cairo_rectangle(cr, bound.left(), bound.top(), bound.width(), bound.height());
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save);
}
示例2: draw
void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save, std::ostringstream *timer_stream) {
D2<SBasis> skeleton = skel_handles.asBezier();
D2<SBasis> pattern = pat_handles.asBezier();
cairo_set_line_width(cr,1.);
cairo_pw_d2_sb(cr, Piecewise<D2<SBasis> >(skeleton));
cairo_set_source_rgba(cr,0.0,0.0,1.0,1.0);
cairo_stroke(cr);
cairo_pw_d2_sb(cr, Piecewise<D2<SBasis> >(pattern));
cairo_set_source_rgba(cr,1.0,0.0,1.0,1.0);
cairo_stroke(cr);
origin_handle.pos[0]=150;
Geom::Point origin = origin_handle.pos;
Piecewise<D2<SBasis> > uskeleton = arc_length_parametrization(Piecewise<D2<SBasis> >(skeleton),2,.1);
uskeleton = remove_short_cuts(uskeleton,.01);
Piecewise<D2<SBasis> > n = rot90(derivative(uskeleton));
n = force_continuity(remove_short_cuts(n,.1));
Piecewise<SBasis> x=Piecewise<SBasis>(pattern[0]-origin[0]);
Piecewise<SBasis> y=Piecewise<SBasis>(pattern[1]-origin[1]);
Interval pattBnds = *bounds_exact(x);
int nbCopies = int(uskeleton.cuts.back()/pattBnds.extent());
//double pattWidth = uskeleton.cuts.back()/nbCopies;
double pattWidth = pattBnds.extent();
double offs = 0;
x-=pattBnds.min();
//x*=pattWidth/pattBnds.extent();
Piecewise<D2<SBasis> >output;
for (int i=0; i<nbCopies; i++){
output.concat(compose(uskeleton,x+offs)+y*compose(n,x+offs));
offs+=pattWidth;
}
//Perform cut for last segment
double tt = uskeleton.cuts.back() - offs;
if(tt > 0.) {
vector<double> rs = roots(x - tt);
rs.push_back(0); rs.push_back(1); //regard endpoints
std::sort(rs.begin(), rs.end());
std::unique(rs.begin(), rs.end());
//enumerate indices of sections to the left of the line
for(unsigned i = (x[0].at0()>tt ? 1 : 0); i < rs.size()-1; i+=2) {
Piecewise<SBasis> port = portion(x+offs, rs[i], rs[i+1]);
output.concat(compose(uskeleton,port)+portion(y, rs[i], rs[i+1])*compose(n,port));
}
}
cairo_pw_d2_sb(cr, output);
cairo_set_source_rgba(cr,1.0,0.0,1.0,1.0);
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save,timer_stream);
}
示例3: draw
void draw(cairo_t *cr,
std::ostringstream *notify,
int width, int height, bool save) {
D2<SBasis> B1 = b1_handle.asBezier();
D2<SBasis> B2 = b2_handle.asBezier();
Piecewise<D2<SBasis> >B;
B.concat(Piecewise<D2<SBasis> >(B1));
B.concat(Piecewise<D2<SBasis> >(B2));
// testing fuse_nearby_ends
std::vector< Piecewise<D2<SBasis> > > pieces;
pieces = fuse_nearby_ends(split_at_discontinuities(B),9);
Piecewise<D2<SBasis> > C;
for (unsigned i=0; i<pieces.size(); i++){
C.concat(pieces[i]);
}
// testing fuse_nearby_ends
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0., 0.5, 0., 1);
//cairo_d2_sb(cr, B1);
cairo_pw_d2_sb(cr, C);
//cairo_pw_d2_sb(cr, B);
cairo_stroke(cr);
Piecewise<D2<SBasis> > uniform_B = arc_length_parametrization(B);
cairo_set_source_rgba (cr, 0., 0., 0.9, 1);
dot_plot(cr,uniform_B);
cairo_stroke(cr);
*notify << "pieces = " << uniform_B.size() << ";\n";
Toy::draw(cr, notify, width, height, save);
}
示例4: draw
void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save, std::ostringstream *timer_stream) {
D2<SBasis> B = B_handle.asBezier();
D2<SBasis> P = P_handle.asBezier();
Geom::Point O = O_handle.pos;
NormalBundle NBdle;
NBdle.setBase(B);
Geom::Point Oo(O[0]+*(NBdle.lengths.rbegin()),O[1]);
vector<D2<SBasis> > Q=compose(NBdle,P,O);
cairo_set_line_width (cr, 0.5);
//Base lines
cairo_set_source_rgba (cr, 0.9, 0., 0., 1);
cairo_d2_sb(cr, B);
draw_line_seg(cr, O, Oo);
cairo_stroke(cr);
//Sections
cairo_set_source_rgba (cr, 0, 0, 0.9, 1);
cairo_d2_sb(cr, P);
for (unsigned i=0;i<Q.size();i++){
cairo_d2_sb(cr, Q[i]);
}
cairo_stroke(cr);
//Normal bundle
cairo_set_source_rgba (cr, 0., 0., 0., 1);
NBdle.draw(cr,3,5);
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save,timer_stream);
}
示例5: p
QuadToy() {
handles.push_back(&psh);
for(unsigned i = 0; i < 100; i++) {
Geom::Point p(uniform() * 400, uniform() * 400);
psh.push_back(p);
psh.push_back(p + Geom::Point(uniform() * 40, uniform() * 40));
}
}
示例6: SBZeros
SBZeros () {
for(unsigned i = 0; i < SIZE; i++)
pB1.push_back(150+uniform()*300,150+uniform()*300);
for(unsigned i = 0; i < SIZE; i++)
pB2.push_back(150+uniform()*300,150+uniform()*300);
handles.push_back(&pB1);
handles.push_back(&pB2);
}
示例7: LengthTester
LengthTester(){
for(int i = 0; i < SIZE; i++) {
b1_handle.push_back(150+uniform()*300,150+uniform()*300);
b2_handle.push_back(150+uniform()*300,150+uniform()*300);
}
b1_handle.pts[0] = Geom::Point(150,150);
b1_handle.pts[1] = Geom::Point(150,150);
b1_handle.pts[2] = Geom::Point(150,450);
b1_handle.pts[3] = Geom::Point(450,150);
handles.push_back(&b1_handle);
handles.push_back(&b2_handle);
}
示例8: ConvolutionToy
ConvolutionToy(){
for(int i = 0; i < SIZE; i++) {
b1_handle.push_back(150+uniform()*300,150+uniform()*300);
b2_handle.push_back(150+uniform()*300,150+uniform()*300);
}
handles.push_back(&b1_handle);
handles.push_back(&b2_handle);
adjuster.pos = Geom::Point(400,100+300*uniform());
handles.push_back(&adjuster);
}
示例9: PathAlongPathToy
PathAlongPathToy() : origin_handle(150,150) {
if(handles.empty()) {
handles.push_back(&skel_handles);
handles.push_back(&pat_handles);
for(int i = 0; i < 8; i++)
skel_handles.push_back(200+50*i,400);
for(int i = 0; i < 4; i++)
pat_handles.push_back(100+uniform()*400,
150+uniform()*100);
handles.push_back(&origin_handle);
}
}
示例10: first_time
void first_time(int argc, char** argv) {
const char *path_name="sanitize_examples.svgd";
if(argc > 1)
path_name = argv[1];
paths = read_svgd(path_name);
//es = edges(paths, crossings_among(paths));
handles.push_back(&angh); handles.push_back(&pathix);
angh.push_back(100, 100);
angh.push_back(80, 100);
angh.push_back(100, 80);
pathix.push_back(30, 200);
}
示例11: NormalBundleToy
NormalBundleToy(){
if(handles.empty()) {
handles.push_back(&B_handle);
handles.push_back(&P_handle);
handles.push_back(&O_handle);
for(unsigned i = 0; i < 4; i++)
B_handle.push_back(200+50*i,400);
for(unsigned i = 0; i < 4; i++)
P_handle.push_back(100+uniform()*400,
150+uniform()*100);
O_handle.pos = Geom::Point(200,200);
}
}
示例12: RandomToy
RandomToy(){
for(int i = 0; i < SIZE; i++) {
b1_handle.push_back(150+uniform()*300,150+uniform()*300);
b2_handle.push_back(150+uniform()*300,150+uniform()*300);
}
b1_handle.pts[0] = Geom::Point(400,300);
b1_handle.pts[1] = Geom::Point(400,400);
b1_handle.pts[2] = Geom::Point(100,400);
b1_handle.pts[3] = Geom::Point(100,300);
b2_handle.pts[0] = Geom::Point(100,300);
b2_handle.pts[1] = Geom::Point(100,200);
b2_handle.pts[2] = Geom::Point(400,200);
b2_handle.pts[3] = Geom::Point(400,300);
handles.push_back(&b1_handle);
handles.push_back(&b2_handle);
for(unsigned i = 0; i < NB_SLIDER; i++) {
adjuster[i].pos = Geom::Point(30+i*20,250);
handles.push_back(&(adjuster[i]));
}
}
示例13: Rect
Conic5() {
handles.push_back(&path_handles);
handles.push_back(&rh);
rh.pos = Rect(Point(100,100), Point(200,200));
rh.show_center_handle = true;
handles.push_back(&oncurve);
for(int j = 0; j < 3; j++){
path_handles.push_back(uniform()*400, 100+ uniform()*300);
}
oncurve.pos = ((path_handles.pts[0]+path_handles.pts[1]+path_handles.pts[2])/3);
handles.push_back(&cutting_plane);
for(int j = 0; j < 2; j++){
cutting_plane.push_back(uniform()*400, 100+ uniform()*300);
}
sliders.push_back(Slider(0.0, 5.0, 0, 0.0, "a"));
sliders.push_back(Slider(0.0, 5.0, 0, 0.0, "b"));
sliders.push_back(Slider(0.0, 5.0, 0, 0.0, "c"));
handles.push_back(&(sliders[0]));
handles.push_back(&(sliders[1]));
handles.push_back(&(sliders[2]));
sliders[0].geometry(Point(50, 20), 250);
sliders[1].geometry(Point(50, 50), 250);
sliders[2].geometry(Point(50, 80), 250);
}
示例14: draw
virtual void draw(cairo_t *cr, std::ostringstream *notify, int width, int height, bool save) {
D2<SBasis> B1 = pB1.asBezier();
D2<SBasis> B2 = pB2.asBezier();
Piecewise<D2<SBasis> >B;
B.concat(Piecewise<D2<SBasis> >(B1));
B.concat(Piecewise<D2<SBasis> >(B2));
std::vector<Point> e;
std::vector<Piecewise<D2<SBasis> > > s;
s.push_back(derivative(B));
for(int j = 0; j < 5; j++) s.push_back(derivative(s.back()));
for(int j = 0; j <= 5; j++) {
for(unsigned d = 0; d < 2; d++) {
std::vector<double> r = roots(make_cuts_independent(s[j])[d]);
for(unsigned k = 0; k < r.size(); k++) e.push_back(B.valueAt(r[k]));
}
}
for(unsigned i = 0; i < e.size(); i++) draw_cross(cr, e[i]);
cairo_set_line_width (cr, .5);
cairo_set_source_rgba (cr, 0., 0.5, 0., 1);
cairo_pw_d2_sb(cr, B);
cairo_stroke(cr);
Toy::draw(cr, notify, width, height, save);
}
示例15: BezierFitTester
BezierFitTester(){
for(int i = 0; i < SIZE; i++) {
b_handle.push_back(150+uniform()*300,150+uniform()*300);
}
b_handle.pts[0] = Geom::Point(70,250);
b_handle.pts[1] = Geom::Point(200,150);
b_handle.pts[2] = Geom::Point(200,350);
b_handle.pts[3] = Geom::Point(350,200);
handles.push_back(&b_handle);
// M 70 250 C 860 766 200 350 350 200
// M 70 250 C 906 833 200 350 350 200
// M 70 250 C 800 738 200 350 350 200
sliders.push_back(Slider(2, 50, 1, 25, "number of points"));
handles.push_back(&(sliders[0]));
}