[vtkusers] Newbie question about vtkMeshQuality
Andriy Fedorov
fedorov at bwh.harvard.edu
Wed Apr 27 13:04:20 EDT 2005
Ok, I figured that out. What is wrong is that the vtkMeshQuality is
different in CVS and in the latest official release (4.2). I didn't know
that. Here's the header file from the official release:
/*=========================================================================
Program: Visualization Toolkit
Module: $RCSfile: vtkMeshQuality.h,v $
Language: C++
Date: $Date: 2002/10/22 16:02:39 $
Version: $Revision: 1.3 $
Copyright (c) 1993-2002 Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkMeshQuality - calculate quality of tetrahedral meshes
// .SECTION Description
// vtkMeshQuality will calculate the normalized quality ratio of the cells
// in a tetrahedral mesh according to the equation:
// <p> ratio = (radius of circumscribed sphere)/(radius of inscribed
sphere)/3.
// <p> The minumum (and ideal) quality ratio is 1.0 for regular tetrahedra,
// i.e. all sides of equal length. Larger values indicate poorer mesh
// quality. The resulting quality values (and the tetrahedron volumes)
// are set as the Scalars of the FieldData of the output.
// .SECTION Thanks
// This class was developed by Leila Baghdadi, Hanif Ladak, and
// David Steinman at the Imaging Research Labs, Robarts Research Institute.
#ifndef __vtkMeshQuality_h
#define __vtkMeshQuality_h
#include "vtkDataSetToDataObjectFilter.h"
class VTK_GRAPHICS_EXPORT vtkMeshQuality : public
vtkDataSetToDataObjectFilter
{
public:
static vtkMeshQuality *New();
vtkTypeRevisionMacro(vtkMeshQuality,vtkDataSetToDataObjectFilter);
void PrintSelf(ostream& os, vtkIndent indent);
// Description:
// Turn on/off the calculation of volume for each cell (Default: On).
// The volume the first component of the cell scalars in the output
// data.
vtkSetMacro(Volume,int);
vtkGetMacro(Volume,int);
vtkBooleanMacro(Volume,int);
// Description:
// Turn on/off the calculation of the quality ratio for each cell
// (Default: On). The ratio is 1 for a regular tetrahedron and
// greater than one for other tetrahedrons. The values are stored
// in the second component of the cell scalars in the output data,
// unless Volume calculation is off in which case the values are
// stored in the first scalar component.
vtkSetMacro(Ratio,int);
vtkGetMacro(Ratio,int);
vtkBooleanMacro(Ratio,int);
protected:
vtkMeshQuality();
~vtkMeshQuality();
void Execute();
int Volume;
int Ratio;
private:
vtkMeshQuality(const vtkMeshQuality&); // Not implemented.
void operator=(const vtkMeshQuality&); // Not implemented.
};
#endif
Mathieu Malaterre wrote:
> What is wrong with :
>
> $ ctest -R MeshQuality -V
>
> Test project
> Changing directory into
> /home/mathieu/Dashboards/MyTests/VTK-gcc/Graphics/Testing/Cxx
> 1/ 1 Testing MeshQuality
> Test command:
> /home/mathieu/Dashboards/MyTests/VTK-gcc/bin/GraphicsCxxTests
> MeshQuality -D /home/mathieu/Dashboards/MyTests/VTKData -T
> /home/mathieu/Dashboards/MyTests/VTK-gcc/Testing/Temporary -V
> Baseline/Graphics/MeshQuality.png
>
> Triangle quality of mesh
> /home/mathieu/Dashboards/MyTests/VTKData/Data/uGridEx.vtk
> Edge Ratio:
> range: 1.41421 - 1.41421
> average: 1.41421 , standard deviation: 1.30634e-08
> Aspect Ratio:
> range: 1.39385 - 1.39385
> average: 1.39385 , standard deviation: 8.87815e-09
> Radius Ratio:
> range: 1.20711 - 1.20711
> average: 1.20711 , standard deviation: 1.83331e-09
> Frobenius Norm:
> range: 1.1547 - 1.1547
> average: 1.1547 , standard deviation: 3.4377e-09
> Minimal Angle:
> range: 45 - 45
> average: 45 , standard deviation: 2.92002e-07
>
> Quadrilatedral quality of mesh
> /home/mathieu/Dashboards/MyTests/VTKData/Data/uGridEx.vtk
> Edge Ratio:
> range: 1 - 1
> average: 1 , standard deviation: 0
> Aspect Ratio:
> range: 1 - 1
> average: 1 , standard deviation: 0
> Radius Ratio:
> range: 1 - 1
> average: 1 , standard deviation: 0
> Average Frobenius Norm:
> range: 1 - 1
> average: 1 , standard deviation: 0
> Maximal Frobenius Norm:
> range: 1 - 1
> average: 1 , standard deviation: 0
> Minimal Angle:
> range: 90 - 90
> average: 90 , standard deviation: 0
>
> Tetrahedral quality of mesh
> /home/mathieu/Dashboards/MyTests/VTKData/Data/uGridEx.vtk
> Edge Ratio:
> range: 1.41421 - 1.73205
> average: 1.57313 , standard deviation: 0.158919
> Aspect Ratio:
> range: 1.36603 - 1.70711
> average: 1.53657 , standard deviation: 0.170541
> Radius Ratio:
> range: 1.36603 - 1.39385
> average: 1.37994 , standard deviation: 0.0139107
> Frobenius Norm:
> range: 1.19055 - 1.32283
> average: 1.25669 , standard deviation: 0.0661417
> Minimal Dihedral Angle:
> range: 45 - 54.7356
> average: 49.8678 , standard deviation: 4.86781
>
> Hexahedral quality of mesh
> /home/mathieu/Dashboards/MyTests/VTKData/Data/uGridEx.vtk
> Edge Ratio:
> range: 1 - 1
> average: 1 , standard deviation: 0
>
> -- Process completed
> Passed
>
> The following tests passed:
> MeshQuality
>
> 100% tests passed, 0 tests failed out of 1
>
>
> This is tested every night...
> Mathieu
>
> Andriy Fedorov wrote:
>
>> Mathieu,
>>
>> Are you aware that the test you pointed me to is outdated:
>> apparently, the functionality provided by vtkMeshQuality in the
>> latest release of VTK is significantly restricted.
>>
>> AF
>>
>>
>> Mathieu Malaterre wrote:
>>
>>> Andriy,
>>>
>>> Use the documentation of VTK. For example go to the doxygen of
>>> the class you wish to use:
>>>
>>> http://www.vtk.org/doc/nightly/html/classvtkMeshQuality.html
>>>
>>> Then scroll, you'll find a 'Tests' section, which will lead you to:
>>>
>>> http://www.vtk.org/doc/nightly/html/c2_vtk_t_8.html#c2_vtk_t_vtkMeshQuality
>>>
>>>
>>> In this case the choice is easy since there is only one test
>>> written in c++:
>>>
>>> http://public.kitware.com/cgi-bin/viewcvs.cgi/*checkout*/Graphics/Testing/Cxx/MeshQuality.cxx?root=VTK&content-type=text/plain
>>>
>>>
>>> This gives you an example on how to use this class:
>>>
>>> <snip>
>>> vtkUnstructuredGridReader* mr = vtkUnstructuredGridReader::New();
>>> vtkUnstructuredGrid* ug;
>>> vtkMeshQuality* iq = vtkMeshQuality::New();
>>>
>>> mr->SetFileName( fname );
>>> mr->Update();
>>>
>>> ug = mr->GetOutput(); // <-- this is the line you need
>>> iq->SetInput( ug );
>>> </snip>
>>>
>>>
>>> HTH
>>> Mathieu
>>>
>>> Andriy Fedorov wrote:
>>>
>>>> I know this is something very simple... I am trying to use
>>>> itkMeshQuality with a tetrahedral 3D mesh. Here's the code:
>>>>
>>>> #include "vtkUnstructuredGrid.h"
>>>> #include "vtkUnstructuredGridReader.h"
>>>> #include "vtkMeshQuality.h"
>>>> #include "vtkDataSet.h"
>>>> #include <iostream>
>>>>
>>>> int main(int argc, char **argv){
>>>> if(argc<2)
>>>> return -1;
>>>>
>>>> vtkUnstructuredGridReader *vtk_mesh_reader =
>>>> vtkUnstructuredGridReader::New();
>>>> vtkMeshQuality *mesh_qual = vtkMeshQuality::New();
>>>> vtkDataObject *output_mesh;
>>>>
>>>> vtk_mesh_reader->SetFileName(argv[1]);
>>>> vtk_mesh_reader->Update();
>>>> vtkDataSet *input_mesh = vtkDataSet::SafeDownCast(
>>>> vtk_mesh_reader);
>>>> mesh_qual->SetInput(input_mesh);
>>>> mesh_qual->Update();
>>>> output_mesh = mesh_qual->GetOutput();
>>>>
>>>> return 0;
>>>> }
>>>>
>>>> When I run it, I have failure here:
>>>>
>>>> ERROR: In
>>>> /home/fedorov/SPL/slicer2/Lib/linux-x86/VTK/Common/vtkSource.cxx,
>>>> line 384
>>>> vtkMeshQuality (0x8069318): Required input 0 is not assigned.
>>>> Skipping execution.
>>>>
>>>> I realize it shuld be possible to figure out from the code, but I
>>>> already spent couple of hours w/o success (my VTK experience
>>>> approaches 0). Can somebody give me a quick hint what I am
>>>> missing? Thanks a lot!
>>>>
>>>> Andriy Fedorov
>>>> _______________________________________________
>>>> This is the private VTK discussion list. Please keep messages
>>>> on-topic. Check the FAQ at: http://www.vtk.org/Wiki/VTK_FAQ
>>>> Follow this link to subscribe/unsubscribe:
>>>> http://www.vtk.org/mailman/listinfo/vtkusers
>>>>
>>>
>>
>>
>
More information about the vtkusers
mailing list