re triangulation of an STL file (slicing) to create hybrid STL file

Hi all

I am a php developper for my project i need to slice STL files a litle like 123d make but in my case i want to reorganize the triangles or repopulate the mesh by constant size right angled triangles if possible . ideally i will like to have 4 triangles per slices each of my triangles should remain in the square slices space .

Here is my parsed STL data
$x_vals = array($vertex1X[$i], $vertex2X[$i], $vertex3X[$i]);
$y_vals = array($vertex1Y[$i], $vertex2Y[$i], $vertex3Y[$i]);
$z_vals = array($vertex1Z[$i], $vertex2Z[$i], $vertex3Z[$i]);

i have no idea where to start your advice’s are welcome .