Changing vertices of the G4TessellatedSolid

Is there any way I can change the vertices of facets of G4TessellatedSolid after the initial construction?

I couldn’t change them by using functions like below.
tessllated->GetFacet(i)->SetVertex(0, G4ThreeVector(x,y,z));

Thanks in advance!

Vertex position can be changed by the following code:

G4VFacet* facet = tessllated->GetFacet(i);
facet->SetVertex(facet->GetVertexIndex(0), G4ThreeVector(x,y,z));

But I would like to explain that by changing the position of vertices at run time you introduce a discrepancy between the internal “voxel structure” of G4TesselatedSolid (which is used for faster calculation) and real geometry. It is like to introduce “holes” in the surface of the solid.

By the way, something similar happens when changing the position of the vertices in G4Tet. This can lead to skipping some material.

Thank you for the reply!
About the “holes”, dose this happen even I invoke “/run/GeometryModified true”? This seemed to activate the re-initialization of the voxel structure.
Is there any “safe” way to change the these geometries between G4Runs?

I’m not very familiar with “/run/geometryModified”, but according to its description, this command might work in case of G4Tet, although it should be noted that re-voxelization of geometry is not a cheep operation.

In case of G4TessellatedSolid re-voxelization of geometry will not help, because G4TessellatedSolid has its own internal voxel structure. Frankly speaking, I do not see any easy “safe” solution for G4TessellatedSolid.

side question regarding the voxelization: is it possible to visualize said voxelization(s)?

Visualisation of the 3D space voxelization is possible through the class G4DrawVoxels, or
through the UI command /vis/drawLogicalVolume

The voxel structure of the tessellated solid itself cannot be visualised

1 Like

You can try the following:

  • Construct all possible variation of the tessellated solid in advance
  • Change the geometry between runs by

Thank you very much.
It is true that re-voxelization of the tetrahedrons take a large amount of the computational cost, but this may be able to be alleviated by decreasing the number of the voxels to be constructed (G4LogicalVolume::SetSmartless(…)).

For the method to construct all the tessellated solid in advance and using them worked well for me. Thanks!

The cost to recompute the voxelization depends on the complexity (number of daughters) of the relevant volumes.

Note that you could potentially invalidate the voxelisation of the relevant volume(s) only - and redo only those. I don’t recall if that is supported currently or you need to create custom code.