Subject: CGAL users discussion list
List archive
- From: "Laurent Rineau (GeometryFactory)" <>
- To:
- Subject: Re: [cgal-discuss] .mesh to vtk output
- Date: Fri, 10 Jun 2011 12:09:39 +0200
- Organization: GeometryFactory
On vendredi 10 juin 2011 00:51:41 Michel Audette wrote:
> Dear CGAL deveopers,
>
> I did a search on vtk in the 3.8 source code, and found
> Complex_3_in_triangulation_3_to_vtk , which sounds like what I need. I
> would like to be able to visualize the CGAL tetrahedralization results
> with Paraview.
>
> Is there an example or demo somewhere that documents how to use this class?
No. That is undocumented. I wrote this function with the purpose to write a
VTK filter that does 3D meshing of 3D images (is not it what you are doing)?
The usage is simple :
// given a C3t3 variable 'c3t3',
// given vtkUnstructuredGrid* pointer output
// (that points to a valid empty grid)
CGAL::output_c3t3_to_vtk_unstructured_grid(c3t3, output);
output->Squeeze(); // I do not remember why I used Squeeze().
As attachment I give you my non-finished attempt to write the VTK filter. I
image you can read VTK code easily. It is not finished because:
- it does not use the ability of CGAL-3.8 to preserve sharp edges
- I do not know what is the common way to pass parameters (such as size
criteria) to a VTK filter.
And I have not sure that still works. I started that more than a year ago,
and
then I got other more priority tasks to do and I forgot that VTK filter.
Maybe we could collaborate and finish that together.
--
Laurent Rineau, PhD
R&D Engineer at GeometryFactory http://www.geometryfactory.com/
Release Manager of the CGAL Project http://www.cgal.org/
#include "vtkCGALMesh3D.h" #include "vtkCellArray.h" #include "vtkCellData.h" #include "vtkInformation.h" #include "vtkInformationVector.h" #include "vtkObjectFactory.h" #include "vtkPointData.h" #include "vtkUnstructuredGrid.h" #ifndef CGAL_USE_VTK # define CGAL_USE_VTK #endif #include <CGAL/Exact_predicates_inexact_constructions_kernel.h> #include <CGAL/Mesh_triangulation_3.h> #include <CGAL/Mesh_complex_3_in_triangulation_3.h> #include <CGAL/Mesh_criteria_3.h> #include <CGAL/Labeled_image_mesh_domain_3.h> #include <CGAL/make_mesh_3.h> #include <CGAL/Image_3.h> #include <CGAL/IO/Complex_3_in_triangulation_3_to_vtk.h> // Domain struct K: public CGAL::Exact_predicates_inexact_constructions_kernel {}; typedef CGAL::Image_3 Image; typedef CGAL::Labeled_image_mesh_domain_3<Image,K> Mesh_domain; // Triangulation typedef CGAL::Mesh_triangulation_3<Mesh_domain>::type Tr; typedef CGAL::Mesh_complex_3_in_triangulation_3<Tr> C3t3; // Mesh Criteria typedef CGAL::Mesh_criteria_3<Tr> Mesh_criteria; typedef Mesh_criteria::Facet_criteria Facet_criteria; typedef Mesh_criteria::Cell_criteria Cell_criteria; vtkCxxRevisionMacro(vtkCGALMesh3D, "$Id: vtkCGALMesh3D.cxx 58426 2010-09-01 15:26:47Z lrineau $"); vtkStandardNewMacro(vtkCGALMesh3D); vtkCGALMesh3D::vtkCGALMesh3D() { } int vtkCGALMesh3D::RequestData( vtkInformation *vtkNotUsed(request), vtkInformationVector **inputVector, vtkInformationVector *outputVector) { // get the info objects vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); vtkInformation *outInfo = outputVector->GetInformationObject(0); // get the input and ouptut vtkImageData *inData = vtkImageData::SafeDownCast( inInfo->Get(vtkDataObject::DATA_OBJECT())); vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast( outInfo->Get(vtkDataObject::DATA_OBJECT())); Image image; if(!image.read_vtk_image_data(inData)) return 0; // Domain Mesh_domain domain(image); // Mesh criteria Facet_criteria facet_criteria(30, 6, 4); // angle, size, approximation Cell_criteria cell_criteria(3, 8); // radius-edge ratio, size Mesh_criteria criteria(facet_criteria, cell_criteria); // Meshing C3t3 c3t3 = CGAL::make_mesh_3<C3t3>(domain, criteria); // Output CGAL::output_c3t3_to_vtk_unstructured_grid(c3t3, output); output->Squeeze(); return 0; } void vtkCGALMesh3D::PrintSelf(ostream& os, vtkIndent indent) { this->Superclass::PrintSelf(os,indent); }
// .NAME vtkCGALMesh3D - create 3D unstructured grid from a labeled volume image // .SECTION // vtkCGALMesh3D is a filter that compute 3D tetrahedral meshes from a // labeled 3D image (a volume). // .SECTION CGAL Package // http://www.cgal.org/Pkg/Mesh3 #ifndef __vtkCGALMesh3D_h #define __vtkCGALMesh3D_h #endif // __vtkCGALMesh3D_h #include "vtkCGALConfigure.h" // Include configuration header. #include "vtkUnstructuredGridAlgorithm.h" #include "vtkImageData.h" class VTK_vtkCGAL_EXPORT vtkCGALMesh3D : public vtkUnstructuredGridAlgorithm { public: // Description: // Default constructor static vtkCGALMesh3D *New(); vtkTypeRevisionMacro(vtkCGALMesh3D,vtkUnstructuredGridAlgorithm); void PrintSelf(ostream& os, vtkIndent indent); protected: vtkCGALMesh3D(); ~vtkCGALMesh3D() {}; // Usual data generation method int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); private: vtkCGALMesh3D(const vtkCGALMesh3D&); // Not implemented. void operator=(const vtkCGALMesh3D&); // Not implemented. };
- [cgal-discuss] .mesh to vtk output, Michel Audette, 06/10/2011
- Re: [cgal-discuss] .mesh to vtk output, Laurent Rineau (GeometryFactory), 06/10/2011
- Re: [cgal-discuss] .mesh to vtk output, Michel Audette, 06/10/2011
- Re: [cgal-discuss] .mesh to vtk output, Michel Audette, 06/10/2011
- Re: [cgal-discuss] .mesh to vtk output, Michel Audette, 06/10/2011
- Re: [cgal-discuss] .mesh to vtk output, Laurent Rineau (GeometryFactory), 06/10/2011
Archive powered by MHonArc 2.6.16.