Zoom in and display problem

i use occt 7.7 ,the whole program create in .NET CLR
in the using progress,i find when i zoom the object to the max scale,the display effect will deteriorate. the example is such as the figure 11 and 12
i can use which method to control this display behavior ,i expect your help ,think you very much

Attachments: 
gkv311 n's picture

The atrifacts appear when (single) floating point precision math is not enough to provide good results.

Why would you need to zoom in to the model that much? How do use handle Camera to zoom in on OCCT (which API)?

chai senlin's picture

Think you for your reply very much, I use myView()->Zoom(theX1, theY1, theX2, theY2); to complete my 'zoom in' works.
the model is not zoomed too much. The main issue is that this problem occurs when I display some relatively smaller models. And it is quite obvious

chai senlin's picture

I have solved this problem. By using TopoDS_Shape, I was able to construct the triangular face data connection. The display is normal. However, if you use your own Graphic3d_ArrayOfTriangles, this display issue will occur. Especially when you have a large number of coordinate values, I hope this can help those who have such needs.

gkv311 n's picture

If you refer to AIS_Shape, then it creates Graphic3d_ArrayOfTriangles under the hood. Hence, there should be no much difference from a custom presentation created from the same triangles. If you'll share the code of your custom AIS object, then maybe somebody will be able to spot an issue or a bug in it. But anyway, using AIS_Shape is perfectly fine and recommended, if it suits your needs.

Notice that AIS_ViewController implements zooming in at mouse cursor position by default, and adjusts camera properties based on picked 3D point (for which, object should be not only displayed, but also selectable in AIS). But this is unrelated to the method of V3d_View you have mentioned.

chai senlin's picture

I have done some more work recently and found that the main cause is that the coordinates of my graphics are too large. The specific values can be referred to in the following diagram. When I use the following shading mode, this problem will occur. Handle(Graphic3d_Aspects) ga = new Graphic3d_Aspects; ga->SetColor(m_color); ga->SetShadingModel(Graphic3d_TOSM_FACET);

When the coordinates are very large, this problem will occur with only a small proportion of scaling. This problem can be solved by using "smooth", but "smooth" does not meet my requirements. The "smooth shading" will flatten my step ridges.As shown in the third and fourth figures below,The fourth picture represents my ideal outcome.I am still troubled by trying to solve this problem, but there is still no good solution at present.

gkv311 n's picture

These values are indeed very large. Too large for single precision floating precision numbers used by GPUs for rendering. Here is another post on the forum related to this subject.

Switching to double precision in rendering is usually not an option, but there are some workarounds / tricks that could be used to cope with the problem to some extent.

OCCT provides Graphic3d_ZLayerSettings::Origin() property that could be used to avoid loosing geometry precision on conversion to single precision floating point numbers.

However, it is not applied automatically - it is responsibility of application to move distant objects into separate Z Layer(s) with permissable origin, and the apply local transformation to the object to keep its geometry within single floating point limits. This would, however, not resolve other kind of issues when scene will try to fit objects at different extents.

Here is a live example of its effect: Layer origin - Draw sample

chai senlin's picture

Thank you very much for your help. I plan to put this issue aside for now and take some time to study it further based on the examples you provided, to see if there are any good solutions. Once again, I would like to express my gratitude and best wishes for all to go smoothly.