I am developing several tools related to terrain modelling. And I found there is a very fundamental operation that need to be done for them. It is similar to MeshSplit but not exactly. I’ve abstracted the operation below:
Red line is a polyline on a base mesh. It can be the result of mesh intersection or polyline projection.
Blue dots are the new vertices the red line creates on the base mesh.
The meshFaces that intersect with the blue dot will be re-triangulated (delaunay I guess) , while other meshFaces remain intact. See images below.
This way I can add detail to the base terrain mesh and manipulate the mesh locally. I am just curious if any algorithms or scripts existed before I invest time to reinvent the wheel.
I’ve searched around the forum for a while. It seems that @Terry_Chappell and @Holo are developing similar tools. It would be great if you two can share some insights.
There is code inside my TrimMeshForDD.py script that will do what you want. Please take a look and see if you can sort out what the code has to offer. It contains many comments and tries to fully document each procedure in this 6000+ line script. It will run without the two files mentioned at the top of the script; these are for window dressing (shows picture of operation) and to speed up computing the volume of a trimmed mesh. It uses a ETO GUI interface.
Notice that the mesh is split under the green boundary curve (reused from Trim operation). The green curve is like the red curve in your picture. The mesh faces cut by the boundary curve have been replaced by new triangles which are joined to the uncut mesh.
To use the script:
0. Display only 1 mesh in the Top View
Run the script. This will move the mesh to the Start layer and copy it to the Normal layer. The mesh on the Start layer is never changed. It is your original mesh.
Select an Operation
Enter a closed boundary curve (or Select or Reuse an existing curve)
Select options under Show Options
Press button in lower-left corner of GUI with name of operation (Split Mesh for last example).
Use Layers panel to control display of results.
This script works on all my meshes including many that Rhino’s built in Mesh Tools cannot split or trim correctly. It does not work on all meshes as there seems to be no limit to how many special cases there are that need special handling.
Hope this helps. I wrote this script because I could not get my meshes to split at all or in reasonable time. It is many times faster that Rhino’s Mesh Tools for splitting my large meshes (>5M faces).
If you are not into writing scripts or Python, then this may not be of much help to you. For my application of analyzing 3D models created from drone photos using photogrammetry, it is better than anything I have seen on the DroneDeploy and similar forums.
I greatly appreciate your generosity to share the script. And yes, I am doing this in python. Your script deals with closed boundary. I would like to know whether the “closed” condition is essential for using your method, since I don’t want the base mesh to be trimmed nor split. It will be one single mesh just with new vertices added locally. I want to make sure it is doable to make such tweaks from your procedures.
After having a glimpse of of your code, it seems to me that two most “line-consuming” procedures are find_naked_faces and make_replacement_faces. Are these two the main procedures for solving my problems? I will take some time to read in depth.
Lastly, just a simple suggestion for trimming your gigantic mesh. I would first do a delete mesh face operation to greatly reduce the mesh size.
Your suggestion for speeding up triming the mesh is interesting. I initially tried this but it is faster to create a new mesh inside the boundary and simply ignore the old, much bigger mesh outside the boundary. Much less data to process.
The code only works for a closed boundary curve but all of the curve does not have to lie on the mesh.
The two procedures you identified are the key ones.
Well something like your image doesn’t work on NURBS surfaces either - you need to have a full and complete intersection for Boolean operations to work, because it needs to analyze the split parts to see which to keep and which to remove. In the case above, MeshSplit works fine though to split the mesh quads while leaving the mesh plane “A” intact.
If you extend mesh “B” to the left so that it cuts all the way through mesh “A”, MeshBooleanSplit works.