Problem 1875

Summary: G4Sphere missing polygons in cut plane after cutawayPlane
Product: Geant4 Reporter: hq.ks
Component: visualization/OpenGLAssignee: John.Allison
Status: RESOLVED LATER    
Severity: minor CC: hq.ks
Priority: P5    
Version: 10.2   
Hardware: PC   
OS: Linux   
Attachments: visualization with missing polygons

Description hq.ks 2016-06-29 18:53:05 CEST
When drawing a hollow sphere created by using G4Sphere, after applying a cutawayPlane, the part of the sphere in the half-space is correctly removed, but no new polygons are added in the plane of the cut. The resulting object is open, one can see through the half-sphere not affected by the cut. 

For comparision, with G4Boxes, the cutawayPlane creates new surface polygons in the cut plane, resulting in a closed object. 

sectionPlane works correctly for G4Sphere, adding polygons in the cut layer (and hiding everything else). So technically, the code to add the missing polygons should already be present in another function or something.
Comment 1 hq.ks 2016-06-29 18:54:37 CEST
Created attachment 408 [details]
visualization with missing polygons
Comment 2 John.Allison 2016-07-17 15:10:58 CEST
(Sorry to be so slow attending to this bug report.)

Can you tell me:

1) what graphics system you are using?  (OpenGL, HepRepFile,...?)

2) the exact command you used?
Comment 3 John.Allison 2016-08-14 12:28:15 CEST
Cutaways and sections are generally performed by Boolean operations.  However, for cutaways in OpenGL, clip planes are used.  Exactly what happens seems to be platform dependent but on my Mac it simply causes cutaway pixels not to be drawn so no new polygons are created and, as you put it, "The resulting object is
open, one can see through the half-sphere not affected by the cut."

This applies to any object so it is strange that it appears to be different for a G4Box.

By comparison, a section in OpenGL is performed by a Boolean operation (in fact, a Boolean intersection of all objects with a thin box).  In this case extra polygons are generated and the objects are closed.

So that explains your observations (apart from the strange observation with G4Box).

We do have this situation under review for two reasons:

1) Boolean operations can sometimes fail.  (It is difficult to avoid numerical errors in the calculations of intersecting polygons when, for example, edges and surfaces coincide.)  We have an on-going programme to improve this situation.

2) One can use clipping planes in OpenGL for sections - two back-to-back planes. Currently this is switched off, so Boolean intersection is used.  The reason is that clipping planes clip just about everything away but the Boolean processor (the it works) reconstructs the missing polygons.

Incidentally, OpenGL is the ONLY graphics system that currently supports cutaways.  Another way to get a cutaway is to use the following:

help /vis/scene/add/volume

Command /vis/scene/add/volume
Guidance :
Adds a physical volume to current scene, with optional clipping volume.
If physical-volume-name is "world" (the default), the top of the
main geometry tree (material world) is added.  If "worlds", the
top of all worlds - material world and parallel worlds, if any - are
added.  Otherwise a search of all worlds is made, taking the first
matching occurence only.  To see a representation of the geometry
hierarchy of the worlds, try "/vis/drawTree [worlds]" or one of the
driver/browser combinations that have the required functionality, e.g., HepRep.
If clip-volume-type is specified, the subsequent parameters are used to
to define a clipping volume.  For example,
"/vis/scene/add/volume ! ! ! -box km 0 1 0 1 0 1" will draw the world
with the positive octant cut away.  (If the Boolean Processor issues
warnings try replacing 0 by 0.000000001 or something.)
If clip-volume-type is prepended with '-', the clip-volume is subtracted
(cutaway). (This is the default if there is no prepended character.)
If '*' is prepended, the intersection of the physical-volume and the
clip-volume is made. (You can make a section/DCUT with a thin box, for
example).
For "box", the parameters are xmin,xmax,ymin,ymax,zmin,zmax.
Only "box" is programmed at present.