Open CASCADE, the 3D modelling kernel
3D modeling & numerical simulation

Search the Forums
See All Topics
Open CASCADEShowroomGet it!Developer CornerSupport and ProductsAbout us
Technical overview
Areas of use
Shape factory
Shape gallery
What's new
System requirements
Download Center
Public license
Getting started
Open Source community
Training and e-learning
A-la Carte Support
Value-added software
Complementary Components
Customer Corner
Company Profile
Marketing Materials
Contact Us
Home / Developer Corner / Forums / Usage issues / MeshVS_MeshPrsBuilder won't display gouraud shaded objects

MeshVS_MeshPrsBuilder won't display gouraud shaded objects

MeshVS_MeshPrsBuilder won't display gouraud shaded objects
jelle 2013/01/04 02:24
Hi, I'm using MeshVS_MeshPrsBuilder for the fast display of STL meshes, which is so much faster than the more standard StlAPI.
( IMHO converting meshes -> breps by default is a bad idea... the docs also dont state that this conversion is going on, which is worrying )
Even though I'm setting the following flags ( MeshVS_DA_SmoothShading and MeshVS_DA_Reflection are necessary for gouraud shading ):

mesh_drawer.SetMaterial(MeshVS_DA_FrontMaterial, Graphic3d_MaterialAspect(Graphic3d_NOM_SATIN))
mesh_drawer.SetBoolean( MeshVS_DA_DisplayNodes, False)
mesh_drawer.SetBoolean( MeshVS_DA_ShowEdges, False)
mesh_drawer.SetBoolean( MeshVS_DA_SmoothShading, True)
mesh_drawer.SetBoolean( MeshVS_DA_Reflection, True)

I'm not arriving to smooth shading.
Any ideas what might be going wrong?
I've been glancing over the c++ classes and can't figure out why smooth shading wont pan out...



Mark Blome 2013/01/10 20:53
Hi Jelle,

I think this fails because SmoothShading requires mean normal vectors at mesh nodes, not element normal vectors.

MeshVS_MeshPrsBuilder will ask the data source (any class derived from MeshVS_DataSource) about nodal normal
vectors using the function GetNodeNormal(). However by default in MeshVS_DataSource this function returns false,
which will deactivate smooth shading:

Standard_BooleanMeshVS_DataSource::GetNodeNormal( const Standard_Integer ranknode, const Standard_Integer Id, Standard_Real &nx, Standard_Real &ny, Standard_Real &nz)
return Standard_False;

In PythonOCC provided SMESH_MeshVSLink (derived from MeshVS_DataSource ) implemented by Sioutis Fotios this function is not implemented.
I will implement this function and let you know if that would solve this problem (I am working on SMESH_MeshVSLink for speed improvements when displaying
volume meshes at the moment anyway).

Mark Blome 2013/01/11 14:24

smooth shading works nicely with surface meshes if a MeshVS_DataSource3D derived class is
provided to MeshVS_MeshPrsBuilder that implements nodal normal vectors (GetNodeNormal method).
In the attached ZIP file such a class is implemented and two examples are shown (smooth shading visualization
of 2 surface grids created with NETGEN).


You have to be logged in to download the attached file
Latest news
  • New features to enhance the development process
  • Open CASCADE Technology 6.7.1 is available for download!
  • Open CASCADE Technology 6.7.0 is available for download!

  • © OPEN CASCADE 2000 - 2014  |  Search  |  Contacts   |  Site map