 Welcome back cat from scratch episode number nine in this video. It's gonna be pretty quick We're going to be updating the routines that we have that export our file as an STL To handle our new data structures pretty quick. Let's get right into it so first things first let's update our Declarations for these two functions that write STLs so no longer taking any of those input parameters just taking the structure of the body Awesome that one is good to go Actually, if I recall in our geometry routine, we did have In our drum tree function file, we had this make clip routine that I had that Manually created these parametric polygonal measures for a clip. I believe down here. We had we called the Old version of this function. Yeah, here it is. Let's just comment that out for the time being Save that file So the main body of work has to happen in this out.seaf File, let's again change all these functions to take our new input parameter. Just the body structure Okay, so we will need this num triangles value at least for this Second f right here as part of the binary version of the STL. So we will have to use our function from yesterday, which Was called I think count faces So that will give us that value. However, we won't actually be using This this for loop Incrementing to that variable because we now have a structure with everything inside it So we might as well just define an iterator for the face starting at the first face on the body and Instead of having this for leap Just have a while leap and we'll say while Itter is not no. So while we have a valid face Continue and then again this normal stuff we have normals in our data structure So we don't have to bother with any of those function calls. We can just say f right It or normal and I've ever called this is already a vector 3 and they each it's the vector of 3 floats So float is 4 bytes You know size 3 and to the file f. So that's all can say the same Then here we're looping through the vertices in the face oh By the way, this this function is going to assume everything is triangulated which by the way is required for STL So I'm not going to bother with any error handling You'll just see in the STL file It won't have a you know, it won't look right unless you are working with a Triangulated body so just to keep that in mind. I'm not going to put any error handling here But I guess we could in the future As you can tell I'm kind of against error handling just as a as a matter of principle so we'll create a vector of floats for the nodes and We will set them equal to iter node Array jx iter node array j Why? then iter node array j z and Then simply pass that value in here in the f right so node Then we'll pass actually we by count again if you can look back at the previous video see why we need that and We'll iterate on our on our faces Then at the end here. I Omitted this last time, but we really should be f closing our file when we're done on to the next version of the STL is The ASCII version This time we won't actually need to get the number of triangles I don't think because that doesn't come up front in the in the file, but we will still need that on That iterator so I struck face Itter equals body face We'll change this first line out here for that while loop once again while iter does not equal null Kill these normal things once again here. We can pass in instead of normal Values pass an iter normal because again itters the face that we're currently working on and it has normal in the data structure So no problem Outer loop, that's fine here. This is gonna apply a lot of typing, but let's get rid of all this garbage We're gonna pass in again the x y and z coordinates every vertex. So we'll say itter No, DeRay J X Itter No, DeRay J Y Itter DeRay J Z That should that should work and loop again. You have to iterate and then once again we'll F close our file Now that should work. I'm just gonna assume it does. I'm not gonna even bother checking anything It was simple changes and our main file Let's update our two test cases to output using both those new files that we have First let's kill all our old garbage with this draw body routine. That's not from this video So what we will need to do a car star Like a string type thing So I guess we'll call it file one equals prism stl And then we will use that right stl we'll use the binary one first we'll pass in the prism and we'll pass in the Address of our file one. Let's copy that down here This time it won't be file one will be file two. It'll be called Hexagon stl will be passing in hexagon and file two And it will be using the ASCII version of the right stl function that should all work just fine Let's make the file Let's run it and it ran Now you can see we have a prism that stl which is 684 bytes and hexagon stl which is 702 bytes It's very curious that the hexagon stl which by the way is a much simpler model is actually more bytes than our prism obviously, that's because the prism is a binary version and still on is a ASCII version that's why it's much more efficient. So I'm gonna open these two up in our Online visualizer and see how they work. I'll do it back. So here are the two files. I'm open at the same time Let's see what happens and Yeah, you can see right here. We have both our prism dot stl That's that's the big one here as well as you can't really see it But it's this hexagon shape one that's inside it, which is to be expected. So yep, it works We have two new working Routines that handle our new data structure And yeah, see you next time