Grasshopper

algorithmic modeling for Rhino

Hi, 

I am trying to split breps which consist of several curved surfaces joined together. The grasshopper 'split brep' component works well for splitting one brep into two pieces using a second cutting brep, but I would like to split large breps into smaller ones with several cutting breps. 

I have managed to get something working well using a VB component, with the short script below, but this falls down for some of the breps, as the order of resulting breps from each split is not intuitive.

Does anyone have any insight into the order in which split brep results are returned? Doesn't seem to be based on relative area of the resulting pieces, direction of the splitting brep, or sorted points. 

Dim split_breps_A As New list (Of brep)
Dim split_breps_D As New list (Of brep)
Dim brep_A As Brep
Dim brep_D As Brep

Dim srf_areas As New list (Of Double)
For i As int32 = 0 To C.count - 1
Brep_A = B.Split(C(i), 0.0000001)(0)
Brep_D = B.Split(C(i), 0.0000001)(1)
B = Brep_D
split_breps_A.add(Brep_A)
split_breps_D.add(Brep_D)
srf_areas.add(Brep_A.GetArea)
If i = C.count - 1 Then
srf_areas.add(Brep_D.GetArea)
split_breps_A.add(Brep_D)
End If
Next i
A = split_breps_A
D = split_breps_D
Area = srf_areas

Views: 4707

Replies to This Discussion

Not the most elegant of solutions, probably, but works for the next set of geometry, at least. The split fragments are tested against distance to the next splitting brep to make sure the split process goes in the right direction. The updated Brep split sequence below, and full cluster attached. Note that tolerance is absolute rather than document tolerance - due to the integrity of the inherited Rhino geometry we didn't want to increase document tolerance to ensure splitting. 

If anyone has a better method of shattering Breps.... please share.

Dim split_breps_A As New list (Of brep)
Dim split_breps_D As New list (Of brep)
Dim brep_A As Brep
Dim brep_D As Brep
Dim srf_areas As New list (Of Double)
Dim dist_A As Double
Dim dist_d As Double

For i As int32 = 0 To C.count - 2
Brep_A = B.Split(C(i), 0.0000001)(1)
Brep_D = B.Split(C(i), 0.0000001)(0)
dist_A = P(i + 1).DistanceTo(Brep_A.ClosestPoint(P(i + 1)))
dist_D = P(i + 1).DistanceTo(Brep_D.ClosestPoint(P(i + 1)))
If dist_a < dist_d Then
B = Brep_A
split_breps_A.add(Brep_d)
split_breps_D.add(Brep_a)
Else
B = Brep_D
split_breps_A.add(Brep_A)
split_breps_D.add(Brep_D)
End If
Next i

If dist_A < dist_D Then
split_breps_A.add(B.Split(C(C.Count - 1), 0.0000001)(0))
split_breps_A.add(B.Split(C(C.Count - 1), 0.0000001)(1))
Else
split_breps_A.add(B.Split(C(C.Count - 1), 0.0000001)(1))
split_breps_A.add(B.Split(C(C.Count - 1), 0.0000001)(0))
End If

A = split_breps_a
D = split_breps_d

Attachments:

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service