Changeset 174 for trunk/UMap.pas
- Timestamp:
- Nov 26, 2017, 11:35:25 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UMap.pas
r172 r174 259 259 CellDistance: TCellsDistance; 260 260 Cell: TCell; 261 Cell2: TCell; 261 262 L1, L2: TLine; 262 263 MP: TPoint; 263 264 LinkLine: TLine; 264 Polygon: TPolygon;265 //LeftLink: TCellsDistance;266 //CenterLink: TCellsDistance;267 //RightLink: TCellsDistance;268 265 LeftClosingLine1: TLine; 269 266 LeftClosingLine2: TLine; … … 283 280 LeftCellCommon: TCell; 284 281 RightCellCommon: TCell; 285 //LeftText: string; 286 //RightText: string; 287 NeighborCell: TCell; 282 const 283 CellGapWidth = 4; 288 284 begin 289 285 Clear; … … 306 302 // Calculate distance between all cells 307 303 CellsDistance := TFPGObjectList<TCellsDistance>.Create; 308 for I1 := 1to Cells.Count - 1 do304 for I1 := 0 to Cells.Count - 1 do 309 305 for I2 := I1 + 1 to Cells.Count - 1 do begin 310 306 NewCellDist := TCellsDistance.Create; … … 362 358 LeftCell := Cell.Neighbors[I]; 363 359 RightCell := Cell.Neighbors[(I + 1) mod Cell.Neighbors.Count]; 364 //LeftText := LeftCell.Neighbors.ToString;365 //RightText := RightCell.Neighbors.ToString;366 360 LeftIndex := LeftCell.Neighbors.IndexOf(Cell); 367 361 RightIndex := RightCell.Neighbors.IndexOf(Cell); … … 406 400 end; 407 401 408 // Compute polygon around cells with sequence sorted by link angle402 {// Compute polygon around cells with sequence sorted by link angle 409 403 for Cell in Cells do begin 410 404 // Use whole map first for cell polygon … … 414 408 for NeighborCell in Cell.Neighbors do begin 415 409 LinkLine := TLine.Create(Cell.PosPx, NeighborCell.PosPx); 416 LinkLine.Distance := LinkLine.Distance - 4;410 LinkLine.Distance := LinkLine.Distance - CellGapWidth; 417 411 MP := LinkLine.GetMiddle; 418 412 // Create half plane vector … … 424 418 Cell.Polygon := Polygon; 425 419 end else Cell.Polygon.Clear; 420 end;} 421 422 // Additional polygon by all other cells 423 for Cell in Cells do begin 424 Cell.Polygon := TPolygon.Create(TRect.Create(TPoint.Create(0, 0), 425 TPoint.Create(Size.X * DefaultCellSize.X, Size.Y * DefaultCellSize.Y))); 426 for Cell2 in Cells do 427 if Cell2 <> Cell then begin 428 LinkLine := TLine.Create(Cell.PosPx, Cell2.PosPx); 429 LinkLine.Distance := LinkLine.Distance - CellGapWidth; 430 MP := LinkLine.GetMiddle; 431 // Create half plane vector 432 L1 := TLine.Create(MP, TPoint.Create(MP.X + LinkLine.GetSize.X, 433 MP.Y + LinkLine.GetSize.Y)); 434 435 Cell.Polygon.CutLine(L1, Cell.PosPx); 436 end; 437 end; 438 439 // Remove all neighbor links for cell pairs with non-overlaping polygons 440 for Cell in Cells do begin 441 for I := Cell.Neighbors.Count - 1 downto 0 do begin 442 if Cell.Polygon.EdgeDistance(Cell.Neighbors[I].Polygon) > 2 * CellGapWidth then 443 Cell.Neighbors.Delete(I); 444 end; 426 445 end; 427 446
Note:
See TracChangeset
for help on using the changeset viewer.