Merge branch 'master' of github.com:pascalabcnet/pascalabcnet
This commit is contained in:
commit
490697a3e9
|
|
@ -15,7 +15,7 @@ internal static class RevisionClass
|
|||
public const string Major = "3";
|
||||
public const string Minor = "3";
|
||||
public const string Build = "0";
|
||||
public const string Revision = "1615";
|
||||
public const string Revision = "1627";
|
||||
|
||||
public const string MainVersion = Major + "." + Minor;
|
||||
public const string FullVersion = Major + "." + Minor + "." + Build + "." + Revision;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
%COREVERSION%=0
|
||||
%REVISION%=1615
|
||||
%REVISION%=1627
|
||||
%MINOR%=3
|
||||
%MAJOR%=3
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
type Node<T> = auto class
|
||||
data: T;
|
||||
left,right: Node<T>;
|
||||
end;
|
||||
|
||||
function CNode<T>(x: T; l: Node<T> := nil;
|
||||
r: Node<T> := nil): Node<T> := new Node<T>(x,l,r);
|
||||
|
||||
function Infix<T>(root: Node<T>): sequence of T;
|
||||
begin
|
||||
if root = nil then exit;
|
||||
yield sequence Infix(root.left);
|
||||
yield root.data;
|
||||
yield sequence Infix(root.right);
|
||||
end;
|
||||
|
||||
begin
|
||||
var root := CNode(1,CNode(2,CNode(3),CNode(4)),CNode(5));
|
||||
Infix(root).Print;
|
||||
end.
|
||||
|
|
@ -2,7 +2,7 @@
|
|||
// This CSharp output file generated by Gardens Point LEX
|
||||
// Version: 1.1.3.301
|
||||
// Machine: DESKTOP-A6LT9RI
|
||||
// DateTime: 12.01.2018 11:43:58
|
||||
// DateTime: 17.01.2018 0:27:09
|
||||
// UserName: ?????????
|
||||
// GPLEX input file <ABCPascal.lex>
|
||||
// GPLEX frame file <embedded resource>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
// GPPG version 1.3.6
|
||||
// Machine: DESKTOP-A6LT9RI
|
||||
// DateTime: 12.01.2018 11:43:59
|
||||
// DateTime: 17.01.2018 0:27:10
|
||||
// UserName: ?????????
|
||||
// Input file <ABCPascal.y>
|
||||
|
||||
|
|
|
|||
|
|
@ -188,5 +188,6 @@ script=
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -1 +1 @@
|
|||
!define VERSION '3.3.0.1615'
|
||||
!define VERSION '3.3.0.1627'
|
||||
|
|
|
|||
14
TestSuite/Average4funs.pas
Normal file
14
TestSuite/Average4funs.pas
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
{function Average1<TSource>(Self: sequence of TSource; selector: TSource -> integer): real; extensionmethod;
|
||||
begin
|
||||
|
||||
end;
|
||||
|
||||
function Average1<TSource>(Self: sequence of TSource; selector: TSource -> real): real; extensionmethod;
|
||||
begin
|
||||
end;}
|
||||
|
||||
begin
|
||||
var pupils : array of integer := (1,2,3);
|
||||
var r := pupils.Average(p->p);
|
||||
Assert(abs(r - 2)<0.000001);
|
||||
end.
|
||||
|
|
@ -481,6 +481,10 @@ type
|
|||
procedure Write(params vals: array of object);
|
||||
/// Устанавливает файловый указатель на начало файла
|
||||
procedure Reset;
|
||||
/// Возвращает имя файла
|
||||
function Name: string;
|
||||
/// Возвращает полное имя файла
|
||||
function FullName: string;
|
||||
end;
|
||||
|
||||
// Class for typed files
|
||||
|
|
@ -499,8 +503,6 @@ type
|
|||
function FilePos: int64;
|
||||
/// Возвращает количество элементов в типизированном файле
|
||||
function FileSize: int64;
|
||||
/// Устанавливает текущую позицию файлового указателя в типизированном файле на элемент с номером n
|
||||
procedure Seek(n: int64);
|
||||
end;
|
||||
|
||||
// Class for binary files
|
||||
|
|
@ -3351,10 +3353,7 @@ function string.operator in(substr: string; str: string) := str.Contains(substr)
|
|||
|
||||
procedure operator+=(var left: StringBuilder; right: string); extensionmethod := left.Append(right);
|
||||
|
||||
function operator implicit(s: string): StringBuilder; extensionmethod;
|
||||
begin
|
||||
Result := new StringBuilder(s);
|
||||
end;
|
||||
function operator implicit(s: string): StringBuilder; extensionmethod := new StringBuilder(s);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Операции для array of T
|
||||
|
|
@ -5356,6 +5355,18 @@ begin
|
|||
PABCSystem.Reset(Self);
|
||||
end;
|
||||
|
||||
function AbstractBinaryFile.Name: string;
|
||||
begin
|
||||
Result := fi.Name
|
||||
end;
|
||||
|
||||
function AbstractBinaryFile.FullName: string;
|
||||
begin
|
||||
Result := fi.FullName
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------
|
||||
// TypedFile & BinaryFile methods
|
||||
// -----------------------------------------------------
|
||||
|
|
@ -5369,11 +5380,6 @@ begin
|
|||
Result := PABCSystem.FileSize(Self);
|
||||
end;
|
||||
|
||||
procedure TypedFile.Seek(n: int64);
|
||||
begin
|
||||
PABCSystem.Seek(Self, n);
|
||||
end;
|
||||
|
||||
function BinaryFile.FilePos: int64;
|
||||
begin
|
||||
Result := PABCSystem.FilePos(Self);
|
||||
|
|
@ -8156,6 +8162,71 @@ type
|
|||
end;
|
||||
end;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//>> Метод расширения Print для элементарных типов
|
||||
//------------------------------------------------------------------------------
|
||||
function Print(Self: integer): integer; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Print(Self: real): real; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Print(Self: char): char; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Print(Self: boolean): boolean; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Print(Self: BigInteger): BigInteger; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: integer): integer; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: real): real; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: char): char; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: boolean): boolean; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: BigInteger): BigInteger; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//>> Методы расширения для sequence of T # Extension methods for sequence of T
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -2036,7 +2036,7 @@ type
|
|||
Result := pmb.ToMeshGeometry3D
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
PrismT = class(ObjectWithMaterial3D)
|
||||
private
|
||||
function Model := inherited model as PrismVisual3D;
|
||||
|
|
@ -2265,6 +2265,17 @@ type
|
|||
end;
|
||||
end;
|
||||
|
||||
My13D = class(MeshElement3D)
|
||||
public function Tessellate(): MeshGeometry3D; override;
|
||||
begin
|
||||
var tm := new MeshBuilder(false, false);
|
||||
tm.AddRevolvedGeometry(Arr(Pnt(0,0),Pnt(0,1),Pnt(0.3,1),Pnt(0.5,0.3),Pnt(2,1),Pnt(3,0)),nil,Origin,OrtZ,80);
|
||||
Result := tm.ToMesh(false);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
type
|
||||
AnyT = class(ObjectWithMaterial3D)
|
||||
constructor(x, y, z: real; c: GColor);
|
||||
|
|
@ -2277,10 +2288,14 @@ type
|
|||
//var a := new TerrainVisual3D;
|
||||
//a.Content := (new SphereVisual3D()).Model;
|
||||
//a.Text := 'PascalABC';
|
||||
var a := new LinesVisual3D;
|
||||
a.Thickness := 1.99;
|
||||
//a.Points := Arr(P3D(0, 0, 0), P3D(3, 0, 0), P3D(3, 0, 0), P3D(3, 3, 0), P3D(3, 3, 0), P3D(3, 3, 3));
|
||||
a.Color := c;
|
||||
//var a := new LinesVisual3D;
|
||||
{a.Thickness := 1.99;
|
||||
a.Points := Arr(P3D(0, 0, 0), P3D(3, 0, 0), P3D(3, 0, 0), P3D(3, 3, 0), P3D(3, 3, 0), P3D(3, 3, 3));
|
||||
a.Color := c;}
|
||||
|
||||
var a := new My13D;
|
||||
a.Material := c;
|
||||
|
||||
|
||||
{var aa := 1;
|
||||
var b := 80;
|
||||
|
|
@ -2315,61 +2330,66 @@ type
|
|||
end;
|
||||
end;
|
||||
|
||||
// function Inv<T>(p: ()->T): T := Invoke&<T>(p); // посмотреть, почему не выводится!
|
||||
|
||||
var DefaultMaterialColor := Colors.Red;
|
||||
function DefaultMaterial := MaterialHelper.CreateMaterial(DefaultMaterialColor);
|
||||
|
||||
function Group(x, y, z: integer): GroupT := Invoke&<GroupT>(()->GroupT.Create(x, y, z));
|
||||
function Group(p: Point3D): GroupT := Invoke&<GroupT>(()->GroupT.Create(p.x, p.y, p.z));
|
||||
function Group: GroupT := Invoke&<GroupT>(()->GroupT.Create(0, 0, 0));
|
||||
function Group(params lst: array of Object3D): GroupT := Invoke&<GroupT>(()->GroupT.Create(0, 0, 0, lst));
|
||||
function Group(en: sequence of Object3D): GroupT := Invoke&<GroupT>(()->GroupT.Create(0, 0, 0, en));
|
||||
|
||||
function Sphere(x, y, z, r: real; m: Material): SphereT := Invoke&<SphereT>(()->SphereT.Create(x, y, z, r, m));
|
||||
function Sphere(center: Point3D; r: real; m: Material) := Sphere(center.x, center.y, center.z, r, m);
|
||||
function Sphere(x, y, z, r: real; m: Material := DefaultMaterial): SphereT := Invoke&<SphereT>(()->SphereT.Create(x, y, z, r, m));
|
||||
function Sphere(center: Point3D; r: real; m: Material := DefaultMaterial) := Sphere(center.x, center.y, center.z, r, m);
|
||||
|
||||
function Ellipsoid(x, y, z, rx, ry, rz: real; m: Material): EllipsoidT := Invoke&<EllipsoidT>(()->EllipsoidT.Create(x, y, z, rx, ry, rz, m));
|
||||
function Ellipsoid(center: Point3D; rx, ry, rz: real; m: Material): EllipsoidT := Ellipsoid(center.x, center.y, center.z, rx, ry, rz, m);
|
||||
function Ellipsoid(x, y, z, rx, ry, rz: real; m: Material := DefaultMaterial): EllipsoidT := Invoke&<EllipsoidT>(()->EllipsoidT.Create(x, y, z, rx, ry, rz, m));
|
||||
function Ellipsoid(center: Point3D; rx, ry, rz: real; m: Material := DefaultMaterial): EllipsoidT := Ellipsoid(center.x, center.y, center.z, rx, ry, rz, m);
|
||||
|
||||
function Box(x, y, z, l, w, h: real; m: Material): BoxT := Invoke&<BoxT>(()->BoxT.Create(x, y, z, l, w, h, m));
|
||||
function Box(center: Point3D; sz: Size3D; m: Material): BoxT := Invoke&<BoxT>(()->BoxT.Create(center.x, center.y, center.z, sz.X, sz.Y, sz.z, m));
|
||||
function Box(x, y, z, l, w, h: real; m: Material := DefaultMaterial): BoxT := Invoke&<BoxT>(()->BoxT.Create(x, y, z, l, w, h, m));
|
||||
function Box(center: Point3D; sz: Size3D; m: Material := DefaultMaterial): BoxT := Invoke&<BoxT>(()->BoxT.Create(center.x, center.y, center.z, sz.X, sz.Y, sz.z, m));
|
||||
|
||||
function Cube(x, y, z, w: real; m: Material): BoxT := Box(x, y, z, w, w, w, m);
|
||||
function Cube(center: Point3D; w: real; m: Material): BoxT := Box(center.x, center.y, center.z, w, w, w, m);
|
||||
function Cube(x, y, z, w: real; m: Material := DefaultMaterial): BoxT := Box(x, y, z, w, w, w, m);
|
||||
function Cube(center: Point3D; w: real; m: Material := DefaultMaterial): BoxT := Box(center.x, center.y, center.z, w, w, w, m);
|
||||
|
||||
const
|
||||
arhl = 3;
|
||||
ard = 0.2;
|
||||
|
||||
function Arrow(x, y, z, vx, vy, vz, diameter, hl: real; c: Material): ArrowT := Invoke&<ArrowT>(()->ArrowT.Create(x, y, z, vx, vy, vz, diameter, hl, c));
|
||||
function Arrow(x, y, z, vx, vy, vz, diameter: real; c: Material) := Arrow(x, y, z, vx, vy, vz, diameter, arhl, c);
|
||||
function Arrow(x, y, z, vx, vy, vz: real; c: Material): ArrowT := Arrow(x, y, z, vx, vy, vz, ard, arhl, c);
|
||||
function Arrow(p: Point3D; v: Vector3D; diameter, hl: real; c: Material) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, hl, c);
|
||||
function Arrow(p: Point3D; v: Vector3D; diameter: real; c: Material) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, arhl, c);
|
||||
function Arrow(p: Point3D; v: Vector3D; c: Material) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, ard, arhl, c);
|
||||
function Arrow(x, y, z, vx, vy, vz, diameter, hl: real; c: Material := DefaultMaterial): ArrowT := Invoke&<ArrowT>(()->ArrowT.Create(x, y, z, vx, vy, vz, diameter, hl, c));
|
||||
function Arrow(x, y, z, vx, vy, vz, diameter: real; c: Material := DefaultMaterial) := Arrow(x, y, z, vx, vy, vz, diameter, arhl, c);
|
||||
function Arrow(x, y, z, vx, vy, vz: real; c: Material := DefaultMaterial): ArrowT := Arrow(x, y, z, vx, vy, vz, ard, arhl, c);
|
||||
function Arrow(p: Point3D; v: Vector3D; diameter, hl: real; c: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, hl, c);
|
||||
function Arrow(p: Point3D; v: Vector3D; diameter: real; c: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, arhl, c);
|
||||
function Arrow(p: Point3D; v: Vector3D; c: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, ard, arhl, c);
|
||||
|
||||
function TruncatedConeAux(x, y, z, height, baseradius, topradius: real; sides: integer; topcap: boolean; c: Material) := Invoke&<TruncatedConeT>(()->TruncatedConeT.Create(x, y, z, height, baseradius, topradius, sides, topcap, c));
|
||||
|
||||
const maxsides = 37;
|
||||
|
||||
///--
|
||||
function TruncatedCone(x, y, z, height, baseradius, topradius: real; topcap: boolean; c: Material): TruncatedConeT := TruncatedConeAux(x, y, z, height, baseradius, topradius, maxsides, topcap, c);
|
||||
function TruncatedCone(x, y, z, height, baseradius, topradius: real; c: Material) := TruncatedCone(x, y, z, height, baseradius, topradius, True, c);
|
||||
function TruncatedCone(x, y, z, height, baseradius, topradius: real; topcap: boolean; c: Material := DefaultMaterial): TruncatedConeT := TruncatedConeAux(x, y, z, height, baseradius, topradius, maxsides, topcap, c);
|
||||
function TruncatedCone(x, y, z, height, baseradius, topradius: real; c: Material := DefaultMaterial) := TruncatedCone(x, y, z, height, baseradius, topradius, True, c);
|
||||
///--
|
||||
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; topcap: boolean; c: Material) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, topcap, c);
|
||||
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; c: Material) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, True, c);
|
||||
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; topcap: boolean; c: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, topcap, c);
|
||||
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; c: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, True, c);
|
||||
|
||||
///--
|
||||
function Cylinder(x, y, z, height, radius: real; topcap: boolean; c: Material): CylinderT := Invoke&<CylinderT>(()->CylinderT.Create(x, y, z, height, radius, maxsides, topcap, c));
|
||||
function Cylinder(x, y, z, height, radius: real; c: Material) := Cylinder(x, y, z, height, radius, True, c);
|
||||
function Cylinder(x, y, z, height, radius: real; topcap: boolean; c: Material := DefaultMaterial): CylinderT := Invoke&<CylinderT>(()->CylinderT.Create(x, y, z, height, radius, maxsides, topcap, c));
|
||||
function Cylinder(x, y, z, height, radius: real; c: Material := DefaultMaterial) := Cylinder(x, y, z, height, radius, True, c);
|
||||
///--
|
||||
function Cylinder(p: Point3D; height, radius: real; topcap: boolean; c: Material) := Cylinder(p.x, p.y, p.z, height, radius, topcap, c);
|
||||
function Cylinder(p: Point3D; height, radius: real; c: Material) := Cylinder(p.x, p.y, p.z, height, radius, True, c);
|
||||
function Cylinder(p: Point3D; height, radius: real; topcap: boolean; c: Material := DefaultMaterial) := Cylinder(p.x, p.y, p.z, height, radius, topcap, c);
|
||||
function Cylinder(p: Point3D; height, radius: real; c: Material := DefaultMaterial) := Cylinder(p.x, p.y, p.z, height, radius, True, c);
|
||||
|
||||
function Tube(x, y, z, height, radius, innerradius: real; c: Material): PipeT := Invoke&<PipeT>(()->PipeT.Create(x, y, z, height, radius, innerradius, c));
|
||||
function Tube(p: Point3D; height, radius, innerradius: real; c: Material) := Tube(p.x, p.y, p.z, height, radius, innerradius, c);
|
||||
function Tube(x, y, z, height, radius, innerradius: real; c: Material := DefaultMaterial): PipeT := Invoke&<PipeT>(()->PipeT.Create(x, y, z, height, radius, innerradius, c));
|
||||
function Tube(p: Point3D; height, radius, innerradius: real; c: Material := DefaultMaterial) := Tube(p.x, p.y, p.z, height, radius, innerradius, c);
|
||||
|
||||
function Cone(x, y, z, height, radius: real; c: Material): TruncatedConeT := TruncatedCone(x, y, z, height, radius, 0, True, c);
|
||||
function Cone(p: Point3D; height, radius: real; c: Material) := TruncatedCone(p.x, p.y, p.z, height, radius, 0, True, c);
|
||||
function Cone(x, y, z, height, radius: real; c: Material := DefaultMaterial): TruncatedConeT := TruncatedCone(x, y, z, height, radius, 0, True, c);
|
||||
function Cone(p: Point3D; height, radius: real; c: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, height, radius, 0, True, c);
|
||||
|
||||
function Teapot(x, y, z: real; c: Material): TeapotT := Invoke&<TeapotT>(()->TeapotT.Create(x, y, z, c));
|
||||
function Teapot(p: Point3D; c: Material) := Teapot(p.x, p.y, p.z, c);
|
||||
function Teapot(x, y, z: real; c: Material := DefaultMaterial): TeapotT := Invoke&<TeapotT>(()->TeapotT.Create(x, y, z, c));
|
||||
function Teapot(p: Point3D; c: Material := DefaultMaterial) := Teapot(p.x, p.y, p.z, c);
|
||||
|
||||
function BillboardText(x, y, z: real; text: string; fontsize: real := 12): BillboardTextT := Invoke&<BillboardTextT>(()->BillboardTextT.Create(x, y, z, text, fontsize));
|
||||
function BillboardText(p: Point3D; text: string; fontsize: real := 12) := BillboardText(P.x, p.y, p.z, text, fontsize);
|
||||
|
|
@ -2377,56 +2397,52 @@ function BillboardText(p: Point3D; text: string; fontsize: real := 12) := Billbo
|
|||
function CoordinateSystem(arrowslength, diameter: real): CoordinateSystemT := Invoke&<CoordinateSystemT>(()->CoordinateSystemT.Create(0, 0, 0, arrowslength, diameter));
|
||||
function CoordinateSystem(arrowslength: real) := CoordinateSystem(arrowslength, arrowslength / 10);
|
||||
|
||||
function Text3D(x, y, z: real; text: string; height: real; fontname: string; c: Color): TextT := Invoke&<TextT>(()->TextT.Create(x, y, z, text, height, fontname, c));
|
||||
function Text3D(p: Point3D; text: string; height: real; fontname: string; c: Color) := Text3D(P.x, p.y, p.z, text, height, fontname, c);
|
||||
function Text3D(x, y, z: real; text: string; height: real; fontname: string := 'Arial'; c: Color := Colors.Black): TextT := Invoke&<TextT>(()->TextT.Create(x, y, z, text, height, fontname, c));
|
||||
function Text3D(p: Point3D; text: string; height: real; fontname: string := 'Arial'; c: Color := Colors.Black) := Text3D(P.x, p.y, p.z, text, height, fontname, c);
|
||||
function Text3D(x, y, z: real; text: string; height: real; c: Color) := Text3D(x, y, z, text, height, 'Arial', c);
|
||||
function Text3D(p: Point3D; text: string; height: real; c: Color) := Text3D(p.x, p.y, p.z, text, height, 'Arial', c);
|
||||
function Text3D(x, y, z: real; text: string; height: real) := Text3D(x, y, z, text, height, 'Arial', Colors.Black);
|
||||
function Text3D(p: Point3D; text: string; height: real) := Text3D(p.x, p.y, p.z, text, height, 'Arial', Colors.Black);
|
||||
|
||||
function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; c: Material): RectangleT := Invoke&<RectangleT>(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, c));
|
||||
function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; c: Material): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, c);
|
||||
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material): RectangleT := Rectangle3D(x, y, z, l, w, normal, OrtX, c);
|
||||
function Rectangle3D(x, y, z, l, w: real; c: Material): RectangleT := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, c);
|
||||
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, c);
|
||||
function Rectangle3D(p: Point3D; l, w: real; c: Material): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, c);
|
||||
function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; c: Material := DefaultMaterial): RectangleT := Invoke&<RectangleT>(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, c));
|
||||
function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; c: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, c);
|
||||
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material := DefaultMaterial): RectangleT := Rectangle3D(x, y, z, l, w, normal, OrtX, c);
|
||||
function Rectangle3D(x, y, z, l, w: real; c: Material := DefaultMaterial): RectangleT := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, c);
|
||||
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, c);
|
||||
function Rectangle3D(p: Point3D; l, w: real; c: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, c);
|
||||
|
||||
/// Загружает модель из файла .obj, .3ds, .lwo, .objz, .stl, .off
|
||||
function FileModel3D(x, y, z: real; fname: string; c: Material): FileModelT := Invoke&<FileModelT>(()->FileModelT.Create(x, y, z, fname, c));
|
||||
function FileModel3D(p: Point3D; fname: string; c: Material): FileModelT := FileModel3D(p.x, p.y, p.z, fname, c);
|
||||
|
||||
function Prism(x, y, z: real; Sides: integer; Radius, Height: real; c: Material): PrismT := Invoke&<PrismT>(()->PrismT.Create(x, y, z, Sides, Radius, Height, c));
|
||||
function Prism(p: Point3D; Sides: integer; Radius, Height: real; c: Material): PrismT := Prism(p.X, p.Y, p.Z, Sides, Radius, Height, c);
|
||||
function Prism(x, y, z: real; Sides: integer; Radius, Height: real; c: Material := DefaultMaterial): PrismT := Invoke&<PrismT>(()->PrismT.Create(x, y, z, Sides, Radius, Height, c));
|
||||
function Prism(p: Point3D; Sides: integer; Radius, Height: real; c: Material := DefaultMaterial): PrismT := Prism(p.X, p.Y, p.Z, Sides, Radius, Height, c);
|
||||
|
||||
function PrismWireFrame(x, y, z: real; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := Invoke&<PrismTWireFrame>(()->PrismTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
||||
function PrismWireFrame(p: Point3D; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := PrismWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
||||
|
||||
function Pyramid(x, y, z: real; Sides: integer; Radius, Height: real; c: Material): PyramidT := Invoke&<PyramidT>(()->PyramidT.Create(x, y, z, Sides, Radius, Height, c));
|
||||
function Pyramid(p: Point3D; Sides: integer; Radius, Height: real; c: Material): PyramidT := Pyramid(p.X, p.Y, p.Z, Sides, Radius, Height, c);
|
||||
function Pyramid(x, y, z: real; Sides: integer; Radius, Height: real; c: Material := DefaultMaterial): PyramidT := Invoke&<PyramidT>(()->PyramidT.Create(x, y, z, Sides, Radius, Height, c));
|
||||
function Pyramid(p: Point3D; Sides: integer; Radius, Height: real; c: Material := DefaultMaterial): PyramidT := Pyramid(p.X, p.Y, p.Z, Sides, Radius, Height, c);
|
||||
|
||||
function PyramidWireFrame(x, y, z: real; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := Invoke&<PyramidTWireFrame>(()->PyramidTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
||||
function PyramidWireFrame(p: Point3D; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := PyramidWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
||||
|
||||
function Lego(x, y, z: real; col, r, h: integer; c: Color): LegoT := Invoke&<LegoT>(()->LegoT.Create(x, y, z, col, r, h, c));
|
||||
function Lego(x, y, z: real; col, r, h: integer; c: Material := DefaultMaterial): LegoT := Invoke&<LegoT>(()->LegoT.Create(x, y, z, col, r, h, c));
|
||||
|
||||
function Icosahedron(x, y, z, R: real; c: Material): IcosahedronT := Invoke&<IcosahedronT>(()->IcosahedronT.Create(x, y, z, 4*R/Sqrt(2)/Sqrt(5+Sqrt(5)), c));
|
||||
function Dodecahedron(x, y, z, R: real; c: Material): DodecahedronT := Invoke&<DodecahedronT>(()->DodecahedronT.Create(x, y, z, R*4/Sqrt(3)/(1+Sqrt(5)), c));
|
||||
function Tetrahedron(x, y, z, R: real; c: Material): TetrahedronT := Invoke&<TetrahedronT>(()->TetrahedronT.Create(x, y, z, 4*R/Sqrt(6), c));
|
||||
function Octahedron(x, y, z, R: real; c: Material): OctahedronT := Invoke&<OctahedronT>(()->OctahedronT.Create(x, y, z, R*Sqrt(2), c));
|
||||
function Icosahedron(p: Point3D; R: real; c: Material): IcosahedronT := Icosahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Dodecahedron(p: Point3D; R: real; c: Material): DodecahedronT := Dodecahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Tetrahedron(p: Point3D; R: real; c: Material): TetrahedronT := Tetrahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Octahedron(p: Point3D; R: real; c: Material): OctahedronT := Octahedron(p.X,p.Y,p.Z,R,c);
|
||||
|
||||
//function Inv<T>(p: ()->T): T := Invoke&<T>(p); // посмотреть, почему не выводится!
|
||||
function Icosahedron(x, y, z, R: real; c: Material := DefaultMaterial): IcosahedronT := Invoke&<IcosahedronT>(()->IcosahedronT.Create(x, y, z, 4*R/Sqrt(2)/Sqrt(5+Sqrt(5)), c));
|
||||
function Dodecahedron(x, y, z, R: real; c: Material := DefaultMaterial): DodecahedronT := Invoke&<DodecahedronT>(()->DodecahedronT.Create(x, y, z, R*4/Sqrt(3)/(1+Sqrt(5)), c));
|
||||
function Tetrahedron(x, y, z, R: real; c: Material := DefaultMaterial): TetrahedronT := Invoke&<TetrahedronT>(()->TetrahedronT.Create(x, y, z, 4*R/Sqrt(6), c));
|
||||
function Octahedron(x, y, z, R: real; c: Material := DefaultMaterial): OctahedronT := Invoke&<OctahedronT>(()->OctahedronT.Create(x, y, z, R*Sqrt(2), c));
|
||||
function Icosahedron(p: Point3D; R: real; c: Material := DefaultMaterial): IcosahedronT := Icosahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Dodecahedron(p: Point3D; R: real; c: Material := DefaultMaterial): DodecahedronT := Dodecahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Tetrahedron(p: Point3D; R: real; c: Material := DefaultMaterial): TetrahedronT := Tetrahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Octahedron(p: Point3D; R: real; c: Material := DefaultMaterial): OctahedronT := Octahedron(p.X,p.Y,p.Z,R,c);
|
||||
|
||||
function Segments3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create(points, thickness, c));
|
||||
function Polyline3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create(points.Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
||||
function Polygon3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create((points+points.First).Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
||||
function Segment3D(p1, p2: Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create(Seq(p1,p2), thickness, c));
|
||||
|
||||
function Torus(x, y, z, Diameter, TubeDianeter: real; c: Material): TorusT := Invoke&<TorusT>(()->TorusT.Create(x,y,z,Diameter, TubeDianeter, c));
|
||||
function Torus(p: Point3D; Diameter, TubeDianeter: real; c: Material): TorusT := Torus(p.x,p.y,p.z,Diameter,TubeDianeter,c);
|
||||
function Torus(x, y, z, Diameter, TubeDianeter: real; c: Material := DefaultMaterial): TorusT := Invoke&<TorusT>(()->TorusT.Create(x,y,z,Diameter, TubeDianeter, c));
|
||||
function Torus(p: Point3D; Diameter, TubeDianeter: real; c: Material := DefaultMaterial): TorusT := Torus(p.x,p.y,p.z,Diameter,TubeDianeter,c);
|
||||
|
||||
function MyH(x, y, z, Length: real; c: Color): MyAnyT := Invoke&<MyAnyT>(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
function MyH(x, y, z, Length: real; c: Material): MyAnyT := Invoke&<MyAnyT>(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
|
|
@ -2475,7 +2491,7 @@ begin
|
|||
//var c1 := XamlReader.Load(new System.IO.FileStream('cube.xaml',System.IO.FileMode.Open)) as CubeVisual3D;
|
||||
//hvp.Children.Add(c1);
|
||||
|
||||
var off := new offreader(nil);
|
||||
{var off := new offreader(nil);
|
||||
var s := System.IO.File.OpenRead('boxcube.off');
|
||||
off.Load(s);
|
||||
|
||||
|
|
@ -2484,18 +2500,14 @@ begin
|
|||
m1.EdgeDiameter := 0;
|
||||
m1.VertexRadius := 0;
|
||||
m1.Mesh := off.CreateMesh;
|
||||
hvp.Children.Add(m1);
|
||||
|
||||
{var m1 := new MeshGeometryVisual3D();
|
||||
m1.MeshGeometry := off.CreateMeshGeometry3D;
|
||||
hvp.Children.Add(m1);}
|
||||
|
||||
var ex := new ExtrudedVisual3D();
|
||||
ex.BackMaterial := Colors.Green;
|
||||
ex.Diameters := new DoubleCollection(Arr(1.0,1.5,1.2));
|
||||
ex.Path := new Point3DCollection(Arr(P3D(0,0,0),P3D(0,1,0),P3D(0,1,1),P3D(1,1,1)));
|
||||
hvp.Children.Add(ex);
|
||||
|
||||
{var m1 := new ModelVisual3D();
|
||||
m1.Content := off.CreateModel3D;
|
||||
hvp.Children.Add(m1);}
|
||||
|
||||
{var imp := new HelixToolkit.Wpf.ModelImporter();
|
||||
imp.Load('a.xaml',nil,False);}
|
||||
end;
|
||||
|
||||
procedure Proba2 := Invoke(ProbaP2);
|
||||
|
|
|
|||
5
TestSuite/LambdaInferenceTAsResult.pas
Normal file
5
TestSuite/LambdaInferenceTAsResult.pas
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
function Inv<T>(p: ()->T): T := p();
|
||||
|
||||
begin
|
||||
Assert(Inv(()->1)=1)
|
||||
end.
|
||||
|
|
@ -1704,7 +1704,22 @@ namespace PascalABCCompiler.TreeConverter
|
|||
SystemLibrary.SystemLibrary.init_reference_type(ctn);
|
||||
}
|
||||
|
||||
//Первый параметр - выходной. Он содержит выражения с необходимыми преобразованиями типов.
|
||||
/// <summary>
|
||||
/// Получение compiled_type_node из либо compiled_type_node либо compiled_generic_instance_type_node. Используется ниже локально
|
||||
/// </summary>
|
||||
private compiled_type_node get_compiled_type_node(type_node t)
|
||||
{
|
||||
var ctn = t as compiled_type_node;
|
||||
if (ctn == null)
|
||||
{
|
||||
var cgn = t as compiled_generic_instance_type_node;
|
||||
if (cgn != null)
|
||||
ctn = cgn.original_generic as compiled_type_node;
|
||||
}
|
||||
return ctn;
|
||||
}
|
||||
|
||||
//Первый параметр - выходной. Он содержит выражения с необходимыми преобразованиями типов.
|
||||
public function_node select_function(expressions_list parameters, SymbolInfoList functions, location loc, List<SyntaxTree.expression> syntax_nodes_parameters = null)
|
||||
{
|
||||
if (functions == null)
|
||||
|
|
@ -2105,6 +2120,119 @@ namespace PascalABCCompiler.TreeConverter
|
|||
convert_function_call_expressions(funcs[0], parameters, tcl);
|
||||
return funcs[0];
|
||||
}
|
||||
|
||||
Func<Type, bool> IsFunc = t => t.IsGenericType && t.FullName.StartsWith("System.Func");
|
||||
Func<type_node, Type> get_type = tt =>
|
||||
{
|
||||
var ct = get_compiled_type_node(tt);
|
||||
return ct?.compiled_type;
|
||||
};
|
||||
Func<type_node, bool> IsFuncT = tt =>
|
||||
{
|
||||
var ct = get_compiled_type_node(tt);
|
||||
if (ct == null)
|
||||
return false;
|
||||
Type t = ct.compiled_type;
|
||||
return IsFunc(t);
|
||||
};
|
||||
|
||||
|
||||
var ParamsCount = funcs[0].parameters.Count;
|
||||
var b = funcs.All(f => f.parameters.Count == ParamsCount);
|
||||
if (!b) break;
|
||||
|
||||
var bools = Enumerable.Range(1, funcs.Count()).Select(x => true).ToList();
|
||||
|
||||
var AllOK = true;
|
||||
for (var i=0; i < ParamsCount; i++)
|
||||
{
|
||||
// Хочу взять проекцию всех функций на i-тый параметр
|
||||
var parsi = funcs.Select(f => f.parameters[i].type);
|
||||
if (parsi.Any(p => !IsFuncT(p))) // Если какой-то параметр не функция, то пробросим его
|
||||
continue;
|
||||
|
||||
var argss = funcs.Select(f => get_type(f.parameters[i].type).GetGenericArguments()).ToArray(); // последовательность массивов параметров Func
|
||||
var cnts = argss.Select(a => a.Count());
|
||||
|
||||
var fpi = funcs[0].parameters[i];
|
||||
var cnt = get_type(fpi.type).GetGenericArguments().Count();
|
||||
// Проверю, что у остальных функций столько же параметров
|
||||
if (cnts.Any(c => c != cnts.First())) // если нет, то - всё - это ошибка - многозначность. Хотя тут уже не должно быть
|
||||
{
|
||||
AllOK = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Цикл по параметрам Func кроме последнего
|
||||
for (var k = 0; k < cnt - 1; k++)
|
||||
{
|
||||
var kpars = funcs.Select(f => get_type(f.parameters[i].type).GetGenericArguments()[k]);
|
||||
Type p0 = kpars.First();
|
||||
bool bb = kpars.All(p => p.Equals(p0));
|
||||
if (!bb)
|
||||
{
|
||||
AllOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!AllOK)
|
||||
break;
|
||||
|
||||
var kres = funcs.Select(f => get_type(f.parameters[i].type).GetGenericArguments()[cnt - 1]).ToArray();
|
||||
|
||||
//if (funcs[0].is_extension_method)
|
||||
var fldiResType = funcs[0].is_extension_method ? // странно, но всегда кво параметров в syntax_nodes_parameters на 1 меньше. Иначе падает
|
||||
((syntax_nodes_parameters[i - 1] as SyntaxTree.function_lambda_definition).RealSemTypeOfResult as compiled_type_node).compiled_type :
|
||||
((syntax_nodes_parameters[i - 1] as SyntaxTree.function_lambda_definition).RealSemTypeOfResult as compiled_type_node).compiled_type;
|
||||
|
||||
for (int n = 0; n < bools.Count; n++)
|
||||
{
|
||||
if (!fldiResType.Equals(kres[n]))
|
||||
bools[n] = false;
|
||||
}
|
||||
//var rettype_i =
|
||||
}
|
||||
if (AllOK)
|
||||
if (bools.Count(x=>x==true) == 1) // урра! нашлась ровно одна функция! мы победили!
|
||||
{
|
||||
var ind = bools.IndexOf(true);
|
||||
return funcs[ind];
|
||||
}
|
||||
|
||||
/// Проба 15.01.18 - потом удалить
|
||||
/*{
|
||||
var f1 = funcs[0];
|
||||
var f2 = funcs[1];
|
||||
for (int i = 0; i < parameters.Count; i++)
|
||||
{
|
||||
type_node f1i = f1.parameters[i].type;
|
||||
type_node f2i = f2.parameters[i].type;
|
||||
var f1ic = get_compiled_type_node(f1i);
|
||||
var f2ic = get_compiled_type_node(f2i);
|
||||
if (f1ic == null || f2ic == null)
|
||||
break;
|
||||
Type ct1 = f1ic.compiled_type;
|
||||
Type ct2 = f2ic.compiled_type;
|
||||
if (IsFunc(ct1) && IsFunc(ct2))
|
||||
{
|
||||
var l1 = ct1.GetGenericArguments()[0];
|
||||
var l2 = ct2.GetGenericArguments()[0];
|
||||
var b = l1.Equals(l2);
|
||||
var b1 = l1 == l2;
|
||||
}
|
||||
//var p = syntax_nodes_parameters[i];
|
||||
}
|
||||
|
||||
}*/
|
||||
|
||||
// Вот здесь нужен анализ всех оставшихся функций.
|
||||
// Если они отличаются только функциональными параметрами и у этих параметров
|
||||
// одинаковый тип параметров (они уже инстанцированы!), то надо еще раз
|
||||
// вызвать то, что вызывается в DeduceFunction чтобы установить, каков тип возвращаемого значения лямбды, после чего
|
||||
// выбрать либо функцию из оставшихся с ровно совпадающим типом лямбды либо с ближайшим
|
||||
// (остались только те, к которым можно преобразовать)
|
||||
// Некоторая проблема будет если лямбд останется несколько и расстояния до результата будут разными и ненулевыми везде
|
||||
|
||||
if (funcs.Count == 2) // SSM - это ужасный способ устранения бага #236 Range(1,10).Sum(e -> e); Для хорошего способа весь код выбора версий функций для делегатов надо переписывать
|
||||
{
|
||||
var f1 = funcs[0];
|
||||
|
|
@ -2156,6 +2284,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
return f1;
|
||||
}
|
||||
}
|
||||
|
||||
/*if (f1.return_value_type != null && f2.return_value_type != null)
|
||||
{
|
||||
var p1 = f1.return_value_type;
|
||||
|
|
|
|||
|
|
@ -5041,7 +5041,7 @@ namespace PascalABCCompiler.TreeConverter
|
|||
{
|
||||
ThrowCompilationError = false;
|
||||
function_node ffn = convertion_data_and_alghoritms.select_function(exprs, sil, subloc, syntax_nodes_parameters);
|
||||
if (ffn == null)
|
||||
if (ffn == null)
|
||||
{
|
||||
if (skip_first_parameter)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -649,13 +649,13 @@ namespace PascalABCCompiler.TreeRealization
|
|||
var result = true;
|
||||
exception_on_body_compilation = null;
|
||||
|
||||
if (lambda_syntax_node.formal_parameters == null
|
||||
/*if (lambda_syntax_node.formal_parameters == null
|
||||
|| lambda_syntax_node.formal_parameters.params_list == null
|
||||
|| lambda_syntax_node.formal_parameters.params_list.Count == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}*/
|
||||
if (lambda_syntax_node.formal_parameters != null)
|
||||
foreach (var t in lambda_syntax_node.formal_parameters.params_list)
|
||||
{
|
||||
var lambdaInfType = t.vars_type as lambda_inferred_type;
|
||||
|
|
@ -885,14 +885,15 @@ namespace PascalABCCompiler.TreeRealization
|
|||
}
|
||||
|
||||
foreach (var formal_delegate in formal_delegates)
|
||||
//Перебираем все полученные формальные параемтры, соотвтетсвующие фактическим лямбдам
|
||||
// Перебираем все полученные формальные параметры, соответствующие фактическим лямбдам
|
||||
{
|
||||
var lambda_syntax_node = lambda_syntax_nodes[formal_delegate.Key];
|
||||
Exception on_lambda_body_compile_exception;
|
||||
// Исключение которое может возникнуть в результате компиляции тела лямбды если мы выберем неправильные типы параметров
|
||||
if (!TryToDeduceTypesInLambda(lambda_syntax_node, formal_delegate.Value, deduced, nils,
|
||||
out on_lambda_body_compile_exception))
|
||||
//Пробуем вычислить типы из лямбд
|
||||
// Исключение которое может возникнуть в результате компиляции тела лямбды если мы выберем неправильные типы параметров
|
||||
var b = TryToDeduceTypesInLambda(lambda_syntax_node, formal_delegate.Value, deduced, nils,
|
||||
out on_lambda_body_compile_exception);
|
||||
if (!b)
|
||||
// Пробуем вычислить типы из лямбд
|
||||
{
|
||||
RestoreLambdasStates(lambda_syntax_nodes.Values.ToList(), saved_lambdas_states);
|
||||
|
||||
|
|
|
|||
|
|
@ -122,6 +122,7 @@ function InvokeString(d: Func0<string>): string := Invoke&<String>(d);
|
|||
function InvokeReal(d: Func0<real>): real := Invoke&<Real>(d);
|
||||
function InvokeBoolean(d: Func0<boolean>): boolean := Invoke&<boolean>(d);
|
||||
function InvokeInteger(d: Func0<integer>): integer := Invoke&<integer>(d);
|
||||
function Inv<T>(p: ()->T): T := Invoke&<T>(p); // Теперь это работает!
|
||||
|
||||
function wplus := SystemParameters.WindowResizeBorderThickness.Left + SystemParameters.WindowResizeBorderThickness.Right;
|
||||
|
||||
|
|
@ -426,7 +427,7 @@ type
|
|||
function GetPos: Point3D := Invoke&<Point3D>(()->P3D(transltransform.OffsetX, transltransform.OffsetY, transltransform.OffsetZ));
|
||||
|
||||
protected
|
||||
function CreateObject: Object3D; virtual;
|
||||
function CreateObject: Object3D; virtual; // нужно для клонирования
|
||||
begin
|
||||
Result := nil;
|
||||
end;
|
||||
|
|
@ -629,6 +630,8 @@ type
|
|||
begin
|
||||
CreateBase0(m, x, y, z);
|
||||
m.Material := mat;
|
||||
//MaterialHelper.ChangeOpacity(mat,0.1);
|
||||
//MaterialHelper.ChangeOpacity(BackMaterial,0.1);
|
||||
//m.BackMaterial := nil;
|
||||
end;
|
||||
|
||||
|
|
@ -1183,17 +1186,14 @@ function MyAnimation.&Then(second: MyAnimation): MyAnimation := Self + second;
|
|||
type
|
||||
SphereT = class(ObjectWithMaterial3D)
|
||||
private
|
||||
procedure SetR(r: real);
|
||||
begin
|
||||
var m := model as SphereVisual3D;
|
||||
Invoke(()->begin m.Radius := r end);
|
||||
end;
|
||||
|
||||
function GetR: real := InvokeReal(()->(model as SphereVisual3D).Radius);
|
||||
function Model := inherited model as SphereVisual3D;
|
||||
procedure SetRP(r: real) := Model.Radius := r;
|
||||
procedure SetR(r: real) := Invoke(SetRP,r);
|
||||
function GetR: real := InvokeReal(()->Model.Radius);
|
||||
function NewVisualObject(r: real): SphereVisual3D;
|
||||
begin
|
||||
var sph := new SphereVisual3D;
|
||||
sph.Center := P3D(0, 0, 0);
|
||||
sph.Center := Origin;
|
||||
sph.Radius := r;
|
||||
Result := sph;
|
||||
end;
|
||||
|
|
@ -1211,25 +1211,25 @@ type
|
|||
private
|
||||
function Model := inherited model as EllipsoidVisual3D;
|
||||
procedure SetRXP(r: real) := Model.RadiusX := r;
|
||||
procedure SetRX(r: real) := Invoke(SetRXP, x);
|
||||
procedure SetRX(r: real) := Invoke(SetRXP, r);
|
||||
function GetRX: real := InvokeReal(()->Model.RadiusX);
|
||||
procedure SetRYP(r: real) := Model.RadiusY := r;
|
||||
procedure SetRY(r: real) := Invoke(SetRYP, x);
|
||||
procedure SetRY(r: real) := Invoke(SetRYP, r);
|
||||
function GetRY: real := InvokeReal(()->Model.RadiusY);
|
||||
procedure SetRZP(r: real) := Model.RadiusZ := r;
|
||||
procedure SetRZ(r: real) := Invoke(SetRZP, x);
|
||||
procedure SetRZ(r: real) := Invoke(SetRZP, r);
|
||||
function GetRZ: real := InvokeReal(()->Model.RadiusZ);
|
||||
function NewVisualObject(rx, ry, rz: real): HelixToolkit.Wpf.EllipsoidVisual3D;
|
||||
function NewVisualObject(rx, ry, rz: real): EllipsoidVisual3D;
|
||||
begin
|
||||
var ell := new EllipsoidVisual3D;
|
||||
ell.Center := P3D(0, 0, 0);
|
||||
ell.Center := Origin;
|
||||
ell.RadiusX := rx;
|
||||
ell.RadiusY := ry;
|
||||
ell.RadiusZ := rz;
|
||||
Result := ell;
|
||||
end;
|
||||
protected
|
||||
function CreateObject: Object3D; override := new EllipsoidT(X, Y, Z, RadiusX, RadiusY, RadiusZ, Material);
|
||||
function CreateObject: Object3D; override := new EllipsoidT(X, Y, Z, RadiusX, RadiusY, RadiusZ, Material.Clone);
|
||||
public
|
||||
constructor(x, y, z, rx, ry, rz: real; m: GMaterial) := CreateBase(NewVisualObject(rx, ry, rz), x, y, z, m);
|
||||
|
||||
|
|
@ -1239,6 +1239,29 @@ type
|
|||
function Clone := (inherited Clone) as EllipsoidT;
|
||||
end;
|
||||
|
||||
CubeT = class(ObjectWithMaterial3D)
|
||||
private
|
||||
function model := inherited model as CubeVisual3D;
|
||||
procedure SetWP(r: real) := model.SideLength := r;
|
||||
procedure SetW(r: real) := Invoke(SetWP, r);
|
||||
function GetW: real := InvokeReal(()->model.SideLength);
|
||||
private
|
||||
function NewVisualObject(w: real): CubeVisual3D;
|
||||
begin
|
||||
var bx := new CubeVisual3D;
|
||||
bx.Center := Origin;
|
||||
bx.SideLength := w;
|
||||
Result := bx;
|
||||
end;
|
||||
protected
|
||||
function CreateObject: Object3D; override := new CubeT(X, Y, Z, SideLength, Material.Clone);
|
||||
public
|
||||
constructor(x, y, z, w: real; m: GMaterial) := CreateBase(NewVisualObject(w), x, y, z, m);
|
||||
|
||||
property SideLength: real read GetW write SetW;
|
||||
function Clone := (inherited Clone) as CubeT;
|
||||
end;
|
||||
|
||||
BoxT = class(ObjectWithMaterial3D)
|
||||
private
|
||||
function model := inherited model as BoxVisual3D;
|
||||
|
|
@ -1255,14 +1278,13 @@ type
|
|||
function GetL: real := InvokeReal(()->model.Length);
|
||||
|
||||
procedure SetSzP(r: Size3D) := (model.Length, model.Width, model.Height) := (r.X, r.Y, r.Z);
|
||||
|
||||
procedure SetSz(r: Size3D) := Invoke(SetSzP, r);
|
||||
function GetSz: Size3D := Invoke&<Size3D>(()->begin Result := Sz3D(model.Length, model.Width, model.Height) end);
|
||||
function GetSz: Size3D := Inv(()->Sz3D(model.Length, model.Width, model.Height));
|
||||
private
|
||||
function NewVisualObject(l, w, h: real): BoxVisual3D;
|
||||
begin
|
||||
var bx := new BoxVisual3D;
|
||||
bx.Center := P3D(0, 0, 0);
|
||||
bx.Center := Origin;
|
||||
(bx.Width, bx.Height, bx.Length) := (w, h, l);
|
||||
Result := bx;
|
||||
end;
|
||||
|
|
@ -2330,123 +2352,120 @@ type
|
|||
end;
|
||||
end;
|
||||
|
||||
function Group(x, y, z: integer): GroupT := Invoke&<GroupT>(()->GroupT.Create(x, y, z));
|
||||
function Group(p: Point3D): GroupT := Invoke&<GroupT>(()->GroupT.Create(p.x, p.y, p.z));
|
||||
function Group: GroupT := Invoke&<GroupT>(()->GroupT.Create(0, 0, 0));
|
||||
function Group(params lst: array of Object3D): GroupT := Invoke&<GroupT>(()->GroupT.Create(0, 0, 0, lst));
|
||||
function Group(en: sequence of Object3D): GroupT := Invoke&<GroupT>(()->GroupT.Create(0, 0, 0, en));
|
||||
function DefaultMaterialColor := RandomColor;
|
||||
function DefaultMaterial := MaterialHelper.CreateMaterial(DefaultMaterialColor);
|
||||
|
||||
function Sphere(x, y, z, r: real; m: Material): SphereT := Invoke&<SphereT>(()->SphereT.Create(x, y, z, r, m));
|
||||
function Sphere(center: Point3D; r: real; m: Material) := Sphere(center.x, center.y, center.z, r, m);
|
||||
function Group(x, y, z: integer): GroupT := Inv(()->GroupT.Create(x, y, z));
|
||||
function Group(p: Point3D): GroupT := Inv(()->GroupT.Create(p.x, p.y, p.z));
|
||||
function Group: GroupT := Inv(()->GroupT.Create(0, 0, 0));
|
||||
function Group(params lst: array of Object3D): GroupT := Inv(()->GroupT.Create(0, 0, 0, lst));
|
||||
function Group(en: sequence of Object3D): GroupT := Inv(()->GroupT.Create(0, 0, 0, en));
|
||||
|
||||
function Ellipsoid(x, y, z, rx, ry, rz: real; m: Material): EllipsoidT := Invoke&<EllipsoidT>(()->EllipsoidT.Create(x, y, z, rx, ry, rz, m));
|
||||
function Ellipsoid(center: Point3D; rx, ry, rz: real; m: Material): EllipsoidT := Ellipsoid(center.x, center.y, center.z, rx, ry, rz, m);
|
||||
function Sphere(x, y, z, Radius: real; m: Material := DefaultMaterial): SphereT := Inv(()->SphereT.Create(x, y, z, Radius, m));
|
||||
function Sphere(center: Point3D; Radius: real; m: Material := DefaultMaterial) := Sphere(center.x, center.y, center.z, Radius, m);
|
||||
|
||||
function Box(x, y, z, l, w, h: real; m: Material): BoxT := Invoke&<BoxT>(()->BoxT.Create(x, y, z, l, w, h, m));
|
||||
function Box(center: Point3D; sz: Size3D; m: Material): BoxT := Invoke&<BoxT>(()->BoxT.Create(center.x, center.y, center.z, sz.X, sz.Y, sz.z, m));
|
||||
function Ellipsoid(x, y, z, RadiusX, RadiusY, RadiusZ: real; m: Material := DefaultMaterial): EllipsoidT := Inv(()->EllipsoidT.Create(x, y, z, RadiusX, RadiusY, RadiusZ, m));
|
||||
function Ellipsoid(center: Point3D; RadiusX, RadiusY, RadiusZ: real; m: Material := DefaultMaterial) := Ellipsoid(center.x, center.y, center.z, RadiusX, RadiusY, RadiusZ, m);
|
||||
|
||||
function Cube(x, y, z, w: real; m: Material): BoxT := Box(x, y, z, w, w, w, m);
|
||||
function Cube(center: Point3D; w: real; m: Material): BoxT := Box(center.x, center.y, center.z, w, w, w, m);
|
||||
function Cube(x, y, z, SideLength: real; m: Material := DefaultMaterial): CubeT := Inv(()->CubeT.Create(x, y, z, SideLength, m));
|
||||
function Cube(center: Point3D; SideLength: real; m: Material := DefaultMaterial): CubeT := Cube(center.x, center.y, center.z, SideLength, m);
|
||||
|
||||
const
|
||||
arhl = 3;
|
||||
ard = 0.2;
|
||||
function Box(x, y, z, SizeX, SizeY, SizeZ: real; m: Material := DefaultMaterial): BoxT := Inv(()->BoxT.Create(x, y, z, SizeX, SizeY, SizeZ, m));
|
||||
function Box(center: Point3D; sz: Size3D; m: Material := DefaultMaterial): BoxT := Inv(()->BoxT.Create(center.x, center.y, center.z, sz.X, sz.Y, sz.z, m));
|
||||
|
||||
function Arrow(x, y, z, vx, vy, vz, diameter, hl: real; c: Material): ArrowT := Invoke&<ArrowT>(()->ArrowT.Create(x, y, z, vx, vy, vz, diameter, hl, c));
|
||||
function Arrow(x, y, z, vx, vy, vz, diameter: real; c: Material) := Arrow(x, y, z, vx, vy, vz, diameter, arhl, c);
|
||||
function Arrow(x, y, z, vx, vy, vz: real; c: Material): ArrowT := Arrow(x, y, z, vx, vy, vz, ard, arhl, c);
|
||||
function Arrow(p: Point3D; v: Vector3D; diameter, hl: real; c: Material) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, hl, c);
|
||||
function Arrow(p: Point3D; v: Vector3D; diameter: real; c: Material) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, arhl, c);
|
||||
function Arrow(p: Point3D; v: Vector3D; c: Material) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, ard, arhl, c);
|
||||
const arhl = 3; ard = 0.2;
|
||||
|
||||
function TruncatedConeAux(x, y, z, height, baseradius, topradius: real; sides: integer; topcap: boolean; c: Material) := Invoke&<TruncatedConeT>(()->TruncatedConeT.Create(x, y, z, height, baseradius, topradius, sides, topcap, c));
|
||||
function Arrow(x, y, z, vx, vy, vz, diameter, hl: real; m: Material := DefaultMaterial): ArrowT := Inv(()->ArrowT.Create(x, y, z, vx, vy, vz, diameter, hl, m));
|
||||
function Arrow(x, y, z, vx, vy, vz, diameter: real; m: Material := DefaultMaterial) := Arrow(x, y, z, vx, vy, vz, diameter, arhl, m);
|
||||
function Arrow(x, y, z, vx, vy, vz: real; m: Material := DefaultMaterial) := Arrow(x, y, z, vx, vy, vz, ard, arhl, m);
|
||||
function Arrow(p: Point3D; v: Vector3D; diameter, hl: real; m: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, hl, m);
|
||||
function Arrow(p: Point3D; v: Vector3D; diameter: real; m: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, diameter, arhl, m);
|
||||
function Arrow(p: Point3D; v: Vector3D; m: Material := DefaultMaterial) := Arrow(p.x, p.y, p.z, v.X, v.Y, v.Z, ard, arhl, m);
|
||||
|
||||
function TruncatedConeAux(x, y, z, Height, Radius, TopRadius: real; sides: integer; topcap: boolean; c: Material) := Inv(()->TruncatedConeT.Create(x, y, z, Height, Radius, TopRadius, sides, topcap, c));
|
||||
|
||||
const maxsides = 37;
|
||||
|
||||
///--
|
||||
function TruncatedCone(x, y, z, height, baseradius, topradius: real; topcap: boolean; c: Material): TruncatedConeT := TruncatedConeAux(x, y, z, height, baseradius, topradius, maxsides, topcap, c);
|
||||
function TruncatedCone(x, y, z, height, baseradius, topradius: real; c: Material) := TruncatedCone(x, y, z, height, baseradius, topradius, True, c);
|
||||
function TruncatedCone(x, y, z, Height, Radius, TopRadius: real; topcap: boolean; m: Material := DefaultMaterial): TruncatedConeT := TruncatedConeAux(x, y, z, Height, Radius, TopRadius, maxsides, topcap, m);
|
||||
function TruncatedCone(x, y, z, Height, Radius, TopRadius: real; m: Material := DefaultMaterial) := TruncatedCone(x, y, z, Height, Radius, TopRadius, True, m);
|
||||
///--
|
||||
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; topcap: boolean; c: Material) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, topcap, c);
|
||||
function TruncatedCone(p: Point3D; height, baseradius, topradius: real; c: Material) := TruncatedCone(p.x, p.y, p.z, height, baseradius, topradius, True, c);
|
||||
function TruncatedCone(p: Point3D; Height, Radius, TopRadius: real; topcap: boolean; m: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, Height, Radius, TopRadius, topcap, m);
|
||||
function TruncatedCone(p: Point3D; Height, Radius, TopRadius: real; m: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, Height, Radius, TopRadius, True, m);
|
||||
|
||||
///--
|
||||
function Cylinder(x, y, z, height, radius: real; topcap: boolean; c: Material): CylinderT := Invoke&<CylinderT>(()->CylinderT.Create(x, y, z, height, radius, maxsides, topcap, c));
|
||||
function Cylinder(x, y, z, height, radius: real; c: Material) := Cylinder(x, y, z, height, radius, True, c);
|
||||
function Cylinder(x, y, z, Height, Radius: real; topcap: boolean; m: Material := DefaultMaterial): CylinderT := Inv(()->CylinderT.Create(x, y, z, Height, Radius, maxsides, topcap, m));
|
||||
function Cylinder(x, y, z, Height, Radius: real; m: Material := DefaultMaterial) := Cylinder(x, y, z, Height, Radius, True, m);
|
||||
///--
|
||||
function Cylinder(p: Point3D; height, radius: real; topcap: boolean; c: Material) := Cylinder(p.x, p.y, p.z, height, radius, topcap, c);
|
||||
function Cylinder(p: Point3D; height, radius: real; c: Material) := Cylinder(p.x, p.y, p.z, height, radius, True, c);
|
||||
function Cylinder(p: Point3D; Height, Radius: real; topcap: boolean; m: Material := DefaultMaterial) := Cylinder(p.x, p.y, p.z, Height, Radius, topcap, m);
|
||||
function Cylinder(p: Point3D; Height, Radius: real; m: Material := DefaultMaterial) := Cylinder(p.x, p.y, p.z, Height, Radius, True, m);
|
||||
|
||||
function Tube(x, y, z, height, radius, innerradius: real; c: Material): PipeT := Invoke&<PipeT>(()->PipeT.Create(x, y, z, height, radius, innerradius, c));
|
||||
function Tube(p: Point3D; height, radius, innerradius: real; c: Material) := Tube(p.x, p.y, p.z, height, radius, innerradius, c);
|
||||
function Tube(x, y, z, Height, Radius, InnerRadius: real; m: Material := DefaultMaterial): PipeT := Inv(()->PipeT.Create(x, y, z, Height, Radius, InnerRadius, m));
|
||||
function Tube(p: Point3D; Height, Radius, InnerRadius: real; m: Material := DefaultMaterial) := Tube(p.x, p.y, p.z, Height, Radius, InnerRadius, m);
|
||||
|
||||
function Cone(x, y, z, height, radius: real; c: Material): TruncatedConeT := TruncatedCone(x, y, z, height, radius, 0, True, c);
|
||||
function Cone(p: Point3D; height, radius: real; c: Material) := TruncatedCone(p.x, p.y, p.z, height, radius, 0, True, c);
|
||||
function Cone(x, y, z, Height, Radius: real; m: Material := DefaultMaterial): TruncatedConeT := TruncatedCone(x, y, z, Height, Radius, 0, True, m);
|
||||
function Cone(p: Point3D; Height, Radius: real; m: Material := DefaultMaterial) := TruncatedCone(p.x, p.y, p.z, Height, Radius, 0, True, m);
|
||||
|
||||
function Teapot(x, y, z: real; c: Material): TeapotT := Invoke&<TeapotT>(()->TeapotT.Create(x, y, z, c));
|
||||
function Teapot(p: Point3D; c: Material) := Teapot(p.x, p.y, p.z, c);
|
||||
function Teapot(x, y, z: real; c: Material := DefaultMaterial): TeapotT := Inv(()->TeapotT.Create(x, y, z, c));
|
||||
function Teapot(p: Point3D; c: Material := DefaultMaterial) := Teapot(p.x, p.y, p.z, c);
|
||||
|
||||
function BillboardText(x, y, z: real; text: string; fontsize: real := 12): BillboardTextT := Invoke&<BillboardTextT>(()->BillboardTextT.Create(x, y, z, text, fontsize));
|
||||
function BillboardText(p: Point3D; text: string; fontsize: real := 12) := BillboardText(P.x, p.y, p.z, text, fontsize);
|
||||
function BillboardText(x, y, z: real; Text: string; Fontsize: real := 12): BillboardTextT := Inv(()->BillboardTextT.Create(x, y, z, text, fontsize));
|
||||
function BillboardText(p: Point3D; Text: string; Fontsize: real := 12) := BillboardText(P.x, p.y, p.z, text, fontsize);
|
||||
|
||||
function CoordinateSystem(arrowslength, diameter: real): CoordinateSystemT := Invoke&<CoordinateSystemT>(()->CoordinateSystemT.Create(0, 0, 0, arrowslength, diameter));
|
||||
function CoordinateSystem(arrowslength: real) := CoordinateSystem(arrowslength, arrowslength / 10);
|
||||
function CoordinateSystem(ArrowsLength, Diameter: real): CoordinateSystemT := Inv(()->CoordinateSystemT.Create(0, 0, 0, arrowslength, diameter));
|
||||
function CoordinateSystem(ArrowsLength: real) := CoordinateSystem(arrowslength, arrowslength / 10);
|
||||
|
||||
function Text3D(x, y, z: real; text: string; height: real; fontname: string; c: Color): TextT := Invoke&<TextT>(()->TextT.Create(x, y, z, text, height, fontname, c));
|
||||
function Text3D(p: Point3D; text: string; height: real; fontname: string; c: Color) := Text3D(P.x, p.y, p.z, text, height, fontname, c);
|
||||
function Text3D(x, y, z: real; text: string; height: real; c: Color) := Text3D(x, y, z, text, height, 'Arial', c);
|
||||
function Text3D(p: Point3D; text: string; height: real; c: Color) := Text3D(p.x, p.y, p.z, text, height, 'Arial', c);
|
||||
function Text3D(x, y, z: real; text: string; height: real) := Text3D(x, y, z, text, height, 'Arial', Colors.Black);
|
||||
function Text3D(p: Point3D; text: string; height: real) := Text3D(p.x, p.y, p.z, text, height, 'Arial', Colors.Black);
|
||||
function Text3D(x, y, z: real; Text: string; Height: real; fontname: string := 'Arial'; c: Color := Colors.Black): TextT := Inv(()->TextT.Create(x, y, z, text, height, fontname, c));
|
||||
function Text3D(p: Point3D; Text: string; Height: real; fontname: string := 'Arial'; c: Color := Colors.Black) := Text3D(P.x, p.y, p.z, text, height, fontname, c);
|
||||
function Text3D(x, y, z: real; Text: string; Height: real; c: Color) := Text3D(x, y, z, text, height, 'Arial', c);
|
||||
function Text3D(p: Point3D; Text: string; Height: real; c: Color) := Text3D(p.x, p.y, p.z, text, height, 'Arial', c);
|
||||
|
||||
function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; c: Material): RectangleT := Invoke&<RectangleT>(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, c));
|
||||
function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; c: Material): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, c);
|
||||
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; c: Material): RectangleT := Rectangle3D(x, y, z, l, w, normal, OrtX, c);
|
||||
function Rectangle3D(x, y, z, l, w: real; c: Material): RectangleT := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, c);
|
||||
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; c: Material): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, c);
|
||||
function Rectangle3D(p: Point3D; l, w: real; c: Material): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, c);
|
||||
function Rectangle3D(x, y, z, l, w: real; normal, lendirection: Vector3D; m: Material := DefaultMaterial): RectangleT := Inv(()->RectangleT.Create(x, y, z, l, w, normal, lendirection, m));
|
||||
function Rectangle3D(p: Point3D; l, w: real; normal, lendirection: Vector3D; m: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, lendirection, m);
|
||||
function Rectangle3D(x, y, z, l, w: real; normal: Vector3D; m: Material := DefaultMaterial): RectangleT := Rectangle3D(x, y, z, l, w, normal, OrtX, m);
|
||||
function Rectangle3D(x, y, z, l, w: real; m: Material := DefaultMaterial): RectangleT := Rectangle3D(x, y, z, l, w, OrtZ, OrtX, m);
|
||||
function Rectangle3D(p: Point3D; l, w: real; normal: Vector3D; m: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, normal, OrtX, m);
|
||||
function Rectangle3D(p: Point3D; l, w: real; m: Material := DefaultMaterial): RectangleT := Rectangle3D(p.x, p.y, p.z, l, w, OrtZ, OrtX, m);
|
||||
|
||||
/// Загружает модель из файла .obj, .3ds, .lwo, .objz, .stl, .off
|
||||
function FileModel3D(x, y, z: real; fname: string; c: Material): FileModelT := Invoke&<FileModelT>(()->FileModelT.Create(x, y, z, fname, c));
|
||||
function FileModel3D(p: Point3D; fname: string; c: Material): FileModelT := FileModel3D(p.x, p.y, p.z, fname, c);
|
||||
function FileModel3D(x, y, z: real; fname: string; m: Material): FileModelT := Inv(()->FileModelT.Create(x, y, z, fname, m));
|
||||
function FileModel3D(p: Point3D; fname: string; m: Material): FileModelT := FileModel3D(p.x, p.y, p.z, fname, m);
|
||||
|
||||
function Prism(x, y, z: real; Sides: integer; Radius, Height: real; c: Material): PrismT := Invoke&<PrismT>(()->PrismT.Create(x, y, z, Sides, Radius, Height, c));
|
||||
function Prism(p: Point3D; Sides: integer; Radius, Height: real; c: Material): PrismT := Prism(p.X, p.Y, p.Z, Sides, Radius, Height, c);
|
||||
function Prism(x, y, z: real; Sides: integer; Height, Radius: real; m: Material := DefaultMaterial): PrismT := Inv(()->PrismT.Create(x, y, z, Sides, Radius, Height, m));
|
||||
function Prism(p: Point3D; Sides: integer; Height, Radius: real; m: Material := DefaultMaterial): PrismT := Prism(p.X, p.Y, p.Z, Sides, Radius, Height, m);
|
||||
|
||||
function PrismWireFrame(x, y, z: real; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := Invoke&<PrismTWireFrame>(()->PrismTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
||||
function PrismWireFrame(p: Point3D; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := PrismWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
||||
function PrismWireFrame(x, y, z: real; Sides: integer; Height, Radius: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := Inv(()->PrismTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
||||
function PrismWireFrame(p: Point3D; Sides: integer; Height, Radius: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PrismTWireFrame := PrismWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
||||
|
||||
function Pyramid(x, y, z: real; Sides: integer; Radius, Height: real; c: Material): PyramidT := Invoke&<PyramidT>(()->PyramidT.Create(x, y, z, Sides, Radius, Height, c));
|
||||
function Pyramid(p: Point3D; Sides: integer; Radius, Height: real; c: Material): PyramidT := Pyramid(p.X, p.Y, p.Z, Sides, Radius, Height, c);
|
||||
function Pyramid(x, y, z: real; Sides: integer; Height, Radius: real; m: Material := DefaultMaterial): PyramidT := Inv(()->PyramidT.Create(x, y, z, Sides, Radius, Height, m));
|
||||
function Pyramid(p: Point3D; Sides: integer; Height, Radius: real; m: Material := DefaultMaterial): PyramidT := Pyramid(p.X, p.Y, p.Z, Sides, Radius, Height, m);
|
||||
|
||||
function PyramidWireFrame(x, y, z: real; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := Invoke&<PyramidTWireFrame>(()->PyramidTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
||||
function PyramidWireFrame(p: Point3D; Sides: integer; Radius, Height: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := PyramidWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
||||
function PyramidWireFrame(x, y, z: real; Sides: integer; Height, Radius: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := Inv(()->PyramidTWireFrame.Create(x, y, z, Sides, Radius, Height, thickness, c));
|
||||
function PyramidWireFrame(p: Point3D; Sides: integer; Height, Radius: real; Thickness: real := 1.2; c: Color := GrayColor(64)): PyramidTWireFrame := PyramidWireFrame(p.x, p.y, p.z, Sides, Radius, Height, thickness, c);
|
||||
|
||||
function Lego(x, y, z: real; col, r, h: integer; c: Color): LegoT := Invoke&<LegoT>(()->LegoT.Create(x, y, z, col, r, h, c));
|
||||
function Lego(x, y, z: real; col, r, h: integer; m: Material := DefaultMaterial): LegoT := Inv(()->LegoT.Create(x, y, z, col, r, h, m));
|
||||
|
||||
function Icosahedron(x, y, z, R: real; c: Material): IcosahedronT := Invoke&<IcosahedronT>(()->IcosahedronT.Create(x, y, z, 4*R/Sqrt(2)/Sqrt(5+Sqrt(5)), c));
|
||||
function Dodecahedron(x, y, z, R: real; c: Material): DodecahedronT := Invoke&<DodecahedronT>(()->DodecahedronT.Create(x, y, z, R*4/Sqrt(3)/(1+Sqrt(5)), c));
|
||||
function Tetrahedron(x, y, z, R: real; c: Material): TetrahedronT := Invoke&<TetrahedronT>(()->TetrahedronT.Create(x, y, z, 4*R/Sqrt(6), c));
|
||||
function Octahedron(x, y, z, R: real; c: Material): OctahedronT := Invoke&<OctahedronT>(()->OctahedronT.Create(x, y, z, R*Sqrt(2), c));
|
||||
function Icosahedron(p: Point3D; R: real; c: Material): IcosahedronT := Icosahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Dodecahedron(p: Point3D; R: real; c: Material): DodecahedronT := Dodecahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Tetrahedron(p: Point3D; R: real; c: Material): TetrahedronT := Tetrahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Octahedron(p: Point3D; R: real; c: Material): OctahedronT := Octahedron(p.X,p.Y,p.Z,R,c);
|
||||
function Icosahedron(x, y, z, r: real; m: Material := DefaultMaterial): IcosahedronT := Inv(()->IcosahedronT.Create(x, y, z, 4*R/Sqrt(2)/Sqrt(5+Sqrt(5)), m));
|
||||
function Dodecahedron(x, y, z, r: real; m: Material := DefaultMaterial): DodecahedronT := Inv(()->DodecahedronT.Create(x, y, z, R*4/Sqrt(3)/(1+Sqrt(5)), m));
|
||||
function Tetrahedron(x, y, z, r: real; m: Material := DefaultMaterial): TetrahedronT := Inv(()->TetrahedronT.Create(x, y, z, 4*R/Sqrt(6), m));
|
||||
function Octahedron(x, y, z, r: real; m: Material := DefaultMaterial): OctahedronT := Inv(()->OctahedronT.Create(x, y, z, R*Sqrt(2), m));
|
||||
function Icosahedron(p: Point3D; r: real; m: Material := DefaultMaterial): IcosahedronT := Icosahedron(p.X,p.Y,p.Z,R,m);
|
||||
function Dodecahedron(p: Point3D; r: real; m: Material := DefaultMaterial): DodecahedronT := Dodecahedron(p.X,p.Y,p.Z,R,m);
|
||||
function Tetrahedron(p: Point3D; r: real; m: Material := DefaultMaterial): TetrahedronT := Tetrahedron(p.X,p.Y,p.Z,R,m);
|
||||
function Octahedron(p: Point3D; r: real; m: Material := DefaultMaterial): OctahedronT := Octahedron(p.X,p.Y,p.Z,R,m);
|
||||
|
||||
//function Inv<T>(p: ()->T): T := Invoke&<T>(p); // посмотреть, почему не выводится!
|
||||
function Segments3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Inv(()->SegmentsT.Create(points, thickness, c));
|
||||
function Polyline3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Inv(()->SegmentsT.Create(points.Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
||||
function Polygon3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Inv(()->SegmentsT.Create((points+points.First).Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
||||
function Segment3D(p1, p2: Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Inv(()->SegmentsT.Create(Seq(p1,p2), thickness, c));
|
||||
|
||||
function Segments3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create(points, thickness, c));
|
||||
function Polyline3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create(points.Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
||||
function Polygon3D(points: sequence of Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create((points+points.First).Pairwise.SelectMany(x->Seq(x[0],x[1])), thickness, c));
|
||||
function Segment3D(p1, p2: Point3D; thickness: real := 1.2; c: Color := GrayColor(64)): SegmentsT := Invoke&<SegmentsT>(()->SegmentsT.Create(Seq(p1,p2), thickness, c));
|
||||
function Torus(x, y, z, Diameter, TubeDiameter: real; m: Material := DefaultMaterial): TorusT := Inv(()->TorusT.Create(x,y,z,Diameter, TubeDiameter, m));
|
||||
function Torus(p: Point3D; Diameter, TubeDiameter: real; m: Material := DefaultMaterial): TorusT := Torus(p.x,p.y,p.z,Diameter,TubeDiameter,m);
|
||||
|
||||
function Torus(x, y, z, Diameter, TubeDianeter: real; c: Material): TorusT := Invoke&<TorusT>(()->TorusT.Create(x,y,z,Diameter, TubeDianeter, c));
|
||||
function Torus(p: Point3D; Diameter, TubeDianeter: real; c: Material): TorusT := Torus(p.x,p.y,p.z,Diameter,TubeDianeter,c);
|
||||
function MyH(x, y, z, Length: real; c: Color): MyAnyT := Inv(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
function MyH(x, y, z, Length: real; c: Material): MyAnyT := Inv(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
|
||||
function MyH(x, y, z, Length: real; c: Color): MyAnyT := Invoke&<MyAnyT>(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
function MyH(x, y, z, Length: real; c: Material): MyAnyT := Invoke&<MyAnyT>(()->MyAnyT.Create(x, y, z, Length, c));
|
||||
|
||||
function Any(x, y, z: real; c: Color): AnyT := Invoke&<AnyT>(()->AnyT.Create(x, y, z, c));
|
||||
function Any(x, y, z: real; c: Color): AnyT := Inv(()->AnyT.Create(x, y, z, c));
|
||||
|
||||
procedure ProbaP;
|
||||
begin
|
||||
|
|
|
|||
|
|
@ -53,35 +53,77 @@ begin
|
|||
Result := CreateFile&<real>(fname);
|
||||
end;
|
||||
|
||||
/// Возвращает последовательность элементов открытого типизированного файла
|
||||
function Elements<T>(Self: file of T): sequence of T; extensionmethod;
|
||||
/// Устанавливает текущую позицию файлового указателя в типизированном файле на элемент с номером n
|
||||
function Seek<T>(Self: file of T; n: int64): file of T; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Seek(Self, n);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
/// Считывает и возвращает следующий элемент типизированного файла
|
||||
function Read<T>(Self: file of T): T; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Read(Self, Result);
|
||||
end;
|
||||
|
||||
/// Считывает и возвращает два следующих элемента типизированного файла в виде кортежа
|
||||
function Read2<T>(Self: file of T): (T,T); extensionmethod;
|
||||
begin
|
||||
var a,b: T;
|
||||
PABCSystem.Read(Self, a);
|
||||
PABCSystem.Read(Self, b);
|
||||
Result := (a,b);
|
||||
end;
|
||||
|
||||
/// Считывает и возвращает три следующих элемента типизированного файла в виде кортежа
|
||||
function Read3<T>(Self: file of T): (T,T,T); extensionmethod;
|
||||
begin
|
||||
var a,b,c: T;
|
||||
PABCSystem.Read(Self, a);
|
||||
PABCSystem.Read(Self, b);
|
||||
PABCSystem.Read(Self, c);
|
||||
Result := (a,b,c);
|
||||
end;
|
||||
|
||||
/// Возвращает последовательность элементов открытого типизированного файла от текущего элемента до конечного
|
||||
function ReadElements<T>(Self: file of T): sequence of T; extensionmethod;
|
||||
begin
|
||||
while not Self.Eof do
|
||||
begin
|
||||
var x: T;
|
||||
read(Self,x);
|
||||
var x := Self.Read;
|
||||
yield x;
|
||||
end;
|
||||
end;
|
||||
|
||||
/// Считывает и возвращает следующий элемент типизированного файла
|
||||
function ReadElement<T>(Self: file of T): T; extensionmethod;
|
||||
begin
|
||||
Read(Self, Result);
|
||||
end;
|
||||
|
||||
/// Открывает типизированный файл, возвращает последовательность элементов и закрывает его
|
||||
/// Открывает типизированный файл, возвращает последовательность его элементов и закрывает его
|
||||
function ReadElements<T>(fname: string): sequence of T;
|
||||
begin
|
||||
var f := OpenBinary&<T>(fname);
|
||||
while not f.Eof do
|
||||
begin
|
||||
var x := f.ReadElement;
|
||||
var x := f.Read;
|
||||
yield x;
|
||||
end;
|
||||
f.Close
|
||||
end;
|
||||
|
||||
/// Открывает типизированный файл, возвращает последовательность его элементов и закрывает его
|
||||
procedure WriteElements<T>(fname: string; ss: sequence of T);
|
||||
begin
|
||||
var f := CreateBinary&<T>(fname);
|
||||
foreach var x in ss do
|
||||
f.Write(x);
|
||||
f.Close
|
||||
end;
|
||||
|
||||
/// Записывает данные в типизированный файл
|
||||
procedure Write<T>(Self: file of T; params vals: array of T); extensionmethod;
|
||||
begin
|
||||
foreach var x in vals do
|
||||
PABCSystem.Write(Self, x);
|
||||
end;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Операции для procedure
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -97,12 +139,6 @@ begin
|
|||
Result := () -> for var i:=1 to n do p
|
||||
end;
|
||||
|
||||
procedure Write<T>(Self: file of T; params vals: array of T); extensionmethod;
|
||||
begin
|
||||
foreach var x in vals do
|
||||
PABCSystem.Write(Self, x);
|
||||
end;
|
||||
|
||||
var __initialized: boolean;
|
||||
|
||||
procedure __InitModule;
|
||||
|
|
|
|||
|
|
@ -481,6 +481,10 @@ type
|
|||
procedure Write(params vals: array of object);
|
||||
/// Устанавливает файловый указатель на начало файла
|
||||
procedure Reset;
|
||||
/// Возвращает имя файла
|
||||
function Name: string;
|
||||
/// Возвращает полное имя файла
|
||||
function FullName: string;
|
||||
end;
|
||||
|
||||
// Class for typed files
|
||||
|
|
@ -499,8 +503,6 @@ type
|
|||
function FilePos: int64;
|
||||
/// Возвращает количество элементов в типизированном файле
|
||||
function FileSize: int64;
|
||||
/// Устанавливает текущую позицию файлового указателя в типизированном файле на элемент с номером n
|
||||
procedure Seek(n: int64);
|
||||
end;
|
||||
|
||||
// Class for binary files
|
||||
|
|
@ -3255,16 +3257,6 @@ begin
|
|||
Result := sb.ToString;
|
||||
end;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Методы для object (экспериментально)
|
||||
//------------------------------------------------------------------------------
|
||||
/// Выводит значение объекта на экран, после чего выводит пробел
|
||||
procedure Print(Self: object); extensionmethod := Print(Self);
|
||||
|
||||
/// Выводит значение объекта на экран и переходит на следующую строку
|
||||
procedure Println(Self: object); extensionmethod := Println(Self);
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Операции для string и char
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -5363,6 +5355,18 @@ begin
|
|||
PABCSystem.Reset(Self);
|
||||
end;
|
||||
|
||||
function AbstractBinaryFile.Name: string;
|
||||
begin
|
||||
Result := fi.Name
|
||||
end;
|
||||
|
||||
function AbstractBinaryFile.FullName: string;
|
||||
begin
|
||||
Result := fi.FullName
|
||||
end;
|
||||
|
||||
|
||||
|
||||
// -----------------------------------------------------
|
||||
// TypedFile & BinaryFile methods
|
||||
// -----------------------------------------------------
|
||||
|
|
@ -5376,11 +5380,6 @@ begin
|
|||
Result := PABCSystem.FileSize(Self);
|
||||
end;
|
||||
|
||||
procedure TypedFile.Seek(n: int64);
|
||||
begin
|
||||
PABCSystem.Seek(Self, n);
|
||||
end;
|
||||
|
||||
function BinaryFile.FilePos: int64;
|
||||
begin
|
||||
Result := PABCSystem.FilePos(Self);
|
||||
|
|
@ -8163,6 +8162,71 @@ type
|
|||
end;
|
||||
end;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//>> Метод расширения Print для элементарных типов
|
||||
//------------------------------------------------------------------------------
|
||||
function Print(Self: integer): integer; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Print(Self: real): real; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Print(Self: char): char; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Print(Self: boolean): boolean; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Print(Self: BigInteger): BigInteger; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Print(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: integer): integer; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: real): real; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: char): char; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: boolean): boolean; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
function Println(Self: BigInteger): BigInteger; extensionmethod;
|
||||
begin
|
||||
PABCSystem.Println(Self);
|
||||
Result := Self;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//>> Методы расширения для sequence of T # Extension methods for sequence of T
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
C:\PABCWork.NET
|
||||
C:\PABCWork.NET
|
||||
Loading…
Reference in a new issue