Einzelnen Beitrag anzeigen

Bjoerk

Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
 
Delphi 10.4 Sydney
 
#43

AW: Polygon.Inflate

  Alt 8. Jul 2014, 12:17
Ich gehe davon aus, dass dein Ausgangspolygon das betonierte Resultat sein soll. Die Bewehrung muss zur Außenseite jeweils ein Mindestmaß an Betondeckung aufweisen. Du brauchst nun die Maße der Bewehrung.
So wird das allerdings schon klarer. Die vier Margins sind dann die jeweilige Mindestdicke der Betondeckung links, rechts, oben und unten. Aber wie wird die Dicke der Betondeckung bei einer Schräge bestimmt?
Betondeckungen verstehen sich immer parallel zur Polygonline.

Vielleicht hierzu meine Methode CornerStyle. Die liefert das "Align" eines Knotens.
Zum Beispiel bekommt ein Polygonknoten CornerStyle = csTopLeft die Margens Top und Left.

Und in #33 ist noch ein Indexfehler drin. Punkt 0 wird nach 1 gespeichert, 1 nach 2 usw..

Delphi-Quellcode:
procedure TPolygon.Inflate(Value: double);
var
  I, J: integer;
  C: TFloatPoint;
  Line: TFloatLine;
  Lines: TFloatLines;
begin
  if FCount > 2 then
  begin
    Lines := TFloatLines.Create;
    try
      if Area < 0 then
        Value := -Value;
      for I := 0 to FCount - 1 do
      begin
        J := Next(I);
        Line.P1 := FItems[I];
        Line.P2 := FItems[J];
        Line.ShiftUV(0, Value);
        Lines.Add(Line);
      end;
      Clear;
      C.Clear;
      Add(C);
      for I := 0 to Lines.Count - 1 do
      begin
        J := Lines.Next(I);
        if Lines.Item[I].IntersectLines(Lines.Item[J], C) then
          Add(C);
      end;
      ExChange(0, FCount - 1);
      Del(FCount - 1);
    finally
      Lines.Free;
    end;
  end;
end;

function TPolygon.CornerStyle(const Index: integer): TCornerStyle;
var
  Temp: TPolygon;
  dX, dY: double;
begin
  if (FCount > 2) and (Index > -1) and (Index < FCount) then
  begin
    Temp := TPolygon.Create;
    try
      Temp.Assign(Self);
      Temp.Inflate(1);
      dX := Temp[Index].X - FItems[Index].X;
      dY := Temp[Index].Y - FItems[Index].Y;
      if (dX < 0) and (dY > 0) then
        Result := csTopRight
      else
        if (dX < 0) and (dY < 0) then
          Result := csBottomRight
        else
          if (dX > 0) and (dY < 0) then
            Result := csBottomLeft
          else
            Result := csTopLeft; // (dX > 0) and (dY > 0)
      // ShowMessage(Format('%d: (%2.f %2.f) %2.f (%2.f %2.f) %2.f = %d',
      // [Index, FItems[Index].X, FItems[Index].Y, dX,
      // Temp[Index].X, Temp[Index].Y, dY, Integer(Result)]));
    finally
      Temp.Free;
    end;
  end;
end;
  Mit Zitat antworten Zitat