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_Mesh with MeshVS_ElementalColorPrsBuilder leads in grey selection

MeshVS_Mesh with MeshVS_ElementalColorPrsBuilder leads in grey selection

MeshVS_Mesh with MeshVS_ElementalColorPrsBuilder leads in grey selection
spam killer 2012/04/05 12:14

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
You have to be logged in to download the attached file
Pawel 2013/01/09 14:47
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.

spam killer 2013/01/09 18:35
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 :-)

Latest news
  • Open CASCADE Technology 6.7.0 is available for download!
  • Open CASCADE Technology 6.6.0 is available for download!
  • Open CASCADE Technology 6.5.5 is available for download!

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