Skip to main content
1 of 3
userrandrand
  • 6.1k
  • 10
  • 35

If no mesh of the surface is ever parallel to the x,y or z plane then one can utilize the VertexNormals option for light shading to obtain the normals of the meshes in the x,y or z plane and remove them like this :

Normal@reg /. p_Polygon :> Nothing /; AllTrue[p[[2, 2]], MatchQ[Abs@Rationalize[#], {OrderlessPatternSequence[0, 1, 0]}] &] 

enter image description here

If the surface does have meshes that are parallel to the x, y or z plane then the direction of normals is not enough and one has to use the coordinates of these planes. Such a scenario is likely rare unless one has a piece wise function or a bad mesh but for completeness a code for such a scenario is included below.

The code below takes a couple {n,val} where n=1,2 or 3 for x,y or z and val is the constant value taken on the plane:

withinPlane[couple_][poly_] := AllTrue[Rationalize[poly[[1]], 0], #[[couple[[1]] ]] == couple[[2]] &]; 

Then one may remove the meshes belonging planes belonging to boundaries of the mesh region:

Normal@reg /. p_Polygon :> Nothing /; Or @@ Through@{withinPlane[{1, 0}], withinPlane[{1, 1}], , withinPlane[{2, 0}], withinPlane[{2, 20}], withinPlane[{3, 0}], withinPlane[{3, 10}]}@p 

Which leads to the same plot above.

userrandrand
  • 6.1k
  • 10
  • 35