Problems with MeshVS

Hi all,

I've done my first steps with MeshVS and have some problems.
Here's what I do:

1) build a MeshVS
Handle(Im_MeshDataSource) aDS = new Im_MeshDataSource(theMesh);
Handle(MeshVS_Mesh) aMesh = new MeshVS_Mesh();
aMesh->AddBuilder(new MeshVS_MeshPrsBuilder(aMesh.operator->()), Standard_True);

aMesh->SetDisplayMode( MeshVS_DMF_Shading );
if (m_pAISContext->HasOpenedContext())
m_pAISContext->Redisplay( aMesh );

2) for changing the display style (for AIS_InteractiveObject):
Handle(AIS_InteractiveContext) theContext = m_canvas->GetAISContext();
m_canvas->GetClientSize(&width, &height);
m_canvas->GetDocument()->GetAISContext()->Select (0,0,width,height,m_canvas->m_View);

for(theContext->InitCurrent(); theContext->MoreCurrent(); theContext->NextCurrent())

And here's the problem: after adding the mesh to my AIS_InteractiveContext it is always selected. But I cant change the display style because theContext has no current objects.

Anyone has an hint for me?



Sharjith Naramparambath's picture

Dear Patrik,

I am also trying to use MeshVS but cannot atall find any good start point. Searching the forum I came across the code put up by you here. But I could not find any Im_MeshDataSource class. Also please specify how the variable theMesh is declared.

Thanks in advance

N. Sharjith

Patrik Mueller's picture


you cannot find one: Im_MeshDataSource is my class derived from MeshVS_DataSource. The same with theMesh: its a variable for an OpenMesh class from me.

So what kind of mesh data do you have?



Sharjith Naramparambath's picture

I don't have any mesh data yet. The thing is that I want to make a mesh from BRepMesh::Mesh. The sample shows how to explore through the TopoDS structure and create triangulation of each face and make vertices and edges and all. I would be using this information for operation on the triangles but I want to display the mesh using color gradient etc. For this I have understood that MeshVS is the right thing. I have also studied the classes and found that it requires some datasource. I have also gone through the XSDRAWSTLVRML classes. It seems I will have to make a custom datasource. Please give some guidance and hints.

Thanks and Regards,
N. Sharjith

Fotis Sioutis's picture

Hello Nair.
I remembered that in the past i created a test DataSource class for BRepMesh_Discret objects.I also modified it for the other algos used in OCC, but i cannot find these modifications ... Anyway you can get it at

I hope i was of some help to you



Sharjith Naramparambath's picture

Thanks a ton Fotis! I will start experimenting with the help of your code.

Thanks and Regards,
N. Sharjith