HLR algorithm gives empty shapes for GLTF model.

Hello,

I am trying to run HLR algorithm on the shapes obtained from an imported GLTF model. But I always get empty shapes
when I extract using HLRBRep_PolyHLRToShape class. This happens when using HLRBRep_PolyAlgo as well as HLRBRep_Algo.
I do get expected results for STEP and IGES models though.
Can anyone please help me with this?

Thankyou.

Kirill Gavrilov's picture

Existing HLR algorithm requires B-Rep definition on input, so that it cannot produce any results for triangulation-only geometry imported from glTF (or STL file). This is a limitation of specific algorithm (cannot say if it might be improved to handle such geometry or that doesn't make sense).

Prajwal Shelar's picture

Thanks Kirill.

Is there any way in which we can convert triangulation-only geometry/shapes to B-Rep?

Prajwal Shelar's picture

Hi Kirill,
I found at that, CAD Assistant v1.6.1 has a 'Hidden Line' mode in 'Display Mode' and displays HLR for glTF . Does it use some other algorithms ?

Kirill Gavrilov's picture

 Prajwal Shelar wrote:

Does it use some other algorithms ?

It is a visualization-only HLR feature basically drawing a silhouette of closed parts (Graphic3d_Aspects::ToDrawSilhouette()).

Prajwal Shelar's picture

Thanks Kirill !

Is it Graphic3d_Aspects::ToDrawSilhouette() or Graphic3d_Aspects::SetDrawSilhouette() ?
Also, can you please provide some more details on how to use it?

Regards,
Prajwal

Prajwal Shelar's picture

Hi Kirill,
I tried building solid shape by using Poly_Triangulations obtained from the faces of shapes of gltf and from these Poly_Triangulations I build wires,faces,shells and finally solid shape by using (BRepBuilderAPI_MakeSolid). I then used this shape for HLR algorithm and got non-empty shapes. But these also include mesh edges of triangulations (snapshot attached). Is there any
way to eliminate these mesh edges from the shape (TopoDS_Shape) and get expected result as shown in second snapshot ?
Thank You!

Attachments: 
Kirill Gavrilov's picture

 Prajwal Shelar wrote

I tried building solid shape by using Poly_Triangulations obtained from the faces of shapes of gltf and from these Poly_Triangulations I build wires,faces,shells and finally solid shape by using (BRepBuilderAPI_MakeSolid)

From attached screenshot it looks like some individual triangles being put into dedicated TopoDS_Face. Maybe sharing result .brep shape could be useful.

Prajwal Shelar's picture

Thanks Kirill.
Here are the .brep files.

Kirill Gavrilov's picture

The first problem is geometry continuity of Edges shared between Faces. HLR is expected to draw edges on hard connections, and in your case it is almost every edge as planar faces doesn't connect smoothly: HLRBRep_Algo produces the following result on your shape:

vs. HLRAlgo_PolyAlgo:

I think that HLRAlgo_PolyAlgo does some simpler check to detect hard edges here - by comparing surface normals at connected edges or something like that, so that we see redundant edges being dropped on a planar topping. So that to get rid of redundant edges at round corners you need to detect which triangles are smoothly connected (with some angle tolerance) and encode this information somehow into B-Rep.

However, in your case a simple angle smoothing check wouldn't give desired result. If we will consider 20 degrees as a smooth angle we will end up with almost no hard edges in your case (I'm drawing Face Boundaries here as their drawing is based on BRep_Tool::MaxContinuity() check that could be easily overridden in Draw with help of BRepLib::EncodeRegularity()):

pload MODELING VISUALIZATION
restore HLRInputShape.brep b
encoderegularity b 20
vinit View1
vdisplay -dispMode 1 b
vaspects b -faceBoundaryDraw 1 -mostContinuity c0
vfit

This is because this shape has smoothing fillets, so that almost all connections are expected to be smooth. Image from your expectations cannot be achieved like that:

To detect edge lines on your attached image you really need an algorithm that would detect features like fillets, holes, round corners and other things (depending on complexity of your real models), classify them and perform segmentation of your input STL file into domains.

Only after that processing (usually called "defeaturing") it would make sense to think about generating a HLR image out of that...

Prajwal Shelar's picture

Thank you so much Kirill for the detailed explanation.

Prajwal Shelar's picture

Hi Kirill,
As in my case, every triangle is a face (TopoDS_Face) , if I group all the triangular faces together, is it possible to construct a single TopoDS_Face from this group with only outer edges?