Hi Anton,
I haven't read your mail in much detail, but generally it is a very bad idea to
directly modify nodes of a path.
Could you explain what you are trying to do? Each point should be displaced by a different
amount or...?
Ciao,
Johan
-----Oorspronkelijk bericht-----
Van: Anton Moiseev [mailto:benderamp@...400...]
Verzonden: ma 25/01/2010 23:06
Aan: inkscape-devel(a)lists.sourceforge.net
Onderwerp: [Inkscape-devel] Set new coordinates for points in
thePiecewise<D2<SBasis> > array
Hello,
I'm trying to write a new live effect which would move original path
points to new locations.
I have taken lpe-envelope.cpp for the base and write my code inside
Geom::Piecewise<Geom::D2<Geom::SBasis> >
LPEPerspective::doEffect_pwd2 (Geom::Piecewise<Geom::D2<Geom::SBasis>
const & pwd2_in)
so, I receive Piecewise<D2<SBasis> > at the input and want to return
generated object Piecewise<D2<SBasis> > at the output, which would
contain all orinal pwd2_in points, but with new coordinates.
Generally I did not have problems with my algorithm and I have an
array of Point objects, but now when I want to put them back to
Piecewise<D2<SBasis> > array, the result does not have the required
quality:
It is hard to explain in more details, so would try to put some code I have.
Piecewise<D2<SBasis> > output = pwd2_in; // this gives me a path with
same number of nodes as the original one
then I go though all points in the path and try to set new location
for each point
for (unsigned i = 0; i < pwd2_in.segs.size(); i++){
Point target_point = XXX; // calc new value for current point
output[i][0][0][0] = target_point[0]; // set value for x
output[i][1][0][0] = target_point[1]; // set value for y
}
return output;
With code which works in this way the transformation converted any the
object to invisible phantome (the selection showed its area with
nothing inside, but when remove the selection it is not possible to
select object again, also the "edit points" did not show any objects)
- in short, the result was broken.
Then I played a bit with printing values for pwd2_in path, understood
that I must somehow play with SBasis object values (set values to
SBasis[0][0] and SBasis[0][1]) and added the following to the code:
for (unsigned i = 0; i < pwd2_in.segs.size(); i++){
Point target_point = XXX; // calc new value for current point
output[i][0][0][0] = target_point[0]; // set value for x
output[i][1][0][0] = target_point[1]; // set value for y
if(i > 0) {
// setup previous point target value
output[i - 1][0][0][1] = target_point[0];
output[i - 1][1][0][1] = target_point[1];
} else {
output[i][0][0][1] = target_point[0];
output[i][1][0][1] = target_point[1];
}
}
return output;
That was much better - I was able to see the deformed objects which
looked much like originals, but still had some issues:
1. Bended curves became straight lines
2. I have problems with objects consisting of multiple paths
Actually, the 1st point only shows itself when I try to deform such
object as symbol '3' (converted to path) - after deforming its shape
looks like original, but consists of straight lines; though when I
deform a simple triangle with one rib curved,the curve does not
disappear, but did not test much though with this deffect.
The 2nd problem for now is more important - it is visible after
deforming symbol '4' - when it is converted to path, it consists of 2
unconnected path objects, and after my deforming, those 2 paths become
connected at some point. This is definitely happens because I set
incorrect values to SBasis[0][1] and actually I would prefer not to
play with SBasis object by hands and to do my task in some other more
reliable way, but for now I could not find anything relevant in the
documentation.
thank's
------------------------------------------------------------------------------
The Planet: dedicated and managed hosting, cloud storage, colocation
Stay online with enterprise data centers and the best network in the business
Choose flexible plans and management services without long-term contracts
Personal 24x7 support from experience hosting pros just a phone call away.
http://p.sf.net/sfu/theplanet-com
_______________________________________________
Inkscape-devel mailing list
Inkscape-devel(a)lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/inkscape-devel