Interactive three-dimensional visualization and creation of geometries for Monte Carlo calculations

Interactive three-dimensional visualization and creation of geometries for Monte Carlo calculations

ARTICLE IN PRESS Nuclear Instruments and Methods in Physics Research A 562 (2006) 827–829 www.elsevier.com/locate/nima Interactive three-dimensional...

266KB Sizes 0 Downloads 13 Views

ARTICLE IN PRESS

Nuclear Instruments and Methods in Physics Research A 562 (2006) 827–829 www.elsevier.com/locate/nima

Interactive three-dimensional visualization and creation of geometries for Monte Carlo calculations C. Theisa,, K.H. Bucheggerb, M. Bruggera, D. Forkel-Wirtha, S. Roeslera, H. Vinckea a

CERN, Geneva 23, CH-1211 Geneva, Switzerland GASCAD, Teichstrasse 2, A-4595 Waldneukirchen, Austria

b

Available online 9 March 2006

Abstract The implementation of three-dimensional geometries for the simulation of radiation transport problems is a very time-consuming task. Each particle transport code supplies its own scripting language and syntax for creating the geometries. All of them are based on the Constructive Solid Geometry scheme requiring textual description. This makes the creation a tedious and error-prone task, which is especially hard to master for novice users. The Monte Carlo code FLUKA comes with built-in support for creating two-dimensional cross-sections through the geometry and FLUKACAD, a custom-built converter to the commercial Computer Aided Design package AutoCAD, exists for 3D visualization. For other codes, like MCNPX, a couple of different tools are available, but they are often specifically tailored to the particle transport code and its approach used for implementing geometries. Complex constructive solid modeling usually requires very fast and expensive special purpose hardware, which is not widely available. In this paper SimpleGeo is presented, which is an implementation of a generic versatile interactive geometry modeler using off-the-shelf hardware. It is running on Windows, with a Linux version currently under preparation. This paper describes its functionality, which allows for rapid interactive visualization as well as generation of three-dimensional geometries, and also discusses critical issues regarding common CAD systems. r 2006 Elsevier B.V. All rights reserved. PACS: 07.05.T; 42.30.T; 02.50.N; 02.70.L Keywords: Constructive solid geometry; Monte Carlo simulations; FLUKA

1. Introduction The implementation of three-dimensional (3D) geometries for radiation transport simulations is a very timeconsuming and challenging task. Each particle transport code uses textual description and supplies its own scripting language, which makes the creation of geometries a nontrivial undertaking, especially for novice users. The Monte Carlo code FLUKA [1,2] comes with built-in support for creating two-dimensional cross-sections through the geometry and FLUKACAD, a custom-built converter to the commercial Computer Aided Design (CAD) package AutoCAD, exists for 3D visualization [3]. For other codes a couple of different tools are available, but they are often specifically tailored to the particle transport code and its Corresponding author. Tel.: +41 22 767 8069; fax: +41 22 767 5700.

E-mail address: [email protected] (C. Theis). 0168-9002/$ - see front matter r 2006 Elsevier B.V. All rights reserved. doi:10.1016/j.nima.2006.02.125

approach used for implementing geometries. Therefore, the decision was taken to implement the modeling framework SimpleGeo in a generic way based on principles of computer graphics rather than schemes applied by specific simulation packages. Consequently, export to various Monte Carlo codes can be provided. Interactive creation of 3D models is a very common problem in computer graphics as well as engineering. Nowadays, two different approaches, CAD and Constructive Solid Geometry (CSG) [4], govern the market of commercially available solutions. Both of them offer the means to let the designers inspect their models from different viewpoints, at different scales and allow for interactive modifications. However, the representation of the models is different and so is the way the creation of the geometry is performed by the designer. It should be noted that neither solution is better or worse but rather more or less suitable for the problem to be solved.

ARTICLE IN PRESS 828

C. Theis et al. / Nuclear Instruments and Methods in Physics Research A 562 (2006) 827–829

2. Geometric modeling 2.1. Computer aided design CAD packages are widely spread among the engineering community. If these packages do not include explicit support for solids a rigid body is represented by its boundary faces, which are made up of connected edges. Curved surfaces can be either approximated by patches of planar faces or, if available, using free-form surfaces like non-uniform rational B-splines. Consequently, an accurate or sometimes approximated visual model is created but inherent properties of the original solid are lost. For example a sphere will be approximated by a specified number of polygons which allows for visual identification as a sphere, although it is actually reduced to a collection of boundary faces. Depending on the application, like technical drawings for example, this loss of information is negligible because the visual information can still be perceived. The use of arbitrarily accurate face-patches instead of solids results in greater flexibility with respect to the construction process. However, the situation is more difficult considering the creation of geometries that are to be used in radiation transport problems. All Monte Carlo transport packages trace particles through geometric setups and therefore, efficient and accurate tracking algorithms are of crucial importance. This is exactly the weakness of CAD systems because the test whether a point is contained within a sphere, for example, will result in a point-in-polyhedron test. This requires a significantly large number of computations, whereas the test is trivial if the analytic formula describing the object is available. This clearly shows that regarding efficiency using standard CAD models for transport calculations results in a severe drawback with respect to the required runtime. One solution would be to opt for a coarser representation of the surface but one cannot avoid the tradeoff between geometric precision and CPU time requirements. In addition there are issues of accuracy, closure and consistency of the geometry which are discussed in more detail in Ref. [5].

Fig. 1. Hierarchical CSG tree used to model solids combining primitives and Boolean operations [6].

In general, the methods used for rendering CSG models can be classified into two categories: image space and object space approaches. Image space solutions include scanline, ray tracing, and various z-buffer algorithms [7]. Z-buffer algorithms do, depending on the complexity and size of the model, support interactive modeling but very often require special hardware because the whole CSG expression has to be reevaluated for every displayed image frame. For complex geometries object space methods are more favorable. The most obvious object space solution is to convert the analytic CSG model into an approximated boundary representation (B-rep), which is a native format for all common graphics systems. The basic concept of Breps is that a solid can be approximated by finding a discrete set of points on the surface. Connecting these vertices by edges results in a mesh of polygons approximating the solid. This approach allows for fast user interaction but has the tradeoff that in some pathological cases visualization artifacts, like missing faces, can occur due to numerical problems caused by the approximation. A detailed discussion of these issues would exceed the limits of this paper and can be found in Ref. [8]. However, these cases can be reduced by sophisticated algorithms and variation of the level of detail considered for the creation of the approximated bodies. 3. The implementation of SimpleGeo

2.2. Hierarchical constructive solid geometry Hierarchical CSG is a modeling scheme that represents 3D solids by a tree-graph whose leaves contain geometric primitives and whose nodes represent Boolean and affine operations (see Fig. 1). The fact that analytic descriptions are used makes this approach a much more suitable candidate for creating the geometries for radiation transport simulations because the aforementioned efficiency and consistency problems are inherently avoided. The native modeling operations include (1) instantiation of basic primitives, (2) creation of complex models made of basic primitives in a hierarchical way, using Boolean operations (union, difference, intersection), (3) application of affine operations (translation, rotation, scaling).

The motivation for SimpleGeo was the need for a generic interactive 3D visualization and geometry modeling tool for Monte Carlo transport codes. Major attention was paid to the requirement of an intuitive graphical user interface which would allow for fast and flexible creation and inspection of the models. In order to retain independence from specific simulation packages and the operating system the software architecture is built upon an object-oriented component model. Consequently, the user interface is decoupled from the modeling kernel which was written in standard C þ þ and is therefore easily portable to different operating systems. The only requirement is that OpenGL graphics libraries, upon which SimpleGeo’s rendering engine is based, are available. SimpleGeo is a hybrid

ARTICLE IN PRESS C. Theis et al. / Nuclear Instruments and Methods in Physics Research A 562 (2006) 827–829

829

geometries is supported and only a rudimentary FLUKA exporter is supplied. The latter will be replaced by a far more powerful version after the introduction of a new geometry-syntax in FLUKA. Due to the flexibility of the chosen implementation the system can be easily extended to handle different data formats. 4. Summary and future work

Fig. 2. Screenshot of the model of an ionization chamber in SimpleGeo.

solution which makes use of the analytic CSG representation as well as the B-rep that is used for rendering only. Consequently, it allows for fast and flexible user interaction but possible visualization artifacts have no impact on the created output files, as they are based solely on the CSG representation. In many geometry packages that are applied by Monte Carlo simulations all regions are defined in a universal coordinate system. With respect to the tracking algorithms this approach is very convenient. However it proves to be quite intricate for the user if changes in existing geometries are to be made. In order to move an entire particle detector the user would have to rewrite the description of every region-forming component, which can turn into an extremely laborious and also error-prone task. This problem is solved in SimpleGeo by the application of the hierarchical geometry model which inherently suggests relative coordinate frames for each hierarchy level. Consequently, any change in the position of, for example, a union operation affects all the primitives this union consists of. On one hand this facilitates modifications to the model and on the other hand enforces a logical structuring of the geometry. This structure can easily be manipulated by dragging and dropping elements or even whole sub-branches of the CSG tree. The resulting geometries, as can be seen in Fig. 2, are displayed in real time for inspection by the user. In addition, a generic data import and export interface was implemented, allowing for easy extension to different formats. For the time being the import of FLUKA

SimpleGeo is the implementation of a solid modeler which combines CSG as well as B-reps. This hybrid architecture allows for rapid and flexible visualization and creation of solid models for radiation transport codes. Due to the generic approach it is not limited to a specific Monte Carlo code but can be easily extended in the future. In addition to the rapid creation of geometries via dragand-drop also a scripting language for parametric modeling is included. Different rendering modes allow for the creation of 2D sketches as well as 3D renderings. Future work includes the extension of the supported Monte Carlo packages, geometry caching for optimization, additions to the macro language and also the development of geometry debugging facilities. Acknowledgments The authors would like to thank Josef Haslinger for valuable discussions, as well as Sabine Mayer, Markus Fuerstner, Joachim Vollaire and Heinz Vincke for supplying test scenarios and the time-consuming task of betatesting. References [1] A. Fasso`, A. Ferrari, P.R. Sala, Electron–photon transport in FLUKA: status, October 23–26, 2000, in: A. Kling, F. Barao, M. Nakagawa, L. Tavora, P. Vaz (Eds.), Proceedings of the MonteCarlo 2000 Conference, Lisbon, Springer-Verlag Berlin, 2001, pp. 159–164. [2] A. Fasso`, A. Ferrari, J. Ranft, P.R. Sala, FLUKA: Status and prospective for hadronic applications, in: A. Kling, F. Barao, M. Nakagawa, L. Tavora, P. Vaz (Eds.), Proceedings of the MonteCarlo 2000 Conference, October 23–26, 2000, Lisbon, Springer-Verlag Berlin, 2001, pp. 955–960. [3] H. Vincke, FLUKACAD/PIPSICAD: a 3 dimensional interface between FLUKA and Autocad, Proceedings of the SATIF-5 Workshop, 2000, pp. 361–370. [4] A.G. Requicha, ACM Comput. Surveys 12 (1980) 437. [5] T.M. Murali, T.A. Funkhouser, Consistent solid and boundary representations from arbitrary polygonal data, Proceedings of the 1997 Symposium on Interactive 3D Graphics, 1997. [6] N. Stewart, G. Leach, S. John, An improved Z-buffer CSG rendering algorithm, Eurographics/Siggraph Workshop on Graphics Hardware, 1998, pp. 25–30. [7] J. Goldfeather, J.P.M. Hultquist, H. Fuchs, Comput. Graphics 20 (4) (1986) 107. [8] M. Segal, ACM SIGGRAPH Comput. Graphics 24 (4) (1990) 105.