Opencascade Hidden Line Removal

Source: Internet
Author: User

opencascade Hidden Line removal

[Email protected]

Abstract. To provide the precision required in industrial design, drawings need to offer the possibility of removing lines, which AR e hidden in a given projection. Opencascade provides, algorithms for this Hidden line removal component. The paper mainly translate the document of Opencascade Modeling algorithms, and give some applications in the plant design CAD software.

Key Words. Opencascade, HLR, Hidden line removal

1. Introduction

It is an important content to use computer to generate the real graphics of three-dimensional objects, and when describing objects with display equipment, three-dimensional information must be transformed by some projection and plotted on two-dimensional display plane. Because the projection transform loses the depth information, it often leads to the two semantics of the graph. To eliminate such two semantics, it is necessary to eliminate obscured lines or polygons when plotting, which is customarily known as the elimination of hidden lines (Hidden line removal) or the elimination of hidden faces (Hidden face removal). In engineering applications, it is necessary to automatically generate two-dimensional drawings based on three-dimensional models for directing production. One of the two-dimensional drawings mainly includes the three-dimensional model of the hidden map, dimension and part number labeling and other content. 1.1 is shown in a CAD software automatically based on the three-dimensional model to generate two-dimensional drawings:

Figure 1.1 Drawing generated from 3D model by PDMS

1.1 is shown in the PDMS software automatically generated drawings, drawings in the graphics area of the pipeline model is based on the three-dimensional model of automatic projection and blanking after the generation. It also generates dimensions and pipe names, as well as information about the item number or material table in the upper-right corner.

Although now 3D PDF format is very popular, but the two-dimensional production drawings in the current domestic design and construction units are still indispensable. When the model is large, the blanking speed and auto-generated label text are arranged neatly (or meet the Engineering habit), which is the core technology of the automatic generation of the two-dimensional drawing, and also the difficulty in the process.

The principle of the blanking algorithm is actually very simple, as long as two conditions are satisfied:

V Object A is behind the object B;

V Object A and object B have overlapping parts on the projection plane;

The previous condition is actually generalized, which can be either an object or a polygon or a line. Propositional object A is formed behind object B, and the blanking calculation becomes a two-dimensional problem: The overlapping part of object A and object B on the projection plane is the part of a being eliminated. After the projection transformation, the area occupied by the object on the projection plane is called the falling shadow area of the object, and the projection of any point on the object falls within the shadow area. Obviously, if the shadow area of two objects in space is overlapping, then the object at the back will be obscured by the front object, and the part that is obscured is the overlapping part of the falling shadow area. The blanking process is to find the public part of the two, and to judge the process of both before and after by the third dimension depth coordinate. Because it is a line output, this process is a comparison of lines with each object (face), the final visible part of the intersection is the final visible part of this line.

Opencascade provides two types of blanking algorithms: Hlrbrep_algo and Hlrbrep_polyalgo. These algorithms are based on the same principle: compare the visibility of each edge of a shape relative to each polygon, and calculate the visible and hidden portions of each edge. The algorithm removes or marks quilt cover obscured edges by calculating the object display characteristics in the specified projection direction. These two algorithms are also used in conjunction with some extraction functions, such as refactoring a simplified model and so on, the new model is made up of edges, which is the contour line in the projection direction.

Hlrbrep_algo is a high-precision algorithm based on the model, and Hlrbrep_polyalgo is a discrete data based algorithm. Accurate results can be obtained when using Hlrbrep_algo, while Hlrbrep_polyalgo can be used to increase the computational speed. Both of their algorithms can handle any type of model, such as composition, polygon, or line, but there are constraints that are not processed as follows:

V-point is not processed;

The V z plane is not clipped;

V Infinite face or line is not processed;

1.2 shows the definition of some of the edges in Opencascade:

Figure 1.2 sharp, smooth and sewn edges in a simple screw shape

The solid line in Figure 1.3 is an outer contour line of the same phase shape, and the dashed part is an equal parameter line.

Figure 1.3 Outline edges and isoparameters in the same shape

Figure 1.4 A extraction showing hidden sharp edges

1.4 It can be seen that the blue dashed line is the blocked thread that should be removed.

2.HLR Usage

The use of the Opencascade hidden line removal algorithm involves several steps:

2.1 Loading Shapes

By using the Hlrbrep_algo::add () function, the shape that needs to be hidden is added to the blanking algorithm. For Hlrbrep_polyalgo objects, use the Hlrbrep_polyalgo::load () function to add one or more shapes that need to be processed.

2.2 Setting View Parameters

The projection direction is set by the function Hlrbrep_polyalgo::P rojector (), whose parameters are a Hlralgo_projector object. This projection data is usually obtained based on the three-dimensional view data, and then the projection parameters that need to be hidden are set.

2.3 Computing The projections

The outer contour of the model is computed through the function hlrbrep_polyalgo::update () in the class Hlrbrep_polyalgo. When using the class Hlrbrep_algo, the Hlrbrep_algo::update () algorithm must be called to calculate the model visible and hidden lines by calling Method Hlrbrep_algo::hide (). When you use class Hlrbrep_polyalgo, the visible and hidden lines are calculated by Hlrbrep_polyhlrtoshape.

2.4 Extracting Edges

After the Hlrbrep_hlrtoshape and Hlrbrep_polyhlrtoshape could be free the hidden model data, the extracted data sources correspond to Hlrbrep_algo and Hlrbrep_polyalgo objects respectively. The types that can be extracted are:

V Visible/hidden sharp edges;

v Visible/hidden Smooth edges;

v Visible/hidden sewn edges;

v Visible/hidden outline edges;

The extract operation is implemented by the function hlrbrep_polyhlrtoshape::update.

3.Examples

In order to produce functions similar to the draft function modules of Aveva PDMS, a hidden line elimination algorithm is required to automatically generate two-dimensional drawings based on the model. The following code is a simple example of a test HLR algorithm:

osg::node* TESTPOLYHLR (void) {osg::ref_ptr<osg::Geode> Ageode =NewOsg::geode (); Osg::ref_ptr<osg::Geometry> Alinegeometry =NewOsg::geometry (); Osg::ref_ptr<osg::Vec3Array> avertices =NewOsg::vec3array ();    Topods_shape Apipemodel; Breptools::read (Apipemodel,"D:/pipemodels/2007.brep", Brep_builder ()); Brepmesh_incrementalmesh Amesher (Apipemodel,0.1);    Osd_timer Atimer;    Atimer.start (); Handle_hlrbrep_polyalgo Ahlrpolyalgo=NewHlrbrep_polyalgo ();    Hlralgo_projector Aprojector;    Hlrbrep_polyhlrtoshape Ahlr2shape; Ahlrpolyalgo-Load (Apipemodel); Ahlrpolyalgo-projector (aprojector); Ahlrpolyalgo-Update ();    Ahlr2shape.update (Ahlrpolyalgo);    Atimer.stop ();    Atimer.show (std::cout);  for(Topexp_explorer E (Ahlr2shape.vcompound (), Topabs_edge); E.more (); E.next ()) {Topods_edge Anedge=Topods::edge (E.current ()); Topods_vertex Afirstvertex=Topexp::firstvertex (Anedge); Topods_vertex Alastvertex=Topexp::lastvertex (Anedge); GP_PNT Afirstpoint=Brep_tool::P nt (Afirstvertex); GP_PNT Alastpoint=Brep_tool::P nt (Alastvertex); Avertices-push_back (OSG::VEC3 (Afirstpoint.x (), Afirstpoint.y (), afirstpoint.z ()); Avertices-push_back (OSG::VEC3 (Alastpoint.x (), Alastpoint.y (), alastpoint.z ()); }     for(Topexp_explorer E (Ahlr2shape.outlinevcompound (), Topabs_edge); E.more (); E.next ()) {Topods_edge AnEdge 
    =Topods::edge (E.current ()); Topods_vertex Afirstvertex=Topexp::firstvertex (Anedge); Topods_vertex Alastvertex=Topexp::lastvertex (Anedge); GP_PNT Afirstpoint=Brep_tool::P nt (Afirstvertex); GP_PNT Alastpoint=Brep_tool::P nt (Alastvertex); Avertices-push_back (OSG::VEC3 (Afirstpoint.x (), Afirstpoint.y (), afirstpoint.z ()); Avertices-push_back (OSG::VEC3 (Alastpoint.x (), Alastpoint.y (), alastpoint.z ()); } alinegeometry-Setvertexarray (avertices); Alinegeometry->addprimitiveset (NewOSG::D rawarrays (osg::P rimitiveset::lines,0, avertices->size ())); Ageode-adddrawable (alinegeometry); returnageode.release ();}

Based on the usage described above, you can generate a result that contains only the blanking of the segment data, and then display the results in OpenSceneGraph as shown:

Figure 3.1 HLR for pipe model

Figure 3.2 HLR pipe model in OpenSceneGraph

Figure 3.3 HLR Time usage

As shown in Figure 3.2, a simple pipeline model after Hlrbrep_polyalgo blanking, generating a lot of line data, but the figure 3.3 shows that the HLR blanking speed is relatively fast. Because Hlrbrep_polyalgo is based on discrete meshes and visual data, less data is generated when the discrete accuracy is reduced. If the discrete precision is reduced, the resulting segment data is significantly reduced.

Figure 3.4 HLR pipe model in less tesslate precision

Figure 3.5 HLR Pipe model in less tesslate precision time usage

It is shown from figure 3.4 and figure 3.5 that when the discrete precision of the model is reduced, the segment data resulting from blanking is obviously reduced without affecting the two-dimensional graphic quality after blanking, and the speed of the blanking algorithm is obviously much faster. Therefore, the discrete precision is also a key factor of HLR blanking algorithm, and it is necessary to choose the suitable discrete precision when using the blanking HLR algorithm.

4.Conclusion

In conclusion, Opencascade hidden line to eliminate the HLR algorithm is relatively simple to use, but a thorough understanding of the algorithm, or need to calm down, debug into the code, in understanding the general principle of the basis of its implementation for further understanding.

To use Opencascade's HLR algorithm, the two-dimensional data of the model can be obtained if the projection parameters are specified and the model is loaded to eliminate hidden. If you want to speed up the algorithm to reduce the two-dimensional contour data of the model, we need to select the appropriate mesh discrete precision.

5. References

1. Opencascade Modeling Algorithms User Guide6.8.0 2014

2. What reinforcements. Computer graphics. Mechanical industry press. 2010

3. Sun Jia. Computer graphics. Tsinghua University Press. 2000

PDF Version:opencascade Hidden Line Removal

Opencascade Hidden Line Removal

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.