# Problem layout pst-solides3d

I'm trying to have 2 cylinder pierce a parallelepiped, but I can't have the 2 cylinders properly drawed...

Here is what I got :

The two cylinders are within the box, and they pierce the yellow panel. I've got, as you can see, problems with the layout...

1° the front cylinder doesn't intersect the side panel

2° the second cylinder is the same as the first, so it should go through the yellow panel, but it isn't drawed...

Besides, I tried to change the view point, but it was worse... Why is the layout so dependant of the viewpoint ?

And finally, but I don't know if it can be done, the yellow panel have in fact 2 holes to let the cylinder go through it... I haven't find in the doc a way to do it... If you have any ideas...

Here's my code :

\psset{unit=0.25}
\begin{pspicture}[showgrid=false](-15,-10)(10,10)
\psset{Decran=90, solidmemory, action=none}%, viewpoint=5 -10 10}
%%% Back
\psSolid[
object=parallelepiped,%
a=3.5, b=0.12, c=1.22,
name=derriere]%
(0, -2.0 b 2 div sub, c 2 div b sub)
%%% Base
\psSolid[
object=parallelepiped,%
a=3.5, b=4.0, c=0.12,
fillcolor=black!20,
name=fond]%
(0,0,0 c 2 div sub)
%% Sides
\psSolid[
object=parallelepiped,%
a=0.12, b=4.0, c=1.1,
name=coteg]%
(-1.75 a 2 div add, 0, c 2 div)
\psSolid[
object=parallelepiped,%
a=0.12, b=4.0, c=1.1,
name=coted]%
(1.75 a 2 div sub, 0, c 2 div)
%%% Front
\psSolid[
object=parallelepiped,%
a=3.5, b=0.12, c=1.22,
fillcolor=yellow!50,
%action=none,
name=devant]%
(0, 2.0 b 2 div add, c 2 div b sub)
%%% Cylinders
\psSolid[
object=cylindrecreux,
h=2,r=0.45,
fillcolor=green!50,
mode=4,
incolor=black!50,
RotX=-90,
name=ant1]
(a 4 div 0.1 sub, 0.2, 0.5)

\psSolid[
object=cylindrecreux,
h=2,r=0.45,
fillcolor=green!50,
mode=4,
incolor=black!50,
RotX=-90,
name=ant2]
(-0.875, 0.2, 0.5)
\psSolid[object=fusion,
action=draw**,
base=devant ant1 ant2 derriere fond coteg coted,
](0,0,0)
\composeSolid

\end{pspicture}

• seems interesting. Tomorrow gonna try it. – Troy Woo Nov 14 '14 at 22:31

Explanation

The problem is obvious after I observed the examples from the package document: You simply don't have enough subdivision for the sides. The fusion object does not perform any Boolean operation at all, but simply remove the patches that are invisible. When the patches are not dense enough, the effect as shown in your figure appears.

Solution

Since parallelepiped does not have a ngrid parameter, I took the pain to scale a cube instead. But then I have to tweak the actual displacement of the sides (it can always be computed automatically but I am lazy XD). Now you can see this is not as nearly perfect, but it makes my point: it is always better to use custom defined object, says Herbert.

My ugly code...

\psset{unit=0.25}
\begin{pspicture}[showgrid=false](-15,-10)(10,10)
\psset{Decran=90, solidmemory, action=none}%,viewpoint=10 45 25 rtp2xyz}
%%% Back
\psSolid[
object=parallelepiped,%
a=3.5, b=0.12, c=1.22,
name=derriere]%
(0, -2.0 b 2 div sub, c 2 div b sub)
%%% Base
\psSolid[
object=parallelepiped,%
a=3.5, b=4.0, c=0.12,
fillcolor=black!20,
name=fond]%
(0,0,0 c 2 div sub)
%% Sides
\psSolid[
object=parallelepiped,%
a=0.12, b=4.0, c=1.1,
name=coteg]%
(-1.75 a 2 div add, 0, c 2 div)
%%% Cylinders
\psSolid[
object=cylindrecreux,
h=2,r=0.45,
fillcolor=green!50,
mode=4,ngrid=25 18,
incolor=black!50,
RotX=-90,
name=ant1]
(a 4 div 0.1 sub, 0.2, 0.5)
\psSolid[
object=cylindrecreux,
h=2,r=0.45,
fillcolor=green!50,
mode=4,ngrid=25 18,
incolor=black!50,
RotX=-90,
name=ant2]
(-0.875, 0.2, 0.5)
%% Sides front
\psSolid[
object=cube,%
a=0.12, b=4.0, c=1.1,ngrid=2,
name=coted,transform={1 33.3 9.17 scaleOpoint3d}]%
(1.75 a 2 div sub, 0, c 2 div .49 sub)
%%% Front
\psSolid[
object=cube,%
a=3.5, b=0.12, c=1.22,ngrid=10,
fillcolor=yellow!50,transform={1 .0343 .3486 scaleOpoint3d},
%action=none,
name=devant]%

Beware though that, in the case of fusion, transform={ a b c scaleOpiont3d} of one object seems to affect the others too if their codes come after it. I have to use transform={ 1 1 1 scaleOpiont3d} to nullify this effect...
In this case, dear @Herbert, is it possible to create a new parameter ngrid=a b c for parallelepiped? and also fix the problem with scaleOpoint3d as I mentioned in the above paragraph?