# Why is RegionIntersection failing on my custom Region?

I load a custom region, specified as BoundaryMeshRegion

R = Import["C:\\data\\Profile.stl", "BoundaryMeshRegion"]


and I try to find an intersection

intersection = RegionIntersection[R, InfiniteLine[RegionCentroid[R], {1, 0, 0}]]
RegionMeasure[intersection]


Where

And I get errors:

Is this supposed to work ? I can't figure out what I am doing wrong, here's all the troubleshooting I could think of:

I would really appreciate any tips on what I am doing wrong, this functionality works with standard regions like Ball[], I would really like this to work on my region too!

• Please try to upload Profile.stl somewhere; your question is unanswerable otherwise. Oct 12, 2018 at 15:05
• File added ufile.io/jo8j6 ! Oct 12, 2018 at 19:12
• It seems like there's no intersection: Show[{R, DiscretizeRegion[InfiniteLine[RegionCentroid[R], {0, 0, 1}], RegionBounds[R]]}] Oct 15, 2018 at 13:07
• Thank you @halmir for pointing that out! I changed line direction to {1,0,0} to make sure they do cross, still same error though :( Line direction {0,1,0} produces the same error again Oct 15, 2018 at 19:39

As a workaround, you could take boundary polygons and find intersection:

poly = Polygon[MeshPrimitives[R, 2][[All, 1]]];

line = InfiniteLine[RegionCentroid[R], {1, 0, 0}];

intersection =
RegionIntersection[poly,
InfiniteLine[RegionCentroid[R], {1, 0, 0}]];

RegionMeasure[Line @@ intersection]


33.6465

or to reduce computation time:

polys = MeshPrimitives[R, 2];

ipolys = Pick[polys, RegionDisjoint[line, #] & /@ polys, False];

intersection = RegionIntersection[line, Polygon@ipolys[[All, 1]]]

• Thank you @halmir, this works! I can use it as a workaround for now, after I figure out what it does :) Oct 17, 2018 at 13:37