{"id":1385,"date":"2023-10-31T12:33:51","date_gmt":"2023-10-31T12:33:51","guid":{"rendered":"https:\/\/uneedtalk.com\/config\/tredword\/?page_id=1385"},"modified":"2023-12-01T13:17:05","modified_gmt":"2023-12-01T13:17:05","slug":"7-3-3d-model-and-geometry-modules","status":"publish","type":"page","link":"https:\/\/radi-cal.org\/method\/7-3-3d-model-and-geometry-modules\/","title":{"rendered":"7.3. 3D model and geometry modules"},"content":{"rendered":"<div class=\"row\"  id=\"row-744812284\">\n<div class=\"col small-12 large-12\"  ><div class=\"col-inner\" style=\"padding:0px 0px 0px 0px;margin:0px 0px -43px 0px;\" >\n<h1>7.3. 3D model and geometry modules<\/h1>\n<\/div><\/div>\n<div class=\"col medium-7 small-12 large-7\"  ><div class=\"col-inner\"  >\n<h2>7.3.1. OBJ file import<\/h2>\n<p>In order to maximize the potential application of the software, an import module allowing the import of standard CAD files was implemented. There are various common file formats used to store and deploy threedimensional CAD models. Because of its simplicity and widespread use as an exchange format, the OBJ format (The Library of Congress (USA), no date; Bourke, 2022) has been chosen for implementation.<br \/>\nThe format is clear-text-based, so it can be viewed with any text file editor. The following sample shows the data of a simple triangulated cube with a dimension of one located at the origin (see Figure 95).<\/p>\n<\/div><\/div>\n<div class=\"col medium-5 small-12 large-5\"  ><div class=\"col-inner text-center\"  >\n\t<div class=\"img has-hover x md-x lg-x y md-y lg-y\" id=\"image_2060360357\">\n\t\t\t\t\t\t\t\t<div class=\"img-inner dark\" >\n\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"257\" height=\"290\" src=\"https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/16-1.jpg\" class=\"attachment-original size-original\" alt=\"\" \/>\t\t\t\t\t\t\n\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\n<style scope=\"scope\">\n\n#image_2060360357 {\n  width: 89%;\n}\n<\/style>\n\t<\/div>\n\t\n<\/div><\/div>\n<div class=\"col small-12 large-12\"  ><div class=\"col-inner text-center\"  >\n\t<div class=\"img has-hover x md-x lg-x y md-y lg-y\" id=\"image_637911828\">\n\t\t\t\t\t\t\t\t<div class=\"img-inner dark\" >\n\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"946\" height=\"628\" src=\"https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/17-1.jpg\" class=\"attachment-original size-original\" alt=\"\" srcset=\"https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/17-1.jpg 946w, https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/17-1-603x400.jpg 603w, https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/17-1-768x510.jpg 768w\" sizes=\"(max-width: 946px) 100vw, 946px\" \/>\t\t\t\t\t\t\n\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\n<style scope=\"scope\">\n\n#image_637911828 {\n  width: 93%;\n}\n<\/style>\n\t<\/div>\n\t\n<\/div><\/div>\n<div class=\"col small-12 large-12\"  ><div class=\"col-inner\"  >\n<p>Firstly a list of vertices (\u201cv\u201d) and normal vectors (\u201cvn\u201d) is contained. In the bottom section, the indices of these elements are referenced (\u201cf\u201d) to define 12 triangular surfaces. While the format allows additional features, see e.g. (Bourke, 2022), the data contained in this simple example covers all types that are required for importing geometry to the RadiCal method. Beyond the features contained in the above example, only the functionality to import texture coordinates is additionally implemented. The texture feature can potentially be used to define the directional system for non-isotropic surface roughness. However, this feature is currently not fully implemented in the raytracer.<\/p>\n<h2>7.3.1.1. Implementation<\/h2>\n<p>The OBJ import is contained in class TimportOBJ of the module rc_OBJimport. <\/p>\n<\/div><\/div>\n<div class=\"col small-12 large-12\"  ><div class=\"col-inner text-center\"  >\n\t<div class=\"img has-hover x md-x lg-x y md-y lg-y\" id=\"image_1347295079\">\n\t\t\t\t\t\t\t\t<div class=\"img-inner dark\" >\n\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"927\" height=\"397\" src=\"https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/18-1.jpg\" class=\"attachment-large size-large\" alt=\"\" srcset=\"https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/18-1.jpg 927w, https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/18-1-800x343.jpg 800w, https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/18-1-768x329.jpg 768w\" sizes=\"(max-width: 927px) 100vw, 927px\" \/>\t\t\t\t\t\t\n\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\n<style scope=\"scope\">\n\n#image_1347295079 {\n  width: 86%;\n}\n<\/style>\n\t<\/div>\n\t\n<\/div><\/div>\n<div class=\"col small-12 large-12\"  ><div class=\"col-inner\"  >\n<p>The class contains solely the function ReadOBJ which performs the import. All required additional routines are contained within this function. The function returns the imported geometry (geo), extracted material list (mlib) and a list with errors or warnings (errList) that can potentially occur during the import.<br \/>\nApart from the filename (fn) the function has two input parameters that are used to control the function of the smooth shading feature (see 7.6). Additionally, an optional array can be passed to the function triggering an automatic subdivision of the geometry during the import. This array provides the relevant material identifiers (as strings) and the subdivision limit that should be applied during the import for the specified material layer.<\/p>\n<h2>7.3.2. Internal geometry definitions<\/h2>\n<p>Internally, the imported geometry is stored in a hierarchical structure: The master node (TRCGeometry) contains a list of objects (TRCGeoObject), and each object contains a list of faces (TRCface). Along with the objects, the boundary boxes (relevant to collision detection) are included at each level.<\/p>\n<\/div><\/div>\n<div class=\"col small-12 large-12\"  ><div class=\"col-inner text-center\"  >\n\t<div class=\"img has-hover x md-x lg-x y md-y lg-y\" id=\"image_851023073\">\n\t\t\t\t\t\t\t\t<div class=\"img-inner dark\" >\n\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"909\" height=\"471\" src=\"https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/19-1.jpg\" class=\"attachment-large size-large\" alt=\"\" srcset=\"https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/19-1.jpg 909w, https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/19-1-772x400.jpg 772w, https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/19-1-768x398.jpg 768w\" sizes=\"(max-width: 909px) 100vw, 909px\" \/>\t\t\t\t\t\t\n\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\n<style scope=\"scope\">\n\n#image_851023073 {\n  width: 100%;\n}\n<\/style>\n\t<\/div>\n\t\n<\/div><\/div>\n<div class=\"col small-12 large-12\"  ><div class=\"col-inner\"  >\n<p>As shown in the class definitions above, the 3D data contained in the OBJ file is stored in a hierarchical structure that additionally contains pre-computed data to increase the performance of the raytracing algorithm.<\/p>\n<\/div><\/div>\n<div class=\"col medium-5 small-12 large-5\"  ><div class=\"col-inner\"  >\n<p>The three vertices provided by the OBJ face definition are converted into a face origin (v0) and two vectors (edge1, edge2). Based on the edge vectors, a local reference system is precomputed for every face (lxv, lyv, snv). The x-axis of the reference system is aligned to the edge1 vector, whereas the z-axis is aligned to the surface normal vector of the face. If the imported model contains normal vectors defined on the vertices (s0, s1, s2) the smooth shading function can be used to derive surface smooth normal vectors throughout the face<\/p>\n<\/div><\/div>\n<div class=\"col medium-7 small-12 large-7\"  ><div class=\"col-inner text-center\"  >\n\t<div class=\"img has-hover x md-x lg-x y md-y lg-y\" id=\"image_575855966\">\n\t\t\t\t\t\t\t\t<div class=\"img-inner dark\" >\n\t\t\t<img loading=\"lazy\" decoding=\"async\" width=\"561\" height=\"436\" src=\"https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/20-1.jpg\" class=\"attachment-large size-large\" alt=\"\" srcset=\"https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/20-1.jpg 561w, https:\/\/radi-cal.org\/method\/wp-content\/uploads\/2023\/10\/20-1-515x400.jpg 515w\" sizes=\"(max-width: 561px) 100vw, 561px\" \/>\t\t\t\t\t\t\n\t\t\t\t\t<\/div>\n\t\t\t\t\t\t\t\t\n<style scope=\"scope\">\n\n#image_575855966 {\n  width: 84%;\n}\n<\/style>\n\t<\/div>\n\t\n<\/div><\/div>\n<div class=\"col small-12 large-12\"  ><div class=\"col-inner\"  >\n<p>(see 7.6). If no vertex normals are contained in the file, a single constant surface normal vector (snv) is generated by applying the cross-product of edge1 and edge2. The direction of the surface normal vector is used to distinguish the front and backside of the surface. The definition follows the convention of computer graphics: a counter-clockwise sequence of the vertices defines the front side of the surface, while the clockwise order defines its back side. Based on the ordinal variables frontID and backID, each side can be assigned a different surface material.<\/p>\n<\/div><\/div>\n<\/div>\n<style>\n#menu-main li:nth-child(7) .sub-menu{display:block !important;}\n<\/style>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"page-right-sidebar.php","meta":{"footnotes":""},"_links":{"self":[{"href":"https:\/\/radi-cal.org\/method\/wp-json\/wp\/v2\/pages\/1385"}],"collection":[{"href":"https:\/\/radi-cal.org\/method\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/radi-cal.org\/method\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/radi-cal.org\/method\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/radi-cal.org\/method\/wp-json\/wp\/v2\/comments?post=1385"}],"version-history":[{"count":20,"href":"https:\/\/radi-cal.org\/method\/wp-json\/wp\/v2\/pages\/1385\/revisions"}],"predecessor-version":[{"id":1979,"href":"https:\/\/radi-cal.org\/method\/wp-json\/wp\/v2\/pages\/1385\/revisions\/1979"}],"wp:attachment":[{"href":"https:\/\/radi-cal.org\/method\/wp-json\/wp\/v2\/media?parent=1385"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}