 Search on this site Search in forums  Home » U++ Library support » Draw, Display, Images, Bitmaps, Icons » Problem in dasher.cpp and proposed solution
Problem in dasher.cpp and proposed solution Fri, 13 April 2012 16:02   koldo Messages: 3143Registered: August 2008 Ultimate Member
Hello Mirek

In dasher.cpp if the line drawn is very long, it enters in an almost endless loop.

```void Dasher::Line(const Pointf& p)
{
if(sum == 0) {
PutLine(p);
return;
}
Pointf v = p - p0;
double len = Length(v);
double pos = 0;
while(pos + rem < len) {
pos += rem;
Put(pos / len * v + p0);
flag = !flag;
rem = (*pattern)[patterni];
patterni = (patterni + 1) % pattern->GetCount();
}
rem -= len - pos;
Put(p);
p0 = p;
}```

If "len" is very high, the program gets stuck in the while loop.

If you could limit this in any way, by limiting or len or the number of iterations of the while loop, the problem gets solved.

Thank you .

Best regards
Iñaki
Re: Problem in dasher.cpp and proposed solution [message #35982 is a reply to message #35981] Sat, 14 April 2012 11:22    mirek Messages: 12571Registered: November 2005 Ultimate Member
 koldo wrote on Fri, 13 April 2012 10:02 Hello Mirek In dasher.cpp if the line drawn is very long, it enters in an almost endless loop. ```void Dasher::Line(const Pointf& p) { if(sum == 0) { PutLine(p); return; } Pointf v = p - p0; double len = Length(v); double pos = 0; while(pos + rem < len) { pos += rem; Put(pos / len * v + p0); flag = !flag; rem = (*pattern)[patterni]; patterni = (patterni + 1) % pattern->GetCount(); } rem -= len - pos; Put(p); p0 = p; }``` If "len" is very high, the program gets stuck in the while loop. If you could limit this in any way, by limiting or len or the number of iterations of the while loop, the problem gets solved. Thank you .

If I understand it well, this is the same problem as

http://www.ultimatepp.org/redmine/issues/214

correct?

There is no easy solution to this... Perhaps some rough clip estimate before doing stroke?
Re: Problem in dasher.cpp and proposed solution [message #35983 is a reply to message #35982] Sat, 14 April 2012 13:00   koldo Messages: 3143Registered: August 2008 Ultimate Member
Hello Mirek

Yes. It seems the same problem.

I think in this case a rough solution could be valid.

Best regards
Iñaki
 Previous Topic: Bug: Missing width in DrawArc on X11 Next Topic: how to dispaly moving text has any idea?
Goto Forum:

Current Time: Sat Jul 04 23:59:32 CEST 2020

Total time taken to generate the page: 0.01023 seconds