Example for MeshVS_NodalColorPrsBuilder

Hello,

I have found some examples for MeshVS_MeshPrsBuilder and it works well. But i want to colorize each triangle in a different color. MeshVS_NodalColorPrsBuilder or MeshVS_ElementalColorPrsBuilder should do the job. But i could'nt get both to work.

Does anybody has an example for MeshVS_NodalColorPrsBuilder or MeshVS_ElementalColorPrsBuilder? Or an instruction how to handle these builder?

Thanks for your help.

Brandt

Sebastian Starkey's picture

Hi Brandt,

Did you solve your problem? I am trying to do something similar.

Thanks a lot,

Sepp Forcher's picture

hello,

you can do it with MeshVS_ElementalColorPrsBuilder:

Handle_MeshVS_ElementalColorPrsBuilder aBuilder = new MeshVS_ElementalColorPrsBuilder( meshVS, MeshVS_DMF_ElementalColorDataPrs | MeshVS_DMF_OCCMask);
const TColStd_PackedMapOfInteger& anAllElements = meshVS->GetDataSource()->GetAllElements();
TColStd_MapIteratorOfPackedMapOfInteger anIter(anAllElements);

for ( ; anIter.More(); anIter.Next() )
{
aBuilder->SetColor1( anIter.Key(), Quantity_Color(Quantity_NOC_WHITE));
}
int nBuilder = meshVS->GetBuildersCount();
if(nBuilder > 1)
meshVS->RemoveBuilder(nBuilder-1);
meshVS->AddBuilder( aBuilder, Standard_True );