BIM connecting piece three-dimensional contour generation method based on pipe port geometric parameters
By using a 3D contour generation method based on pipe port geometric parameters, the problems of non-standard dimensions, complex transition curves, imperfect multi-port processing, and abnormal vertical pipe intersections in BIM software when generating electromechanical pipeline connectors are solved, achieving efficient and accurate connector generation and automated design.
Patent Information
- Application Number
- CN202611188943.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-06
- Publication Date
- 2026-11-24
AI Technical Summary
Existing BIM software has several problems when generating MEP (Mechanical, Electrical, and Plumbing) connectors, including difficulty in generating non-standard sized connectors, complex calculation of transition curves, inadequate handling of multi-port connectors, lack of automated embedding of HVAC (Heating, Ventilation, and Air Conditioning) engineering knowledge, and abnormal connector shapes when vertical pipes intersect.
By acquiring the pipe port information associated with the connector, determining whether it is a vertical pipe, calculating the cross-sectional edge segments of each port, generating transition curves using a double tangent arc fitting algorithm, assembling a closed two-dimensional contour and determining the three-dimensional stretching parameters, performing anchor point decomposition and composite combination of multi-port connectors, and automatically determining the guide vanes, the three-dimensional contour of the connector is generated.
It enables the instant generation of accurate connector shapes without the need for pre-set family library templates, with smooth and natural transition curves, stable calculation of multi-port connectors, automatic embedding of HVAC engineering knowledge, handling of vertical pipe intersection scenarios, simplifying project configuration and improving design efficiency and model accuracy.
Smart Images

Figure CN123158798A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of electromechanical pipeline design technology, and in particular to a method for generating three-dimensional contours of BIM connectors based on the geometric parameters of pipe ports. Background Technology
[0002] Currently, commonly used electromechanical pipeline design methods have the following technical problems:
[0003] 1. Connection geometry generation relies on pre-built family library templates: Current mainstream BIM software (such as Revit and MagiCAD) typically relies on pre-built parametric family library templates when generating pipe connections. Each connection type (elbow, tee, reducer, etc.) requires a pre-built parametric family file, which defines the connection's geometry, dimensional parameters, and constraints. When encountering non-standard sized connections (e.g., cross-sectional dimensions not in the standard specification table), the family library may not have a corresponding template, resulting in the connection being unable to be generated or requiring manual modeling. When the intersection angle of two pipes is non-standard (e.g., a non-90-degree oblique intersection), the angle parameters in the pre-built family file may not be covered, leading to inaccurate shapes. Furthermore, each new connection specification requires maintaining a family library file, increasing the complexity of software deployment and project configuration.
[0004] 2. Lack of Mathematical Rigor in Connector Transition Curve Generation: When generating the geometric profile of a connector, a smooth transition curve needs to be generated between the cross-sectional edges of the two pipe ports. In existing technologies, some solutions use simple straight line segments to connect the endpoints of the two cross-sections, resulting in sharp corners in the connector profile at the ports, making it less smooth and natural. Other solutions use iterative approximation methods (such as least-squares fitting) to find the transition curve, which involves large computational loads and cannot guarantee convergence, leading to poor performance when handling a large number of connectors. Still other solutions impose hard-coded restrictions on the type of transition curve (e.g., only supporting arc transitions for 90-degree bends), requiring switching to different algorithm branches when the pipe intersection angle changes, resulting in complex code that is difficult to extend.
[0005] 3. Inadequate handling of multi-port connector shape combinations: In practical engineering, scenarios where three or more pipes intersect at the same node are common (such as tees, crosses, and multi-way connectors). Current technologies for handling multi-port connector shapes typically employ either pre-setting independent templates for each number of ports or simply performing a Boolean union operation on the cylinders in each port direction. The former requires creating separate templates for 2-port, 3-port, 4-port, and 5-port connections, with the number of templates increasing dramatically with the port combination method; the latter's Boolean operations are prone to calculation failures or inaccurate results when handling complex cross-sections (such as chamfered transitions in rectangular pipes), leading to abnormal connector shapes or even connection generation failures.
[0006] 4. Lack of automated integration of HVAC engineering knowledge: In HVAC engineering, rectangular duct elbows with large cross-sectional dimensions (typically width or height ≥ 500mm) require guide vanes to reduce airflow resistance and noise. Existing BIM software, when generating connectors, only focuses on geometric shape generation and lacks the ability to automatically determine such engineering rules. Designers need to manually check which elbows require guide vanes after connector generation, and then manually modify the connector type and display style. This is labor-intensive and prone to omissions, seriously affecting design efficiency and the accuracy of model review.
[0007] 5. Abnormal connector shape at the intersection of vertical and horizontal pipes: The intersection of vertical (rise) and horizontal pipes is a common scenario in BIM models. Current technology, when generating such connectors, causes the vertical pipe's direction vector to be parallel to the Z-axis, resulting in its projection onto the XY plane degenerating into a single point. This leads to the failure of contour generation algorithms based on XY plane projection, resulting in abnormal connector shapes (e.g., contour collapse to zero area, divergent transition curve calculations). This prevents pipe systems containing risers from correctly displaying connector shapes, requiring manual intervention from designers and severely impacting the integrity of automated modeling.
[0008] Therefore, there is a need to provide a method for generating 3D contours of BIM connectors based on the geometric parameters of pipe ports, which can solve the above-mentioned technical problems existing in the prior art. Summary of the Invention
[0009] The purpose of this invention is to provide a method for generating three-dimensional contours of BIM connectors based on the geometric parameters of pipe ports, which can solve the above-mentioned technical problems existing in the prior art.
[0010] This invention is implemented as follows:
[0011] A method for generating 3D contours of BIM connectors based on pipe port geometry parameters includes the following steps:
[0012] Step 1: Obtain all pipe port information associated with the connector;
[0013] Step 2: Determine if it is a vertical pipe. If yes, use the straight-through strategy for the cross-sectional profile. If no, proceed to step 3.
[0014] Step 3: Calculate the cross-sectional edge segments at each port;
[0015] Step 4: Generate transition curves using the double tangent arc fitting algorithm;
[0016] Step 5: Assemble the closed two-dimensional profile and determine the three-dimensional stretching parameters;
[0017] Step 6: Anchor point decomposition and composite assembly of multi-port connectors;
[0018] Step 7: Automatic determination and pattern marking of guide vanes;
[0019] Step 8: Return the 3D contour result of the connector.
[0020] Step 1 includes the following sub-steps:
[0021] Step 11: Read port data;
[0022] When creating a connector, record the port information of all associated pipes. Each port information contains two fields: pipe instance ID and endpoint type.
[0023] Step 12: Port deserialization and verification;
[0024] The serialized string is deserialized to restore a list of port objects, and then three layers of validation are performed:
[0025] ① Quantity verification: The number of ports on the connector must be between 2 and 5; if there are fewer than 2 ports, it is not considered a connector; if there are more than 5 ports, it is considered abnormal data, an error log is recorded, and the connector is skipped.
[0026] ② Deduplication check: Sort by pipeline instance ID and remove duplicates;
[0027] ③ Existence verification: Query the BIM model database based on the pipe instance ID to confirm that each pipe entity exists and has not been deleted;
[0028] Port data is stored as a serialized string in the connector's properties, in the format "instance ID:endpoint type", with multiple ports separated by semicolons;
[0029] Verification result processing: Extract geometric parameters for ports that pass all verifications, i.e., execute step 13; record an exception log for ports that fail verification and remove them from the port object list; if the number of remaining ports after verification is less than 2, terminate the contour generation of the connector.
[0030] Step 13: Obtain the geometric parameters of the pipe port;
[0031] For each valid port, extract the following core geometry parameters from the pipe entity associated with it:
[0032] Insertion point coordinates: that is, the three-dimensional coordinates of the connection point on the pipe entity;
[0033] End direction vector: This refers to the normalized tangent direction of the pipe entity at that port. The end direction vector is a three-dimensional direction vector.
[0034] Cross-sectional width dWidth: the width or diameter of the pipe body;
[0035] Cross-sectional height dHeight: This refers to the cross-sectional height or diameter of the pipe entity.
[0036] Bottom elevation dElevation: the Z coordinate of the centerline of the pipe entity at this port;
[0037] The calculation rules for insertion depth InsertDepth are as follows: For cold air ducts, insertion depth = cross-sectional width dWidth × 1.5; for ordinary ducts, insertion depth = cross-sectional width dWidth; the upper limit of insertion depth = min(InsertDepth, duct length / 2).
[0038] Step 2 includes the following sub-steps:
[0039] Step 21: Determine if it is a vertical pipe. If yes, proceed to step 22. If no, that is, the pipe is not a vertical pipe, proceed to step 3.
[0040] For each port, determine the perpendicularity of the end direction vector: calculate the dot product of the end direction vector and the Z-axis unit vector kZAxis = (0, 0, 1). If the absolute value of the dot product is greater than 1 - 1e-6, then the pipe to which the port belongs is determined to be a vertical pipe.
[0041] Step 22: Straighten the vertical pipe cross-section profile, then proceed to Step 5.
[0042] In step 21,
[0043] Step 22 includes the following sub-steps:
[0044] Step 221: Directly obtain the cross-sectional outline polygon of the pipe at the port: if the pipe is rectangular, return the four vertices of the rectangle; if the pipe is circular, return an approximate octagonal circle.
[0045] Step 222: Take the smaller difference between the Z elevations of the two ports as the bottom elevation;
[0046] Step 223: Take the absolute value of the difference between the Z elevations of the two ports as the stretching thickness;
[0047] Step 224: Directly use the polygon of the vertical pipe cross-section profile as the two-dimensional profile of the connector, add the bottom elevation of step 222 and the stretching thickness of step 223 to form a three-dimensional shape, and proceed to step 5 to assemble the profile.
[0048] Step 3 includes the following sub-steps:
[0049] Step 31: Project the end direction vector of the port onto the XY plane;
[0050] For the first port, the Z component of the port's end direction vector is removed and projected onto the XY plane to obtain the planar direction vector; for the second port, the Z component of the port's end direction vector is removed and projected onto the XY plane, and the projected planar direction vector is inverted.
[0051] Step 32: Calculate the direction of the normal to the cross section;
[0052] The normal vector in the width direction of the cross section is obtained by taking the cross product of the Z-axis unit vector and the plane direction vector.
[0053] Step 33: Construct the cross-sectional edge segments;
[0054] With the insertion point as the center, extend the cross-section width to both sides along the direction of the normal vector by half to construct the cross-section edge segment;
[0055] Step 34: Record elevation information;
[0056] Record the Z-coordinate of the starting point of the edge segment of each port section as the elevation of that port, and then reset the Z-coordinate of the edge segment of the section to zero.
[0057] Step 4 includes the following sub-steps:
[0058] Step 41: Calculate the plane normal;
[0059] The normal vector of the plane containing the arc is determined by the cross product of the two tangent direction vectors; if the length of the cross product result is less than 1e-6, it degenerates into a straight line connection and no arc fitting is performed.
[0060] Step 42: Calculate the radial vector;
[0061] In the plane of the arc, calculate the radial vectors at the two endpoints of the arc; construct two radial lines based on the radial vectors at the two endpoints of the arc.
[0062] Step 43: Find the center of the arc;
[0063] Extend the two radial lines in step 42 and find their intersection point. This intersection point is the center of the arc.
[0064] Step 44: Calculate the arc sweep half-angle from the first endpoint to the second endpoint;
[0065] Step 44 includes the following sub-steps:
[0066] Step 441: Calculate the two radius vectors;
[0067] Step 442: Calculate the signed area;
[0068] Step 443: Calculate the half-angle of the arc sweep;
[0069] Step 45: Use Rodriguez rotation to find the midpoint of the arc;
[0070] Step 46: Construct a three-point arc segment;
[0071] Assemble the starting point ptFirst, the midpoint ptMid, and the ending point ptSecond into a three-point arc segment. When ptMid is valid, it represents an arc passing through the three points; when ptMid is invalid, it represents a straight line segment.
[0072] Step 47: Perform double tangent arc fitting on both ends of the cross-section edge segment to generate transition curves on both sides; the transition curves on both sides connect the left and right ends of the cross-section edge segment respectively.
[0073] Step 5 includes the following sub-steps:
[0074] Step 51: Assemble the closed contour;
[0075] Connect the section edge line segment from step 3 and the transition curves on both sides from step 4 in sequence to form a closed polyline.
[0076] Step 52: Determine the three-dimensional stretching parameters;
[0077] Determine the bottom elevation and stretch thickness of the connector from the Z coordinates of the two port section edge segments; set the three-dimensional properties of the closed polyline; stretch the two-dimensional closed profile along the Z-axis from the bottom elevation dBotEle to dBotEle + thick to form the three-dimensional solid shape of the connector.
[0078] Step 6 includes the following sub-steps:
[0079] Step 61: Anchor point selection; select the first port from all ports as the anchor point;
[0080] Step 62: Decompose in pairs; take the anchor point port and each of the other ports, and perform steps 2 to 5 respectively to obtain N-1 independent two-dimensional closed contours, which are denoted as sub-contours;
[0081] Step 63: Unify the elevation range; traverse all sub-contours and take the global minimum bottom elevation and the global maximum top elevation;
[0082] Step 64: Combine into a composite contour; after projecting all sub-contours onto the XY plane, they are used as a set of sub-polylines for the composite polyline.
[0083] Step 7 includes the following sub-steps:
[0084] Step 71: Seven-step condition chain determination;
[0085] For the generated connectors, check them in the following order, judging each condition in sequence. If any condition is not met, the check will stop and the message "No guide vanes needed" will be returned.
[0086] Condition ①, Component classification check: The component classification ID of the connector is duct elbow;
[0087] Condition ②, Port Count Check: The number of ports is exactly 2;
[0088] Condition ③, Existence check of pipelines: Both associated pipeline entities exist and are accessible;
[0089] Condition ④, Rectangular cross-section inspection: Both pipes have rectangular cross-sections;
[0090] Condition ⑤, Cross-sectional dimension matching check: The cross-sectional dimensions of the two pipes match—matching in the same direction or crossing each other, with a tolerance of 1e-6;
[0091] Condition 6, Minimum size threshold check: The first pipe must have at least one cross-sectional dimension ≥ 500mm;
[0092] Condition 7, Centerline Perpendicularity Check: The centerline direction vectors of the two pipes are perpendicular to each other;
[0093] If all seven conditions above are met, it is determined that the connector needs to be equipped with guide vanes.
[0094] Step 72: For connectors requiring guide vanes, apply style tags; style tags include:
[0095] ① Set the type attribute of the connector to "elbow with guide vanes";
[0096] ② Set the display color of the connector to yellow;
[0097] ③ Set the guide vane marker position;
[0098] Step 73: Reverse recovery;
[0099] When the geometry of the connector changes, causing it to no longer meet the conditions for the guide vane, the system automatically performs reverse recovery. The reverse recovery process is as follows: restore the connector's type attribute to the default value; restore the connector's display color to the system default color; and clear the guide vane flag.
[0100] In step 8, the polyline data of the generated three-dimensional contour of the connector is returned to the caller for display by the three-dimensional rendering engine; at the same time, the determination result of the guide vane is returned for attribute annotation and color rendering.
[0101] ① Results processing: Extract key information from the final generated connectors—connector type, number of ports, polyline data of the three-dimensional profile, and determination results of the guide vanes;
[0102] ② Handling of anomalies and empty results: If the port data is abnormal and the contour generation fails, an empty result is returned and an error log is recorded, which does not affect the generation of other connectors; if an anomaly occurs in the geometric calculation, the connection point is skipped and the anomaly information is recorded.
[0103] Compared with the prior art, the present invention has the following advantages:
[0104] 1. This invention enables real-time generation of parametric connectors that are independent of family library dependencies: This invention does not rely on any pre-set parametric family library templates. Instead, it starts from the actual geometric parameters (insertion point coordinates, end direction vector, cross-sectional width, and height) of the pipe port associated with the connector and constructs the three-dimensional contour shape of the connector in real time through mathematical calculations. Regardless of whether the duct is of standard size (such as common specifications like 400×300, 500×400, etc.) or non-standard size (such as irregular cross-sections temporarily determined on-site), regardless of whether the two pipes are of the same diameter or different diameters (such as a 600×400 duct intersecting with a 400×300 duct), and regardless of whether the intersection angle is a standard 90 degrees or an arbitrary angle (such as 45 degrees, 60 degrees, 120 degrees, etc.), this invention can automatically generate accurate connector shapes within milliseconds, without the need to create and maintain family files for each specification in advance. In actual HVAC BIM modeling projects, a floor containing hundreds of connectors would require dozens of family files of different specifications to be pre-configured and loaded and matched one by one in the project if a traditional family library solution is used. However, with the method of this invention, all connectors can be calculated instantly at the time of creation, which greatly simplifies the project configuration process and eliminates the problem of connector generation failure due to missing family libraries.
[0105] 2. This invention employs a mathematically rigorous double-tangent arc fitting algorithm: This invention uses a closed-form solution to achieve double-tangent arc fitting. Given two endpoints and their respective tangent direction vectors, it calculates the plane normal through cross product, finds the center of the circle by finding the intersection of radial lines, determines the sweep direction through scalar triple product, calculates the half-angle using atan2, and finds the midpoint of the arc through Rodrigues rotation. These five mathematical operations accurately construct a circular arc transition curve that satisfies both endpoint position and tangent direction constraints. Compared with existing straight-segment connection schemes, double-tangent arc fitting ensures the tangent continuity (G1 continuity) of the connector contour at the port, resulting in a smooth and natural transition curve without sharp corners or broken lines. Compared with traditional iterative approximation schemes, the closed-form solution requires no iterative loops, maintains constant computational load, and provides accurate results without convergence issues. Compared with traditional hard-coded branching schemes, the same algorithm is applicable to any intersection angle, eliminating the need to write different processing logic for different angles such as 90 degrees and 45 degrees, resulting in concise code that is easy to extend. The core mathematical operations of the algorithm in this invention (cross product, dot product, scalar triple product, atan2, Rodriguez rotation) are all standard vector operations, which are highly efficient and can maintain a millisecond-level response speed when processing hundreds of connectors in batches.
[0106] 3. This invention adopts a highly efficient and stable multi-port connector shape combination: This invention uses an anchor point decomposition strategy to process multi-port connectors (tees, crosses, and multi-ports), decomposing the N-port problem into N-1 pairs of two-port sub-problems with the first port as the anchor point. Each pair of sub-problems independently performs double tangent arc fitting to generate sub-contours, and then combines all sub-contours into a composite polyline. The advantages of this strategy are: (1) Algorithm reuse - the core algorithm of the two-port connector can be fully reused in multi-port connectors, without the need to write independent logic for 3-port, 4-port, and 5-port connectors; (2) Computational stability - avoids the problem of calculation failure or inaccurate results that may occur when Boolean union operation is used to process complex cross-sections (such as the chamfer transition of rectangular pipes). Each sub-contour is calculated independently and accurately; (3) Scalability - the increase in the number of ports only linearly increases the amount of computation (one more two-port algorithm is executed for each additional port), and does not cause the algorithm complexity to increase sharply. In actual engineering, a four-port connector (4 ports) only needs to perform two-port contour generation 3 times. The total amount of computation is about 3 times that of a single bend, and it is still completed in milliseconds.
[0107] 4. This invention achieves intelligent and automatic embedding of HVAC engineering knowledge: During the connection generation process, this invention automatically executes guide vane determination. Through a seven-step condition chain (component classification → number of ports → pipe existence → rectangular cross-section → size matching → minimum size threshold → centerline perpendicularity), the design specification of "large cross-section elbows of rectangular ducts requiring guide vanes" in HVAC engineering is encoded into executable algorithmic logic. When all conditions are met, the system automatically marks the connection as an "elbow with guide vanes" and displays it in a prominent yellow color, allowing designers to quickly identify key nodes requiring guide vanes without manual inspection. When the pipe is edited, causing the conditions to no longer be met, the system automatically reverts to the default state, ensuring that the markings always match the actual geometry. This mechanism deeply integrates engineering domain knowledge with geometric algorithms, improving the engineering accuracy and reviewability of the BIM model and reducing rework caused by missing guide vanes during design reviews.
[0108] 5. Robust handling of vertical pipe intersection scenarios in this invention: This invention effectively solves the problem of abnormal connector shape when vertical pipes (rises) intersect with horizontal pipes by using vertical pipe determination (absolute value of the dot product of the direction vector and the Z-axis > 1-ε) and a cross-sectional profile straight-through strategy. When the pipe to which the port belongs is detected to be a vertical pipe, the algorithm skips the XY plane projection and double tangent arc fitting steps, directly taking the cross-sectional profile polygon of the pipe at that port as the two-dimensional profile of the connector, and using the difference in Z-elevation between the two ends as the stretching thickness. This strategy avoids the calculation divergence or profile collapse problem caused by the projection of the direction vector onto the XY plane degenerating into a zero vector, ensuring that the connector shape is correctly generated under any elevation combination. At the same time, the acquisition of the cross-sectional profile polygon supports two cross-sectional types: rectangular (four vertices) and circular (approximately a regular octagon), without the need to write additional shape processing logic for vertical pipes. Attached Figure Description
[0109] Figure 1 This is a flowchart of the BIM connector 3D contour generation method based on pipe port geometric parameters according to the present invention. Detailed Implementation
[0110] The present invention will be further described below with reference to the accompanying drawings and specific embodiments.
[0111] Please see the appendix Figure 1 A method for generating 3D contours of BIM connectors based on pipe port geometric parameters includes the following steps:
[0112] Step 1: Obtain all pipe port information associated with the connector.
[0113] Step 1 is used to extract and verify the port data of all associated pipes from the connector properties, providing input for subsequent geometric calculations. The entire process of Step 1 is divided into three stages: port data reading, deserialization verification, and geometric parameter extraction.
[0114] Step 1 includes the following sub-steps:
[0115] Step 11: Port data reading.
[0116] Specifically, when creating a connector, the port information of all associated pipes is recorded. Each port information (FittingPort) contains two fields: pipe instance ID (m_iInstId, int64 type, uniquely identifying the pipe entity to which the port belongs) and endpoint type (m_eType, enumeration type, indicating whether the port is located at the start point eStart or the end point eEnd of the pipe).
[0117] Port data is stored as a serialized string in the connector's properties, in the format "Instance ID:Endpoint Type", with multiple ports separated by semicolons. For example, "12345:eStart;67890:eEnd;11111:eStart" indicates that the connector is associated with 3 pipe ports.
[0118] Step 12: Port deserialization and verification.
[0119] Specifically, the serialized string is parsed according to the format agreed upon in step 11: first, each port entry is separated by a semicolon, then the instance ID and endpoint type are separated by a colon; subsequently, the instance ID is restored to the corresponding pipe object through the pipe instance ID mapping table, and finally, the ports of each pipe are organized into a list of port objects, and three layers of validation are performed:
[0120] ① Quantity verification: The number of ports on the connector must be between 2 and 5. If there are fewer than 2 ports, it is not considered a connector (a single pipe does not require a connector). If there are more than 5 ports, it is considered abnormal data, an error log is recorded, and the connector is skipped.
[0121] ② Deduplication check: Sort by pipe instance ID and deduplicate to ensure that the same pipe is not connected to the same connector repeatedly.
[0122] The existing port structure has implemented equality comparison and sorting operators, and can directly use the standard library to sort and deduplicate pipe instance IDs.
[0123] ③ Existence verification: Query the BIM model database based on the pipeline instance ID to confirm that each pipeline entity exists and has not been deleted.
[0124] For large BIM models containing a large number of components, the invention patent application with publication number CN121350030A discloses a fast search method and system for components and their relationships based on the BIM model. The spatial search engine technology of this fast search method can be used to query pipe entities, accelerating the spatial positioning and querying of pipe entities with a time complexity of O(1).
[0125] Verification result processing: Extract geometric parameters for ports that pass all verifications, i.e., execute step 13; record an exception log for ports that fail verification (i.e., fail verification at any layer) and remove them from the port object list; if the number of ports remaining after verification is less than 2, terminate the contour generation of the connector.
[0126] Step 13: Obtain the geometric parameters of the pipe port.
[0127] Specifically, for each valid port (i.e., a port that passes all checks), the following core geometric parameters are extracted from the associated pipe entity:
[0128] Insertion point coordinates (ptPort): These are the three-dimensional coordinates of the connection point on the pipe entity.
[0129] End direction vector (vecPort): This is the normalized tangent direction of the pipe entity at its port. The end direction vector is a three-dimensional direction vector.
[0130] Cross-sectional width (dWidth): This refers to the cross-sectional width (rectangular pipe) or diameter (circular pipe) of the pipe entity.
[0131] Cross-sectional height (dHeight): This refers to the cross-sectional height (rectangular pipe) or diameter (circular pipe) of the pipe entity.
[0132] Bottom elevation (dElevation): The Z-coordinate of the centerline of the pipe entity at this port.
[0133] Insertion depth calculation: The connection point is not located at the geometric end of the pipe, but is offset inward by an insertion depth to simulate the engineering structure of the connector actually being inserted into the pipe.
[0134] The calculation rules for insertion depth are as follows: For cold air ducts, insertion depth = cross-sectional width dWidth × 1.5; For ordinary ducts (excluding cold air ducts), insertion depth = cross-sectional width dWidth; The upper limit of insertion depth = min(InsertDepth, duct length / 2) to avoid overlapping insertion depths at both ends.
[0135] Preferably, the insertion point coordinates can be obtained through the GetInsertPoint(eType) method of the existing pipe, and the end direction vector can be obtained through the GetEndVector(eType) method of the existing technology (the starting point is taken in the opposite direction and the ending point is taken in the positive direction) to ensure that the end direction vector always points to the outside of the pipe (i.e., away from the connector).
[0136] Step 2: Determine if it is a vertical pipe. If yes, use the straight-through strategy for the cross-sectional profile. If no, proceed to step 3.
[0137] Step 2 is used to identify vertical pipe (rise) scenarios. A cross-sectional profile straight-through strategy is adopted for vertical pipes to avoid degradation of subsequent projection algorithms.
[0138] Step 2 includes the following sub-steps:
[0139] Step 21: Determine if it is a vertical pipe. If yes, proceed to step 22. If no, that is, the pipe is a non-vertical pipe (the pipe whose end direction vector is not parallel to the Z-axis), proceed to step 3.
[0140] Specifically, the perpendicularity of the end direction vector of each port is determined: the dot product of the end direction vector and the Z-axis unit vector kZAxis = (0, 0, 1) is calculated. If the absolute value of the dot product is greater than 1 - 1e-6 (i.e. the end direction vector is almost parallel to the Z-axis), then the pipe to which the port belongs is determined to be a vertical pipe.
[0141] The mathematical expression of its judgment logic is as follows:
[0142] if |vecPort · kZAxis| > 1 - ε:
[0143] The pipe is a vertical pipe.
[0144] Where kZAxis = (0, 0, 1), ε = 1e-6.
[0145] Step 22: Straighten the vertical pipe cross-section profile, then proceed to Step 5.
[0146] For vertical pipes, their directional projection on the XY plane degenerates into a single point, making it impossible to use the projection and double-tangent arc fitting algorithms in subsequent steps 3 and 4. Therefore, a cross-sectional profile straight-through strategy is adopted, skipping steps 3 and 4 and proceeding directly to step 5.
[0147] Step 22 includes the following sub-steps:
[0148] Step 221: Directly obtain the cross-sectional profile polygon of the pipe at the port (GetEndProfile): If the pipe is a rectangular pipe, return the four vertices of the rectangle; if the pipe is a circular pipe, return a regular octagonal approximation circle (the 8 vertices are evenly distributed on the circumference of the approximation circle).
[0149] Step 222: Take the smaller difference between the Z-elevations of the two ports as the bottom elevation. Its mathematical expression is: dBotEle = min(ptPort_first.Z, ptPort_second.Z).
[0150] Step 223: Take the absolute value of the difference between the Z-elevation of the two ports as the stretch thickness. Its mathematical expression is: dThick = |ptPort_first.Z - ptPort_second.Z|.
[0151] Step 224: Directly use the polygon of the vertical pipe cross-section profile as the two-dimensional profile of the connector, add the bottom elevation of step 222 and the stretching thickness of step 223 to form a three-dimensional shape, and proceed to step 5 to assemble the profile.
[0152] This cross-sectional profile straight-through strategy avoids the problem of end direction vector projection degradation, ensuring the correct shape of the connector when vertical and horizontal pipes intersect.
[0153] Step 3: Calculate the cross-sectional edge segments of each port.
[0154] Step 3 is used to convert the three-dimensional direction vector and cross-sectional dimensions of the non-perpendicular pipe into two-dimensional cross-sectional edge segments on the XY plane, providing endpoints and tangent directions for subsequent transition curve fitting.
[0155] Step 3 includes the following sub-steps:
[0156] Step 31: Project the end direction vector of the port onto the XY plane.
[0157] Specifically, for the first port, the Z component of the port's end direction vector is removed and projected onto the XY plane to obtain the planar direction vector, which is mathematically expressed as:
[0158] vecXY = vecPort - (vecPort · kZAxis) × kZAxis
[0159] vecXY = normalize(vecXY)
[0160] For the second port, remove the Z component from the end direction vector of the port, project it onto the XY plane, and then invert the projected plane direction vector (Negate), because its direction points inwards to the inside of the connector. Its mathematical expression is:
[0161] vecPortSec_XY = -normalize(vecPortSec - (vecPortSec · kZAxis) ×kZAxis)
[0162] Step 32: Calculate the direction of the cross section normal.
[0163] Specifically, the normal vector in the width direction of the cross section is obtained by taking the cross product of the Z-axis unit vector and the plane direction vector. Its mathematical expression is as follows:
[0164] vecNormal = kZAxis × vecXY
[0165] The normal vector is perpendicular to the direction of the non-perpendicular pipe, lies in the XY plane, and points towards the cross-sectional width direction of the non-perpendicular pipe.
[0166] Step 33: Construct the cross-sectional edge segments.
[0167] With the insertion point as the center, extend the cross-section width to both sides along the direction of the normal vector by half, constructing the cross-section edge segments, which can be mathematically expressed as:
[0168] segPort = (ptPort + dWidth / 2 × vecNormal, ptPort - dWidth / 2 × vecNormal).
[0169] The cross-sectional edge segment is the width edge of the pipe at that port, located on the XY plane.
[0170] Step 34: Record elevation information.
[0171] Specifically, the Z-coordinate of the starting point of the edge segment of each port section is recorded as the elevation of that port, which is mathematically represented as: dElePort = ptPort.Z.
[0172] The Z-coordinate of the cross-section edge segment is then set to zero, so that subsequent calculations are performed on a pure two-dimensional plane, and three-dimensional information is managed separately through elevation parameters.
[0173] Step 4: Use the double tangent arc fitting algorithm to generate the transition curve.
[0174] The transition curve generated in step 4 is a circular arc (hereinafter referred to as "fitted circular arc"), defined as: a unique circular arc located in the same plane, passing through two endpoints ptFirst and ptSecond, and whose tangent directions at the two endpoints are tangent to vecFirst and vecSecond respectively, used to form a smooth transition between the cross-sectional edge segments of the two pipe ports.
[0175] Step 4 is the core algorithm of this invention, used to generate a smooth transition curve between the cross-sectional edge segments of the two ports. The FitEndTangent algorithm is employed, given two endpoints (ptFirst, ptSecond) and their respective tangent direction vectors (vecFirst, vecSecond), to find the unique arc satisfying the following constraints: the arc passes through ptFirst and its tangent direction at ptFirst is vecFirst; the arc passes through ptSecond and its tangent direction at ptSecond is vecSecond. This FitEndTangent algorithm uses a closed-form solution, eliminating the need for iterative approximation.
[0176] Step 4 includes the following sub-steps:
[0177] Step 41: Calculate the plane normal.
[0178] First, determine the tangent direction vectors of the two pipe segments at their connection endpoints. Let vecFirst be the tangent direction vector of the first pipe segment at endpoint ptFirst, and vecSecond be the tangent direction vector of the second pipe segment at endpoint ptSecond. They are calculated as follows:
[0179] - If it is a straight pipe, take the axial direction vector from the start point to the end point of the pipe and normalize it, and use it as the tangent direction vector of that end point;
[0180] - If it is an arc pipe, let the center of the arc be C, the normal of the plane be n, and the connecting endpoint be P. Calculate the radius vector r = P − C, and take the tangent direction vector at the endpoint t = normalize(n × r), whose direction is consistent with the direction of the arc from the starting point to the ending point.
[0181] Subsequently, by taking the cross product of the tangent direction vectors at the two endpoints, the normal vector of the plane containing the fitted arc (i.e., the fitted arc mentioned above) can be determined. Its mathematical expression is: vecNormal = normalize(vecFirst × vecSecond).
[0182] If the length of the cross product result is less than 1e-6 (i.e., the two tangent direction vectors are approximately parallel), it degenerates into a straight line connection, and arc fitting is not performed. Its mathematical expression is:
[0183] if |vecFirst × vecSecond| < ε:
[0184] Returns the line segment TSegment(ptFirst, ptSecond).
[0185] Step 42: Calculate the radial vector.
[0186] In the plane of the arc, the radial vectors (perpendicular to the tangent at the endpoints and pointing towards the center of the arc) at the two endpoints of the arc are mathematically expressed as follows:
[0187] vecRadialFirst = vecFirst × vecNormal
[0188] vecRadialSecond = vecSecond × vecNormal.
[0189] Two radial lines are constructed based on the radial vectors at the two endpoints of the arc. Their mathematical expression is as follows:
[0190] lineRadialFirst = (ptFirst, ptFirst + vecRadialFirst)
[0191] lineRadialSecond = (ptSecond, ptSecond + vecRadialSecond).
[0192] Step 43: Find the center of the arc.
[0193] Specifically, after extending the two radial lines in step 42, find their intersection point. This intersection point is the center of the arc, which can be mathematically expressed as:
[0194] ptCenter = CalcInterPt(lineRadialFirst, lineRadialSecond,emExtendBoth)
[0195] Here, emExtendBoth represents the method to find the intersection of two line segments that can be extended in any direction.
[0196] Step 44: Calculate the arc sweep half-angle from the first endpoint to the second endpoint of the arc.
[0197] Step 44 includes the following sub-steps:
[0198] Step 441: Calculate the two radius vectors, which are mathematically expressed as: vecR1 = ptFirst - ptCenter, vecR2 = ptSecond - ptCenter.
[0199] Step 442: Calculate the signed area (by determining the sweep direction through the scalar triple product), which is mathematically expressed as: dArea = vecNormal · (vecR1 × vecR2).
[0200] The sign of the scalar triple product determines whether the arc sweeps clockwise or counterclockwise.
[0201] Step 443: Calculate the half-angle of the arc sweep, which is mathematically expressed as: dHalfAngle = 0.5 × atan2(dArea, vecR1 · vecR2).
[0202] Preferably, when calculating the half-angle of the arc sweep, the atan2 function is used instead of acos, which can correctly handle the full angle range (0~360 degrees) and retain the direction information.
[0203] Step 45: Use Rodriguez rotation to find the midpoint of the arc.
[0204] Specifically, using the half-angle dHalfAngle of the arc sweep obtained in step 443 as the rotation angle, the first radius vector vecR1 is rotated around the normal vector vecNormal by this half-angle of the arc sweep using the Rodrigues rotation formula, to obtain the radius vector at the midpoint of the arc, which is mathematically expressed as:
[0205] vecHalf = vecR1 × cos(dHalfAngle) + (vecNormal × vecR1) × sin(dHalfAngle)
[0206] ptMid = ptCenter + vecHalf
[0207] Since the total sweep angle of the fitted arc from ptFirst to ptSecond is 2 × dHalfAngle, the radius vector that reaches the midpoint of the arc after rotating vecR1 around vecNormal by dHalfAngle is the same.
[0208] Step 46: Construct a three-point arc segment by assembling the starting point ptFirst, the midpoint ptMid, and the ending point ptSecond into a three-point arc segment. Its mathematical expression is: result = TSegment(ptFirst, ptMid, ptSecond).
[0209] This three-point arc segment fully defines the smooth transition curve connecting the endpoints of the two port sections. When ptMid is valid, it represents an arc passing through the three points; when ptMid is invalid (parallel degradation case), it represents a straight line segment.
[0210] Step 47: Perform double tangent arc fitting on both endpoints of the cross-section edge segment to generate transition curves on both sides, the mathematical expression of which is:
[0211] segLeft = FitEndTangent(segFirst.Start, segSecond.Start,vecPortFirst_XY, vecPortSec_XY)
[0212] segRight = FitEndTangent(segFirst.End, segSecond.End, vecPortFirst_XY, vecPortSec_XY).
[0213] The transition curves on both sides connect the left and right endpoints of the cross-section edge segment, respectively.
[0214] Step 5: Assemble the closed two-dimensional profile and determine the three-dimensional stretching parameters.
[0215] Step 5 assembles the calculated cross-sectional edge segments and transition curves on both sides into a complete closed polyline, and adds three-dimensional stretching information.
[0216] Step 5 includes the following sub-steps:
[0217] Step 51: Assemble the closed contour.
[0218] Connect the section edge segment from step 3 and the transition curves on both sides from step 4 sequentially to form a closed polyline, the mathematical expression of which is:
[0219] polyline = LinkSegmentsToPoly(segFirst, segLeft, segSecond, segRight)
[0220] Wherein: segFirst is the cross-sectional edge segment of the first port; segLeft is the transition curve (double tangent arc) at the left endpoint of the cross-sectional edge segment; segSecond is the cross-sectional edge segment of the second port; and segRight is the transition curve (double tangent arc) connecting the right endpoint of the cross-sectional edge segment. The four segments are connected end to end to form a closed two-dimensional contour.
[0221] Step 52: Determine the three-dimensional stretching parameters.
[0222] Specifically, the bottom elevation, top elevation, and tensile thickness of the connector are determined from the Z coordinates (elevations) of the side segments of the two port sections.
[0223] Let the elevation of the first pipe port be dEleFirst, and the elevation of the second pipe port be dEleSecond, then:
[0224] - Bottom elevation dBotEle = min(dEleFirst, dEleSecond)
[0225] - Top elevation dTopEle = max(dEleFirst, dEleSecond)
[0226] - Stretch thickness dThick = dTopEle − dBotEle
[0227] Set the 3D properties of a closed polyline:
[0228] polyline.SetElevation(dBotEle) / / Bottom elevation
[0229] polyline.SetThick(dThick) / / Stretch thickness
[0230] Finally, the two-dimensional closed contour is stretched along the Z-axis from the bottom elevation dBotEle to dBotEle + dThick (i.e., the top elevation dTopEle), forming the three-dimensional solid shape of the connector.
[0231] In the common case where two pipes are at the same elevation (i.e., dEleFirst == dEleSecond), the stretch thickness dThick is zero, and the connector appears as a planar outline. In actual rendering, the thickness of the connector can be assigned by the cross-sectional height of the pipe.
[0232] Step 53: Merging of vertical pipe straight-through cases.
[0233] For the case where the vertical pipe cross-section profile is determined to be straight in step 2, since the cross-section of the vertical pipe itself is a closed polygon located in the horizontal plane, there is no need to perform the cross-section edge segment extraction in step 3 and the double tangent arc fitting in step 4. The cross-section polygon is directly used as the closed polyline mentioned in step 51. Then, step 52 is also performed to determine the bottom elevation dBotEle, top elevation dTopEle, and stretching thickness dThick according to the elevations of the two ports, and stretching along the Z-axis to form a three-dimensional solid. That is, the line segment assembly process in step 51 is replaced by "directly using the vertical pipe cross-section polygon", and the stretching parameter calculation and three-dimensional stretching process in step 52 are reused.
[0234] Step 6: Anchor point decomposition and composite assembly of multi-port connectors.
[0235] Steps 2 to 5 are the algorithm for generating the contour of a two-port connector. When the number of ports associated with a connector is greater than 2 (such as tees, crosses, and multi-ports), an anchor point decomposition strategy is used to decompose the multi-port problem into multiple two-port sub-problems, thereby generating the contour of the multi-port connector through algorithm reuse.
[0236] Step 6 includes the following sub-steps:
[0237] Step 61: Anchor point selection.
[0238] Use the first port (portFirst) of all ports as the anchor point.
[0239] The anchor point selection strategy is to take the first one according to the port input order to ensure the determinism of the result.
[0240] Step 62: Decompose in pairs.
[0241] Take the anchor point port and each of the remaining ports, and perform steps 2 to 5 respectively to obtain N-1 independent two-dimensional closed contours, denoted as sub-contours, whose mathematical expression is:
[0242] for i = 1 to N-1:
[0243] poly_i = ConnectTwoPort(portFirst, portList[i])
[0244] Each sub-profile describes the shape of the connector between the anchor port and the i-th port.
[0245] Step 63: Standardize the elevation range.
[0246] Traversing all sub-contours, we take the global minimum bottom elevation and the global maximum top elevation. Its mathematical expression is as follows:
[0247] dBotEle_global = min(poly_i.dBotEle for all i)
[0248] dTopEle_global = max(poly_i.dTopEle for all i).
[0249] Step 64: Combine into a composite contour.
[0250] After projecting all sub-contours onto the XY plane, the resulting set of sub-polylines, which forms a compound polyline, can be mathematically expressed as:
[0251] plResult.m_subPolys = [project_to_XY(poly_i) for all i]
[0252] plResult.SetElevation(dBotEle_global)
[0253] plResult.SetThick(dTopEle_global - dBotEle_global)
[0254] A composite polyline consists of multiple independent, closed sub-polylines, each describing a branch shape of the connector. In 3D display, each sub-polyline is stretched along the Z-axis to form multiple branch bodies of the connector. This operation avoids the complexity and instability of Boolean union operations while accurately representing the spatial morphology of multi-port connectors.
[0255] As an optional optimization implementation, a Boolean union operation can be performed on multiple sub-polylines to merge overlapping areas into a single profile, thereby obtaining a more accurate connector shape.
[0256] Step 7: Automatic determination and pattern marking of guide vanes.
[0257] Step 7 is used to automatically determine whether the rectangular duct elbow needs to be equipped with guide vanes, and write the determination result into the connector properties.
[0258] Step 7 includes the following sub-steps:
[0259] Step 71: Seven-step condition chain determination.
[0260] The generated connectors are checked in the following order. If any condition is not met, the check is terminated and "No guide vanes needed" is returned. Here, "generated connectors" refers to the complete component object obtained by merging and assembling (Boolean union) multiple branch bodies formed in the aforementioned steps. Each branch body corresponds to an associated pipe port.
[0261] Condition ①, Component Classification Check: The component classification ID of the connector is duct elbow (e.g., INDP_IDX_WindDuctElbow = 50073), and only duct elbows require guide vanes. This classification ID is determined and written into the connector attributes according to the type of pipe being connected and the geometry of the connector when the connector is generated, based on a preset component classification table. It is read from the connector attributes during the judgment process.
[0262] Condition ②, Port Quantity Check: The number of ports is exactly 2. The guide vanes are only applicable to two-port bends.
[0263] Condition ③, Existence check of pipelines: Both related pipeline entities exist and are accessible, ensuring data integrity.
[0264] Condition ④, Rectangular cross-section inspection: Both pipes have rectangular cross-sections (not circular). Circular duct elbows do not require guide vanes.
[0265] Condition ⑤, Cross-sectional dimension matching check: The cross-sectional dimensions of the two pipes must match—either in the same direction (dWidth1 == dWidth2 and dHeight1 == dHeight2) or cross-matching (dWidth1 == dHeight2 and dHeight1 == dWidth2), with a tolerance of 1e-6, to ensure that the cross-sections at both ends of the elbow are consistent. Where dWidth1 / dHeight1 is the cross-sectional width / height of the first pipe, and dWidth2 / dHeight2 is the cross-sectional width / height of the second pipe.
[0266] Condition 6, Minimum size threshold check: The first pipe must have at least one cross-sectional dimension ≥ 500mm. HVAC engineering rules: Small cross-section elbows do not require guide vanes.
[0267] Condition ⑦, Centerline Perpendicularity Check: The centerline direction vectors of the two pipes are perpendicular to each other, i.e., |vec1 · vec2| ≤ 1e-6. Guide vanes are only applicable to 90-degree bends. Here, vec1 and vec2 are the unit vectors of the centerline directions of the first and second pipes, respectively.
[0268] If all seven conditions above are met, it is determined that the connector needs to be equipped with guide vanes.
[0269] Step 72: Apply style tags to the connectors that require guide vanes.
[0270] The style tags include:
[0271] ① Set the connector type attribute (INDP_ATTR_MECH_LX) to "Elbow with guide vanes".
[0272] ② Set the display color of the connector to yellow (RGB: 1.0, 1.0, 0.0) to make it stand out in the 3D view.
[0273] ③ Set the guide vane flag (m_bGuideVaneStyle = true).
[0274] Step 73: Reverse recovery.
[0275] When the geometry of a connector changes (e.g., the cross-sectional dimensions change after the pipe is edited), causing the guide vane conditions to no longer be met, the system automatically performs a reverse recovery. The reverse recovery process is as follows: restore the connector's type attributes to their default values; restore the connector's display color to the system default color; and clear the guide vane flag (m_bGuideVaneStyle = false). This mechanism ensures that the guide vane flag always matches the actual geometry of the connector.
[0276] Step 8: Return the 3D contour result of the connector.
[0277] The generated 3D contour polyline data of the connector (including bottom elevation, extrusion thickness, and sub-polyline set) is returned to the caller for display by the 3D rendering engine. Simultaneously, the result of the guide vane determination (i.e., whether guide vanes need to be set) is returned for attribute annotation and color rendering.
[0278] ① Results processing: Extract key information from the final generated connectors—connector type (elbow / tee / cross / multi-way), number of ports, polyline data of the three-dimensional profile (bottom elevation, tensile thickness, sub-polyline set), and guide vane determination results.
[0279] ② Handling of anomalies and empty results: If the port data is abnormal and the contour generation fails, an empty result is returned and an error log is recorded, which does not affect the generation of other connectors; if an anomaly occurs in the geometric calculation (such as direction vector degradation or cross-sectional dimension being zero), the connection point is skipped and the anomaly information is recorded.
[0280] The above are merely preferred embodiments of the present invention and are not intended to limit the scope of protection of the invention. Therefore, any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A method for generating 3D contours of BIM connectors based on pipe port geometric parameters, characterized in that: Includes the following steps: Step 1: Obtain all pipe port information associated with the connector; Step 2: Determine if it is a vertical pipe. If yes, use the straight-through strategy for the cross-sectional profile. If no, proceed to step 3. Step 3: Calculate the cross-sectional edge segments at each port; Step 4: Generate transition curves using the double tangent arc fitting algorithm; Step 5: Assemble the closed two-dimensional profile and determine the three-dimensional stretching parameters; Step 6: Anchor point decomposition and composite assembly of multi-port connectors; Step 7: Automatic determination and pattern marking of guide vanes; Step 8: Return the 3D contour result of the connector.
2. The method for generating three-dimensional contours of BIM connectors based on pipe port geometric parameters according to claim 1, characterized in that: Step 1 includes the following sub-steps: Step 11: Read port data; When creating a connector, record the port information of all associated pipes. Each port information contains two fields: pipe instance ID and endpoint type. Step 12: Port deserialization and verification; The serialized string is deserialized to restore a list of port objects, and then three layers of validation are performed: ① Quantity verification: The number of ports on the connector must be between 2 and 5; if there are fewer than 2 ports, it is not considered a connector; if there are more than 5 ports, it is considered abnormal data, an error log is recorded, and the connector is skipped. ② Deduplication check: Sort by pipeline instance ID and remove duplicates; ③ Existence verification: Query the BIM model database based on the pipe instance ID to confirm that each pipe entity exists and has not been deleted; Port data is stored as a serialized string in the connector's properties, in the format "instance ID:endpoint type", with multiple ports separated by semicolons; Verification result processing: Extract geometric parameters for ports that pass all verifications, i.e., execute step 13; record an exception log for ports that fail verification and remove them from the port object list; If the number of remaining ports after verification is less than 2, the outline generation of the connector will be terminated. Step 13: Obtain the geometric parameters of the pipe port; For each valid port, extract the following core geometry parameters from the pipe entity associated with it: Insertion point coordinates: that is, the three-dimensional coordinates of the connection point on the pipe entity; End direction vector: that is, the normalized tangent direction of the pipe entity at this port; The end direction vector is a three-dimensional direction vector; Cross-sectional width dWidth: the width or diameter of the pipe body; Cross-sectional height dHeight: This refers to the cross-sectional height or diameter of the pipe entity. Bottom elevation dElevation: the Z coordinate of the centerline of the pipe entity at this port; The calculation rules for insertion depth InsertDepth are as follows: For cold air ducts, insertion depth = cross-sectional width dWidth × 1.5; for ordinary ducts, insertion depth = cross-sectional width dWidth; the upper limit of insertion depth = min(InsertDepth, duct length / 2).
3. The method for generating three-dimensional contours of BIM connectors based on pipe port geometric parameters according to claim 1, characterized in that: Step 2 includes the following sub-steps: Step 21: Determine if it is a vertical pipe. If yes, proceed to step 22. If no, that is, the pipe is not a vertical pipe, proceed to step 3. For each port, determine the perpendicularity of the end direction vector: calculate the dot product of the end direction vector and the Z-axis unit vector kZAxis = (0, 0, 1). If the absolute value of the dot product is greater than 1 - 1e-6, then the pipe to which the port belongs is determined to be a vertical pipe. Step 22: Straighten the vertical pipe cross-section profile, then proceed to Step 5.
4. The method for generating three-dimensional contours of BIM connectors based on pipe port geometric parameters according to claim 3, characterized in that: In step 21, Step 22 includes the following sub-steps: Step 221: Directly obtain the cross-sectional outline polygon of the pipe at the port: if the pipe is rectangular, return the four vertices of the rectangle; if the pipe is circular, return an approximate octagonal circle. Step 222: Take the smaller difference between the Z elevations of the two ports as the bottom elevation; Step 223: Take the absolute value of the difference between the Z elevations of the two ports as the stretching thickness; Step 224: Directly use the polygon of the vertical pipe cross-section profile as the two-dimensional profile of the connector, add the bottom elevation of step 222 and the stretching thickness of step 223 to form a three-dimensional shape, and proceed to step 5 to assemble the profile.
5. The method for generating three-dimensional contours of BIM connectors based on pipe port geometric parameters according to claim 1, characterized in that: Step 3 includes the following sub-steps: Step 31: Project the end direction vector of the port onto the XY plane; For the first port, the Z component of the port's end direction vector is removed and projected onto the XY plane to obtain the planar direction vector; for the second port, the Z component of the port's end direction vector is removed and projected onto the XY plane, and the projected planar direction vector is inverted. Step 32: Calculate the direction of the normal to the cross section; The normal vector in the width direction of the cross section is obtained by taking the cross product of the Z-axis unit vector and the plane direction vector. Step 33: Construct the cross-sectional edge segments; With the insertion point as the center, extend the cross-section width to both sides along the direction of the normal vector by half to construct the cross-section edge segment; Step 34: Record elevation information; Record the Z-coordinate of the starting point of the edge segment of each port section as the elevation of that port, and then reset the Z-coordinate of the edge segment of the section to zero.
6. The method for generating three-dimensional contours of BIM connectors based on pipe port geometric parameters according to claim 1, characterized in that: Step 4 includes the following sub-steps: Step 41: Calculate the plane normal; The normal vector of the plane containing the arc is determined by the cross product of the two tangent direction vectors; if the length of the cross product result is less than 1e-6, it degenerates into a straight line connection and no arc fitting is performed. Step 42: Calculate the radial vector; In the plane of the arc, calculate the radial vectors at the two endpoints of the arc; construct two radial lines based on the radial vectors at the two endpoints of the arc. Step 43: Find the center of the arc; Extend the two radial lines in step 42 and find their intersection point. This intersection point is the center of the arc. Step 44: Calculate the arc sweep half-angle from the first endpoint to the second endpoint; Step 44 includes the following sub-steps: Step 441: Calculate the two radius vectors; Step 442: Calculate the signed area; Step 443: Calculate the half-angle of the arc sweep; Step 45: Use Rodriguez rotation to find the midpoint of the arc; Step 46: Construct a three-point arc segment; Assemble the starting point ptFirst, the midpoint ptMid, and the ending point ptSecond into a three-point arc segment. When ptMid is valid, it represents an arc passing through the three points; when ptMid is invalid, it represents a straight line segment. Step 47: Perform double tangent arc fitting on both ends of the cross-section edge segment to generate transition curves on both sides; the transition curves on both sides connect the left and right ends of the cross-section edge segment respectively.
7. The method for generating three-dimensional contours of BIM connectors based on pipe port geometric parameters according to claim 1, characterized in that: Step 5 includes the following sub-steps: Step 51: Assemble the closed contour; Connect the section edge line segment from step 3 and the transition curves on both sides from step 4 in sequence to form a closed polyline. Step 52: Determine the three-dimensional stretching parameters; Determine the bottom elevation and stretch thickness of the connector from the Z coordinates of the two port section edge segments; set the three-dimensional properties of the closed polyline; stretch the two-dimensional closed profile along the Z-axis from the bottom elevation dBotEle to dBotEle + thick to form the three-dimensional solid shape of the connector.
8. The method for generating three-dimensional contours of BIM connectors based on pipe port geometric parameters according to claim 1, characterized in that: Step 6 includes the following sub-steps: Step 61: Anchor point selection; select the first port from all ports as the anchor point; Step 62: Decompose in pairs; take the anchor point port and each of the other ports, and perform steps 2 to 5 respectively to obtain N-1 independent two-dimensional closed contours, which are denoted as sub-contours; Step 63: Unify the elevation range; traverse all sub-contours and take the global minimum bottom elevation and the global maximum top elevation; Step 64: Combine into a composite contour; after projecting all sub-contours onto the XY plane, they are used as a set of sub-polylines for the composite polyline.
9. The method for generating three-dimensional contours of BIM connectors based on pipe port geometric parameters according to claim 1, characterized in that: Step 7 includes the following sub-steps: Step 71: Seven-step condition chain determination; For the generated connectors, check them in the following order, judging each condition in sequence. If any condition is not met, the check will terminate and return "No guide vanes needed"; Condition ①, Component classification check: The component classification ID of the connector is duct elbow; Condition ②, Port Count Check: The number of ports is exactly 2; Condition ③, Existence check of pipelines: Both associated pipeline entities exist and are accessible; Condition ④, Rectangular cross-section inspection: Both pipes have rectangular cross-sections; Condition ⑤, Cross-sectional dimension matching check: The cross-sectional dimensions of the two pipes match—matching in the same direction or crossing each other, with a tolerance of 1e-6; Condition 6, Minimum size threshold check: The first pipe must have at least one cross-sectional dimension ≥ 500mm; Condition 7, Centerline Perpendicularity Check: The centerline direction vectors of the two pipes are perpendicular to each other; If all seven conditions above are met, it is determined that the connector needs to be equipped with guide vanes. Step 72: For connectors requiring guide vanes, apply style tags; style tags include: ① Set the type attribute of the connector to "elbow with guide vanes"; ② Set the display color of the connector to yellow; ③ Set the guide vane marker position; Step 73: Reverse recovery; When the geometry of the connector changes, causing it to no longer meet the conditions for the guide vane, the system automatically performs reverse recovery. The reverse recovery process is as follows: restore the connector's type attribute to the default value; restore the connector's display color to the system default color; and clear the guide vane flag.
10. The method for generating three-dimensional contours of BIM connectors based on pipe port geometric parameters according to claim 1, characterized in that: In step 8, the polyline data of the generated three-dimensional contour of the connector is returned to the caller for display by the three-dimensional rendering engine; at the same time, the determination result of the guide vane is returned for attribute annotation and color rendering. ① Results processing: Extract key information from the final generated connectors—connector type, number of ports, polyline data of the three-dimensional profile, and determination results of the guide vanes; ② Handling of anomalies and empty results: If the port data is abnormal and the contour generation fails, an empty result is returned and an error log is recorded, which does not affect the generation of other connectors; if an anomaly occurs in the geometric calculation, the connection point is skipped and the anomaly information is recorded.
Citation Information
Patent Citations
BIM model-based component and association relationship rapid search method and system
CN121350030A
