about NormalizeBreakPoints -talk about a bug

Please post bug reports, feature requests, or any question regarding the DELPHI AREA projects here.

about NormalizeBreakPoints -talk about a bug

Postby liu8670 » August 7th, 2008, 6:39 am

I think LastAngle:=Angle; must be added

Code: Select all
function TGraphLink.NormalizeBreakPoints(Options: TLinkNormalizeOptions): Boolean;
var
  I: Integer;
  Neighborhood: Integer;
  LastAngle, Angle, DiffAngle: Double;
begin
  Result := False;
  if (PointCount > 2) and (Options <> []) then
  begin
    BeginUpdate;
    try
      // Delete breakpoints on same point
      if lnoDeleteSamePoint in Options then
      begin
        Neighborhood := NeighborhoodRadius;
        I := 1;
        while I < PointCount do
        begin
          if LineLength(Points[I - 1], Points[I]) <= Neighborhood then
          begin
            if I = PointCount - 1 then
              RemovePoint(I - 1)
            else
              RemovePoint(I);
            Result := True;
          end
          else
            Inc(I);
        end;
      end;
      // Delete breakpoints on a straight line
      if lnoDeleteSameAngle in Options then
      begin
        LastAngle := LineSlopeAngle(Points[0], Points[1]);
        I := 2;
        while I < PointCount do
        begin
          Angle := LineSlopeAngle(Points[I - 1], Points[I]);
          ifDiffAngle:= Abs(Angle - LastAngle) * 180 /PI;//< Pi / 360 must be rewrited
          if  DiffAngle < 1 then
          begin
            if I = PointCount - 1 then
              RemovePoint(I - 1)
            else
              RemovePoint(I);
            Result := True;
          end
          else
            Inc(I);
          LastAngle:=Angle;// I think it is important
        end;
      end;
    finally
      EndUpdate;
    end;
  end;
end;
liu8670
Member
Member
 
Posts: 3
Joined: December 7th, 2007, 12:36 am

Postby Kambiz » August 7th, 2008, 11:48 am

You are right. Thank you.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to DELPHI AREA Projects

Who is online

Users browsing this forum: No registered users and 3 guests

cron