5
$\begingroup$

I'm trying to generate outer edges of two overlapping objects. I've thought that one can overlap objects with RegionUnion. However I don't want to get the inner edges to be drawn.

I tried the EdgeForm[] function, but couldn't manage to just generate the outer edges of the overlapping objects.

This is my attempt:

Graphics3D[
 {
  {Blue // Lighter // Lighter, Opacity[0.8]
   , RegionUnion[
    Parallelepiped[{-.25, -.5, 0}, {{.5, 0, 0}, {0, 1, 0}, {0, 0, -0.04}}]
    , Parallelepiped[{-.5, -.25, 0}, {{1, 0, 0}, {0, .5, 0}, {0, 0, -0.04} }]
    ]
   }
  , {Gray, Opacity[0.2], EdgeForm[],
   RegionUnion[
    Parallelepiped[{-.25, -.5, -0.04}, {{.5, 0, 0}, {0, 1, 0}, {0,  0, -0.08}}]
    , Parallelepiped[{-.5, -.25, -0.04}, {{1, 0, 0}, {0, .5, 0}, {0, 0, -0.08}}]
    ]}}]

enter image description here

Any suggestion? Thanks for reading

$\endgroup$

2 Answers 2

8
$\begingroup$

Region`Mesh`MergeCells

solids = {Parallelepiped[{-.25, -.5, 
     0}, {{.5, 0, 0}, {0, 1, 0}, {0, 0, -0.04}}], 
   Parallelepiped[{-.5, -.25, 
     0}, {{1, 0, 0}, {0, .5, 0}, {0, 0, -0.04}}], 
   Parallelepiped[{-.25, -.5, -0.04}, {{.5, 0, 0}, {0, 1, 0}, {0, 
      0, -0.08}}], 
   Parallelepiped[{-.5, -.25, -0.04}, {{1, 0, 0}, {0, .5, 0}, {0, 
      0, -0.08}}]};
mesh = BoundaryDiscretizeRegion[RegionUnion[solids]] // 
   Region`Mesh`MergeCells;
Graphics3D[{Blue // Lighter // Lighter, Opacity[0.8], mesh}]

enter image description here

$\endgroup$
7
$\begingroup$

One way by using the RegionPlot3D after converting the polyhedron(RegionUnion[..]) to Region.

solids = {Parallelepiped[{-.25, -.5, 0}, {{.5, 0, 0}, {0, 1, 0}, {0, 0, -0.04}}], 
Parallelepiped[{-.5, -.25, 0}, {{1, 0, 0}, {0, .5, 0}, {0, 0, -0.04}}], 
Parallelepiped[{-.25, -.5, -0.04}, {{.5, 0, 0}, {0, 1, 0}, {0, 0, -0.08}}], 
Parallelepiped[{-.5, -.25, -0.04}, {{1, 0, 0}, {0, .5, 0}, {0, 0, -0.08}}]};

RegionPlot3D[{Region@RegionUnion[solids]},PlotStyle -> Directive[Blue // Lighter // Lighter, Opacity[0.8]]]

enter image description here

$\endgroup$
2
  • $\begingroup$ I really like the rendering of this one, than the Graphics3D function. However as I'm working with more Graphic3D objects (text callouts, arrows, etc), the RegionPlot3D is uncompatible with my objects. (maybe i'm not constructing them properly) Thanks! How can I get this rendering for the Graphic3D function? $\endgroup$ Commented Jan 10, 2023 at 10:46
  • 1
    $\begingroup$ The RegionPlot3D returns Graphics3D as a head, therefore you can combine it with other Graphics3D objects by using the Show function or you can use it together with other objects inside a single Graphics3D call by removing the Graphics3D head e.g. Graphics3D[{Sphere[{0, .05, 0}, .1], List @@ RegionPlot3D[{Region@RegionUnion[solids]}, PlotStyle -> Directive[Blue // Lighter // Lighter, Opacity[0.8]]]}] $\endgroup$
    – vindobona
    Commented Jan 11, 2023 at 20:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.