I have a question about preallocation with object-oriented programming.
I have this object:
This is the result of a few loops. I could have one only loop, but I prefere to do it step by step to better control that I'm not wasting my time with dumb errors. I think it's not important, but I'll show an example.
This is an object containing the tooth 11 (FDI nomenclature) of six different samples (STL-files) of teeth.
First I rotate and translate a tooth to fit a reference tooth (in this case tooth in second row). For this I get tform (transformation matrix) and movingReg (new set of points/vertices).
Then I do a nearest point analysis and get k and dist an calculate Fk which is the distance vector with which I calculate the MeanVertices for the reference tooth (that's why there is only one matrix, in the second row).
Matlab tells me to preallocate the whole time, which I don't know how to do with this object. How can I preallocate (for example) FDINumber11.Vertices (see the code bellow this paragraph) before reading the data and not knowing how many points the file has? I think solution would apply to the other characteristics.
FDINumber11_STL = stlread(FDINumber11(i).STLPath);
FDINumber11(i).Faces = FDINumber11_STL.ConnectivityList;
The whole process takes a little while, not too much but I hope to one day try it with many more teeth, so optimization would be a good thing to do. The worst case is that I learn a good programming practice, so even in case I cannot preallocate here, I would be glad to get a good explanation of it.
As always thank you very much.
PS: I have an example of a preallocation here, used in this code and it seems to work.
summe1 = 0.0;
summe1 = summe1 + (FDINumber11(i).Fk - FDINumber11(r).Vertices)/(m-1);