Changeset 172 for trunk/UMap.pas


Ignore:
Timestamp:
Nov 24, 2017, 10:11:54 AM (7 years ago)
Author:
chronos
Message:
  • Fixed: Rectangle points were not normalized.
  • Fixed: Error in rect to polygon conversion.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UMap.pas

    r171 r172  
    239239{ TVoronoiMap }
    240240
    241 function CompareDistance(C1, C2: Pointer): Integer;
    242 begin
    243   if TCellsDistance(C1).Distance > TCellsDistance(C2).Distance then Result := 1
    244   else if TCellsDistance(C1).Distance < TCellsDistance(C2).Distance then Result := -1
    245   else Result := 0;
    246 end;
    247 
    248 function CompareDistanceReverse(const C1, C2: TCellsDistance): Integer;
    249 begin
    250   if C1.Distance > C2.Distance then Result := -1
    251   else if C1.Distance < C2.Distance then Result := 1
     241function CompareDistance(const C1, C2: TCellsDistance): Integer;
     242begin
     243  if C1.Distance > C2.Distance then Result := 1
     244  else if C1.Distance < C2.Distance then Result := -1
    252245  else Result := 0;
    253246end;
     
    321314    CellsDistance.Add(NewCellDist);
    322315  end;
    323   CellsDistance.Sort(CompareDistanceReverse);
     316  CellsDistance.Sort(CompareDistance);
    324317
    325318  // Keep shortest non-intersected cell pairs
    326319  SelectedCells := TFPGObjectList<TCellsDistance>.Create;
    327320  SelectedCells.FreeObjects := False;
    328   I := CellsDistance.Count - 1;
    329   while I >= 0 do begin
     321  I := 0;
     322  while I < CellsDistance.Count do begin
    330323    Intersected := False;
    331324    for J := 0 to SelectedCells.Count - 1 do
     
    347340    end;
    348341    if not Intersected then SelectedCells.Add(CellsDistance[I]);
    349     Dec(I);
     342    Inc(I);
    350343  end;
    351344
Note: See TracChangeset for help on using the changeset viewer.