1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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, or (at your option) any later version.
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.
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
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // File : VTKViewer_GeometryFilter.cxx
24 // Author : Michael ZORIN
27 #include "VTKViewer_GeometryFilter.h"
28 #include "VTKViewer_ConvexTool.h"
29 #include "VTKViewer_ArcBuilder.h"
31 #include <vtkSmartPointer.h>
32 #include <vtkCellArray.h>
33 #include <vtkCellData.h>
34 #include <vtkGenericCell.h>
35 #include <vtkHexagonalPrism.h>
36 #include <vtkHexahedron.h>
37 #include <vtkInformation.h>
38 #include <vtkInformationVector.h>
39 #include <vtkMergePoints.h>
40 #include <vtkObjectFactory.h>
41 #include <vtkPointData.h>
42 #include <vtkPolyData.h>
43 #include <vtkPolygon.h>
44 #include <vtkPyramid.h>
45 #include <vtkStructuredGrid.h>
47 #include <vtkUnsignedCharArray.h>
48 #include <vtkUnstructuredGrid.h>
51 #include <vtkVersion.h>
59 #include "utilities.h"
67 #define VTK_XVERSION (VTK_MAJOR_VERSION*10000+VTK_MINOR_VERSION*100+VTK_BUILD_VERSION)
70 //#define USE_ROBUST_TRIANGULATION
72 ///////////////////////////////////////////////////////////////////////////////////////////////
73 // VSR 26/10/2012: fix of regression (issue 21924) - increased memory consumption
74 // for displaying of 3d elements, introduced by fix for issue 20314.
76 // The macro SHOW_COINCIDING_3D_PAL20314, when defined, allows correct visualization of
77 // coincident 3d elements but causes substantial increasing of memory consumption, as all 3d
78 // elements are always shown, even if they are totally covered by surrounding faces.
79 // If this macro is not defined (commented), the behaviour is defined by another macro -
80 // SHOW_COINCIDING_3D_PAL21924, as follows:
81 // - If SHOW_COINCIDING_3D_PAL21924 is defined, an alternative solution for computing
82 // visibility of 3d elements is used; this solution allows to fix problem with visibility
83 // of coinciding 3d elements in most cases (though some cases might not work), while not
84 // causing significant increasing of memory consumption.
85 // - If SHOW_COINCIDING_3D_PAL21924 is not defined (commented), coinciding 3d elements are
86 // not shown at all (this corresponds to the state before issue 20314 fixing).
87 ///////////////////////////////////////////////////////////////////////////////////////////////
88 //#define SHOW_COINCIDING_3D_PAL20314
89 #ifndef SHOW_COINCIDING_3D_PAL20314
90 #define SHOW_COINCIDING_3D_PAL21924
92 ///////////////////////////////////////////////////////////////////////////////////////////////
94 vtkStandardNewMacro(VTKViewer_GeometryFilter);
96 VTKViewer_GeometryFilter
97 ::VTKViewer_GeometryFilter():
100 myIsWireframeMode(0),
101 myAppendCoincident3D(0),
107 VTKViewer_GeometryFilter
108 ::~VTKViewer_GeometryFilter()
112 * \brief Return true for only one volume including a given edge
113 * \param [in] id1 - 1st edge end
114 * \param [in] id2 - second edge end
115 * \param [in] cellId - volume ID
116 * \param [in] input - the grid
118 static inline bool toShowEdge( vtkIdType id1, vtkIdType id2, vtkIdType cellId, vtkUnstructuredGrid* input )
120 // return true if the given cell is the 1st among cells including the edge
121 vtkCellLinks * links = input->GetCellLinks();
124 links = input->GetCellLinks();
127 std::swap( id1, id2 );
128 vtkIdType *cells = links->GetCells( id1 );
130 // among cells, look for a cell including the edge
131 vtkIdType *cellPts, npts, iCell = 0;
135 if ( cells[iCell] == cellId )
137 input->GetCellPoints( cells[iCell], npts, cellPts );
138 for ( vtkIdType i = 0; i < npts && !found; ++i )
139 found = ( cellPts[i] == id2 );
142 return ( cells[iCell] == cellId );
146 VTKViewer_GeometryFilter
148 vtkInformation *request,
149 vtkInformationVector **inputVector,
150 vtkInformationVector *outputVector)
152 // get the info objects
153 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
154 vtkInformation *outInfo = outputVector->GetInformationObject(0);
156 // get the input and ouptut
157 vtkDataSet *input = vtkDataSet::SafeDownCast(
158 inInfo->Get(vtkDataObject::DATA_OBJECT()));
159 vtkPolyData *output = vtkPolyData::SafeDownCast(
160 outInfo->Get(vtkDataObject::DATA_OBJECT()));
162 vtkIdType numCells=input->GetNumberOfCells();
169 if (input->GetDataObjectType() == VTK_UNSTRUCTURED_GRID){
170 return this->UnstructuredGridExecute(input, output, outInfo);
172 return Superclass::RequestData(request,inputVector,outputVector);
178 VTKViewer_GeometryFilter
179 ::UnstructuredGridExecute(vtkDataSet *dataSetInput,
181 vtkInformation *outInfo)
183 vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)dataSetInput;
184 vtkCellArray *Connectivity = input->GetCells();
186 if ( Connectivity == NULL )
188 vtkDebugMacro(<<"Nothing to extract");
197 vtkPoints *p = input->GetPoints();
198 vtkIdType numCells=input->GetNumberOfCells();
199 vtkPointData *pd = input->GetPointData();
200 vtkCellData *cd = input->GetCellData();
201 vtkPointData *outputPD = output->GetPointData();
203 VTKViewer_OrderedTriangulator anOrderedTriangulator;
204 VTKViewer_DelaunayTriangulator aDelaunayTriangulator;
206 vtkCellData *outputCD = output->GetCellData();
207 vtkGenericCell *cell = vtkGenericCell::New();
209 vtkIdList *cellIds = vtkIdList::New();
210 vtkIdList *faceIds = vtkIdList::New();
211 vtkIdList *cellIdsTmp = vtkIdList::New();
212 vtkIdList *faceIdsTmp = vtkIdList::New();
216 int faceId, *faceVerts, *edgeVerts, numFacePts;
218 vtkIdType PixelConvert[4];
219 // Change the type from int to vtkIdType in order to avoid compilation errors while using VTK
220 // from ParaView-3.4.0 compiled on 64-bit Debian platform with VTK_USE_64BIT_IDS = ON
221 vtkIdType aNewPts[VTK_CELL_SIZE];
223 unsigned char updateLevel = (unsigned char)(GetUpdateGhostLevel());
224 unsigned char *cellGhostLevels = 0;
231 vtkDebugMacro(<<"Executing geometry filter for unstructured grid input");
233 vtkDataArray* temp = 0;
236 temp = cd->GetArray("vtkGhostLevels");
238 if ( (!temp) || (temp->GetDataType() != VTK_UNSIGNED_CHAR)
239 || (temp->GetNumberOfComponents() != 1))
241 vtkDebugMacro("No appropriate ghost levels field available.");
245 cellGhostLevels = ((vtkUnsignedCharArray*)temp)->GetPointer(0);
248 // Determine nature of what we have to do
249 if ( (!this->CellClipping) && (!this->PointClipping) &&
250 (!this->ExtentClipping) )
258 cellVis = new char[numCells];
261 bool buildArcs = false;
264 // check if there are quadratic 1D or 2D elements
265 bool hasQuad1D2D = false;
266 if ( vtkUnsignedCharArray* types = input->GetCellTypesArray() )
268 std::set<vtkIdType> quad1D2DTypes;
269 quad1D2DTypes.insert( VTK_QUADRATIC_EDGE );
270 quad1D2DTypes.insert( VTK_QUADRATIC_TRIANGLE );
271 quad1D2DTypes.insert( VTK_BIQUADRATIC_TRIANGLE );
272 quad1D2DTypes.insert( VTK_QUADRATIC_QUAD );
273 quad1D2DTypes.insert( VTK_BIQUADRATIC_QUAD );
274 quad1D2DTypes.insert( VTK_QUADRATIC_POLYGON );
276 for ( int i = 0; i < types->GetNumberOfTuples() && !hasQuad1D2D; ++i )
277 hasQuad1D2D = quad1D2DTypes.count( types->GetValue(i) );
279 buildArcs = hasQuad1D2D;
283 // Issue 0020115: [CEA 308] Quadratic elements visualization
284 // Fix of remark described in note 0005222 - SIGSEGV
285 vtkPoints* outputPoints = vtkPoints::New();
286 outputPoints->DeepCopy(input->GetPoints());
287 output->SetPoints(outputPoints);
288 outputPoints->Delete();
292 output->SetPoints(input->GetPoints());
295 outputPD->PassData(pd);
297 outputCD->CopyAllocate(cd,numCells,numCells/2);
299 output->Allocate(numCells/4+1,numCells);
301 // Loop over the cells determining what's visible
304 for (cellId=0, Connectivity->InitTraversal();
305 Connectivity->GetNextCell(npts,pts);
309 if ( ( this->CellClipping && cellId < this->CellMinimum ) ||
310 cellId > this->CellMaximum )
316 for (i=0; i < npts; i++)
318 x = p->GetPoint(pts[i]);
319 if ( ( ( ( this->PointClipping && (pts[i] < this->PointMinimum ) ) ||
320 pts[i] > this->PointMaximum) ) ||
321 ( this->ExtentClipping &&
322 ( x[0] < this->Extent[0] || x[0] > this->Extent[1] ||
323 x[1] < this->Extent[2] || x[1] > this->Extent[3] ||
324 x[2] < this->Extent[4] || x[2] > this->Extent[5] )) )
328 }//point/extent clipping
330 }//if point clipping needs checking
332 }//if not all visible
334 if ( input->GetCellLinks() )
337 // Loop over all cells now that visibility is known
338 // (Have to compute visibility first for 3D cell boundaries)
339 int progressInterval = numCells/20 + 1;
340 TMapOfVectorId aDimension2VTK2ObjIds;
341 if ( myStoreMapping )
342 aDimension2VTK2ObjIds.resize( 3 ); // max dimension is 2
344 for (cellId=0, Connectivity->InitTraversal();
345 Connectivity->GetNextCell(npts,pts);
348 //Progress and abort method support
349 if ( !(cellId % progressInterval) )
351 vtkDebugMacro(<<"Process cell #" << cellId);
352 this->UpdateProgress ((float)cellId/numCells);
355 // Handle ghost cells here. Another option was used cellVis array.
356 if (cellGhostLevels && cellGhostLevels[cellId] > updateLevel)
357 { // Do not create surfaces in outer ghost cells.
361 if (allVisible || cellVis[cellId]) //now if visible extract geometry
363 //special code for nonlinear cells - rarely occurs, so right now it
365 vtkIdType aCellType = input->GetCellType(cellId);
372 case VTK_POLY_VERTEX:
373 newCellId = output->InsertNextCell(aCellType,npts,pts);
375 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
377 outputCD->CopyData(cd,cellId,newCellId);
382 newCellId = output->InsertNextCell(aCellType,npts,pts);
384 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
385 outputCD->CopyData(cd,cellId,newCellId);
391 newCellId = output->InsertNextCell(aCellType,npts,pts);
393 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
394 outputCD->CopyData(cd,cellId,newCellId);
397 case VTK_TRIANGLE_STRIP:
398 newCellId = output->InsertNextCell(aCellType,npts,pts);
400 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
401 outputCD->CopyData(cd,cellId,newCellId);
405 newCellId = output->InsertNextCell(aCellType,npts,pts);
407 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
408 outputCD->CopyData(cd,cellId,newCellId);
411 case VTK_CONVEX_POINT_SET: {
412 bool anIsOk = anOrderedTriangulator.Execute(input,
417 GetAppendCoincident3D(),
423 aDimension2VTK2ObjIds,
426 aDelaunayTriangulator.Execute(input,
431 GetAppendCoincident3D(),
437 aDimension2VTK2ObjIds,
446 aCellType = VTK_LINE;
447 for ( int edgeID = 0; edgeID < 6; ++edgeID )
449 edgeVerts = vtkTetra::GetEdgeArray( edgeID );
450 if ( toShowEdge( pts[edgeVerts[0]], pts[edgeVerts[1]], cellId, input ))
452 aNewPts[0] = pts[edgeVerts[0]];
453 aNewPts[1] = pts[edgeVerts[1]];
454 newCellId = output->InsertNextCell( aCellType, 2, aNewPts );
456 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
457 outputCD->CopyData(cd,cellId,newCellId);
464 #ifdef SHOW_COINCIDING_3D_PAL21924
465 faceIdsTmp->SetNumberOfIds( npts );
466 for ( int ai = 0; ai < npts; ai++ )
467 faceIdsTmp->SetId( ai, pts[ai] );
468 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
470 aCellType = VTK_TRIANGLE;
472 for (faceId = 0; faceId < 4; faceId++)
475 faceVerts = vtkTetra::GetFaceArray(faceId);
476 faceIds->InsertNextId(pts[faceVerts[0]]);
477 faceIds->InsertNextId(pts[faceVerts[1]]);
478 faceIds->InsertNextId(pts[faceVerts[2]]);
479 input->GetCellNeighbors(cellId, faceIds, cellIds);
480 int nbNeighbors = cellIds->GetNumberOfIds() - cellIdsTmp->GetNumberOfIds();
481 #ifdef SHOW_COINCIDING_3D_PAL21924
482 bool process = nbNeighbors <= 0;
484 bool process = nbNeighbors <= 0 || GetAppendCoincident3D();
486 if ( process || ( !allVisible && !cellVis[cellIds->GetId(0)] ))
488 for ( i=0; i < numFacePts; i++)
489 aNewPts[i] = pts[faceVerts[i]];
490 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
492 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
493 outputCD->CopyData(cd,cellId,newCellId);
503 aCellType = VTK_LINE;
504 for ( int edgeID = 0; edgeID < 12; ++edgeID )
506 edgeVerts = vtkVoxel::GetEdgeArray( edgeID );
507 if ( toShowEdge( pts[edgeVerts[0]], pts[edgeVerts[1]], cellId, input ))
509 aNewPts[0] = pts[edgeVerts[0]];
510 aNewPts[1] = pts[edgeVerts[1]];
511 newCellId = output->InsertNextCell( aCellType, 2, aNewPts );
513 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
514 outputCD->CopyData(cd,cellId,newCellId);
521 #ifdef SHOW_COINCIDING_3D_PAL21924
522 faceIdsTmp->SetNumberOfIds( npts );
523 for ( int ai = 0; ai < npts; ai++ )
524 faceIdsTmp->SetId( ai, pts[ai] );
525 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
527 for (faceId = 0; faceId < 6; faceId++)
530 faceVerts = vtkVoxel::GetFaceArray(faceId);
531 faceIds->InsertNextId(pts[faceVerts[0]]);
532 faceIds->InsertNextId(pts[faceVerts[1]]);
533 faceIds->InsertNextId(pts[faceVerts[2]]);
534 faceIds->InsertNextId(pts[faceVerts[3]]);
535 aCellType = VTK_QUAD;
537 input->GetCellNeighbors(cellId, faceIds, cellIds);
538 int nbNeighbors = cellIds->GetNumberOfIds() - cellIdsTmp->GetNumberOfIds();
539 #ifdef SHOW_COINCIDING_3D_PAL21924
540 bool process = nbNeighbors <= 0;
542 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
544 if ( process || ( !allVisible && !cellVis[cellIds->GetId(0)] ))
546 for ( i=0; i < numFacePts; i++)
547 aNewPts[i] = pts[faceVerts[PixelConvert[i]]];
548 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
550 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
551 outputCD->CopyData(cd,cellId,newCellId);
561 aCellType = VTK_LINE;
562 for ( int edgeID = 0; edgeID < 12; ++edgeID )
564 edgeVerts = vtkHexahedron::GetEdgeArray( edgeID );
565 if ( toShowEdge( pts[edgeVerts[0]], pts[edgeVerts[1]], cellId, input ))
567 aNewPts[0] = pts[edgeVerts[0]];
568 aNewPts[1] = pts[edgeVerts[1]];
569 newCellId = output->InsertNextCell( aCellType, 2, aNewPts );
571 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
572 outputCD->CopyData(cd,cellId,newCellId);
579 #ifdef SHOW_COINCIDING_3D_PAL21924
580 faceIdsTmp->SetNumberOfIds( npts );
581 for ( int ai = 0; ai < npts; ai++ )
582 faceIdsTmp->SetId( ai, pts[ai] );
583 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
585 aCellType = VTK_QUAD;
587 for (faceId = 0; faceId < 6; faceId++)
590 faceVerts = vtkHexahedron::GetFaceArray(faceId);
591 faceIds->InsertNextId(pts[faceVerts[0]]);
592 faceIds->InsertNextId(pts[faceVerts[1]]);
593 faceIds->InsertNextId(pts[faceVerts[2]]);
594 faceIds->InsertNextId(pts[faceVerts[3]]);
595 input->GetCellNeighbors(cellId, faceIds, cellIds);
596 int nbNeighbors = cellIds->GetNumberOfIds() - cellIdsTmp->GetNumberOfIds();
597 #ifdef SHOW_COINCIDING_3D_PAL21924
598 bool process = nbNeighbors <= 0;
600 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
602 if ( process || (!allVisible && !cellVis[cellIds->GetId(0)]) )
604 for ( i=0; i < numFacePts; i++)
605 aNewPts[i] = pts[faceVerts[i]];
606 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
608 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
609 outputCD->CopyData(cd,cellId,newCellId);
619 aCellType = VTK_LINE;
620 for ( int edgeID = 0; edgeID < 9; ++edgeID )
622 edgeVerts = vtkWedge::GetEdgeArray( edgeID );
623 if ( toShowEdge( pts[edgeVerts[0]], pts[edgeVerts[1]], cellId, input ))
625 aNewPts[0] = pts[edgeVerts[0]];
626 aNewPts[1] = pts[edgeVerts[1]];
627 newCellId = output->InsertNextCell( aCellType, 2, aNewPts );
629 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
630 outputCD->CopyData(cd,cellId,newCellId);
637 #ifdef SHOW_COINCIDING_3D_PAL21924
638 faceIdsTmp->SetNumberOfIds( npts );
639 for ( int ai = 0; ai < npts; ai++ )
640 faceIdsTmp->SetId( ai, pts[ai] );
641 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
643 for (faceId = 0; faceId < 5; faceId++)
646 faceVerts = vtkWedge::GetFaceArray(faceId);
647 faceIds->InsertNextId(pts[faceVerts[0]]);
648 faceIds->InsertNextId(pts[faceVerts[1]]);
649 faceIds->InsertNextId(pts[faceVerts[2]]);
650 aCellType = VTK_TRIANGLE;
652 if (faceVerts[3] >= 0)
654 faceIds->InsertNextId(pts[faceVerts[3]]);
655 aCellType = VTK_QUAD;
658 input->GetCellNeighbors(cellId, faceIds, cellIds);
659 int nbNeighbors = cellIds->GetNumberOfIds() - cellIdsTmp->GetNumberOfIds();
660 #ifdef SHOW_COINCIDING_3D_PAL21924
661 bool process = nbNeighbors <= 0;
663 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
665 if ( process || ( !allVisible && !cellVis[cellIds->GetId(0)] ))
667 for ( i=0; i < numFacePts; i++)
668 aNewPts[i] = pts[faceVerts[i]];
669 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
671 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
672 outputCD->CopyData(cd,cellId,newCellId);
678 case VTK_HEXAGONAL_PRISM:
682 aCellType = VTK_LINE;
683 for ( int edgeID = 0; edgeID < 18; ++edgeID )
685 edgeVerts = vtkHexagonalPrism::GetEdgeArray( edgeID );
686 if ( toShowEdge( pts[edgeVerts[0]], pts[edgeVerts[1]], cellId, input ))
688 aNewPts[0] = pts[edgeVerts[0]];
689 aNewPts[1] = pts[edgeVerts[1]];
690 newCellId = output->InsertNextCell( aCellType, 2, aNewPts );
692 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
693 outputCD->CopyData(cd,cellId,newCellId);
700 #ifdef SHOW_COINCIDING_3D_PAL21924
701 faceIdsTmp->SetNumberOfIds( npts );
702 for ( int ai = 0; ai < npts; ai++ )
703 faceIdsTmp->SetId( ai, pts[ai] );
704 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
706 for (faceId = 0; faceId < 8; faceId++)
708 faceVerts = vtkHexagonalPrism::GetFaceArray(faceId);
710 faceIds->InsertNextId(pts[faceVerts[0]]);
711 faceIds->InsertNextId(pts[faceVerts[1]]);
712 faceIds->InsertNextId(pts[faceVerts[2]]);
713 faceIds->InsertNextId(pts[faceVerts[3]]);
714 aCellType = VTK_QUAD;
716 if (faceVerts[5] >= 0)
718 faceIds->InsertNextId(pts[faceVerts[4]]);
719 faceIds->InsertNextId(pts[faceVerts[5]]);
720 aCellType = VTK_POLYGON;
723 input->GetCellNeighbors(cellId, faceIds, cellIds);
724 int nbNeighbors = cellIds->GetNumberOfIds() - cellIdsTmp->GetNumberOfIds();
725 #ifdef SHOW_COINCIDING_3D_PAL21924
726 bool process = nbNeighbors <= 0;
728 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
730 if ( process || ( !allVisible && !cellVis[cellIds->GetId(0)] ))
732 for ( i=0; i < numFacePts; i++)
733 aNewPts[i] = pts[faceVerts[i]];
734 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
736 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
737 outputCD->CopyData(cd,cellId,newCellId);
747 aCellType = VTK_LINE;
748 for ( int edgeID = 0; edgeID < 8; ++edgeID )
750 edgeVerts = vtkPyramid::GetEdgeArray( edgeID );
751 if ( toShowEdge( pts[edgeVerts[0]], pts[edgeVerts[1]], cellId, input ))
753 aNewPts[0] = pts[edgeVerts[0]];
754 aNewPts[1] = pts[edgeVerts[1]];
755 newCellId = output->InsertNextCell( aCellType, 2, aNewPts );
757 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
758 outputCD->CopyData(cd,cellId,newCellId);
765 #ifdef SHOW_COINCIDING_3D_PAL21924
766 faceIdsTmp->SetNumberOfIds( npts );
767 for ( int ai = 0; ai < npts; ai++ )
768 faceIdsTmp->SetId( ai, pts[ai] );
769 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
771 for (faceId = 0; faceId < 5; faceId++)
774 faceVerts = vtkPyramid::GetFaceArray(faceId);
775 faceIds->InsertNextId(pts[faceVerts[0]]);
776 faceIds->InsertNextId(pts[faceVerts[1]]);
777 faceIds->InsertNextId(pts[faceVerts[2]]);
778 aCellType = VTK_TRIANGLE;
780 if (faceVerts[3] >= 0)
782 faceIds->InsertNextId(pts[faceVerts[3]]);
783 aCellType = VTK_QUAD;
786 input->GetCellNeighbors(cellId, faceIds, cellIds);
787 int nbNeighbors = cellIds->GetNumberOfIds() - cellIdsTmp->GetNumberOfIds();
788 #ifdef SHOW_COINCIDING_3D_PAL21924
789 bool process = nbNeighbors <= 0;
791 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
793 if ( process || ( !allVisible && !cellVis[cellIds->GetId(0)] ))
795 for ( i=0; i < numFacePts; i++)
796 aNewPts[i] = pts[faceVerts[i]];
797 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
799 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
800 outputCD->CopyData(cd,cellId,newCellId);
807 #if VTK_XVERSION > 50700
810 vtkIdType nFaces = 0;
811 vtkIdType* ptIds = 0;
813 input->GetFaceStream(cellId, nFaces, ptIds);
814 #ifdef SHOW_COINCIDING_3D_PAL21924
817 faceIdsTmp->Reset(); // use 2 facets
818 numFacePts = ptIds[idp];
819 for (i = 0; i < numFacePts; i++)
820 faceIdsTmp->InsertNextId(ptIds[idp + i]);
822 numFacePts = ptIds[idp];
823 for (i = 0; i < numFacePts; i++)
824 faceIdsTmp->InsertNextId(ptIds[idp + i]);
825 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
829 for (faceId = 0; faceId < nFaces; faceId++)
832 numFacePts = ptIds[idp];
834 for (i = 0; i < numFacePts; i++)
836 faceIds->InsertNextId(ptIds[idp + i]);
841 case 3: aCellType = VTK_TRIANGLE; break;
842 case 4: aCellType = VTK_QUAD; break;
843 default:aCellType = VTK_POLYGON;
845 input->GetCellNeighbors(cellId, faceIds, cellIds);
846 int nbNeighbors = cellIds->GetNumberOfIds() - cellIdsTmp->GetNumberOfIds();
847 if ( myShowInside && nbNeighbors > 0 && cellId < cellIds->GetId(0) )
848 continue; // don't add twice same internal face in wireframe mode
849 #ifdef SHOW_COINCIDING_3D_PAL21924
850 bool process = nbNeighbors <= 0;
852 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
854 if (process || myShowInside
855 || (!allVisible && !cellVis[cellIds->GetId(0)]))
857 for (i = 0; i < numFacePts; i++)
858 aNewPts[i] = ptIds[pt0 + i];
859 newCellId = output->InsertNextCell(aCellType, numFacePts, aNewPts);
861 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
862 outputCD->CopyData(cd, cellId, newCellId);
869 case VTK_QUADRATIC_EDGE:
870 case VTK_QUADRATIC_TRIANGLE:
871 case VTK_BIQUADRATIC_TRIANGLE:
872 case VTK_QUADRATIC_QUAD:
873 case VTK_BIQUADRATIC_QUAD:
874 case VTK_QUADRATIC_POLYGON:
875 case VTK_QUADRATIC_TETRA:
876 case VTK_QUADRATIC_HEXAHEDRON:
877 case VTK_TRIQUADRATIC_HEXAHEDRON:
878 case VTK_QUADRATIC_WEDGE:
879 case VTK_QUADRATIC_PYRAMID:
881 if(!myIsWireframeMode)
883 input->GetCell(cellId,cell);
884 vtkIdList *lpts = vtkIdList::New();
885 vtkPoints *coords = vtkPoints::New();
886 vtkIdList *cellIds = vtkIdList::New();
889 if ( cell->GetCellDimension() == 1 ) {
890 vtkIdType arcResult = -1;
892 arcResult = Build1DArc(cellId, input, output, pts, myMaxArcAngle);
893 newCellId = arcResult;
896 if(!myIsBuildArc || arcResult == -1 ) {
897 aCellType = VTK_LINE;
899 cell->Triangulate(0,lpts,coords);
900 for (i=0; i < lpts->GetNumberOfIds(); i+=2) {
901 aNewPts[0] = lpts->GetId(i);
902 aNewPts[1] = lpts->GetId(i+1);
903 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
905 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
906 outputCD->CopyData(cd,cellId,newCellId);
911 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
912 outputCD->CopyData(cd,cellId,newCellId);
915 else if ( cell->GetCellDimension() == 2 ) {
917 aCellType = VTK_TRIANGLE;
919 cell->Triangulate(0,lpts,coords);
920 for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
921 aNewPts[0] = lpts->GetId(i);
922 aNewPts[1] = lpts->GetId(i+1);
923 aNewPts[2] = lpts->GetId(i+2);
924 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
926 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
927 outputCD->CopyData(cd,cellId,newCellId);
931 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds,true);
934 else //3D nonlinear cell
936 #ifdef SHOW_COINCIDING_3D_PAL21924
940 case VTK_QUADRATIC_TETRA: npts1 = 4; break;
941 case VTK_QUADRATIC_HEXAHEDRON: npts1 = 8; break;
942 case VTK_TRIQUADRATIC_HEXAHEDRON: npts1 = 8; break;
943 case VTK_QUADRATIC_WEDGE: npts1 = 6; break;
944 case VTK_QUADRATIC_PYRAMID: npts1 = 5; break;
947 for (int ai=0; ai<npts; ai++)
948 faceIdsTmp->InsertNextId(pts[ai]);
949 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
952 aCellType = VTK_TRIANGLE;
954 for (int j=0; j < cell->GetNumberOfFaces(); j++)
956 vtkCell *face = cell->GetFace(j);
957 input->GetCellNeighbors(cellId, face->PointIds, cellIds);
958 int nbNeighbors = cellIds->GetNumberOfIds() - cellIdsTmp->GetNumberOfIds();
959 #ifdef SHOW_COINCIDING_3D_PAL21924
960 bool process = nbNeighbors <= 0;
962 bool process = nbNeighbors <= 0 || GetAppendCoincident3D();
964 if ( process || myShowInside ) {
965 face->Triangulate(0,lpts,coords);
966 for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
967 aNewPts[0] = lpts->GetId(i);
968 aNewPts[1] = lpts->GetId(i+1);
969 aNewPts[2] = lpts->GetId(i+2);
970 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
972 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
973 outputCD->CopyData(cd,cellId,newCellId);
977 } //3d nonlinear cell
985 case VTK_QUADRATIC_EDGE:
987 vtkIdType arcResult =-1;
989 arcResult = Build1DArc(cellId, input, output, pts,myMaxArcAngle);
990 newCellId = arcResult;
992 if(!myIsBuildArc || arcResult == -1) {
993 aCellType = VTK_POLY_LINE;
1000 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1004 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1006 outputCD->CopyData(cd,cellId,newCellId);
1009 case VTK_QUADRATIC_TRIANGLE:
1010 case VTK_BIQUADRATIC_TRIANGLE:
1013 aCellType = VTK_POLYGON;
1016 aNewPts[0] = pts[0];
1017 aNewPts[1] = pts[3];
1018 aNewPts[2] = pts[1];
1019 aNewPts[3] = pts[4];
1020 aNewPts[4] = pts[2];
1021 aNewPts[5] = pts[5];
1023 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1025 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1027 outputCD->CopyData(cd,cellId,newCellId);
1030 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds);
1033 case VTK_QUADRATIC_QUAD:
1034 case VTK_BIQUADRATIC_QUAD:
1037 aCellType = VTK_POLYGON;
1040 aNewPts[0] = pts[0];
1041 aNewPts[1] = pts[4];
1042 aNewPts[2] = pts[1];
1043 aNewPts[3] = pts[5];
1044 aNewPts[4] = pts[2];
1045 aNewPts[5] = pts[6];
1046 aNewPts[6] = pts[3];
1047 aNewPts[7] = pts[7];
1049 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1051 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1053 outputCD->CopyData(cd,cellId,newCellId);
1056 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds);
1059 case VTK_QUADRATIC_POLYGON:
1063 aCellType = VTK_POLYGON;
1065 for ( i = 0; i < npts/2; ++i )
1067 aNewPts[i*2 ] = pts[i];
1068 aNewPts[i*2+1] = pts[i+npts/2];
1070 newCellId = output->InsertNextCell(aCellType,npts,aNewPts);
1072 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1074 outputCD->CopyData(cd,cellId,newCellId);
1077 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds);
1080 case VTK_QUADRATIC_TETRA:
1081 case VTK_QUADRATIC_WEDGE:
1082 case VTK_TRIQUADRATIC_HEXAHEDRON:
1083 case VTK_QUADRATIC_HEXAHEDRON:
1084 case VTK_QUADRATIC_PYRAMID:
1086 aCellType = VTK_POLY_LINE;
1087 input->GetCell(cellId,cell);
1090 int nbEdges = cell->GetNumberOfEdges();
1091 for ( int edgeId = 0; edgeId < nbEdges; ++edgeId )
1093 vtkCell * edge = cell->GetEdge( edgeId );
1094 if ( toShowEdge( edge->GetPointId(0), edge->GetPointId(2), cellId, input ))
1096 aNewPts[0] = edge->GetPointId(0);
1097 aNewPts[1] = edge->GetPointId(2);
1098 aNewPts[2] = edge->GetPointId(1);
1099 newCellId = output->InsertNextCell( aCellType, 3, aNewPts );
1101 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1102 outputCD->CopyData(cd,cellId,newCellId);
1108 #ifdef SHOW_COINCIDING_3D_PAL21924
1109 int nbPnt = npts - cell->GetNumberOfEdges();
1110 faceIdsTmp->SetNumberOfIds( nbPnt );
1111 for ( int ai = 0; ai < nbPnt; ai++ )
1112 faceIdsTmp->SetId( ai, pts[ai] );
1113 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
1115 int nbFaces = cell->GetNumberOfFaces();
1116 for ( faceId = 0; faceId < nbFaces; faceId++ )
1118 vtkCell * face = cell->GetFace( faceId );
1119 input->GetCellNeighbors( cellId, face->GetPointIds(), cellIds );
1120 int nbNeighbors = cellIds->GetNumberOfIds() - cellIdsTmp->GetNumberOfIds();
1121 if ( nbNeighbors <= 0 )
1123 int nbEdges = face->GetNumberOfPoints() / 2;
1124 for ( int edgeId = 0; edgeId < nbEdges; ++edgeId )
1126 vtkIdType p1 = ( edgeId );
1127 vtkIdType p2 = ( edgeId + nbEdges );
1128 vtkIdType p3 = ( edgeId + 1 ) % nbEdges;
1129 if ( toShowEdge( face->GetPointId(p1), face->GetPointId(p2), cellId, input ))
1131 aNewPts[0] = face->GetPointId( p1 );
1132 aNewPts[1] = face->GetPointId( p2 );
1133 aNewPts[2] = face->GetPointId( p3 );
1134 newCellId = output->InsertNextCell( aCellType, 3, aNewPts );
1136 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1137 outputCD->CopyData(cd,cellId,newCellId);
1144 } // case of volumes in wireframe
1145 } // switch by quadratic type
1155 vtkDebugMacro(<<"Extracted " << input->GetNumberOfPoints() << " points,"
1156 << output->GetNumberOfCells() << " cells.");
1162 cellIdsTmp->Delete();
1163 faceIdsTmp->Delete();
1170 if ( input->GetCellLinks() )
1172 input->GetCellLinks()->Initialize(); // free memory
1175 // fill myVTK2ObjIds vector in ascending cell dimension order
1176 myVTK2ObjIds.clear();
1177 if( myStoreMapping && !aDimension2VTK2ObjIds.empty() )
1179 size_t nbCells = ( aDimension2VTK2ObjIds[0].size() +
1180 aDimension2VTK2ObjIds[1].size() +
1181 aDimension2VTK2ObjIds[2].size() );
1182 if ( myVTK2ObjIds.capacity() > nbCells )
1183 TVectorId().swap( myVTK2ObjIds );
1184 myVTK2ObjIds.reserve( nbCells );
1186 for( int aDimension = 0; aDimension <= 2; aDimension++ )
1187 if ( !aDimension2VTK2ObjIds[ aDimension ].empty() )
1189 myVTK2ObjIds.insert( myVTK2ObjIds.end(),
1190 aDimension2VTK2ObjIds[ aDimension ].begin(),
1191 aDimension2VTK2ObjIds[ aDimension ].end() );
1192 TVectorId().swap( aDimension2VTK2ObjIds[ aDimension ]);
1200 VTKViewer_GeometryFilter
1201 ::InsertId( const vtkIdType theCellId,
1202 const vtkIdType theCellType,
1203 TVectorId& theVTK2ObjIds,
1204 TMapOfVectorId& theDimension2VTK2ObjIds )
1206 //theVTK2ObjIds.push_back( theCellId );
1209 switch( theCellType )
1212 case VTK_POLY_VERTEX:
1220 case VTK_TRIANGLE_STRIP:
1228 TVectorId& aCellIds = theDimension2VTK2ObjIds[ aDimension ];
1229 aCellIds.push_back( theCellId );
1233 VTKViewer_GeometryFilter
1234 ::SetInside(int theShowInside)
1236 if(myShowInside == theShowInside)
1239 myShowInside = theShowInside;
1244 VTKViewer_GeometryFilter
1247 return myShowInside;
1252 VTKViewer_GeometryFilter
1253 ::SetWireframeMode(int theIsWireframeMode)
1255 if(myIsWireframeMode == theIsWireframeMode)
1258 myIsWireframeMode = theIsWireframeMode;
1263 VTKViewer_GeometryFilter
1264 ::GetWireframeMode()
1266 return myIsWireframeMode;
1271 VTKViewer_GeometryFilter
1272 ::SetStoreMapping(int theStoreMapping)
1274 if(myStoreMapping == theStoreMapping)
1277 myStoreMapping = theStoreMapping;
1282 VTKViewer_GeometryFilter
1285 return myStoreMapping;
1289 vtkIdType VTKViewer_GeometryFilter::GetElemObjId( int theVtkID )
1291 if( theVtkID < 0 || theVtkID >= (int)myVTK2ObjIds.size() )
1293 return myVTK2ObjIds[theVtkID];
1297 void VTKViewer_GeometryFilter::BuildArcedPolygon(vtkIdType cellId,
1298 vtkUnstructuredGrid* input,
1299 vtkPolyData *output,
1300 TMapOfVectorId& theDimension2VTK2ObjIds,
1303 vtkIdType aCellType = VTK_POLYGON;
1304 vtkIdType *aNewPoints = NULL;
1305 vtkIdType aNbPoints = 0;
1306 vtkIdType newCellId;
1308 //Input and output cell data
1309 vtkCellData *cd = input->GetCellData();
1310 vtkCellData *outputCD = output->GetCellData();
1312 //Input and output scalars on point data
1313 vtkDataArray* inputScalars = input->GetPointData()->GetScalars();
1314 vtkDataArray* outputScalars = output->GetPointData()->GetScalars();
1316 std::vector< vtkSmartPointer<vtkPoints> > aCollection;
1317 std::vector< std::vector<double> > aScalarCollection;
1319 vtkCell* aCell = input->GetCell(cellId);
1320 switch(aCell->GetCellType()) {
1321 case VTK_QUADRATIC_TRIANGLE:
1322 case VTK_BIQUADRATIC_TRIANGLE:
1324 //Get All points from input cell
1325 Pnt P0 = CreatePnt( aCell, inputScalars, 0 );
1326 Pnt P1 = CreatePnt( aCell, inputScalars, 1 );
1327 Pnt P2 = CreatePnt( aCell, inputScalars, 2 );
1328 Pnt P3 = CreatePnt( aCell, inputScalars, 3 );
1329 Pnt P4 = CreatePnt( aCell, inputScalars, 4 );
1330 Pnt P5 = CreatePnt( aCell, inputScalars, 5 );
1332 VTKViewer_ArcBuilder aBuilder1(P0,P3,P1,myMaxArcAngle); //Build arc using 0, 3 and 1 points
1334 cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1337 VTKViewer_ArcBuilder aBuilder2(P1,P4,P2,myMaxArcAngle); //Build arc using 1, 4 and 2 points
1339 cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1342 VTKViewer_ArcBuilder aBuilder3(P2,P5,P0,myMaxArcAngle); //Build arc using 2, 5 and 0 points
1344 cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1347 aCollection.push_back(aBuilder1.GetPoints());
1348 aCollection.push_back(aBuilder2.GetPoints());
1349 aCollection.push_back(aBuilder3.GetPoints());
1351 aScalarCollection.push_back(aBuilder1.GetScalarValues());
1352 aScalarCollection.push_back(aBuilder2.GetScalarValues());
1353 aScalarCollection.push_back(aBuilder3.GetScalarValues());
1356 case VTK_QUADRATIC_QUAD:
1357 case VTK_BIQUADRATIC_QUAD:
1359 //Get All points from input cell
1360 Pnt P0 = CreatePnt( aCell, inputScalars, 0 );
1361 Pnt P1 = CreatePnt( aCell, inputScalars, 1 );
1362 Pnt P2 = CreatePnt( aCell, inputScalars, 2 );
1363 Pnt P3 = CreatePnt( aCell, inputScalars, 3 );
1364 Pnt P4 = CreatePnt( aCell, inputScalars, 4 );
1365 Pnt P5 = CreatePnt( aCell, inputScalars, 5 );
1366 Pnt P6 = CreatePnt( aCell, inputScalars, 6 );
1367 Pnt P7 = CreatePnt( aCell, inputScalars, 7 );
1369 VTKViewer_ArcBuilder aBuilder1(P0,P4,P1,myMaxArcAngle); //Build arc using 0, 4 and 1 points
1371 cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1374 VTKViewer_ArcBuilder aBuilder2(P1,P5,P2,myMaxArcAngle); //Build arc using 1, 5 and 2 points
1376 cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1379 VTKViewer_ArcBuilder aBuilder3(P2,P6,P3,myMaxArcAngle); //Build arc using 2, 6 and 3 points
1381 cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1384 VTKViewer_ArcBuilder aBuilder4(P3,P7,P0,myMaxArcAngle); //Build arc using 3, 7 and 0 points
1386 cout << "Quadrangle arc 4 " << ( aBuilder4.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1389 aCollection.push_back(aBuilder1.GetPoints());
1390 aCollection.push_back(aBuilder2.GetPoints());
1391 aCollection.push_back(aBuilder3.GetPoints());
1392 aCollection.push_back(aBuilder4.GetPoints());
1394 aScalarCollection.push_back(aBuilder1.GetScalarValues());
1395 aScalarCollection.push_back(aBuilder2.GetScalarValues());
1396 aScalarCollection.push_back(aBuilder3.GetScalarValues());
1397 aScalarCollection.push_back(aBuilder4.GetScalarValues());
1400 case VTK_QUADRATIC_POLYGON:
1402 int nbP = aCell->GetNumberOfPoints();
1403 std::vector< Pnt > pVec( nbP + 2 );
1405 for ( int i = 0; i < nbP/2; ++i )
1407 pVec[i*2 + 0] = CreatePnt( aCell, inputScalars, i );
1408 pVec[i*2 + 1] = CreatePnt( aCell, inputScalars, i + nbP/2 );
1410 pVec[ nbP ] = pVec[ 0 ];
1411 pVec[ nbP+1 ] = pVec[ 1 ];
1413 for ( int i = 0; i < nbP; i += 2 )
1415 VTKViewer_ArcBuilder aBuilder( pVec[i], pVec[i+1], pVec[i+2], myMaxArcAngle );
1416 aCollection.push_back( aBuilder.GetPoints() );
1417 aScalarCollection.push_back( aBuilder.GetScalarValues() );
1421 default: //Unsupported cell type
1426 const vtkIdType numFacePts = 3;
1427 vtkIdList *pts = vtkIdList::New();
1428 vtkPoints *coords = vtkPoints::New();
1429 aCellType = VTK_TRIANGLE;
1430 vtkIdType aNewPts[numFacePts];
1431 vtkIdType aTriangleId;
1433 vtkPolygon *aPlg = vtkPolygon::New();
1434 std::map<int, double> aPntId2ScalarValue;
1435 aNbPoints = MergevtkPoints(aCollection, aScalarCollection, aPlg->GetPoints(), aPntId2ScalarValue, aNewPoints);
1436 aPlg->GetPointIds()->SetNumberOfIds(aNbPoints);
1438 for(vtkIdType i = 0; i < aNbPoints;i++) {
1439 aPlg->GetPointIds()->SetId(i, aNewPoints[i]);
1442 aPlg->Triangulate(0,pts,coords);
1444 for (vtkIdType i=0; i < pts->GetNumberOfIds(); i+=3) {
1445 aNewPts[0] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i));
1446 aNewPts[1] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+1));
1447 aNewPts[2] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+2));
1450 outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i)]);
1451 outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+1)]);
1452 outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+2)]);
1455 aTriangleId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1458 InsertId( cellId, aCellType, myVTK2ObjIds, theDimension2VTK2ObjIds );
1459 outputCD->CopyData(cd,cellId,aTriangleId);
1466 std::map<int, double> aPntId2ScalarValue;
1467 aNbPoints = MergevtkPoints(aCollection, aScalarCollection, output->GetPoints(), aPntId2ScalarValue, aNewPoints);
1469 for(vtkIdType i = 0; i < aNbPoints; i++)
1470 outputScalars->InsertNextTuple1(aPntId2ScalarValue[aNewPoints[i]]);
1471 newCellId = output->InsertNextCell(aCellType,aNbPoints,aNewPoints);
1472 outputCD->CopyData(cd,cellId,newCellId);
1475 InsertId( cellId, aCellType, myVTK2ObjIds, theDimension2VTK2ObjIds );
1479 delete [] aNewPoints;
1483 void VTKViewer_GeometryFilter::SetQuadraticArcMode(bool theFlag)
1485 if(myIsBuildArc != theFlag) {
1486 myIsBuildArc = theFlag;
1490 bool VTKViewer_GeometryFilter::GetQuadraticArcMode() const
1492 return myIsBuildArc;
1495 void VTKViewer_GeometryFilter::SetQuadraticArcAngle(double theMaxAngle)
1497 if(myMaxArcAngle != theMaxAngle) {
1498 myMaxArcAngle = theMaxAngle;
1503 double VTKViewer_GeometryFilter:: GetQuadraticArcAngle() const
1505 return myMaxArcAngle;
1508 int VTKViewer_GeometryFilter::GetAppendCoincident3D() const {
1509 // VSR 26/10/2012: see description of SHOW_COINCIDING_3D_PAL20314
1510 // in the top of this file
1511 #ifdef SHOW_COINCIDING_3D_PAL20314
1512 return myAppendCoincident3D;
1518 void VTKViewer_GeometryFilter::SetAppendCoincident3D(int theFlag) {
1519 if(myAppendCoincident3D != theFlag){
1520 myAppendCoincident3D = theFlag;