A three-dimensional model anchor point positioning method, device and readable storage medium
Patent Information
- Application Number
- CN202611155829.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-31
- Publication Date
- 2026-10-23
AI Technical Summary
该方式存在显著缺陷:其一,重复机械性操作量大,处理复杂或批量模型时耗时极长,效率低下;其二,完全依赖个人经验与习惯,缺乏统一创建标准,不同操作者或不同时间得到的位置和数量差异明显,难以支持后续的自动化集成与规范管理;其三,人工目测与鼠标操作受显示分辨率、观察视角和手部颤动等因素影响,容易引入位置误差,尤其在曲面转折处精度难以保证
[0050]从上述的技术方案可以看出,本申请实施例提供的一种三维模型锚点定位方法、装置和可读存储介质,包括:获取目标三维模型的网格数据,该网格数据包含构成模型的多个面以及每个面的边信息;基于网格数据提取构成模型表面的边线段,并根据每条边线段所在平面的方向属性,将其转化为参考平面内的对应线段,形成初始线段集合;对初始线段集合执行多级线段过滤处理,以去除不表征模型外部轮廓的冗余线段,该多级线段过滤处理包括基于线段共线性的重叠边去除操作、基于线段相交关系的相交边分割操作、以及基于线段与面的包含关系的内部边筛除操作;提取轮廓线段集合中所有线段的端点坐标,对端点坐标去重后生成三维模型的轮廓锚点。
Smart Images

Figure CN122966729A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of anchor point positioning technology, and more specifically, to a method, apparatus and readable storage medium for anchor point positioning of a three-dimensional model. Background Technology
[0002] In the processing of 3D models and applications such as virtual assembly and augmented reality, it is often necessary to define external contour anchor points on the model surface as alignment references. The generation method directly affects work efficiency and consistency.
[0003] Current anchor point creation methods rely entirely on manual operation: operators open the model using 3D software, determine the positions through visual observation and subjective judgment, manually click to create anchor points, and repeatedly drag and fine-tune them to approximate positions. This method has significant drawbacks: First, it involves a large amount of repetitive mechanical operations, which is extremely time-consuming and inefficient when processing complex or batch models. Second, it relies entirely on personal experience and habits, lacking a unified creation standard. The positions and quantities obtained by different operators or at different times vary significantly, making it difficult to support subsequent automated integration and standardized management. Third, manual visual inspection and mouse operation are easily affected by factors such as display resolution, viewing angle, and hand tremors, which can easily introduce positional errors, especially at curved surface transitions where accuracy is difficult to guarantee. In addition, anchor points are not related to the model's geometric data. Once the model design changes, all manual operations must be repeated, resulting in high maintenance costs.
[0004] Therefore, there is an urgent need for a method that can automatically and accurately generate contour anchor points based on model geometric data, in order to eliminate reliance on manual methods, establish unified standards, and fundamentally improve positioning accuracy. Summary of the Invention
[0005] This application provides a method, apparatus, and readable storage medium for anchor point positioning of a 3D model, which realizes efficient automatic generation, standardized result output, and high-precision positioning of 3D model contour anchor points.
[0006] A method for anchor point positioning of a 3D model, comprising:
[0007] Obtain the mesh data of the target 3D model, wherein the mesh data includes multiple faces that constitute the model and edge information of each face;
[0008] Based on the grid data, the edge segments constituting the model surface are extracted, and each edge segment is converted into a corresponding line segment in the reference plane according to the direction attribute of the plane where each edge segment is located, forming an initial line segment set.
[0009] A multi-level line segment filtering process is performed on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, resulting in a contour line segment set. The multi-level line segment filtering process includes overlapping edge removal based on line segment collinearity, intersecting edge segmentation based on line segment intersection relationship, and internal edge filtering based on the inclusion relationship between line segment and surface.
[0010] Extract the endpoint coordinates of all line segments in the contour line segment set, and generate the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
[0011] Optionally, the step of converting each edge segment into a corresponding line segment in the reference plane based on the orientation attribute of the plane containing each edge segment includes:
[0012] For each edge segment, determine the normal vector of the plane containing the edge segment;
[0013] If the cross product of the normal vector and the preset vertical direction vector indicates that the two vectors are not parallel, then the plane is determined to be a non-horizontal plane. The coordinates of the two endpoints of the edge segment are multiplied by the horizontal unit vector to obtain the projected coordinates on the horizontal plane. Based on the projected coordinates, a projected line segment is constructed as the corresponding line segment in the reference plane.
[0014] If the cross product result indicates that the two vectors are parallel, then the plane is determined to be a horizontal plane, and the edge segment is directly retained as the corresponding line segment in the reference plane.
[0015] Optionally, the overlapping edge removal operation based on line segment collinearity includes:
[0016] Iterate through the set of line segments to be filtered and match the endpoint coordinates of each line segment;
[0017] If two line segments have the same shared endpoint, calculate the first direction vector and the second direction vector pointing from the shared endpoint to the other endpoint of the two line segments, respectively.
[0018] Based on the cross product and dot product of the first direction vector and the second direction vector, determine the collinearity and directionality of the two line segments;
[0019] When the cross product result indicates that the two vectors are parallel and the dot product result indicates that the two vectors are in the same direction, it is determined that the two line segments are collinear and overlap in the same direction.
[0020] Keep the line segment with the longer vector magnitude of the two line segments, and remove the other line segment.
[0021] Optionally, the intersection edge segmentation operation based on line segment intersection relationships includes:
[0022] Iterate through the set of line segments to be filtered and combine each pair of line segments to determine whether the two line segments are parallel.
[0023] If the two line segments are determined to be parallel, then no division is performed;
[0024] If it is determined that the two line segments are not parallel, the existence of an intersection point is determined by parametric intersection point detection. When the detection result shows that the intersection point is located on both line segments at the same time, the coordinates of the intersection point are obtained.
[0025] Based on the intersection point, the two intersecting line segments are split into multiple segments, and the new line segments obtained from the splitting are used to update the set of line segments to be filtered.
[0026] Optionally, the multi-level line segment filtering process further includes:
[0027] An overlapping edge removal operation based on line segment collinearity is used to perform a secondary overlapping edge removal on the set of line segments to be filtered obtained after the intersection edge segmentation operation.
[0028] Optionally, the internal edge filtering operation based on the inclusion relationship between line segments and surfaces includes:
[0029] For each line segment to be tested in the set of line segments to be filtered, obtain all faces in the grid data;
[0030] For each face, determine the spatial equation of the face;
[0031] For the two endpoints of the line segment to be tested, determine whether the endpoints lie on the surface based on the surface space equation;
[0032] If both endpoints of the line segment to be measured are located on the same surface, then construct rays from the two endpoints in any direction and count the number of intersections between each ray and the boundary of the surface.
[0033] If the number of intersections between the two rays and the boundary of the surface is odd, the line segment to be tested is determined to be an internal edge of the surface and is removed; otherwise, the line segment to be tested is retained.
[0034] Optionally, after the internal edge filtering operation, the following steps are also included:
[0035] Traverse the set of line segments to be filtered after internal edge filtering, and compare the endpoint coordinates of each line segment;
[0036] If two line segments share the same endpoint, calculate two vectors from the shared endpoint to their respective other endpoints, and determine whether the two line segments are collinear based on the cross product of the two vectors.
[0037] If the cross product indicates that the two vectors are collinear, then the two line segments are determined to be collinear.
[0038] A new line segment is constructed using the two non-shared endpoints of the two line segments, and the original two line segments are removed from the set of line segments to be filtered.
[0039] Optionally, the step of extracting the endpoint coordinates of all line segments in the contour line segment set, and generating the contour anchor points of the 3D model after deduplicating the endpoint coordinates includes:
[0040] Extract the coordinates of the two endpoints of each line segment in the contour line segment set to form an endpoint coordinate set;
[0041] Remove duplicate coordinate points from the endpoint coordinate set to obtain the deduplicated endpoint coordinate set;
[0042] Spatial clustering is performed on the endpoints in the deduplicated endpoint coordinate set, and endpoints whose mutual distance is less than a preset distance merging threshold are divided into the same cluster.
[0043] For each cluster, the cluster center of all endpoint coordinates within the cluster is taken as the coordinates of a single contour anchor point to generate a merged set of contour anchor points.
[0044] A three-dimensional model anchor point positioning device is used to perform the three-dimensional model anchor point positioning method as described in any of the preceding claims, comprising:
[0045] The mesh data module is used to acquire the mesh data of the target 3D model. The mesh data includes multiple faces that make up the model and the edge information of each face.
[0046] The line segment extraction module is used to extract the edge line segments that constitute the surface of the model based on the grid data, and convert each edge line segment into a corresponding line segment in the reference plane according to the direction attribute of the plane where each edge line segment is located, forming an initial line segment set.
[0047] A multi-level filtering module is used to perform multi-level line segment filtering on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, thereby obtaining a contour line segment set. The multi-level line segment filtering includes overlapping edge removal based on line segment collinearity, intersecting edge segmentation based on line segment intersection relationship, and internal edge filtering based on the inclusion relationship between line segment and surface.
[0048] The contour anchor point module is used to extract the endpoint coordinates of all line segments in the contour line segment set, and generate the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
[0049] A readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the three-dimensional model anchor point positioning method as described in any of the preceding claims.
[0050] As can be seen from the above technical solutions, the present application provides a three-dimensional model anchor point positioning method, apparatus, and readable storage medium, including: acquiring mesh data of a target three-dimensional model, the mesh data containing multiple faces constituting the model and edge information of each face; extracting edge segments constituting the surface of the model based on the mesh data, and converting them into corresponding line segments in a reference plane according to the direction attribute of the plane where each edge segment is located, forming an initial line segment set; performing multi-level line segment filtering processing on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, the multi-level line segment filtering processing including overlapping edge removal operation based on line segment collinearity, intersecting edge segmentation operation based on line segment intersection relationship, and internal edge filtering operation based on the inclusion relationship between line segments and faces; extracting the endpoint coordinates of all line segments in the contour line segment set, and generating the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
[0051] First, this application automatically performs edge segment extraction, reference plane mapping, multi-level filtering, and endpoint deduplication by reading mesh data, eliminating the need for manual intervention in the entire process from the original model to anchor point generation. This eliminates repetitive manual creation and fine-tuning operations, significantly improving anchor point generation efficiency, especially suitable for batch model processing scenarios. Second, in the multi-level segment filtering process, the overlapping edge removal operation eliminates redundant edges based on the collinearity of line segments, the intersecting edge segmentation operation accurately segments at intersections based on the intersection relationship of line segments, and the internal edge removal operation removes invisible edges inside the model based on the inclusion relationship between line segments and faces. This ensures that the final set of retained contour segments strictly corresponds to the external contour of the model, without relying on the operator's subjective judgment, thus enabling the output of standardized anchor point results for the same model. Furthermore, the edge segments processed in this application are directly derived from the original mesh data of the model and are accurately mapped to the reference plane through directional attributes without any manual relocation. The intersecting edge segmentation operation ensures that key points at contour turning points are not missed, and the internal edge filtering operation eliminates interference from internal structures. As a result, the extracted anchor point coordinates are highly consistent with the actual external contour of the model, ensuring the accuracy of anchor point positioning from both the data source and algorithm processing levels. Attached Figure Description
[0052] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0053] Figure 1 This is a flowchart of a three-dimensional model anchor point positioning method disclosed in an embodiment of this application;
[0054] Figure 2This is a schematic diagram of a three-dimensional model anchor point positioning device disclosed in an embodiment of this application. Detailed Implementation
[0055] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0056] This application can be used in a wide variety of general-purpose or special-purpose computing device environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor devices, distributed computing environments including any of the above devices, etc.
[0057] The following section introduces the solution proposed in this application. The technical solution is as follows, please refer to the text below for details.
[0058] Figure 1 This is a flowchart of a three-dimensional model anchor point positioning method disclosed in an embodiment of this application.
[0059] like Figure 1 As shown, the method may include:
[0060] Step S1: Obtain the mesh data of the target 3D model. The mesh data includes multiple faces that make up the model and the edge information of each face.
[0061] Specifically, the target model is opened in the 3D software. The main node of the model from which contour anchor points need to be generated is selected. All child nodes under this main node are traversed, and the mesh information data corresponding to the child nodes is extracted. All triangular facets that make up the mesh are saved. Through the data interaction interface or model file parsing module of the 3D modeling software, the digital representation of the target 3D model is read, and the mesh topology and geometric information are extracted from it. The acquired mesh data discretizes the model surface into a series of polygonal patches. Each patch records the edge segment data that makes up its boundary, including the endpoint index, connection order, and coordinate values of each endpoint in 3D space. The surface information not only clarifies the geometric boundary range of each face but also implies the orientation and positional relationship of each face in space, providing complete basic data for subsequent steps to extract the edge segments of the model surface and analyze the orientation attributes of the faces.
[0062] Step S2: Based on the grid data, extract the edge segments that constitute the surface of the model, and according to the direction attribute of the plane where each edge segment is located, convert each edge segment into a corresponding line segment in the reference plane to form an initial line segment set.
[0063] Specifically, during implementation, each face in the grid data is traversed, and all edge segments constituting that face are extracted sequentially from its edge information. For the face being processed, any pair of adjacent edge segments on its boundary are selected, and a first direction vector and a second direction vector reflecting their respective extension directions are constructed using the coordinate difference between the endpoints of these two edge segments. The cross product operation is performed on the first direction vector and the second direction vector, and the resulting vector is the direction vector of the face, used to characterize the orientation of the face in space. Subsequently, the cross product of the direction vector of the face and a pre-defined vertical unit vector is calculated. If the cross product is not zero, it indicates that the face is not parallel to the horizontal reference plane. In this case, a projection transformation is required for all edge segments on the face. This involves performing a dot product of the coordinates of each endpoint of each edge segment with a set of orthogonal basis vectors within the horizontal reference plane, thereby obtaining a two-dimensional projection representation of the edge segment within the horizontal reference plane, and saving this projection segment. If the cross product is zero, it indicates that the face is either horizontal or parallel to the horizontal reference plane. In this case, no projection transformation is needed, and the edge segments on the face are directly saved in their original three-dimensional form. After completing the above processing for all faces in the mesh data, all the resulting line segments constitute the initial line segment set. This initial line segment set includes both edge segments originally located within the horizontal plane and projected line segments transformed from non-horizontal planes to the horizontal reference plane. This achieves an integrated expression of the model surface boundary information within a unified reference plane, providing line segment data to be processed for subsequent multi-level line segment filtering.
[0064] Step S3: Perform multi-level line segment filtering on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, and obtain a contour line segment set. The multi-level line segment filtering includes overlapping edge removal based on line segment collinearity, intersecting edge segmentation based on line segment intersection relationship, and internal edge filtering based on the inclusion relationship between line segment and surface.
[0065] Specifically, a multi-level line segment filtering process is performed on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, resulting in a contour line segment set. This multi-level line segment filtering process includes overlapping edge removal based on line segment collinearity, intersection edge segmentation based on line segment intersection relationships, and internal edge removal based on the inclusion relationship between line segments and surfaces. The overlapping edge removal operation based on line segment collinearity analyzes the direction vectors and spatial positions of line segments to identify groups of line segments that are on the same straight line and partially or completely overlap. Based on the projection interval coverage relationship of the line segments in the straight line direction, mutually overlapping redundant parts are eliminated or merged into the longest continuous line segment, eliminating redundant boundary information. The intersection edge segmentation operation based on line segment intersection relationships detects whether any two line segments in the initial line segment set have an internal intersection point that is not an endpoint. If an intersection relationship is detected, the original line segment is divided into several sub-line segments at the intersection point, ensuring that all processed line segments only connect at their endpoints, preventing line segment overlap and ensuring topological consistency in boundary representation. The internal edge filtering operation based on the containment relationship between line segments and faces determines whether each line segment completely falls within the interior region of a face rather than being located on the face's boundary ring. This containment relationship can be determined through methods such as ray casting or bounding box pre-checking. All internal line segments completely contained within a face are removed from the set, retaining only the boundary line segments that constitute the model's outer contour. After this multi-level filtering, the remaining line segments form a contour line segment set, where each line segment is a valid boundary component of the model's outer contour on the reference plane.
[0066] Step S4: Extract the endpoint coordinates of all line segments in the contour line segment set, and generate the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
[0067] Specifically, each line segment in the contour line segment set is traversed, and its starting and ending endpoint coordinates are recorded one by one. Since adjacent contour line segments connect at their endpoints, there will inevitably be a large number of duplicate endpoints in the recorded coordinate data. These endpoint coordinates are then deduplicated and merged. Based on a preset spatial tolerance, multiple endpoint coordinates that are sufficiently close in position are considered as the same anchor point, and after merging, a set of non-redundant contour anchor points is obtained. These anchor points correspond to the key feature vertices of the 3D model's external contour on the reference plane, defining the geometric shape of the model contour and providing an accurate set of reference points for subsequent applications such as contour reconstruction, graphic fitting, or CNC machining path generation.
[0068] As can be seen from the above technical solutions, the present application provides a three-dimensional model anchor point positioning method, apparatus, and readable storage medium, including: acquiring mesh data of a target three-dimensional model, the mesh data containing multiple faces constituting the model and edge information of each face; extracting edge segments constituting the surface of the model based on the mesh data, and converting them into corresponding line segments in a reference plane according to the direction attribute of the plane where each edge segment is located, forming an initial line segment set; performing multi-level line segment filtering processing on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, the multi-level line segment filtering processing including overlapping edge removal operation based on line segment collinearity, intersecting edge segmentation operation based on line segment intersection relationship, and internal edge filtering operation based on the inclusion relationship between line segments and faces; extracting the endpoint coordinates of all line segments in the contour line segment set, and generating the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
[0069] First, this application automatically performs edge segment extraction, reference plane mapping, multi-level filtering, and endpoint deduplication by reading mesh data, eliminating the need for manual intervention in the entire process from the original model to anchor point generation. This eliminates repetitive manual creation and fine-tuning operations, significantly improving anchor point generation efficiency, especially suitable for batch model processing scenarios. Second, in the multi-level segment filtering process, the overlapping edge removal operation eliminates redundant edges based on the collinearity of line segments, the intersecting edge segmentation operation accurately segments at intersections based on the intersection relationship of line segments, and the internal edge removal operation removes invisible edges inside the model based on the inclusion relationship between line segments and faces. This ensures that the final set of retained contour segments strictly corresponds to the external contour of the model, without relying on the operator's subjective judgment, thus enabling the output of standardized anchor point results for the same model. Furthermore, the edge segments processed in this application are directly derived from the original mesh data of the model and are accurately mapped to the reference plane through directional attributes without any manual relocation. The intersecting edge segmentation operation ensures that key points at contour turning points are not missed, and the internal edge filtering operation eliminates interference from internal structures. As a result, the extracted anchor point coordinates are highly consistent with the actual external contour of the model, ensuring the accuracy of anchor point positioning from both the data source and algorithm processing levels.
[0070] In some embodiments of this application, the process of converting each edge segment into a corresponding line segment in the reference plane according to the direction attribute of the plane where each edge segment is located in step S2 is described, which may specifically include:
[0071] Step S21: For each edge segment, determine the normal vector of the plane containing the edge segment. During the process of extracting edge segments face by face from the mesh data, each edge segment is associated with its corresponding model surface patch. For the currently processed edge segment, first obtain the surface normal vector of the patch containing the edge segment. During real-time calculation, select any two adjacent edge segments on the boundary of the patch, subtract the starting coordinates from the endpoint coordinates of each edge segment, and obtain two edge vectors representing the spatial extension direction of the segment. Then perform a cross product operation on the two edge vectors; the result is the plane normal vector of the patch. If an edge segment is a shared edge of two adjacent patches, the normal vector of either patch can be selected as the plane normal vector corresponding to the edge segment; alternatively, a preset rule can be used, such as selecting the normal vector of the face with the smaller angle to a preset perpendicular direction vector, to ensure consistency in projection processing. The surface normal vector can be determined either by using the surface normal vector information directly stored in the mesh data, or by calculating it in real time through the cross product of two non-collinear edge vectors on the surface boundary when needed. Thus, each edge segment obtains a normal vector representing its spatial orientation in the plane, providing a basis for determining subsequent plane orientation attributes.
[0072] Step S22: If the cross product of the normal vector and the preset vertical direction vector indicates that the two vectors are not parallel, then the plane is determined to be a non-horizontal plane. The coordinates of the two endpoints of the edge segment are multiplied by the horizontal unit vector to obtain the projected coordinates on the horizontal plane. Based on the projected coordinates, a projected line segment is constructed as the corresponding line segment in the reference plane. Specifically, the normal vector determined in step S21 is cross-multiplied with a preset vertical direction unit vector to obtain the cross-product vector. When the length of the cross-product vector is not zero, it means that the normal vector and the vertical direction vector are not parallel, thus determining that the plane where the edge segment is located is not a horizontal plane, that is, the plane has an inclined or perpendicular attitude relative to the horizontal reference plane. In this case, the edge segment needs to be projected. The coordinates of the starting endpoint and the ending endpoint of the edge segment are multiplied by two mutually orthogonal horizontal unit vectors defined in the horizontal plane to obtain two scalar coordinate values, which constitute the two-dimensional coordinates of the endpoints after projection onto the horizontal plane. By using the starting and ending projection coordinates, a projected line segment located within the horizontal reference plane can be defined. This projected line segment is the corresponding line segment of the original edge segment in the reference plane and is saved. This transformation process eliminates the spatial position differences caused by plane tilt, unifying all edge segments on non-horizontal planes to the same reference plane.
[0073] Step S23: If the cross product result indicates that the two vectors are parallel, then the plane is determined to be a horizontal plane, and the edge segment is directly retained as the corresponding line segment in the reference plane. When the length of the cross product vector calculated in step S22 is zero, it indicates that the normal vector of the plane where the edge segment is located is parallel to the preset vertical direction vector, that is, the plane itself is a horizontal plane or parallel to the horizontal reference plane. In this case, the edge segment is already located in the target reference plane, and no projection transformation is required. The system directly saves the original endpoint coordinates of the edge segment and uses them as the corresponding line segment in the reference plane. Through the above case-by-case processing, edge segments from different spatial orientations are all uniformly expressed in the same horizontal reference plane and are gathered to form an initial line segment set, ensuring the consistency of the line segment data on the geometric datum for subsequent contour extraction.
[0074] In some embodiments of this application, the process of multi-level line segment filtering in step S3 is described. The multi-level line segment filtering includes: a first, overlapping edge removal operation based on line segment collinearity; a second, intersecting edge segmentation operation based on line segment intersection relationships; and a third, internal edge filtering operation based on the inclusion relationship between line segments and surfaces. These are described below, and specifically may include:
[0075] Firstly, the overlapping edge removal operation based on line segment collinearity includes:
[0076] ① Traverse the set of line segments to be filtered and match the endpoint coordinates of each line segment;
[0077] ②If there are two line segments with the same shared endpoint, calculate the first direction vector and the second direction vector pointing from the shared endpoint to the other endpoint of the two line segments respectively;
[0078] ③ Determine the collinearity and directionality of the two line segments based on the cross product and dot product results of the first direction vector and the second direction vector;
[0079] ④ When the cross product result indicates that the two vectors are parallel and the dot product result indicates that the two vectors are in the same direction, it is determined that the two line segments are collinear and overlap in the same direction;
[0080] Keep the line segment with the longer vector magnitude of the two line segments, and remove the other line segment.
[0081] Specifically, the overlapping edge removal operation based on line segment collinearity, as part of the multi-level line segment filtering process, aims to identify and remove redundant line segments that are collinear and overlap in the same direction in the initial line segment set due to the extraction of mesh surface boundaries. This ensures that the model contour representation retains only the longest continuous line segments in each extension direction, thereby simplifying the data and avoiding boundary repetition. The specific implementation process of this operation is described below.
[0082] The process iterates through the set of line segments to be filtered, systematically matching the endpoint coordinates of each segment. This step reads the spatial coordinates of the two endpoints of each line segment and compares them with the endpoint coordinates of the other line segments to identify shared endpoints with consistent coordinate positions. Endpoint matching identifies candidate line segment pairs that may be connected or collinear, defining the comparison range for subsequent collinearity assessments.
[0083] When endpoint matching determines that two line segments share a common endpoint, this common endpoint is used as a reference starting point. Two vectors are constructed pointing from this common endpoint to the other endpoint of each line segment, denoted as the first direction vector and the second direction vector. These two direction vectors not only explicitly express the extension direction of each line segment from the common endpoint, but their vector magnitudes are also closely related to the actual length of the corresponding line segments, thus providing a geometric calculation basis for subsequent collinearity determination and length comparison.
[0084] After obtaining the first and second direction vectors, cross product and dot product operations are performed on the two vectors respectively. The collinearity and directionality of the two line segments are then comprehensively evaluated based on the results. The cross product operation produces a vector result reflecting the parallel relationship between the two vectors in space. By determining whether the cross product result is a zero vector or approximately a zero vector, it is possible to reliably determine whether the first and second direction vectors are parallel in space. The dot product operation produces a scalar result whose numerical sign reveals the cosine characteristic of the angle between the two vectors, thus indicating whether the two vectors point to the same side or opposite sides.
[0085] When the cross product indicates that the first and second direction vectors are parallel to each other, and the dot product indicates that the two vectors are in the same direction, it can be inferred that the two line segments not only lie on the same straight line, but also extend in the same direction from a shared endpoint. In this state, the two line segments exhibit a collinear and overlapping geometric relationship, where the boundary represented by the shorter line segment is completely covered by the longer line segment, creating information redundancy in the contour representation.
[0086] Based on this determination, the system further compares the magnitudes of the first and second direction vectors. The line segment corresponding to the direction vector with the larger magnitude is the longer line segment. The system retains this longer line segment as a valid contour edge, while removing the shorter line segment from the line segment set. Through this process, all collinear and overlapping redundant edges in the same direction are eliminated one by one. Finally, each line segment in the line segment set represents the longest non-repeating boundary segment in a certain direction, providing a redundant and highly concise data foundation for subsequent contour extraction.
[0087] Secondly, the intersection edge segmentation operation based on line segment intersection relationships includes:
[0088] ① Traverse the set of line segments to be filtered and combine each pair of line segments to determine whether the two line segments are parallel;
[0089] ② If the two line segments are determined to be parallel, then no division is performed;
[0090] ③ If it is determined that the two line segments are not parallel, the existence of an intersection point is determined by parametric intersection point detection. When the detection result shows that the intersection point is located on both line segments at the same time, the coordinates of the intersection point are obtained.
[0091] ④ Based on the intersection point, the two intersecting line segments are split into multiple segments respectively, and the new line segments obtained from the splitting are updated to the set of line segments to be filtered.
[0092] Specifically, the intersection edge segmentation operation based on line segment intersection relationships, as part of the multi-level line segment filtering process, aims to eliminate line segment intersections in the set of lines to be filtered, ensuring that all lines connect only at their endpoints, thereby maintaining the consistency and unambiguity of the model boundary representation at the topological level. The specific implementation process of this operation is described below.
[0093] The algorithm iterates through all pairwise line segment combinations in the set of line segments to be filtered, determining whether each pair of line segments is parallel. For the currently selected two line segments, the algorithm extracts their respective direction vectors and performs a parallelism check. It calculates the direction vectors of the two line segments, divides each direction vector by its own magnitude to obtain the unit direction vector of the corresponding line segment, and performs a cross product operation on the two unit direction vectors. If the cross product result is zero, the two line segments are considered parallel. If the detection result shows that the direction vectors of the two line segments are parallel, it indicates that these two line segments will not intersect internally in space. Therefore, there is no need to perform a segmentation operation on this line segment pair; its original shape is preserved, and the process continues with the next pair of line segments.
[0094] If the two line segments are determined to be non-parallel after testing, it indicates that these two line segments have different extension directions within their respective reference planes, and there is a potential for them to intersect. In this case, a parametric intersection detection method is used. Parametric expressions are established along the geometric extension lines of the two line segments respectively. A system of linear equations is constructed to solve for the proportional parameters t1 and t2 corresponding to the intersection point of the two lines, where t1 is the proportion of the intersection point on the first line segment, and t2 is the proportion of the intersection point on the second line segment. After obtaining the proportional parameters of this theoretical intersection point, it is further verified whether t1 and t2 are both within the range of 0 to 1. If they are not within this range, it means that the intersection point falls on the extension line of the line segment and is not a valid intersection point of the line segment body. If they are both within the range of 0 to 1, it is confirmed that the intersection point is located on both line segments simultaneously and is a valid dividing point. Then, the precise coordinate value of the intersection point is calculated based on the proportional parameters.
[0095] After determining the valid intersection point coordinates, the two intersecting line segments are segmented based on these points. For each intersecting line segment, using the intersection point as the dividing boundary, the original line segment is split into two segments: one from the original starting endpoint to the intersection point, and the other from the intersection point to the original ending endpoint, forming multiple new sub-segments. After the splitting is complete, the original two intersecting line segments are removed from the set of line segments to be filtered, and all the new line segments obtained from the splitting are added to the set to complete the set update. By traversing all pairwise line segment combinations and performing the above judgment and segmentation process, there are no longer any internally intersecting line segments in the entire set of line segments to be filtered. All line segments are connected only through their endpoints, providing line segment data with a clear topological structure for subsequent internal edge filtering operations based on line segment and surface inclusion relationships and final contour anchor point extraction.
[0096] Furthermore, the multi-level line segment filtering process also includes:
[0097] An overlapping edge removal operation based on line segment collinearity is used to perform a secondary overlapping edge removal on the set of line segments to be filtered obtained after the intersection edge segmentation operation.
[0098] After the intersection edge segmentation operation is completed, the number of line segments in the set of line segments to be filtered increases due to the splitting of the intersection segments. The multiple new sub-line segments generated by the splitting may re-establish collinear and unidirectional overlaps with other existing line segments in the set. This overlap phenomenon stems from the fact that the intersection edge segmentation operation itself is not intended to eliminate overlap, but rather to mechanically segment at the intersection point. The continuity of the segmented sub-line segments along the original line segment direction is interrupted, but the interval coverage relationship with other existing line segments in that direction has not yet been processed. If such newly generated overlaps are not cleaned up, the model contour will still have multiple partially or completely overlapping line segments in the same extension direction, causing redundancy in boundary representation and affecting the accuracy of subsequent internal edge filtering and contour anchor point extraction.
[0099] To address this, the system invokes the aforementioned overlapping edge removal operation based on line segment collinearity to perform a secondary scan and cleanup of the updated set of line segments to be filtered after intersecting edge segmentation. The execution logic of this secondary overlapping edge removal operation is consistent with the initial overlapping edge removal: it iterates through the endpoints of each line segment in the set for matching; for line segment pairs with shared endpoints, it constructs direction vectors; and uses cross product and dot product results to determine collinearity and directionality. When a line segment is determined to be collinear and overlapping in the same direction, the longer line segment is retained, and the shorter line segment is removed. This supplementary processing effectively eliminates the collinearity and overlapping redundancy introduced or exposed by intersecting segmentation, ensuring that the final contour line segment set retains only the unique, longest continuous boundary line segment in each extension direction, further improving the conciseness of the contour line segment data and the accuracy of its geometric representation.
[0100] Thirdly, the internal edge filtering operation based on the inclusion relationship between line segments and surfaces includes:
[0101] ① For each line segment to be tested in the set of line segments to be filtered, obtain all faces in the grid data;
[0102] ② For each face, determine the spatial equation of the face;
[0103] ③ For the two endpoints of the line segment to be measured, determine whether the endpoints lie on the surface based on the surface space equation;
[0104] ④ If both endpoints of the line segment to be measured are located on the same surface, construct rays from the two endpoints in any direction and count the number of intersections between each ray and the boundary of the surface.
[0105] ⑤ If the number of intersections between the two rays and the boundary of the surface is odd, the line segment to be tested is determined to be an internal edge of the surface and removed; otherwise, the line segment to be tested is retained.
[0106] Specifically, the internal edge filtering operation based on the containment relationship between line segments and faces, as part of the multi-level line segment filtering process, aims to identify and remove redundant edges from the set of line segments to be filtered that are entirely inside a certain facet of the model surface rather than forming the outer contour of the model, thereby ensuring that the final retained contour line segments truly reflect the visible outer boundary of the model. The specific implementation process of this operation is described below.
[0107] For each line segment to be tested in the set of line segments to be filtered, the system first re-acquires all face information contained in the mesh data of the target 3D model. This step includes all faces in the mesh data within the scope of consideration, serving as the spatial reference domain for determining whether each line segment constitutes an internal edge. By traversing all faces, the system ensures that each line segment to be tested undergoes complete inclusion relationship detection, avoiding the mistaken inclusion of internal edges due to missed faces.
[0108] For each face, a planar equation describing the face in space is determined based on geometric information such as vertex coordinates or normal vectors. This planar equation accurately describes the geometric position and orientation of the infinitely extending plane containing the face, providing a mathematical basis for subsequent determination of the positional relationship between points and faces. To determine whether an endpoint lies on the face, two in-plane vectors are constructed from the three non-collinear endpoints of the face. The cross product of these two vectors is then performed to obtain the plane normal vector. Next, any endpoint on the face is selected as a reference point, and the vector pointing from the reference point to the endpoint to be measured is calculated. This vector is then multiplied by the plane normal vector. If the absolute value of the dot product is less than a preset error threshold, the endpoint to be measured is determined to lie on the plane containing the face.
[0109] After obtaining the spatial equation of the current plane, for the two endpoints of the line segment to be measured, the coordinates of the endpoints are substituted into the spatial equation of the plane for verification to determine whether the endpoints lie on the plane containing the plane. If the endpoint coordinates satisfy the relationship defined by the spatial equation of the plane, it is determined that the endpoint lies on the plane containing the plane; if not, it indicates that the endpoint and the plane are not in the same plane, and the possibility of an inclusion relationship between the plane and the line segment to be measured can be ruled out, and the process can then proceed to the next plane for further evaluation.
[0110] If, after the above verification, it is determined that both endpoints of the line segment to be tested lie on the same surface, then the line segment meets the basic conditions to become an internal edge of the surface. Further determination is needed to confirm whether it is indeed located within the surface's internal region rather than on its boundary. In this case, rays are constructed from the two endpoints of the line segment along arbitrarily chosen, non-specific directions. The direction of the ray can be randomly determined or preset to be a direction that is neither parallel to nor coincides with the surface boundary, ensuring that the ray can correctly traverse the surface's internal and external regions. For each ray, the number of valid intersections with all boundaries of the surface is counted.
[0111] Based on the statistical results of the number of intersections between two rays and the surface boundary, internal edges are determined. If the number of intersections between each ray and the surface boundary is odd, then according to the parity criterion of the inclusion relationship between points and polygons, it indicates that both endpoints are located within the surface, and thus the line segment to be tested is determined to be an internal edge completely within the surface. Such internal edges do not contribute to the external visible contour of the model and are considered redundant geometric information; the system removes the line segment to be tested from the set of line segments to be filtered. Conversely, if the number of intersections between any ray and the surface boundary does not meet the odd condition (e.g., an even number of intersections or intersections falling on boundary vertices), it indicates that at least one endpoint is located on or outside the surface boundary. In this case, the line segment to be tested may be part of the contour boundary, and the system retains it. Through the above detection and filtering process, line segment by line and surface by surface, all internal edges completely contained within the surface are cleaned up, and the final set of contour line segments only contains the valid boundary information constituting the external contour of the model.
[0112] In some embodiments of this application, considering that in practical applications, the set of contour segments after the internal edge filtering operation may exhibit boundary fragmentation due to the previous intersecting edge segmentation operation, i.e., the originally continuous model contour edges are divided into multiple short segments with connected endpoints and collinearity. Although these short segments do not overlap and are all valid boundaries, excessive segmentation is not conducive to the concise representation of contour data and subsequent processing. Therefore, this application may also include a process of merging collinear connecting segments.
[0113] Following the internal edge removal operation, the following is also included:
[0114] Traverse the set of line segments to be filtered after internal edge filtering, and compare the endpoint coordinates of each line segment;
[0115] If two line segments share the same endpoint, calculate two vectors from the shared endpoint to their respective other endpoints, and determine whether the two line segments are collinear based on the cross product of the two vectors.
[0116] If the cross product indicates that the two vectors are collinear, then the two line segments are determined to be collinear.
[0117] A new line segment is constructed using the two non-shared endpoints of the two line segments, and the original two line segments are removed from the set of line segments to be filtered.
[0118] Specifically, the process iterates through the set of line segments to be filtered after internal edge filtering, comparing and matching the endpoint coordinates of each line segment in the set. By comparing the spatial positions of the endpoint coordinates, it identifies line segment pairs that share the same endpoint relationship, i.e., two line segments that connect at their endpoints and together form adjacent segments on the contour boundary. The existence of such shared endpoints is a geometric prerequisite for determining whether two line segments can be merged into a longer continuous line segment.
[0119] For a pair of line segments that share the same endpoint, construct two vectors, each starting from the shared endpoint, pointing to the other endpoint of the two line segments. The first vector points from the shared endpoint to the other endpoint of the first line segment, and the second vector points from the shared endpoint to the other endpoint of the second line segment. By performing a cross product on these two vectors, we obtain the result used to determine the parallelism between the two vectors in space. If the cross product is zero or approximately zero, it indicates that the two vectors are parallel in space, and therefore we can determine that the two line segments extend along the same straight line at the shared endpoint, i.e., the two line segments are collinear.
[0120] Once the cross product result confirms that two line segments are collinear, these two line segments are considered as mergeable continuous boundary segments. At this point, using the two non-shared endpoints of the two line segments as the starting and ending endpoints of a new line segment, a completely new line segment is constructed. This new line segment fully covers the continuous boundary interval expressed by the original two line segments, replacing the fragmented representation of two segments with a single line segment entity. After the new line segment is constructed, the original two line segments involved in the merging are removed from the set of line segments to be filtered, and the new line segment is added to the set, completing the set update. By traversing all line segment pairs and performing the above merging operation, all short line segments with connected and collinear endpoints in the set of line segments to be filtered are merged into longer continuous line segments, effectively reducing the number of contour line segments and further optimizing the geometric continuity and structural simplicity of the contour data.
[0121] In some embodiments of this application, the process of extracting the endpoint coordinates of all line segments in the contour line segment set in step S4, and generating the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates is described, which may specifically include:
[0122] Step S41: Extract the coordinates of the two endpoints of each line segment in the contour line segment set to form an endpoint coordinate set. After multi-level line segment filtering and optional merging operations, each line segment in the contour line segment set is a valid boundary segment constituting the outer contour of the model. The system traverses all line segments in the set, reads the stored start and end endpoint coordinates of each line segment, and merges these coordinate data into a unified endpoint coordinate set. This endpoint coordinate set completely records the end geometric position information of all boundary segments of the model's outer contour on the reference plane, providing the original data source for subsequent deduplication and clustering processing. Since contour line segments usually exhibit a continuous distribution characteristic of being connected end to end, adjacent line segments share the same endpoint at their junctions. Therefore, this endpoint coordinate set will inevitably contain a large number of records with completely duplicate coordinate values.
[0123] Step S42: Remove duplicate coordinate points from the endpoint coordinate set to obtain a deduplicated endpoint coordinate set. The endpoint coordinate set formed in step S41 is traversed and compared to identify duplicate records with identical coordinate values. For each set of endpoints with completely identical coordinate values, only one record is retained, and all other duplicate coordinate points are removed. After this operation, the original redundant duplicates in the endpoint coordinate set are cleared, and each geometric position corresponds to only one endpoint record. Considering the numerical precision of the grid data and the slight coordinate deviations that may be introduced during the aforementioned projection and segmentation processes, some endpoints that should coincide in actual geometric sense may still have slight gaps between their coordinate values, making it difficult to merge them solely based on completely equal coordinate comparisons. Therefore, a spatial clustering step is introduced after deduplication to achieve more complete endpoint merging at the level of location proximity.
[0124] Step S43: Spatial clustering is performed on the endpoints in the deduplicated endpoint coordinate set, and endpoints with a distance between them less than a preset distance merging threshold are grouped into the same cluster. The system sets a reasonable spatial distance merging threshold, which is used to determine whether the coordinates of two endpoints should be considered as the same position geometrically. Taking all endpoints in the deduplicated endpoint coordinate set as objects, the spatial distance between each endpoint is calculated. When the distance between any two endpoints is less than the distance merging threshold, these two endpoints are considered to correspond to the same feature vertex on the model contour geometrically, and are grouped into the same cluster. By traversing all endpoints and dividing them into clusters according to the distance relationship, the endpoints that were originally scattered due to numerical errors are aggregated into multiple clusters, and each cluster represents an independent anchor point position on the contour.
[0125] Step S44: For each cluster, the cluster center of all endpoint coordinates within the cluster is taken as the coordinates of a single contour anchor point to generate a merged contour anchor point set. After completing the endpoint clustering, for each cluster, all endpoint coordinate records contained in that cluster are obtained. The arithmetic mean of the coordinate values of all endpoints within the cluster is calculated to obtain a coordinate point located at the geometric center of each endpoint within the cluster; this point is the cluster center of the cluster. The coordinate value of this cluster center is used as the coordinates of the single contour anchor point corresponding to that cluster. Since the cluster center integrates the positional information of all endpoints within the cluster, it can effectively smooth out the numerical deviation of individual endpoints and improve the stability and representativeness of anchor point positioning. After traversing all clusters and generating corresponding contour anchor points one by one, the merged contour anchor point set is obtained. This contour anchor point set completely, uniquely, and accurately defines the external contour feature vertices of the 3D model on the reference plane, providing reliable reference point data for subsequent applications such as contour reconstruction, graphic fitting, or processing path planning.
[0126] The following describes a three-dimensional model anchor point positioning device provided in the embodiments of this application. The three-dimensional model anchor point positioning device described below and the three-dimensional model anchor point positioning method described above can be referred to in correspondence.
[0127] See Figure 2 , Figure 2 This is a schematic diagram of a three-dimensional model anchor point positioning device disclosed in an embodiment of this application.
[0128] like Figure 2 As shown, the three-dimensional model anchor point positioning device is used to perform the three-dimensional model anchor point positioning method as described in any of the above claims, and may include:
[0129] Mesh data module 110 is used to acquire mesh data of the target 3D model, wherein the mesh data includes multiple faces constituting the model and edge information of each face;
[0130] The line segment extraction module 120 is used to extract the edge line segments constituting the surface of the model based on the grid data, and convert each edge line segment into a corresponding line segment in the reference plane according to the direction attribute of the plane where each edge line segment is located, forming an initial line segment set.
[0131] The multi-level filtering module 130 is used to perform multi-level line segment filtering on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, thereby obtaining a contour line segment set. The multi-level line segment filtering includes overlapping edge removal based on line segment collinearity, intersecting edge segmentation based on line segment intersection relationship, and internal edge filtering based on the inclusion relationship between line segment and surface.
[0132] The contour anchor point module 140 is used to extract the endpoint coordinates of all line segments in the contour line segment set, and generate the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
[0133] As can be seen from the above technical solutions, the present application provides a three-dimensional model anchor point positioning method, apparatus, and readable storage medium, including: acquiring mesh data of a target three-dimensional model, the mesh data containing multiple faces constituting the model and edge information of each face; extracting edge segments constituting the surface of the model based on the mesh data, and converting them into corresponding line segments in a reference plane according to the direction attribute of the plane where each edge segment is located, forming an initial line segment set; performing multi-level line segment filtering processing on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, the multi-level line segment filtering processing including overlapping edge removal operation based on line segment collinearity, intersecting edge segmentation operation based on line segment intersection relationship, and internal edge filtering operation based on the inclusion relationship between line segments and faces; extracting the endpoint coordinates of all line segments in the contour line segment set, and generating the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
[0134] First, this application automatically performs edge segment extraction, reference plane mapping, multi-level filtering, and endpoint deduplication by reading mesh data, eliminating the need for manual intervention in the entire process from the original model to anchor point generation. This eliminates repetitive manual creation and fine-tuning operations, significantly improving anchor point generation efficiency, especially suitable for batch model processing scenarios. Second, in the multi-level segment filtering process, the overlapping edge removal operation eliminates redundant edges based on the collinearity of line segments, the intersecting edge segmentation operation accurately segments at intersections based on the intersection relationship of line segments, and the internal edge removal operation removes invisible edges inside the model based on the inclusion relationship between line segments and faces. This ensures that the final set of retained contour segments strictly corresponds to the external contour of the model, without relying on the operator's subjective judgment, thus enabling the output of standardized anchor point results for the same model. Furthermore, the edge segments processed in this application are directly derived from the original mesh data of the model and are accurately mapped to the reference plane through directional attributes without any manual relocation. The intersecting edge segmentation operation ensures that key points at contour turning points are not missed, and the internal edge filtering operation eliminates interference from internal structures. As a result, the extracted anchor point coordinates are highly consistent with the actual external contour of the model, ensuring the accuracy of anchor point positioning from both the data source and algorithm processing levels.
[0135] Optionally, the step of converting each edge segment into a corresponding line segment in the reference plane based on the orientation attribute of the plane containing each edge segment includes:
[0136] For each edge segment, determine the normal vector of the plane containing the edge segment;
[0137] If the cross product of the normal vector and the preset vertical direction vector indicates that the two vectors are not parallel, then the plane is determined to be a non-horizontal plane. The coordinates of the two endpoints of the edge segment are multiplied by the horizontal unit vector to obtain the projected coordinates on the horizontal plane. Based on the projected coordinates, a projected line segment is constructed as the corresponding line segment in the reference plane.
[0138] If the cross product result indicates that the two vectors are parallel, then the plane is determined to be a horizontal plane, and the edge segment is directly retained as the corresponding line segment in the reference plane.
[0139] Optionally, the overlapping edge removal operation based on line segment collinearity includes:
[0140] Iterate through the set of line segments to be filtered and match the endpoint coordinates of each line segment;
[0141] If two line segments have the same shared endpoint, calculate the first direction vector and the second direction vector pointing from the shared endpoint to the other endpoint of the two line segments, respectively.
[0142] Based on the cross product and dot product of the first direction vector and the second direction vector, determine the collinearity and directionality of the two line segments;
[0143] When the cross product result indicates that the two vectors are parallel and the dot product result indicates that the two vectors are in the same direction, it is determined that the two line segments are collinear and overlap in the same direction.
[0144] Keep the line segment with the longer vector magnitude of the two line segments, and remove the other line segment.
[0145] Optionally, the intersection edge segmentation operation based on line segment intersection relationships includes:
[0146] Iterate through the set of line segments to be filtered and combine each pair of line segments to determine whether the two line segments are parallel.
[0147] If the two line segments are determined to be parallel, then no division is performed;
[0148] If it is determined that the two line segments are not parallel, the existence of an intersection point is determined by parametric intersection point detection. When the detection result shows that the intersection point is located on both line segments at the same time, the coordinates of the intersection point are obtained.
[0149] Based on the intersection point, the two intersecting line segments are split into multiple segments, and the new line segments obtained from the splitting are used to update the set of line segments to be filtered.
[0150] Optionally, the multi-level line segment filtering process further includes:
[0151] An overlapping edge removal operation based on line segment collinearity is used to perform a secondary overlapping edge removal on the set of line segments to be filtered obtained after the intersection edge segmentation operation.
[0152] Optionally, the internal edge filtering operation based on the inclusion relationship between line segments and surfaces includes:
[0153] For each line segment to be tested in the set of line segments to be filtered, obtain all faces in the grid data;
[0154] For each face, determine the spatial equation of the face;
[0155] For the two endpoints of the line segment to be tested, determine whether the endpoints lie on the surface based on the surface space equation;
[0156] If both endpoints of the line segment to be measured are located on the same surface, then construct rays from the two endpoints in any direction and count the number of intersections between each ray and the boundary of the surface.
[0157] If the number of intersections between the two rays and the boundary of the surface is odd, the line segment to be tested is determined to be an internal edge of the surface and is removed; otherwise, the line segment to be tested is retained.
[0158] Optionally, after the internal edge filtering operation, the following steps are also included:
[0159] Traverse the set of line segments to be filtered after internal edge filtering, and compare the endpoint coordinates of each line segment;
[0160] If two line segments share the same endpoint, calculate two vectors from the shared endpoint to their respective other endpoints, and determine whether the two line segments are collinear based on the cross product of the two vectors.
[0161] If the cross product indicates that the two vectors are collinear, then the two line segments are determined to be collinear.
[0162] A new line segment is constructed using the two non-shared endpoints of the two line segments, and the original two line segments are removed from the set of line segments to be filtered.
[0163] Optionally, the step of extracting the endpoint coordinates of all line segments in the contour line segment set, and generating the contour anchor points of the 3D model after deduplicating the endpoint coordinates includes:
[0164] Extract the coordinates of the two endpoints of each line segment in the contour line segment set to form an endpoint coordinate set;
[0165] Remove duplicate coordinate points from the endpoint coordinate set to obtain the deduplicated endpoint coordinate set;
[0166] Spatial clustering is performed on the endpoints in the deduplicated endpoint coordinate set, and endpoints whose mutual distance is less than a preset distance merging threshold are divided into the same cluster.
[0167] For each cluster, the cluster center of all endpoint coordinates within the cluster is taken as the coordinates of a single contour anchor point to generate a merged set of contour anchor points.
[0168] This application embodiment also provides a readable storage medium that can store a program suitable for execution by a processor, the program being used for:
[0169] Obtain the mesh data of the target 3D model, wherein the mesh data includes multiple faces that constitute the model and edge information of each face;
[0170] Based on the grid data, the edge segments constituting the model surface are extracted, and each edge segment is converted into a corresponding line segment in the reference plane according to the direction attribute of the plane where each edge segment is located, forming an initial line segment set.
[0171] A multi-level line segment filtering process is performed on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, resulting in a contour line segment set. The multi-level line segment filtering process includes overlapping edge removal based on line segment collinearity, intersecting edge segmentation based on line segment intersection relationship, and internal edge filtering based on the inclusion relationship between line segment and surface.
[0172] Extract the endpoint coordinates of all line segments in the contour line segment set, and generate the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
[0173] Optionally, the refined and extended functions of the program can be referred to the above description.
[0174] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0175] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.
[0176] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for anchor point positioning of a three-dimensional model, characterized in that, include: Obtain the mesh data of the target 3D model, wherein the mesh data includes multiple faces that constitute the model and edge information of each face; Based on the grid data, the edge segments constituting the model surface are extracted, and each edge segment is converted into a corresponding line segment in the reference plane according to the direction attribute of the plane where each edge segment is located, forming an initial line segment set. A multi-level line segment filtering process is performed on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, resulting in a contour line segment set. The multi-level line segment filtering process includes overlapping edge removal based on line segment collinearity, intersecting edge segmentation based on line segment intersection relationship, and internal edge filtering based on the inclusion relationship between line segment and surface. Extract the endpoint coordinates of all line segments in the contour line segment set, and generate the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
2. The method according to claim 1, characterized in that, The step of converting each edge segment into a corresponding line segment in the reference plane based on the orientation attribute of the plane containing each edge segment includes: For each edge segment, determine the normal vector of the plane containing the edge segment; If the cross product of the normal vector and the preset vertical direction vector indicates that the two vectors are not parallel, then the plane is determined to be a non-horizontal plane. The coordinates of the two endpoints of the edge segment are multiplied by the horizontal unit vector to obtain the projected coordinates on the horizontal plane. Based on the projected coordinates, a projected line segment is constructed as the corresponding line segment in the reference plane. If the cross product result indicates that the two vectors are parallel, then the plane is determined to be a horizontal plane, and the edge segment is directly retained as the corresponding line segment in the reference plane.
3. The method according to claim 1, characterized in that, The overlapping edge removal operation based on line segment collinearity includes: Iterate through the set of line segments to be filtered and match the endpoint coordinates of each line segment; If two line segments have the same shared endpoint, calculate the first direction vector and the second direction vector pointing from the shared endpoint to the other endpoint of the two line segments, respectively. Based on the cross product and dot product of the first direction vector and the second direction vector, determine the collinearity and directionality of the two line segments; When the cross product result indicates that the two vectors are parallel and the dot product result indicates that the two vectors are in the same direction, it is determined that the two line segments are collinear and overlap in the same direction. Keep the line segment with the longer vector magnitude of the two line segments, and remove the other line segment.
4. The method according to claim 1, characterized in that, The intersection edge segmentation operation based on line segment intersection relationships includes: Iterate through the set of line segments to be filtered and combine each pair of line segments to determine whether the two line segments are parallel. If the two line segments are determined to be parallel, then no division is performed; If it is determined that the two line segments are not parallel, the existence of an intersection point is determined by parametric intersection point detection. When the detection result shows that the intersection point is located on both line segments at the same time, the coordinates of the intersection point are obtained. Based on the intersection point, the two intersecting line segments are split into multiple segments, and the new line segments obtained from the splitting are used to update the set of line segments to be filtered.
5. The method according to claim 1 or 4, characterized in that, The multi-level line segment filtering process also includes: An overlapping edge removal operation based on line segment collinearity is used to perform a secondary overlapping edge removal on the set of line segments to be filtered obtained after the intersection edge segmentation operation.
6. The method according to claim 1, characterized in that, The internal edge filtering operation based on the inclusion relationship between line segments and surfaces includes: For each line segment to be tested in the set of line segments to be filtered, obtain all faces in the grid data; For each face, determine the spatial equation of the face; For the two endpoints of the line segment to be tested, determine whether the endpoints lie on the surface based on the surface space equation; If both endpoints of the line segment to be measured are located on the same surface, then construct rays from the two endpoints in any direction and count the number of intersections between each ray and the boundary of the surface. If the number of intersections between the two rays and the boundary of the surface is odd, the line segment to be tested is determined to be an internal edge of the surface and is removed; otherwise, the line segment to be tested is retained.
7. The method according to claim 1, characterized in that, Following the internal edge removal operation, the following is also included: Traverse the set of line segments to be filtered after internal edge filtering, and compare the endpoint coordinates of each line segment; If two line segments share the same endpoint, calculate two vectors from the shared endpoint to their respective other endpoints, and determine whether the two line segments are collinear based on the cross product of the two vectors. If the cross product indicates that the two vectors are collinear, then the two line segments are determined to be collinear. A new line segment is constructed using the two non-shared endpoints of the two line segments, and the original two line segments are removed from the set of line segments to be filtered.
8. The method according to claim 1, characterized in that, The step of extracting the endpoint coordinates of all line segments in the contour line segment set, and generating the contour anchor points of the 3D model after deduplicating the endpoint coordinates includes: Extract the coordinates of the two endpoints of each line segment in the contour line segment set to form an endpoint coordinate set; Remove duplicate coordinate points from the endpoint coordinate set to obtain the deduplicated endpoint coordinate set; Spatial clustering is performed on the endpoints in the deduplicated endpoint coordinate set, and endpoints whose mutual distance is less than a preset distance merging threshold are divided into the same cluster. For each cluster, the cluster center of all endpoint coordinates within the cluster is taken as the coordinates of a single contour anchor point to generate a merged set of contour anchor points.
9. A three-dimensional model anchor point positioning device, characterized in that, A method for performing the three-dimensional model anchor point positioning method as described in any one of claims 1-8, comprising: The mesh data module is used to acquire the mesh data of the target 3D model. The mesh data includes multiple faces that make up the model and the edge information of each face. The line segment extraction module is used to extract the edge line segments that constitute the surface of the model based on the grid data, and convert each edge line segment into a corresponding line segment in the reference plane according to the direction attribute of the plane where each edge line segment is located, forming an initial line segment set. A multi-level filtering module is used to perform multi-level line segment filtering on the initial line segment set to remove redundant line segments that do not represent the external contour of the model, thereby obtaining a contour line segment set. The multi-level line segment filtering includes overlapping edge removal based on line segment collinearity, intersecting edge segmentation based on line segment intersection relationship, and internal edge filtering based on the inclusion relationship between line segment and surface. The contour anchor point module is used to extract the endpoint coordinates of all line segments in the contour line segment set, and generate the contour anchor points of the three-dimensional model after deduplicating the endpoint coordinates.
10. A readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements each step of the three-dimensional model anchor point positioning method as described in any one of claims 1-8.
