Model lofting method, device and equipment and storage medium
The path type mark and the unified storage of the merged point coordinate set are used to generate a contour point set, and the contour points are projected and transformed to generate triangular facets, and three-dimensional model data is generated.
Patent Information
- Application Number
- CN202510763240.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-06-09
- Publication Date
- 2025-09-19
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing model lofting methods cannot effectively distinguish and process contour path data and hole path data, resulting in the contour path and hole path being mixed during the lofting process, unable to maintain their respective geometric characteristics, affecting the geometric accuracy of the 3D model.
The contour path data and hole path data of the target drawing are preprocessed and the path types are marked, and uniformly stored as a merged point coordinate set. The intersection point with the angle bisector plane is calculated by taking the merged point as the starting point of the ray to generate a contour point set, and the contour points are projected and transformed to generate triangular patches. Triangular patches are generated based on the transformed UV coordinate data to generate three-dimensional model data.
The merged point coordinate set obtained by path type marking and unified storage is used to generate a contour point set, and three-dimensional model data is generated for the generated triangular facets, and three-dimensional model data is generated according to the data generation method of the generated triangular facets.
Smart Images

Figure CN120672949A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of three-dimensional models, and in particular to a model lofting method, device, equipment and storage medium. Background Art
[0002] With the rapid development of computer 3D modeling technology, model lofting, as an important 3D modeling technique, has been widely used in industrial design, game development, architectural visualization, and other fields. Traditional model lofting methods typically use simple linear interpolation or spline curve interpolation to generate 3D models. These methods often have obvious limitations when dealing with complex contours.
[0003] Existing model lofting technologies often fail to effectively distinguish and process contour and hole path data when processing complex contours containing holes. This results in the mixing of contour and hole paths during the lofting process, failing to preserve their respective geometric properties. Furthermore, traditional methods lack a unified mechanism for marking path types, making it impossible to differentiate path types during subsequent triangle patch generation and UV coordinate mapping, affecting the geometric accuracy of the final 3D model. Summary of the Invention
[0004] The main purpose of the present invention is to solve the technical problem that the existing model lofting method cannot effectively distinguish and process contour path data and hole path data; A first aspect of the present invention provides a model lofting method, the model lofting method comprising: Preprocess the contour path data and hole path data of the target drawing, mark the path type, and store them uniformly to obtain a merged point coordinate set; Traversing the preset lofting path according to the merging point coordinate set, taking the merging point in the merging point coordinate set as the ray starting point and calculating the intersection point with the angle bisector plane of the lofting path to obtain a contour point set; Performing a projection transformation of the three-dimensional coordinates of the contour points in the contour point set into a two-dimensional UV coordinate system, and generating a triangular facet according to the transformed UV coordinate data; The geometric data of the triangular facets and the corresponding UV coordinate data are output and processed to obtain the three-dimensional model data corresponding to the target drawing.
[0005] Optionally, in a first implementation of the first aspect of the present invention, traversing a preset lofting path according to the merging point coordinate set, calculating an intersection point with an angle bisector plane of the lofting path using a merging point in the merging point coordinate set as a ray starting point, and obtaining a contour point set includes: Performing segment decomposition processing on the preset lofting path to obtain a lofting path segment set, and traversing the lofting path segments in the lofting path segment set to construct an angle bisector plane corresponding to each lofting path segment; For each merged point in the merged point coordinate set, a ray direction is calculated according to the currently traversed lofting path segment, and the coordinates of the intersection point of the ray direction and the angle bisector plane are calculated; Accumulating and storing the intersection coordinates of the intersection points into a new contour point coordinate set, and determining whether the processing of all the lofted path segments is completed through a traversal control mechanism; If so, deduplication and sorting are performed on the new contour point coordinate set to obtain a contour point set.
[0006] Optionally, in a second implementation of the first aspect of the present invention, performing segment decomposition processing on the preset lofting path to obtain a lofting path segment set, and traversing the lofting path segments in the lofting path segment set to construct an angle bisector plane corresponding to each lofting path segment includes: Performing node extraction processing on the preset lofting path, decomposing the lofting path into a sequence of line segments with a start point and an end point according to the extracted nodes, and obtaining a lofting path line segment set; Traversing the set of lofting path line segments, and calculating the corresponding line segment direction vector and the perpendicular direction vector according to the endpoint coordinates of the currently traversed lofting path line segment; A cross product operation is performed on the line segment direction vector and the vertical direction vector to obtain a normal vector of the angle bisector plane, and the angle bisector plane is constructed according to the normal vector to obtain the corresponding angle bisector plane.
[0007] Optionally, in a third implementation of the first aspect of the present invention, calculating a ray direction for each merged point in the merged point coordinate set according to a currently traversed lofting path segment, and calculating an intersection of the ray direction and the angle bisector plane includes: Traversing the merging point coordinate set, and calculating the ray direction corresponding to each merging point according to the currently traversed lofting path segment; Constructing a ray parameter equation according to the merged point coordinate set and the ray direction; The ray parameter equation and the angle bisector plane are solved simultaneously, and the intersection point of the ray direction and the angle bisector plane is determined by solving the ray parameter to obtain the coordinates of the intersection point.
[0008] Optionally, in a fourth implementation of the first aspect of the present invention, performing a projection transformation on the contour points in the contour point set from three-dimensional coordinates to a two-dimensional UV coordinate system, and generating a triangular facet according to the transformed UV coordinate data includes: Traverse the four vertex coordinates corresponding to each two adjacent sections in the contour point set, and split the quadrilateral into two triangles to obtain triangle vertex data; Calculate the u coordinate and the v coordinate according to the three-dimensional coordinates of the triangle vertex data in the three-dimensional space and the direction vectors of the u axis and the v axis of the two-dimensional UV coordinate system, respectively, to obtain preliminary UV coordinate data; Scaling the preliminary UV coordinate data using a scaling factor to obtain UV coordinate data of a triangular face, and updating the scaling factor to the distance between two adjacent vertices currently traversed; The normal vector and the area of the triangle are calculated according to the three-dimensional coordinates to obtain geometric data of the triangle patch, and the triangle patch is obtained according to the geometric data and the UV coordinate data.
[0009] Optionally, in a fifth implementation of the first aspect of the present invention, the path type includes a contour path type and a hole path type; The traversal of the four vertex coordinates corresponding to each two adjacent sections in the contour point set and the division of the quadrilateral into two triangles to obtain the triangle vertex data includes: Traverse the vertex coordinates of the four vertices corresponding to each two adjacent sections in the contour point set; Splitting two adjacent cross sections into two triangles according to the vertex coordinates of the four vertices and a preset segmentation rule to obtain triangle data to be verified; Calculating the center of gravity of the triangle based on the coordinates of the three vertices of the triangle data to be verified to obtain center of gravity coordinate data; Determine whether the barycentric coordinate data is inside the closed polygon formed by the vertices of the hole path type. If so, mark the triangle data to be verified as an invalid triangle; if not, mark the triangle data to be verified as a valid triangle. Generate triangle vertex data based on the triangle data to be verified that is marked as a valid triangle.
[0010] Optionally, in a sixth implementation of the first aspect of the present invention, the outputting the geometric data and the corresponding UV coordinate data of the triangular facet to obtain the three-dimensional model data corresponding to the target drawing includes: Adding the UV coordinate data of the triangular face to a preset UV data set according to a preset order and regular format; Performing data optimization processing on the UV data set after the data is stored to obtain an optimized UV data set, wherein the data optimization processing includes one or both of sorting the UV data set according to the UV coordinate data and constructing an index corresponding to the UV coordinate data; The optimized UV data set and geometric data of the triangular facet are used as output results and saved as a three-dimensional model file to obtain three-dimensional model data.
[0011] A second aspect of the present invention provides a model lofting device, comprising: The data preprocessing module is used to preprocess the contour path data and hole path data of the target drawing and mark the path type, and uniformly store the merged point coordinate set; A contour generation module is used to traverse the preset lofting path according to the merging point coordinate set, calculate the intersection point with the angular bisector plane of the lofting path with the merging point in the merging point coordinate set as the ray starting point, and obtain the contour point set; a triangulation processing module, configured to perform a projection transformation of the three-dimensional coordinates of the contour points in the contour point set into a two-dimensional UV coordinate system, and generate triangular facets according to the transformed UV coordinate data; The data output module is used to output the geometric data of the triangular facets and the corresponding UV coordinate data to obtain the three-dimensional model data corresponding to the target drawing.
[0012] A third aspect of the present invention provides a model lofting device, comprising: a memory and at least one processor, wherein the memory stores instructions, and the memory and the at least one processor are interconnected via a circuit; the at least one processor calls the instructions in the memory so that the model lofting device executes the steps of the above-mentioned model lofting method.
[0013] A fourth aspect of the present invention provides a computer-readable storage medium, wherein the computer-readable storage medium stores instructions, which, when executed on a computer, enable the computer to execute the steps of the above-mentioned model lofting method.
[0014] The above-mentioned model lofting method, device, equipment, and storage medium preprocess the contour path data and hole path data of the target drawing and mark the path type, uniformly storing a merged point coordinate set; traversing the preset lofting path based on the merged point coordinate set, calculating the intersection point with the angle bisector plane of the lofting path with the merged point as the ray starting point to obtain a contour point set; projecting the contour points in the contour point set from the three-dimensional coordinates to the two-dimensional UV coordinate system, and generating triangular facets based on the transformed UV coordinate data; and outputting the geometric data of the triangular facets and the corresponding UV coordinate data to obtain three-dimensional model data. Through path type marking and a unified processing mechanism, the present invention effectively solves the problem of lofting complex contours containing hole structures, ensuring that the geometric characteristics of the contour path and hole path are correctly processed.
[0015] Other features and advantages of the present invention will be described in the following description, and in part will become apparent from the description, or understood by practicing the present invention. The purposes and other advantages of the present invention are realized and obtained by the structures particularly pointed out in the description, claims and drawings.
[0016] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, preferred embodiments are given below and described in detail with reference to the accompanying drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 Schematic diagram of a first embodiment of a model lofting method according to an embodiment of the present invention; Figure 2 A schematic diagram of an embodiment of a model lofting device in an embodiment of the present invention; Figure 3 A schematic diagram of an embodiment of a model lofting device in an embodiment of the present invention; Figure 4 Schematic diagram of an embodiment of calculating the intersection point of a ray and an angle bisector plane in an embodiment of the present invention. DETAILED DESCRIPTION
[0018] To make the objectives, technical solutions, and advantages of the embodiments of the present invention more clear, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the embodiments described are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0019] The terms "including," "having," and any variations thereof, as used in the embodiments of the present invention are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or device comprising a series of steps or units is not limited to the listed steps or units, but may optionally include other steps or units not listed, or may optionally include other steps or units inherent to the process, method, product, or device.
[0020] To facilitate understanding of this embodiment, a model lofting method disclosed in an embodiment of the present invention is first introduced in detail. Figure 1 As shown, this method includes the following steps: 101. Preprocess the contour path data and hole path data of the target drawing, mark the path types, and uniformly store them to obtain a merged point coordinate set; In one embodiment of the present invention, the contour path data and hole path data from the target drawing are first read. This data is typically stored in a CAD file or graphics file as a sequence of two-dimensional coordinate points. The contour path data defines the outer boundary of the model, while the hole path data represents the boundaries of the areas within the model that need to be hollowed out. During the reading process, the geometric information of each path is simultaneously extracted, including the coordinate values of each control point on the path and the path's connectivity. Next, data preprocessing is performed, traversing all coordinate points in the contour and hole paths, identifying and removing duplicate coordinate points to avoid redundant data in subsequent calculations. The paths are also checked for overlapping or self-intersecting line segments. Geometric algorithms are used to determine the intersections between line segments, and any problematic line segments detected are marked or deleted. During preprocessing, the paths are also smoothed to eliminate minor noise points generated during data sampling or conversion, ensuring the geometric continuity of the paths. Path type marking is a key step in preprocessing, assigning a path type identifier to each coordinate point. Specifically, coordinate points belonging to contour paths are marked as type "contour" and constitute the model's outer boundary; coordinate points belonging to hole paths are marked as type "hole" and define the hollowed-out areas within the model. During the marking process, a mapping between point and path types is established, and the closedness of the paths is verified to ensure that both contour and hole paths form closed geometric shapes. Finally, unified storage is performed, creating a unified data structure, pointsList, to hold all preprocessed coordinate points—this is known as the merged point coordinate set. This data structure is a two-dimensional array, with each array element containing the 3D coordinate value of the coordinate point and the corresponding path type identifier. Contour and hole path points are added to pointsList in a specific order, maintaining the topological connectivity between the points. During storage, the coordinate data is normalized to unify coordinate and numerical precision, ensuring the accuracy of subsequent calculations. Through this series of preprocessing operations, the previously separate contour and hole path data are integrated into a merged point coordinate set containing complete geometric information and type identifiers. This set serves as the basic data source for subsequent lofting calculations.
[0021] 102. Traverse the preset lofting path according to the merging point coordinate set, calculate the intersection point of the ray with the angle bisector plane of the lofting path using the merging point in the merging point coordinate set as the starting point, and obtain a contour point set; In one embodiment of the present invention, traversing the preset lofting path according to the merged point coordinate set, and calculating the intersection of the ray starting point with the angle bisector plane of the lofting path using the merged point in the merged point coordinate set as the ray starting point to obtain the contour point set includes: performing line segment decomposition processing on the preset lofting path to obtain a lofting path segment set, traversing the lofting path segments in the lofting path segment set, and constructing the angle bisector plane corresponding to each lofting path segment; calculating the ray direction for each lofting point in the merged point coordinate set according to the currently traversed lofting path segment, and calculating the intersection coordinates of the ray direction and the angle bisector plane; accumulating and storing the intersection coordinates of the intersection into a new contour point coordinate set, and determining whether the processing of all lofting path segments is completed through a traversal control mechanism; if so, deduplicating and sorting the new contour point coordinate set to obtain the contour point set.
[0022] Specifically, the preset lofting path is first decomposed into line segments, and a complete geometric representation is constructed by reading the control point sequence of the lofting path. The lofting path is usually defined in the form of a spline curve or broken line in three-dimensional space. The key control points on the path are identified through a node extraction algorithm. These control points include the starting point, end point, and turning point where the direction changes significantly. During the node extraction process, the rate of change of the direction vector between adjacent control points is calculated. When the rate of change exceeds a preset threshold, the point is marked as a key node. Based on the extracted node sequence, the continuous lofting path is decomposed into a series of line segments with clear starting and end points. Each line segment is defined by two adjacent nodes, thereby obtaining a set of lofting path line segments. Subsequently, the line segment set is traversed, and the geometric properties of each lofting path line segment are calculated. For the currently traversed line segment, the direction vector of the line segment is first calculated based on the coordinate difference of the starting and end points of the line segment, and then the direction vector is normalized to obtain a unit direction vector.
[0023] Specifically, after obtaining the line segment direction vector, it is necessary to calculate the perpendicular direction vector to construct the angle bisector plane. The perpendicular direction vector is calculated using the cross product method. First, a reference vector is selected, usually set to the Z-axis direction. When the line segment direction vector is not parallel to the reference vector, the perpendicular direction vector is obtained by the cross product of the two vectors, and the result is normalized. When the line segment direction vector is parallel to the reference vector, the spare reference vector X-axis direction is used for calculation. In special cases, when consecutive line segments are collinear, the perpendicular vector of the previous line segment is inherited to maintain continuity. For closed lofting paths, ensure that the perpendicular vectors of the start and end points remain consistent. The normal vector of the angle bisector plane is calculated through the cross product of the line segment direction vector and the perpendicular direction vector. The normal vector is perpendicular to the angle bisector plane and determines the spatial direction of the plane. The construction of the angle bisector plane is based on the midpoint of the line segment and the calculated normal vector to form a complete plane geometric representation.
[0024] Specifically, the following process deals with the ray direction calculation and intersection point solution, such as Figure 4 As shown. For each merge point in the merge point coordinate set, the corresponding ray direction is calculated according to the position of the currently traversed loft path segment. The calculation method of the ray direction varies according to the position of the segment in the loft path: when processing the starting segment of the loft path, the ray direction is set to the direction vector of the segment; when processing the intermediate segment, the ray direction is calculated as the normalized result of the sum of the current segment direction vector and the previous segment direction vector. This calculation method ensures that the ray is along the angle bisector of the two segments; when processing the terminating segment, the ray direction is set to the direction vector of the segment. In special cases, when the angle between adjacent segments is too small, the direction perpendicular to the segment is used as the ray direction to avoid numerical instability problems during the calculation process. When the segments are collinear, the direction vector perpendicular to the segment is used as the ray direction. Based on the calculated ray direction and merge point coordinates, a ray parametric equation is constructed. This equation uses a parameterized form to express the relationship between the coordinates of any point on the ray and the starting point coordinates and direction vector.
[0025] Specifically, the intersection coordinates are solved by combining the ray parametric equation and the angle bisector plane equation. The ray parametric equation is expressed as: , , , where the starting point is , the direction vector is The angle bisector plane equation is expressed as: , where the starting point of the lofted path segment is , is the plane normal vector. Substituting the ray parametric equation into the angle bisector plane equation yields a linear equation involving the parameter t. Solving this equation yields the value of the ray parameter t, which is then substituted into the ray parametric equation to calculate the three-dimensional coordinates of the intersection. The calculated intersection coordinates are accumulated and stored in a new contour point coordinate set, which uses a dynamic array structure to accommodate varying amounts of intersection data. During processing, a traversal control mechanism is maintained, using a counter to record the number of processed line segments and compare it with the total number of line segments in the set of lofted paths. When the counter value equals the total number of line segments, processing of all line segments is complete, and the final data consolidation phase begins.
[0026] Specifically, after completing the processing of all the projection path segments, the new contour point coordinate set is deduplicated and sorted. Deduplication is achieved through a coordinate comparison algorithm. A distance threshold is set. When the Euclidean distance between two points is less than the threshold, they are considered to be duplicate points and merged. The sorting process is based on the geometric position relationship of the points. The angle value of each point relative to the contour center is calculated, and the points are arranged in angular order to ensure the orderliness and continuity of the contour points. The data after deduplication and sorting constitutes the final contour point set, which contains all valid contour point coordinates on the current section while maintaining the geometric integrity and topological correctness of the contour. The processed contour point set is added to the final contour point set, which stores the contour point data of each section during the projection process, forming a complete three-dimensional model skeleton structure.
[0027] Furthermore, the step of performing segment decomposition processing on the preset lofting path to obtain a set of lofting path line segments, and traversing the lofting path line segments in the set of lofting path line segments to construct an angle bisector plane corresponding to each lofting path line segment includes: performing node extraction processing on the preset lofting path, decomposing the lofting path into a sequence of line segments with a starting point and an end point according to the extracted nodes, to obtain a set of lofting path line segments; traversing the set of lofting path line segments, and calculating a corresponding line segment direction vector and a perpendicular direction vector according to the endpoint coordinates of the currently traversed lofting path line segment; performing a cross product operation on the line segment direction vector and the perpendicular direction vector to obtain a normal vector of the angle bisector plane, and constructing the angle bisector plane according to the normal vector to obtain the corresponding angle bisector plane.
[0028] Specifically, the preset lofting path is first subjected to node extraction. Lofting paths typically exist as continuous three-dimensional curves or broken lines and contain a large amount of dense coordinate point data. The node extraction process can identify key control points by analyzing the geometric characteristics of each point on the path. The node extraction algorithm can also use equidistant sampling to select nodes on the path at fixed arc length intervals, or adopt an adaptive sampling method to dynamically adjust the node density based on the local complexity of the path. For different types of lofting paths, a node sequence is established during the node extraction process, recording the position index and three-dimensional coordinate information of each node in the original path, while maintaining the sequential relationship of the nodes on the path.
[0029] Specifically, based on the extracted key node sequence, the continuous lofting path is decomposed into a sequence of line segments with clear start and end points. The decomposition process is performed according to the order of the nodes on the path. A line segment is formed between every two adjacent key nodes, with the start point being the coordinates of the current node and the end point being the coordinates of the next node. Each line segment is assigned a unique identifier, and its sequential position within the entire path is recorded. Its geometric properties, including length, direction, and endpoint coordinates, are also stored. The segment length is calculated by calculating the Euclidean distance between its two endpoints, and the segment direction is normalized to obtain a unit direction vector by subtracting the start point coordinates from the endpoint coordinates. During the decomposition process, the validity of the line segments can be checked to filter out segments that are too short or contain anomalies. Collinear continuous line segments can also be merged to avoid redundant geometric data. The resulting lofting path segment set is stored in an ordered data structure, with each segment element containing complete geometric information, including start and end point coordinates, length, direction vector, and other attributes. A mapping relationship is established between the line segments and the original path to ensure that the decomposed line segment data fully represents the geometric characteristics of the original lofting path.
[0030] Specifically, the set of line segments of the lofted path is then traversed, and each line segment in the set is geometrically analyzed and the angle bisector plane is constructed one by one. The traversal process uses a sequential access method, starting from the first element of the line segment set and processing to the last element in sequence. For the currently traversed line segment, the endpoint coordinate information of the line segment is first extracted to obtain the three-dimensional coordinate values of the start and end points. The direction vector of the line segment is calculated using the method d1 = normalize(P2 - P1), where P1 is the starting point of the line segment and P2 is the end point of the line segment. The normalize function converts the vector into a direction vector of unit length. The normalization process is achieved by calculating the modulus of the vector and then dividing each component of the vector by the modulus to ensure that the length of the direction vector is unit length. When the modulus of the vector is close to zero, the default direction vector or the direction vector of the previous line segment is used as a substitute to avoid numerical calculation errors.
[0031] Specifically, the perpendicular vector is calculated using a cross product. First, a reference vector is selected, typically set to (0, 0, 1) along the Z-axis, as the initial reference vector. If the segment direction vector is not parallel to the Z-axis reference vector, the perpendicular vector is calculated using the function normalize(cross(segment direction vector, reference vector)). The cross function represents a vector cross product, and the normalize function normalizes the result. If the segment direction vector is parallel or nearly parallel to the Z-axis reference vector, the cross product result approaches the zero vector. In this case, the cross product is switched to the backup reference vector (1, 0, 0), along the X-axis, and the cross product is repeated. The degree of parallelism between the two vectors is determined by calculating the absolute value of the dot product of the segment direction vector and the reference vector. When the absolute value of the dot product is close to 1, the vectors are considered parallel. The calculated perpendicular vector is normalized to a unit vector, ensuring numerical stability and geometric correctness in subsequent calculations.
[0032] Specifically, the calculation of the angle bisector plane normal vector is achieved through the cross product operation of the line segment direction vector and the perpendicular direction vector. The normalized line segment direction vector and the perpendicular direction vector are used as input, and a vector cross product operation is performed to obtain a normal vector that is perpendicular to both vectors. The direction of the resulting vector of the cross product operation is determined according to the right-hand rule to ensure the consistency of the normal vector's direction and the correctness of the geometric meaning. The calculated normal vector also needs to be normalized to make it a unit normal vector to facilitate the subsequent establishment of the plane equation and intersection calculation. The construction of the angle bisector plane is based on the calculated normal vector and the reference point on the line segment. The reference point is usually the midpoint of the line segment, and the starting point or end point of the line segment can also be selected as a known point on the plane. The angle bisector plane is represented by a point normal equation. The geometric parameters of the angle bisector plane are stored in a dedicated data structure, including the three component values of the normal vector and the three-dimensional coordinate values of the reference point. At the same time, an association relationship is established between the angle bisector plane and the corresponding line segment to ensure that each line segment has a unique corresponding angle bisector plane.
[0033] Specifically, after the angle bisector planes are constructed, the construction results are verified and quality controlled. The verification process includes checking whether the normal vector is a valid unit vector, confirming that its modulus is 1 and that the values of each component are within a reasonable range, and verifying whether the plane equation parameters are set correctly. The geometric relationship between adjacent angle bisector planes is also calculated, including the angle and relative position relationship between the planes, and evaluating the spatial continuity and geometric consistency of the angle bisector plane sequence. For closed lofting paths, special attention needs to be paid to the connection of the angle bisector planes at the beginning and end of the line segments to ensure that the angle bisector planes at the closed point can be correctly connected to avoid geometric discontinuities or sudden changes in direction. The angle bisector plane set is stored in the same order as the line segment set, and an ordered data structure such as an array or linked list is used to establish a one-to-one mapping relationship between line segments and angle bisector planes. Each angle bisector plane data contains complete geometric information, including the normal vector components, reference point coordinates, and the identifier of the corresponding line segment, forming a complete and structured angle bisector plane data set. This data set will serve as the geometric basis for the subsequent ray intersection calculation process.
[0034] Furthermore, the calculating of the ray direction for each merged point in the merged point coordinate set according to the currently traversed lofting path segment, and the calculating of the intersection of the ray direction and the angle bisector plane include: traversing the merged point coordinate set, and calculating the ray direction corresponding to each merged point according to the currently traversed lofting path segment; constructing a ray parameter equation according to the merged point coordinate set and the ray direction; performing a simultaneous solution processing on the ray parameter equation and the angle bisector plane, determining the intersection of the ray direction and the angle bisector plane by solving the ray parameters, and obtaining the intersection coordinates.
[0035] Specifically, the process begins by traversing the merge point coordinate set, which contains preprocessed contour and hole path points. Each merge point has 3D coordinate information and a path type identifier. The traversal process uses a sequential access method, starting with the first merge point in the set and processing each merge point one by one to the last merge point. For the currently traversed merge point, the corresponding ray direction is calculated based on the position of the currently processed lofted path segment. The ray direction calculation method varies depending on the positional characteristics of the segment within the lofted path. First, it is determined whether the current segment is the starting segment, intermediate segment, or ending segment of the lofted path. When processing the starting segment of the lofted path, the ray direction corresponding to the merge point is directly set to the direction vector of the segment, ensuring that the ray is projected along the initial direction of the lofted path. When processing intermediate segments, the ray direction needs to take into account the geometric relationship between adjacent segments. The sum vector of the current segment direction vector and the previous segment direction vector is calculated, and then the sum vector is normalized to obtain the angle bisector direction. This calculation method ensures a smooth transition of ray directions and avoids sudden changes in direction at segment junctions. When processing a terminating line segment, the ray direction is set to the direction vector of the line segment, maintaining consistency with the line segment direction.
[0036] Specifically, in special cases, when the angle between adjacent line segments is too small to cause the calculation of the angle bisector direction to be unstable, the direction perpendicular to the current line segment is used as the ray direction, and the vertical direction vector is calculated through cross product operation. For closed lofting paths, the closed characteristics of the path need to be considered when processing the head and tail connections to ensure the continuity of the ray direction calculation of the head and tail segments. When the line segments are collinear, the direction vector perpendicular to the line segment is used as the ray direction to avoid geometric calculation problems caused by the coincidence of the ray direction and the line segment direction. The path type attribute of the merged point is also considered. For the merged points marked as contour path type and the merged points marked as hole path type, the same ray direction calculation method is used, but different geometric verifications will be performed according to the path type in subsequent processing. After the ray direction calculation is completed, the calculation result is normalized to ensure that the ray direction vector is a unit vector. At the same time, the validity of the ray direction is verified to avoid the occurrence of zero vectors or abnormal vectors.
[0037] Specifically, based on the calculated ray direction and merging point coordinates, a ray parametric equation is constructed to describe the spatial straight line starting from the merging point along the ray direction. The ray parametric equation uses a parametric representation to express the coordinates of any point on the ray as a function of the starting point coordinates, the direction vector, and the parameters. The geometric meaning of the ray parameter t represents the distance from the starting point along the ray direction. When t=0, it corresponds to the starting point of the ray. The larger the t value, the farther the position is from the starting point. The various parameters of the ray parametric equation are stored in a data structure, including the three component values of the starting point coordinates, the three component values of the direction vector, and the parameter value range and constraints. The establishment of the ray parametric equation provides a mathematical basis for the subsequent intersection calculation. The parametric equation can be used to represent the coordinates of any point on the ray, which is convenient for simultaneous solution with the angle bisector plane equation. Ensure the validity of the ray direction vector and the accuracy of the starting point coordinates to avoid the failure of parametric equation construction due to incorrect input data.
[0038] Specifically, the ray parametric equation and the angle bisector plane equation are then solved simultaneously, and the intersection position of the ray and the angle bisector plane is determined through mathematical calculations. The simultaneous solution process substitutes the ray parametric equation into the angle bisector plane equation to obtain a linear equation for the ray parameter t. Specifically, the ray parametric equation is substituted into the angle bisector plane equation and expanded to obtain the linear equation form for the parameter t. Through sorting, a mathematical expression can be obtained for the relationship between the parameter t and the ray direction vector, the angle bisector plane normal vector, and the position of the starting point and the reference point. When the dot product of the ray direction vector and the angle bisector plane normal vector is not zero, the value of the parameter t is solved by division. The validity of the calculated parameter t value is checked to ensure that the t value is non-negative, because the ray only extends in the positive direction of the starting point. When the t value is negative, it means that the intersection point is in the opposite direction of the ray starting point. This situation does not geometrically meet the definition of a ray, and such intersection points are marked as invalid intersection points. When the ray direction vector is perpendicular to the angle bisector plane normal, the dot product of the two vectors is zero. In this case, the ray is parallel to the angle bisector plane or the ray is in the plane. Special treatment is performed according to the specific situation. In the case of parallelism, there is no intersection point. When the ray is in the plane, the entire ray is an intersection point.
[0039] Specifically, after obtaining a valid parameter t value, it is substituted into the ray parametric equation to calculate the three-dimensional coordinates of the intersection. The calculated intersection coordinates are then verified, including checking whether the coordinate values are within a reasonable range and verifying that the intersection lies on the angle bisector plane. The verification process ensures the correctness of the calculation results by substituting the intersection coordinates into the angle bisector plane equation to check whether the equation holds. The distance between the intersection and the ray starting point is also calculated to assess the rationality of the intersection position. Intersection positions that are too far away indicate numerical errors or improper geometric configuration during the calculation process. After completing the intersection coordinate calculation and verification, the valid intersection coordinates are stored in the intersection coordinate set. The corresponding merge point identifier and the layout path segment identifier are also recorded to establish an association between the intersection and the original data. For each combination of a merge point and the current layout path segment, the complete ray direction calculation, parametric equation construction, and intersection solution process are performed to ensure that all merge points receive corresponding intersection coordinates, forming a complete contour intersection data set.
[0040] 103. Performing projection transformation of the three-dimensional coordinates of the contour points in the contour point set into a two-dimensional UV coordinate system, and generating a triangular facet according to the transformed UV coordinate data; In one embodiment of the present invention, the projective transformation of the contour points in the contour point set from three-dimensional coordinates to a two-dimensional UV coordinate system and the generation of a triangular patch based on the transformed UV coordinate data includes: traversing the four vertex coordinates corresponding to each two adjacent sections in the contour point set, and dividing the quadrilateral into two triangles to obtain triangle vertex data; calculating the u coordinate and the v coordinate according to the three-dimensional coordinates of the triangle vertex data in three-dimensional space and the direction vectors of the u axis and the v axis of the two-dimensional UV coordinate system to obtain preliminary UV coordinate data; scaling the preliminary UV coordinate data using a scaling factor to obtain UV coordinate data of the triangular patch, and updating the scaling factor to the distance between the two adjacent vertices currently traversed; calculating the normal vector and the area of the triangle according to the three-dimensional coordinates to obtain geometric data of the triangular patch, and obtaining a triangular patch based on the geometric data and the UV coordinate data.
[0041] Specifically, start traversing the corresponding vertices of each two adjacent sections in the contour point set. The contour point set contains multiple section data generated during the lofting process. Each section consists of a series of contour points, which are arranged in a specific order to form a closed or open contour shape. The correspondence between adjacent sections is established through the index position of the contour points, that is, the j-th contour point of the i-th section corresponds to the j-th contour point of the i+1-th section. Each pair of adjacent sections is processed one by one. For the two sections currently traversed, the coordinates of the four vertices at the corresponding positions are extracted. These four vertices form a quadrilateral, two of which come from the previous section and the other two from the next section. The process of splitting the quadrilateral into two triangles uses the diagonal segmentation method, selecting a diagonal line of the quadrilateral to divide the quadrilateral into two triangles. After the segmentation is completed, the triangle vertex data is obtained. Each triangle consists of the three-dimensional coordinates of three vertices. The order of the vertices is arranged according to the right-hand rule to ensure that the normal vector of the triangle points in the correct direction.
[0042] The 3D coordinates are then projected onto the 2D UV coordinate system. The UV coordinate system is a two-dimensional parameterized coordinate system used to map 3D surfaces onto a 2D texture space. The UV coordinate system is defined by two orthogonal direction vectors: the u-axis direction vector and the v-axis direction vector. These two vectors are typically unit vectors and perpendicular to each other. For each vertex in the triangle vertex data, the corresponding u and v coordinates are calculated based on its 3D coordinates and the axis vectors of the UV coordinate system.
[0043] The coordinates are calculated as: ; in are the three-dimensional vertex coordinates, is the origin coordinate of the UV coordinate system, is the origin of the UV coordinate system in two-dimensional space, is the u-axis direction vector, is the modulus of the vector in the u-axis direction.
[0044] The coordinates are calculated as: ; in is the v-axis direction vector, is the modulus of the vector in the v-axis direction.
[0045] The UV coordinate calculation process essentially projects a point in 3D space onto two axis vectors in the UV coordinate system. The point's components along each axis are calculated using dot multiplication, and then normalized by dividing by the modulus of the axis vector. The calculated u and v coordinates are validated to ensure they are within a reasonable range, avoiding abnormal values due to overflow or calculation errors. The preliminary UV coordinate data is then scaled using a scaling factor. This factor adjusts the scale of the UV coordinates to ensure proportional accuracy and visual consistency in texture mapping. This scaling process multiplies the preliminary UV coordinate data by the scaling factor. The scaling factor update mechanism calculates the Euclidean distance between adjacent vertices in a triangle based on the distance between the two currently traversed vertices. A single edge is selected as a reference length and set as the new scaling factor. Distance calculation uses a standard 3D distance formula. Dynamic updating of the scaling factor ensures that texture density in different areas adapts to geometric characteristics. Smaller scaling factors increase texture resolution in areas with significant geometric variation, while larger scaling factors reduce texture data size in areas with less geometric variation. The UV coordinate data obtained after scaling constitutes the texture coordinate information of the triangle patch. These data, together with the geometric information of the triangle, define a complete triangle patch.
[0046] Then, the geometric properties of the triangle are calculated based on the three-dimensional coordinates of the triangle vertices, including important parameters such as the normal vector and area. The calculation of the triangle normal vector uses the vector cross multiplication method, selecting two side vectors of the triangle for cross multiplication to obtain the normal vector perpendicular to the triangle plane. The specific calculation process is: first calculate the two side vectors of the triangle, and then perform a cross multiplication operation to obtain the normal vector. The result of the cross multiplication operation needs to be normalized to make the normal vector a unit vector, which is convenient for subsequent lighting calculations and surface rendering. The calculation of the triangle area is based on the modulus of the normal vector, that is: ; in is the modulus of the normal vector. This formula uses the geometric meaning of vector cross product to calculate the area of the parallelogram and then divides it by 2 to get the area of the triangle. The calculated geometric data is integrated with the UV coordinate data to form a complete triangle patch data structure. Each triangle patch contains information such as the three-dimensional coordinates of the three vertices, the UV coordinates corresponding to the three vertices, the unit normal vector of the triangle, the area value of the triangle, and the material properties of the triangle. The triangle patch is quality inspected, including checking whether the area of the triangle is too small, whether the normal vector is valid, whether the UV coordinates are within a reasonable range, etc. After verification, the triangle patch data is stored in the triangle patch set, forming a complete surface representation of the three-dimensional model.
[0047] Furthermore, the path type includes a contour path type and a hole path type; the traversing the four vertex coordinates corresponding to each two adjacent sections in the contour point set and dividing the quadrilateral into two triangles to obtain triangle vertex data includes: traversing the vertex coordinates of the four vertices corresponding to each two adjacent sections in the contour point set; dividing the two adjacent sections into two triangles according to a preset division rule based on the vertex coordinates of the four vertices to obtain the triangle data to be verified; calculating the center of gravity of the triangle for the three vertex coordinates of the triangle data to be verified to obtain the center of gravity coordinate data; judging whether the center of gravity coordinate data is inside the closed polygon formed by the vertices of the hole path type, if so, marking the triangle data to be verified as an invalid triangle, if not, marking the triangle data to be verified as a valid triangle; generating triangle vertex data based on the triangle data to be verified marked as a valid triangle.
[0048] Specifically, when processing a contour point set, it is necessary to identify and distinguish between two different path types: contour path type and hole path type. The contour path type represents the outer boundary of a 3D model surface, defining the model's external shape. The polygon formed by these path points encloses the solid portion of the model. The hole path type represents the boundary of a hollow region within the 3D model, defining the area to be hollowed out. The polygon formed by these path points identifies the space within the model where no material exists. The process begins by traversing the corresponding vertex coordinates of each adjacent section in the contour point set. The contour point set contains multiple layers of contour data arranged in cross-section order. Each section has the same number of contour points, and these contour points are in a one-to-one correspondence based on index order. For the two adjacent sections currently being processed, the coordinates of the four vertices corresponding to the position index are extracted. These four vertices come from the i-th contour point of the previous section, the i+1-th contour point of the previous section, the i-th contour point of the next section, and the i+1-th contour point of the next section. These four vertices form a quadrilateral region in 3D space. Verify the validity of the four vertices to ensure that they do not have duplicate coordinates or collinearity. At the same time, check the path type identification of the vertex and record the path type information of each vertex.
[0049] Specifically, the quadrilateral formed by two adjacent cross-sections is split into two triangles based on the vertex coordinates of the four vertices and according to a preset segmentation rule. The preset segmentation rule defines the specific method for segmenting the quadrilateral, typically using a diagonal segmentation strategy to ensure the geometric stability and consistency of the segmentation result. Two possible diagonals of the quadrilateral are calculated: the first diagonal connects the first and third vertices, and the second diagonal connects the second and fourth vertices. The segmentation rule evaluates the geometric quality of two segmentation schemes, selecting the optimal one by calculating metrics such as the area, minimum angle, and side length ratio of the resulting triangles. Using the principle of balanced area ratio, the segmentation scheme that produces two triangles with relatively uniform areas is selected, avoiding triangles that are too narrow or have significantly different areas. After segmentation is completed, two unverified triangle data are generated. Each triangle consists of three vertex coordinates, and the vertices are arranged in a counterclockwise order to maintain the consistency of the normal vector direction. The unverified triangle data contains the triangle's geometric information and the path type attributes of the vertices. This data requires further verification to confirm its validity.
[0050] Specifically, the centroid of the triangle is then calculated for the three vertex coordinates of each triangle data to be verified. The centroid coordinate data represents the spatial position of the geometric center of the triangle. The centroid of the triangle is calculated using the arithmetic average method. The x-coordinate of the centroid is equal to the average of the x-coordinates of the three vertices, the y-coordinate of the centroid is equal to the average of the y-coordinates of the three vertices, and the z-coordinate of the centroid is equal to the average of the z-coordinates of the three vertices. The calculated centroid coordinate data is associated with the corresponding section information to establish a correspondence between the centroid position and the section level, which is convenient for subsequent spatial position judgment processing. The centroid coordinate data not only contains three-dimensional spatial coordinate information, but also records the section index and triangle identifier where the centroid is located, forming a complete centroid position description.
[0051] Specifically, the spatial inclusion relationship of the centroid position is judged next to determine whether the centroid coordinate data lies within the closed polygon formed by vertices of the hole path type. The closed polygon formed by vertices of the hole path type defines the boundary of the hole area in the model. These polygons form a closed contour shape on the two-dimensional plane. First, all vertices marked as the hole path type in the current section are extracted, and these vertices are connected in order of vertex index to form a closed polygon. The judgment of whether a point is inside the polygon uses a ray casting algorithm. This algorithm sends a horizontal ray from the point to be judged and counts the number of intersections between the ray and the polygon boundary. If the number of intersections is odd, the point is inside the polygon; if the number of intersections is even, the point is outside the polygon. The specific implementation process of the ray casting algorithm includes: selecting the centroid coordinate as the starting point of the ray, selecting the horizontal right direction as the ray direction, traversing each edge of the hole polygon, judging whether the ray intersects with the edge, and counting the number of all intersections. The intersection judgment of the edge and the ray needs to consider the position of the edge endpoint and the direction of the ray. When the two endpoints of the edge are respectively above and below the ray, the x-coordinate of the intersection of the ray and the edge is further calculated. If the x-coordinate of the intersection is greater than the x-coordinate of the starting point of the ray, it is considered that there is a valid intersection. To handle boundary conditions, special rules are used to avoid repeated calculations when the ray passes through the vertices of the polygon to ensure the accuracy of the judgment results. According to the calculation results of the ray casting algorithm, it is judged whether the center of gravity is inside the hole polygon. If the center of gravity is inside the hole polygon, it indicates that the triangle is in the hole area of the model and should be marked as an invalid triangle and eliminated in subsequent processing. If the center of gravity is outside the hole polygon, it indicates that the triangle is in the solid area of the model and should be marked as a valid triangle and retained in the final geometric data.
[0052] Specifically, after validating all pending triangle data, the final triangle vertex data is generated based on the marking results. The marking information for valid triangles is aggregated and organized to form a valid triangle list, which contains all triangle data that has passed hole path verification. Valid triangles are screened from the pending triangle data, and their complete geometric information, including vertex coordinates, vertex normals, and texture coordinates, is extracted. The generation of triangle vertex data includes data format conversion and data structure optimization to ensure that the generated data meets the input requirements of subsequent rendering and processing modules. Topological verification is performed on valid triangles, checking the connectivity and shared vertices between triangles to ensure the generated mesh has a good topological structure. Vertex data is indexed to eliminate duplicate vertices and establish a vertex index table to reduce data redundancy and improve processing efficiency. The resulting triangle vertex data contains a complete geometric description of the model surface, excluding invalid triangles located in hole areas. This results in triangular mesh data that accurately reflects the model's physical structure. This data forms the basis for the 3D model surface representation and meets subsequent processing requirements such as texture mapping, lighting calculation, and rendering.
[0053] 104. Output processing is performed on the geometric data of the triangular facet and the corresponding UV coordinate data to obtain three-dimensional model data corresponding to the target drawing.
[0054] In one embodiment of the present invention, the output processing of the geometric data and corresponding UV coordinate data of the triangular facets to obtain the three-dimensional model data corresponding to the target drawing includes: adding the UV coordinate data of the triangular facets to a preset UV data set according to a preset order and regular format; performing data optimization processing on the UV data set after storing the data to obtain an optimized UV data set, wherein the data optimization processing includes one or both of sorting the UV data set according to the UV coordinate data and constructing an index corresponding to the UV coordinate data; and obtaining the three-dimensional model data based on the optimized UV data set and the geometric data of the triangular facets as output results and saving them as a three-dimensional model file.
[0055] Specifically, the UV coordinate data of each triangle patch is added to a pre-set UV data set according to a preset order and regular format. A UV data set is a data structure specifically used to store texture coordinate information, organized in a linear array or dynamic list format. The preset order defines the order in which the UV coordinate data is added. It is typically arranged according to the processing order or geometric topology of the triangle patches, ensuring that the UV coordinate data maintains a consistent index relationship with the corresponding triangle vertices. The regular format specifies the storage format of the UV coordinate data in the set. Each UV coordinate data item contains floating-point values for the u and v components, as well as associated information such as the corresponding vertex and triangle identifiers. All valid triangle patches are traversed, and the UV coordinate data corresponding to each patch's three vertices is extracted and added to the UV data set in order. During the addition process, the UV coordinate data is checked for validity, verifying that the u and v component values are within a reasonable range. UV coordinate values typically range from [0, 1]. Coordinate values outside this range are normalized or marked as abnormal data. The integrity of the UV coordinate data is also checked to ensure that each triangle has the complete three vertex UV coordinates. Patches with missing UV coordinates are marked and interpolated to generate the missing coordinate data. The storage structure of the UV data set supports fast access and modification operations. A hash table or tree structure is used to establish the mapping relationship between UV coordinate data and vertex indices, improving the efficiency of data lookup and update.
[0056] Specifically, after data addition is complete, the stored UV dataset undergoes data optimization. This optimization process primarily involves sorting and indexing. Sorting rearranges the data items in the dataset based on the specific attributes of the UV coordinate data. Common sorting criteria include ascending u-coordinate values, ascending v-coordinate values, distance from the origin, or lexicographical order. First, an appropriate sorting algorithm is selected. For small datasets, insertion sort or selection sort is used, while for large datasets, efficient algorithms such as quick sort or merge sort are used. During the sorting process, the correspondence between the UV coordinate data and the original vertex indices is maintained. Data traceability is maintained by establishing a mapping table or using a data structure containing the original indices. Sorting improves access efficiency for the UV dataset, enabling fast coordinate-based queries and range searches. Indexing creates an efficient index structure for the UV dataset. Index structures include spatial, hash, and tree indexes. Spatial indexes employ quadtree or grid indexing, partitioning the UV coordinate space into multiple regions. Each region records the UV coordinate data items it contains, supporting fast queries based on spatial location. Hash indexes calculate hash values based on UV coordinates, grouping data items with the same hash value into the same bucket, enabling constant-time exact match queries. Tree indexes use a balanced binary tree or B-tree structure, constructing an index tree based on the sorted UV coordinates, supporting range queries and ordered traversal operations.
[0057] Specifically, when building an index, the access patterns and query requirements of the UV dataset are first analyzed, and the most appropriate index type and parameter configuration are selected. For applications that frequently perform exact match queries, hash indexes are prioritized, optimizing query performance by selecting an appropriate hash function and bucket size. For applications that require range queries or sorted access, tree indexes are constructed, leveraging the self-balancing properties of balanced trees to ensure logarithmic query complexity. Spatial indexes are suitable for neighborhood queries and spatial relationship analysis based on two-dimensional UV coordinate locations. The appropriate spatial partitioning strategy and index depth are selected based on the distribution characteristics of UV coordinates. The index building process consists of three phases: index structure initialization, data item insertion, and index optimization. The initialization phase determines the index type, capacity, and configuration parameters. The insertion phase adds all data items in the UV dataset to the index structure one by one. The optimization phase rebalances or reorganizes the index to improve access efficiency. After index building is complete, the optimized UV dataset is obtained. This dataset not only contains ordered UV coordinate data but also features an efficient index structure, significantly improving data access and processing performance.
[0058] Specifically, the optimized UV data set and the geometric data of the triangular facets are then used as output and saved as a 3D model file to generate the final 3D model data. The geometric data includes information such as the 3D coordinates of the triangle vertices, normal vectors, area, and topological connectivity. Together with the UV coordinate data, this data constitutes a complete 3D model representation. Select an appropriate 3D model file format to store the output results. Common formats include OBJ, PLY, STL, and custom binary formats. The OBJ format stores model data in text format, offering good readability and compatibility. The file contains different types of data records, such as vertex coordinate lines, texture coordinate lines, normal lines, and face definition lines. The PLY format supports both binary and text storage, offers flexible data structure definition capabilities, and can store custom vertex and face attribute information. The STL format is specifically designed for storing triangular mesh data. While simple and widely supported, it does not support the storage of texture coordinates or material information. Select the most appropriate file format based on application needs and compatibility requirements, while also considering factors such as file size, read speed, and data integrity.
[0059] Specifically, the file saving process consists of three steps: data serialization, file writing, and integrity verification. Data serialization converts the UV data set and geometry data in memory into the data representation specified by the file format. This includes operations such as coordinate precision control, data type conversion, and byte order processing. Floating-point coordinate values are truncated, typically retaining 6 to 8 significant digits to balance file size and data accuracy. The file writing operation writes the serialized data to the target file according to the format specifications. The writing process uses a buffering mechanism to improve writing efficiency and monitors resources such as disk space and write permissions. For large-scale model data, a block-based writing method is used, dividing the data into multiple blocks for batch writing to avoid excessive memory usage and write timeouts. The integrity verification phase verifies the written file, including file size checks, format validation, and data consistency checks. A checksum or hash value is calculated for the written data and compared with the checksum value of the original data to ensure that no data corruption or loss occurred during the file writing process. Format verification verifies that the file conforms to the target format specifications by parsing the file header information and data structure. After the file is saved and verified, 3D model data containing complete geometric and texture information is generated. This data can be directly used by downstream applications such as 3D modeling software, rendering engines, and manufacturing equipment, realizing the complete conversion process from 2D drawings to 3D models.
[0060] In this embodiment, the contour path data and hole path data of the target drawing are preprocessed and path type marked, and a unified storage is obtained to obtain a set of merged point coordinates. Based on the set of merged point coordinates, a preset lofting path is traversed, and the intersection of the ray with the angle bisector of the lofting path is calculated with the merged point as the starting point to obtain a set of contour points. The contour points in the set of contour points are projected from the three-dimensional coordinates to the two-dimensional UV coordinate system, and triangular facets are generated based on the transformed UV coordinate data. The geometric data of the triangular facets and the corresponding UV coordinate data are output and processed to obtain the three-dimensional model data. Through the path type marking and unified processing mechanism, the present invention effectively solves the problem of complex contour lofting containing hole structures, ensuring that the geometric characteristics of the contour path and hole path are correctly processed.
[0061] The above describes the model lofting method in the embodiment of the present invention. The following describes the model lofting device in the embodiment of the present invention. Figure 2 In one embodiment of the present invention, a model lofting device includes: The data preprocessing module 201 is used to preprocess the contour path data and hole path data of the target drawing and mark the path type, and uniformly store them to obtain a merged point coordinate set; The contour generation module 202 is configured to traverse the preset lofting path according to the merging point coordinate set, calculate the intersection point of the ray with the angular bisector plane of the lofting path using the merging point in the merging point coordinate set as the starting point, and obtain the contour point set; The triangulation processing module 203 is used to perform a projection transformation of the three-dimensional coordinates of the contour points in the contour point set into a two-dimensional UV coordinate system, and generate a triangular facet according to the transformed UV coordinate data; The data output module 204 is used to output the geometric data of the triangular facets and the corresponding UV coordinate data to obtain the three-dimensional model data corresponding to the target drawing.
[0062] In an embodiment of the present invention, the model lofting device operates the aforementioned model lofting method. The device pre-processes the contour path data and hole path data of the target drawing and marks the path type, uniformly storing a merged point coordinate set; traverses a preset lofting path based on the merged point coordinate set, calculates the intersection of the ray with the angle bisector of the lofting path using the merged point as the starting point, and obtains a contour point set; performs a projection transformation of the contour points in the contour point set from three-dimensional coordinates to a two-dimensional UV coordinate system, and generates triangular facets based on the transformed UV coordinate data; and outputs and processes the geometric data of the triangular facets and the corresponding UV coordinate data to obtain three-dimensional model data. Through path type marking and a unified processing mechanism, the present invention effectively solves the problem of complex contour lofting involving hole structures, ensuring that the geometric characteristics of the contour path and hole path are correctly processed.
[0063] above Figure 2 The model lofting device in the embodiment of the present invention is described in detail from the perspective of modular functional entities. The model lofting device in the embodiment of the present invention is described in detail from the perspective of hardware processing.
[0064] Figure 3 The figure is a schematic diagram of the structure of a model lofting device provided by an embodiment of the present invention. The model lofting device 300 may vary significantly depending on its configuration or performance. It may include one or more processors (central processing units, CPUs) 310 (e.g., one or more processors), memory 320, and one or more storage media 330 (e.g., one or more mass storage devices) storing application programs 333 or data 332. The memory 320 and storage medium 330 may be either transient or persistent storage. The program stored in the storage medium 330 may include one or more modules (not shown), each of which may include a series of instructions for operating on the model lofting device 300. Furthermore, the processor 310 may be configured to communicate with the storage medium 330, and the model lofting device 300 may execute the series of instructions stored in the storage medium 330 to implement the steps of the model lofting method described above.
[0065] The model lofting device 300 may further include one or more power supplies 340, one or more wired or wireless network interfaces 350, one or more input and output interfaces 360, and / or one or more operating systems 331, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. It will be understood by those skilled in the art that Figure 3The structure of the model lofting device shown does not constitute a limitation on the model lofting device provided by the present invention, and may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently.
[0066] The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium or a volatile computer-readable storage medium. The computer-readable storage medium stores instructions, which, when executed on a computer, cause the computer to execute the steps of the model lofting method.
[0067] Those skilled in the art will clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described systems, devices, and units can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0068] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the portion that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes various media that can store program code, such as a USB flash drive, a mobile hard drive, a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.
[0069] As described above, the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that the technical solutions described in the above embodiments can still be modified, or some of the technical features thereof can be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A model lofting method, characterized in that: The model lofting method comprises: Preprocess the contour path data and hole path data of the target drawing, mark the path type, and store them uniformly to obtain a merged point coordinate set; Traversing the preset lofting path according to the merging point coordinate set, taking the merging point in the merging point coordinate set as the ray starting point and calculating the intersection point with the angle bisector plane of the lofting path to obtain a contour point set; Performing a projection transformation of the three-dimensional coordinates of the contour points in the contour point set into a two-dimensional UV coordinate system, and generating a triangular facet according to the transformed UV coordinate data; The geometric data of the triangular facets and the corresponding UV coordinate data are output and processed to obtain the three-dimensional model data corresponding to the target drawing.
2. The model lofting method according to claim 1, characterized in that: The preset lofting path is traversed according to the merging point coordinate set, and the intersection point with the angle bisector plane of the lofting path is calculated with the merging point in the merging point coordinate set as the ray starting point to obtain the contour point set. Performing segment decomposition processing on the preset lofting path to obtain a lofting path segment set, and traversing the lofting path segments in the lofting path segment set to construct an angle bisector plane corresponding to each lofting path segment; For each merged point in the merged point coordinate set, a ray direction is calculated according to the currently traversed lofting path segment, and the coordinates of the intersection point of the ray direction and the angle bisector plane are calculated; Accumulating and storing the intersection coordinates of the intersection points into a new contour point coordinate set, and determining whether the processing of all the lofted path segments is completed through a traversal control mechanism; If so, deduplication and sorting are performed on the new contour point coordinate set to obtain a contour point set.
3. The model lofting method according to claim 2, characterized in that: The step of performing segment decomposition processing on the preset lofting path to obtain a lofting path segment set, and traversing the lofting path segments in the lofting path segment set to construct an angle bisector plane corresponding to each lofting path segment includes: Performing node extraction processing on the preset lofting path, decomposing the lofting path into a sequence of line segments with a start point and an end point according to the extracted nodes, and obtaining a lofting path line segment set; Traversing the set of lofting path line segments, and calculating the corresponding line segment direction vector and the perpendicular direction vector according to the endpoint coordinates of the currently traversed lofting path line segment; A cross product operation is performed on the line segment direction vector and the vertical direction vector to obtain a normal vector of the angle bisector plane, and the angle bisector plane is constructed according to the normal vector to obtain the corresponding angle bisector plane.
4. The model lofting method according to claim 2, characterized in that: The step of calculating a ray direction for each merged point in the merged point coordinate set according to the currently traversed lofting path segment, and calculating an intersection point between the ray direction and the angle bisector plane includes: Traversing the merging point coordinate set, and calculating the ray direction corresponding to each merging point according to the currently traversed lofting path segment; Constructing a ray parameter equation according to the merged point coordinate set and the ray direction; The ray parameter equation and the angle bisector plane are solved simultaneously, and the intersection point of the ray direction and the angle bisector plane is determined by solving the ray parameters to obtain the coordinates of the intersection point.
5. The model lofting method according to claim 1, characterized in that: The step of performing a projection transformation from three-dimensional coordinates to a two-dimensional UV coordinate system on the contour points in the contour point set and generating a triangular facet according to the transformed UV coordinate data comprises: Traverse the four vertex coordinates corresponding to each two adjacent sections in the contour point set, and split the quadrilateral into two triangles to obtain triangle vertex data; Calculate the u coordinate and the v coordinate according to the three-dimensional coordinates of the triangle vertex data in the three-dimensional space and the direction vectors of the u axis and the v axis of the two-dimensional UV coordinate system, respectively, to obtain preliminary UV coordinate data; Scaling the preliminary UV coordinate data using a scaling factor to obtain UV coordinate data of a triangular face, and updating the scaling factor to the distance between two adjacent vertices currently traversed; The normal vector and the area of the triangle are calculated according to the three-dimensional coordinates to obtain geometric data of the triangle patch, and the triangle patch is obtained according to the geometric data and the UV coordinate data.
6. The model lofting method according to claim 5, characterized in that: The path types include contour path types and hole path types; The traversal of the four vertex coordinates corresponding to each two adjacent sections in the contour point set and the division of the quadrilateral into two triangles to obtain the triangle vertex data includes: Traverse the vertex coordinates of the four vertices corresponding to each two adjacent sections in the contour point set; Splitting two adjacent cross sections into two triangles according to the vertex coordinates of the four vertices and a preset segmentation rule to obtain triangle data to be verified; Calculating the center of gravity of the triangle based on the three vertex coordinates of the triangle data to be verified to obtain center of gravity coordinate data; Determine whether the barycentric coordinate data is inside the closed polygon formed by the vertices of the hole path type. If so, mark the triangle data to be verified as an invalid triangle; if not, mark the triangle data to be verified as a valid triangle. Generate triangle vertex data based on the triangle data to be verified that is marked as a valid triangle.
7. The model lofting method according to claim 1, characterized in that: The outputting of the geometric data of the triangular facets and the corresponding UV coordinate data to obtain the three-dimensional model data corresponding to the target drawing includes: Adding the UV coordinate data of the triangular face to a preset UV data set according to a preset order and regular format; Performing data optimization processing on the UV data set after the data is stored to obtain an optimized UV data set, wherein the data optimization processing includes one or both of sorting the UV data set according to the UV coordinate data and constructing an index corresponding to the UV coordinate data; The optimized UV data set and geometric data of the triangular facet are used as output results and saved as a three-dimensional model file to obtain three-dimensional model data.
8. A model lofting device, characterized in that: The model lofting device comprises: The data preprocessing module is used to preprocess the contour path data and hole path data of the target drawing and mark the path type, and uniformly store the merged point coordinate set; A contour generation module is used to traverse the preset lofting path according to the merging point coordinate set, calculate the intersection point with the angular bisector plane of the lofting path with the merging point in the merging point coordinate set as the ray starting point, and obtain the contour point set; a triangulation processing module, configured to perform a projection transformation of the three-dimensional coordinates of the contour points in the contour point set into a two-dimensional UV coordinate system, and generate triangular facets according to the transformed UV coordinate data; The data output module is used to output the geometric data of the triangular facets and the corresponding UV coordinate data to obtain the three-dimensional model data corresponding to the target drawing.
9. A model lofting device, characterized in that: The model lofting device includes: a memory and at least one processor, wherein the memory stores instructions; The at least one processor calls the instructions in the memory to enable the model lofting device to perform the steps of the model lofting method according to any one of claims 1 to 7.
10. A computer-readable storage medium having instructions stored thereon, characterized in that: When the instructions are executed by a processor, the steps of the model lofting method according to any one of claims 1 to 7 are implemented.