//#define __MYDEBUG__
//#define USE_ROBUST_TRIANGULATION
+///////////////////////////////////////////////////////////////////////////////////////////////
+// VSR 26/10/2012: fix of regression (issue 21924) - increased memory consumption
+// for displaying of 3d elements, introduced by fix for issue 20314.
+// ...
+// The macro SHOW_COINCIDING_3D_PAL20314, when defined, allows correct visualization of
+// coincident 3d elements but causes substantial increasing of memory consumption, as all 3d
+// elements are always shown, even if they are totally covered by surrounding faces.
+// If this macro is not defined (commented), the behaviour is defined by another macro -
+// SHOW_COINCIDING_3D_PAL21924, as follows:
+// - If SHOW_COINCIDING_3D_PAL21924 is defined, an alternative solution for computing
+// visibility of 3d elements is used; this solution allows to fix problem with visibility
+// of coinciding 3d elements in most cases (though some cases might not work), while not
+// causing significant increasing of memory consumption.
+// - If SHOW_COINCIDING_3D_PAL21924 is not defined (commented), coinciding 3d elements are
+// not shown at all (this corresponds to the state before issue 20314 fixing).
+///////////////////////////////////////////////////////////////////////////////////////////////
+//#define SHOW_COINCIDING_3D_PAL20314
+#ifndef SHOW_COINCIDING_3D_PAL20314
+#define SHOW_COINCIDING_3D_PAL21924
+#endif
+///////////////////////////////////////////////////////////////////////////////////////////////
+
vtkCxxRevisionMacro(VTKViewer_GeometryFilter, "$Revision$");
vtkStandardNewMacro(VTKViewer_GeometryFilter);
vtkIdList *cellIds = vtkIdList::New();
vtkIdList *faceIds = vtkIdList::New();
+ vtkIdList *cellIdsTmp = vtkIdList::New();
+ vtkIdList *faceIdsTmp = vtkIdList::New();
char *cellVis;
vtkIdType newCellId;
cellId,
myShowInside,
allVisible,
- myAppendCoincident3D,
+ GetAppendCoincident3D(),
cellVis,
output,
outputCD,
cellId,
myShowInside,
allVisible,
- myAppendCoincident3D,
+ GetAppendCoincident3D(),
cellVis,
output,
outputCD,
break;
}
case VTK_TETRA: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 4; faceId++)
{
faceIds->Reset();
aCellType = VTK_TRIANGLE;
numFacePts = 3;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_VOXEL: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 6; faceId++)
{
faceIds->Reset();
aCellType = VTK_QUAD;
numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_HEXAHEDRON: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 6; faceId++)
{
faceIds->Reset();
aCellType = VTK_QUAD;
numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_WEDGE: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 5; faceId++)
{
faceIds->Reset();
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_HEXAGONAL_PRISM: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 8; faceId++)
{
faceVerts = vtkHexagonalPrism::GetFaceArray(faceId);
numFacePts = 6;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
break;
}
case VTK_PYRAMID: {
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < 5; faceId++)
{
faceIds->Reset();
numFacePts = 4;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
vtkIdType* ptIds = 0;
int idp = 0;
input->GetFaceStream(cellId, nFaces, ptIds);
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+#endif
for (faceId = 0; faceId < nFaces; faceId++)
{
faceIds->Reset();
}
// TODO understand and fix display of several polyhedrons
input->GetCellNeighbors(cellId, faceIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if (process || myShowInside
|| (!allVisible && !cellVis[cellIds->GetId(0)]))
{
}
else //3D nonlinear cell
{
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ faceIdsTmp->Reset();
+ int npts1 = 0;
+ switch (aCellType ){
+ case VTK_QUADRATIC_TETRA: npts1 = 4; break;
+ case VTK_QUADRATIC_HEXAHEDRON: npts1 = 8; break;
+ case VTK_TRIQUADRATIC_HEXAHEDRON: npts1 = 8; break;
+ case VTK_QUADRATIC_WEDGE: npts1 = 6; break;
+ case VTK_QUADRATIC_PYRAMID: npts1 = 5; break;
+ }
+ if ( npts1 > 0 ) {
+ for (int ai=0; ai<npts; ai++)
+ faceIdsTmp->InsertNextId(pts[ai]);
+ input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
+ }
+#endif
aCellType = VTK_TRIANGLE;
numFacePts = 3;
for (int j=0; j < cell->GetNumberOfFaces(); j++){
vtkCell *face = cell->GetFace(j);
input->GetCellNeighbors(cellId, face->PointIds, cellIds);
- bool process = cellIds->GetNumberOfIds() <= 0 ? true : myAppendCoincident3D;
+#ifdef SHOW_COINCIDING_3D_PAL21924
+ int nbNeighbors = 0;
+ for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
+ if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
+ }
+ bool process = nbNeighbors <= 0;
+#else
+ bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
+#endif
if ( process || myShowInside ) {
face->Triangulate(0,lpts,coords);
for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
cellIds->Delete();
faceIds->Delete();
+ cellIdsTmp->Delete();
+ faceIdsTmp->Delete();
if ( cellVis )
{
return myMaxArcAngle;
}
-
int VTKViewer_GeometryFilter::GetAppendCoincident3D() const {
+// VSR 26/10/2012: see description of SHOW_COINCIDING_3D_PAL20314
+// in the top of this file
+#ifdef SHOW_COINCIDING_3D_PAL20314
return myAppendCoincident3D;
+#else
+ return false;
+#endif
}
void VTKViewer_GeometryFilter::SetAppendCoincident3D(int theFlag) {