[vtkusers] tetrahedral mesh

Mathieu Malaterre mathieu.malaterre at kitware.com
Wed Mar 10 10:17:42 EST 2004


Longfei,

	Sorry about that. I am using the very last revision of
vtkOrderedTriangulator. You have two options:
- replace the existing cxx and h file with those from CVS.
- don't use the fast method and use Triangulate instead of
TemplateTriangulate, see old doc :

http://www.vtk.org/doc/release/4.2/html/classvtkOrderedTriangulator.html

Mathieu
Ps: You can download files here:
http://vtk.org/cgi-bin/cvsweb.cgi/~checkout~/VTK/Common/vtkOrderedTriangulator.cxx
http://vtk.org/cgi-bin/cvsweb.cgi/~checkout~/VTK/Common/vtkOrderedTriangulator.h


lfcong at nlpr.ia.ac.cn wrote:
> Hi Mathieu Malaterre 
>          I have compile the code you give to me . There are two error 
> //@@@@@@@@@@
>   E:\meshgeneration\unstrictmesh\Arrays.cxx(24) : error C2039: 'UseTemplatesOn' : is not a member of 'vtkOrderedTriangulator'
>         E:\vtk\VTK\Common\vtkOrderedTriangulator.h(78) : see declaration of 'vtkOrderedTriangulator'
> E:\meshgeneration\unstrictmesh\Arrays.cxx(42) : error C2664: 'int __thiscall vtkOrderedTriangulator::InsertPoint(int,float [],float [],int)' : cannot convert parameter 2 from 'double *' to 'float []'
>         Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
> E:\meshgeneration\unstrictmesh\Arrays.cxx(90) : warning C4508: 'main' : function should return a value; 'void' return type assumed
> Error executing cl.exe.
>  //@@@@@@@@
> Best regard
> 
> 
>>Longfei Cong,
>>
>>
>>	Here is demo file that shows a typical use of vtkOrderedTriangulator:
>>
>>#include "vtkOrderedTriangulator.h"
>>#include "vtkPoints.h"
>>#include "vtkUnstructuredGridWriter.h"
>>#include "vtkUnstructuredGrid.h"
>>#include "vtkRenderer.h"
>>#include "vtkRenderWindow.h"
>>#include "vtkRenderWindowInteractor.h"
>>#include "vtkDataSetMapper.h"
>>
>>double para_coord[18] = {
>> 1.0, 0.0, 0.0,
>> 0.75,0.25,0.0,
>> 0.75,0.0,0.0,
>> 0.75,0.0,0.25,
>> 0.875,0.125,0.0,
>> 0.875,0.0,0.125,
>>};
>>
>>int main()
>>{
>> vtkOrderedTriangulator *triangulator = 
>>vtkOrderedTriangulator::New();  triangulator-
>>
>>>InitTriangulation(0.0,1.0, 0.0,1.0, 0.0,1.0, 2000);
>>
>> triangulator->PreSortedOff();
>> triangulator->UseTemplatesOn ();
>>
>> double *p = para_coord;
>>
>> vtkPoints *Points = vtkPoints::New();
>> Points->SetNumberOfPoints(6);
>> for(int i=0;i<6;i++,p+=3)
>>   {
>>   Points->SetPoint(i, p);
>>   }
>>
>> //first case
>> for(int i=0;i<6;i++)
>> {
>>   double *temp = para_coord + 3*i;
>>   double *temp2 = para_coord + 3*i;
>>//    std::cout << temp[0] << ',' << temp[1] << ',' << temp[2] << 
>>endl;//    std::cout << temp2[0] << ',' << temp2[1] << ',' << 
>>temp2[2] << endl;
>>   triangulator->InsertPoint(i, temp, temp2, 0);
>> }
>> triangulator->Triangulate();
>>
>> vtkUnstructuredGrid *aTetraGrid1 = vtkUnstructuredGrid::New();
>> aTetraGrid1->Allocate (1, 1);
>> int num = triangulator->AddTetras(0, aTetraGrid1);
>> aTetraGrid1->SetPoints(Points);
>>
>> std::cout << num << endl;
>>
>> vtkUnstructuredGridWriter *writer = 
>>vtkUnstructuredGridWriter::New();  writer->SetInput( aTetraGrid1 );
>> writer->SetFileName( "tetras.vtk" );
>> writer->Write();
>>
>> vtkDataSetMapper *aTetraMapper1 = vtkDataSetMapper::New();
>> aTetraMapper1->SetInput (aTetraGrid1);
>>
>> vtkActor *aTetraActor1 = vtkActor::New();
>> aTetraActor1->SetMapper (aTetraMapper1);
>> //aTetraActor1->GetProperty()->BackfaceCullingOn();
>>
>> vtkRenderer *renderer = vtkRenderer::New();
>> vtkRenderWindow *renWin = vtkRenderWindow::New();
>> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
>>
>> renderer->SetBackground(1,1,1);
>> renderer->AddActor( aTetraActor1 );
>>
>> renWin->AddRenderer( renderer );
>> renWin->SetSize( 300, 300 );
>>
>> iren->SetRenderWindow( renWin );
>> iren->Initialize();
>> iren->Start();
>>
>>
>> triangulator->Delete();
>> aTetraGrid1->Delete();
>> writer->Delete();
>> Points->Delete();
>>
>> aTetraActor1->Delete();
>> aTetraMapper1->Delete();
>> renderer->Delete();
>> renWin->Delete();
>> iren->Delete();
>>}
>>
>>
>>Longfei Cong wrote:
>>
>>>Hi Mathieu Malaterre,
>>>Thanks a million for your help I'll try it!
>>>
>>>
>>>
>>>>Jean M. Favre wrote:
>>>>
>>>>
>>>>>Longfei Cong wrote:
>>>>>
>>>>>
>>>>>
>>>>>>Hi vtkusers,
>>>>>>           I am a beginer of VTk. Could anyone please help me 
>>
>>with tetrahedral mesh generation of and give some example about 
>>tetrahedral mesh generation.
>>
>>>>>
>>>>>http://tetgen.berlios.de/
>>>>
>>>>Or directly in VTK you can use vtkOrderedTriangulator :
>>>>
>>>>http://www.vtk.org/doc/nightly/html/classvtkOrderedTriangulator.html
>>>>
>>>>HTH
>>>>Mathieu
>>>>
>>>>
>>>>_______________________________________________
>>>>This is the private VTK discussion list. 
>>>>Please keep messages on-topic. Check the FAQ at: <" 
>>
>>target="l">http://public.kitware.com/cgi-bin/vtkfaq>
>>
>>>>Follow this link to subscribe/unsubscribe:
>>>>http://www.vtk.org/mailman/listinfo/vtkusers





More information about the vtkusers mailing list