View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007588VTK(No Category)public2008-08-30 21:492013-04-05 20:17
ReporterTakuya OSHIMA 
Assigned ToZhanping Liu 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionfixed 
PlatformOSOS Version
Product Version 
Target VersionFixed in Version 
Summary0007588: vtkWedge::Triangulate() returns inverted tetrahedron
Description1. Open the attached wedge.vtk.
2. Apply Integrate Variables.
3. Choose Cell Data from the combo box at the top of spreadsheet view.

The volume is shown as -0.166667 instead of the expected value of 0.5. Looks like this is because vtkWedge::Triangulate() is returning an inverted tetrahedron at line 244 of vtkIntegrateAttributes.cxx.
TagsNo tags attached.
Project
Type
Attached Files? file icon wedge.vtk [^] (181 bytes) 2008-08-30 21:49
? file icon wedge_correct.vtk [^] (181 bytes) 2008-09-23 12:03
png file icon 1.png [^] (53,990 bytes) 2008-09-23 21:22


png file icon 2.png [^] (183,620 bytes) 2008-09-23 21:22


png file icon 3.png [^] (13,254 bytes) 2008-09-23 21:22


? file icon wedge_correct_0924.vtk [^] (181 bytes) 2008-09-24 09:40

 Relationships

  Notes
(0013557)
Zhanping Liu (developer)
2008-09-23 12:12
edited on: 2008-09-23 12:15

The reported problem was due to two issues, i.e., (1) the negative sign of the result, and (2) the unequality of the absolute to 0.5.

The first issue was caused by the incorrect format (in terms of the order of the vertices of the wedge) of the input file (wedge.vtk). According to http://www.vtk.org/doc/nightly/html/classvtkWedge.html, [^] "the wedge is defined by the six points (0-5) where (0,1,2) is the base of the wedge which, using the right hand rule, forms a triangle whose normal points outward (away from the triangular face (3,4,5))". However, the base of the wedge defined by the input file (wedge.vtk) forms a triangle whose normal points INWARD (TOWARD the triangular surface 3, 4, 5). Thus a negative volume was obtained. When a wedge (see the attached VTK file, wedge_correct.vtk) with a correct format (in terms of the order of the vertices of the wedge) is used, the result turns into a positive value.

The second issue, i.e., the bug, was due to the incomplete decomposition of a wedge into three tetrahedrons (see vtkWedge.cxx for vtkWedge::Triangulate()). It has been fixed.

(0013561)
Takuya OSHIMA (reporter)
2008-09-23 21:21

As to the sign of the volume, your wedge_correct.vtk does not seem to be correct to me indeed from the following standpoints.

1. If I precisely follow the documentation you cited (http://www.vtk.org/doc/nightly/html/classvtkWedge.html [^]) the base normal of wedge_correct.vtk points to inward (incorrect), while the one of my wedge.vtk points to outward (correct).

2. If I load wedge_correct.vtk into ParaView and run Normal Glyphs over it, the normals all point to inward (while they should all point to outward).

3. As to your triangulation code checked out just now from the CVS head: according to http://www.vtk.org/doc/nightly/html/classvtkTetra.html, [^] "the tetrahedron is defined by the four points (0-3); where (0,1,2) is the base of the tetrahedron which, using the right hand rule, forms a triangle whose normal points in the direction of the fourth point." Hence the point orderings of the base faces of the original wedge and its first triangulated tetra should be opposite. However your corresponding code

  // Tetra #0 info: { 0, 1, 2, 3 }
  p[0] = 0; p[1] = 1; p[2] = 2; p[3] = 3;
  for ( i=0; i < 4; i++ )
    {
    ptIds->InsertNextId(this->PointIds->GetId(p[i]));
    pts->InsertNextPoint(this->Points->GetPoint(p[i]));
    }

is using the point ordering as is (and the same thing can be said as to the remaining triangulated tetrahedra).

Please, please do double check your thoughts.
(0013562)
Takuya OSHIMA (reporter)
2008-09-23 21:24

I attached figures to describe each point of my thoughts with the corresponding filenames (1.png, 2.png and 3.png corresponding to the points above, 1., 2. and 3.)
(0013565)
Zhanping Liu (developer)
2008-09-24 10:18

Above all, thank 7islands for pointing out the problem.

(1) In the wedge file (wedge_correct.vtk) that I uploaded on Sept 23, the "CELLS" field, i.e., the order of the points that is used to describe the topology of the cell (wedge), was wrong. I forgot to update this field while modifying the wedge file. This problem has been corrected in the newly uploaded wedge file (wedge_correct_0924.vtk). Now "Normal Glyphs" point outward.

(2) On page 334, "VTK User's Guide (updated for version 5)", Fig.15-17 shows the Ids of the vertices used to construct a VALID wedge. In the wedge file (wedge_correct_0924.vtk), the following field

=================
POINTS 6 float
0 0 0 0 1 0 1 0 0
0 0 1 0 1 1 1 0 1
=================

provides the points in the EXACT order specified by Fig.15-17:

point #0: (0, 0, 0)
point #1: (0, 1, 0)
point #2: (1, 0, 0)
point #3: (0, 0, 1)
point #4: (0, 1, 1)
point #5: (1, 0, 1)

As a result, the base formed by points #0, #1, #2 points outward.

Then the following field

=============
CELLS 1 7
6 0 1 2 3 4 5
=============

just consistently lists the Ids of the aforementioned points.

Your wedge file (wedge.vtk) differs from my wedge file (wedge_correct_0924.vtk) in that: the points are FIRST provided in an order different from the one specified by Fig.15-17, THEN followed by a ID list to tell the actual order of the points. This scheme seems ok while actually it does not work. "wedge_correct_0924.vtk" strictly complies with the specification of Fig. 15-17 and it works.

(3) The order of the points comprising each tetrahedron in vtkWedge::Triangulate() was wrong. It has been fixed.

Should you find additional problems, please let me know.

new revision: 1.7; previous revision: 1.6
(0013566)
Zhanping Liu (developer)
2008-09-24 10:23

+
(0013572)
Takuya OSHIMA (reporter)
2008-09-24 21:11

Thanks for the rapid fix. This time the fixed code (revision 1.7) seems to be correct. However there still looks to be an important misunderstanding so I'd like to clarify it.

Although I don't have a copy of VTK User's Guide (I ordered a while ago and waiting for it to arrive :) ), I assume the essence is written in the VTK file format doc (http://www.vtk.org/pdf/file-formats.pdf [^] , especially the VTK_WEDGE figure of Figure 2). From that standpoint I'd like to emphasize that my wedge.vtk is perfectly valid, and this time your wedge_correct_0924.vtk as well. Note that the point number ordering in CELLS can be arbitrary, as long as the topology it represents in conjunction with its corresponding point coordinates is valid. That's the whole point of an unstructured grid, isn't it?

This issue can be marked as resolved upon reading this note as the code itself seems to be correct to me.
(0013577)
Zhanping Liu (developer)
2008-09-25 08:54

Thank you, 7islands. We will keep you posted regarding the order of vertices comprising a wedge.

 Issue History
Date Modified Username Field Change
2008-08-30 21:49 Takuya OSHIMA New Issue
2008-08-30 21:49 Takuya OSHIMA File Added: wedge.vtk
2008-09-18 11:00 Berk Geveci Status backlog => tabled
2008-09-18 11:00 Berk Geveci Assigned To => Zhanping Liu
2008-09-18 11:05 Berk Geveci Project ParaView => VTK
2008-09-23 12:03 Zhanping Liu File Added: wedge_correct.vtk
2008-09-23 12:12 Zhanping Liu Note Added: 0013557
2008-09-23 12:15 Zhanping Liu Note Edited: 0013557
2008-09-23 12:17 Zhanping Liu Status tabled => @80@
2008-09-23 21:21 Takuya OSHIMA Status @80@ => @20@
2008-09-23 21:21 Takuya OSHIMA Resolution open => reopened
2008-09-23 21:21 Takuya OSHIMA Note Added: 0013561
2008-09-23 21:22 Takuya OSHIMA File Added: 1.png
2008-09-23 21:22 Takuya OSHIMA File Added: 2.png
2008-09-23 21:22 Takuya OSHIMA File Added: 3.png
2008-09-23 21:24 Takuya OSHIMA Note Added: 0013562
2008-09-24 09:40 Zhanping Liu File Added: wedge_correct_0924.vtk
2008-09-24 10:18 Zhanping Liu Note Added: 0013565
2008-09-24 10:23 Zhanping Liu Status @20@ => @80@
2008-09-24 10:23 Zhanping Liu Resolution reopened => fixed
2008-09-24 10:23 Zhanping Liu Note Added: 0013566
2008-09-24 21:11 Takuya OSHIMA Status @80@ => @20@
2008-09-24 21:11 Takuya OSHIMA Resolution fixed => reopened
2008-09-24 21:11 Takuya OSHIMA Note Added: 0013572
2008-09-25 08:54 Zhanping Liu Note Added: 0013577
2008-09-25 08:55 Zhanping Liu Status @20@ => @80@
2008-09-25 08:55 Zhanping Liu Resolution reopened => fixed
2011-01-13 17:00 Source_changeset_attached => VTK master a2bd8391
2011-01-13 17:00 Source_changeset_attached => VTK master 020ef709
2011-06-16 13:12 Zack Galbreath Category Development => (No Category)
2013-04-05 20:17 Berk Geveci Status customer review => closed


Copyright © 2000 - 2018 MantisBT Team