Jump to content

RectCoordinatesSub ( pieceA ; pieceB ; materialA ; materialB ; positionX ; positionY )


This topic is 6474 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Name & Parameters: [color:red][big] RectCoordinatesSub ( pieceA ; pieceB ; materialA ; materialB ; positionX ; positionY ) [/big]

Description: Returns the coordinates of rectangles (with dimensions pieceA x pieceB,) that can be cut from an area of materials (with dimensions materialA x materialB), starting from positionX, positionY.

This is designed to be used by the xmChart plugin to generate a graphic representation of how to cut the most pieces from the material.

This is a sub function of RectCoordinates(), located here (along with a demo):)

http://www.fmforums.com/forum/showtopic.php?tid/179077/post/216239/#216239/

Sample Input:

RectCoordinatesSub(12;12;15;25;0;0)

Results:

AddRect( 0;0;12;12;white)¶

AddFrame(0;0;12;12;1;black)¶

AddRect( 0;12;12;12;white)¶

AddFrame(0;12;12;12;1;black)¶

Recursive: yes

Formula:

//RectCoordinatesSub ( pieceA ; pieceB ; materialA; materialB; positionX; positionY )



/*

Returns the coordinates of rectangles (with dimensions pieceA x pieceB,) that can be cut from an area of materials (with dimensions materialA x materialB), starting from positionX, positionY.



This is designed to be used by the xmChart plugin to generate a graphic representation of how to cut the most pieces from the material. 

Coordinates start from the top, left.  

The string returned is in the form: 



AddRect( 0;0;12;12;white)¶

AddFrame(0;0;12;12;1;black)¶

AddRect( 0;12;12;12;white)¶

AddFrame(0;12;12;12;1;black)¶





Sub function of: RectCoordinates().

CFs Required: RectCount(), and DrawRect().



7-29-2006

By Mike Hackett

*/





Let(

[

  /*Check the count with first cutting hozontal pieces from horizontal material.*/

  countRows = Case(materialA ≥ pieceA and Div(materialB; pieceB) > 0; 

                               Div(materialB; pieceB) + 

                                    RectCount(pieceA; pieceB; materialA - pieceA; materialB));



  /*Check the count with first cutting vertical pieces from horizontal material.*/

  countColumns = Case(materialB ≥ pieceA and Div(materialA; pieceB) > 0; 

                               Div(MaterialA;PieceB) + 

                                    RectCount(pieceA; pieceB; materialB - pieceA; materialA))

];



Case(countRows > 0 or countColumns > 0;

  Case(countRows > countColumns; 

    //Draw as many rows as will fit first

    DrawRect(positionX; positionY; pieceA; pieceB; "Down"; Div(materialB; pieceB)) &

       RectCoordinatesSub( pieceA; pieceB; materialA - pieceA; materialB; positionX + pieceA; positionY );



    //Draw as many columns as will fit first

    DrawRect(positionX; positionY; pieceB; pieceA; "Across"; Div(materialA;PieceB)) &

       RectCoordinatesSub( pieceA; pieceB; materialA; materialB - pieceA; positionX; positionY + pieceA )))

) 

Required Functions: RectCount()

DrawRect()

Author(s): Ender

Date: 07/29/06

Credits: Based on the discussion in this thread: http://www.fmforums.com/forum/showtopic.php?tid/170643/

Disclaimer:

FM Forums does not endorse or warrantee these files are fit for any particular purpose. Do not post or distribute files without written approval from the copyright owner. All files are deemed public domain unless otherwise indictated. Please backup every file that you intend to modify.

Link to comment
Share on other sites

This topic is 6474 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.