For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings


Need to speed up your development?
Have a look at our:

Samples & Tools


Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

MeshVS_Mesh with MeshVS_ElementalColorPrsBuilder leads in grey selection

Thorsten's picture


I am using MeshVS_Mesh and MeshVS_MeshPrsBuilder to display STL Files (~25MB):

Handle_MeshVS_Mesh newAISMesh = new MeshVS_Mesh();
newAISMesh->SetHilightMode ( MeshVS_DMF_WireFrame);
newAISMesh->SetDisplayMode ( MeshVS_DMF_Shading);
newAISMesh->SetMeshSelMethod( MeshVS_MSM_PRECISE);
Handle(MeshVS_MeshPrsBuilder) prsbuilderHighlighter = new MeshVS_MeshPrsBuilder(
newAISMesh, MeshVS_DMF_OCCMask, datasource);
newAISMesh->AddBuilder(prsbuilderHighlighter, true);
Handle_MeshVS_Drawer drawerHighlighter = prsbuilderHighlighter->GetDrawer();
drawerHighlighter->SetBoolean(MeshVS_DA_DisplayNodes, false);
drawerHighlighter->SetBoolean(MeshVS_DA_ShowEdges, true);

Now I want to read STL Files containing color information and display them. For this I switched from "MeshPrsBuilder" to "MeshVS_ElementalColorPrsBuilder":

Handle(MeshVS_ElementalColorPrsBuilder) prsbuilder = new MeshVS_ElementalColorPrsBuilder(
newAISMesh, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask , datasource);
newAISMesh->AddBuilder( prsbuilder, true);

Handle_MeshVS_Drawer drawer = prsbuilder->GetDrawer();
drawer->SetBoolean(MeshVS_DA_DisplayNodes, false);
drawer->SetBoolean(MeshVS_DA_ShowEdges, false);
drawer->SetBoolean(MeshVS_DA_ColorReflection, true);
drawer->SetBoolean(MeshVS_DA_Reflection, true);

After assigning Color1 and Color2 (fore-/background) to each triangle, each triangle shows up in its individual color.

My problem:
When I select the mesh with the mouse, the whole MeshVS_Mesh turns grey with no reflections or colors other than one grey color.

How can I preserve the individual color representation an reflection in the "selected" state of the mesh?

Best regards

Pawel's picture

I've just come up with this solution:

myMesh->SetDataSource( aTipDS );
myMesh->GetDrawer()->SetBoolean(MeshVS_DA_SmoothShading,Standard_True); //MeshVS_DrawerAttribute

Handle_MeshVS_ElementalColorPrsBuilder aTipColorPrsBuilder = new MeshVS_ElementalColorPrsBuilder( myMesh.operator ->(),
MeshVS_DMF_Shading | MeshVS_DMF_ElementalColorDataPrs, aTipDS );

aTipColorPrsBuilder->SetColors1( aTipDS->GetColorMap() );
myMesh->AddBuilder( aTipColorPrsBuilder, Standard_False /*Standard_True*/ );

Handle_MeshVS_MeshPrsBuilder aTipPrsBuilder = new MeshVS_MeshPrsBuilder( myMesh.operator ->(),
MeshVS_DMF_WireFrame, aTipDS, -1, MeshVS_BP_Default);
myMesh->AddBuilder( aTipPrsBuilder, Standard_True /*Standard_False*/);
myMesh->GetDrawer()->SetBoolean(MeshVS_DA_ShowEdges, Standard_False);
myMesh->GetDrawer()->SetBoolean(MeshVS_DA_Reflection, Standard_True);
myMesh->GetDrawer()->SetBoolean(MeshVS_DA_SmoothShading, Standard_True);
myMesh->GetDrawer()->SetBoolean(MeshVS_DA_ColorReflection, Standard_True);

myMesh->SetDisplayMode( MeshVS_DMF_Shading );
myMesh->SetMeshSelMethod( MeshVS_MSM_PRECISE);

It gives nice shaded visualization using MeshVS_ElementalColorPrsBuilder and selection possibility using MeshVS_MeshPrsBuilder.

... in case anyone still needs it.


Thorsten's picture

Thank you very much!

I tried the same (second Builder of type "MeshVS_MeshPrsBuilder" for selecting) without success. After I deleted the flag "MeshVS_DMF_OCCMask" (as you did), it works. The selection/deselection takes about 30 seconds or so for a 25 MB STL file (260000 points), but this is another problem I also had before.

Thank you :-)