VTK vs AIS

A-U

Active CAD practitioner
I think I'm hitting some limitations of the AIS module (or the documentation thereof - e.g. how do I display an edge with the orientation indicated).

Is it worthwhile to invest time into converting to OCCT+VTK? Are there any other alternatives that should be considered? I'm looking for some subjective opinions to form my own...

Thanks!
 

Quaoar

Administrator
Staff member
My subjective opinion is that VTK is much more flexible from the architectural point of view compared to AIS, although AIS outperforms VTK for larger scenes. I have no idea how to draw an orientation glyph with AIS, and I am not sure to get any community help on that matter as I'm not sure that the community is consolidated enough.

At the same time I have had hard times to get visually appealling scenes with VTK. One unresolved problem for me is to draw CAD edges on top of CAD faces without visual artifacts and z-fighting. In AIS, the quality of rendering looks good out of the box.

If I had time and enough courage, I would definitely avoid using both frameworks and tried to implement this stuff with pure OpenGL to see where I can get.
 
  • Like
Reactions: A-U

blobfish

CAD community veteran
I think I'm hitting some limitations of the AIS module (or the documentation thereof - e.g. how do I display an edge with the orientation indicated).

Is it worthwhile to invest time into converting to OCCT+VTK? Are there any other alternatives that should be considered? I'm looking for some subjective opinions to form my own...

Thanks!
I haven't used either so my opinion shouldn't count for much. IMHO: I have enough bugs from occt and I never use it for anything that I can do anywhere else. Isn't VTK made by the same people that came up with cmake? ${THAT_IS_ALL_I_NEED_TO_KNOW}. I have used coin3d and OpenSceneGraph(OSG). I like OSG!



At the same time I have had hard times to get visually appealling scenes with VTK. One unresolved problem for me is to draw CAD edges on top of CAD faces without visual artifacts and z-fighting. In AIS, the quality of rendering looks good out of the box.

If I had time and enough courage, I would definitely avoid using both frameworks and tried to implement this stuff with pure OpenGL to see where I can get.
for z fighting look for glDepthRange. I would be afraid of OpenGL would be deprecated by the time I got up to speed with it. If I was to head down that road, I would go Vulkan.
 

Quaoar

Administrator
Staff member
IMHO: I have enough bugs from occt and I never use it for anything that I can do anywhere else.
I agree on that. OpenCascade is all about modelling and data exchange and it's better if it stayed in that niche, not trying to do everything. There are graphics libs, and OCC will never outcompete them simply because it's a huge topic in itself. I quickly checked the manual of OSG, and it looks promising. It will be interesting to see how well does it play with CAD.

I think, in general, such an approach of having the complete SDK, including modelling, solver, data exchange, snd visualization all in one package is not a bad idea after all. Just like a Toyota car is composed of original components only. But, frankly speaking, OpenCascade is not Toyota. Maybe a good example here would be C3D kernel, but I have never used it in production and it's not free.
 

blobfish

CAD community veteran
I agree on that. OpenCascade is all about modelling and data exchange and it's better if it stayed in that niche, not trying to do everything. There are graphics libs, and OCC will never outcompete them simply because it's a huge topic in itself.
I agree 100%. A few years back OCC put out a message about wanting to hire opengl developers because they wanted to develop a new graphics API. I did a huge eyeroll. I understand their dilemma, they are trying to sustain a business so they have to go where they think the money is. Unfortunately I think most businesses consider the solid modelling kernel a solved problem by the big commercial cad companies and see little point in investing in occt modeling algos. Just my point of view.


I quickly checked the manual of OSG, and it looks promising. It will be interesting to see how well does it play with CAD.
It is a general scenegraph so some of the higher level stuff that is present in other apis might not be there, but I would guess there is nothing to stop you from implementing what you need. If you are curious about OSG and CAD, you could download and build cadseer ;) screenshots


I think, in general, such an approach of having the complete SDK, including modelling, solver, data exchange, snd visualization all in one package is not a bad idea after all. Just like a Toyota car is composed of original components only. But, frankly speaking, OpenCascade is not Toyota. Maybe a good example here would be C3D kernel, but I have never used it in production and it's not free.
Yeah it would be nice if we had a 'one stop' API for all things CAD, I just think it might be 'pie in the sky'. OCC is spread way to thin and I don't think they are doing anything particularly well. Of course I have never used their commercial offerings, so maybe those are of a higher caliber.
 

Jojain

CAD practitioner
Being a total novice at 3D graphics (and even c++ actually) does these others toolkits offers simple API for selections shapes and stuff or do you have to implement everything yourself ?
With my very little knowledge of AIS, it seems that it comes with most of the feature one would expect from a basic CAD application, doesn't it ?
 

A-U

Active CAD practitioner
At the same time I have had hard times to get visually appealling scenes with VTK. One unresolved problem for me is to draw CAD edges on top of CAD faces without visual artifacts and z-fighting. In AIS, the quality of rendering looks good out of the box.

Did you tried reaching out to the vtk community regarding the issues? Is this a "wontifix" kind of a situation?
 

Quaoar

Administrator
Staff member
Did you tried reaching out to the vtk community regarding the issues? Is this a "wontifix" kind of a situation?
Nope, I haven't. I have actually always thought that I'm lacking some fundamental OpenGL knowledge.
 

Quaoar

Administrator
Staff member
Being a total novice at 3D graphics (and even c++ actually) does these others toolkits offers simple API for selections shapes and stuff or do you have to implement everything yourself ?
Yeah, AIS is a pretty high-level thing compared to VTK. I think it's good to get started, but once you hit its limitations, you'll have to go deeper.
 

natalia

Moderator
Staff member
I think I'm hitting some limitations of the AIS module (or the documentation thereof - e.g. how do I display an edge with the orientation indicated).
How doing this with the AIS module of OCCT:

If under “an edge with the orientation indicated” we consider a line with the arrow at the end, AIS_Line is the simplest way to have it. By default, this presentation has no arrow at the end. For visualizing it, just correct attributes in the following way:

the codethe result
// creating the presentation
Handle(Geom_CartesianPoint) pointA = new Geom_CartesianPoint(50., 50., 0.);
Handle(Geom_CartesianPoint) pointB = new Geom_CartesianPoint(100., 80., 0.);
Handle(AIS_Line) line= new AIS_Line(pointA, pointB);

// switch ON arrow using
line->Attributes()->SetLineArrowDraw( Standard_True);
line ->Attributes()->SetArrowAspect(new Prs3d_ArrowAspect(15./*angle*/, 5./*length*/));

// visualize presentation in context
AISContext->Display (line, Standard_True);
1633513486761.png

Here, 3D segmented arrow is visualized (constructed with Prs3d_Arrow:: DrawSegments).

At the same time, there are lots of parameters that the custom application requires to settle, like 3D or 2D arrow type, arrow length, angle, thickness and others. So, another and more flexible way is implementing a new presentation by ourselves using the standard approach of OCCT presentations creation (“https://dev.opencascade.org/doc/overview/html/occt_user_guides__visualization.html”, rows “If you are creating your own type…”).

We need to:

- create inheritance from the AIS_InteractiveObject,

- redefine Compute() and prepare graphical elements,

- redefine ComputeSelection() [optional, only if processing of selection is necessary for the presentation]

Samples of other arrow presentations that might be useful to fill Compute() of this custom presentation:

arrow kinddraw command/test (based on OCCT-750)previewhow to
Shaded 3D arrow

samples are:
AIS_Trihedron,
AIS_ViewCube,
AIS_Manipulator
vtrihedron t -drawAxes X -hideLabels on -dispmode sh -attribute TubeRadiusPercent 0.005 -color XAxis white -color origin white1633513496223.pngcall Prs3d_Arrow:: DrawShaded()
2D arrow

sample is:
PrsDim_AngleDimension
tests\v3d\dimensions\angle1801633513501804.pngImplement the primitives creation as in PrsDim_Dimension:: DrawExtension()
some 3D arrows in one presentation

MeshVS_Mesh
tests\v3d\mesh\B71633513530745.pngImplementation is similar to
MeshVS_VectorPrsBuilder:: DrawVector()

Also, it is always possible to prepare a topology shape that contains the edge and orientation lines and fill AIS_Shape with it.

OCCT visualization toolkit is not a container of presentations for all cases. However, it contains lots of samples of how a presentation of interest might be constructed.
 

Attachments

  • 1633513226441.png
    1633513226441.png
    2.8 KB · Views: 6
  • 1633513307963.png
    1633513307963.png
    1.8 KB · Views: 3
  • 1633513345707.png
    1633513345707.png
    2.3 KB · Views: 5
Last edited:

Quaoar

Administrator
Staff member
@A-U In CQ, I noticed a sort of an issue that I'm constantly having with VTK but never with AIS. It's the offset rendering of coincident topology:

1634799294030.png
Is there anything specific you're doing about rendering edges on top of the shaded presentation? Or is it my local problem maybe?
 

A-U

Active CAD practitioner
Yes, I see it too. It only happens with the axes helpers (AIS_Line objects AFAIR). If you hide them (untick the boxes next to XYZ) it will render fine. It never bothered me so I did not investigate. Help will be always appreciated :).
 
Last edited:

Quaoar

Administrator
Staff member
I've just come across this link about VTK history from its authors:

https://vimeo.com/610315121/eca95f4af0

Could be interesting to watch while having a cup of coffee.
 

Quaoar

Administrator
Staff member
@A-U yes, I have been playing with these offset props from day one. Actually, I never succeeded in fighting the glitches the guy from the forum is talking about. Here's what I mean (click to enlarge):

1637091544014.png
My approach was a mix of tricks, and on Windows, I got satisfactory results by enabling "rendering edges as tubes." With that shader enabled, edges look thick enough to appear on top of the facets. That did not work on Linux though. All in all, it looked dirty, and it might be interesting to dig deeper into OpenCascade's AIS to find out their method for coincident topology solving.

Btw, setting the parameters to 0.5, 100 as proposed on the VTK forum only make things worse:

1637092016227.png

So here is the thing: it's unclear how to tune these settings, and the entire approach looks a bit dirty to me (maybe I'm wrong and that's Ok though). I know it all sounds like fighting for perfectionism, but when I see all such things working out of the box in random CAD tools, I feel a little bit envious.
 
Last edited:

A-U

Active CAD practitioner
With vtk.js I had to tune the params somewhat. I tried also with regular vtk (9) and it seems that this combinations gives quite nice results:
Code:
mapper.SetResolveCoincidentTopologyToShiftZBuffer()
mapper.SetResolveCoincidentTopologyZShift(0.2)
I wish I understood what I'm doing.
 

Quaoar

Administrator
Staff member
With vtk.js I had to tune the params somewhat. I tried also with regular vtk (9) and it seems that this combinations gives quite nice results:
Code:
mapper.SetResolveCoincidentTopologyToShiftZBuffer()
mapper.SetResolveCoincidentTopologyZShift(0.2)
I wish I understood what I'm doing.
Interesting. How do you load CAD geometry into a vtk.js scene?
 
Top