Skip to main content
added 295 characters in body
Source Link
userrandrand
  • 6.1k
  • 10
  • 35

Simple case (works here)

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. These normals look like {0,0,1}, {0,-1,0}, {0,1,0} etc but as floating point real numbers. Hence, we may remove them like this :

(Note the usage of Normal below to convert the GraphicsComplex structure into an ordinary list of graphics primitives and directives to facilitate pattern matching)

(p[[2]] below has the form VertexNormals-> {values__} ) :

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

enter image description here

That works except maybe if one explicitly changes the VertexNormals option via NormalsFunction or something.

More complicated scenario with piecewise constant surfaces (not the case 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 as argument a polygon poly and 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 to planes at the boundaries of the plot:

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.

Simple case (works here)

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 (p[[2]] below has the form VertexNormals-> {values__} ) :

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

enter image description here

That works except maybe if one explicitly changes the VertexNormals option via NormalsFunction or something.

More complicated scenario with piecewise constant surfaces (not the case 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 as argument a polygon poly and 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 to planes at the boundaries of the plot:

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.

Simple case (works here)

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. These normals look like {0,0,1}, {0,-1,0}, {0,1,0} etc but as floating point real numbers. Hence, we may remove them like this :

(Note the usage of Normal below to convert the GraphicsComplex structure into an ordinary list of graphics primitives and directives to facilitate pattern matching)

(p[[2]] below has the form VertexNormals-> {values__} )

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

enter image description here

That works except maybe if one explicitly changes the VertexNormals option via NormalsFunction or something.

More complicated scenario with piecewise constant surfaces (not the case 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 as argument a polygon poly and 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 to planes at the boundaries of the plot:

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.

added 295 characters in body
Source Link
userrandrand
  • 6.1k
  • 10
  • 35

Simple case (works here)

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 (p[[2]] below has the form VertexNormals-> {values__} ) :

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

enter image description here

That works except maybe if one explicitly changes the VertexNormals option via NormalsFunction or something.

More complicated scenario with piecewise constant surfaces (not the case 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 as argument a polygon poly and 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 planes at the boundaries of the mesh regionplot:

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.

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.

Simple case (works here)

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 (p[[2]] below has the form VertexNormals-> {values__} ) :

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

enter image description here

That works except maybe if one explicitly changes the VertexNormals option via NormalsFunction or something.

More complicated scenario with piecewise constant surfaces (not the case 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 as argument a polygon poly and 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 to planes at the boundaries of the plot:

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.

Source Link
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.