Skip to main content

Hi,



Is there a way I can find the mass of a polygon object?



Thanks



Richard

Hi Richard,



Thanks for your question here!



While it is possible to estimate element volumes in the sequential mode of OpticStudio, currently there is no volume/mass calculator available for non-sequential objects. If you are able to export the object to a CAD file and open it in a CAD program, such as SolidWorks or Creo, that is probably the easiest way to obtain the volume or mass of a particular element. Apologies for the inconvenience.



Best,



Csilla


Thanks Csilla, I'll give that a try


Hi Csilla,



I followed your previous answer mentioning about non-sequential mode in which we have no option to calculate masses in OS.



In sequential mode I am particularly asking, How can we find the total mass of the lens system in our OS layout? 



 



Best Regards.


As per my above question, I figured out how to calculate my lens layout mass/volume data in OS environment, in sequential mode.



Using report ribbon in the analyze menu, the 'Presciption Data' OS does the work for you, it is seen on the very below in the prescription data text.





I hope this indormation will be helpful for anyone who needs the mass/volume data in any lens layout in sequential mode.


Hi Önder,



Thanks for your posts here on the forums!



Yes, you are correct, in sequential mode, you may find the volume and mass information in the Prescription Data under Analyze...Reports.



Also, you may pull this data to the Merit Function using the TMAS optimization operand and optimize for it if needed.





Best,



Csilla


That hint is awesome, thank you Csilla,



Best wishes.


Last but not the least, calculation of volume is also available in OS. As I figured out, there is an operand for this purpose; VOLU. After giving it a try I startled. 


Check out this website on tetrahedral shoelace methods for calculating the volume of irregular polyhedra.  It only gives good results on faceted, non-curved polyhedra.

https://ysjournal.com/tetrahedral-shoelace-method-calculating-volume-of-irregular-solids/


Are there any plans to implement a volume calculator for non-sequential objects? I formally request this feature be added if not. The operand FREZ has the option to return the volume of a Freeform Z object, and there are ways to calculate volume in sequential mode.


Interesting topic from the past. 

I believe the technique @Mike.Jones is referring to is laid out in detail in a 2001 paper from Zhang and Chen

http://chenlab.ece.cornell.edu/Publication/Cha/icip01_Cha.pdf

OpticStudio provides almost all the information necessary to calculate the volume of an object in non-sequential mode but the ZOS-API fails in one particular case which makes it virtually impossible to implement.  Zemax knows of this limitation with the ZOS-API since at least 2019.  While this is not technically a bug, it is a poor implementation of the OpenShadedModelVisualizationExport() tool and should be fixed.

The essence of the paper is as follows:

  • First, the object must be a solid object which satisfies the convex hull consideration (i.e., a “water-tight” solid).  Solids by default in OpticStudio satisfy this and if a solid does not (say a CAD object), then OpticStudio will throw an error.
  • Tesselate an object so that you can represent any surface with triangles.  For a square or rectangular surface, this would be represented by 2 triangles.  The size & location of the vertices are not important at this step.  The triangle will be represented by vertices A-B-C.
  • Calculate the tetrahedral volume the triangle makes with the global (0, 0, 0) location.  Since we’re including the origin, this calculation becomes trivial.
  • Determine the normal vector of the triangle such that the normal satisfies the right-hand rule.  The normal can be determined by taking AB cross AC.  The sign of the tetrahedral volume will be determined by the sign of the dot product of the point A and the normal vector.
  • Since the tessellated object is water-tight, the normal vectors for each triangle should point in the same direction (either inside the solid or outside the solid).  In order to ensure the normals are pointing in the same direction, 2 adjacent triangles must have their vertices defined such that their common side has opposite directions (OpticStudio does nothing to ensure the order of vertices are consistent):
  • It’s at this point the order of the vertices matter.  If A-B-C lie in the plane of the screen, then a clockwise order of vertices will have the normal go into the screen while a counterclockwise order of vertices will have the normal come out of the screen.  This is where OpticStudio fails in the general sense.  Although the IShadedModelTriangleList has the XYZ normal vectors, the ZOS-API does not try to implement the correct order of the vertices.

In some simple testing of this, a CAD part (whether using SMS or ACIS) has the correct order of vertices but native parts (such as a Rectangular Volume), are incorrect.  My guess is that OpticStudio relies on a 3rd party library to tesselate CAD parts (and the 3rd party library does this correctly) while OpticStudio tries to tesselate native objects itself and does it incorrectly.

An added level of difficulty trying to fix this is the OpenShadedModelVisulationExport() does not export adjacent triangles.  My guess is that since this feature is most likely multi-threaded, the order the vertices are added to the double ] array is FIFO.  So, not only would you have to sort the triangle list into adjacent triangles, you would also have to then check the order of vertices.  

I have attached C# code which will calculate the volume based on the assumption the normals are correct (i.e., for CAD parts).  Feel free to add code to sort the triangle list and rearrange the vertices to satisfy the normal direction consideration.  A very crude workaround and is not guaranteed to produce accurate results, especially with updates to CAD libraries, will be to take native objects, make a Boolean CAD representation of the native object, and then use the code to calculate the volume.  My tests show results within 0.25% accuracy.


Reply