CN115272605A - Pick-up method, device, equipment and storage medium for three-dimensional model components - Google Patents

Pick-up method, device, equipment and storage medium for three-dimensional model components Download PDF

Info

Publication number
CN115272605A
CN115272605A CN202110476544.5A CN202110476544A CN115272605A CN 115272605 A CN115272605 A CN 115272605A CN 202110476544 A CN202110476544 A CN 202110476544A CN 115272605 A CN115272605 A CN 115272605A
Authority
CN
China
Prior art keywords
component
picked
dimensional model
sub
model
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110476544.5A
Other languages
Chinese (zh)
Inventor
尤勇敏
其他发明人请求不公开姓名
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiuling Jiangsu Digital Intelligent Technology Co Ltd
Original Assignee
Jiuling Jiangsu Digital Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Jiuling Jiangsu Digital Intelligent Technology Co Ltd filed Critical Jiuling Jiangsu Digital Intelligent Technology Co Ltd
Priority to CN202110476544.5A priority Critical patent/CN115272605A/en
Publication of CN115272605A publication Critical patent/CN115272605A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T17/00Three dimensional [3D] modelling, e.g. data description of 3D objects
    • G06T17/10Constructive solid geometry [CSG] using solid primitives, e.g. cylinders, cubes
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F30/00Computer-aided design [CAD]
    • G06F30/10Geometric CAD
    • G06F30/13Architectural design, e.g. computer-aided architectural design [CAAD] related to design of buildings, bridges, landscapes, production plants or roads

Landscapes

  • Physics & Mathematics (AREA)
  • Engineering & Computer Science (AREA)
  • Geometry (AREA)
  • Theoretical Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Hardware Design (AREA)
  • Civil Engineering (AREA)
  • Architecture (AREA)
  • Software Systems (AREA)
  • Computer Graphics (AREA)
  • Structural Engineering (AREA)
  • Computational Mathematics (AREA)
  • Mathematical Analysis (AREA)
  • Mathematical Optimization (AREA)
  • Pure & Applied Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • General Engineering & Computer Science (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The invention discloses a method for picking up a three-dimensional model component, which comprises the following steps: constructing a detection ray based on the position of the picking point, and determining whether the detection ray intersects with the three-dimensional model component to be picked; if the disjointness is determined, acquiring a first model sub-component group of the three-dimensional model component to be picked according to a preset rule; projecting the first model subcomponent set to a display plane to obtain a second model subcomponent set; determining whether a distance between a pickup point position in the display plane and at least one sub-component in the second model sub-component group is less than a preset threshold; and if the number of the three-dimensional model components is smaller than a preset threshold value, picking up the three-dimensional model components to be picked up. The invention realizes that the three-dimensional model can be picked up within a preset pixel distance range from the mouse clicking position by using a ray detection method in combination with a screen projection method, so that the accuracy of picking up the three-dimensional model by a user is improved and the operation difficulty is reduced.

Description

三维模型构件的拾取方法、装置、设备及存储介质Picking method, device, equipment and storage medium for three-dimensional model components

技术领域technical field

本发明涉及建筑信息化技术领域,具体涉及一种三维模型构件的拾取方法、装置、设备及存储介质。The invention relates to the technical field of building information technology, in particular to a method, device, equipment and storage medium for picking up three-dimensional model components.

背景技术Background technique

建筑信息模型(BIM)是建筑学、工程学以及土木工程的新工具,用以表示以三维图形为主、物件导向、建筑学有关的电脑辅助设计。BIM技术通过对建筑的数据化、信息模型整合,在提高生产效率、节约成本和缩短工期方面发挥重要作用。它具备可视化、协调性、模拟性、优化性、可出图性五个特点。WebGL是一种3D绘图协议,WebGL可以实现在浏览器里更流畅地展示3D场景和建筑信息模型,而无需浏览器插件的支持。Building Information Modeling (BIM) is a new tool for architecture, engineering, and civil engineering to represent three-dimensional graphics-based, object-oriented, architecture-related computer-aided design. BIM technology plays an important role in improving production efficiency, saving costs and shortening the construction period through the digitization of buildings and the integration of information models. It has five characteristics of visualization, coordination, simulation, optimization and plotting. WebGL is a 3D drawing protocol. WebGL can display 3D scenes and building information models more smoothly in the browser without the support of browser plug-ins.

基于WebGL的BIM引擎在显示BIM模型时,需要根据鼠标点击对BIM模型进行拾取和操作。而当用户有意愿点选,但鼠标位置接近却并未完全落入BIM模型的屏幕像素范围内时,则无法选中目标模型。When the WebGL-based BIM engine displays the BIM model, it needs to pick up and operate the BIM model according to the mouse click. And when the user is willing to click, but the mouse position is close but not completely within the screen pixel range of the BIM model, the target model cannot be selected.

发明内容Contents of the invention

针对以上现有技术的缺陷,本发明提供一种三维模型构件的拾取方法、装置、设备及存储介质,利用射线检测法结合屏幕投影法的方式,实现在距离鼠标点击位置一预设像素距离范围内能够拾取三维模型,以提高用户拾取三维模型的准确度并降低操作难度。In view of the above defects in the prior art, the present invention provides a method, device, equipment and storage medium for picking up a three-dimensional model component, which uses the method of ray detection combined with the screen projection method to realize the distance range of one preset pixel distance from the mouse click position. The 3D model can be picked up in order to improve the accuracy of picking up the 3D model and reduce the difficulty of operation.

为实现上述目的,本发明的实施例提供了一种三维模型构件的拾取方法,所述方法包括:基于拾取点位置构建检测射线,并确定所述检测射线与待拾取的三维模型构件是否相交;若确定所述检测射线与所述待拾取的三维模型构件不相交,则根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组;将所述第一模型子构件组投影至显示平面以获得第二模型子构件组;确定所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离是否小于预设阈值;以及若所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离小于预设阈值,则拾取所述待拾取的三维模型构件。In order to achieve the above object, an embodiment of the present invention provides a method for picking a 3D model component, the method comprising: constructing a detection ray based on the position of the picking point, and determining whether the detection ray intersects with the 3D model component to be picked; If it is determined that the detection ray does not intersect with the three-dimensional model component to be picked, then obtain the first model sub-component group of the three-dimensional model component to be picked according to preset rules; project the first model sub-component group to a display plane to obtain a second set of model sub-components; determining whether the distance between a pick point position in the display plane and at least one sub-component in the second set of model sub-components is less than a preset threshold; and if If the distance between the pick-up point position in the display plane and at least one sub-component in the second model sub-component group is less than a preset threshold, the three-dimensional model component to be picked is picked.

所述确定所述检测射线与待拾取的三维模型构件是否相交进一步包括:判断所述待拾取的三维模型构件是否存在包围盒;若所述待拾取的三维模型构件存在所述包围盒,则获取所述包围盒并判断所述检测射线与所述包围盒是否相交;以及若所述待拾取的三维模型构件不存在包围盒,或者所述待拾取的三维模型构件存在包围盒但判断出所述检测射线与所述包围盒不相交,则确定所述检测射线与所述待拾取的三维模型构件不相交。The determining whether the detection ray intersects with the 3D model component to be picked further includes: judging whether there is a bounding box in the 3D model component to be picked; if the bounding box exists in the 3D model component to be picked up, obtaining The bounding box and judging whether the detection ray intersects with the bounding box; and if there is no bounding box for the three-dimensional model component to be picked, or if there is a bounding box for the three-dimensional model component to be picked but it is determined that the If the detection ray does not intersect the bounding box, then it is determined that the detection ray does not intersect the to-be-picked three-dimensional model component.

进一步地,若下列中至少一项存在,则判断所述待拾取的三维模型构件不存在包围盒:所述待拾取的三维模型构件为具有单个顶点的点状构件;或在所述待拾取的三维模型构件为具有两个顶点的线状构件的情况下,所述线状构件与预设多个平面的至少一个平面平行。Further, if at least one of the following exists, it is judged that there is no bounding box for the three-dimensional model component to be picked: the three-dimensional model component to be picked is a point-shaped component with a single vertex; When the three-dimensional model component is a linear component having two vertices, the linear component is parallel to at least one of a plurality of predetermined planes.

所述方法进一步包括:在存在所述包围盒且判断出所述检测射线与所述包围盒相交的情况下,判断所述待拾取的三维模型构件的顶点连线所组成的多边形与所述检测射线是否相交。The method further includes: in the case that the bounding box exists and it is determined that the detection ray intersects the bounding box, judging that the polygon formed by the vertex lines of the three-dimensional model components to be picked is consistent with the detection ray. Whether the ray intersects.

判断所述待拾取的三维模型构件的顶点连线所组成的多边形与所述检测射线是否相交包括:判断所述待拾取的三维模型构件的任意三个顶点的连线所组成的三角形与所述检测射线是否相交;以及若所有由任意三个顶点的连线所组成的三角形与所述检测射线都不相交,则确定所述检测射线与所述待拾取的三维模型构件不相交。Judging whether the polygon formed by the lines connecting the vertices of the three-dimensional model component to be picked intersects with the detection ray includes: judging whether the triangle formed by the lines connecting any three vertices of the three-dimensional model component to be picked intersects with the Whether the detection ray intersects; and if all the triangles formed by the lines connecting any three vertices do not intersect the detection ray, then determine that the detection ray does not intersect the 3D model component to be picked.

根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组进一步包括:根据待拾取的三维模型构件的索引数据获取第一模型子构件组,其中:当待拾取的三维模型构件仅包括具有单个顶点的点状子构件或具有两个顶点的线状子构件时,所述第一模型子构件组分别为所述点状子构件或所述线状子构件;以及当待拾取的三维模型构件包括除点状子构件或线状子构件以外的三维模型子构件时,所述第一模型子构件组包括根据所述索引数据对待拾取的三维模型构件进行拆分后所形成的具有两个顶点的线状子构件的组合。Obtaining the first model sub-component group of the 3D model component to be picked up according to preset rules further includes: acquiring the first model sub-component group according to the index data of the 3D model component to be picked up, wherein: when the 3D model component to be picked up When only point-shaped sub-components with a single vertex or line-shaped sub-components with two vertexes are included, the first model sub-component group is respectively the point-shaped sub-component or the line-shaped sub-component; and when the three-dimensional model component to be picked When including 3D model subcomponents other than point subcomponents or line subcomponents, the first model subcomponent group includes a line with two vertices formed by splitting the 3D model component to be picked up according to the index data A combination of shape subcomponents.

本发明的实施例还提供了一种三维模型构件的拾取装置,所述装置包括:获取模块,用于在确定检测射线与待拾取的三维模型构件不相交的情况下,根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组;投影模块,用于将所述第一模型子构件组投影至显示平面以获得第二模型子构件组;以及确定模块,用于当确定所述显示平面中的拾取点位置与所述第二模型子构件中的至少一个子构件之间的距离小于预设阈值时,拾取所述待拾取的三维模型构件。进一步地,所述装置还包括判断模块,用于基于拾取点位置构建检测射线,并确定所述检测射线与待拾取的三维模型构件是否相交。The embodiment of the present invention also provides a pick-up device for a 3D model component, the device includes: an acquisition module, used to acquire all The first model sub-component group of the three-dimensional model component to be picked; the projection module is used to project the first model sub-component group to the display plane to obtain the second model sub-component group; and the determination module is used for when determining When the distance between the pick-up point position in the display plane and at least one of the second model sub-components is less than a preset threshold, the three-dimensional model component to be picked is picked. Further, the device further includes a judging module, configured to construct a detection ray based on the position of the picking point, and determine whether the detection ray intersects with the three-dimensional model component to be picked.

本发明的实施例还提供了一种计算机设备,包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现以上任一实施例所述的三维模型构件的拾取方法的步骤。An embodiment of the present invention also provides a computer device, including a memory and a processor, the memory stores a computer program that can run on the processor, and the processor implements any of the above when executing the computer program. The steps of the method for picking up a three-dimensional model component described in an embodiment.

本发明的实施例还提供了一种计算机可读存储介质,其上存储有计算机程序,计算机程序被处理器执行时实现以上任一实施例所述的三维模型构件的拾取方法的步骤。An embodiment of the present invention also provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the method for picking a three-dimensional model component described in any of the above embodiments are implemented.

本发明的优点在于,通过利用射线检测法结合屏幕投影法的方式,实现在距离鼠标点击位置一预设像素距离范围内能够拾取三维模型,特别是当该三维模型仅为点状或线段构件时,能够拾取该三维模型构件,以提高用户拾取三维模型的准确度并降低操作难度。The advantage of the present invention is that, by using the ray detection method combined with the screen projection method, the three-dimensional model can be picked up within a preset pixel distance from the mouse click position, especially when the three-dimensional model is only a point-like or line-segment component , the 3D model component can be picked up, so as to improve the accuracy of picking up the 3D model for the user and reduce the difficulty of operation.

附图说明Description of drawings

下面结合附图,通过对本发明的具体实施方式详细描述,将使本发明的技术方案及其它有益效果显而易见。The technical solutions and other beneficial effects of the present invention will be apparent through the detailed description of specific embodiments of the present invention in conjunction with the accompanying drawings.

图1示出了本发明的第一实施例所提供的三维模型构件的拾取方法的流程示意图。Fig. 1 shows a schematic flowchart of the method for picking up a three-dimensional model component provided by the first embodiment of the present invention.

图2示出了本发明的第一实施例所提供的三维模型构件的拾取方法的又一流程示意图。Fig. 2 shows another schematic flowchart of the method for picking up a three-dimensional model component provided by the first embodiment of the present invention.

图3至图6分别示出了本发明的第一实施例所提供的三维模型构件的拾取方法的应用场景一至场景四的示意图。3 to 6 respectively show schematic diagrams of application scenarios 1 to 4 of the method for picking up a three-dimensional model component provided by the first embodiment of the present invention.

图7示出了本发明的第二实施例所提供的三维模型构件的拾取装置的结构示意图。Fig. 7 shows a schematic structural diagram of a picking device for a three-dimensional model component provided by a second embodiment of the present invention.

图8示出了本发明的实施例提供的计算机设备的结构示意图。FIG. 8 shows a schematic structural diagram of a computer device provided by an embodiment of the present invention.

具体实施方式Detailed ways

下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述。显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域技术人员在没有作出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the drawings in the embodiments of the present invention. Apparently, the described embodiments are only some of the embodiments of the present invention, but not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative efforts fall within the protection scope of the present invention.

本发明的说明书和权利要求书以及附图中的术语“第一”“第二”“第三”等(如果存在)是用于区别类似的对象,而不必用于描述特定的顺序或先后次序。应当理解,这样描述的对象在适当情况下可以互换。在本发明的描述中,“多个”的含义是两个或两个以上,除非另有明确具体地限定。此外,术语“包括”和“具有”以及它们的任何变形,意图在于覆盖不排它的包含。附图中所示的一些方框图是功能实体,不一定必须与物理或逻辑上独立的实体相对应。可以采用软件形式来实现这些功能实体,或在一个或多个硬件电路或集成电路中实现这些功能实体,或在不同网络和/或处理器装置和/或微控制器装置中实现这些功能实体。The terms "first", "second", "third", etc. (if any) in the description and claims of the present invention and the drawings are used to distinguish similar objects and not necessarily to describe a specific order or sequence . It should be understood that the items so described are interchangeable under appropriate circumstances. In the description of the present invention, "plurality" means two or more, unless otherwise clearly and specifically defined. Furthermore, the terms "comprising" and "having", as well as any variations thereof, are intended to cover a non-exclusive inclusion. Some of the block diagrams shown in the drawings are functional entities and do not necessarily correspond to physically or logically separate entities. These functional entities may be implemented in software, or in one or more hardware circuits or integrated circuits, or in different network and/or processor means and/or microcontroller means.

在本发明的描述中,需要说明的是,除非另有明确的规定和限定,术语“安装”、“相连”、“连接”应做广义理解,例如,可以是固定连接,也可以是可拆卸连接,或一体地连接;可以是机械连接,也可以是电连接或可以相互通讯;可以是直接相连,也可以通过中间媒介间接相连,可以是两个元件内部的连通或两个元件的相互作用关系。对于本领域的普通技术人员而言,可以根据具体情况理解上述术语在本发明中的具体含义。In the description of the present invention, it should be noted that unless otherwise specified and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense, for example, it can be a fixed connection or a detachable connection. Connected, or integrally connected; it can be mechanically connected, or electrically connected, or can communicate with each other; it can be directly connected, or indirectly connected through an intermediary, and it can be the internal communication of two components or the interaction of two components relation. Those of ordinary skill in the art can understand the specific meanings of the above terms in the present invention according to specific situations.

为使本发明的目的、特征和优点能够更加明显易懂,下面结合附图和具体实施方式对本发明作进一步详细的说明。In order to make the purpose, features and advantages of the present invention more comprehensible, the present invention will be further described in detail below in conjunction with the accompanying drawings and specific embodiments.

图1示出了本发明的第一实施例所提供的三维模型构件的拾取方法的流程示意图。本实施例提供的三维模型构件的拾取方法,可以适用于计算机设备中。所述计算机设备可以为智能手机、平板电脑、笔记本电脑、台式电脑或个人数字助理等具有安装绘图应用程序的电子设备,本实施例对计算机设备的具体形式不做限定。Fig. 1 shows a schematic flowchart of the method for picking up a three-dimensional model component provided by the first embodiment of the present invention. The method for picking up a three-dimensional model component provided in this embodiment can be applied to computer equipment. The computer device may be an electronic device with a drawing application program installed, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, or a personal digital assistant, and the specific form of the computer device is not limited in this embodiment.

另外,本发明第一实施例提供的三维模型构件的拾取方法,其执行主体可以是如第二实施例提供的三维模型构件的拾取装置,所述装置可以通过软件、硬件或者软硬件结合的方式实现成为计算机设备的部分或者全部。下述方法实施例的执行主体以计算机设备为例来进行说明,以实现例如在WebGL环境下,能够在距鼠标点击位置一预设像素距离范围内拾取三维模型构件,以提高用户拾取三维模型构件的准确度并降低操作难度。In addition, the method for picking up a 3D model component provided in the first embodiment of the present invention may be executed by the device for picking up a 3D model component as provided in the second embodiment, and the device may be implemented by means of software, hardware or a combination of software and hardware. Implementation becomes part or all of computer equipment. The execution subject of the following method embodiments is described by taking computer equipment as an example, so as to achieve, for example, in the WebGL environment, the three-dimensional model component can be picked up within a preset pixel distance from the mouse click position, so as to improve the user's ability to pick up the three-dimensional model component accuracy and reduce operational difficulty.

参考图1,本发明的第一实施例所提供的三维模型构件的拾取方法包括以下步骤:Referring to Fig. 1, the method for picking up a three-dimensional model component provided by the first embodiment of the present invention includes the following steps:

步骤S10,基于拾取点位置构建检测射线,并确定所述检测射线与待拾取的三维模型构件是否相交;Step S10, constructing a detection ray based on the position of the picking point, and determining whether the detection ray intersects with the three-dimensional model component to be picked;

步骤S20,若确定所述检测射线与所述待拾取的三维模型构件不相交,则根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组;Step S20, if it is determined that the detection ray does not intersect with the three-dimensional model component to be picked, then acquire the first model sub-component group of the three-dimensional model component to be picked according to preset rules;

步骤S30,将所述第一模型子构件组投影至显示平面以获得第二模型子构件组;Step S30, projecting the first model sub-component group to a display plane to obtain a second model sub-component group;

步骤S40,确定所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离是否小于预设阈值;Step S40, determining whether the distance between the picking point position in the display plane and at least one sub-component in the second model sub-component group is smaller than a preset threshold;

步骤S50,若所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离小于预设阈值,则拾取所述待拾取的三维模型构件。Step S50, if the distance between the pick-up point position in the display plane and at least one sub-component in the second model sub-component group is smaller than a preset threshold, pick the 3D model component to be picked.

以下将进一步描述本实施例所述方法的每一步骤。Each step of the method described in this embodiment will be further described below.

在步骤S10,在计算机设备中,可以通过建筑类软件加载建筑信息模型(即,BIM模型)于计算机设备所提供的浏览器中并在计算机设备的二维屏幕上呈现。在BIM模型加载完毕之后,将模型构件的数据按顶点、索引的方式存储到内存。其中,所述内存可以位于浏览器、计算机本地硬盘或远程服务器中,在此不做限定。针对每一个BIM模型构件,记录唯一的识别号(即,id值)、一份顶点信息以及一份索引信息,并将BIM模型构件和相机对象加入三维场景(即三维空间)作为鼠标拾取的前提条件。其中,所述三维场景是指以视点(即相机)为原点的相机视点的坐标系定义的三维空间。In step S10, in the computer device, the building information model (that is, the BIM model) can be loaded into the browser provided by the computer device through construction software and presented on the two-dimensional screen of the computer device. After the BIM model is loaded, the data of the model components are stored in memory in the form of vertices and indexes. Wherein, the memory may be located in the browser, the local hard disk of the computer, or the remote server, which is not limited here. For each BIM model component, record a unique identification number (ie, id value), a piece of vertex information, and a piece of index information, and add the BIM model component and camera object to the 3D scene (ie, 3D space) as a prerequisite for mouse picking condition. Wherein, the three-dimensional scene refers to a three-dimensional space defined by a coordinate system of a camera viewpoint with the viewpoint (that is, the camera) as the origin.

在本实施例中,通过存储的索引信息能够获取模型构件的顶点信息,同时识别模型构件为具有多个顶点的模型构件、具有单个顶点的点状构件,或具有两个顶点的线状构件。具体的,模型构件顶点数据中索引值对应于获取顶点信息的方式,例如,顶点数组[v,v,v],其中v代表顶点,索引值是一个类型数组(TypedArray),其存储尺寸就决定了获取数据的类型,例如,存储尺寸为1,就是从顶点数组获取1个点来使用,构造成点状构件;存储尺寸为2,则取两个点连接线段;存储尺寸为3,取三点依次连接成角形。In this embodiment, the vertex information of the model component can be obtained through the stored index information, and at the same time, the model component can be identified as a model component with multiple vertices, a point component with a single vertex, or a linear component with two vertices. Specifically, the index value in the vertex data of the model component corresponds to the method of obtaining vertex information, for example, the vertex array [v, v, v], where v represents a vertex, and the index value is a typed array (TypedArray), and its storage size is determined by In order to obtain the type of data, for example, if the storage size is 1, it is to obtain a point from the vertex array and use it to construct a point-shaped component; if the storage size is 2, then take two points to connect the line segment; if the storage size is 3, take three The points are connected in turn to form an angle.

图3和图4分别示出了本发明的第一实施例所提供的三维模型构件的拾取方法的应用场景一和场景二的示意图。具体的,如图3和图4所示,以相机1为三维空间中的视点原点,模型构件2为三维空间中显示的模型构件,模型构件3为模型构件1经过坐标变换、投影等操作后在屏幕空间4(即二维平面)中所显示的对应的模型构件。当加载场景并生成BIM模型构件的相关数据后,鼠标点击屏幕上呈现的模型构件3,记录鼠标点击位置(亦即,拾取点位置)的屏幕坐标。FIG. 3 and FIG. 4 respectively show schematic diagrams of application scenarios 1 and 2 of the method for picking up a three-dimensional model component provided by the first embodiment of the present invention. Specifically, as shown in Figure 3 and Figure 4, camera 1 is the origin of the viewpoint in the three-dimensional space, model component 2 is the model component displayed in the three-dimensional space, and model component 3 is the model component 1 after coordinate transformation, projection and other operations The corresponding model components displayed in screen space 4 (ie, a two-dimensional plane). After the scene is loaded and the relevant data of the BIM model component is generated, the mouse clicks on the model component 3 presented on the screen, and the screen coordinates of the mouse click position (that is, the pick point position) are recorded.

当获取鼠标点击位置的屏幕坐标后,判断检测射线与待拾取的模型构件2是否相交。当判断出检测射线与待拾取的模型构件2相交时,则直接拾取模型构件2。当判断出检测射线与待拾取的模型构件2不相交时,则需要通过后续的投影法进一步判断是否拾取模型构件2。图2示出了本发明的第一实施例所提供的三维模型构件的拾取方法的又一流程示意图,其具体示出了通过检测射线法判断是否拾取模型构件的步骤,主要包括:After obtaining the screen coordinates of the mouse click position, it is judged whether the detection ray intersects with the model component 2 to be picked. When it is judged that the detection ray intersects the model component 2 to be picked, the model component 2 is picked directly. When it is judged that the detection ray does not intersect the model component 2 to be picked up, it is necessary to further determine whether to pick up the model component 2 through a subsequent projection method. Fig. 2 shows another schematic flowchart of the method for picking up a three-dimensional model component provided by the first embodiment of the present invention, which specifically shows the steps of judging whether to pick up a model component by detecting rays, mainly including:

步骤S11,判断模型构件是否存在包围盒,若存在,则获取模型构件的包围盒,若不存在,则视为检测射线与待拾取的三维模型构件不相交,并通过投影法进一步判断是否拾取模型构件;Step S11, judge whether there is a bounding box for the model component, if yes, obtain the bounding box of the model component, if not, consider the detection ray does not intersect with the 3D model component to be picked, and further judge whether to pick the model by projection method member;

步骤S12,判断检测射线与所获取的包围盒是否相交;Step S12, judging whether the detection ray intersects with the acquired bounding box;

步骤S121,当检测射线与所述包围盒相交时,则进一步判断该模型构件的顶点连线所组成的多边形与检测射线是否相交,若相交,则拾取模型构件,若不相交,则确定检测射线与待拾取的模型构件不相交,需要通过投影法进一步判断是否拾取模型构件;Step S121, when the detection ray intersects the bounding box, further judge whether the polygon formed by the vertex connection of the model component intersects the detection ray, if it intersects, pick the model component, if not, determine the detection ray It does not intersect with the model component to be picked, and it is necessary to further judge whether to pick the model component through the projection method;

步骤S122,当检测射线与所述包围盒不相交时,确定检测射线与待拾取的模型构件不相交,需要通过投影法进一步判断是否拾取模型构件。Step S122, when the detection ray does not intersect the bounding box, it is determined that the detection ray does not intersect the model component to be picked, and it is necessary to further judge whether to pick the model component by projection method.

在本实施例中,以图3中的场景一为例,检测射线5被设置为从三维场景的相机1为射线起点O,经鼠标点击位置生成的一条射线,该鼠标点击位置可以被理解为点击位置的屏幕坐标或点击位置在三维空间中的投影坐标。检测射线5的射线方向D可以根据以下步骤获得:根据相机投影矩阵将点击位置的二维屏幕坐标点D(x,y)转换到三维空间内,获得对应的三维空间的投影点坐标P(x’,y’),设置默认z坐标值,最后通过三维空间的投影点坐标和相机位置坐标点,可确定射线方向D。In this embodiment, taking scene one in FIG. 3 as an example, the detection ray 5 is set as a ray generated from the camera 1 of the three-dimensional scene as the starting point O of the ray through the mouse click position, and the mouse click position can be understood as The screen coordinates of the clicked position or the projected coordinates of the clicked position in 3D space. The ray direction D of the detection ray 5 can be obtained according to the following steps: convert the two-dimensional screen coordinate point D(x, y) of the clicked position into the three-dimensional space according to the camera projection matrix, and obtain the corresponding three-dimensional space projection point coordinate P(x ', y'), set the default z coordinate value, and finally determine the ray direction D through the coordinates of the projected point in the three-dimensional space and the coordinate point of the camera position.

在步骤S11,判断检测射线与待拾取的模型构件2是否相交进一步包括判断模型构件2是否存在包围盒,若存在,则获取模型构件的包围盒,若不存在,则视为检测射线与待拾取的三维模型构件不相交,并通过投影法进一步判断是否拾取模型构件2。在本实施例中,包围盒是指能够包容物体的立方体。In step S11, judging whether the detection ray intersects the model component 2 to be picked further includes judging whether there is a bounding box in the model component 2, and if so, obtaining the bounding box of the model component; The 3D model components of are disjoint, and the projection method is used to further judge whether to pick model component 2. In this embodiment, a bounding box refers to a cube that can contain an object.

图5示出了本发明的第一实施例所提供的三维模型构件的拾取方法的场景三的示意图,该场景三为模型构件不存在包围盒的情况,即无法计算包围盒的情况。具体的,如图5所示,模型构件不存在包围盒(或视为不存在包围盒)包括以下至少一种情况:待拾取的三维模型构件为具有单个顶点的点状构件41;或当待拾取的三维模型构件为具有两个顶点(即端点)的线状构件42且所述线状构件42与如下所述的笛卡尔坐标系中6个方向上的平面(-X,X,-Y,Y,-Z,Z)中的至少一个平面平行。应当理解,可以通过前述索引值识别模型构件为具有多个顶点的模型构件、具有单个顶点的点状构件,或具有两个顶点的线状构件。当模型构件不存在包围盒时,无法通过判断检测射线与包围盒是否相交的方法确定是否拾取模型构件(即,射线法失效),从而需要通过投影法进一步判断是否拾取模型构件。Fig. 5 shows a schematic diagram of scenario 3 of the method for picking a 3D model component provided by the first embodiment of the present invention. The scenario 3 is a situation where there is no bounding box for the model component, that is, a situation where the bounding box cannot be calculated. Specifically, as shown in FIG. 5 , the model component does not have a bounding box (or is considered to have no bounding box) including at least one of the following situations: the three-dimensional model component to be picked is a point-shaped component 41 with a single vertex; The picked-up three-dimensional model component is a linear component 42 with two vertices (i.e. endpoints), and the linear component 42 is aligned with the plane (-X, X,-Y , Y, -Z, Z) at least one plane is parallel. It should be understood that the model component can be identified as a model component with multiple vertices, a point-shaped component with a single vertex, or a linear component with two vertices through the aforementioned index value. When the model component does not have a bounding box, it is impossible to determine whether to pick the model component by judging whether the detection ray intersects the bounding box (that is, the ray method fails), so it is necessary to further judge whether to pick the model component by the projection method.

在本实施例中,当确定模型构件2存在包围盒时,则获取模型构件2的包围盒。为了便于理解,在图3和图4所示的场景一和场景二中,模型构件2为矩形,其包围盒即为模型构件2本身,以矩形包围盒为例,可以通过以下平面公式获取包围盒的6个平面:In this embodiment, when it is determined that the model component 2 has a bounding box, the bounding box of the model component 2 is obtained. For ease of understanding, in scenarios 1 and 2 shown in Figure 3 and Figure 4, the model component 2 is a rectangle, and its bounding box is the model component 2 itself. Taking the rectangular bounding box as an example, the enclosing box can be obtained by the following plane formula The 6 planes of the box:

Figure BDA0003047589420000071
Figure BDA0003047589420000071

Figure BDA0003047589420000072
Figure BDA0003047589420000072

Figure BDA0003047589420000073
Figure BDA0003047589420000073

其中,-X,X,-Y,Y,-Z,Z是笛卡尔坐标系中6个方向上的平面,Pi为顶点坐标。这6个面相交围成的空间,就是包围一个模型构件的长方体,即矩形包围盒。Among them, -X, X, -Y, Y, -Z, Z are planes in 6 directions in the Cartesian coordinate system, and Pi is the vertex coordinates. The space enclosed by the intersection of these six faces is a cuboid surrounding a model component, that is, a rectangular bounding box.

需要说明的是,对于本步骤中模型构件的包围盒的具体方式,可以由设计人员根据实际场景和用户需求自行设置。获取该模型构件的包围盒可以是获取预置的包围盒,例如,预设BIM模型的包围盒;也可以为根据模型构件生成包围盒。只要本步骤中处理器可以获取模型构件的包围盒,本实施例对此不做任何限制。It should be noted that the specific manner of the bounding box of the model component in this step can be set by the designer according to the actual scene and user requirements. Acquiring the bounding box of the model component may be to acquire a preset bounding box, for example, a preset bounding box of a BIM model; or it may be to generate a bounding box according to the model component. As long as the processor can obtain the bounding box of the model component in this step, this embodiment does not impose any limitation on this.

在步骤S12,判断检测射线与所获取的包围盒是否相交。在本实施例中,判断检测射线5与上述包围盒是否相交的过程包括:设O为射线起点,D为射线方向,N为平面法线,P0表示平面上的一个点,P表示平面上的任意点(即待求交点),且当P=P0时,0·N=0,则平面方程(P-P0)·N=0,所以(O+D·t-P0)·N=0,则(O-P0)·N+D·N·t=0,最终获得t=(P0-O)·N/D·N(其中D·N≠0)。其中,t为一标量,当t无解时(即D·N=0),则视为检测射线5与该平面无交点。在遍历包围盒的所有平面后,若检测射线5与所有平面都无交点,则判断检测射线5与上述包围盒不相交,如图4的场景二所示。反之,当检测射线5与至少一个平面有交点,则判断检测射线5与上述包围盒相交,如图3的场景一所示。In step S12, it is judged whether the detected ray intersects with the acquired bounding box. In this embodiment, the process of judging whether the detection ray 5 intersects the bounding box includes: set O as the starting point of the ray, D as the direction of the ray, N as the plane normal, P0 as a point on the plane, and P as the point on the plane Arbitrary point (that is, the intersection point to be found), and when P=P0, 0·N=0, then the plane equation (P-P0)·N=0, so (O+D·t-P0)·N=0, Then (O−P0)·N+D·N·t=0, and finally t=(P0−O)·N/D·N (where D·N≠0) is obtained. Wherein, t is a scalar, and when t has no solution (that is, D·N=0), it is considered that the detection ray 5 has no intersection with the plane. After traversing all the planes of the bounding box, if the detection ray 5 has no intersection with all the planes, it is judged that the detection ray 5 does not intersect the above bounding box, as shown in scene 2 of FIG. 4 . Conversely, when the detection ray 5 intersects at least one plane, it is judged that the detection ray 5 intersects the bounding box, as shown in scene 1 of FIG. 3 .

步骤S121,如图3的场景一所示,当检测射线5与所述包围盒相交时,则进一步判断该模型构件2的顶点连线所组成的多边形与检测射线5是否相交,若相交,则直接执行拾取模型构件2的操作,若不相交,则确定检测射线5与待拾取的模型构件2不相交,需要通过投影法进一步判断是否拾取模型构件2。Step S121, as shown in scene 1 of FIG. 3 , when the detection ray 5 intersects the bounding box, it is further judged whether the polygon formed by the vertex connections of the model component 2 intersects the detection ray 5, and if so, then Directly execute the operation of picking up the model component 2. If they do not intersect, then it is determined that the detection ray 5 does not intersect with the model component 2 to be picked up. It is necessary to further judge whether to pick up the model component 2 through the projection method.

其中,判断所述模型构件2的顶点连线所组成的多边形与所述检测射线是否相交可以采用如下三角形相交算法:判断所述模型构件2的任意三个顶点的连线所组成的三角形与所述检测射线5是否相交;以及当所有由任意三个顶点的连线所组成的三角形与所述检测射线5都不相交时,确定检测射线与待拾取的三维模型构件不相交。其中,该三角形相交算法可以采用本领域技术人员熟知的三角形相交算法,例如重心法、同向法等。以三角形相交算法的重心法为例,三角形的三个顶点是通过模型构件的索引信息从顶点列表取得的三维坐标点A,B,C,因此对于平面内任意一点P(即待求交点),都可以由如下方程来表示:Wherein, the following triangle intersection algorithm may be used to determine whether the polygon formed by the vertex lines of the model component 2 intersects with the detection ray: determine the triangle formed by the lines of any three vertices of the model component 2 and the Whether the detection ray 5 intersects; and when all the triangles formed by the lines connecting any three vertices do not intersect the detection ray 5, determine that the detection ray does not intersect the three-dimensional model component to be picked. Wherein, the triangle intersection algorithm may adopt a triangle intersection algorithm well known to those skilled in the art, such as the center of gravity method, the same direction method, and the like. Taking the center of gravity method of the triangle intersection algorithm as an example, the three vertices of the triangle are the three-dimensional coordinate points A, B, and C obtained from the vertex list through the index information of the model component. Therefore, for any point P in the plane (that is, the intersection point to be obtained), can be expressed by the following equation:

P=A+u*(C-A)+v*(B-A)P=A+u*(C-A)+v*(B-A)

如果系数u或v为负值,那么相当于朝相反的方向移动,即BA或CA方向。那么如果想让P位于三角形ABC内部,当u=0且v=0时,就是点A,当u=0,v=1时,就是点B,而当u=1,v=0时,就是点C,整理上述方程得到P-A=u(C-A)+v(B-A),令v0=C-A,v1=B-A,v2=P-A,则v2=u*v0+v*v1,将等式两边分别点乘v0和v1后得到两个等式:If the coefficient u or v is negative, it is equivalent to moving in the opposite direction, that is, BA or CA direction. Then if you want P to be located inside the triangle ABC, when u=0 and v=0, it is point A, when u=0, v=1, it is point B, and when u=1, v=0, it is Point C, arrange the above equation to get P-A=u(C-A)+v(B-A), let v0=C-A, v1=B-A, v2=P-A, then v2=u*v0+v*v1, multiply the two sides of the equation respectively Two equations are obtained after v0 and v1:

(v2)·v0=(u*v0+v*v1)·v0;以及(v2)·v0=(u*v0+v*v1)·v0; and

(v2)·v1=(u*v0+v*v1)·v1(v2)·v1=(u*v0+v*v1)·v1

注意,u和v是数值,而v0,v1和v2是向量,所以可以将点积展开得到:Note that u and v are numbers, and v0, v1 and v2 are vectors, so the dot product can be expanded to get:

v2·v0=u*(v0·v0)+v*(v1·v0);以及v2·v0=u*(v0·v0)+v*(v1·v0); and

v2·v1=u*(v0·v1)+v*(v1·v1)v2·v1=u*(v0·v1)+v*(v1·v1)

解这个方程得到:Solving this equation gives:

u=((v1·v1)(v2·v0)-(v1·v0)(v2·v1))/((v0·v0)(v1·v1)-(v0·v1)(v1·v0))u=((v1·v1)(v2·v0)-(v1·v0)(v2·v1))/((v0·v0)(v1·v1)-(v0·v1)(v1·v0))

v=((v0·v0)(v2·v1)-(v0·v1)(v2·v0))/((v0·v0)(v1·v1)-(v0·v1)(v1·v0))v=((v0·v0)(v2·v1)-(v0·v1)(v2·v0))/((v0·v0)(v1·v1)-(v0·v1)(v1·v0))

求得u和v,即如果满足如下三个条件:Obtain u and v, that is, if the following three conditions are met:

u>=0u>=0

v>=0v>=0

u+v<=1u+v<=1

则检测射线在三角形内有交点,如果与三角形判断相交,则与模型构件相交,按此方法判断全部相交的模型构件的信息,并按需拾取和操作。Then the detection ray has an intersection point in the triangle. If it is judged to intersect with the triangle, it will intersect with the model component. According to this method, the information of all intersected model components is judged, and the information is picked and operated as required.

在步骤S122,当检测射线5与所述包围盒不相交时,则确定检测射线5与待拾取的模型构件2不相交,需要通过后续的投影法判断是否拾取模型构件2。In step S122, when the detection ray 5 does not intersect the bounding box, it is determined that the detection ray 5 does not intersect the model component 2 to be picked, and it is necessary to determine whether to pick the model component 2 through the subsequent projection method.

在步骤S20,当确定检测射线与待拾取的三维模型构件不相交时,即通过检测射线与包围盒的相交算法和三角形相交算法仍未能获得拾取模型构件的结果时,需要执行投影法判断是否拾取模型构件2。具体的,根据待拾取的模型构件的索引数据获取第一模型子构件组,其中:当待拾取的模型构件仅包括具有单个顶点的点状构件或具有两个顶点的线状构件时,所述第一模型子构件组分别为所述点状构件或所述线状构件;以及当待拾取的模型构件包括除点状构件或线状构件以外的三维模型构件时,所述第一模型子构件组包括根据所述索引数据对待拾取的三维模型构件进行拆分后所形成的具有两个顶点的线状构件的组合。具体的,根据索引值取顶点数组中的两个点连成线段。In step S20, when it is determined that the detection ray does not intersect with the three-dimensional model component to be picked, that is, when the result of picking up the model component cannot be obtained through the intersection algorithm of the detection ray and the bounding box and the triangle intersection algorithm, it is necessary to perform the projection method to judge whether Pick up model component 2. Specifically, the first model sub-component group is obtained according to the index data of the model component to be picked, wherein: when the model component to be picked only includes a point-shaped component with a single vertex or a linear component with two vertexes, the The first model sub-component group is respectively the point-shaped component or the linear component; and when the model components to be picked up include three-dimensional model components other than point-shaped components or linear components, the first model sub-component The group includes a combination of linear components with two vertices formed by splitting the three-dimensional model components to be picked up according to the index data. Specifically, according to the index value, two points in the vertex array are connected to form a line segment.

在步骤S30,将所述第一模型子构件组投影至显示平面,例如屏幕,以获得第二模型子构件组。例如,当待拾取的模型构件仅包括具有单个顶点的点状构件或具有两个顶点的线状构件时,将其顶点在三维空间中的坐标通过相机投影矩阵转换到屏幕坐标,得到屏幕上的投影线段;当待拾取的模型构件包括除点状构件或线状构件以外的三维模型构件时,同样地,将拆分后的第一模型子构件组中的线段两端点(即顶点)在三维空间中的坐标通过相机投影矩阵转换到屏幕坐标,得到屏幕上的投影线段,其中,模型空间到屏幕空间的变换公式为:In step S30, the first model sub-component set is projected onto a display plane, such as a screen, to obtain a second model sub-component set. For example, when the model components to be picked only include point components with a single vertex or linear components with two vertices, the coordinates of the vertices in the three-dimensional space are converted to screen coordinates through the camera projection matrix, and the on-screen Projection line segment; when the model components to be picked up include three-dimensional model components other than point components or linear components, similarly, the two ends (i.e. vertices) of the line segment in the first model sub-component group after splitting are The coordinates in the space are converted to screen coordinates through the camera projection matrix to obtain the projected line segment on the screen, where the transformation formula from model space to screen space is:

屏幕坐标点P_screen=P_world·M_camera^(-1)·M_projection;Screen coordinate point P_screen=P_world·M_camera^(-1)·M_projection;

其中P_world为线段端点的世界坐标点,相机矩阵为M_camera,投影矩阵为M_projection。Among them, P_world is the world coordinate point of the endpoint of the line segment, the camera matrix is M_camera, and the projection matrix is M_projection.

在步骤S40,当确定所述显示平面中的拾取点位置与所述第二模型子构件中的至少一个子构件之间的距离小于预设阈值时,拾取所述三维模型构件。具体的,图6示出了本发明的第一实施例所提供的三维模型构件的拾取方法的应用场景四的示意图。如图6所示,模型构件2的线段31的端点A和端点B在三维空间中的坐标通过相机投影矩阵转换到屏幕坐标(端点A’和端点B’),根据鼠标点击的屏幕位置D和转换后的投影线段32之间的距离d进行判断,如果距离d小于预设的像素距离,则视为成功获取构件点选结果,并返回拾取模型构件2的结果。当遍历模型构件2中所有的线段构件,其投影线段与鼠标点击的屏幕位置D之间的距离d都大于预设的像素距离,则获得确定构件点选失败的结果,并返回不拾取模型构件2的结果。本领域普通技术人员应当理解,计算屏幕位置点D到投影线段的距离可以采用切线法或类似的本领域技术人员熟知的计算方法,本实施例在此不做限制。In step S40, when it is determined that the distance between the pick-up point position in the display plane and at least one of the second model sub-components is smaller than a preset threshold, the three-dimensional model component is picked. Specifically, FIG. 6 shows a schematic diagram of an application scenario four of the method for picking a three-dimensional model component provided by the first embodiment of the present invention. As shown in Figure 6, the coordinates of the endpoint A and the endpoint B of the line segment 31 of the model member 2 in three-dimensional space are transformed into screen coordinates (endpoint A' and endpoint B') by the camera projection matrix, according to the screen position D and The distance d between the converted projected line segments 32 is judged. If the distance d is less than the preset pixel distance, it is considered that the component selection result has been successfully obtained, and the result of picking up the model component 2 is returned. When traversing all the line segment components in the model component 2, the distance d between the projected line segment and the screen position D clicked by the mouse is greater than the preset pixel distance, then the result of confirming that the component selection fails is obtained, and the model component is not picked. 2 results. Those of ordinary skill in the art should understand that the calculation of the distance from the screen location point D to the projected line segment may use a tangent method or a similar calculation method known to those skilled in the art, which is not limited in this embodiment.

图7示出了本发明的第二实施例所提供的三维模型构件的拾取装置100的结构示意图。所述装置100包括:获取模块10,用于在确定检测射线与待拾取的三维模型构件不相交的情况下,根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组;投影模块20,用于将所述第一模型子构件组投影至显示平面以获得第二模型子构件组;以及确定模块30,用于当确定所述显示平面中的拾取点位置与所述第二模型子构件中的至少一个子构件之间的距离小于预设阈值时,拾取所述待拾取的三维模型构件。所述装置100还包括判断模块40,用于基于拾取点位置构建检测射线,并确定所述检测射线与待拾取的三维模型构件是否相交。FIG. 7 shows a schematic structural diagram of a picking device 100 for a three-dimensional model component provided by a second embodiment of the present invention. The device 100 includes: an acquisition module 10, configured to acquire the first model sub-component group of the three-dimensional model component to be picked according to preset rules when it is determined that the detection ray does not intersect with the three-dimensional model component to be picked; A projection module 20, configured to project the first model sub-component group onto a display plane to obtain a second model sub-component group; When the distance between at least one of the two model sub-components is less than a preset threshold, the 3D model component to be picked is picked. The device 100 also includes a judging module 40, configured to construct a detection ray based on the position of the picking point, and determine whether the detection ray intersects with the three-dimensional model component to be picked.

同时应当理解,第二实施例与第一实施例中的相关特征可相互参考、借鉴,此处不再一一赘述。At the same time, it should be understood that the relevant features in the second embodiment and the first embodiment may refer to and learn from each other, and details will not be repeated here.

本发明通过射线检测与投影检测相结合的方式,实现了当检测射线位于模型构件外部但与模型构件十分接近时进行准确拾取、同时对检测射线无法检测到的线状构件、点状构件进行准确拾取的效果。The invention realizes accurate picking when the detection ray is located outside the model component but very close to the model component by combining ray detection and projection detection, and at the same time accurately picks up linear components and point components that cannot be detected by the detection ray. Pickup effect.

图8示出了本发明的实施例提供的计算机设备200的结构示意图。该计算机设备包括通过系统总线300连接的处理器310、存储器320、网络接口330、显示屏340和输入装置350。其中,该计算机设备200的处理器310用于提供计算和控制能力。该计算机设备200的存储器320包括非易失性存储介质、内存储器。该非易失性存储介质存储有操作系统和计算机程序。该内存储器为非易失性存储介质中的操作系统和计算机程序的运行提供环境。该计算机设备200的网络接口330用于与外部的计算机设备通过网络连接通信。该计算机程序被处理器310执行时以实现三维模型构件的拾取方法。该计算机设备200的显示屏340可以是液晶显示屏或者电子墨水显示屏,该计算机设备200的输入装置350可以是显示屏340上覆盖的触摸层,也可以是计算机设备200外壳上设置的按键、轨迹球或触控板,还可以是外接的键盘、触控板或鼠标等。FIG. 8 shows a schematic structural diagram of a computer device 200 provided by an embodiment of the present invention. The computer device includes a processor 310 , a memory 320 , a network interface 330 , a display screen 340 and an input device 350 connected through a system bus 300 . Wherein, the processor 310 of the computer device 200 is used to provide calculation and control capabilities. The memory 320 of the computer device 200 includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and computer programs. The internal memory provides an environment for the operation of the operating system and computer programs in the non-volatile storage medium. The network interface 330 of the computer device 200 is used to communicate with external computer devices via a network connection. When the computer program is executed by the processor 310, the picking method of the three-dimensional model component is realized. The display screen 340 of the computer device 200 may be a liquid crystal display screen or an electronic ink display screen, and the input device 350 of the computer device 200 may be a touch layer covered on the display screen 340, or a button set on the casing of the computer device 200, A trackball or a touchpad, or an external keyboard, touchpad, or mouse.

本领域技术人员可以理解,图8中示出的结构,仅仅是与本申请方案相关的部分结构的框图,并不构成对本申请方案所应用于其上的计算机设备的限定,具体的计算机设备可以包括比图中所示更多或更少的部件,或者组合某些部件,或者具有不同的部件布置。Those skilled in the art can understand that the structure shown in FIG. 8 is only a block diagram of a partial structure related to the solution of this application, and does not constitute a limitation on the computer equipment to which the solution of this application is applied. The specific computer equipment can be More or fewer components than shown in the figures may be included, or some components may be combined, or have a different arrangement of components.

在一个实施例中,提供了一种计算机设备,包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的计算机程序,所述处理器执行所述计算机程序时实现以下步骤:In one embodiment, a computer device is provided, including a memory and a processor, the memory stores a computer program that can run on the processor, and the processor implements the following steps when executing the computer program :

基于拾取点位置构建检测射线,并确定所述检测射线与待拾取的三维模型构件是否相交;若确定所述检测射线与所述待拾取的三维模型构件不相交,则根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组;将所述第一模型子构件组投影至显示平面以获得第二模型子构件组;确定所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离是否小于预设阈值;以及若所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离小于预设阈值,则拾取所述待拾取的三维模型构件。Construct a detection ray based on the position of the picking point, and determine whether the detection ray intersects with the three-dimensional model component to be picked; if it is determined that the detection ray does not intersect the three-dimensional model component to be picked, then obtain the The first model sub-component group of the three-dimensional model component to be picked; projecting the first model sub-component group to a display plane to obtain a second model sub-component group; determining the position of the picking point in the display plane and the first Whether the distance between at least one sub-component in the second model sub-component group is less than a preset threshold; and if the distance between the picking point position in the display plane and at least one sub-component in the second model sub-component group If the distance is less than the preset threshold, the three-dimensional model component to be picked is picked.

对上述步骤的具体限定和实现方式可以参看上述实施例一,在此不再赘述。For the specific limitation and implementation of the above steps, reference may be made to the first embodiment above, which will not be repeated here.

在另一个实施例中,提供了一种计算机可读存储介质,其上存储有计算机程序,程序被处理器执行时实现以下用于三维模型构件的拾取方法的步骤:In another embodiment, a computer-readable storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the following steps of the picking method for a three-dimensional model component are implemented:

基于拾取点位置构建检测射线,并确定所述检测射线与待拾取的三维模型构件是否相交;若确定所述检测射线与所述待拾取的三维模型构件不相交,则根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组;将所述第一模型子构件组投影至显示平面以获得第二模型子构件组;确定所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离是否小于预设阈值;以及若所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离小于预设阈值,则拾取所述待拾取的三维模型构件。Construct a detection ray based on the position of the picking point, and determine whether the detection ray intersects with the three-dimensional model component to be picked; if it is determined that the detection ray does not intersect the three-dimensional model component to be picked, then obtain the The first model sub-component group of the three-dimensional model component to be picked; projecting the first model sub-component group to a display plane to obtain a second model sub-component group; determining the position of the picking point in the display plane and the first Whether the distance between at least one sub-component in the second model sub-component group is less than a preset threshold; and if the distance between the picking point position in the display plane and at least one sub-component in the second model sub-component group If the distance is less than the preset threshold, the three-dimensional model component to be picked is picked.

对上述步骤的具体限定和实现方式可以参看上述实施例一,在此不再赘述。For the specific limitation and implementation of the above steps, reference may be made to the first embodiment above, which will not be repeated here.

本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,所述的计算机程序可存储于一非易失性计算机可读取存储介质中,该计算机程序在执行时,可包括如上述各方法的实施例的流程。其中,本申请所提供的各实施例中所使用的对存储器、存储、数据库或其它介质的任何引用,均可包括非易失性和/或易失性存储器。非易失性存储器可包括只读存储器(ROM)、可编程ROM(PROM)、电可编程ROM(EPROM)、电可擦除可编程ROM(EEPROM)或闪存。易失性存储器可包括随机存取存储器(RAM)或者外部高速缓冲存储器。作为说明而非局限,RAM以多种形式可得,诸如静态RAM(SRAM)、动态RAM(DRAM)、同步DRAM(SDRAM)、双数据率SDRAM(DDRSDRAM)、增强型SDRAM(ESDRAM)、同步链路(Synchlink)DRAM(SLDRAM)、存储器总线(Rambus)直接RAM(RDRAM)、直接存储器总线动态RAM(DRDRAM)、以及存储器总线动态RAM(RDRAM)等。Those of ordinary skill in the art can understand that all or part of the processes in the methods of the above embodiments can be implemented through computer programs to instruct related hardware, and the computer programs can be stored in a non-volatile computer-readable memory In the medium, when the computer program is executed, it may include the processes of the embodiments of the above-mentioned methods. Wherein, any references to memory, storage, database or other media used in the various embodiments provided in the present application may include non-volatile and/or volatile memory. Nonvolatile memory can include read only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms such as Static RAM (SRAM), Dynamic RAM (DRAM), Synchronous DRAM (SDRAM), Double Data Rate SDRAM (DDRSDRAM), Enhanced SDRAM (ESDRAM), Synchronous Chain Synchlink DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

以上对本发明实施例所提供的一种三维模型构件的拾取方法、装置、设备及存储介质进行了详细介绍,本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的技术方案及其核心思想;本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本发明各实施例的技术方案的范围。The method, device, equipment and storage medium for picking up a three-dimensional model component provided by the embodiment of the present invention have been described in detail above. In this paper, specific examples are used to illustrate the principle and implementation of the present invention. The above embodiments The description is only used to help understand the technical solution and its core idea of the present invention; those skilled in the art should understand that it can still modify the technical solutions recorded in the foregoing embodiments, or equivalently replace some of the technical features and these modifications or replacements do not make the essence of the corresponding technical solutions depart from the scope of the technical solutions of the embodiments of the present invention.

Claims (10)

1.一种三维模型构件的拾取方法,其特征在于,所述方法包括:1. A method for picking up a three-dimensional model member, characterized in that the method comprises: 基于拾取点位置构建检测射线,并确定所述检测射线与待拾取的三维模型构件是否相交;Constructing a detection ray based on the position of the picking point, and determining whether the detection ray intersects with the three-dimensional model component to be picked; 若确定所述检测射线与所述待拾取的三维模型构件不相交,则根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组;If it is determined that the detection ray does not intersect with the three-dimensional model component to be picked, the first model sub-component group of the three-dimensional model component to be picked is obtained according to preset rules; 将所述第一模型子构件组投影至显示平面以获得第二模型子构件组;projecting the first set of model sub-components onto a display plane to obtain a second set of model sub-components; 确定所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离是否小于预设阈值;以及determining whether the distance between the pick point location in the display plane and at least one sub-component in the second model sub-component set is less than a predetermined threshold; and 若所述显示平面中的拾取点位置与所述第二模型子构件组中的至少一个子构件之间的距离小于预设阈值,则拾取所述待拾取的三维模型构件。If the distance between the picking point position in the display plane and at least one sub-component in the second model sub-component group is smaller than a preset threshold, then picking the three-dimensional model component to be picked. 2.如权利要求1所述的三维模型构件的拾取方法,其特征在于,所述确定所述检测射线与待拾取的三维模型构件是否相交进一步包括:2. The method for picking up a three-dimensional model component as claimed in claim 1, wherein determining whether the detection ray intersects with the three-dimensional model component to be picked further comprises: 判断所述待拾取的三维模型构件是否存在包围盒;judging whether there is a bounding box for the three-dimensional model component to be picked; 若所述待拾取的三维模型构件存在所述包围盒,则获取所述包围盒并判断所述检测射线与所述包围盒是否相交;以及If the bounding box exists in the three-dimensional model component to be picked, then acquire the bounding box and determine whether the detection ray intersects the bounding box; and 若所述待拾取的三维模型构件不存在包围盒,或者所述待拾取的三维模型构件存在包围盒但判断出所述检测射线与所述包围盒不相交,则确定所述检测射线与所述待拾取的三维模型构件不相交。If the 3D model component to be picked does not have a bounding box, or the 3D model component to be picked has a bounding box but it is determined that the detection ray does not intersect the bounding box, then determine that the detection ray and the The 3D model components to be picked do not intersect. 3.如权利要求2所述的三维模型构件的拾取方法,其特征在于,若下列中至少一项存在,则判断所述待拾取的三维模型构件不存在包围盒:3. The method for picking up a three-dimensional model component as claimed in claim 2, wherein if at least one of the following exists, it is judged that the three-dimensional model component to be picked does not have a bounding box: 所述待拾取的三维模型构件为具有单个顶点的点状构件;或The three-dimensional model component to be picked is a point-shaped component with a single vertex; or 在所述待拾取的三维模型构件为具有两个顶点的线状构件的情况下,所述线状构件与预设多个平面的至少一个平面平行。In the case that the three-dimensional model component to be picked is a linear component having two vertices, the linear component is parallel to at least one of a plurality of preset planes. 4.如权利要求2所述的三维模型构件的拾取方法,其特征在于,所述方法进一步包括:在存在所述包围盒且判断出所述检测射线与所述包围盒相交的情况下,判断所述待拾取的三维模型构件的顶点连线所组成的多边形与所述检测射线是否相交。4. The method for picking up a three-dimensional model component according to claim 2, characterized in that the method further comprises: when the bounding box exists and it is judged that the detection ray intersects the bounding box, judging Whether the polygon formed by the vertices of the three-dimensional model component to be picked intersects the detection ray. 5.如权利要求4所述的三维模型构件的拾取方法,其特征在于,判断所述待拾取的三维模型构件的顶点连线所组成的多边形与所述检测射线是否相交包括:判断所述待拾取的三维模型构件的任意三个顶点的连线所组成的三角形与所述检测射线是否相交;以及若所有由任意三个顶点的连线所组成的三角形与所述检测射线都不相交,则确定所述检测射线与所述待拾取的三维模型构件不相交。5. The method for picking up a three-dimensional model component according to claim 4, wherein judging whether the polygon formed by the vertex lines of the three-dimensional model component to be picked up intersects with the detection ray comprises: judging that the to-be-picked Whether the triangle formed by the connection line of any three vertices of the picked three-dimensional model member intersects the detection ray; and if all the triangles formed by the connection line of any three vertices do not intersect the detection ray, then It is determined that the detection ray does not intersect with the three-dimensional model component to be picked. 6.如权利要求1所述的三维模型构件的拾取方法,其特征在于,根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组进一步包括:6. The method for picking up a 3D model component according to claim 1, wherein obtaining the first model sub-component group of the 3D model component to be picked up according to preset rules further comprises: 根据待拾取的三维模型构件的索引数据获取第一模型子构件组,其中:Obtain the first model sub-component group according to the index data of the three-dimensional model component to be picked, wherein: 当待拾取的三维模型构件仅包括具有单个顶点的点状子构件或具有两个顶点的线状子构件时,所述第一模型子构件组分别为所述点状子构件或所述线状子构件;以及When the three-dimensional model component to be picked only includes a point-shaped sub-component with a single vertex or a linear sub-component with two vertices, the first model sub-component group is the point-shaped sub-component or the linear sub-component respectively; and 当待拾取的三维模型构件包括除点状子构件或线状子构件以外的三维模型子构件时,所述第一模型子构件组包括根据所述索引数据对待拾取的三维模型构件进行拆分后所形成的具有两个顶点的线状子构件的组合。When the three-dimensional model components to be picked include three-dimensional model sub-components other than point-shaped sub-components or line-shaped sub-components, the first model sub-component group includes A combination of linear subcomponents with two vertices. 7.一种三维模型构件的拾取装置,其特征在于,所述装置包括:7. A pick-up device for a three-dimensional model component, characterized in that the device comprises: 获取模块,用于在确定检测射线与待拾取的三维模型构件不相交的情况下,根据预设规则获取所述待拾取的三维模型构件的第一模型子构件组;An acquisition module, configured to acquire the first model sub-component group of the three-dimensional model component to be picked according to preset rules when it is determined that the detection ray does not intersect with the three-dimensional model component to be picked; 投影模块,用于将所述第一模型子构件组投影至显示平面以获得第二模型子构件组;以及a projection module for projecting the first set of model sub-components onto a display plane to obtain a second set of model sub-components; and 确定模块,用于当确定所述显示平面中的拾取点位置与所述第二模型子构件中的至少一个子构件之间的距离小于预设阈值时,拾取所述待拾取的三维模型构件。A determining module, configured to pick the 3D model component to be picked when it is determined that the distance between the pick-up point position in the display plane and at least one of the second model sub-components is less than a preset threshold. 8.如权利要求7所述的三维模型构件的拾取装置,其特征在于,所述装置还包括判断模块,用于基于拾取点位置构建检测射线,并确定所述检测射线与待拾取的三维模型构件是否相交。8. The picking-up device of a three-dimensional model component as claimed in claim 7, characterized in that, the device also includes a judging module for constructing a detection ray based on the position of the picking point, and determining the relationship between the detection ray and the three-dimensional model to be picked. Whether the components intersect. 9.一种计算机设备,包括存储器、处理器,所述存储器上存储有可在所述处理器上运行的计算机程序,其特征在于,所述处理器执行所述计算机程序时实现权利要求1至7中任一项所述方法的步骤。9. A computer device, comprising a memory and a processor, the memory is stored with a computer program that can run on the processor, it is characterized in that, when the processor executes the computer program, claims 1 to 1 are realized. The step of any one of the methods in 7. 10.一种计算机可读存储介质,其上存储有计算机程序,其特征在于,计算机程序被处理器执行时实现如权利要求1至7任一项所述的三维模型构件的拾取方法中的步骤。10. A computer-readable storage medium, on which a computer program is stored, characterized in that, when the computer program is executed by a processor, the steps in the method for picking up a three-dimensional model component according to any one of claims 1 to 7 are realized .
CN202110476544.5A 2021-04-29 2021-04-29 Pick-up method, device, equipment and storage medium for three-dimensional model components Pending CN115272605A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110476544.5A CN115272605A (en) 2021-04-29 2021-04-29 Pick-up method, device, equipment and storage medium for three-dimensional model components

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110476544.5A CN115272605A (en) 2021-04-29 2021-04-29 Pick-up method, device, equipment and storage medium for three-dimensional model components

Publications (1)

Publication Number Publication Date
CN115272605A true CN115272605A (en) 2022-11-01

Family

ID=83745423

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110476544.5A Pending CN115272605A (en) 2021-04-29 2021-04-29 Pick-up method, device, equipment and storage medium for three-dimensional model components

Country Status (1)

Country Link
CN (1) CN115272605A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116012562A (en) * 2022-12-28 2023-04-25 中建电子信息技术有限公司 A method to quickly complete the model making of BIM 3D visualization platform
CN118570419A (en) * 2024-08-02 2024-08-30 芯瑞微(上海)电子科技有限公司 Methods for determining the spatial positions of vertices and geometric bodies and methods for assigning unit attributes
CN119131227A (en) * 2023-12-04 2024-12-13 叁农数据(广州)有限公司 Three-dimensional object data processing method, device, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0425179A2 (en) * 1989-10-23 1991-05-02 International Business Machines Corporation Object selection detection in a graphics display system
CN103473814A (en) * 2013-09-23 2013-12-25 电子科技大学中山学院 Three-dimensional geometric primitive picking method based on GPU
CN107748643A (en) * 2017-11-10 2018-03-02 济南迅捷万通科技发展有限公司 A kind of interactive object pick-up method based on subsurface three-dimensional space
CN108037870A (en) * 2017-11-03 2018-05-15 福建天晴数码有限公司 A kind of method and terminal of the three-dimensional scenic object pickup based on touch-screen
CN112184870A (en) * 2020-10-13 2021-01-05 成都智鑫易利科技有限公司 Three-dimensional object picking method for three-dimensional graphic software

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0425179A2 (en) * 1989-10-23 1991-05-02 International Business Machines Corporation Object selection detection in a graphics display system
CN103473814A (en) * 2013-09-23 2013-12-25 电子科技大学中山学院 Three-dimensional geometric primitive picking method based on GPU
CN108037870A (en) * 2017-11-03 2018-05-15 福建天晴数码有限公司 A kind of method and terminal of the three-dimensional scenic object pickup based on touch-screen
CN107748643A (en) * 2017-11-10 2018-03-02 济南迅捷万通科技发展有限公司 A kind of interactive object pick-up method based on subsurface three-dimensional space
CN112184870A (en) * 2020-10-13 2021-01-05 成都智鑫易利科技有限公司 Three-dimensional object picking method for three-dimensional graphic software

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
王晏民,郭明等人: "海量精细点云数据组织与管理", 30 April 2015, 北京:测绘出版社, pages: 82 - 91 *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116012562A (en) * 2022-12-28 2023-04-25 中建电子信息技术有限公司 A method to quickly complete the model making of BIM 3D visualization platform
CN119131227A (en) * 2023-12-04 2024-12-13 叁农数据(广州)有限公司 Three-dimensional object data processing method, device, equipment and storage medium
CN118570419A (en) * 2024-08-02 2024-08-30 芯瑞微(上海)电子科技有限公司 Methods for determining the spatial positions of vertices and geometric bodies and methods for assigning unit attributes

Similar Documents

Publication Publication Date Title
JP7498820B2 (en) Deciding on the building layout
CN115272605A (en) Pick-up method, device, equipment and storage medium for three-dimensional model components
CN108062784B (en) Three-dimensional model texture mapping conversion method and device
US10346996B2 (en) Image depth inference from semantic labels
JP4900204B2 (en) Object recognition method
CN110866496A (en) Robot localization and mapping method and device based on depth image
US20160292900A1 (en) Image group processing and visualization
CA3182430A1 (en) Systems and methods for automatic alignment of drawings
US20170059306A1 (en) Point cloud systems and methods
CN113010945A (en) BIM model linkage method and system
CN114494379B (en) Convex hull-assisted three-dimensional point cloud registration method, device and medium based on FPFH
CN113379826A (en) Method and device for measuring volume of logistics piece
CN112528428B (en) Method and device for displaying physical parameters of engineering structure and computer equipment
JP7003617B2 (en) Estimator, estimation method, and estimation program
CN114998433A (en) Pose calculation method and device, storage medium and electronic equipment
CN111813984B (en) Method and device for realizing indoor positioning by using homography matrix and electronic equipment
CN117606991A (en) Three-dimensional parameter acquisition methods, devices, equipment and storage media for geotechnical particles
CN117745996A (en) Method and device for moving three-dimensional view
CN110765513B (en) Connection node placement method and products for wall keel model and L-shaped roof guide beam model
CN117649483A (en) Modeling system for 3D virtual model
CN115018763A (en) Method, device, equipment and storage medium for pit detection based on surface fitting
CN116945145A (en) Touch sensor calibration system, method, device and chip applied to mechanical arm
TWI571753B (en) Electronic calculating apparatus for generating an interaction index map of an image, method thereof and computer program product thereof
JP7594897B2 (en) Information processing device
CN115687673B (en) Picture archiving method and device, electronic equipment and readable storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination