本文整理汇总了C++中geom::Affine::translation方法的典型用法代码示例。如果您正苦于以下问题:C++ Affine::translation方法的具体用法?C++ Affine::translation怎么用?C++ Affine::translation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类geom::Affine
的用法示例。
在下文中一共展示了Affine::translation方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: draw
void draw(cairo_t *cr,
std::ostringstream *notify,
int width, int height, bool save, std::ostringstream *timer_stream) {
if (first_time)
{
first_time = false;
sliders[0].geometry(Point(50, 50), 100);
}
size_t const num_points = static_cast<size_t>(sliders[0].value());
D2<SBasis> B1 = b_handle.asBezier();
Piecewise<D2<SBasis> >B;
B.concat(Piecewise<D2<SBasis> >(B1));
// 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, 2.);
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);
Timer tm;
Timer::Time als_time = tm.lap();
cairo_set_source_rgba (cr, 0., 0., 0.9, 1);
//dot_plot(cr,uniform_B);
cairo_stroke(cr);
std::cout << B[0] << std::endl;
Geom::Affine translation;
Geom::Path original_path;
//original_bezier.append(B[0]);
//original_bezier.appendNew<CubicBezier> (B[0]);
CubicBezier original_bezier(b_handle.pts);
original_path.append(original_bezier);
std::vector<double> initial_t;
std::vector<Geom::Point> curve_points;
if (randomize_times) {
std::uniform_real_distribution<double> dist_t(0,1);
for (size_t ii = 0; ii < num_points; ++ii) {
double const t = dist_t(generator);
initial_t.push_back(t);
}
std::sort(initial_t.begin(), initial_t.end());
double const min = initial_t.front();
double const max = initial_t.back();
for (auto& t : initial_t) {
t = (t-min)/(max-min);
}
for (auto const t : initial_t) {
curve_points.push_back(original_bezier.pointAt(t));
}
}
else {
for (size_t ii = 0; ii < num_points; ++ii) {
double const t = static_cast<double>(ii) / (num_points-1);
Geom::Point const p = original_bezier.pointAt(t);
initial_t.push_back(t);
curve_points.push_back(p);
}
}
cairo_set_source_rgba (cr, 0., 0., .9, 1);
cairo_path(cr, original_path);
draw_text(cr, original_path.initialPoint(), "original curve and old fit");
Geom::CubicBezier fitted_new;
Geom::CubicBezier fitted_new_a;
Geom::Point very_old_version_raw[4];
bezier_fit_cubic(very_old_version_raw, curve_points.data(), curve_points.size(), 0.);
Geom::CubicBezier very_old_bezier(
very_old_version_raw[0],
very_old_version_raw[1],
very_old_version_raw[2],
very_old_version_raw[3]
);
Geom::Path very_old_version_path;
very_old_version_path.append(very_old_bezier);
cairo_set_source_rgba (cr, .7, .7, 0., 1);
cairo_stroke(cr);
cairo_path(cr, very_old_version_path);
cairo_set_source_rgba (cr, 0., 0., .9, 1);
cairo_stroke(cr);
//.........这里部分代码省略.........
示例2: bbox
Geom::OptRect SPShape::bbox(Geom::Affine const &transform, SPItem::BBoxType bboxtype) const {
Geom::OptRect bbox;
if (!this->_curve) {
return bbox;
}
bbox = bounds_exact_transformed(this->_curve->get_pathvector(), transform);
if (!bbox) {
return bbox;
}
if (bboxtype == SPItem::VISUAL_BBOX) {
// convert the stroke to a path and calculate that path's geometric bbox
if (!this->style->stroke.isNone()) {
Geom::PathVector *pathv = item_outline(this, true); // calculate bbox_only
if (pathv) {
bbox |= bounds_exact_transformed(*pathv, transform);
delete pathv;
}
}
// Union with bboxes of the markers, if any
if ( this->hasMarkers() && !this->_curve->get_pathvector().empty() ) {
/** \todo make code prettier! */
Geom::PathVector const & pathv = this->_curve->get_pathvector();
// START marker
for (unsigned i = 0; i < 2; i++) { // SP_MARKER_LOC and SP_MARKER_LOC_START
if ( this->_marker[i] ) {
SPItem* marker_item = sp_item_first_item_child( _marker[i] );
if (marker_item) {
Geom::Affine tr(sp_shape_marker_get_transform_at_start(pathv.begin()->front()));
if (_marker[i]->orient_mode == MARKER_ORIENT_AUTO_START_REVERSE) {
// Reverse start marker if necessary
tr = Geom::Rotate::from_degrees( 180.0 ) * tr;
} else if (_marker[i]->orient_mode == MARKER_ORIENT_ANGLE) {
Geom::Point transl = tr.translation();
tr = Geom::Rotate::from_degrees(_marker[i]->orient) * Geom::Translate(transl);
}
if (_marker[i]->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
tr = Geom::Scale(this->style->stroke_width.computed) * tr;
}
// total marker transform
tr = marker_item->transform * _marker[i]->c2p * tr * transform;
// get bbox of the marker with that transform
bbox |= marker_item->visualBounds(tr);
}
}
}
// MID marker
for (unsigned i = 0; i < 3; i += 2) { // SP_MARKER_LOC and SP_MARKER_LOC_MID
if ( !this->_marker[i] ) {
continue;
}
SPMarker* marker = _marker[i];
SPItem* marker_item = sp_item_first_item_child( marker );
if ( !marker_item ) {
continue;
}
for(Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
// START position
if ( path_it != pathv.begin()
&& ! ((path_it == (pathv.end()-1)) && (path_it->size_default() == 0)) ) // if this is the last path and it is a moveto-only, there is no mid marker there
{
Geom::Affine tr(sp_shape_marker_get_transform_at_start(path_it->front()));
if (marker->orient_mode == MARKER_ORIENT_ANGLE) {
Geom::Point transl = tr.translation();
tr = Geom::Rotate::from_degrees(marker->orient) * Geom::Translate(transl);
}
if (marker->markerUnits == SP_MARKER_UNITS_STROKEWIDTH) {
tr = Geom::Scale(this->style->stroke_width.computed) * tr;
}
tr = marker_item->transform * marker->c2p * tr * transform;
bbox |= marker_item->visualBounds(tr);
}
// MID position
if ( path_it->size_default() > 1) {
Geom::Path::const_iterator curve_it1 = path_it->begin(); // incoming curve
Geom::Path::const_iterator curve_it2 = ++(path_it->begin()); // outgoing curve
while (curve_it2 != path_it->end_default())
{
/* Put marker between curve_it1 and curve_it2.
* Loop to end_default (so including closing segment), because when a path is closed,
//.........这里部分代码省略.........