How to use it

 

VC# 2005 example

Delphi 7 example

 

 

VC# 2005 Example

 

Prerequisite: check our VB 2005 sample to see the components and their placement

 

Step 1. Set pieces to be cut (also called PARTS).

 

AnyShapeCut2DX1.NumberOfParts = 50;

for (int i = 0; i < 20; i++)

{

AnyShapeCut2DX1.SetPart(i, 0, 6, 0, 0, 0, 0, 90, 0, i, 0);

AnyShapeCut2DX1.SetPartVertex(i, 0, 0, 0);

AnyShapeCut2DX1.SetPartVertex(i, 1, 20, 0);

AnyShapeCut2DX1.SetPartVertex(i, 2, 20, 10);

AnyShapeCut2DX1.SetPartVertex(i, 3, 10, 10);

AnyShapeCut2DX1.SetPartVertex(i, 4, 10, 20);

AnyShapeCut2DX1.SetPartVertex(i, 5, 0, 20);

}

for (int i = 20; i < 30; i++)

{

AnyShapeCut2DX1.SetPart(i, 0, 4, 0, 0, 0, 0, 90, 0, i, 0);

AnyShapeCut2DX1.SetPartVertex(i, 0, 20, 0);

AnyShapeCut2DX1.SetPartVertex(i, 1, 60, 40);

AnyShapeCut2DX1.SetPartVertex(i, 2, 20, 80);

AnyShapeCut2DX1.SetPartVertex(i, 3, 0, 40);

}

for (int i = 30; i < 50; i++)

{

AnyShapeCut2DX1.SetPart(i, 0, 6, 0, 0, 0, 0, 90, 0, i, 0);

AnyShapeCut2DX1.SetPartVertex(i, 0, 10, 0);

AnyShapeCut2DX1.SetPartVertex(i, 1, 20, 10);

AnyShapeCut2DX1.SetPartVertex(i, 2, 10, 20);

AnyShapeCut2DX1.SetPartVertex(i, 3, 0, 20);

AnyShapeCut2DX1.SetPartVertex(i, 4, 0, 10);

AnyShapeCut2DX1.SetPartVertex(i, 5, 10, 10);

}

 

Step 2. Set the sheets to cut from (also called stock or REPOSITORY pieces).

 

AnyShapeCut2DX1.NumberOfStockPieces = 1;

AnyShapeCut2DX1.SetStock(0, 0, 6, 0, 0, 0, 0, 0, 0);

AnyShapeCut2DX1.SetStockVertex(0, 0, 10, 10);

AnyShapeCut2DX1.SetStockVertex(0, 1, 200, 10);

AnyShapeCut2DX1.SetStockVertex(0, 2, 290, 100);

AnyShapeCut2DX1.SetStockVertex(0, 3, 200, 200);

AnyShapeCut2DX1.SetStockVertex(0, 4, 10, 290);

AnyShapeCut2DX1.SetStockVertex(0, 5, 100, 100);

 

Step 3. Set other parameters.

 

AnyShapeCut2DX1.RandomSeed = 0;

AnyShapeCut2DX1.Resolution = 0.1;

Step 4. Start the optimization process.

 

AnyShapeCut2DX1.Start();

 

Step 5. Use the OnFinish event to extract the results of optimization.

 

// this example displays only the first sheet.

// if you want to obtain information about all sheets just iterate through all of them
// sheets are indexed from 0 to TotalNumberOfUtilizedStockPieces
// usually the first parameter of the methods is the sheet index

// get & draw the sheet

 

AnyShapeCut2DX1.GetStock(StockIndex, out stock_type, out no_vertices, out cx_s, out cy_s, out cr_s, out no_holes, out e_Stock, out priority);

double x, y;

double min_X = 10000000;

double min_Y = 10000000; // maxdouble

Point []points = new Point[no_vertices];

for (int j = 0; j < no_vertices; j++)

{

AnyShapeCut2DX1.GetStockVertex(StockIndex, j, out x, out y);

points[j].X = (int)x;

points[j].Y = Picture1.Height - (int)y;

if (x < min_X)

    min_X = x;

if (y < min_Y)

    min_Y = y;

}

g.DrawPolygon(Pens.Black, points);

 

// get & draw each part placed in the sheet

 

int NoParts;

AnyShapeCut2DX1.NumberOfUtilizedParts(SheetIndex, out NoParts, out StockIndex, out e_Stock);

for (int i = 0; i < NoParts; i++){

int face_rotated;

double rot_angle;

double rot_step;

double cx_p, cy_p, cr_p;

int allow_face_rotation;

AnyShapeCut2DX1.GetUtilizedPart(SheetIndex, i, out part_type, out rot_angle, out face_rotated, out StockIndex, out PartIndex, out e_Stock, out e_Part);

AnyShapeCut2DX1.GetPart(PartIndex, out part_type, out no_vertices, out cx_p, out cy_p, out cr_p, out no_holes, out rot_step, out allow_face_rotation, out e_Part, out priority);

points = new Point[no_vertices];

for (int j = 0; j < no_vertices; j++){

    AnyShapeCut2DX1.GetVertexOfUtilizedPart(SheetIndex, i, j, out x, out y, out StockIndex, out PartIndex, out e_Stock, out e_Part);

    points[j].X = (int)min_X + (int)x;

    points[j].Y = Picture1.Height - (int)min_Y - (int)y;

        }

        g.FillPolygon(Brushes.Red, points);

        g.DrawPolygon(Pens.Black, points);

}

       
 

 

Delphi 7 Example