1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
|
/*
* Author(s):
* Jabiertxo Arraiza Cenoz <jabier.arraiza@marker.es>
*
* Copyright (C) 2014 Author(s)
*
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
#include "live_effects/lpe-fillet-chamfer.h"
#include "helper/geom.h"
#include "display/curve.h"
#include "helper/geom-curves.h"
#include "helper/geom-satellite.h"
#include <2geom/elliptical-arc.h>
#include "knotholder.h"
#include <boost/optional.hpp>
// TODO due to internal breakage in glibmm headers, this must be last:
#include <glibmm/i18n.h>
namespace Inkscape {
namespace LivePathEffect {
static const Util::EnumData<FilletMethod> FilletMethodData[FM_END] = {
{ FM_AUTO, N_("Auto"), "auto" }, { FM_ARC, N_("Force arc"), "arc" },
{ FM_BEZIER, N_("Force bezier"), "bezier" }
};
static const Util::EnumDataConverter<FilletMethod> FMConverter(FilletMethodData,
FM_END);
LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject)
: Effect(lpeobject),
satellites_param(_("pair_array_param"), _("pair_array_param"),
"satellites_param", &wr, this),
method(_("Method:"), _("Methods to calculate the fillet or chamfer"),
"method", FMConverter, &wr, this, FM_AUTO),
radius(_("Radius (unit or %):"), _("Radius, in unit or %"), "radius", &wr,
this, 0.0),
chamfer_steps(_("Chamfer steps:"), _("Chamfer steps"), "chamfer_steps",
&wr, this, 1),
flexible(_("Flexible radius size (%)"), _("Flexible radius size (%)"),
"flexible", &wr, this, false),
mirror_knots(_("Mirror Knots"), _("Mirror Knots"), "mirror_knots", &wr,
this, true),
only_selected(_("Change only selected nodes"),
_("Change only selected nodes"), "only_selected", &wr, this,
false),
use_knot_distance(_("Use knots distance instead radius"),
_("Use knots distance instead radius"),
"use_knot_distance", &wr, this, false),
hide_knots(_("Hide knots"), _("Hide knots"), "hide_knots", &wr, this,
false),
apply_no_radius(_("Apply changes if radius = 0"), _("Apply changes if radius = 0"), "apply_no_radius", &wr, this, true),
apply_with_radius(_("Apply changes if radius > 0"), _("Apply changes if radius > 0"), "apply_with_radius", &wr, this, true),
helper_size(_("Helper size with direction:"),
_("Helper size with direction"), "helper_size", &wr, this, 0)
{
registerParameter(&satellites_param);
registerParameter(&method);
registerParameter(&radius);
registerParameter(&chamfer_steps);
registerParameter(&helper_size);
registerParameter(&flexible);
registerParameter(&use_knot_distance);
registerParameter(&mirror_knots);
registerParameter(&apply_no_radius);
registerParameter(&apply_with_radius);
registerParameter(&only_selected);
registerParameter(&hide_knots);
radius.param_set_range(0.0, Geom::infinity());
radius.param_set_increments(1, 1);
radius.param_set_digits(4);
radius.param_overwrite_widget(true);
chamfer_steps.param_set_range(1, 999);
chamfer_steps.param_set_increments(1, 1);
chamfer_steps.param_set_digits(0);
//chamfer_steps.param_overwrite_widget(true);
helper_size.param_set_range(0, 999);
helper_size.param_set_increments(5, 5);
helper_size.param_set_digits(0);
//helper_size.param_overwrite_widget(true);
}
void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
{
SPLPEItem *splpeitem = const_cast<SPLPEItem *>(lpeItem);
SPShape *shape = dynamic_cast<SPShape *>(splpeitem);
if (shape) {
Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(shape->getCurve()->get_pathvector());
Satellites satellites;
for (Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
if (path_it->empty()) {
continue;
}
std::vector<Satellite> subpath_satellites;
for (Geom::Path::const_iterator curve_it = path_it->begin(); curve_it != path_it->end(); ++curve_it) {
//Maybe we want this satellites...
//if (curve_it->isDegenerate()) {
// continue
//}
Satellite satellite(FILLET);
satellite.setSteps(chamfer_steps);
subpath_satellites.push_back(satellite);
}
//we add the last satellite on open path because pointwise is related to nodes, not curves
//so maybe in the future we can need this last satellite in other effects
//dont remove for this effect because pointwise class has methods when the path is modiffied
//and we want one method for all uses
if (!path_it->closed()) {
Satellite satellite(FILLET);
satellite.setSteps(chamfer_steps);
subpath_satellites.push_back(satellite);
}
satellites.push_back(subpath_satellites);
}
pointwise.setPathVector(pathv);
pointwise.setSatellites(satellites);
satellites_param.setPointwise(pointwise);
} else {
g_warning("LPE Fillet/Chamfer can only be applied to shapes (not groups).");
SPLPEItem *item = const_cast<SPLPEItem *>(lpeItem);
item->removeCurrentPathEffect(false);
}
}
Gtk::Widget *LPEFilletChamfer::newWidget()
{
// use manage here, because after deletion of Effect object, others might
// still be pointing to this widget.
Gtk::VBox *vbox = Gtk::manage(new Gtk::VBox(Effect::newWidget()));
vbox->set_border_width(5);
vbox->set_homogeneous(false);
vbox->set_spacing(2);
std::vector<Parameter *>::iterator it = param_vector.begin();
while (it != param_vector.end()) {
if ((*it)->widget_is_visible) {
Parameter *param = *it;
Gtk::Widget *widg = param->param_newWidget();
if (param->param_key == "radius") {
Inkscape::UI::Widget::Scalar *widg_registered =
Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg));
widg_registered->signal_value_changed().connect(
sigc::mem_fun(*this, &LPEFilletChamfer::updateAmount));
widg = widg_registered;
if (widg) {
Gtk::HBox *scalar_parameter = dynamic_cast<Gtk::HBox *>(widg);
std::vector<Gtk::Widget *> childList = scalar_parameter->get_children();
Gtk::Entry *entry_widget = dynamic_cast<Gtk::Entry *>(childList[1]);
entry_widget->set_width_chars(6);
}
} else if (param->param_key == "chamfer_steps") {
Inkscape::UI::Widget::Scalar *widg_registered =
Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg));
widg_registered->signal_value_changed().connect(
sigc::mem_fun(*this, &LPEFilletChamfer::updateChamferSteps));
widg = widg_registered;
if (widg) {
Gtk::HBox *scalar_parameter = dynamic_cast<Gtk::HBox *>(widg);
std::vector<Gtk::Widget *> childList = scalar_parameter->get_children();
Gtk::Entry *entry_widget = dynamic_cast<Gtk::Entry *>(childList[1]);
entry_widget->set_width_chars(3);
}
} else if (param->param_key == "helper_size") {
Inkscape::UI::Widget::Scalar *widg_registered =
Gtk::manage(dynamic_cast<Inkscape::UI::Widget::Scalar *>(widg));
widg_registered->signal_value_changed().connect(
sigc::mem_fun(*this, &LPEFilletChamfer::refreshKnots));
} else if (param->param_key == "only_selected") {
Gtk::manage(widg);
}
Glib::ustring *tip = param->param_getTooltip();
if (widg) {
vbox->pack_start(*widg, true, true, 2);
if (tip) {
widg->set_tooltip_text(*tip);
} else {
widg->set_tooltip_text("");
widg->set_has_tooltip(false);
}
}
}
++it;
}
Gtk::HBox *fillet_container = Gtk::manage(new Gtk::HBox(true, 0));
Gtk::Button *fillet =
Gtk::manage(new Gtk::Button(Glib::ustring(_("Fillet"))));
fillet->signal_clicked()
.connect(sigc::mem_fun(*this, &LPEFilletChamfer::fillet));
fillet_container->pack_start(*fillet, true, true, 2);
Gtk::Button *inverse_fillet =
Gtk::manage(new Gtk::Button(Glib::ustring(_("Inverse fillet"))));
inverse_fillet->signal_clicked()
.connect(sigc::mem_fun(*this, &LPEFilletChamfer::inverseFillet));
fillet_container->pack_start(*inverse_fillet, true, true, 2);
Gtk::HBox *chamfer_container = Gtk::manage(new Gtk::HBox(true, 0));
Gtk::Button *chamfer =
Gtk::manage(new Gtk::Button(Glib::ustring(_("Chamfer"))));
chamfer->signal_clicked()
.connect(sigc::mem_fun(*this, &LPEFilletChamfer::chamfer));
chamfer_container->pack_start(*chamfer, true, true, 2);
Gtk::Button *inverse_chamfer =
Gtk::manage(new Gtk::Button(Glib::ustring(_("Inverse chamfer"))));
inverse_chamfer->signal_clicked()
.connect(sigc::mem_fun(*this, &LPEFilletChamfer::inverseChamfer));
chamfer_container->pack_start(*inverse_chamfer, true, true, 2);
vbox->pack_start(*fillet_container, true, true, 2);
vbox->pack_start(*chamfer_container, true, true, 2);
return vbox;
}
void LPEFilletChamfer::fillet()
{
updateSatelliteType(FILLET);
}
void LPEFilletChamfer::inverseFillet()
{
updateSatelliteType(INVERSE_FILLET);
}
void LPEFilletChamfer::chamfer()
{
updateSatelliteType(CHAMFER);
}
void LPEFilletChamfer::inverseChamfer()
{
updateSatelliteType(INVERSE_CHAMFER);
}
void LPEFilletChamfer::refreshKnots()
{
//Find another way to update knots satellites_param.knoth->update_knots(); do the thing
//but not updat the knot index on node delete
if (tools_isactive(desktop, TOOLS_NODES)) {
tools_switch(desktop, TOOLS_SELECT);
tools_switch(desktop, TOOLS_NODES);
}
}
void LPEFilletChamfer::updateAmount()
{
double power = 0;
if (!flexible) {
power = radius;
} else {
power = radius / 100;
}
Satellites satellites = pointwise.getSatellites();
Geom::PathVector pathv = pointwise.getPathVector();
for (size_t i = 0; i < satellites.size(); ++i) {
for (size_t j = 0; j < satellites[i].size(); ++j) {
boost::optional<size_t> previous_index = boost::none;
if(j == 0 && pathv[i].closed()){
previous_index = pathv[i].size() - 1;
} else if(!pathv[i].closed() || j != 0) {
previous_index = j - 1;
}
if (!pathv[i].closed() && j == 0) {
satellites[i][j].amount = 0;
continue;
}
if (pathv[i].size() == j) {
continue;
}
if ((!apply_no_radius && satellites[i][j].amount == 0) ||
(!apply_with_radius && satellites[i][j].amount != 0))
{
continue;
}
Geom::Point satellite_point = pathv[i].pointAt(j);
if (isNodePointSelected(satellite_point) || !only_selected) {
if (!use_knot_distance && !flexible) {
if(previous_index) {
satellites[i][j].amount = satellites[i][j].radToLen(power, pathv[i][*previous_index], pathv[i][j]);
} else {
satellites[i][j].amount = 0.0;
}
} else {
satellites[i][j].amount = power;
}
}
}
}
pointwise.setSatellites(satellites);
satellites_param.setPointwise(pointwise);
}
void LPEFilletChamfer::updateChamferSteps()
{
Satellites satellites = pointwise.getSatellites();
Geom::PathVector pathv = pointwise.getPathVector();
for (size_t i = 0; i < satellites.size(); ++i) {
for (size_t j = 0; j < satellites[i].size(); ++j) {
if ((!apply_no_radius && satellites[i][j].amount == 0) ||
(!apply_with_radius && satellites[i][j].amount != 0))
{
continue;
}
if (only_selected) {
Geom::Point satellite_point = pathv[i].pointAt(j);
if (isNodePointSelected(satellite_point)) {
satellites[i][j].steps = chamfer_steps;
}
} else {
satellites[i][j].steps = chamfer_steps;
}
}
}
pointwise.setSatellites(satellites);
satellites_param.setPointwise(pointwise);
}
void LPEFilletChamfer::updateSatelliteType(SatelliteType satellitetype)
{
Satellites satellites = pointwise.getSatellites();
Geom::PathVector pathv = pointwise.getPathVector();
for (size_t i = 0; i < satellites.size(); ++i) {
for (size_t j = 0; j < satellites[i].size(); ++j) {
if ((!apply_no_radius && satellites[i][j].amount == 0) ||
(!apply_with_radius && satellites[i][j].amount != 0))
{
continue;
}
if (pathv[i].size() == j) {
if (!only_selected) {
satellites[i][j].satellite_type = satellitetype;
}
continue;
}
if (only_selected) {
Geom::Point satellite_point = pathv[i].pointAt(j);
if (isNodePointSelected(satellite_point)) {
satellites[i][j].satellite_type = satellitetype;
}
} else {
satellites[i][j].satellite_type = satellitetype;
}
}
}
pointwise.setSatellites(satellites);
satellites_param.setPointwise(pointwise);
}
void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
{
SPLPEItem *splpeitem = const_cast<SPLPEItem *>(lpeItem);
SPShape *shape = dynamic_cast<SPShape *>(splpeitem);
if (shape) {
SPCurve *c = shape->getCurve();
SPPath *path = dynamic_cast<SPPath *>(shape);
if (path) {
c = path->get_original_curve();
}
//fillet chamfer specific calls
satellites_param.setUseDistance(use_knot_distance);
//mandatory call
satellites_param.setEffectType(effectType());
satellites_param.setPathUpdate(false);
Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector());
Satellites satellites = satellites_param.data();
if(satellites.empty()) {
doOnApply(lpeItem);
satellites = satellites_param.data();
}
if (hide_knots) {
satellites_param.setHelperSize(0);
} else {
satellites_param.setHelperSize(helper_size);
}
size_t number_nodes = pathv.nodes().size();
for (size_t i = 0; i < satellites.size(); ++i) {
for (size_t j = 0; j < satellites[i].size(); ++j) {
if (satellites[i][j].is_time != flexible) {
satellites[i][j].is_time = flexible;
double amount = satellites[i][j].amount;
if (pathv[i].size() == j){
continue;
}
Geom::Curve const &curve_in = pathv[i][j];
if (satellites[i][j].is_time) {
double time = timeAtArcLength(amount, curve_in);
satellites[i][j].amount = time;
} else {
double size = arcLengthAt(amount, curve_in);
satellites[i][j].amount = size;
}
}
if (satellites[i][j].has_mirror != mirror_knots) {
satellites[i][j].has_mirror = mirror_knots;
}
satellites[i][j].hidden = hide_knots;
}
}
//if are diferent sizes call to poinwise recalculate
//TODO: Update the satellite data in paths modified, Goal 0.93
size_t satellites_counter = pointwise.getTotalSatellites();
if (satellites_counter != 0 ){
std::cout << number_nodes << "aaaaa" << pointwise.getTotalSatellites() << "\n";
}
if (satellites_counter != 0 && number_nodes != satellites_counter) {
satellites_param.setPathUpdate(true);
Satellite satellite(satellites[0][0].satellite_type);
satellite.setIsTime(satellites[0][0].is_time);
satellite.setHasMirror(mirror_knots);
satellite.setHidden(hide_knots);
pointwise.recalculateForNewPathVector(pathv, satellite);
} else {
pointwise.setPathVector(pathv);
pointwise.setSatellites(satellites);
}
satellites_param.setPointwise(pointwise);
refreshKnots();
} else {
g_warning("LPE Fillet can only be applied to shapes (not groups).");
}
}
void
LPEFilletChamfer::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
{
hp_vec.push_back(_hp);
}
Geom::PathVector
LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in)
{
const double GAP_HELPER = 0.00001;
Geom::PathVector path_out;
size_t path = 0;
const double K = (4.0 / 3.0) * (sqrt(2.0) - 1.0);
Geom::PathVector pathv = pathv_to_linear_and_cubic_beziers(path_in);
for (Geom::PathVector::const_iterator path_it = pathv.begin(); path_it != pathv.end(); ++path_it) {
if (path_it->empty()) {
continue;
}
_hp.push_back(*path_it);
Geom::Path tmp_path;
if (path_it->size() == 1) {
path++;
tmp_path.start(path_it[0].pointAt(0));
tmp_path.append(path_it[0]);
path_out.push_back(tmp_path);
continue;
}
double time0 = 0;
size_t curve = 0;
Satellites satellites = pointwise.getSatellites();
for (Geom::Path::const_iterator curve_it1 = path_it->begin(); curve_it1 != path_it->end(); ++curve_it1) {
size_t next_index = curve + 1;
if (curve == pathv[path].size() - 1 && pathv[path].closed()) {
next_index = 0;
}
if (curve == pathv[path].size() -1 && !pathv[path].closed()) { //the path is open and we are at end of path
if (time0 != 1) { //Previous satellite not at 100% amount
Geom::Curve *last_curve = curve_it1->portion(time0, 1);
last_curve->setInitial(tmp_path.finalPoint());
tmp_path.append(*last_curve);
}
continue;
}
Satellite satellite = satellites[path][next_index];
if (!curve) { //curve == 0
if (!path_it->closed()) {
time0 = 0;
} else {
time0 = satellites[path][0].time(*curve_it1);
}
}
bool last = pathv[path].size() - 1 == curve;
Geom::Curve const &curve_it2 = pathv[path][next_index];
double s = satellite.arcDistance(curve_it2);
double time1 = satellite.time(s, true, (*curve_it1));
double time2 = satellite.time(curve_it2);
if (time1 <= time0) {
time1 = time0;
}
if (time2 > 1) {
time2 = 1;
}
std::vector<double> times;
times.push_back(time0);
times.push_back(time1);
times.push_back(time2);
Geom::Curve *knot_curve_1 = curve_it1->portion(times[0], times[1]);
if (curve > 0) {
knot_curve_1->setInitial(tmp_path.finalPoint());
} else {
tmp_path.start((*curve_it1).pointAt(times[0]));
}
Geom::Point start_arc_point = knot_curve_1->finalPoint();
Geom::Point end_arc_point = curve_it2.pointAt(times[2]);
if (times[2] == 1) {
end_arc_point = curve_it2.pointAt(times[2] - GAP_HELPER);
}
if (times[1] == times[0]) {
start_arc_point = curve_it1->pointAt(times[0] + GAP_HELPER);
}
double k1 = distance(start_arc_point, curve_it1->finalPoint()) * K;
double k2 = distance(end_arc_point, curve_it2.initialPoint()) * K;
Geom::CubicBezier const *cubic_1 =
dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_1);
Geom::Ray ray_1(start_arc_point, curve_it1->finalPoint());
if (cubic_1) {
ray_1.setPoints((*cubic_1)[2], start_arc_point);
}
Geom::Point handle_1 = Geom::Point::polar(ray_1.angle(), k1) + start_arc_point;
if (time0 == 1) {
handle_1 = start_arc_point;
}
Geom::Curve *knot_curve_2 = curve_it2.portion(times[2], 1);
Geom::CubicBezier const *cubic_2 =
dynamic_cast<Geom::CubicBezier const *>(&*knot_curve_2);
Geom::Ray ray_2(curve_it2.initialPoint(), end_arc_point);
if (cubic_2) {
ray_2.setPoints(end_arc_point, (*cubic_2)[1]);
}
Geom::Point handle_2 = end_arc_point - Geom::Point::polar(ray_2.angle(), k2);
bool ccw_toggle = cross(curve_it1->finalPoint() - start_arc_point,
end_arc_point - start_arc_point) < 0;
double angle = angle_between(ray_1, ray_2, ccw_toggle);
double handleAngle = ray_1.angle() - angle;
if (ccw_toggle) {
handleAngle = ray_1.angle() + angle;
}
Geom::Point inverse_handle_1 = Geom::Point::polar(handleAngle, k1) + start_arc_point;
if (time0 == 1) {
inverse_handle_1 = start_arc_point;
}
handleAngle = ray_2.angle() + angle;
if (ccw_toggle) {
handleAngle = ray_2.angle() - angle;
}
Geom::Point inverse_handle_2 = end_arc_point - Geom::Point::polar(handleAngle, k2);
if (times[2] == 1) {
end_arc_point = curve_it2.pointAt(times[2]);
}
if (times[1] == times[0]) {
start_arc_point = curve_it1->pointAt(times[0]);
}
Geom::Line const x_line(Geom::Point(0, 0), Geom::Point(1, 0));
Geom::Line const angled_line(start_arc_point, end_arc_point);
double arc_angle = Geom::angle_between(x_line, angled_line);
double radius = Geom::distance(start_arc_point,
middle_point(start_arc_point, end_arc_point)) /
sin(angle / 2.0);
Geom::Coord rx = radius;
Geom::Coord ry = rx;
if (times[1] != 1) {
if (times[1] != times[0] || (times[1] == 1 && times[0] == 1)) {
if (!knot_curve_1->isDegenerate()) {
tmp_path.append(*knot_curve_1);
}
}
SatelliteType type = satellite.satellite_type;
size_t steps = satellite.steps;
if (steps < 1) {
steps = 1;
}
if (type == CHAMFER) {
Geom::Path path_chamfer;
path_chamfer.start(tmp_path.finalPoint());
if ((is_straight_curve(*curve_it1) &&
is_straight_curve(curve_it2) && method != FM_BEZIER) ||
method == FM_ARC) {
ccw_toggle = ccw_toggle ? 0 : 1;
path_chamfer.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0,
ccw_toggle, end_arc_point);
} else {
path_chamfer.appendNew<Geom::CubicBezier>(handle_1, handle_2,
end_arc_point);
}
double chamfer_stepsTime = 1.0 / steps;
for (size_t i = 1; i < steps; i++) {
Geom::Point chamfer_step = path_chamfer.pointAt(chamfer_stepsTime * i);
tmp_path.appendNew<Geom::LineSegment>(chamfer_step);
}
tmp_path.appendNew<Geom::LineSegment>(end_arc_point);
} else if (type == INVERSE_CHAMFER) {
Geom::Path path_chamfer;
path_chamfer.start(tmp_path.finalPoint());
if ((is_straight_curve(*curve_it1) &&
is_straight_curve(curve_it2) && method != FM_BEZIER) ||
method == FM_ARC) {
path_chamfer.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0,
ccw_toggle, end_arc_point);
} else {
path_chamfer.appendNew<Geom::CubicBezier>(
inverse_handle_1, inverse_handle_2, end_arc_point);
}
double chamfer_stepsTime = 1.0 / steps;
for (size_t i = 1; i < steps; i++) {
Geom::Point chamfer_step =
path_chamfer.pointAt(chamfer_stepsTime * i);
tmp_path.appendNew<Geom::LineSegment>(chamfer_step);
}
tmp_path.appendNew<Geom::LineSegment>(end_arc_point);
} else if (type == INVERSE_FILLET) {
if ((is_straight_curve(*curve_it1) &&
is_straight_curve(curve_it2) && method != FM_BEZIER) ||
method == FM_ARC) {
tmp_path.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle,
end_arc_point);
} else {
tmp_path.appendNew<Geom::CubicBezier>(inverse_handle_1,
inverse_handle_2, end_arc_point);
}
} else if (type == FILLET) {
if ((is_straight_curve(*curve_it1) &&
is_straight_curve(curve_it2) && method != FM_BEZIER) ||
method == FM_ARC) {
ccw_toggle = ccw_toggle ? 0 : 1;
tmp_path.appendNew<Geom::EllipticalArc>(rx, ry, arc_angle, 0, ccw_toggle,
end_arc_point);
} else {
tmp_path.appendNew<Geom::CubicBezier>(handle_1, handle_2,
end_arc_point);
}
}
} else {
if (!knot_curve_1->isDegenerate()) {
tmp_path.append(*knot_curve_1);
}
}
if (path_it->closed() && last) {
tmp_path.close();
}
curve++;
time0 = times[2];
}
path++;
path_out.push_back(tmp_path);
}
return path_out;
}
}; //namespace LivePathEffect
}; /* namespace Inkscape */
/*
Local Variables:
mode:c++
c-file-style:"stroustrup"
c-file-offset:((innamespace . 0)(inline-open . 0)(case-label . +))
indent-tabs-mode:nil
fill-column:99
End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
|