Polysurface completely intersects another solid --> approximate split by a planar cut

Hi there,

assume the scenario in the following image:

The polysurface “cuts” the block in two, e.g. using BooleanSplit I could easily do a split in Rhino. However, I want that splitting to be approximated by a planar cut (since my output has to consist of planar-sided blocks only). How could I approach that most effectively?

Extract the points where the edges are cut by the surface, then defining a plane from 3 of them and altering the rest accordingly? Are there any built-in functionalities you could recommended in order to make this process as simple as possible?

Hi wtfermi,

I would try using Plane.FitPlaneToPoints method instead of generating a plane from three non colinear points. I would cut the curved surface with box instead, then get the vertices from the inner part of that cut surface (vertices = Brep.DuplicateVertices()) and then find a plane from four of its vertices: plane = Plane.FitPlaneToPoints(pts)[1].

Other solution might be to use Surface.TryGetPlane method (with somewhat increased tolerance argument), “Surface” being the upper mentioned inner part of cut surface.

Thanks for your reply, the FitPlaneToPoints method seems to be exactly what I’m looking for.
One quick question about your answer though: How do I quickly find out, which one is the inner part of the cut surface?

For example, I would count the number of edges. The inner part would have 4, while the outer would have more than 4: innerCutBrep.Edges.Count.
The same goes for vertices: innerCutBrep.Vertices.Count.

You can also check for the inner loops:

import rhinoscriptsyntax as rs
import Rhino

boxId = rs.GetObject("pick up the box")
surfaceId = rs.GetObject("pick up the surface")
box = rs.coercebrep(boxId)
cutter = rs.coercebrep(surfaceId)

tol = Rhino.RhinoDoc.ActiveDoc.ModelAbsoluteTolerance
splittedCutterParts = cutter.Split(box, tol)

# check if splittedCutterParts[0] has holes:
loops = splittedCutterParts[0].Faces[0].Loops
for l in loops:
    if l.LoopType == Rhino.Geometry.BrepLoopType.Inner:
        print "there's a hole"
        break
else:
    print "no holes"

Or maybe even check for the edges adjacency to see how many of naked ones each one has (outer would have more naked edges):

# the same as upper code until "# check if splittedCutterParts[0] has holes:" line

nakedEdges = []
for part in splittedCutterParts:
    brepEdges = part.Edges
    itemList = []
    for edge in brepEdges:
        edgeAdj = edge.Valence
        if edgeAdj == Rhino.Geometry.EdgeAdjacency.Naked:
            itemList.append(edge.DuplicateCurve())
    nakedEdges.append(itemList)

if len(nakedEdges[0]) > len(nakedEdges[1]):
    splittedCutter = splittedCutterParts[1]
else:
    splittedCutter = splittedCutterParts[0]