Salome HOME
PAL10125 - by double click on reference original object becomes selected
[modules/gui.git] / src / VTKViewer / VTKViewer_GeometryFilter.cxx
1 //  SALOME OBJECT : kernel of SALOME component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VTKViewer_GeometryFilter.cxx
25 //  Author : Michael ZORIN
26 //  Module : SALOME
27 //  $Header$
28
29 #include "VTKViewer_GeometryFilter.h"
30 #include "VTKViewer_ConvexTool.h"
31
32 #include <vtkSmartPointer.h>
33 #include <vtkCellArray.h>
34 #include <vtkCellData.h>
35 #include <vtkGenericCell.h>
36 #include <vtkHexahedron.h>
37 #include <vtkMergePoints.h>
38 #include <vtkObjectFactory.h>
39 #include <vtkPointData.h>
40 #include <vtkPolyData.h>
41 #include <vtkPyramid.h>
42 #include <vtkStructuredGrid.h>
43 #include <vtkTetra.h>
44 #include <vtkUnsignedCharArray.h>
45 #include <vtkUnstructuredGrid.h>
46 #include <vtkVoxel.h>
47 #include <vtkWedge.h>
48
49 #include <vector>
50 #include <map>
51 using namespace std;
52
53
54 #ifdef _DEBUG_
55 static int MYDEBUG = 0;
56 #else
57 static int MYDEBUG = 0;
58 #endif
59
60 #if defined __GNUC__
61   #if __GNUC__ == 2
62     #define __GNUC_2__
63   #endif
64 #endif
65
66 vtkCxxRevisionMacro(VTKViewer_GeometryFilter, "$Revision$");
67 vtkStandardNewMacro(VTKViewer_GeometryFilter);
68
69 VTKViewer_GeometryFilter::VTKViewer_GeometryFilter(): 
70   myShowInside(0),
71   myStoreMapping(0)
72 {}
73
74
75 VTKViewer_GeometryFilter::~VTKViewer_GeometryFilter()
76 {}
77
78
79 void VTKViewer_GeometryFilter::Execute()
80 {
81   vtkDataSet *input= this->GetInput();
82   vtkIdType numCells=input->GetNumberOfCells();
83
84   if (numCells == 0)
85     {
86       return;
87     }
88   
89   if (input->GetDataObjectType() == VTK_UNSTRUCTURED_GRID){
90     this->UnstructuredGridExecute();
91     return;
92   }else
93     vtkGeometryFilter::Execute();
94 }
95
96
97 void VTKViewer_GeometryFilter::SetStoreMapping(int theStoreMapping){
98   myStoreMapping = theStoreMapping;
99   this->Modified();
100 }
101
102
103 vtkIdType VTKViewer_GeometryFilter::GetElemObjId(int theVtkID){
104   if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
105 #if defined __GNUC_2__
106   return myVTK2ObjIds[theVtkID];
107 #else
108   return myVTK2ObjIds.at(theVtkID);
109 #endif
110 }
111
112
113 void VTKViewer_GeometryFilter::UnstructuredGridExecute()
114 {
115   vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)this->GetInput();
116   vtkCellArray *Connectivity = input->GetCells();
117   if (Connectivity == NULL) {return;}
118   vtkIdType cellId;
119   int i;
120   int allVisible;
121   vtkIdType npts = 0;
122   vtkIdType *pts = 0;
123   vtkPoints *p = input->GetPoints();
124   vtkIdType numCells=input->GetNumberOfCells();
125   vtkPointData *pd = input->GetPointData();
126   vtkCellData *cd = input->GetCellData();
127   vtkPolyData *output = this->GetOutput();
128   vtkPointData *outputPD = output->GetPointData();
129   
130   vtkCellData *outputCD = output->GetCellData();
131   //vtkCellArray *Verts, *Lines, *Polys, *Strips;
132   vtkIdList *cellIds, *faceIds;
133   char *cellVis;
134   vtkIdType newCellId;
135   int faceId, *faceVerts, numFacePts;
136   float *x;
137   int PixelConvert[4], aNewPts[VTK_CELL_SIZE];
138   // ghost cell stuff
139   unsigned char  updateLevel = (unsigned char)(output->GetUpdateGhostLevel());
140   unsigned char  *cellGhostLevels = 0;  
141   
142   PixelConvert[0] = 0;
143   PixelConvert[1] = 1;
144   PixelConvert[2] = 3;
145   PixelConvert[3] = 2;
146   
147   vtkDebugMacro(<<"Executing geometry filter for unstructured grid input");
148
149   vtkDataArray* temp = 0;
150   if (cd)
151     {
152     temp = cd->GetArray("vtkGhostLevels");
153     }
154   if ( (!temp) || (temp->GetDataType() != VTK_UNSIGNED_CHAR)
155     || (temp->GetNumberOfComponents() != 1))
156     {
157     vtkDebugMacro("No appropriate ghost levels field available.");
158     }
159   else
160     {
161     cellGhostLevels = ((vtkUnsignedCharArray*)temp)->GetPointer(0);
162     }
163   
164   // Check input
165   if ( Connectivity == NULL )
166     {
167     vtkDebugMacro(<<"Nothing to extract");
168     return;
169     }
170
171   // Determine nature of what we have to do
172   cellIds = vtkIdList::New();
173   faceIds = vtkIdList::New();
174   if ( (!this->CellClipping) && (!this->PointClipping) &&
175        (!this->ExtentClipping) )
176     {
177     allVisible = 1;
178     cellVis = NULL;
179     }
180   else
181     {
182     allVisible = 0;
183     cellVis = new char[numCells];
184     }
185
186   // Just pass points through, never merge
187   output->SetPoints(input->GetPoints());
188   outputPD->PassData(pd);
189
190   outputCD->CopyAllocate(cd,numCells,numCells/2);
191
192   output->Allocate(numCells/4+1,numCells);
193   //Verts = vtkCellArray::New();
194   //Verts->Allocate(numCells/4+1,numCells);
195   //Lines = vtkCellArray::New();
196   //Lines->Allocate(numCells/4+1,numCells);
197   //Polys = vtkCellArray::New();
198   //Polys->Allocate(numCells/4+1,numCells);
199   //Strips = vtkCellArray::New();
200   //Strips->Allocate(numCells/4+1,numCells);
201   
202   // Loop over the cells determining what's visible
203   if (!allVisible)
204     {
205     for (cellId=0, Connectivity->InitTraversal(); 
206          Connectivity->GetNextCell(npts,pts); 
207          cellId++)
208       {
209       cellVis[cellId] = 1;
210       if ( this->CellClipping && cellId < this->CellMinimum ||
211            cellId > this->CellMaximum )
212         {
213         cellVis[cellId] = 0;
214         }
215       else
216         {
217         for (i=0; i < npts; i++) 
218           {
219           x = p->GetPoint(pts[i]);
220           if ( (this->PointClipping && (pts[i] < this->PointMinimum ||
221                                         pts[i] > this->PointMaximum) ) ||
222                (this->ExtentClipping && 
223                 (x[0] < this->Extent[0] || x[0] > this->Extent[1] ||
224                  x[1] < this->Extent[2] || x[1] > this->Extent[3] ||
225                  x[2] < this->Extent[4] || x[2] > this->Extent[5] )) )
226             {
227             cellVis[cellId] = 0;
228             break;
229             }//point/extent clipping
230           }//for each point
231         }//if point clipping needs checking
232       }//for all cells
233     }//if not all visible
234   
235   // Loop over all cells now that visibility is known
236   // (Have to compute visibility first for 3D cell boundarys)
237   int progressInterval = numCells/20 + 1;
238   if(myStoreMapping){
239     myVTK2ObjIds.clear();
240     myVTK2ObjIds.reserve(numCells);
241   }
242   for (cellId=0, Connectivity->InitTraversal(); 
243        Connectivity->GetNextCell(npts,pts); 
244        cellId++)
245     {
246     //Progress and abort method support
247     if ( !(cellId % progressInterval) )
248       {
249       vtkDebugMacro(<<"Process cell #" << cellId);
250       this->UpdateProgress ((float)cellId/numCells);
251       }
252
253     // Handle ghost cells here.  Another option was used cellVis array.
254     if (cellGhostLevels && cellGhostLevels[cellId] > updateLevel)
255       { // Do not create surfaces in outer ghost cells.
256       continue;
257       }
258     
259     if (allVisible || cellVis[cellId])  //now if visible extract geometry
260       {
261       //special code for nonlinear cells - rarely occurs, so right now it
262       //is slow.
263       vtkIdType aCellType = input->GetCellType(cellId);
264       switch (aCellType)
265         {
266         case VTK_EMPTY_CELL:
267           break;
268
269         case VTK_VERTEX:
270         case VTK_POLY_VERTEX:
271           newCellId = output->InsertNextCell(aCellType,npts,pts);
272           if(myStoreMapping){
273             myVTK2ObjIds.push_back(cellId); //apo
274           }
275           outputCD->CopyData(cd,cellId,newCellId);
276           break;
277
278         case VTK_LINE: 
279         case VTK_POLY_LINE:
280           newCellId = output->InsertNextCell(aCellType,npts,pts);
281           if(myStoreMapping){
282             myVTK2ObjIds.push_back(cellId); //apo
283           }
284           outputCD->CopyData(cd,cellId,newCellId);
285           break;
286
287         case VTK_TRIANGLE:
288         case VTK_QUAD:
289         case VTK_POLYGON:
290           newCellId = output->InsertNextCell(aCellType,npts,pts);
291           if(myStoreMapping){
292             myVTK2ObjIds.push_back(cellId); //apo
293           }
294           outputCD->CopyData(cd,cellId,newCellId);
295           break;
296
297         case VTK_TRIANGLE_STRIP:
298           newCellId = output->InsertNextCell(aCellType,npts,pts);
299           if(myStoreMapping){
300             myVTK2ObjIds.push_back(cellId); //apo
301           }
302           outputCD->CopyData(cd,cellId,newCellId);
303           break;
304
305         case VTK_PIXEL:
306           newCellId = output->InsertNextCell(aCellType,npts,pts);
307           if(myStoreMapping){
308             myVTK2ObjIds.push_back(cellId); //apo
309           }
310           outputCD->CopyData(cd,cellId,newCellId);
311           break;
312           
313         case VTK_CONVEX_POINT_SET:{
314           TCellArray tmpCellArray;
315           try{
316             CONVEX_TOOL::GetPolygonalFaces(input,cellId,tmpCellArray); // "VTKViewer_ConvexTool.cxx"
317           } catch (const std::exception& theExc){
318             cout << __FILE__ << "[" << __LINE__ << "] " << "Exception:" << theExc.what() << endl;
319           } catch (...) {
320             cout << __FILE__ << "[" << __LINE__ << "] " << "Exception was occured"<< endl;
321           }
322           TCellArray::iterator aFaceIter = tmpCellArray.begin();
323           for (;  aFaceIter!=tmpCellArray.end(); aFaceIter++){
324             TCell cell = aFaceIter->second;
325             numFacePts = cell.size();
326             if(numFacePts>3)
327               aCellType = VTK_POLYGON;
328             else if(numFacePts == 3)
329               aCellType = VTK_TRIANGLE;
330             else if(numFacePts<3)
331               continue;
332             
333             for ( i=0; i < numFacePts; i++)
334               {
335                 aNewPts[i] = cell[i];
336               }
337             newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
338             if(myStoreMapping){
339               myVTK2ObjIds.push_back(cellId);
340             }
341             outputCD->CopyData(cd,cellId,newCellId);
342           }
343           break;
344         }
345         case VTK_TETRA: {
346           for (faceId = 0; faceId < 4; faceId++)
347             {
348             faceIds->Reset();
349             faceVerts = vtkTetra::GetFaceArray(faceId);
350             faceIds->InsertNextId(pts[faceVerts[0]]);
351             faceIds->InsertNextId(pts[faceVerts[1]]);
352             faceIds->InsertNextId(pts[faceVerts[2]]);
353             numFacePts = 3;
354             aCellType = VTK_TRIANGLE;
355             input->GetCellNeighbors(cellId, faceIds, cellIds);
356             if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
357                  (!allVisible && !cellVis[cellIds->GetId(0)]) )
358               {
359               for ( i=0; i < numFacePts; i++)
360                 {
361                 aNewPts[i] = pts[faceVerts[i]];
362                 }
363               newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
364               if(myStoreMapping){
365                 myVTK2ObjIds.push_back(cellId); //apo
366               }
367               outputCD->CopyData(cd,cellId,newCellId);
368               }
369             }
370           break;
371         }
372         case VTK_VOXEL: {
373           for (faceId = 0; faceId < 6; faceId++)
374             {
375             faceIds->Reset();
376             faceVerts = vtkVoxel::GetFaceArray(faceId);
377             faceIds->InsertNextId(pts[faceVerts[0]]);
378             faceIds->InsertNextId(pts[faceVerts[1]]);
379             faceIds->InsertNextId(pts[faceVerts[2]]);
380             faceIds->InsertNextId(pts[faceVerts[3]]);
381             numFacePts = 4;
382             aCellType = VTK_QUAD;
383             input->GetCellNeighbors(cellId, faceIds, cellIds);
384             if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 || 
385                  (!allVisible && !cellVis[cellIds->GetId(0)]) )
386               {
387               for ( i=0; i < numFacePts; i++)
388                 {
389                 aNewPts[i] = pts[faceVerts[PixelConvert[i]]];
390                 }
391               newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
392               if(myStoreMapping){
393                 myVTK2ObjIds.push_back(cellId); //apo
394               }
395               outputCD->CopyData(cd,cellId,newCellId);
396               }
397             }
398           break;
399         }
400         case VTK_HEXAHEDRON: {
401           for (faceId = 0; faceId < 6; faceId++)
402             {
403             faceIds->Reset();
404             faceVerts = vtkHexahedron::GetFaceArray(faceId);
405             faceIds->InsertNextId(pts[faceVerts[0]]);
406             faceIds->InsertNextId(pts[faceVerts[1]]);
407             faceIds->InsertNextId(pts[faceVerts[2]]);
408             faceIds->InsertNextId(pts[faceVerts[3]]);
409             numFacePts = 4;
410             aCellType = VTK_QUAD;
411             input->GetCellNeighbors(cellId, faceIds, cellIds);
412             if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
413                  (!allVisible && !cellVis[cellIds->GetId(0)]) )
414               {
415               for ( i=0; i < numFacePts; i++)
416                 {
417                 aNewPts[i] = pts[faceVerts[i]];
418                 }
419               newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
420               if(myStoreMapping){
421                 myVTK2ObjIds.push_back(cellId); //apo
422               }
423               outputCD->CopyData(cd,cellId,newCellId);
424               }
425             }
426           break;
427         }
428         case VTK_WEDGE: {
429           for (faceId = 0; faceId < 5; faceId++)
430             {
431             faceIds->Reset();
432             faceVerts = vtkWedge::GetFaceArray(faceId);
433             faceIds->InsertNextId(pts[faceVerts[0]]);
434             faceIds->InsertNextId(pts[faceVerts[1]]);
435             faceIds->InsertNextId(pts[faceVerts[2]]);
436             numFacePts = 3;
437             aCellType = VTK_TRIANGLE;
438             if (faceVerts[3] >= 0)
439               {
440               faceIds->InsertNextId(pts[faceVerts[3]]);
441               numFacePts = 4;
442               aCellType = VTK_QUAD;
443               }
444             input->GetCellNeighbors(cellId, faceIds, cellIds);
445             if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 || 
446                  (!allVisible && !cellVis[cellIds->GetId(0)]) )
447               {
448               for ( i=0; i < numFacePts; i++)
449                 {
450                 aNewPts[i] = pts[faceVerts[i]];
451                 }
452               newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
453               if(myStoreMapping){
454                 myVTK2ObjIds.push_back(cellId); //apo
455               }
456               outputCD->CopyData(cd,cellId,newCellId);
457               }
458             }
459           break;
460         }
461         case VTK_PYRAMID: {
462           for (faceId = 0; faceId < 5; faceId++)
463             {
464             faceIds->Reset();
465             faceVerts = vtkPyramid::GetFaceArray(faceId);
466             faceIds->InsertNextId(pts[faceVerts[0]]);
467             faceIds->InsertNextId(pts[faceVerts[1]]);
468             faceIds->InsertNextId(pts[faceVerts[2]]);
469             numFacePts = 3;
470             aCellType = VTK_TRIANGLE;
471             if (faceVerts[3] >= 0)
472               {
473               faceIds->InsertNextId(pts[faceVerts[3]]);
474               numFacePts = 4;
475               aCellType = VTK_QUAD;
476               }
477             input->GetCellNeighbors(cellId, faceIds, cellIds);
478             if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 || 
479                  (!allVisible && !cellVis[cellIds->GetId(0)]) )
480               {
481               for ( i=0; i < numFacePts; i++)
482                 {
483                 aNewPts[i] = pts[faceVerts[i]];
484                 }
485               newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
486               if(myStoreMapping){
487                 myVTK2ObjIds.push_back(cellId); //apo
488               }
489               outputCD->CopyData(cd,cellId,newCellId);
490               }
491             }
492           break;
493         }
494         //Quadratic cells
495         case VTK_QUADRATIC_EDGE: {
496           newCellId = output->InsertNextCell(VTK_POLY_LINE,npts,pts);
497           if(myStoreMapping)
498             myVTK2ObjIds.push_back(cellId);
499
500           outputCD->CopyData(cd,cellId,newCellId);
501
502           break;
503         }
504         case VTK_QUADRATIC_TRIANGLE: {
505           numFacePts = 6;
506           aCellType = VTK_POLYGON;
507           
508           aNewPts[0] = pts[0];
509           aNewPts[1] = pts[3];
510           aNewPts[2] = pts[1];
511           aNewPts[3] = pts[4];
512           aNewPts[4] = pts[2];
513           aNewPts[5] = pts[5];
514
515           newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
516           if(myStoreMapping)
517             myVTK2ObjIds.push_back(cellId);
518
519           outputCD->CopyData(cd,cellId,newCellId);
520           break;
521         }
522         case VTK_QUADRATIC_QUAD: {
523           numFacePts = 8;
524           aCellType = VTK_POLYGON;
525           
526           aNewPts[0] = pts[0];
527           aNewPts[1] = pts[4];
528           aNewPts[2] = pts[1];
529           aNewPts[3] = pts[5];
530           aNewPts[4] = pts[2];
531           aNewPts[5] = pts[6];
532           aNewPts[6] = pts[3];
533           aNewPts[7] = pts[7];
534
535           newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
536           if(myStoreMapping)
537             myVTK2ObjIds.push_back(cellId);
538
539           outputCD->CopyData(cd,cellId,newCellId);
540           break;
541         }
542         case VTK_QUADRATIC_TETRA: {
543           numFacePts = 8;
544           aCellType = VTK_POLYGON;
545           
546           aNewPts[0] = pts[0];
547           aNewPts[1] = pts[4];
548           aNewPts[2] = pts[1];
549           aNewPts[3] = pts[5];
550           aNewPts[4] = pts[2];
551           aNewPts[5] = pts[6];
552           aNewPts[6] = pts[3];
553           aNewPts[7] = pts[7];
554
555           newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
556           if(myStoreMapping)
557             myVTK2ObjIds.push_back(cellId);
558
559           outputCD->CopyData(cd,cellId,newCellId);
560           break;
561         }
562         case VTK_QUADRATIC_HEXAHEDRON: {
563           numFacePts = 8;
564           aCellType = VTK_POLYGON;
565           
566           //---------------------------------------------------------------
567           aNewPts[0] = pts[0];
568           aNewPts[1] = pts[8];
569           aNewPts[2] = pts[1];
570           aNewPts[3] = pts[17];
571           aNewPts[4] = pts[5];
572           aNewPts[5] = pts[12];
573           aNewPts[6] = pts[4];
574           aNewPts[7] = pts[16];
575
576           newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
577           if(myStoreMapping)
578             myVTK2ObjIds.push_back(cellId);
579
580           outputCD->CopyData(cd,cellId,newCellId);
581
582           //---------------------------------------------------------------
583           aNewPts[0] = pts[1];
584           aNewPts[1] = pts[9];
585           aNewPts[2] = pts[2];
586           aNewPts[3] = pts[18];
587           aNewPts[4] = pts[6];
588           aNewPts[5] = pts[13];
589           aNewPts[6] = pts[5];
590           aNewPts[7] = pts[17];
591
592           newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
593           if(myStoreMapping)
594             myVTK2ObjIds.push_back(cellId);
595
596           outputCD->CopyData(cd,cellId,newCellId);
597
598           //---------------------------------------------------------------
599           aNewPts[0] = pts[2];
600           aNewPts[1] = pts[10];
601           aNewPts[2] = pts[3];
602           aNewPts[3] = pts[19];
603           aNewPts[4] = pts[7];
604           aNewPts[5] = pts[14];
605           aNewPts[6] = pts[6];
606           aNewPts[7] = pts[18];
607
608           newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
609           if(myStoreMapping)
610             myVTK2ObjIds.push_back(cellId);
611
612           outputCD->CopyData(cd,cellId,newCellId);
613
614           //---------------------------------------------------------------
615           aNewPts[0] = pts[3];
616           aNewPts[1] = pts[11];
617           aNewPts[2] = pts[0];
618           aNewPts[3] = pts[16];
619           aNewPts[4] = pts[4];
620           aNewPts[5] = pts[15];
621           aNewPts[6] = pts[7];
622           aNewPts[7] = pts[19];
623
624           newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
625           if(myStoreMapping)
626             myVTK2ObjIds.push_back(cellId);
627
628           outputCD->CopyData(cd,cellId,newCellId);
629
630           //---------------------------------------------------------------
631           aNewPts[0] = pts[0];
632           aNewPts[1] = pts[8];
633           aNewPts[2] = pts[1];
634           aNewPts[3] = pts[9];
635           aNewPts[4] = pts[2];
636           aNewPts[5] = pts[10];
637           aNewPts[6] = pts[3];
638           aNewPts[7] = pts[11];
639
640           newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
641           if(myStoreMapping)
642             myVTK2ObjIds.push_back(cellId);
643
644           outputCD->CopyData(cd,cellId,newCellId);
645
646           //---------------------------------------------------------------
647           aNewPts[0] = pts[4];
648           aNewPts[1] = pts[12];
649           aNewPts[2] = pts[5];
650           aNewPts[3] = pts[13];
651           aNewPts[4] = pts[6];
652           aNewPts[5] = pts[14];
653           aNewPts[6] = pts[7];
654           aNewPts[7] = pts[15];
655
656           newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
657           if(myStoreMapping)
658             myVTK2ObjIds.push_back(cellId);
659
660           outputCD->CopyData(cd,cellId,newCellId);
661
662           break;
663         }
664         } //switch
665       } //if visible
666     } //for all cells
667   
668   if(MYDEBUG && myStoreMapping){
669     for(int i = 0, iEnd = myVTK2ObjIds.size(); i < iEnd; i++){
670       cout<<myVTK2ObjIds[i]<<", ";
671     }
672     cout<<"\n";
673   }
674
675   // Update ourselves and release memory
676   //
677   //output->SetVerts(Verts);
678   //Verts->Delete();
679   //output->SetLines(Lines);
680   //Lines->Delete();
681   //output->SetPolys(Polys);
682   //Polys->Delete();
683   //output->SetStrips(Strips);
684   //Strips->Delete();
685   
686   output->Squeeze();
687
688   vtkDebugMacro(<<"Extracted " << input->GetNumberOfPoints() << " points,"
689   << output->GetNumberOfCells() << " cells.");
690
691   cellIds->Delete();
692   faceIds->Delete();
693   if ( cellVis )
694     {
695     delete [] cellVis;
696     }
697 }
698
699
700 void VTKViewer_GeometryFilter::SetInside(int theShowInside){
701   if(myShowInside == theShowInside) return;
702   myShowInside = theShowInside;
703   this->Modified();
704 }
705 int VTKViewer_GeometryFilter::GetInside(){
706   return myShowInside;
707 }