MeshVS_Mesh question

Hello guys!

I have a mesh presentation MeshVS_Mesh. With the MeshVS_Drawer I can display the whole mesh by using SetBoolean(MeshVS_DA_ShowEdges,Standard_True). Is there any possibility to just show the edges at mesh boundaries (like a outline)?

Regards,
Alex

Alexander Luger's picture

This is still a hot topic for me. Does anyone have an idea how to solve this issue?

Regards,
Alex

jelle's picture

Perhaps this snippet helps?

aDS = SMESH_MeshVSLink(mesh)
aMeshVS = MeshVS_Mesh(True)
DMF = 2 # to wrap; 1 is wireframe
MeshVS_BP_Mesh = 5 # To wrap!
aPrsBuilder = MeshVS_MeshPrsBuilder(aMeshVS.GetHandle(),DMF,aDS.GetHandle()) #,0,MeshVS_BP_Mesh)

aMeshVS.SetDataSource(aDS.GetHandle())
aMeshVS.AddBuilder(aPrsBuilder.GetHandle(),False)
MeshVS_DMF_HilightPrs = int(0x0400)
MeshVS_DMF_Wireframe = int(0x0001)
MeshVS_DMF_Shading = int(0x0002)

<< shaded >>

aMeshVS.SetDisplayMode(MeshVS_DMF_Shading) # 1 -> wireframe, 2 -> shaded

<< wireframe >>

# aMeshVS.SetDisplayMode(MeshVS_DMF_Wireframe) # 1 -> wireframe, 2 -> shaded

jelle's picture

-> SetBoolean(MeshVS_DA_ShowEdges,Standard_True)

Yikes, I didnt read very careful...

Alexander Luger's picture

Yes, that's my problem. I don't want to see the whole mesh in wireframe, just the boundaries.

Mark Blome's picture

Hi Alex,

I think this is not possible with SMESH_MeshVSLink out of
the box. I was looking for such a feature (but couldn't find it)
because displaying volume meshes with lot's of tetrahedra can become
painfully slow when displaying all the triangular faces.

I basically ended up re-implementing SMESH_MeshVSLink sorting out
the boundary triangles myself. I would be happy to share this
code in case you are interested.

Regards,
Mark

Alexander Luger's picture

Hi Mark.

Thank you for your reply! I would be very thankful if you could share your code with me.

Regards,
Alex

Mark Blome's picture

Hi Alex,

attached you'll find my improved version of MeshVSLink.

You can use it something along the lines of this:

(note that by default it will display all elements in MeshVS_DMF_WireFrame/MeshVS_DMF_Shrink
and only boundary triangles in MeshVS_DMF_Shading, but this should be easy to change)

displaymode=1 # 0:MeshVS_DMF_Shading, 1:MeshVS_DMF_WireFrame, 2:MeshVS_DMF_Shrink
submesh = mesh.GetSubMesh(shape)
smoothshading = False
meshvslink = SMESH_MeshVSLink2(mesh, submesh, displaymode, smoothshading)
ais_shape = MeshVS_Mesh(True) # MeshVS_Mesh is derived from AIS_Shape
DMF = 0x0400 | 0x0200 | MeshVS_DMF_WireFrame | MeshVS_DMF_Shading # display mode flags
MeshVS_BP_Mesh = 5
aPrsBuilder = MeshVS_MeshPrsBuilder(ais_shape.GetHandle(),DMF, meshvslink.GetHandle(),0,MeshVS_BP_Mesh)
ais_shape.SetDataSource(self._meshvslink.GetHandle())
ais_shape.AddBuilder(aPrsBuilder.GetHandle(),True)
ais_shape.SetDisplayMode(MeshVS_DMF_Shading)
mesh_drawer = self._ais_shape.GetDrawer().GetObject()

# in shaded display mode when displaying volume grids inner faces are hidden to speed up display
# performance, therefore we need to call GetHiddenNodes/GetHiddenElements here
# (see SMESH_MeshVSLink2 implementation for details)
cutplane = 0 # 0: not active, 1:X, 2:Y, 3:Z, 4:-X, 5:-Y, 6:-Z
cutplane_value = 0.0
hiddennodes_h = TColStd_HPackedMapOfInteger()
hiddenelems_h = TColStd_HPackedMapOfInteger()
meshvslink.GetHiddenNodes(cutplane, cutplane_value, hiddennodes_h.Map())
meshvslink.GetHiddenElements(cutplane, cutplane_value, hiddenelems_h.Map())
ais_shape.SetHiddenNodes( hiddennodes_h.GetHandle() )
ais_shape.SetHiddenElems( hiddenelems_h.GetHandle() )

....

Let me know if you have any issues with this,

regards,
Mark

Attachments: 
Alexander Luger's picture

Thank you very much for your code. So far I used XSDRAWSTLVRML_DataSource as DataSource aDS. So I guess I have to get the SALOME Mesh first of all, to get your example working.

I will get back to you when I was successful with that.

Regards,
Alex