File : testlass.adb


with Reps, Reps.Ops, Messages, Lin, Lin.IO, Lin.IO.Vinci;
use Reps, Reps.Ops, Messages, Lin, Lin.IO, Lin.IO.Vinci;
with Lattice, Lattice.Ops, Lattice.IO;
use Lattice, Lattice.Ops, Lattice.IO;
with Lass;

procedure TestLass is

  N1: constant Positive := 8;  -- lattice patch depth:  -N1 .. N1
  N2: constant Positive := 8;  -- lattice patch width:  -N2 .. N1
  N3: constant Positive := 8;  -- lattice patch height: -N3 .. N3
  LP: constant Positive := 3;  -- layer period: set 2 for AB, 3 for ABC

  Mov: Blob(8);

  procedure AddMovable(L: in IPoint) is
    OK: Boolean;
  begin
    AddMovable(L,Mov,OK);
    if not OK then
      Show("Error: specified point is not in in lattice patch");
    end if;
  end AddMovable;

  procedure Unusual1 is
  begin
    AddMovable(( 0, 0, 0));
    AddMovable(( 1, 1, 0));
    AddMovable(( 1,-1,-1));
    AddMovable(( 2, 0,-1));
  end Unusual1;

  procedure Unusual2 is      -- original
  begin
    AddMovable(( 0, 0, 0));
    AddMovable((-2,-2, 0));
    AddMovable((-1,-1, 0));
    AddMovable(( 1,-2, 0));
  end Unusual2;

  procedure Unusual3 is
  begin
    AddMovable(( 3, 0, 0));
    AddMovable(( 0, 0, 0));
    AddMovable(( 2,-1, 0));
    AddMovable(( 4,-2, 0));
  end Unusual3;

  procedure Unusual4 is
  begin
    AddMovable(( 0,-1, 1));
    AddMovable(( 2,-2, 1));
    AddMovable(( 0, 0, 0));
    AddMovable(( 2,-1, 0));
  end Unusual4;

  procedure Test2 is
  begin
    AddMovable(( 0, 0, 0));
    AddMovable((-2,-2, 0));
    AddMovable((-1,-1, 0));
  end Test2;

  A: RMatPtr;
  B: PolyPtr;

begin
  Verbose := 2;
  InitPatch(N1,N2,N3,LP);

-- declare which NM balls are movable
  Test2;
  Show(Mov);

  Copy(Mov,B);
  Show(B);

  Write(MyImg(B) & ".pol",B);
  AdaWrite(MyImg(B) & ".ada",B);

  A := Constraints(Mov);
  WriteVinci("auto_balls.ine",A);  -- change filename if desired

  declare
    NumVar: constant Positive := 3*Mov.L;
    NumEqu: constant Positive :=   Mov.M;
    V: Rep;

    package Lasserre is new Lass(NumEqu => NumEqu, NumVar => NumVar);
    use Lasserre;

  begin
    MinDoTrans :=    5;    -- min dimension for translations
    MinVolSave :=    4;    -- min dimension for considering saved volume
    MaxVolSave :=   99;    -- max dimension for using saved volume
    MinVolConv :=    4;    -- min dimension for converting saved volume

    Show("Dimension:  ",NumVar);
    Show("Halfspaces: ",NumEqu);
    Show("MinDoTrans  ",MinDoTrans);
    Show("MinVolSave  ",MinVolSave);
    Show("MaxVolSave  ",MaxVolSave);
    Show("MinVolConv  ",MinVolConv);

    Vol(A,V);
    Show("Volume is ",V,17,4);
  end;

end TestLass;