An optical device simulation method and system based on a boundary representation model non-sequence ray tracing
By preprocessing the B-Rep model and employing differentiated ray intersection strategies, combined with a nested spatial hierarchy acceleration structure, the problems of repeated intersection and unstable boundary hits in optical simulation are solved, achieving efficient and stable optical device simulation, suitable for optical path simulation and verification of complex optical systems.
Patent Information
- Application Number
- CN202611564265.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-10
- Publication Date
- 2026-11-06
AI Technical Summary
Existing optical simulation methods face problems such as high overhead of repeated intersection calculations, low efficiency of solving complex freeform surfaces, high cost of determining the validity of clipping regions, and unstable hit results near clipping boundaries in accurate B-Rep model scenarios, making it difficult to meet the requirements of high precision, high efficiency, and high robustness.
A non-sequential ray tracing method based on a boundary representation model is adopted. By performing unified preprocessing on the B-Rep structure, a clipping surface representation and a differentiated ray intersection strategy are established. Combined with nested spatial hierarchy to accelerate structure and parameter domain determination, the intersection process between rays and CAD models is optimized, reducing the overhead of repeated intersection and improving the hit stability near the clipping boundary.
While maintaining the original geometric accuracy of optical devices, it significantly improves the computational efficiency and stability of optical simulation, provides high-precision optical propagation capabilities, and is suitable for scenarios such as stray light analysis, illumination system design, freeform surface optical device analysis, and optomechanical co-simulation.
Smart Images

Figure CN123049959A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of optical simulation and optomechanical joint analysis technology, and relates to an optical device simulation method and system based on non-sequential ray tracing using a boundary representation model. Background Technology
[0002] Optical device simulation is a fundamental supporting step in the modern optical product development process. Whether it's consumer electronics such as mobile phone cameras, automotive cameras, projection and display modules, or high-end equipment like automotive lighting, head-up displays, LiDAR, medical imaging, industrial inspection, aerospace remote sensing, telescopes, and space payloads, the development process relies heavily on the early prediction of light path propagation behavior. Through simulation, researchers can assess whether a system meets requirements for image quality, illumination uniformity, stray light suppression, energy utilization, and thermo-mechanical-optical assembly tolerances before manufacturing physical prototypes. This reduces the number of trial production cycles, shortens the development timeline, and lowers material and processing costs.
[0003] Compared to the traditional process of prototyping and then repeatedly testing and failing, the value of optical simulation lies not only in cost savings but also in enabling R&D activities to be completed in the digital space. This is especially important for optical systems with complex structures, sensitive assembly and adjustment, or extremely high prototyping costs. For example, in stray light analysis, engineers want to identify light paths that may cause ghosting, glare, light leakage, and reduced contrast during the design phase; in lighting system design, engineers want to confirm the results of multiple interactions of light in light guides, reflectors, reflectors, and diffusion structures before manufacturing; and in optomechanical co-design, the influence of non-optical components such as mechanical housings, supports, pressure rings, light shields, and lens barrels on light propagation must also be considered.
[0004] Therefore, optical device simulation is not simply the calculation of the main optical path of a lens, but a system-level analysis problem that needs to cover both optical and mechanical components for complex assemblies. Its industrial significance is reflected not only in the verification of imaging and illumination performance, but also in key R&D stages such as process manufacturability analysis, tolerance analysis, stray light rectification, and structural linkage optimization.
[0005] In optical simulations, especially in non-sequential ray tracing scenarios, light rays do not propagate according to a pre-defined surface sequence, but rather interact with any object in the scene according to real physical processes. Light rays may be reflected, refracted, transmitted, or scattered multiple times between lenses, prisms, mirrors, freeform surface devices, light guides, reflectors, lens barrels, supports, and light-blocking structures. They may also split into multiple successor rays after a single impact to continue propagating.
[0006] This means that for the outer-layer optical simulation system, one of the most fundamental and frequent core operations is the repeated invocation of the ability to "intersect the ray with the current CAD scene". Each ray path advancement requires answering at least two questions: which valid face the current ray first hits, and what the normal, the face to which it belongs, the solid to which it belongs, and, if necessary, the boundary nearest neighbor information for that hit point.
[0007] In real-world industrial tasks, the number of light rays is often enormous. To obtain statistically stable results for illuminance, energy distribution, or stray light paths, simulation systems often need to emit a large number of sampled rays and continue tracing them after each reflection, refraction, or scattering. The throughput efficiency of the intersection kernel directly determines the usability of the entire optical simulation; while the intersection accuracy and robustness directly affect the reliability of subsequent physical calculations. Therefore, optical device simulation places a combination of requirements on the intersection of light rays and CAD models: high accuracy, high throughput, reusability, and stable handling of boundary conditions.
[0008] Industrial optical systems are not composed of only idealized analytical surfaces. Actual models often include analytical surface devices such as lenses, spherical mirrors, cylindrical mirrors, conical mirrors, and prisms, as well as complex surface devices such as freeform lenses, freeform mirrors, light homogenizers, and light guides, and mechanical CAD parts such as housings, lens barrels, supports, pressure rings, spacers, light-blocking plates, and mounting bases.
[0009] These objects are typically maintained jointly by different roles during collaborative R&D. Optical engineers focus on refraction, reflection, aberrations, ghosting, and stray light paths; mechanical engineers focus on assembly space, constraint relationships, occlusion structures, and manufacturability; and systems engineers focus on the performance convergence of the entire assembly. To ensure the uniformity and traceability of geometric information, STEP, IGES, or native CAD files are widely used for exchange in industrial processes. Their geometric representation is usually B-Rep, which uses precise surfaces, edges, vertices, and their topological adjacency relationships to describe solid boundaries.
[0010] B-Rep's advantage lies in preserving the mathematical accuracy and topological semantics of surfaces, which is directly significant for the simulation of optical devices. Many optical performance problems occur precisely in minute structures, curvature variations, near boundaries, or in details of mechanical occlusion. If the model is discretized into a coarse triangular mesh during the input stage, curvature approximation errors, normal errors, boundary cracks, and topological degradation will be introduced, which will then be amplified in subsequent reflection direction, refraction direction, path statistics, and energy distribution results.
[0011] While B-Rep provides accurate representations for industrial models and forms the basis for optical device modeling and ray tracing simulation, performing high-performance ray intersection directly on B-Rep is not easy and cannot well meet the efficiency and stability requirements of large-scale optical simulations. At least the following challenges exist: 1) In B-Rep models, a face is often a combination of the underlying parametric surface and the clipping boundary of the parametric domain. In the process of ray tracing in optical device simulation, even if the ray intersects with the underlying surface, the intersection point may not fall within the effective clipping area of the optical device. Therefore, "finding the intersection point of the surfaces" and "confirming a valid hit" are two different levels of problems.
[0012] 2) The types of faces in the optomechanical assembly are highly mixed, including analytical optical surfaces suitable for closed-form solutions such as planes, spheres, cylinders, and cones, as well as a large number of freeform optical surfaces such as BSpline, NURBS, or Bezier. If a uniform general numerical solution strategy is used for all surfaces, significant redundant overhead will be generated, reducing the overall efficiency of optical simulation.
[0013] 3) For the freeform surfaces at the core of optical devices, the solution of intersection points usually relies on local iterative refinement. If there is a lack of good local candidate region screening and initial value control, iterative solution can easily become a performance bottleneck in optical simulation, and may even lead to unstable convergence, affecting the accuracy of optical simulation.
[0014] 4) In optomechanical industrial CAD models, parameter domain clipping curves are often very complex, especially intersection lines fitted by low-order, long-node vector spline curves. Determining the validity of intersection points within and outside the parameter domain can easily evolve from a secondary step into a major time-consuming process, hindering the iteration speed of large-scale optical simulations.
[0015] 5) Optomechanical CAD models from different software or different process flows often have problems such as inconsistent geometric tolerances, inconsistencies between parameter domain clipping curves and 3D boundary curves, and ambiguity in hit assignment near common edges. Without robust design, misjudgments can easily occur near the boundaries of optical devices.
[0016] 6) Optical simulations often involve near-grazing shots, near-shared edges, near-coplanar shots, and repeated hits on the same optical device. Geometric intersection calculations must be both fast and stable; otherwise, the results of higher-level optical simulations will fluctuate significantly.
[0017] Existing optical simulation solutions can be broadly categorized into two types: one type directly utilizes the intersection capabilities provided by a general geometric kernel on precise CAD and B-Rep models; the other type first discretizes the CAD surface into a triangular mesh and then performs intersection calculations between rays and the mesh.
[0018] The first type of scheme can retain high geometric accuracy, but it usually still has the following limitations when dealing with large-scale non-sequential ray tracing: 1) The design goals of general geometry kernels are usually more inclined towards versatility, completeness and compatibility with a wide range of modeling tasks, rather than deep optimization for optical simulation call patterns where the same B-Rep optical engine scene is repeatedly queried by a large number of rays.
[0019] 2) Many solutions' spatial accelerations mainly focus on model-level or object-level candidate selection, lacking cross-layer collaborative optimization around trimmed faces. Even after candidate faces have been selected, significant redundant overhead may still occur in the face-level solution, freeform surface local search, and parameter domain validity determination stages.
[0020] 3) For optical freeform surfaces, existing solutions often fail to fully utilize the combination of local patches, local bounding volumes, and reasonable initial values in the parameter domain to shrink the solution domain, resulting in a large workload for numerical iteration.
[0021] 4) For the final legality determination of trimmed faces, existing methods usually adopt segment-by-segment judgment, cross-counting, discrete approximation or hierarchical organization. These methods are prone to becoming bottlenecks when facing complex clipping boundaries of optomechanical models, and the boundary robustness is limited.
[0022] 5) Existing solutions typically do not explicitly utilize clipping information in the preprocessing stage to preemptively eliminate local regions of freeform surfaces that are unlikely to form a valid hit, resulting in a large number of parametric patches that fall outside the clipping domain still being retained in the optical simulation runtime path.
[0023] 6) When light rays approach the common edge, common vertex, or very close adjacent surfaces of two faces, if only a single nearest intersection point is output, it is easy for the surface assignment of the optical device to jump under different numerical perturbations, which is not conducive to the upper-level optical simulation module to perform stable boundary propagation processing.
[0024] While the second type of triangulation scheme is easy to integrate into standard computer graphics ray tracing workflows, it has at least the following drawbacks: 1) Triangulation of high-precision CAD surfaces introduces risks of normal error, curvature approximation error, and boundary cracks, which can cause the direction of light reflection and refraction to shift, thus reducing the accuracy of optical simulation.
[0025] 2) To ensure the accuracy of optical simulation, a large number of triangular faces are often required, which leads to a significant increase in preprocessing, storage and traversal overhead.
[0026] 3) For optical devices with small features, thin walls, freeform surface boundaries, and near-boundary optical paths, triangulation errors are more likely to accumulate, affecting the reliability of optical simulations.
[0027] Therefore, there is a need for an optical device simulation method that can directly address high-precision CAD and B-Rep optomechanical models and is suitable for embedding non-sequential ray tracing workflows. This method should not only maintain the geometric semantics of accurate surfaces and clipping boundaries, but also integrate and optimize model-level candidate selection, freeform surface local solution, parameter domain clipping validity determination, and boundary nearest neighbor hit stability around the calling form of optical simulation, thereby simultaneously meeting the requirements of high precision, high efficiency, and high robustness in optical simulation. Summary of the Invention
[0028] The purpose of this invention is to provide an optical device simulation method and system based on a non-sequential ray tracing method using a boundary representation model. This addresses the problems faced by existing optical simulation methods in accurate B-Rep model scenarios, such as high overhead from repetitive intersection calculations, low efficiency in solving complex freeform surfaces, high cost of determining the validity of clipped regions, and unstable hit results near clipped boundaries. By directly establishing an efficient and robust ray intersection and boundary determination mechanism oriented towards the CAD boundary representation model, this invention can provide reusable, high-precision geometric propagation capabilities for scenarios such as stray light analysis, lighting system design, freeform surface optical device analysis, light guide analysis, and optomechanical co-simulation, while preserving the original geometric accuracy and topological semantics.
[0029] The technical solution adopted in this invention is as follows: An optical device simulation method based on boundary representation model and non-sequential ray tracing, used for optical path simulation and verification of optical devices or optomechanical systems, includes: Obtain CAD models of optical devices or optomechanical systems represented by the boundary representation model B-Rep; The surfaces of the B-Rep structure in the CAD model are uniformly preprocessed to form a trimmed surface representation; Establish differentiated ray intersection strategies based on the type of surface; Establish a nested spatial hierarchy acceleration structure for candidate face filtering at runtime, and establish a parameter domain determination structure for confirming the validity of the clipping region for faces with clipping boundaries. During runtime, the system receives the ray to be traced from an external optical simulation system, filters candidate surfaces based on the nested spatial hierarchy acceleration structure, performs surface intersection on the candidate surfaces, and verifies the effectiveness of the candidate intersection points within the parameter domain to obtain a valid hit result. The effective hit results are output to an external optical simulation system, which then performs optical simulation calculations for light reflection, refraction, scattering, absorption, or optical path termination.
[0030] In the above technical solution, the surfaces of the B-Rep structure are further preprocessed in a unified manner to form a clipped surface representation containing at least the following information: bottom surface, parameter domain range, parameter domain clipping curve, surface direction information, and topology identification information.
[0031] Furthermore, differentiated ray intersection strategies are established based on the type of surface. Specifically, analytical or semi-analytical intersection paths are used for analytical surfaces suitable for direct processing, while complex local intersection paths are used for free-form surfaces. A regular sampling grid is established for the parameter domain of the free-form surface. Based on the sampling results, a nested spatial hierarchy is formed to accelerate the organization of local candidate regions. Combined with clipping boundary information, local candidate regions that may be effectively clipped are pre-screened. Iterative refinement and intersection calculations are performed only for local candidate regions.
[0032] Furthermore, by combining the clipping boundary information with the pre-screening of local candidate regions that may be effectively clipped, specifically: based on the correlation between local regions and clipping boundaries, a conservative screening is performed to retain local regions that may participate in the effective clipping.
[0033] Furthermore, during the iterative refinement and intersection calculation process, a system of simultaneous equations is constructed between the spatial position of the surface and the propagation path of the light rays, and linearized iterative solutions are performed using the first derivative of the local surface. When the number of iteration steps exceeds the limit, the parameters go out of bounds, the hit distance is invalid, or it is not better than the previous effective distance, the iterative calculation of the current patch is immediately terminated.
[0034] Furthermore, the establishment of a nested spatial hierarchy acceleration structure for runtime candidate face filtering involves establishing a hierarchical spatial organization based on the spatial information of objects and adjusting the organization in conjunction with the overall relationship of nodes to reduce the runtime candidate filtering overhead. Specifically, this includes: establishing a binary or other basic hierarchical structure based on the bounding box coverage and object distribution, and further organizing it into a multi-branch structure more suitable for runtime batch testing; during the node partitioning process, a cost criterion that considers both the bounding box area of child nodes and the number of objects is adopted to reduce the overall overlap and number of visits during subsequent traversals.
[0035] Furthermore, a parameter domain determination structure is established for the surface with clipping boundaries to confirm the validity of the clipping region. Specifically, this includes: normalizing all parameter domain clipping curves, splitting spline-type clipping curves into multiple independently evaluated curve segments, and performing accurate generalized winding number calculation.
[0036] Furthermore, during the optical simulation operation phase, the system receives the ray to be traced from the external optical simulation system and rapidly filters candidate surfaces based on the nested spatial hierarchy acceleration structure. The selected candidate surfaces are matched with corresponding differentiated ray intersection strategies to complete surface intersection, obtaining candidate intersection points and their corresponding parameter domain coordinates. The parameter domain hierarchical judgment structure is used to verify the effectiveness of the candidate intersection points, eliminating invalid intersection points and obtaining valid hit results. This process employs a hierarchical filtering method that combines the overall model level with the local level of the single surface, and utilizes the effective distance upper bound formed by the current hit distance during runtime to prune more distant candidate regions in advance.
[0037] Furthermore, the effective hit result includes at least the hit point location, hit normal, and hit object identifier. When the input ray approaches the common edge, common vertex, or near-boundary region of adjacent surfaces, additional hit information that satisfies a preset proximity relationship with the most recent hit is also returned for the external optical simulation module to perform boundary propagation determination.
[0038] Compared with the prior art, the present invention has at least the following beneficial effects: 1. This invention directly simulates optical devices based on accurate CAD and B-Rep models, without the need for overall triangulation of the optical device surfaces. This better preserves the original geometric accuracy, curvature information and surface normal continuity of the optical device, and avoids the problem of light reflection and refraction direction shift caused by mesh approximation. It can significantly improve the geometric fidelity of optical path simulation of optical devices.
[0039] 2. This invention accelerates the process through a nested spatial hierarchy structure, forming a cross-layer candidate set contraction mechanism to address the engineering characteristics of massive repeated ray queries in optical simulation. This significantly reduces the overhead of repeated intersection calculations in non-sequential ray tracing and effectively improves the overall computational efficiency of large-scale optical system simulation.
[0040] 3. This invention introduces a potential hit region retention strategy in the preprocessing stage of freeform surface optical devices, which can eliminate a large number of parametric patches that are unlikely to form effective trimmed hits in advance, and concentrate the main overhead on the real and effective curved surface action area and complex local feature area of the optical device, thus optimizing the allocation of optical simulation computing power.
[0041] 4. This invention reduces unnecessary general solution costs by employing differentiated dedicated intersection paths for analytical surfaces and freeform surfaces in the optomechanical model, enabling intersection of different surface types in common industrial optomechanical models to be completed along shorter paths.
[0042] 5. This invention reduces the computational cost of complex boundaries while maintaining the accuracy of the clipping boundary determination through a hybrid clipping determination method on the parameter domain side.
[0043] 6. This invention improves the stability and scalability of optical simulations in common edge, near-common edge, and near-boundary hit scenarios by adopting a boundary conservative acceptance strategy and a joint output mechanism of nearest point and additional hit results.
[0044] 7. This invention provides a reusable, high-performance foundational capability for stray light analysis, lighting design, freeform surface device simulation, and optomechanical co-optimization. Attached Figure Description
[0045] Figure 1 This is a schematic diagram of the overall calling process of the method of the present invention in optical device simulation.
[0046] Figure 2 This is a schematic diagram of the spatial hierarchy structure constructed at the overall model level in the method of the present invention, which visualizes the bounding boxes in different levels and their correspondence with each clipping surface.
[0047] Figure 3 This is a schematic diagram of the local organization of the nested spatial hierarchical acceleration structure in the method of the present invention, showing the retained and removed regions within the parameter domain, where (a) is the AABB distribution in each layer of BVH, and (b) is the pre-pruning result after uniform division of the parameter domain. Detailed Implementation
[0048] The present invention will be further described below with reference to typical embodiments. The following embodiments are used to illustrate the technical concept of the present invention and the collaborative relationship between the various processing layers, and do not constitute a limitation on specific program interfaces, internal variable naming, threshold constants, traversal order or software implementation details.
[0049] The optical device simulation method provided by this invention is based on the intersection calculation of light rays and a high-precision B-Rep model, constructing a non-sequential ray tracing method that can be embedded in an external optical simulation system. In this method, the external optical simulation system is responsible for the physical propagation processes, including light source modeling, optical property configuration, reflection, refraction, scattering, light energy management, and path termination determination. Based on the core method of this invention, the ray to be traced is received at each ray propagation step, and the effective hit result of the ray relative to the accurate CAD model is returned. When dealing with complex situations such as adjacent, overlapping, or near-neighbor hits, this invention can also return additional hit information that is spatially close to the nearest intersection point to support subsequent optical propagation determination.
[0050] To address the typical non-sequential ray tracing pattern where a large number of rays repeatedly query the same precise B-Rep scene, this invention constructs a nested, multi-layered acceleration and decision-making system. Specifically, at the model level, a spatial hierarchy structure for runtime filtering is established for all surfaces in the B-Rep model to quickly narrow down the range of candidate intersection objects; at the surface level, differentiated intersection strategies are adopted based on surface type, and a local patch hierarchy structure is established for complex freeform surfaces, ensuring that the numerical refinement process occurs only within a small number of local candidate regions. Through the above multi-layered collaborative processing, this invention can improve the computational efficiency, geometric accuracy, and engineering robustness of non-sequential ray tracing in the simulation of complex optical devices while avoiding overall triangular mesh discretization.
[0051] like Figure 1 As shown, the method generally includes the following steps: 1. Obtain the CAD model of the optical device and its supporting mechanical structure to be simulated, and extract the face, solid and their mapping relationship in B-Rep.
[0052] 2. Normalize each face into a uniform clipped surface representation, and establish a surface-level intersection finder based on the surface type.
[0053] 3. For analytical surfaces, a dedicated intersection branch is used; for freeform surfaces, local patch partitioning, local candidate selection, and iterative refinement are employed.
[0054] 4. The validity of the parameter domain of the trimming boundary is determined using a method based on the generalized winding number.
[0055] 5. Construct a nested spatial hierarchy structure for the entire CAD model to accelerate the selection of candidate faces.
[0056] 6. During runtime, it receives the ray to be traced from the external optical simulation system, performs model-level traversal and surface-level intersection on the input ray, outputs the nearest intersection point, and returns additional hit results if necessary.
[0057] 7. Return the intersection coordinates, normal, target identifier, and other auxiliary information to the external optical simulation system to drive subsequent reflection, refraction, scattering, absorption, or termination judgments.
[0058] The method of this invention involves some key technical points, which are described in detail below: (1) Surface uniformity and surface family specialization For each face, this invention first extracts the underlying surface, parameter domain trimming curves, direction information, and parameter boundaries in a unified manner, forming a unified trimmed surface representation. Based on this, the surfaces are processed according to their type. For free-form surfaces such as BSplineSurface and BezierSurface, complex surface branches are used; for special free-form surfaces that can geometrically degenerate into planes, they are preferentially downgraded to lower-cost dedicated branches.
[0059] This preprocessing stage-based family classification avoids repetitive, high-cost type discrimination at runtime and provides a unified interface for subsequent local refinement and pruning decisions. In other words, this invention does not feed all faces into the same universal solver, but rather separates analytical surfaces and freeform surfaces onto their respective more suitable hot paths, reducing unnecessary computation from the source.
[0060] (2) Local patch selection and local refinement of freeform surfaces For freeform surfaces, this invention does not directly perform global root finding on the entire parameter domain, but instead preferably performs the following processing: first, a regular sampling mesh is established in the parameter domain, and then local candidate regions are organized in a nested spatial hierarchy acceleration structure based on the sampling results; combined with the clipping boundary information, which parameter units belong to the possible hit regions are identified in advance, and only these regions are retained for runtime intersection paths; when a ray enters a local patch, iterative refinement is performed based on the parameter region corresponding to that local patch.
[0061] The result is that expensive freeform surface refinement is limited to a small number of local candidate regions. In particular, by preprocessing to remove local parametric elements that, although belonging to the underlying surface, are unlikely to form an effective trimmed hit, this invention can significantly reduce the number of subsequent local traversals and iterative refinements.
[0062] (3) Quick determination of the validity of parameter domain clipping In B-Rep, even if a ray intersects the underlying surface, it does not necessarily mean that it has hit a valid face; it is also necessary to determine whether the parameter point (u, v) is within the clipping boundary. Therefore, this invention uses a two-dimensional generalized winding number (GWN) to determine the validity of parameter points within the parameter domain.
[0063] Preferably, for spline-type trimming curves, they can be first divided into multiple segments that are easy to evaluate; when the query point is outside the bounding box of a certain segment, the aggregated information is used to perform a fast generalized winding number calculation; otherwise, the closed solution method is used to perform an accurate evaluation.
[0064] For cases close to the clipping boundary, this invention improves the stability of hitting the vicinity of the common edge through hierarchical evaluation and a boundary conservative acceptance strategy.
[0065] (4) Collaborative candidate set shrinkage at the model and surface levels At the entire CAD model level, this invention constructs a model-level bounding volume hierarchy for all faces, and preferably employs a multi-branch organization method to reduce runtime traversal depth. This model-level structure forms a nested acceleration system with the local patch hierarchy of complex surfaces.
[0066] During runtime, a ray will only proceed to the next, more expensive computational layer after passing the following screening simultaneously: first, it is filtered through a model-level bounding box to enter a small number of candidate faces; if the hit is a freeform surface, it only enters a small number of local parametric patches; even if candidate (u, v) is obtained, it still needs to be confirmed by the parameter domain internal and external decision structure to determine whether it is a valid clipping hit. Thus, this invention can continuously compress the candidate set at different levels.
[0067] (5) The combined output of the nearest point and the additional hit result Traditional optical intersection methods typically only return the nearest intersection point. This invention further supports returning additional hit results when preset proximity conditions are met. This mechanism is particularly suitable for scenarios where light rays approximately hit the common edge of two adjacent faces. In this case, the external optical simulation module can identify near-boundary hit events based on this, and then perform multi-face consistency checks, boundary-specific propagation strategies, or higher-level edge effect processing according to its own strategy, thereby improving the stability of the simulation.
[0068] Furthermore, this additional hit mechanism does not simply take the first two results from all hits after the traversal is complete, but instead participates in distance threshold pruning simultaneously during the traversal. This allows candidate nodes that are significantly further away and would not actually be output to be eliminated in advance.
[0069] In the method of this invention, an external optical simulation system is responsible for the calculation of light source, material properties and subsequent physical propagation. The above method returns the effective hit position, normal, hit object identifier and additional hit results when necessary in each propagation step to drive subsequent reflection, refraction, scattering and termination judgment.
[0070] According to a specific embodiment of the present invention, an optical device simulation method based on non-sequential ray tracing using a boundary representation model specifically includes the following steps: 1. Model Input and Preprocessing
[0071] First, the system reads the CAD model of the optical device to be simulated. This model can be a single optical element or an assembly including lenses, prisms, light guides, reflectors, housings, supports, and shielding structures. After reading the model, the system extracts each face and its associated object relationships, and unifies and standardizes surface information from different sources into a preprocessed result that facilitates repeated queries during runtime.
[0072] 2 Overall Algorithm Framework
[0073] The intersection framework of this invention can be divided into two main parts: a preprocessing stage and a runtime query stage. The preprocessing stage is executed once for a fixed CAD scene, while the runtime stage is repeatedly called a large number of times during the optical simulation process.
[0074] Its overall process can be summarized as follows: 1) Analyze the shape, face, and solid of the assembly and their mapping relationships.
[0075] 2) Regularize each face into a uniform cut surface representation.
[0076] 3) Build a face-level intersection finder for each face and complete the surface classification.
[0077] 4) Establish nested spatial hierarchical structures to accelerate local organization within complex surfaces, and establish parameter domain decision structures for trimming boundaries.
[0078] 5) Organize all face-level intersection finders into model-level intersection finders and establish a nested spatial hierarchy acceleration structure.
[0079] 6) During runtime, an external optical simulation system inputs a ray to accelerate the screening of candidate facets in a nested spatial hierarchy.
[0080] 7) Perform analytical intersection or local intersection of complex surfaces for each candidate surface patch according to the surface type.
[0081] 8) Perform parameter field validity checks on candidate intersection points.
[0082] 9) Maintain the most recent hits and additional hits as needed, and send the final results back to the external optical simulation system.
[0083] 3. Uniform trimmed face representation
[0084] Before entering the waterline calculation, each patch is first normalized into a uniform trimmed surface representation. This representation contains at least the following information: the underlying geometric surface, the parameter domain boundary, the set of parameter domain trimmed curves, surface orientation information, and auxiliary boundary information for rapid judgment.
[0085] The significance of this regularization is that, regardless of whether the target surface is a plane, sphere, cylinder, cone, triangle, or spline freeform surface, the intersection finder only needs to work on the same type of clipping surface, thereby reducing the differences in branch interfaces and unifying the subsequent legality judgment process.
[0086] 4. Surface Family Regularization and Branch Selection
[0087] After establishing a unified representation, this invention performs surface type decomposition during the preprocessing stage, rather than performing costly judgments during each ray query. Preferably, surfaces can be divided into two main categories: 1. Analytical surface family: plane, triangular surface, cylindrical surface, conical surface, spherical surface, etc.
[0088] 2. Freeform surface family: BSplineSurface, BezierSurface, and other complex parametric surfaces that require numerical solutions.
[0089] 5. Normalization of Parameter Domain Clipping Curves
[0090] For surfaces with clipping boundaries, a parameter domain determination structure is established for confirming the validity of the clipping region. Specifically, the parameter domain clipping curves are organized in a way suitable for determination, facilitating subsequent confirmation of hit validity using appropriate hierarchical determination methods based on query relationships. For clipped surfaces, whether a valid region is hit ultimately depends on whether the parameter point (u, v) lies within the valid region enclosed by the clipping boundary. Therefore, this invention first performs a normalization process on each parameter domain clipping curve.
[0091] In a typical implementation, parameter domain curves of different sources and types are uniformly converted into a standard representation that facilitates subsequent generalized winding number evaluation; spline curves suitable for segmented processing can be further divided into sub-segments that facilitate local evaluation, while line segments or other simple curves retain their stable geometric description.
[0092] After the above transformation, although the various cutting curves have different origins, they can all participate in the two-dimensional generalized winding number determination in a unified manner during runtime.
[0093] 6 Robust determination of parameter domain clipping validity
[0094] 6.1 Subsegmentation of Spline-Type Cut Curves For spline-type clipping curves that frequently appear in industrial models, this invention does not directly perform a segment-by-segment linear scan of the entire curve. Instead, it preferentially breaks it down into multiple sub-segments that are more suitable for evaluation. This is done to ensure accuracy while accelerating the process for distant query points.
[0095] 6.2 Principles for Querying the Generalized Wrapping Number in Two Dimensions For the split sub-segments and other parametric curves, this invention constructs a bounding body for each curve segment within the parameter domain.
[0096] Based on the relationship between the query point and the local boundary region, a generalized winding number calculation scheme with appropriate granularity is adopted. Given the parameter point q=(u,v), the query process follows these principles: if q is far from the enclosed region of a certain curve segment, the generalized winding number is calculated quickly and accurately using the endpoint information of that curve segment; if q enters the local region, a closed-loop solution method is used. Through this far-field simplification and near-field refinement approach, the overhead of determining complex clipping boundaries can be transformed from a piecewise closed-loop solution to an efficient hybrid evaluation process.
[0097] 6.3 Precise evaluation of the generalized winding number For sufficiently close query points, this invention does not uniformly revert to discrete sampling, but instead adopts a more suitable closed-loop solution evaluation path based on the representation of the curve segment. This maintains the stability of the determination within and outside the parameter domain, and also helps avoid unnecessary recalculation in complex clipping boundary scenarios.
[0098] 6.4 Overall Judgment of the Legality of Cutting When a candidate intersection point parameter (u, v) is obtained at runtime, the final validity determination is performed as follows: if the clipping boundary of the patch itself can degenerate into a simple parameter domain boundary, then fast boundary judgment is preferred; otherwise, the generalized winding number is accumulated for all parameter domain clipping curves; when the result shows that the parameter point is located inside the valid region, it is determined as a valid hit; when the parameter point is close to the boundary or on the boundary, the boundary conservative acceptance strategy is adopted to improve the stability of hits near the common edge.
[0099] 7. Local patch preprocessing of freeform surfaces
[0100] For freeform surfaces, this invention uses a parametric domain sampling mesh, nested spatial hierarchy to accelerate local organization in the structure, and pre-screening of possible hit regions to establish a surface-level intersection finder.
[0101] 7.1 Parametric Grid Sampling First, a regular sampling mesh is established within the parameter domain of the surface, and the corresponding 3D positions of the sampling points are evaluated in batches. If the underlying surface has undergone preprocessing suitable for batch evaluation, it is preferable to use batch evaluation to obtain the results of the entire mesh at once; otherwise, point-by-point evaluation can also be used. Due to the tensor product form of BSpline and Bezier surfaces, during batch evaluation, all sampling points on the same isoparameter line have identical basis function values under the given parameter value, so only one calculation is needed. Subsequent local patch bounding boxes are formed by combining adjacent sampling points.
[0102] 7.2 Determining the Possible Hit Area To determine which parameter units are likely to form a valid trimmed hit, this invention employs a conservative screening based on the correlation between local regions and trimmed boundaries, retaining local regions that are likely to participate in a valid trimmed hit. Specifically: first, a parameter domain-in / outside determination is performed on the sampling points. Sampling points determined to be located inside the valid region or falling on the trimmed boundary are considered for retention; sampling points clearly located outside are not directly retained. Through this process, it is possible to initially identify which local parameter regions are more likely to participate in a valid hit.
[0103] 7.3 Compensation for Cutting Curve Crossing Relying solely on the internal or external state of the sampling points is insufficient, as there may be cases where the corners of a parameter unit are all external, but the clipping curve passes through the inside of that unit. Therefore, this invention further detects the intersection relationship between the internal parameter lines and the clipping curve. As long as a parameter unit is crossed by the clipping curve, even if none of its corners fall within the valid area, the unit is still retained. This step ensures that narrow clipping regions are not mistakenly deleted during the preprocessing stage.
[0104] 7.4 Establishment of Local Hierarchical Structure When establishing a local hierarchy on a parametric mesh (e.g.) Figure 3 This invention does not unconditionally retain all leaf faces, but only generates leaf bounding boxes for parameter elements that may form a valid trimmed hit. If all child elements under an internal node are removed, the internal node is also deleted; if an internal node has only a small amount of valid area remaining, structural compression can be performed while maintaining geometric coverage. Thus, this invention removes a large number of meaningless local regions from the runtime path during the preprocessing stage.
[0105] 8. Multi-branched bounding body structure of freeform surfaces
[0106] After the local active patches are established, this invention further organizes them into a multi-branch hierarchical bounding body structure suitable for runtime traversal. Each leaf corresponds to a parameter patch, and internal nodes correspond to a combined bounding region of several local patches.
[0107] 9. Nested spatial hierarchy accelerates structure establishment
[0108] For the entire assembly, this invention establishes a nested spatial hierarchy to accelerate the process, using faces as the unit. A hierarchical spatial organization is established based on the spatial information of the objects, and adjustments are made in conjunction with the overall relationships between nodes to reduce runtime candidate filtering overhead. Preferably, a binary or other basic hierarchical structure can be established first based on the bounding box coverage and object distribution, and then further organized into a multi-branch structure more suitable for runtime batch testing. Figure 2 As shown.
[0109] During node partitioning, a cost criterion that considers both the bounding box area of child nodes and the number of objects can be adopted to reduce overall overlap and access counts during subsequent traversals. The model-level structure and the patch-level structure of complex surfaces are independent of each other, but the runtime traversal logic can remain consistent.
[0110] 10. Runtime General Intersection Flow
[0111] Given an input ray, the present invention can be executed according to the following process: 1) Construct a runtime ray representation.
[0112] 2) Filter candidate faces in a nested spatial hierarchy to accelerate the structure.
[0113] 3) For each candidate face, call the intersection branch of its corresponding face level.
[0114] 4) Perform analytical intersection on analytical surfaces and local patch filtering and local iterative refinement on freeform surfaces.
[0115] 5) Perform a uniform TRIM validity check on each candidate intersection point.
[0116] 6) Maintain the most recent hit results and maintain additional hit results as needed.
[0117] 7) Return the final hit information.
[0118] In near-grazing shooting scenarios, the present invention can also be combined with a conservative parallel axis processing strategy during the bounding box testing phase to reduce the risk of missed detections.
[0119] 11 Batch Testing of Multi-Child Bounding Boxes
[0120] In the nested spatial hierarchy acceleration structure, runtime traversal preferentially uses the same type of multi-child node bounding box test function. The core idea is: read the bounding box ranges of multiple child nodes at the same level from the compact node at once, and perform batch intersection tests with the current ray; only retain child nodes that meet the distance interval conditions; and at the same time, use the current nearest hit distance or the effective upper bound formed by the nearest hit distance plus an additional hit threshold to prune nodes that are significantly farther away in advance.
[0121] Therefore, as more hits are discovered in front, the bounding boxes in the distance will be directly cut off at a higher level, thereby reducing unnecessary deep traversal.
[0122] 12. Finding intersection branches of analytic surfaces
[0123] For planes, triangular surfaces, cylindrical surfaces, conical surfaces, and spherical surfaces, this invention employs a dedicated closed-loop solution path. Although the specific intersection formulas differ for each surface, the runtime framework remains consistent: first, candidate intersections between the ray and the underlying surface are solved in the geometric coordinate system of the surface, and then the corresponding parameter domain coordinates are obtained; if the hit distance is not within the allowed range, it is discarded; if the parameter point fails the unified trim validity check, it is discarded again; otherwise, the intersection point coordinates and normal are calculated and written into the hit result.
[0124] Therefore, although analytical surface branches and free surface branches use different methods to find the intersection of the underlying surfaces, they ultimately share the same set of trim validity judgment logic.
[0125] 13. Finding intersection branches of freeform surfaces
[0126] 13.1 Patch Positioning The entry point for a freeform surface branch is its local hierarchical bounding volume structure. When a leaf patch is accessed, the center or representative parameters of that local region can be recovered from the parametric mesh position corresponding to that leaf, and used as the initial reference value for subsequent local iterative refinement. Geometrically, this means: first, the parametric region where the intersection point is located is shrunk to a small area through the local hierarchical structure, and then converges to the precise intersection point near this small area.
[0127] 13.2 Local Iterative Refinement For the freeform surface S(u,v) and the ray R(t) = O + tD, the present invention preferably solves the following system of equations: F(u,v,t)=S(u,v)-(O+tD)=0 Where u and v represent the coordinates of the candidate intersection point in the parameter domain of the freeform surface; t represents the ray propagation distance parameter; S(u,v) represents the three-dimensional position of the freeform surface at parameter (u,v); O represents the starting point of the input ray; D represents the direction vector of the input ray; and F(u,v,t) represents the three-dimensional residual vector to be solved. When F=0, it means that the surface point coincides with the ray point, i.e., a candidate intersection point is obtained.
[0128] Correspondingly, the present invention preferably employs the Newton iterative method to solve the simultaneous equations of the surface and the ray. Specifically, representative parameters corresponding to local patches are used as initial parameter estimates. Subsequently, in each iteration, the parameter values are updated based on the first derivative of the surface at the current parameter and the ray direction, so that the residual F(u,v,t) is gradually reduced to reach the specified accuracy.
[0129] Correspondingly, a locally linearized system can be constructed with respect to the first derivative of the surface and the ray direction, and updated (u,v,t) in each iteration. During the initial iteration, the initial distance parameters can be estimated based on the projection relationship between the representative point of the local patch and the ray, thereby improving convergence efficiency. If convergence is successful within the allowable range of local parameters, high-precision candidate intersection points on the patch are obtained.
[0130] 13.3 Termination and Failure Handling If the local iteration exceeds the allowed number of steps, the updated parameters clearly exceed the effective parameter domain of the surface, the obtained hit distance does not meet the requirements of the effective ray interval, or the current result is not better than the existing effective distance upper bound, then the solution on that local patch is considered a failure. This avoids continuing to consume computational resources in obviously invalid local regions.
[0131] 13.4 Normal Calculation If the local iteration is successful, the normal at that point is calculated using the first derivative of the surface, and the final normal orientation is determined by combining it with the surface orientation information. Finally, this normal, along with the intersection point position, hit distance, and object identifier, is backfilled into the hit record.
[0132] 14. Joint maintenance of nearest point and additional hit results
[0133] This invention does not sort all candidates after the intersection is completed, but maintains the hit results in real time during the traversal. In the nearest point and additional hit modes, the system always retains the current best hit and retains additional hit results when a new candidate and the current nearest hit satisfy a preset proximity relationship. At the same time, the upper bound of the effective distance derived from the current result is fed back to the subsequent hierarchical traversal to eliminate candidate regions that are significantly farther away in advance.
[0134] Therefore, the role of the additional hit mechanism is not only to return extra results, but more importantly, it directly participates in runtime pruning and boundary stability control.
[0135] 15. Results returned in conjunction with optical simulation
[0136] The intersection result includes at least the intersection coordinates, intersection normal, hit distance, hit face identifier, hit solid identifier, and additional hit information if necessary. Upon receiving the above results, the external optical simulation system can continue to perform Fresnel reflection, refraction, specular or diffuse reflection, scattering model invocation, absorption or termination judgment, and new ray generation and continued propagation. Therefore, the output of this invention is not an isolated geometric result, but a structured hit event that can be directly invoked by the upper-level optical propagation module.
[0137] Example 1: Simulation of an optomechanical assembly for stray light analysis
[0138] In a typical embodiment, the object to be simulated is an optomechanical assembly, which includes components such as multiple lenses, lens barrels, pressure rings, spacers, housings, and light-blocking structures. The simulation objective is to analyze the non-sequential propagation path of ambient light entering the optical system from outside the field of view, and to identify the main structural locations and propagation sources that may generate stray light pollution.
[0139] In this embodiment, the external optical simulation system needs to repeatedly perform geometric intersection and hit determination on a large number of light rays on a precise B-Rep assembly. This invention rapidly filters candidate faces by establishing a nested spatial hierarchy acceleration structure; efficiently performs intersection calculations on different geometric objects such as lenses, lens barrels, and light-blocking structures through a face-level differentiated intersection strategy; confirms whether candidate intersection points are located within the effective region of the corresponding face through parameter domain clipping validity determination; and outputs necessary additional hit information near the clipping boundary or multi-face intersection. Therefore, while maintaining the original geometric accuracy of CAD and the assembly topological semantics, it reduces the overhead of repetitive intersection calculations in stray light path analysis and improves the stability of propagation results in complex boundary scenarios.
[0140] Example 2: High-precision simulation of freeform surface lighting components and light guides
[0141] In another typical embodiment, the object to be simulated is an illumination system (light guide system), which includes a freeform lens, a light guide plate, a reflector, and several mounting structures. The simulation objective is to analyze the multiple refractions, reflections, total internal reflections, and final emission distribution of light in the freeform device to evaluate illumination uniformity, light energy utilization, and the effectiveness of light emission direction control.
[0142] In this embodiment, freeform surface devices typically contain a large number of B-Spline or NURBS surfaces, accompanied by complex trimming boundaries and multi-face splicing regions. To address this characteristic, this invention establishes a local hierarchical structure of the freeform surface at the surface level, performing numerical iteration refinement only on a small number of candidate local regions, thereby reducing the computational load of complex surface intersections. Furthermore, it maintains additional hit information at partition boundaries, multi-face intersections, or nearest-neighbor hit regions, providing stable input for subsequent reflection, refraction, total internal reflection, and path branching determination. Therefore, this invention enables high-precision non-sequential ray tracing simulation for illumination and light guide components without discretizing the entire freeform surface device into a conventional triangular mesh.
[0143] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0144] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1 One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0145] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0146] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0147] The embodiments described above are merely some preferred embodiments of the present invention, and are not intended to limit the invention. Those skilled in the art can make various changes and modifications without departing from the spirit and scope of the invention. Therefore, all technical solutions obtained by equivalent substitution or equivalent transformation fall within the protection scope of the present invention.
Claims
1. A simulation method for optical devices based on non-sequential ray tracing using a boundary representation model, characterized in that, Optical path simulation and verification for optical devices or optomechanical systems, including: Obtain CAD models of optical devices or optomechanical systems represented by the boundary representation model B-Rep; The surfaces of the B-Rep structure in the CAD model are uniformly preprocessed to form a trimmed surface representation; Establish differentiated ray intersection strategies based on the type of surface; Establish a nested spatial hierarchy acceleration structure for candidate face filtering at runtime, and establish a parameter domain determination structure for confirming the validity of the clipping region for faces with clipping boundaries. During runtime, the system receives the ray to be traced from an external optical simulation system, filters candidate surfaces based on the nested spatial hierarchy acceleration structure, performs surface intersection on the candidate surfaces, and verifies the effectiveness of the candidate intersection points within the parameter domain to obtain a valid hit result. The effective hit results are output to an external optical simulation system, which then performs optical simulation calculations for light reflection, refraction, scattering, absorption, or optical path termination.
2. The optical device simulation method according to claim 1, characterized in that, The surfaces of the B-Rep structure are uniformly preprocessed to form a clipped surface representation containing at least the following information: the underlying surface, the parameter domain range, the parameter domain clipping curve, the surface orientation information, and the topology identification information.
3. The optical device simulation method according to claim 1, characterized in that, Differentiated ray intersection strategies are established based on the type of surface. Specifically, analytical or semi-analytical intersection paths are used for analytical surfaces suitable for direct processing, while complex local intersection paths are used for free-form surfaces. Local candidate regions are organized for the parameter domain of the free-form surface, and local candidate regions that may be effectively clipped are pre-screened in combination with clipping boundary information. Iterative refinement and intersection calculations are performed only for local candidate regions.
4. The optical device simulation method according to claim 3, characterized in that, Pre-screening of local candidate regions that may be eligible for effective cropping based on cropping boundary information includes: conservative screening based on the relationship between local regions and cropping boundaries, retaining local regions that may be eligible for effective cropping.
5. The optical device simulation method according to claim 3, characterized in that, During the iterative refinement and intersection calculation process, a system of simultaneous equations is constructed between the spatial position of the surface and the propagation path of the light rays. The system is then solved iteratively using the first derivative of the local surface. When the number of iterations exceeds the limit, the parameters go out of bounds, the hit distance is invalid, or it is not better than the previous effective distance, the iterative calculation of the current patch is immediately terminated.
6. The optical device simulation method according to claim 1, characterized in that, The establishment of a nested spatial hierarchy acceleration structure for runtime candidate face filtering specifically includes: establishing a hierarchical spatial organization based on the spatial information of the object, and adjusting the organization in conjunction with the overall relationship of the nodes, so as to reduce the runtime candidate filtering overhead.
7. The optical device simulation method according to claim 1, characterized in that, For surfaces with clipping boundaries, a parameter domain determination structure is established for confirming the validity of the clipping region. Specifically, this includes: performing appropriate organizational processing on the parameter domain clipping curves for determination, and using corresponding hierarchical determination methods based on the query relationship to confirm the hit validity.
8. The optical device simulation method according to claim 7, characterized in that, Based on the relationship between the query point and the local boundary region, a generalized winding number calculation scheme with corresponding granularity is adopted.
9. The optical device simulation method according to claim 1, characterized in that, During the optical simulation operation phase, the system receives the ray to be traced from the external optical simulation system and quickly filters candidate surfaces based on the nested spatial hierarchy acceleration structure. The selected candidate surfaces are matched with corresponding differentiated ray intersection strategies to complete surface intersection, obtaining candidate intersection points and corresponding parameter domain coordinates. The parameter domain hierarchical judgment structure is used to confirm the effectiveness of the candidate intersection points, eliminating invalid intersection points and obtaining valid hit results. The system adopts a hierarchical filtering method that combines the overall model level with the local level of the single surface, and during runtime, the effective distance upper bound formed by the current hit distance is used to prune more distant candidate regions in advance.
10. The optical device simulation method according to claim 1, characterized in that, The effective hit result includes at least the hit point location, hit normal, and hit object identifier. When the input light ray approaches the common edge, common vertex, or near-boundary region of adjacent surfaces, additional hit information that satisfies a preset proximity relationship with the most recent hit is also returned for the external optical simulation module to perform boundary propagation determination.
