Commit 0ec53b7f authored by Kenneth Moreland's avatar Kenneth Moreland
Browse files

Corrections for triangulation.

parent b9ac0bc2
......@@ -24,7 +24,7 @@
#include "vtkPoints.h"
#include "vtkQuad.h"
vtkCxxRevisionMacro(vtkHexahedron, "1.91");
vtkCxxRevisionMacro(vtkHexahedron, "1.92");
vtkStandardNewMacro(vtkHexahedron);
static const double VTK_DIVERGED = 1.e6;
......@@ -549,28 +549,28 @@ int vtkHexahedron::Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)
// is necessary to insure compatible voxel triangulations.
if ( (index % 2) )
{
p[0] = 0; p[1] = 1; p[2] = 4; p[3] = 3;
p[0] = 0; p[1] = 1; p[2] = 3; p[3] = 4;
for ( i=0; i < 4; i++ )
{
ptIds->InsertNextId(this->PointIds->GetId(p[i]));
pts->InsertNextPoint(this->Points->GetPoint(p[i]));
}
p[0] = 1; p[1] = 4; p[2] = 6; p[3] = 5;
p[0] = 1; p[1] = 4; p[2] = 5; p[3] = 6;
for ( i=0; i < 4; i++ )
{
ptIds->InsertNextId(this->PointIds->GetId(p[i]));
pts->InsertNextPoint(this->Points->GetPoint(p[i]));
}
p[0] = 1; p[1] = 4; p[2] = 3; p[3] = 6;
p[0] = 1; p[1] = 4; p[2] = 6; p[3] = 3;
for ( i=0; i < 4; i++ )
{
ptIds->InsertNextId(this->PointIds->GetId(p[i]));
pts->InsertNextPoint(this->Points->GetPoint(p[i]));
}
p[0] = 1; p[1] = 3; p[2] = 2; p[3] = 6;
p[0] = 1; p[1] = 3; p[2] = 6; p[3] = 2;
for ( i=0; i < 4; i++ )
{
ptIds->InsertNextId(this->PointIds->GetId(p[i]));
......@@ -586,21 +586,21 @@ int vtkHexahedron::Triangulate(int index, vtkIdList *ptIds, vtkPoints *pts)
}
else
{
p[0] = 2; p[1] = 1; p[2] = 0; p[3] = 5;
p[0] = 2; p[1] = 1; p[2] = 5; p[3] = 0;
for ( i=0; i < 4; i++ )
{
ptIds->InsertNextId(this->PointIds->GetId(p[i]));
pts->InsertNextPoint(this->Points->GetPoint(p[i]));
}
p[0] = 0; p[1] = 2; p[2] = 7; p[3] = 3;
p[0] = 0; p[1] = 2; p[2] = 3; p[3] = 7;
for ( i=0; i < 4; i++ )
{
ptIds->InsertNextId(this->PointIds->GetId(p[i]));
pts->InsertNextPoint(this->Points->GetPoint(p[i]));
}
p[0] = 2; p[1] = 5; p[2] = 7; p[3] = 6;
p[0] = 2; p[1] = 5; p[2] = 6; p[3] = 7;
for ( i=0; i < 4; i++ )
{
ptIds->InsertNextId(this->PointIds->GetId(p[i]));
......
......@@ -25,7 +25,7 @@
#include "vtkTriangle.h"
#include "vtkUnstructuredGrid.h"
vtkCxxRevisionMacro(vtkPyramid, "1.36");
vtkCxxRevisionMacro(vtkPyramid, "1.37");
vtkStandardNewMacro(vtkPyramid);
static const double VTK_DIVERGED = 1.e6;
......@@ -550,16 +550,53 @@ int vtkPyramid::IntersectWithLine(double p1[3], double p2[3], double tol, double
//----------------------------------------------------------------------------
int vtkPyramid::Triangulate(int vtkNotUsed(index), vtkIdList *ptIds, vtkPoints *pts)
{
int p[4], i;
ptIds->Reset();
pts->Reset();
for ( int i=0; i < 4; i++ )
// The base of the pyramid must be split into two triangles. There are two
// ways to do this (across either diagonal). Pick the shorter diagonal.
double base_points[4][3];
for (i = 0; i < 4; i++)
{
ptIds->InsertId(i,this->PointIds->GetId(i));
pts->InsertPoint(i,this->Points->GetPoint(i));
this->Points->GetPoint(i, base_points[i]);
}
double diagonal1, diagonal2;
diagonal1 = vtkMath::Distance2BetweenPoints(base_points[0], base_points[2]);
diagonal2 = vtkMath::Distance2BetweenPoints(base_points[1], base_points[3]);
return 1;
if (diagonal1 < diagonal2)
{
p[0] = 0; p[1] = 1; p[2] = 2; p[3] = 4;
for (i=0; i < 4; i++)
{
ptIds->InsertId(i,this->PointIds->GetId(i));
pts->InsertPoint(i,this->Points->GetPoint(i));
}
p[0] = 0; p[1] = 2; p[2] = 3; p[3] = 4;
for (i=0; i < 4; i++)
{
ptIds->InsertId(i,this->PointIds->GetId(i));
pts->InsertPoint(i,this->Points->GetPoint(i));
}
}
else
{
p[0] = 0; p[1] = 1; p[2] = 3; p[3] = 4;
for (i=0; i < 4; i++)
{
ptIds->InsertId(i,this->PointIds->GetId(i));
pts->InsertPoint(i,this->Points->GetPoint(i));
}
p[0] = 1; p[1] = 2; p[2] = 3; p[3] = 4;
for (i=0; i < 4; i++)
{
ptIds->InsertId(i,this->PointIds->GetId(i));
pts->InsertPoint(i,this->Points->GetPoint(i));
}
}
return !(diagonal1 == diagonal2);
}
//----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment