A machining feature recognition method based on a double-layer graph neural network

By constructing a two-layer graph neural network and combining a triangular mesh model with node attention coefficient calculation, the problems of low efficiency and unbalanced information transmission in existing technologies for mechanical processing feature recognition are solved, achieving efficient and accurate processing feature recognition.

CN117197801BActive Publication Date: 2025-10-24HUAZHONG UNIV OF SCI & TECH
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202311242524.7
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-09-25
Publication Date
2025-10-24
Estimated Expiration
2043-09-25

AI Technical Summary

Technical Problem

Existing technologies rely on expert knowledge rules for feature recognition in machining, which is inefficient and difficult to adapt to complex scenarios. Furthermore, neural network-based methods suffer from uneven information transmission and failure to consider node structure information when processing 3D models.

Method used

A method based on a two-layer graph neural network is adopted. By constructing a two-layer graph structure dataset and combining a triangular mesh model and node attention coefficient calculation, the information transmission module is improved to enhance recognition accuracy and efficiency.

Benefits of technology

It achieves efficient processing feature recognition without requiring a large amount of expert knowledge rules, and can accurately identify small features in complex 3D models, improving recognition accuracy and computational efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117197801B_ABST
    Figure CN117197801B_ABST
Patent Text Reader

Abstract

The application provides a machining feature recognition method based on a double-layer graph neural network, comprising the following steps: obtaining a part model and analyzing and constructing an initial adjacency graph of the part model; calculating corresponding first face feature tensors and first edge feature tensors for the faces and edges of the part model to obtain a first adjacency graph; triangulating the part model, analyzing the triangulated part model, calculating the geometric information and topological information of each triangular face, and obtaining a second adjacency graph; combining the first adjacency graph and the second adjacency graph to obtain a double-layer graph structure dataset; constructing a double-layer graph neural network model, iteratively training the double-layer graph neural network model by using the double-layer graph structure dataset; obtaining a part model to be detected, inputting the part model to be detected into the trained double-layer graph neural network model, and obtaining part machining features for visual display. The application ensures the recognition accuracy, ensures that the parameter quantity is as small as possible, and improves the efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The application belongs to the technical field of computer-aided process planning, and particularly relates to a machining feature recognition method based on a double-layer graph neural network. BACKGROUND

[0002] Machining feature recognition is an important task in manufacturing, which involves identifying and extracting key geometric, topological and surface features from the data of workpiece surfaces. Feature recognition can help manufacturing enterprises reduce costs, improve quality and production efficiency.

[0003] After nearly four decades of development, researchers have proposed a variety of machining feature recognition methods, which can be broadly divided into rule-based methods and learning-based methods.

[0004] In rule-based methods, rules are manually designed by researchers for machining feature recognition according to experience and knowledge. Although this method was proposed early, few people have conducted in-depth research, mainly because of several difficult problems: it relies on a large number of expert knowledge rules and programming, the rule definition method is not unique; it requires a large number of matches and is low in efficiency; it is difficult to adapt to complex scenarios and cannot recognize intersecting features.

[0005] In addition to rule-based methods, experts have also used artificial neural networks to study machining feature recognition problems. Neural network-based machining feature recognition methods need to first solve how to input the part model to the network. One method is to preprocess the B-rep model and convert it into a point cloud, voxel, triangular mesh, image or other format suitable for network reading. Each type of conversion has its own limitations. The voxel-based method has a significant disadvantage, which is that as the voxel resolution increases, the memory and computing overhead grow cubically. This means that most voxel methods are limited in resolution. Since the resolution of voxel representation is limited, it is difficult to represent large-scale 3D shapes containing small features. Point cloud-based conversion requires uniform sampling of a large number of points from the model surface. Some small features may not be adequately sampled, and the sampled data contains a lot of noise, which can lead to recognition errors. Since the Boundary representation (B-Rep) model is the standard way to describe 3D shapes in CAD applications, it is not efficient to directly perform feature recognition on triangular mesh models rather than on B-Rep models.

[0006] Chinese patent CN 114491841 A discloses a processing feature recognition method based on NX secondary development and graph neural network. The method constructs an attribute adjacency graph of a B-Rep part model in NX secondary development and uses the graph as input of a graph neural network for processing feature recognition. When calculating the feature tensor of the B-Rep surface, the invention calculates the coordinate values of the sampling points on the surface, the normal vector on the surface, and the surface type by setting the sampling points. While calculating the normal vector on the surface, it also means that the invention cannot recognize processing features composed of curved surfaces. Processing parts are mainly divided into four categories of features: groove features, hole features, step features, and transition features, which contain various feature types with curved surfaces. Therefore, this coding method makes the invention not robust enough.

[0007] In addition, the one-dimensional convolution operation of the edge and the two-dimensional convolution operation of the surface are used in the graph neural network model of the patent. Graph neural networks are usually used to process non-grid structured data, such as graph data, node data, or irregular data structures, rather than traditional image data. Although theoretically, planar convolution operations can be used, there may be the following disadvantages:

[0008] Lack of natural grid structure: Convolution operations assume that input data has a fixed grid structure, such as images. However, in graph data, the connections between nodes are irregular and not easily handled by planar convolution kernels. This can result in the convolution kernel failing to fully capture the structural information in the graph data.

[0009] Invariance and equivariance problems: Planar convolution operations in graph neural networks can cause invariance and equivariance problems. In graph data, the positions and connections of nodes usually have no obvious equivariance, so planar convolution may not be able to handle this case.

[0010] Finally, in the information transmission module of the invention, there is a problem of local message transmission because it simply adds connected nodes and maps them to edges and then aggregates them from edges to nodes. Some nodes have very high degrees in the graph, which means that the node may have received a lot of its own information repeatedly, while the information of its neighbors is diluted. This can cause information transmission imbalance, and the model is more likely to focus on highly connected nodes while ignoring nodes with lower degrees, resulting in inaccurate representation of learned nodes. Moreover, many MLP operations are used without considering the structural information of neighbor nodes. SUMMARY

[0011] Therefore, the machining feature recognition method based on the double-layer graph neural network is provided, which does not rely on a large number of expert knowledge rules and programming, reduces the consumption of manpower, ensures the recognition accuracy, and ensures that the parameter quantity is as small as possible to improve the efficiency. Meanwhile, a double-layer graph data structure is generated to represent the CAD model, so as to solve the problem that the resolution of the small machining feature is low and lost when the three-dimensional model is input into the network as a point cloud. Finally, the information transmission module is improved to solve the problems of unbalanced information transmission and not considering the node structure information, and the performance of the model calculation is improved.

[0012] The technical purpose of the present application is achieved as follows:

[0013] The present application provides a machining feature recognition method based on a double-layer graph neural network, comprising:

[0014] S1 obtains a part model, parses the part model under the B-Rep representation method, obtains a face set and an edge set of the part model;

[0015] S2 traverses the face set and the edge set of the part model, calculates face objects and edge objects, face attributes and edge attributes, assigns the face attributes as feature values to the face objects, assigns the edge attributes as feature values to the edge objects, generates an initial adjacency graph based on the face objects and the edge objects, assigns the feature values of the face objects as first face feature tensors, assigns the feature values of the edge objects as first edge feature tensors, adds the first face feature tensors and the first edge feature tensors as attributes to the nodes and the connecting edges of the initial adjacency graph, and obtains a first adjacency graph;

[0016] S3 triangulates the part model, parses the part model after triangulation, obtains a triangular face set and a triangular edge set, traverses the triangular face set and the triangular edge set, calculates triangular face objects and triangular edge objects, triangular face attributes and triangular edge attributes, assigns the triangular face attributes as feature values to the triangular face objects, assigns the triangular edge attributes as feature values to the triangular edge objects, constructs an initial second adjacency graph based on the triangular face objects and the triangular edge objects, assigns the feature values of the triangular face objects as second face feature tensors, assigns the feature values of the triangular edge objects as second edge feature tensors, adds the second face feature tensors and the second edge feature tensors as attributes to the nodes and the connecting edges of the initial second adjacency graph, and obtains a second adjacency graph;

[0017] S4 combines the first adjacency graph and the second adjacency graph to construct a double-layer graph structure data set;

[0018] S5 constructs a double-layer graph neural network model, iteratively trains the double-layer graph neural network model by using the double-layer graph structure data set until the model requirements are met, and obtains a trained double-layer graph neural network model;

[0019] S6acquire a part model to be detected, input the part model to be detected into the trained double-layer graph neural network model, obtain part processing features, and visualize the part processing features.

[0020] Based on the above technical solution, preferably, step S1 comprises:

[0021] S21sets a face identifier of a face, traverses each face in a face set, calculates and obtains a face attribute of each face, instantiates a face object, generates a hash value of the face object according to the face identifier, and assigns the face attribute as a feature value to the face object, and stores the face object, the hash value of the face object and the feature value of the face object into a face dictionary;

[0022] S22sets an edge identifier of an edge, traverses each edge in an edge set, calculates and obtains an edge attribute of each edge, instantiates an edge object, generates a hash value of the edge object according to the edge identifier, and assigns the edge attribute as a feature value to the edge object, and stores the edge object, the hash value of the edge object and the feature value of the edge object into an edge dictionary;

[0023] S23traverses the face dictionary and the edge dictionary, constructs an initial adjacency graph according to the adjacency relationship of the face object and the edge object, the adjacency graph is composed of nodes and connecting edges, each node corresponds to a face object, and each connecting edge corresponds to an edge object;

[0024] S24composes a first face feature tensor by using the feature values of the face object, composes a first edge feature tensor by using the feature values of the edge object, and adds the first face feature tensor and the first edge feature tensor as attributes to the nodes and the connecting edges of the initial adjacency graph respectively, to obtain a first adjacency graph.

[0025] Based on the above technical solution, preferably, the face attribute comprises a type of the face, an area of the face, vertices of the face and a midpoint of the face, and the calculation and obtaining process of the face attribute is as follows:

[0026] The type of each face is obtained by using a BRepAdaptor_Surface() function, the area of each face is obtained by using brepgprop_SurfaceProperties, the vertices of each face are obtained by using GProp_GProps(), and the midpoint of each face is obtained by using a mass_props.CentreOfMass() function;

[0027] Correspondingly, the edge attribute comprises a type of the edge and concave-convex property, and the calculation and obtaining process of the edge attribute is as follows:

[0028] The two faces adjacent to an edge are obtained by using topo.faces_from_edge(), the midpoint coordinate P of the edge and the tangent vector V of the midpoint and the edge are calculated, the normal vectors n1 and n2 of the two faces are calculated by using a GeomLProp_SLProps() function.

[0029] The cross product n3 of n1, n2 is calculated, and the dot product r of n3 and the tangent vector V is calculated;

[0030] If r>0, the corresponding edge is a convex edge;

[0031] If r<0, the corresponding edge is a concave edge;

[0032] If r=0, the corresponding edge is defined as an other type edge.

[0033] On the basis of the above technical solution, preferably, the step S3 comprises:

[0034] S31 triangulates the part model to generate a series of triangular faces;

[0035] S32 traverses each triangular face, obtains the coordinates of the three vertices of the triangular face, and calculates the normal vector and the centroid coordinates of the triangular face to make the triangular face attribute;

[0036] S33 calculates the constant coefficient d of the plane equation of each triangular face, and records the hash value of the B-Rep face to which the triangular face belongs;

[0037] S34 instantiates each triangular face according to the triangular face attribute and the hash value of the B-Rep face to which the triangular face belongs to obtain the hash value of the triangular face object, and assigns the triangular face attribute as the feature value to the triangular face object, and stores the triangular face object and its hash value and feature value in the triangular face dictionary;

[0038] S35 traverses the triangular edges of the triangulated part model, records the hash values of the two adjacent triangular faces of each triangular edge, instantiates each triangular edge according to the hash values of the two adjacent triangular faces to obtain the hash value of the triangular edge object, and assigns the triangular edge attribute as the feature value to the triangular edge object, and stores the triangular edge object and its hash value and feature value in the triangular edge dictionary;

[0039] S36 traverses the triangular face dictionary and the triangular edge dictionary, and constructs an initial second adjacency graph according to the adjacency relationship of the triangular face object and the triangular edge object;

[0040] S37 groups the feature values of the triangular face object into a second face feature tensor, groups the feature values of the triangular edge object into a second edge feature tensor, and adds the second face feature tensor and the second edge feature tensor as attributes to the nodes and connecting edges of the initial second adjacency graph respectively to obtain the second adjacency graph.

[0041] On the basis of the above technical solution, preferably, the step S4 comprises:

[0042] According to the correlation between the faces of the part model in the B-Rep representation and the triangular faces of the part model in the triangular mesh, node linking is performed on the first adjacency graph and the second adjacency graph to generate a double-layer graph structure dataset.

[0043] On the basis of the above technical scheme, preferably, the step S5 comprises:

[0044] S51, a double-layer graph neural network model is constructed, and the structure of the double-layer graph neural network model comprises a node embedding module, a graph-level conversion module, a message passing module and a node classification module;

[0045] S52, the double-layer graph structure dataset is segmented to obtain a training set and a validation set, wherein each sample data in the double-layer graph structure dataset comprises a B-Rep data level and a triangular mesh data level;

[0046] S53, training parameters are set, the training set is input into the double-layer graph neural network model for iterative training, the dimension of the node feature matrix of the training set is expanded according to the node embedding module, the node feature matrices of the two data levels are aggregated and converted according to the graph-level conversion module to obtain a feature aggregation result, the structural similarity and the content similarity between nodes are calculated based on the feature aggregation result by using the message passing module, the vector representation of the nodes is updated according to the attention coefficient, the updated nodes are classified based on the node classification module, and the iteration ends until the model requirements are met, and a trained double-layer graph neural network model is obtained;

[0047] Wherein, after each iteration, the negative log-likelihood loss and the accuracy rate of feature recognition are calculated by using the validation set, and the network weight parameter with the maximum accuracy rate is saved to a weight file.

[0048] On the basis of the above technical scheme, preferably, the dimension expansion of the node feature matrix of the training set according to the node embedding module comprises:

[0049] The node feature matrix of the training set is extracted, and a learnable parameter matrix G is defined;

[0050] The node feature matrix is multiplied by the learnable parameter matrix G to expand the dimension of the node feature matrix;

[0051] The expanded node feature matrix is subjected to a nonlinear transformation, and a F.dropout(x, p) function is used to realize a random inactivation operation, wherein x is the expanded node feature input, and p is the inactivation probability.

[0052] On the basis of the above technical scheme, preferably, the aggregation and conversion of the node feature matrices of the two data levels according to the graph-level conversion module to obtain the feature aggregation result comprises:

[0053] Define a trainable matrix W, map the node feature matrix X_brep of the B-Rep data hierarchy to the node feature matrix X_facet of the triangular mesh data hierarchy using the trainable matrix W, or map X_facet to X_brep using the trainable matrix W;

[0054] Multiply the node feature matrix X_brep of the B-Rep data hierarchy by the trainable matrix W to obtain the mapped first feature matrix X1_mapped=X_brep*W;

[0055] Or multiply the node feature matrix X_facet of the triangular mesh data hierarchy by the transpose of the trainable matrix W to obtain the mapped second feature matrix X2_mapped=X_facet*W T ;

[0056] Add the first feature matrix or the second feature matrix to the node feature matrix of the corresponding hierarchy to obtain the feature aggregation result.

[0057] On the basis of the above technical solutions, preferably, the message passing module is used to calculate the structural similarity and the content similarity between nodes based on the feature aggregation result, and the vector representation of the node is updated according to the attention coefficient, including:

[0058] Step one, for a given node i, calculate the structured fingerprint F i of i, denoted as F i =(V (i) ,w (i) ), V (i) is a set of neighbor nodes of the local receiving domain around node i, and w (i) is the contribution weight of the corresponding neighbor node;

[0059] Step two, for a single node j in the neighbor node set, calculate the structural similarity between node j and the center node i to obtain the structural similarity coefficient s ij ;

[0060] Step three, calculate the content similarity between node j and the center node i to obtain the content similarity coefficient e ij ;

[0061] Step four, normalize the structural similarity coefficient s ij and the content similarity coefficient e ij to obtain the normalized structural similarity coefficient s' ij and the normalized content similarity coefficient e' ij , and the normalization formula is as follows:

[0062] s' ij =exp(s ij ;) / ∑exp(s ik )

[0063] e' ij =exp(LeakyRelu(e ij )) / ∑exp(LeakyRelu(e ik ))

[0064] where LeakyRelu is the activation function, s ik and e ik represent the structural similarity coefficient and content similarity coefficient between all nodes in the neighbor node set and the center node i, respectively;

[0065] Step five, according to the normalized structural similarity coefficient s' ij and the normalized content similarity coefficient e' ij , the attention coefficient a ij between node j and the center node i is calculated;

[0066] Step six, based on the attention coefficient a ij , the target node representation at t+1 time is obtained by weighted summation of the neighbor node representation at t time:

[0067]

[0068] where, represents the influence of node j on the center node i, is the hidden state vector of node j at t time, A is the weight matrix, Σ represents summation over all neighbor nodes, and σ represents the sigmoid function, is the hidden state vector of node i at t+1 time;

[0069] Step seven, repeat steps five and six to perform multiple rounds of information transmission and node representation update until convergence or a specified number of iterations is reached, and output the updated node vector representation.

[0070] On the basis of the above technical scheme, preferably, the calculation formula of the structural similarity coefficient s ij is:

[0071] s ij =A str (F i ,F j )

[0072]

[0073] where a and b represent the sets F i and F jwherein the elements are represented by w(a) and w(b) respectively, and the summation operation is represented by ∑;

[0074] content similarity coefficient e ij The calculation formula is as follows:

[0075] e ij = δ ([QE i ][QE j ])

[0076] wherein δ is a nonlinear activation function, Q is a linear mapping matrix, E j and E j represent the original features of nodes i and j respectively;

[0077] The calculation formula of the attention coefficient a ij is as follows:

[0078]

[0079] wherein σ is a sigmoid function, and are the average values of the content similarity coefficient and the structure similarity coefficient respectively.

[0080] The method of the present application has the following beneficial effects relative to the prior art:

[0081] (1) The present application adopts a triangular mesh model and encodes each triangular facet, and the encoding content is the plane equation coefficient of each triangular facet. Then, through the aggregation of the connected node features between the double-layer graph structure levels, the information that the B-Rep surface features contain more geometric features is realized, and the problem that the model surface, especially the curved surface geometry, cannot be represented is solved;

[0082] (2) The present application adopts the calculation of the attention coefficient between nodes, which allows the network to dynamically allocate the attention weight between different nodes. This means that the network can focus on the nodes related to a specific task, improving the performance and generalization ability;

[0083] (3) The present application introduces a structured fingerprint concept, defines and quantifies the structure information of nodes, realizes the full exploration of the details of the graph topology in GAT, solves the problem of insufficient mining of graph structure details and over-smoothing in traditional GAT, greatly reduces the use of MLP, reduces the network parameter quantity, and improves the calculation efficiency. BRIEF DESCRIPTION OF DRAWINGS

[0084] In order to make the technical solutions in the embodiments of the present application or the prior art clearer, the accompanying drawings needed in the embodiments or prior art description will be briefly introduced. Obviously, the accompanying drawings in the following description only aim to some embodiments of the present application, and other drawings can be obtained by those of ordinary skill in the art without any creative effort.

[0085] Figure 1 A method flowchart of the embodiments of the present application;

[0086] Figure 2 A technical implementation diagram of the embodiments of the present application;

[0087] Figure 3 A machining feature schematic diagram of the embodiments of the present application;

[0088] Figure 4 A part model schematic diagram under B-Rep representation of the embodiments of the present application;

[0089] Figure 5 A first adjacency graph schematic diagram of the embodiments of the present application;

[0090] Figure 6 A triangular meshed part model schematic diagram of the embodiments of the present application;

[0091] Figure 7 A second adjacency graph schematic diagram of the embodiments of the present application;

[0092] Figure 8 A part of double-layer graph structure schematic diagram of the embodiments of the present application;

[0093] Figure 9 A double-layer graph neural network model structure schematic diagram of the embodiments of the present application. DETAILED DESCRIPTION

[0094] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments of the present application, all other embodiments obtained by those of ordinary skill in the art without any creative effort belong to the scope of protection of the present application.

[0095] As shown in the drawings, Figure 1 The present application provides a machining feature recognition method based on double-layer graph neural network, comprising:

[0096] S1, obtaining a part model, analyzing the part model under B-Rep representation to obtain a face set and an edge set of the part model;

[0097] S2 traverses the face set and the edge set of the part model, calculates to obtain the face object and the edge object, the face attribute and the edge attribute, assigns the face attribute as a characteristic value to the face object, assigns the edge attribute as a characteristic value to the edge object, generates an initial adjacency graph based on the face object and the edge object, takes the characteristic value of the face object as a first face feature tensor, takes the characteristic value of the edge object as a first edge feature tensor, adds the first face feature tensor and the first edge feature tensor as attributes to the nodes and the connecting edges of the initial adjacency graph, and obtains a first adjacency graph;

[0098] S3 triangulates the part model, analyzes the part model after triangulation, obtains a triangular face set and a triangular edge set, traverses the triangular face set and the triangular edge set, calculates to obtain a triangular face object and a triangular edge object, a triangular face attribute and a triangular edge attribute, assigns the triangular face attribute as a characteristic value to the triangular face object, assigns the triangular edge attribute as a characteristic value to the triangular edge object, constructs an initial second adjacency graph based on the triangular face object and the triangular edge object, takes the characteristic value of the triangular face object as a second face feature tensor, takes the characteristic value of the triangular edge object as a second edge feature tensor, adds the second face feature tensor and the second edge feature tensor as attributes to the nodes and the connecting edges of the initial second adjacency graph, and obtains a second adjacency graph;

[0099] S4 combines the first adjacency graph and the second adjacency graph, and constructs a double-layer graph structure dataset;

[0100] S5 constructs a double-layer graph neural network model, iteratively trains the double-layer graph neural network model by using the double-layer graph structure dataset until a model requirement is reached, and obtains a trained double-layer graph neural network model;

[0101] S6 obtains a part model to be detected, inputs the part model to be detected into the trained double-layer graph neural network model, obtains part machining features, and visually displays the part machining features.

[0102] Please refer to Figure 2The technical implementation process of the present application is specifically: 1) obtaining a part model, dividing into two processing routes to obtain a first adjacency graph and a second adjacency graph; 2) the first processing route: analyzing the part model under the B-Rep representation method, obtaining the face set and edge set in the topological structure of the part model, traversing each face in the face set, obtaining the type, adjacent edge and center point coordinates of each face, and saving to each face object; traversing each edge in the edge set, obtaining the characteristics of each edge, calculating the concave-convex of each edge, and saving to each edge object, constructing an initial adjacency graph according to the adjacency relationship of the face and the edge, and calculating the first face feature tensor and the second edge feature tensor as attributes added to the initial adjacency graph to obtain the first adjacency graph; 3) the second processing route: triangulating the part model to form a series of triangular faces, obtaining the facet (triangular face) set and edge set in the topological structure of the meshed part model, traversing each facet in the facet set, obtaining the normal vector and adjacent edge of each facet, and saving to each facet object; traversing each triangular edge in the triangular edge set, obtaining the adjacent face of each triangular edge and saving to each triangular edge object, constructing an initial second adjacency graph according to the adjacency relationship of the triangular face and the triangular edge, calculating the second face feature tensor and the second edge feature tensor as attributes added to the initial second adjacency graph to obtain the second adjacency graph; 4) generating a double-layer graph structure according to the first adjacency graph and the second adjacency graph, and obtaining a double-layer graph structure dataset; 5) constructing a double-layer graph neural network model, including a node embedding module, a graph level conversion module, a message passing module and a node classification module; 6) dividing the double-layer graph structure dataset to obtain a training set and a validation set, wherein the double-layer graph structure dataset includes a B-Rep data level and a triangular mesh data level, training the double-layer graph neural network model using the training set, calculating the negative log-likelihood loss and the accuracy rate using the validation set after training each data, and saving the network model weight with the highest accuracy rate to the network weight file; 7) obtaining a part model to be tested, inputting the part model to be tested into the trained double-layer graph neural network model, identifying the part machining features, and visualizing the part machining features.

[0103] Specifically, in an embodiment of the present application, Python OCC is used as a carrier, the dataset of the part model and the tested model are used as input, and the part machining feature result is used as output. The part machining feature mentioned in the present application is shown in Figure 3 .

[0104] Please refer to Figure 4 and Figure 5 , Figure 4 and Figure 5 . In the present embodiment, step S1 includes:

[0105] The part model is imported into a CAD software or a professional geometric modeling software, and a five-layer topology structure of a topology chain of the part model is acquired, including a body, a surface, a ring, an edge and a vertex, from which a surface set and an edge set are acquired.

[0106] Specifically, in an embodiment of the present application, step S2 comprises:

[0107] S21, a surface identifier of a surface is set, each surface in the surface set is traversed, surface attributes of each surface are calculated and acquired, a surface object is instantiated, a hash value of the surface object is generated according to the surface identifier, and the surface attributes are assigned as characteristic values to the surface object, and the surface object, the hash value of the surface object and the characteristic values of the surface object are stored in a surface dictionary;

[0108] S22, an edge identifier of an edge is set, each edge in the edge set is traversed, edge attributes of each edge are calculated and acquired, an edge object is instantiated, a hash value of the edge object is generated according to the edge identifier, and the edge attributes are assigned as characteristic values to the edge object, and the edge object, the hash value of the edge object and the characteristic values of the edge object are stored in an edge dictionary;

[0109] S23, the surface dictionary and the edge dictionary are traversed, and an initial adjacency graph is constructed according to the adjacency relationship of the surface object and the edge object, the adjacency graph is composed of nodes and connecting edges, each node corresponds to a surface object, and each connecting edge corresponds to an edge object.

[0110] S24, the characteristic values of the surface object are composed into a first surface characteristic tensor, the characteristic values of the edge object are composed into a first edge characteristic tensor, and the first surface characteristic tensor and the first edge characteristic tensor are added as attributes to the nodes and the connecting edges of the initial adjacency graph respectively, to obtain a first adjacency graph.

[0111] An example is described as follows:

[0112] The STEP neutral file of the part model is imported into Python OCC to obtain the surface set and the edge set of the part model. The read_step_file function provided by the OCC.Extend.DataExchange module in Python OCC is used to read the STEP model file and construct an entity (hereinafter referred to as shape). The TopologyExplorer class is used to parse the shape to generate a topo object, the faces method of the TopologyExplorer class can traverse all the surfaces of the shape, the edges_from_face method of the TopologyExplorer class can traverse all the edges of the surface, and the vertices_from_edge method of the TopologyExplorer class can traverse all the vertices of the edge.

[0113] Traverse each face in the face set, get the type of each face using the BRepAdaptor_Surface() function provided by OCC.Core.BRepAdaptor, get the area of each face using brepgprop_SurfaceProperties, get the vertices of each face using GProp_GProps(), and then get the centroid of each face using the mass_props.CentreOfMass() function. After obtaining the above information, instantiate the B-Rep face object and put it into the dictionary set of B-Rep faces, with the Key value of the dictionary being the hash value of the B-Rep face object and the Value being the B-Rep face object.

[0114] Traverse each edge in the edge set, and use topo.faces_from_edge() to get the two faces adjacent to the edge. Calculate the midpoint coordinate P of the edge and the tangent vector V of the midpoint and the edge. Use the GeomLProp_SLProps() function to calculate the normal vectors n1 and n2 of the two faces.

[0115] Calculate the cross product n3 of n1 and n2, and then calculate the dot product r of n3 and the tangent vector V. If r>0, the edge is a convex edge; if r<0, the edge is a concave edge; if r=0, the edge is defined as other types of edges. Record the hash values of the adjacent faces of each edge. After obtaining the above information of the edge, instantiate the edge object and put it into the dictionary set of edges, with the Key value of the dictionary being the hash value of the edge object and the Value being the edge object.

[0116] Construct an initial adjacency graph according to the adjacency relationship of the faces and edges. Traverse the edge dictionary, and determine the adjacent faces through the hash values of the adjacent faces recorded in the edge object to generate the initial adjacency graph.

[0117] Assemble the eigenvalues of the face object into a first face eigen tensor, assemble the eigenvalues of the edge object into a first edge eigen tensor, and add the first face eigen tensor and the first edge eigen tensor as attributes to the nodes and connecting edges of the initial adjacency graph, respectively, to obtain a first adjacency graph.

[0118] Specifically, please refer to Figure 6 and Figure 7 , Figure 6 and Figure 7 , where S represents a triangular face of a triangular meshed part model. In a specific embodiment of the present application, step S3 comprises:

[0119] S31 triangularly meshes the part model to generate a series of triangular faces;

[0120] S32 traverses each triangular face, obtains the coordinates of the three vertices of the triangular face, calculates the normal vector and the centroid coordinate of the triangular face, and sets the triangular face attributes;

[0121] S33 For each triangular facet, calculate the constant coefficient d of the plane equation of the triangular facet, and record the hash value of the B-Rep face to which the triangular facet belongs;

[0122] S34 According to the triangular facet attribute of each triangular facet and the hash value of the B-Rep face to which it belongs, instantiate a triangular facet object, obtain the hash value of the triangular facet object, and assign the triangular facet attribute as a feature value to the triangular facet object, and store the triangular facet object and its hash value and feature value in the triangular facet dictionary;

[0123] S35 Traverse the triangular edges of the triangular meshed part model, record the hash values of the two adjacent triangular facets of each triangular edge, instantiate a triangular edge object according to the hash values of the two adjacent triangular facets, obtain the hash value of the triangular edge object, and assign the triangular edge attribute as a feature value to the triangular edge object, and store the triangular edge object and its hash value and feature value in the triangular edge dictionary;

[0124] S36 Traverse the triangular facet dictionary and the triangular edge dictionary, and construct an initial second adjacency graph according to the adjacency relationship of the triangular facet object and the triangular edge object;

[0125] S37 Form a second face feature tensor by the feature values of the triangular facet object, form a second edge feature tensor by the feature values of the triangular edge object, and add the second face feature tensor and the second edge feature tensor as attributes to the nodes and connecting edges of the initial second adjacency graph, respectively, to obtain the second adjacency graph.

[0126] An example is described as follows:

[0127] Traverse the B-Rep face to triangulate the B-Rep face using BRep_Tool().Triangulation(), and the triangular facet is denoted as facet in the following. Traverse each facet, and use the Node() function to obtain the coordinates of the three vertices of the facet, node_1, node_2, and node_3. Obtain the edge vector vec1 by node_1-node_2, and obtain the edge vector vec2 by node_2-node_3, and calculate the cross product of vec1 and vec2 to obtain the normal vector norm of the facet. Calculate the centroid coordinates of the facet by node_1, node_2, and node_3. Calculate the constant coefficient d of the plane equation of the facet. Finally, record the hash value of the B-Rep face to which each facet belongs. After obtaining the information of the above facet, instantiate the facet object, and put it into the facet dictionary collection, and the Key value of the dictionary is the hash value of the facet object, and the Value is the facet object.

[0128] Traverse the edges of the triangular meshed model, record the hash values of the two facets adjacent to each edge, instantiate the edge object after obtaining the above information, and put it into the edge dictionary set, and the Key value of the dictionary is the hash value of the edge object, and the Value is the edge object.

[0129] According to the adjacency relationship of the facet and the edge, an initial second adjacency graph is constructed: traversing the edge dictionary, the adjacent facets can be determined through the hash values of the adjacent facets recorded in the edge object, and the initial second adjacency graph is generated.

[0130] Then, the eigenvalues of the triangular facet object form a second facet eigenvalue tensor, the eigenvalues of the triangular edge object form a second edge eigenvalue tensor, and the second facet eigenvalue tensor and the second edge eigenvalue tensor are added as attributes to the nodes and connecting edges of the initial second adjacency graph, respectively, to obtain the second adjacency graph, in particular, the attributes of the facet include the coefficients x, y, z and the constant coefficient d of the quadratic equation of the facet.

[0131] Specifically, in an embodiment of the present application, step S4 comprises:

[0132] According to the correlation between the facets of the part model under the B-Rep representation and the triangular facets of the part model under the triangular mesh, the nodes of the first adjacency graph and the second adjacency graph are linked, and a double-layer graph structure dataset is generated.

[0133] The linking relationship with the B-Rep face can be determined according to the hash value of the B-Rep face object recorded in each facet object, the two graph structure data are linked, and a double-layer graph structure is generated. Please refer to Figure 8 , Figure 8 This is a schematic diagram of part of the double-layer graph structure of the present embodiment, and according to the double-layer graph structure, a double-layer graph structure dataset can be formed to represent in the form of a graph structure.

[0134] Specifically, please refer to Figure 9 , in an embodiment of the present application, step S5 comprises:

[0135] S51 constructs a double-layer graph neural network model, and the structure of the double-layer graph neural network model comprises a node embedding module, a graph-level conversion module, a message passing module and a node classification module;

[0136] S52 divides the double-layer graph structure dataset to obtain a training set and a validation set, wherein each sample data in the double-layer graph structure dataset comprises a B-Rep data level and a triangular mesh data level.

[0137] S53 sets the training parameters, inputs the training set into the double-layer graph neural network model for iterative training, expands the dimension of the node feature matrix of the training set according to the node embedding module, aggregates and converts the node feature matrices of the two data levels according to the graph level conversion module, obtains a feature aggregation result, calculates the structural similarity and content similarity between nodes based on the feature aggregation result by using the message passing module, updates the vector representation of the nodes according to the attention coefficient, classifies the updated nodes based on the node classification module, and the iteration ends until the model requirements are met, and a trained double-layer graph neural network model is obtained.

[0138] Wherein, after each iteration, the negative log-likelihood loss and the accuracy of feature recognition are calculated by using the validation set, and the network weight parameter with the highest accuracy is saved to the weight file.

[0139] A specific example is described as follows:

[0140] In the embodiment, the double-layer graph neural network model mainly includes the following modules: a node embedding module, a graph level conversion module, a message passing module and a node classification module. Each module is independently set between the two data levels. The third-party library PyTorch Geometric in python can be used to construct each module.

[0141] According to the execution process of the above-mentioned main modules, the general process of training the training set is as follows:

[0142] 1. The node embedding module expands the dimension of the node feature matrix of the training set, including:

[0143] The node feature matrix of the training set is extracted, and a learnable parameter matrix G is defined;

[0144] The node feature matrix is multiplied by the learnable parameter matrix G to expand the dimension of the node feature matrix;

[0145] The expanded node feature matrix is subjected to nonlinear transformation, and the F.dropout(x, p) function is used to realize the random inactivation operation, where x is the input expanded node feature, and p is the inactivation probability.

[0146] 2. The graph level conversion module aggregates and converts the node feature matrices of the two data levels to obtain a feature aggregation result, including:

[0147] A trainable matrix W is defined, and the trainable matrix W is used to map the node feature matrix X_brep of the B-Rep data level to the node feature matrix X_facet of the triangular mesh data level, or map X_facet to X_brep.

[0148] Specifically, the size of the trainable matrix W is (B-Rep level feature dimension, Facet level feature dimension).

[0149] The node feature matrix X_brep of the B-Rep data level is multiplied by the trainable matrix W to obtain the first mapped feature matrix X1_mapped = X_brep * W;

[0150] Or the node feature matrix X_facet of the triangular mesh data level is multiplied by the transpose of the trainable matrix W to obtain the second mapped feature matrix X2_mapped = X_facet * W T ;

[0151] The first feature matrix or the second feature matrix is added to the node feature matrix of the corresponding level to obtain the feature aggregation result. Specifically as follows:

[0152] B-Rep level feature aggregation: X1_aggregated = X1_mapped + X_brep

[0153] Facet level feature aggregation: X2_aggregated = X2_mapped + X_facet

[0154] By using the trainable matrix W, the graph level conversion module can map and aggregate feature matrices of different levels to obtain the feature aggregation result. Such operation enables different levels of features to influence and integrate with each other, improving the expression ability and richness of the features.

[0155] 3. Calculate the structural similarity and content similarity between nodes based on the feature aggregation result using the message passing module, and update the vector representation of the node according to the attention coefficient, including:

[0156] Step one, for a given node i, calculate the structured fingerprint F i of i, denoted as F i = (V (i) ,w (i) ), V (i) is the neighbor node set of the local receptive field around node i, and w (i) is the contribution weight of the corresponding neighbor node;

[0157] Wherein, the calculation method of w (i) is:

[0158] w (i) (j) = exp (-dis(i,j 2 / 2h 2 )

[0159] In the formula, w(i) (j) is the contribution weight of node j, dis represents the distance between nodes, and h is the Gaussian bandwidth.

[0160] Therefore, from the above, it can be seen that the learning process of the structured fingerprint is adaptive.

[0161] Step two, for a single node j in the neighbor node set, the structural similarity between node j and the center node i is calculated, and the structural similarity coefficient s is obtained ij .

[0162] According to the formula of the structured fingerprint, the structural information of the nodes in the double-layer graph structure data is defined and quantified, and the calculation formula of the structural similarity coefficient s ij is as follows:

[0163] s ij = A str (F i , F j )

[0164]

[0165] In the formula, a and b represent elements in sets F i and F j , w(a) and w(b) represent weights associated with these elements, and Σ represents a summation operation.

[0166] The structural similarity coefficient improves the performance of the evaluation of node similarity, and ultimately improves the attention of the graph.

[0167] Step three, the content similarity between node j and the center node i is calculated, and the content similarity coefficient e ij is obtained.

[0168] The calculation formula of the content similarity coefficient e ij is as follows:

[0169] e ij = δ([Q E i ] [Q E j ])

[0170] In the formula, δ is a nonlinear activation function, Q is a linear mapping matrix, and E i and E j represent the original features of node i and node j, respectively.

[0171] The idea of this calculation is: through linear mapping and activation function, the transformed features of vertex i and vertex j are spliced, and are mapped to a real number through the activation function, which is used to calculate the content similarity coefficient. This can capture the content similarity between vertex i and vertex j, and is used for subsequent information transmission and node representation update.

[0172] Step four, normalize the structure similarity coefficient s ij and the content similarity coefficient e ij , to get the normalized structure similarity coefficient s' ij and the normalized content similarity coefficient e' ij , the normalization formula is as follows:

[0173] s' ij = exp(s ij ) / ∑exp(s ik )

[0174] e' ij = exp(LeakyRelu(e ij )) / ∑exp(LeakyRelu(e ik ))

[0175] In the formula, LeakyRelu is an activation function, s ik and e ik respectively refer to the structure similarity coefficient and the content similarity coefficient between all nodes in the neighbor node set and the center node i.

[0176] Specifically, in the normalization formula of the structure similarity coefficient: the numerator exp(s ij ) represents the exponential form of the similarity between node i and center node j, exp(s ij ) exponentiates the value of similarity, which can be converted into a non-negative weight value; the denominator ∑exp(s ik ) represents the sum of the exponentials of the similarity between neighbor node k and center node j, ∑exp(s ik ) sums the exponential values of all similarities, which is used to normalize the weight value of the numerator.

[0177] In the normalization formula of the content similarity coefficient: the numerator exp(LeakyRelu(e ij )) is obtained by processing the original content similarity coefficient e ij with the LeakyReLU activation function, and the LeakyReLU activation function is a kind of rectified linear unit activation function, which can retain part of the negative value, so as to increase the nonlinear ability and generalization ability of the model; the denominator ∑exp(LeakyRelu(e ik)) is the exponential operation after the LeakyReLU activation function processing of the content similarity coefficient between node i and all other neighbor nodes, and the sum of all results. This process can be regarded as a normalization process for all content similarity coefficients, so that the value of each content similarity coefficient is between 0 and 1.

[0178] Step five, according to the normalized structure similarity coefficient s' ij and the normalized content similarity coefficient e' ij , the attention coefficient a ij between node j and center node i is calculated.

[0179] Combining feature similarity and structured interaction, the final attention coefficient a ij is obtained.

[0180]

[0181] In the formula, σ is the sigmoid function, and are the average values of the content similarity coefficient and the structure similarity coefficient, respectively.

[0182] Step six, based on the attention coefficient a ij , the target node representation at t+1 time is obtained by weighted summation of neighbor node representation at t time.

[0183]

[0184] In the formula, represents the influence of node j on center node i, is the hidden state vector of node j at t time, A is the weight matrix, Σ represents summation of all neighbor nodes, and σ represents the sigmoid function, is the hidden state vector of node i at t+1 time.

[0185] After obtaining the attention coefficient a ij of the two nodes, the vector update of the node can be carried out through the message passing framework of the graph neural network, that is, the target node representation at t+1 time is obtained by weighted summation of neighbor node representation at t time.

[0186] The structure information receiving domain of each node will be limited within the k-hop area, which is called "fingerprint size"; when the distance between the center nodes of two receiving domains is less than the threshold k, the attention will be calculated.

[0187] Step seven, repeat steps five and six to perform multiple rounds of information transmission and node representation update until convergence or a specified number of iterations is reached, and output the updated node vector representation.

[0188] Since a single round of information passing and node representation updating can not be sufficient to capture the complex relationships and features in the graph, steps five and six can be repeated for multiple rounds of information passing and node representation updating to better capture the global and local information in the graph. Each round of information passing can further adjust the attention weights between nodes to aggregate more relevant information into the node representations. The model can gradually learn more accurate node representations in multiple rounds of iterations while adaptively assigning attention weights between different nodes to aggregate important node information. This can generate more informative node representations and improve the expressiveness and adaptability of the model.

[0189] In this embodiment, the attention coefficient a ij The message passing operation is provided with weights, and the model can adaptively assign attention weights between different nodes so that important nodes are paid more attention during information passing. The graph attention coefficient is used to weight the features of neighboring nodes to generate a new representation of the node. By considering the importance of different neighboring nodes, the model can better aggregate information to generate more informative node representations. Since the structural information in the graph is considered, the node can aggregate more rich information, which reduces the possibility of overfitting of the network model on small graphs.

[0190] 4. Classify the updated nodes based on the node classification module, including:

[0191] The node classification module uses the torch.nn.functional.softmax(dim, num_classes) function to implement node classification, where dim represents the dimension of the input tensor and num_classes represents the number of final classification categories.

[0192] According to the above process, the double-layer graph neural network model is trained. During training, training parameters such as learning rate, number of iterations, batch size, regularization, etc. are set. The specific training parameters are determined according to the actual situation.

[0193] After each iteration, the negative log-likelihood loss and the accuracy of feature recognition can be calculated using the validation set. The negative log-likelihood loss is used to measure the difference between the model's predicted results and the true labels. The feature recognition accuracy can be used to evaluate the classification performance of the model.

[0194] According to the performance on the validation set, the network weight parameter with the highest accuracy can be selected and saved to the weight file. In this way, the weight file can be loaded in the subsequent testing stage, and the trained model can be used for prediction.

[0195] Through iterative training of the above steps until a model requirement is reached, specifically, the model requirement can be that the accuracy rate reaches 90%, and then a trained double-layer graph neural network model can be obtained.

[0196] Specifically, in combination with the flowchart executed by the model in Figure 9 , the present application provides a detailed model training embodiment, which is specifically described as follows:

[0197] This embodiment is illustrated by taking a sample data as an example, which includes five matrices, that is, a first node feature matrix composed of first face feature tensors, a second node feature matrix composed of second face feature tensors, a first adjacency matrix represented by a first adjacency graph, a second adjacency matrix represented by a second adjacency graph, and a description matrix B describing the link relationship between the nodes of the B-Rep data level and the nodes of the triangular mesh data level of the sample data. Figure 8 For example, Figure 8 , the F2 node is a node of the B-Rep data level, the S1 node is a node of the triangular mesh data level, and there is a dashed line between the F2 node and the S1 node, which means that the F2 node and the S1 node have a link relationship, so the description matrix B contains information describing the link relationship between the F2 node and the S1 node. Specifically, in this sample data, the B-Rep data level contains the first node feature matrix and the first adjacency matrix, and the triangular mesh data level contains the second node feature matrix and the second adjacency matrix.

[0198] According to the structure of the double-layer graph neural network model shown in Figure 9 , the model of this embodiment specifically includes three node embedding modules, two graph-level conversion modules, two message passing modules, and one node classification module. Although the purposes of the three node embedding modules are the same, that is, to perform dimension transformation on the input node feature matrix, the structures of each node embedding module and the dimensions of the learnable parameter matrices used are slightly different, and the same is true for the other graph-level conversion modules and message passing modules. Therefore, each module of the double-layer graph neural network model is defined, and the data flow is shown in Figure 9 : the first node embedding module, the first graph-level conversion module, the first message passing module, the second node embedding module, the second graph-level conversion module, the second message passing module, the third node embedding module, and the node classification module.

[0199] When this sample data is input into the double-layer graph neural network model, first, the first node feature matrix of the B-Rep data level is multiplied by the first learnable parameter matrix G1 in the first node embedding module to obtain the first expanded node feature matrix of the B-Rep data level.

[0200] Afterwards, according to the description matrix B in the sample data, it is determined whether there is a link relationship between the first extended node feature matrix and the nodes of the triangular mesh data level, the first extended node feature matrix with the link relationship is input into the first graph level conversion module, the dimension of the first extended node feature matrix is converted to be the same as that of the corresponding second node feature matrix by multiplying the first trainable matrix W1 and the first extended node feature matrix, then the node feature matrix X_brep of the B-Rep data level is mapped to the triangular mesh data level, that is, added to the second node feature matrix, and the first feature matrix is obtained after the feature aggregation.

[0201] Then, the first feature matrix is input into the first information transmission module for multiple node updates, and the first updated feature matrix with updated node expression is obtained.

[0202] The first updated feature matrix is input into the second node embedding module, the second learnable parameter matrix G2 is used to expand the dimension of the first updated feature matrix, and the second extended node feature matrix is obtained.

[0203] The second extended node feature matrix is input into the second graph level conversion module, the second trainable matrix W2 is multiplied with the second extended node feature matrix, the dimension of the second extended node feature matrix is converted to be the same as that of the first extended node feature matrix, then the node feature matrix X_facet of the triangular mesh data level is mapped to the B-Rep data level, that is, added to the first extended node feature matrix, and the second feature matrix is obtained after the feature aggregation.

[0204] Then, the second feature matrix is input into the second information transmission module for multiple node updates, and the second updated feature matrix with updated node expression is obtained.

[0205] The second updated feature matrix is input into the third node embedding module, the third learnable parameter matrix G3 is used to expand the dimension of the second updated feature matrix, and the third extended node feature matrix is obtained.

[0206] The third extended node feature matrix is input into the node classification module, and the third extended node feature matrix is classified.

[0207] The above is the training process of a single sample data of the embodiment, each training calculates the negative log likelihood loss and the accuracy of feature recognition by using the validation set, and after iteration, the trained double-layer graph neural network model is obtained.

[0208] Obtain the part model to be detected, input the part model to be detected into the trained double-layer graph neural network model, obtain the part processing features, and visualize the part processing features. The following steps can be followed:

[0209] Data preprocessing: First, the part model to be detected needs to be preprocessed to adapt to the input requirements of the model. This may include converting the part model into a graph representation, such as converting the geometric information of the part into a form of nodes and edges.

[0210] Model input: input the preprocessed part model into the trained double-layer graph neural network model. The input can include node features and edge features, which can be extracted from the geometric information, material properties or other related information of the part.

[0211] Feature extraction: through forward propagation, the model obtains the output of the input part model through the calculation of the network layer. In this way, the model can learn the processing features of the part.

[0212] Feature visualization: after obtaining the categories of part processing features, different colors can be marked on different categories of features, and finally the model part with different color categories is displayed in Python OCC.

[0213] The above is only the preferred embodiment of the present application, and is not intended to limit the present application. Any modification, equivalent replacement, improvement, etc. within the spirit and principles of the present application shall be included within the protection scope of the present application.

Claims

1. A machining feature recognition method based on a double-layer graph neural network, characterized in that, The method comprises the following steps: S1, a part model is acquired, and the part model is parsed under a B-Rep representation to obtain a face set and an edge set of the part model; S2, the face set and the edge set of the part model are traversed to obtain face objects and edge objects, face attributes and edge attributes, the face attributes are taken as characteristic values of the face objects, the edge attributes are taken as characteristic values of the edge objects, an initial adjacency graph is generated based on the face objects and the edge objects, the characteristic values of the face objects are taken as first face feature tensors, the characteristic values of the edge objects are taken as first edge feature tensors, and the first face feature tensors and the first edge feature tensors are taken as attributes and added to nodes and connecting edges of the initial adjacency graph to obtain a first adjacency graph; S3, the part model is triangulated, the triangulated part model is parsed to obtain a triangular face set and a triangular edge set, the triangular face set and the triangular edge set are traversed to obtain triangular face objects and triangular edge objects, triangular face attributes and triangular edge attributes, the triangular face attributes are taken as characteristic values of the triangular face objects, the triangular edge attributes are taken as characteristic values of the triangular edge objects, an initial second adjacency graph is constructed based on the triangular face objects and the triangular edge objects, the characteristic values of the triangular face objects are taken as second face feature tensors, the characteristic values of the triangular edge objects are taken as second edge feature tensors, and the second face feature tensors and the second edge feature tensors are taken as attributes and added to nodes and connecting edges of the initial second adjacency graph to obtain a second adjacency graph; S4, the first adjacency graph and the second adjacency graph are combined to construct a double-layer graph structure dataset; S5, a double-layer graph neural network model is constructed, the double-layer graph neural network model is iteratively trained by using the double-layer graph structure dataset until a model requirement is met, and a trained double-layer graph neural network model is obtained; S6, a part to be detected is acquired, the part to be detected is input into the trained double-layer graph neural network model, part machining features are obtained, and the part machining features are visually displayed.

2. The machining feature recognition method based on a double-layer graph neural network according to claim 1, wherein, Step S2 comprises: S21, a face identifier of a face is set, each face in the face set is traversed, face attributes of each face are calculated and obtained, a face object is instantiated, a hash value of the face object is generated according to the face identifier, the face attributes are taken as characteristic values of the face object, the face object, the hash value of the face object and the characteristic values of the face object are stored in a face dictionary; S22, an edge identifier of an edge is set, each edge in the edge set is traversed, edge attributes of each edge are calculated and obtained, an edge object is instantiated, a hash value of the edge object is generated according to the edge identifier, the edge attributes are taken as characteristic values of the edge object, the edge object, the hash value of the edge object and the characteristic values of the edge object are stored in an edge dictionary; S23, the face dictionary and the edge dictionary are traversed, an initial adjacency graph is constructed according to the adjacency relationship of the face objects and the edge objects, the adjacency graph is composed of nodes and connecting edges, each node corresponds to a face object, and each connecting edge corresponds to an edge object; S24, the characteristic values of the face objects are taken as first face feature tensors, the characteristic values of the edge objects are taken as first edge feature tensors, and the first face feature tensors and the first edge feature tensors are taken as attributes and added to the nodes and the connecting edges of the initial adjacency graph to obtain the first adjacency graph.

3. The machining feature recognition method based on a double-layer graph neural network according to claim 2, characterized in that, The face attributes include the type of the face, the area of the face, the vertex of the face and the midpoint of the face, and the calculation process of the face attributes is as follows: The type of each face is obtained by using the BRepAdaptor_Surface() function, the area of each face is obtained by using brepgprop_SurfaceProperties, the vertex of each face is obtained by using GProp_GProps(), and the midpoint of each face is obtained by using the mass_props.CentreOfMass() function; Correspondingly, the edge attributes include the type of the edge and the concave-convex property, and the calculation process of the edge attributes is as follows: The two faces adjacent to an edge are obtained by using topo.faces_from_edge(), the midpoint coordinate P of the edge and the tangent vector V of the midpoint to the edge are calculated, and the normal vectors n1 and n2 of the two faces are calculated by using the GeomLProp_SLProps() function; The cross product n3 of n1 and n2 is calculated, and the dot product r of n3 and the tangent vector V is calculated; If r>0, the corresponding edge is a convex edge; If r<0, the corresponding edge is a concave edge; If r=0, the corresponding edge is defined as an edge of other types.

4. The machining feature recognition method based on a double-layer graph neural network according to claim 2, characterized in that, Step S3 includes: S31 triangulates the part model to generate a series of triangular faces; S32 traverses each triangular face to obtain the coordinates of the three vertices of the triangular face, and calculates the normal vector and the centroid coordinate of the triangular face to make the triangular face attributes; S33 calculates the constant coefficient d of the plane equation of each triangular face, and records the hash value of the B-Rep face to which the triangular face belongs; S34 instantiates a triangular face object according to the triangular face attributes of each triangular face and the hash value of the B-Rep face to which the triangular face belongs, obtains the hash value of the triangular face object, and assigns the triangular face attributes as the feature value to the triangular face object, and stores the triangular face object, the hash value and the feature value thereof in the triangular face dictionary; S35 traverses the triangular edges of the part model after triangulation, records the hash values of the two triangular faces adjacent to each triangular edge, instantiates a triangular edge object according to the hash values of the two adjacent triangular faces, obtains the hash value of the triangular edge object, and assigns the triangular edge attributes as the feature value to the triangular edge object, and stores the triangular edge object, the hash value and the feature value thereof in the triangular edge dictionary; S36 traverses the triangular face dictionary and the triangular edge dictionary, and constructs an initial second adjacency graph according to the adjacency relationship of the triangular face objects and the triangular edge objects; S37 groups the feature values of the triangular face objects into a second face feature tensor, groups the feature values of the triangular edge objects into a second edge feature tensor, and adds the second face feature tensor and the second edge feature tensor as attributes to the nodes and connecting edges of the initial second adjacency graph respectively to obtain the second adjacency graph.

5. The machining feature recognition method based on double-layer graph neural network according to claim 4, characterized in that, Step S4 includes: According to the correlation between the faces of the part model under the B-Rep representation and the triangular faces of the part model under the triangular mesh, the nodes of the first adjacency graph and the second adjacency graph are linked to generate a double-layer graph structure dataset.

6. The machining feature recognition method based on a double-layer graph neural network according to claim 1, wherein, Step S5 includes: S51, a double-layer graph neural network model is constructed, and a structure of the double-layer graph neural network model comprises a node embedding module, a graph-level conversion module, a message passing module, and a node classification module; S52, a double-layer graph structure dataset is segmented to obtain a training set and a validation set, wherein each sample data in the double-layer graph structure dataset comprises a B-Rep data level and a triangular mesh data level; S53, training parameters are set, the training set is input into the double-layer graph neural network model for iterative training, the node feature matrix of the training set is dimensionally expanded according to the node embedding module, the node feature matrices of the two data levels are aggregated and converted according to the graph-level conversion module to obtain a feature aggregation result, the structural similarity and the content similarity between nodes are calculated based on the feature aggregation result by using the message passing module, the vector representation of the nodes is updated according to the attention coefficient, the updated nodes are classified based on the node classification module, and the iteration is ended until the model requirements are met, and a trained double-layer graph neural network model is obtained. Wherein, after each iteration, the negative log-likelihood loss and the accuracy of feature recognition are calculated by using the validation set, and the network weight parameter with the maximum accuracy is saved to a weight file.

7. The machining feature recognition method based on a double-layer graph neural network according to claim 6, characterized in that, The dimension expansion of the node feature matrix of the training set according to the node embedding module comprises: The node feature matrix of the training set is extracted, and a learnable parameter matrix G is defined; The node feature matrix is multiplied by the learnable parameter matrix G to expand the dimension of the node feature matrix; The expanded node feature matrix is subjected to a nonlinear transformation, and a F.dropout(x, p) function is used to realize a random inactivation operation, wherein x is the input expanded node feature, and p is an inactivation probability.

8. The machining feature recognition method based on a double-layer graph neural network according to claim 7, characterized in that, The aggregation and conversion of the node feature matrices of the two data levels according to the graph-level conversion module to obtain the feature aggregation result comprises: A trainable matrix W is defined, and the node feature matrix X_brep of the B-Rep data level is mapped to the node feature matrix X_facet of the triangular mesh data level by using the trainable matrix W, or X_facet is mapped to X_brep; The node feature matrix X_brep of the B-Rep data level is multiplied by the trainable matrix W to obtain a first feature matrix X1_mapped=X_brep*W; or multiplying the node feature matrix X_facet of the triangle mesh data layer by the transpose of the trainable matrix W to obtain the mapped second feature matrix X2_mapped = X_facet*W T ; The first feature matrix or the second feature matrix is added to the node feature matrix of the corresponding level to obtain the feature aggregation result.

9. A processing feature recognition method based on a two-layer graph neural network according to claim 8, characterized in that: The calculation of the structural similarity and the content similarity between nodes based on the feature aggregation result by using the message passing module, and the updating of the vector representation of the nodes according to the attention coefficient comprises: Step one, for a given node i, compute the structured fingerprint F of i i , denoted as F i = (V (i) , w (i) ), V (i) is the set of neighbor nodes in the local reception field around node i, w (i) is the contribution weight of the corresponding neighbor node; Step two, for each node j in the neighbor set, compute the structural similarity between node j and the center node i, to get the structural similarity coefficient s ij ; Step 3: Calculate the content similarity between node j and its central node i, and obtain the content similarity coefficient e ij ; Step four, normalize the structure similarity coefficient s ij and the content similarity coefficient e ij to get the normalized structure similarity coefficient s' ij and the normalized content similarity coefficient e' ij , the normalization formula is as follows: s′ ij = exp(s ij ) / ∑exp(s ik ) e′ ij = exp(LeakyRelu(e ij )) / ∑exp(LeakyRelu(e ik )) where LeakyRelu is an activation function, s ik and e ik denote the structural and content similarity coefficients between all nodes in the neighborhood set and the center node i, respectively. Step 5: According to the normalized structural similarity coefficient s′ ij and the normalized content similarity coefficient e′ ij Calculate the attention coefficient a between node j and central node i ij ; Step six, based on the attention coefficient a ij The target node representation at time t+1 is obtained according to the weighted sum of the neighbor node representations at time t. wherein, represents the influence of node j on the center node i, is the hidden state vector of node j at time t, A is a weight matrix, ∑ represents summation over all neighbor nodes, and σ represents a sigmoid function, is the hidden state vector of node i at time t+1. Step seven, steps five and six are repeated to perform multiple rounds of information transmission and node representation updating until convergence or a specified number of iterations is reached, and the vector representation of the updated nodes is output.

10. The machining feature recognition method based on a double-layer graph neural network according to claim 9, wherein, Structural similarity coefficient s ij The formula for calculating s is: s ij = A str (F i , F j ) where a and b represent elements in sets F i and F j respectively, w(a) and w(b) represent weights associated with these elements respectively, and ∑ represents a summation operation; Content similarity coefficient e ij The calculation formula is: e ij = δ([QE i ][QE j ]) where δ is a nonlinear activation function, Q is a linear mapping matrix, E i and E j denote the original features of node i and node j, respectively; Attention coefficient a ij The calculation formula is: where σ is a sigmoid function, and are the average of the content similarity coefficient and the structure similarity coefficient, respectively.

Citation Information

Patent Citations

  • Processing feature recognition method based on NX secondary development and graph neural network

    CN114491841A