[Gmsh] from hexahedrons to tetrahedrons

Tom f.dshabarow at gmail.com
Mon Jul 23 15:59:55 CEST 2012


Trevor Strickler <trevor.strickler at ...> writes:

> 
> Hi Mark Smith, Michael Dupront and Everyone,With regard to converting 
hexahedrons to tetrahedrons, I have written a patch for Gmsh that allows one 
to interface quad faces on a structured volume boundary to triangle faces with 
a layer or two of pyramids, prisms, and tetrahedra. This will not convert ALL 
the hexahedra in a structured volume to tetrahedra, but if you are trying to 
subdivide hexa for the purposes of interfacing to an unstructured tetrahedral 
volume, this might help.I can email this patch to anyone interested.  It will 
be distributed under the GPL as a modified version of Gmsh.  I will only email 
the source code, so if you want it, you will have to build Gmsh on your own 
machine.- Trevor Strickler
> 
> _______________________________________________
> gmsh mailing list
> gmsh at ...
> http://www.geuz.org/mailman/listinfo/gmsh
> 





I would like to have an hexahedron mesh and I manage to visualize one 
hexahedron. But when I want to visualize more (mesh), nothing is visualized.
Here the code where I try to visualize 2 hexahedrons:

vtkSmartPointer<vtkUnstructuredGrid>	vUGrid = 
vtkSmartPointer<vtkUnstructuredGrid>::New();
vtkSmartPointer<vtkCellArray>		vCellArray = 
vtkSmartPointer<vtkCellArray>::New();
vtkSmartPointer<vtkPoints>		vPoints = 
vtkSmartPointer<vtkPoints>::New();
vtkSmartPointer<vtkHexahedron>		vHexahedron = 
vtkSmartPointer<vtkHexahedron>::New();

for (unsigned int i = 0; i < 2; i++)
{
	vPoints->InsertNextPoint(0.0, 0.0, 0.0);
	vPoints->InsertNextPoint(1.0, 0.0, 0.0);
	vPoints->InsertNextPoint(1.0, 1.0, 0.0);
	vPoints->InsertNextPoint(0.0, 1.0, 0.0);
	vPoints->InsertNextPoint(0.0, 0.0, 1.0);
	vPoints->InsertNextPoint(1.0, 0.0, 1.0);
	vPoints->InsertNextPoint(1.0, 1.0, 1.0);
	vPoints->InsertNextPoint(0.0, 1.0, 1.0);

		
	vHexahedron->GetPointIds()->SetNumberOfIds(8);
	for (unsigned int j = 0; j < 8; j++) {
	    vHexahedron->GetPointIds()->SetId(j,j);
	}
        vUGrid->SetPoints(vPoints);
        vUGrid->InsertNextCell(vHexahedron->GetCellType(), vHexahedron-
>GetPointIds());
}

vtkSmartPointer<vtkDataSetMapper> mapper = 
vtkSmartPointer<vtkDataSetMapper>::New();
mapper->SetInput(vUGrid); 

vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
	actor->SetMapper(mapper);
	 
vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow = 
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor = 
vtkSmartPointer<vtkRenderWindowInteractor>::New();

ui.qvtkWidget->SetRenderWindow(renderWindow);
 
renderer->AddActor(actor);
renderer->SetBackground(0.3, 0.6, 0.3); // Background color green
 
renderWindow->Render();




So, my question is why I do not see anything and how to construct a vtk 
hexahedron mesh..