Measure on Mesh

To write a first entry for the page i requested i want to introduce a method to measure on mesh we are frequently using in our solution, maybe this helps others :-)

In general we only load tesselated geometry because of the large data we have, we store them in MultiLOD JT files and load them using JTOpen API and organize it in a block/blockreference structure.

Now we have either mesh or fastmesh (user decision what to load) and need several measure functions like circle center to circle center, line to planar face, planar face to Circle center and so on.

But on mesh you will not have circles and planar faces (only one triangle is a planar face)

So we set up some functions to generate this base entities from mesh:

  1. setup a variable to track model move or not to handle this expensive operation (we use an enum with “measure item”, “measure between” and “select entity” so we know to expect one or two clicks to finish operation)
  2. get the item under mouse to decide if we have mesh or fastmesh
  3. findclosesttriangle on the mesh
  4. convert to mesh if it is a fastmesh entity
  5. create a memory copy of the mesh and apply the positioning given by block/blockreference structure
  6. get the triangle data we are above
  7. find closest edge: we iterate over the edges collection of the mesh the given triangle has connections to, calculate worldtoscreen with a 2dsegment and defined a 10 pixel area, if within the 10 pixels is an edge is found we have a hit, follow step 7, if not follow step 12
  8. with the given edge we try to get the surrounding lines with two prerequisites: lines should be within 75% longer or shorter of the given one and angle between is below 30deg
  9. we add a check of the found line list is closed
  10. with the given list of lines we check if the lines are planar, with non planar lines we cannot create a circle.
  11. so we have planar curves either closed or not, now we must check if we possibly have a circle, for this we need at least two lines, given two lines we can create a circle with three point, if we have more we take first, last (if closed we use another point close to that) and one in the middle. On an earlier version I also checked all other vertices between the three points to cross check they have nearly the same diameter.
  12. As a result we have either a closed/nonclosed curve (we don’t want to measure that), a closed/nonclosed circle or if we add all segment length and have a vector a straight line…we store this lines in a custom collection for later usage…go to step 14
  13. since there is no edge close to the triangle, we need to find a face, currently we are only interested in planar faces which forms a plane
  14. we get all surrounding tringles with a maximum angle of 30deg and build a new mesh from them and store this in a custom list
  15. with given list(s) of entities we create red lines / faces to display in tempentities.
  16. especially for doing measure between we define some pairs to calculate: line-line, circle-circle, circle-line, line-plane, circle plane, plane-plane and vice versa. Not in all combinations everything is useful, e.g for circle to circle we finally create a green circle, the circle center and the circle axis, having a plane outline, cog and plane normal in most cases is not useful. Also on planes we want the closest distance, this must not be inside the mesh.

And this is how it looks like:

Feel free to comment, maybe you have improvements or ideas?

Kai

 

3

Comments

5 comments
Date Votes
  • Could you share your code?

    0
  • i just want to comment about yours post

    im sure maybi user will ask why you not use Brep that can "handle this issues"

    but i tell no ,its almost cant do any bolian or rail or different... with Brep

    Brep almost cant use in any case most cases not work in good case crash in most 

    we give up the use of brep after months  of test ,and back to old solid(mesh)

    i just recommend any new user be very careful before you choose use Brep ( because from global look

    its look very easy and can solve all the issue this post try solve) but my experience of loose many months

    Brep here its something very very not stabile(especially for bolian ,its almost useless)

    thanks

    so 

     

    0
  • Hello Yakov,

    We have already discussed this topic many times. BRep is designed to do this kind of modeling and works pretty well: https://devdept.zendesk.com/hc/en-us/sections/360002839954-Solid-Modeling.

    We offer multiple modeling tools (Mesh, Solid, Surface, BRep) for this specific reason, they all have pros and cons.

    1
  • I'd also say so. Imported BReps and Water-tightness is a problem, though.
    But this is off-topic IMHO (as well as Yakov's post. don't see any real relationship to Kai's post).

    BTW: Thumbs up for what you guys did there, Kai!

    0
  • Could you share your code?

     

    0

Please sign in to leave a comment.

Didn't find what you were looking for?

New post