1 // Copyright (C) 2007-2015 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 myAppendCoincident3D(0),
101 myIsWireframeMode(0),
107 VTKViewer_GeometryFilter
108 ::~VTKViewer_GeometryFilter()
113 VTKViewer_GeometryFilter
115 vtkInformation *request,
116 vtkInformationVector **inputVector,
117 vtkInformationVector *outputVector)
119 // get the info objects
120 vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
121 vtkInformation *outInfo = outputVector->GetInformationObject(0);
123 // get the input and ouptut
124 vtkDataSet *input = vtkDataSet::SafeDownCast(
125 inInfo->Get(vtkDataObject::DATA_OBJECT()));
126 vtkPolyData *output = vtkPolyData::SafeDownCast(
127 outInfo->Get(vtkDataObject::DATA_OBJECT()));
129 vtkIdType numCells=input->GetNumberOfCells();
136 if (input->GetDataObjectType() == VTK_UNSTRUCTURED_GRID){
137 return this->UnstructuredGridExecute(input, output, outInfo);
139 return Superclass::RequestData(request,inputVector,outputVector);
146 VTKViewer_GeometryFilter
147 ::UnstructuredGridExecute(vtkDataSet *dataSetInput,
149 vtkInformation *outInfo)
152 vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)dataSetInput;
153 vtkCellArray *Connectivity = input->GetCells();
155 if ( Connectivity == NULL )
157 vtkDebugMacro(<<"Nothing to extract");
166 vtkPoints *p = input->GetPoints();
167 vtkIdType numCells=input->GetNumberOfCells();
168 vtkPointData *pd = input->GetPointData();
169 vtkCellData *cd = input->GetCellData();
170 vtkPointData *outputPD = output->GetPointData();
172 VTKViewer_OrderedTriangulator anOrderedTriangulator;
173 VTKViewer_DelaunayTriangulator aDelaunayTriangulator;
175 vtkCellData *outputCD = output->GetCellData();
176 vtkGenericCell *cell = vtkGenericCell::New();
178 vtkIdList *cellIds = vtkIdList::New();
179 vtkIdList *faceIds = vtkIdList::New();
180 vtkIdList *cellIdsTmp = vtkIdList::New();
181 vtkIdList *faceIdsTmp = vtkIdList::New();
185 int faceId, *faceVerts, numFacePts;
187 vtkIdType PixelConvert[4];
188 // Change the type from int to vtkIdType in order to avoid compilation errors while using VTK
189 // from ParaView-3.4.0 compiled on 64-bit Debian platform with VTK_USE_64BIT_IDS = ON
190 vtkIdType aNewPts[VTK_CELL_SIZE];
192 unsigned char updateLevel = (unsigned char)(GetUpdateGhostLevel());
193 unsigned char *cellGhostLevels = 0;
200 vtkDebugMacro(<<"Executing geometry filter for unstructured grid input");
202 vtkDataArray* temp = 0;
205 temp = cd->GetArray("vtkGhostLevels");
207 if ( (!temp) || (temp->GetDataType() != VTK_UNSIGNED_CHAR)
208 || (temp->GetNumberOfComponents() != 1))
210 vtkDebugMacro("No appropriate ghost levels field available.");
214 cellGhostLevels = ((vtkUnsignedCharArray*)temp)->GetPointer(0);
217 // Determine nature of what we have to do
218 if ( (!this->CellClipping) && (!this->PointClipping) &&
219 (!this->ExtentClipping) )
227 cellVis = new char[numCells];
230 // Issue 0020115: [CEA 308] Quadratic elements visualization
231 // Fix of remark described in note 0005222 - SIGSEGV
232 vtkPoints* outputPoints = vtkPoints::New();
233 outputPoints->DeepCopy(input->GetPoints());
234 output->SetPoints(outputPoints);
235 outputPoints->Delete();
237 outputPD->PassData(pd);
239 outputCD->CopyAllocate(cd,numCells,numCells/2);
241 output->Allocate(numCells/4+1,numCells);
243 // Loop over the cells determining what's visible
246 for (cellId=0, Connectivity->InitTraversal();
247 Connectivity->GetNextCell(npts,pts);
251 if ( ( this->CellClipping && cellId < this->CellMinimum ) ||
252 cellId > this->CellMaximum )
258 for (i=0; i < npts; i++)
260 x = p->GetPoint(pts[i]);
261 if ( ( ( ( this->PointClipping && (pts[i] < this->PointMinimum ) ) ||
262 pts[i] > this->PointMaximum) ) ||
263 ( this->ExtentClipping &&
264 ( x[0] < this->Extent[0] || x[0] > this->Extent[1] ||
265 x[1] < this->Extent[2] || x[1] > this->Extent[3] ||
266 x[2] < this->Extent[4] || x[2] > this->Extent[5] )) )
270 }//point/extent clipping
272 }//if point clipping needs checking
274 }//if not all visible
276 // Loop over all cells now that visibility is known
277 // (Have to compute visibility first for 3D cell boundaries)
278 int progressInterval = numCells/20 + 1;
279 TMapOfVectorId aDimension2VTK2ObjIds;
281 myVTK2ObjIds.clear();
282 myVTK2ObjIds.reserve(numCells);
284 for (cellId=0, Connectivity->InitTraversal();
285 Connectivity->GetNextCell(npts,pts);
288 //Progress and abort method support
289 if ( !(cellId % progressInterval) )
291 vtkDebugMacro(<<"Process cell #" << cellId);
292 this->UpdateProgress ((float)cellId/numCells);
295 // Handle ghost cells here. Another option was used cellVis array.
296 if (cellGhostLevels && cellGhostLevels[cellId] > updateLevel)
297 { // Do not create surfaces in outer ghost cells.
301 if (allVisible || cellVis[cellId]) //now if visible extract geometry
303 //special code for nonlinear cells - rarely occurs, so right now it
305 vtkIdType aCellType = input->GetCellType(cellId);
312 case VTK_POLY_VERTEX:
313 newCellId = output->InsertNextCell(aCellType,npts,pts);
315 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
317 outputCD->CopyData(cd,cellId,newCellId);
322 newCellId = output->InsertNextCell(aCellType,npts,pts);
324 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
325 outputCD->CopyData(cd,cellId,newCellId);
331 newCellId = output->InsertNextCell(aCellType,npts,pts);
333 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
334 outputCD->CopyData(cd,cellId,newCellId);
337 case VTK_TRIANGLE_STRIP:
338 newCellId = output->InsertNextCell(aCellType,npts,pts);
340 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
341 outputCD->CopyData(cd,cellId,newCellId);
345 newCellId = output->InsertNextCell(aCellType,npts,pts);
347 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
348 outputCD->CopyData(cd,cellId,newCellId);
351 case VTK_CONVEX_POINT_SET: {
352 bool anIsOk = anOrderedTriangulator.Execute(input,
357 GetAppendCoincident3D(),
363 aDimension2VTK2ObjIds,
366 aDelaunayTriangulator.Execute(input,
371 GetAppendCoincident3D(),
377 aDimension2VTK2ObjIds,
383 #ifdef SHOW_COINCIDING_3D_PAL21924
385 for (int ai=0; ai<npts; ai++)
386 faceIdsTmp->InsertNextId(pts[ai]);
387 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
389 for (faceId = 0; faceId < 4; faceId++)
392 faceVerts = vtkTetra::GetFaceArray(faceId);
393 faceIds->InsertNextId(pts[faceVerts[0]]);
394 faceIds->InsertNextId(pts[faceVerts[1]]);
395 faceIds->InsertNextId(pts[faceVerts[2]]);
396 aCellType = VTK_TRIANGLE;
398 input->GetCellNeighbors(cellId, faceIds, cellIds);
399 #ifdef SHOW_COINCIDING_3D_PAL21924
401 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
402 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
404 bool process = nbNeighbors <= 0;
406 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
408 if ( process || myShowInside ||
409 (!allVisible && !cellVis[cellIds->GetId(0)]) )
411 for ( i=0; i < numFacePts; i++)
412 aNewPts[i] = pts[faceVerts[i]];
413 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
415 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
416 outputCD->CopyData(cd,cellId,newCellId);
422 #ifdef SHOW_COINCIDING_3D_PAL21924
424 for (int ai=0; ai<npts; ai++)
425 faceIdsTmp->InsertNextId(pts[ai]);
426 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
428 for (faceId = 0; faceId < 6; faceId++)
431 faceVerts = vtkVoxel::GetFaceArray(faceId);
432 faceIds->InsertNextId(pts[faceVerts[0]]);
433 faceIds->InsertNextId(pts[faceVerts[1]]);
434 faceIds->InsertNextId(pts[faceVerts[2]]);
435 faceIds->InsertNextId(pts[faceVerts[3]]);
436 aCellType = VTK_QUAD;
438 input->GetCellNeighbors(cellId, faceIds, cellIds);
439 #ifdef SHOW_COINCIDING_3D_PAL21924
441 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
442 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
444 bool process = nbNeighbors <= 0;
446 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
448 if ( process || myShowInside ||
449 (!allVisible && !cellVis[cellIds->GetId(0)]) )
451 for ( i=0; i < numFacePts; i++)
452 aNewPts[i] = pts[faceVerts[PixelConvert[i]]];
453 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
455 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
456 outputCD->CopyData(cd,cellId,newCellId);
461 case VTK_HEXAHEDRON: {
462 #ifdef SHOW_COINCIDING_3D_PAL21924
464 for (int ai=0; ai<npts; ai++)
465 faceIdsTmp->InsertNextId(pts[ai]);
466 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
468 for (faceId = 0; faceId < 6; faceId++)
471 faceVerts = vtkHexahedron::GetFaceArray(faceId);
472 faceIds->InsertNextId(pts[faceVerts[0]]);
473 faceIds->InsertNextId(pts[faceVerts[1]]);
474 faceIds->InsertNextId(pts[faceVerts[2]]);
475 faceIds->InsertNextId(pts[faceVerts[3]]);
476 aCellType = VTK_QUAD;
478 input->GetCellNeighbors(cellId, faceIds, cellIds);
479 #ifdef SHOW_COINCIDING_3D_PAL21924
481 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
482 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
484 bool process = nbNeighbors <= 0;
486 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
488 if ( process || myShowInside ||
489 (!allVisible && !cellVis[cellIds->GetId(0)]) )
491 for ( i=0; i < numFacePts; i++)
492 aNewPts[i] = pts[faceVerts[i]];
493 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
495 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
496 outputCD->CopyData(cd,cellId,newCellId);
502 #ifdef SHOW_COINCIDING_3D_PAL21924
504 for (int ai=0; ai<npts; ai++)
505 faceIdsTmp->InsertNextId(pts[ai]);
506 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
508 for (faceId = 0; faceId < 5; faceId++)
511 faceVerts = vtkWedge::GetFaceArray(faceId);
512 faceIds->InsertNextId(pts[faceVerts[0]]);
513 faceIds->InsertNextId(pts[faceVerts[1]]);
514 faceIds->InsertNextId(pts[faceVerts[2]]);
515 aCellType = VTK_TRIANGLE;
517 if (faceVerts[3] >= 0)
519 faceIds->InsertNextId(pts[faceVerts[3]]);
520 aCellType = VTK_QUAD;
524 input->GetCellNeighbors(cellId, faceIds, cellIds);
525 #ifdef SHOW_COINCIDING_3D_PAL21924
527 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
528 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
530 bool process = nbNeighbors <= 0;
532 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
534 if ( process || myShowInside ||
535 (!allVisible && !cellVis[cellIds->GetId(0)]) )
537 for ( i=0; i < numFacePts; i++)
538 aNewPts[i] = pts[faceVerts[i]];
539 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
541 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
542 outputCD->CopyData(cd,cellId,newCellId);
547 case VTK_HEXAGONAL_PRISM: {
548 #ifdef SHOW_COINCIDING_3D_PAL21924
550 for (int ai=0; ai<npts; ai++)
551 faceIdsTmp->InsertNextId(pts[ai]);
552 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
554 for (faceId = 0; faceId < 8; faceId++)
556 faceVerts = vtkHexagonalPrism::GetFaceArray(faceId);
558 faceIds->InsertNextId(pts[faceVerts[0]]);
559 faceIds->InsertNextId(pts[faceVerts[1]]);
560 faceIds->InsertNextId(pts[faceVerts[2]]);
561 faceIds->InsertNextId(pts[faceVerts[3]]);
562 aCellType = VTK_QUAD;
564 if (faceVerts[5] >= 0)
566 faceIds->InsertNextId(pts[faceVerts[4]]);
567 faceIds->InsertNextId(pts[faceVerts[5]]);
568 aCellType = VTK_POLYGON;
571 input->GetCellNeighbors(cellId, faceIds, cellIds);
572 #ifdef SHOW_COINCIDING_3D_PAL21924
574 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
575 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
577 bool process = nbNeighbors <= 0;
579 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
581 if ( process || myShowInside ||
582 (!allVisible && !cellVis[cellIds->GetId(0)]) )
584 for ( i=0; i < numFacePts; i++)
585 aNewPts[i] = pts[faceVerts[i]];
586 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
588 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
589 outputCD->CopyData(cd,cellId,newCellId);
595 #ifdef SHOW_COINCIDING_3D_PAL21924
597 for (int ai=0; ai<npts; ai++)
598 faceIdsTmp->InsertNextId(pts[ai]);
599 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
601 for (faceId = 0; faceId < 5; faceId++)
604 faceVerts = vtkPyramid::GetFaceArray(faceId);
605 faceIds->InsertNextId(pts[faceVerts[0]]);
606 faceIds->InsertNextId(pts[faceVerts[1]]);
607 faceIds->InsertNextId(pts[faceVerts[2]]);
608 aCellType = VTK_TRIANGLE;
610 if (faceVerts[3] >= 0)
612 faceIds->InsertNextId(pts[faceVerts[3]]);
613 aCellType = VTK_QUAD;
616 input->GetCellNeighbors(cellId, faceIds, cellIds);
617 #ifdef SHOW_COINCIDING_3D_PAL21924
619 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
620 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
622 bool process = nbNeighbors <= 0;
624 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
626 if ( process || myShowInside ||
627 (!allVisible && !cellVis[cellIds->GetId(0)]) )
629 for ( i=0; i < numFacePts; i++)
630 aNewPts[i] = pts[faceVerts[i]];
631 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
633 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
634 outputCD->CopyData(cd,cellId,newCellId);
640 #if VTK_XVERSION > 50700
643 //MESSAGE("VTK_POLYHEDRON geometry filter");
644 vtkIdType nFaces = 0;
645 vtkIdType* ptIds = 0;
647 input->GetFaceStream(cellId, nFaces, ptIds);
648 #ifdef SHOW_COINCIDING_3D_PAL21924
650 for (int ai=0; ai<npts; ai++)
651 faceIdsTmp->InsertNextId(pts[ai]);
652 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
654 for (faceId = 0; faceId < nFaces; faceId++)
657 numFacePts = ptIds[idp];
658 //MESSAGE("numFacePts="<< numFacePts);
660 for (i = 0; i < numFacePts; i++)
662 //MESSAGE("ptIds[" << idp + i << "]=" << ptIds[idp + i]);
663 faceIds->InsertNextId(ptIds[idp + i]);
669 aCellType = VTK_TRIANGLE;
672 aCellType = VTK_QUAD;
675 aCellType = VTK_POLYGON;
678 // TODO understand and fix display of several polyhedrons
679 input->GetCellNeighbors(cellId, faceIds, cellIds);
680 #ifdef SHOW_COINCIDING_3D_PAL21924
682 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
683 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
685 bool process = nbNeighbors <= 0;
687 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
689 if (process || myShowInside
690 || (!allVisible && !cellVis[cellIds->GetId(0)]))
692 for (i = 0; i < numFacePts; i++)
693 aNewPts[i] = ptIds[pt0 + i];
694 newCellId = output->InsertNextCell(aCellType, numFacePts, aNewPts);
696 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
697 outputCD->CopyData(cd, cellId, newCellId);
704 case VTK_QUADRATIC_EDGE:
705 case VTK_QUADRATIC_TRIANGLE:
706 case VTK_BIQUADRATIC_TRIANGLE:
707 case VTK_QUADRATIC_QUAD:
708 case VTK_BIQUADRATIC_QUAD:
709 case VTK_QUADRATIC_POLYGON:
710 case VTK_QUADRATIC_TETRA:
711 case VTK_QUADRATIC_HEXAHEDRON:
712 case VTK_TRIQUADRATIC_HEXAHEDRON:
713 case VTK_QUADRATIC_WEDGE:
714 case VTK_QUADRATIC_PYRAMID:
715 if(!myIsWireframeMode) {
716 input->GetCell(cellId,cell);
717 vtkIdList *lpts = vtkIdList::New();
718 vtkPoints *coords = vtkPoints::New();
719 vtkIdList *cellIds = vtkIdList::New();
722 if ( cell->GetCellDimension() == 1 ) {
723 vtkIdType arcResult = -1;
725 arcResult = Build1DArc(cellId, input, output, pts, myMaxArcAngle);
726 newCellId = arcResult;
729 if(!myIsBuildArc || arcResult == -1 ) {
730 aCellType = VTK_LINE;
732 cell->Triangulate(0,lpts,coords);
733 for (i=0; i < lpts->GetNumberOfIds(); i+=2) {
734 aNewPts[0] = lpts->GetId(i);
735 aNewPts[1] = lpts->GetId(i+1);
736 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
738 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
739 outputCD->CopyData(cd,cellId,newCellId);
744 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
745 outputCD->CopyData(cd,cellId,newCellId);
748 else if ( cell->GetCellDimension() == 2 ) {
750 aCellType = VTK_TRIANGLE;
752 cell->Triangulate(0,lpts,coords);
753 for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
754 aNewPts[0] = lpts->GetId(i);
755 aNewPts[1] = lpts->GetId(i+1);
756 aNewPts[2] = lpts->GetId(i+2);
757 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
759 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
760 outputCD->CopyData(cd,cellId,newCellId);
764 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds,true);
767 else //3D nonlinear cell
769 #ifdef SHOW_COINCIDING_3D_PAL21924
773 case VTK_QUADRATIC_TETRA: npts1 = 4; break;
774 case VTK_QUADRATIC_HEXAHEDRON: npts1 = 8; break;
775 case VTK_TRIQUADRATIC_HEXAHEDRON: npts1 = 8; break;
776 case VTK_QUADRATIC_WEDGE: npts1 = 6; break;
777 case VTK_QUADRATIC_PYRAMID: npts1 = 5; break;
780 for (int ai=0; ai<npts; ai++)
781 faceIdsTmp->InsertNextId(pts[ai]);
782 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
785 aCellType = VTK_TRIANGLE;
787 for (int j=0; j < cell->GetNumberOfFaces(); j++){
788 vtkCell *face = cell->GetFace(j);
789 input->GetCellNeighbors(cellId, face->PointIds, cellIds);
790 #ifdef SHOW_COINCIDING_3D_PAL21924
792 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
793 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
795 bool process = nbNeighbors <= 0;
797 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
799 if ( process || myShowInside ) {
800 face->Triangulate(0,lpts,coords);
801 for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
802 aNewPts[0] = lpts->GetId(i);
803 aNewPts[1] = lpts->GetId(i+1);
804 aNewPts[2] = lpts->GetId(i+2);
805 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
807 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
808 outputCD->CopyData(cd,cellId,newCellId);
812 } //3d nonlinear cell
817 } else { // wireframe
819 case VTK_QUADRATIC_EDGE: {
820 vtkIdType arcResult =-1;
822 arcResult = Build1DArc(cellId, input, output, pts,myMaxArcAngle);
823 newCellId = arcResult;
825 if(!myIsBuildArc || arcResult == -1) {
826 aCellType = VTK_POLY_LINE;
833 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
837 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
839 outputCD->CopyData(cd,cellId,newCellId);
842 case VTK_QUADRATIC_TRIANGLE:
843 case VTK_BIQUADRATIC_TRIANGLE: {
845 aCellType = VTK_POLYGON;
855 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
857 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
859 outputCD->CopyData(cd,cellId,newCellId);
862 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds);
865 case VTK_QUADRATIC_QUAD:
866 case VTK_BIQUADRATIC_QUAD: {
868 aCellType = VTK_POLYGON;
880 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
882 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
884 outputCD->CopyData(cd,cellId,newCellId);
887 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds);
890 case VTK_QUADRATIC_POLYGON: {
893 aCellType = VTK_POLYGON;
895 for ( i = 0; i < npts/2; ++i )
897 aNewPts[i*2 ] = pts[i];
898 aNewPts[i*2+1] = pts[i+npts/2];
900 newCellId = output->InsertNextCell(aCellType,npts,aNewPts);
902 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
904 outputCD->CopyData(cd,cellId,newCellId);
907 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds);
910 case VTK_QUADRATIC_TETRA: {
911 aCellType = VTK_POLYGON;
914 //---------------------------------------------------------------
922 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
924 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
926 outputCD->CopyData(cd,cellId,newCellId);
928 //---------------------------------------------------------------
936 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
938 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
940 outputCD->CopyData(cd,cellId,newCellId);
942 //---------------------------------------------------------------
950 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
952 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
954 outputCD->CopyData(cd,cellId,newCellId);
956 //---------------------------------------------------------------
964 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
966 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
968 outputCD->CopyData(cd,cellId,newCellId);
972 case VTK_QUADRATIC_WEDGE: {
973 aCellType = VTK_POLYGON;
975 //---------------------------------------------------------------
983 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
985 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
986 outputCD->CopyData(cd,cellId,newCellId);
988 //---------------------------------------------------------------
993 aNewPts[3] = pts[10];
995 aNewPts[5] = pts[11];
996 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
998 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
999 outputCD->CopyData(cd,cellId,newCellId);
1001 //---------------------------------------------------------------
1004 aNewPts[0] = pts[0];
1005 aNewPts[1] = pts[8];
1006 aNewPts[2] = pts[2];
1007 aNewPts[3] = pts[14];
1008 aNewPts[4] = pts[5];
1009 aNewPts[5] = pts[11];
1010 aNewPts[6] = pts[3];
1011 aNewPts[7] = pts[12];
1012 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1014 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1015 outputCD->CopyData(cd,cellId,newCellId);
1017 //---------------------------------------------------------------
1019 aNewPts[0] = pts[1];
1020 aNewPts[1] = pts[13];
1021 aNewPts[2] = pts[4];
1022 aNewPts[3] = pts[10];
1023 aNewPts[4] = pts[5];
1024 aNewPts[5] = pts[14];
1025 aNewPts[6] = pts[2];
1026 aNewPts[7] = pts[7];
1027 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1029 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1030 outputCD->CopyData(cd,cellId,newCellId);
1032 //---------------------------------------------------------------
1034 aNewPts[0] = pts[0];
1035 aNewPts[1] = pts[12];
1036 aNewPts[2] = pts[3];
1037 aNewPts[3] = pts[9];
1038 aNewPts[4] = pts[4];
1039 aNewPts[5] = pts[13];
1040 aNewPts[6] = pts[1];
1041 aNewPts[7] = pts[6];
1042 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1044 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1045 outputCD->CopyData(cd,cellId,newCellId);
1048 case VTK_TRIQUADRATIC_HEXAHEDRON:
1049 case VTK_QUADRATIC_HEXAHEDRON: {
1050 aCellType = VTK_POLYGON;
1053 //---------------------------------------------------------------
1054 aNewPts[0] = pts[0];
1055 aNewPts[1] = pts[8];
1056 aNewPts[2] = pts[1];
1057 aNewPts[3] = pts[17];
1058 aNewPts[4] = pts[5];
1059 aNewPts[5] = pts[12];
1060 aNewPts[6] = pts[4];
1061 aNewPts[7] = pts[16];
1063 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1065 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1067 outputCD->CopyData(cd,cellId,newCellId);
1069 //---------------------------------------------------------------
1070 aNewPts[0] = pts[1];
1071 aNewPts[1] = pts[9];
1072 aNewPts[2] = pts[2];
1073 aNewPts[3] = pts[18];
1074 aNewPts[4] = pts[6];
1075 aNewPts[5] = pts[13];
1076 aNewPts[6] = pts[5];
1077 aNewPts[7] = pts[17];
1079 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1081 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1083 outputCD->CopyData(cd,cellId,newCellId);
1085 //---------------------------------------------------------------
1086 aNewPts[0] = pts[2];
1087 aNewPts[1] = pts[10];
1088 aNewPts[2] = pts[3];
1089 aNewPts[3] = pts[19];
1090 aNewPts[4] = pts[7];
1091 aNewPts[5] = pts[14];
1092 aNewPts[6] = pts[6];
1093 aNewPts[7] = pts[18];
1095 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1097 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1099 outputCD->CopyData(cd,cellId,newCellId);
1101 //---------------------------------------------------------------
1102 aNewPts[0] = pts[3];
1103 aNewPts[1] = pts[11];
1104 aNewPts[2] = pts[0];
1105 aNewPts[3] = pts[16];
1106 aNewPts[4] = pts[4];
1107 aNewPts[5] = pts[15];
1108 aNewPts[6] = pts[7];
1109 aNewPts[7] = pts[19];
1111 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1113 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1115 outputCD->CopyData(cd,cellId,newCellId);
1117 //---------------------------------------------------------------
1118 aNewPts[0] = pts[0];
1119 aNewPts[1] = pts[8];
1120 aNewPts[2] = pts[1];
1121 aNewPts[3] = pts[9];
1122 aNewPts[4] = pts[2];
1123 aNewPts[5] = pts[10];
1124 aNewPts[6] = pts[3];
1125 aNewPts[7] = pts[11];
1127 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1129 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1131 outputCD->CopyData(cd,cellId,newCellId);
1133 //---------------------------------------------------------------
1134 aNewPts[0] = pts[4];
1135 aNewPts[1] = pts[12];
1136 aNewPts[2] = pts[5];
1137 aNewPts[3] = pts[13];
1138 aNewPts[4] = pts[6];
1139 aNewPts[5] = pts[14];
1140 aNewPts[6] = pts[7];
1141 aNewPts[7] = pts[15];
1143 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1145 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1147 outputCD->CopyData(cd,cellId,newCellId);
1151 case VTK_QUADRATIC_PYRAMID: {
1152 aCellType = VTK_POLYGON;
1155 //---------------------------------------------------------------
1156 aNewPts[0] = pts[0];
1157 aNewPts[1] = pts[8];
1158 aNewPts[2] = pts[3];
1159 aNewPts[3] = pts[12];
1160 aNewPts[4] = pts[4];
1161 aNewPts[5] = pts[9];
1163 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1165 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1167 outputCD->CopyData(cd,cellId,newCellId);
1169 //---------------------------------------------------------------
1170 aNewPts[0] = pts[0];
1171 aNewPts[1] = pts[9];
1172 aNewPts[2] = pts[4];
1173 aNewPts[3] = pts[10];
1174 aNewPts[4] = pts[1];
1175 aNewPts[5] = pts[5];
1177 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1179 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1181 outputCD->CopyData(cd,cellId,newCellId);
1183 //---------------------------------------------------------------
1184 aNewPts[0] = pts[1];
1185 aNewPts[1] = pts[10];
1186 aNewPts[2] = pts[4];
1187 aNewPts[3] = pts[11];
1188 aNewPts[4] = pts[2];
1189 aNewPts[5] = pts[6];
1191 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1193 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1195 outputCD->CopyData(cd,cellId,newCellId);
1197 //---------------------------------------------------------------
1198 aNewPts[0] = pts[2];
1199 aNewPts[1] = pts[11];
1200 aNewPts[2] = pts[4];
1201 aNewPts[3] = pts[12];
1202 aNewPts[4] = pts[3];
1203 aNewPts[5] = pts[7];
1205 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1207 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1209 outputCD->CopyData(cd,cellId,newCellId);
1211 //---------------------------------------------------------------
1213 aNewPts[0] = pts[0];
1214 aNewPts[1] = pts[5];
1215 aNewPts[2] = pts[1];
1216 aNewPts[3] = pts[6];
1217 aNewPts[4] = pts[2];
1218 aNewPts[5] = pts[7];
1219 aNewPts[6] = pts[3];
1220 aNewPts[7] = pts[8];
1222 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1224 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1226 outputCD->CopyData(cd,cellId,newCellId);
1229 } // case VTK_QUADRATIC_PYRAMID:
1239 vtkDebugMacro(<<"Extracted " << input->GetNumberOfPoints() << " points,"
1240 << output->GetNumberOfCells() << " cells.");
1246 cellIdsTmp->Delete();
1247 faceIdsTmp->Delete();
1254 // to sort myVTK2ObjIds vector by cell dimension (ascending)
1255 if( myStoreMapping && !aDimension2VTK2ObjIds.empty() )
1257 myVTK2ObjIds.clear();
1258 for( vtkIdType aDimension = 0; aDimension <= 2; aDimension++ )
1260 TMapOfVectorId::const_iterator anIter = aDimension2VTK2ObjIds.find( aDimension );
1261 if( anIter != aDimension2VTK2ObjIds.end() )
1263 const TVectorId& aCellIds = anIter->second;
1264 TVectorId::const_iterator anIdIter, anIdIterEnd = aCellIds.end();
1265 for( anIdIter = aCellIds.begin(); anIdIter != anIdIterEnd; anIdIter++ )
1267 const vtkIdType aCellId = *anIdIter;
1268 myVTK2ObjIds.push_back( aCellId );
1278 VTKViewer_GeometryFilter
1279 ::InsertId( const vtkIdType theCellId,
1280 const vtkIdType theCellType,
1281 TVectorId& theVTK2ObjIds,
1282 TMapOfVectorId& theDimension2VTK2ObjIds )
1284 theVTK2ObjIds.push_back( theCellId );
1287 switch( theCellType )
1290 case VTK_POLY_VERTEX:
1298 case VTK_TRIANGLE_STRIP:
1306 TVectorId& aCellIds = theDimension2VTK2ObjIds[ aDimension ];
1307 aCellIds.push_back( theCellId );
1311 VTKViewer_GeometryFilter
1312 ::SetInside(int theShowInside)
1314 if(myShowInside == theShowInside)
1317 myShowInside = theShowInside;
1322 VTKViewer_GeometryFilter
1325 return myShowInside;
1330 VTKViewer_GeometryFilter
1331 ::SetWireframeMode(int theIsWireframeMode)
1333 if(myIsWireframeMode == theIsWireframeMode)
1336 myIsWireframeMode = theIsWireframeMode;
1341 VTKViewer_GeometryFilter
1342 ::GetWireframeMode()
1344 return myIsWireframeMode;
1349 VTKViewer_GeometryFilter
1350 ::SetStoreMapping(int theStoreMapping)
1352 if(myStoreMapping == theStoreMapping)
1355 myStoreMapping = theStoreMapping;
1360 VTKViewer_GeometryFilter
1363 return myStoreMapping;
1367 vtkIdType VTKViewer_GeometryFilter::GetElemObjId( int theVtkID )
1369 if( theVtkID < 0 || theVtkID >= (int)myVTK2ObjIds.size() )
1371 return myVTK2ObjIds[theVtkID];
1375 void VTKViewer_GeometryFilter::BuildArcedPolygon(vtkIdType cellId,
1376 vtkUnstructuredGrid* input,
1377 vtkPolyData *output,
1378 TMapOfVectorId& theDimension2VTK2ObjIds,
1381 vtkIdType aCellType = VTK_POLYGON;
1382 vtkIdType *aNewPoints = NULL;
1383 vtkIdType aNbPoints = 0;
1384 vtkIdType newCellId;
1386 //Input and output cell data
1387 vtkCellData *cd = input->GetCellData();
1388 vtkCellData *outputCD = output->GetCellData();
1390 //Input and output scalars on point data
1391 vtkDataArray* inputScalars = input->GetPointData()->GetScalars();
1392 vtkDataArray* outputScalars = output->GetPointData()->GetScalars();
1394 std::vector< vtkSmartPointer<vtkPoints> > aCollection;
1395 std::vector< std::vector<double> > aScalarCollection;
1397 vtkCell* aCell = input->GetCell(cellId);
1398 switch(aCell->GetCellType()) {
1399 case VTK_QUADRATIC_TRIANGLE:
1400 case VTK_BIQUADRATIC_TRIANGLE:
1402 //Get All points from input cell
1403 Pnt P0 = CreatePnt( aCell, inputScalars, 0 );
1404 Pnt P1 = CreatePnt( aCell, inputScalars, 1 );
1405 Pnt P2 = CreatePnt( aCell, inputScalars, 2 );
1406 Pnt P3 = CreatePnt( aCell, inputScalars, 3 );
1407 Pnt P4 = CreatePnt( aCell, inputScalars, 4 );
1408 Pnt P5 = CreatePnt( aCell, inputScalars, 5 );
1410 VTKViewer_ArcBuilder aBuilder1(P0,P3,P1,myMaxArcAngle); //Build arc using 0, 3 and 1 points
1412 cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1415 VTKViewer_ArcBuilder aBuilder2(P1,P4,P2,myMaxArcAngle); //Build arc using 1, 4 and 2 points
1417 cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1420 VTKViewer_ArcBuilder aBuilder3(P2,P5,P0,myMaxArcAngle); //Build arc using 2, 5 and 0 points
1422 cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1425 aCollection.push_back(aBuilder1.GetPoints());
1426 aCollection.push_back(aBuilder2.GetPoints());
1427 aCollection.push_back(aBuilder3.GetPoints());
1429 aScalarCollection.push_back(aBuilder1.GetScalarValues());
1430 aScalarCollection.push_back(aBuilder2.GetScalarValues());
1431 aScalarCollection.push_back(aBuilder3.GetScalarValues());
1434 case VTK_QUADRATIC_QUAD:
1435 case VTK_BIQUADRATIC_QUAD:
1437 //Get All points from input cell
1438 Pnt P0 = CreatePnt( aCell, inputScalars, 0 );
1439 Pnt P1 = CreatePnt( aCell, inputScalars, 1 );
1440 Pnt P2 = CreatePnt( aCell, inputScalars, 2 );
1441 Pnt P3 = CreatePnt( aCell, inputScalars, 3 );
1442 Pnt P4 = CreatePnt( aCell, inputScalars, 4 );
1443 Pnt P5 = CreatePnt( aCell, inputScalars, 5 );
1444 Pnt P6 = CreatePnt( aCell, inputScalars, 6 );
1445 Pnt P7 = CreatePnt( aCell, inputScalars, 7 );
1447 VTKViewer_ArcBuilder aBuilder1(P0,P4,P1,myMaxArcAngle); //Build arc using 0, 4 and 1 points
1449 cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1452 VTKViewer_ArcBuilder aBuilder2(P1,P5,P2,myMaxArcAngle); //Build arc using 1, 5 and 2 points
1454 cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1457 VTKViewer_ArcBuilder aBuilder3(P2,P6,P3,myMaxArcAngle); //Build arc using 2, 6 and 3 points
1459 cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1462 VTKViewer_ArcBuilder aBuilder4(P3,P7,P0,myMaxArcAngle); //Build arc using 3, 7 and 0 points
1464 cout << "Quadrangle arc 4 " << ( aBuilder4.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1467 aCollection.push_back(aBuilder1.GetPoints());
1468 aCollection.push_back(aBuilder2.GetPoints());
1469 aCollection.push_back(aBuilder3.GetPoints());
1470 aCollection.push_back(aBuilder4.GetPoints());
1472 aScalarCollection.push_back(aBuilder1.GetScalarValues());
1473 aScalarCollection.push_back(aBuilder2.GetScalarValues());
1474 aScalarCollection.push_back(aBuilder3.GetScalarValues());
1475 aScalarCollection.push_back(aBuilder4.GetScalarValues());
1478 case VTK_QUADRATIC_POLYGON:
1480 int nbP = aCell->GetNumberOfPoints();
1481 std::vector< Pnt > pVec( nbP + 2 );
1483 for ( int i = 0; i < nbP/2; ++i )
1485 pVec[i*2 + 0] = CreatePnt( aCell, inputScalars, i );
1486 pVec[i*2 + 1] = CreatePnt( aCell, inputScalars, i + nbP/2 );
1488 pVec[ nbP ] = pVec[ 0 ];
1489 pVec[ nbP+1 ] = pVec[ 1 ];
1491 for ( int i = 0; i < nbP; i += 2 )
1493 VTKViewer_ArcBuilder aBuilder( pVec[i], pVec[i+1], pVec[i+2], myMaxArcAngle );
1494 aCollection.push_back( aBuilder.GetPoints() );
1495 aScalarCollection.push_back( aBuilder.GetScalarValues() );
1499 default: //Unsupported cell type
1504 const vtkIdType numFacePts = 3;
1505 vtkIdList *pts = vtkIdList::New();
1506 vtkPoints *coords = vtkPoints::New();
1507 aCellType = VTK_TRIANGLE;
1508 vtkIdType aNewPts[numFacePts];
1509 vtkIdType aTriangleId;
1511 vtkPolygon *aPlg = vtkPolygon::New();
1512 std::map<int, double> aPntId2ScalarValue;
1513 aNbPoints = MergevtkPoints(aCollection, aScalarCollection, aPlg->GetPoints(), aPntId2ScalarValue, aNewPoints);
1514 aPlg->GetPointIds()->SetNumberOfIds(aNbPoints);
1516 for(vtkIdType i = 0; i < aNbPoints;i++) {
1517 aPlg->GetPointIds()->SetId(i, aNewPoints[i]);
1520 aPlg->Triangulate(0,pts,coords);
1522 for (vtkIdType i=0; i < pts->GetNumberOfIds(); i+=3) {
1523 aNewPts[0] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i));
1524 aNewPts[1] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+1));
1525 aNewPts[2] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+2));
1528 outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i)]);
1529 outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+1)]);
1530 outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+2)]);
1533 aTriangleId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1536 InsertId( cellId, aCellType, myVTK2ObjIds, theDimension2VTK2ObjIds );
1537 outputCD->CopyData(cd,cellId,aTriangleId);
1544 std::map<int, double> aPntId2ScalarValue;
1545 aNbPoints = MergevtkPoints(aCollection, aScalarCollection, output->GetPoints(), aPntId2ScalarValue, aNewPoints);
1547 for(vtkIdType i = 0; i < aNbPoints; i++)
1548 outputScalars->InsertNextTuple1(aPntId2ScalarValue[aNewPoints[i]]);
1549 newCellId = output->InsertNextCell(aCellType,aNbPoints,aNewPoints);
1550 outputCD->CopyData(cd,cellId,newCellId);
1553 InsertId( cellId, aCellType, myVTK2ObjIds, theDimension2VTK2ObjIds );
1557 delete [] aNewPoints;
1561 void VTKViewer_GeometryFilter::SetQuadraticArcMode(bool theFlag)
1563 if(myIsBuildArc != theFlag) {
1564 myIsBuildArc = theFlag;
1568 bool VTKViewer_GeometryFilter::GetQuadraticArcMode() const
1570 return myIsBuildArc;
1573 void VTKViewer_GeometryFilter::SetQuadraticArcAngle(double theMaxAngle)
1575 if(myMaxArcAngle != theMaxAngle) {
1576 myMaxArcAngle = theMaxAngle;
1581 double VTKViewer_GeometryFilter:: GetQuadraticArcAngle() const
1583 return myMaxArcAngle;
1586 int VTKViewer_GeometryFilter::GetAppendCoincident3D() const {
1587 // VSR 26/10/2012: see description of SHOW_COINCIDING_3D_PAL20314
1588 // in the top of this file
1589 #ifdef SHOW_COINCIDING_3D_PAL20314
1590 return myAppendCoincident3D;
1596 void VTKViewer_GeometryFilter::SetAppendCoincident3D(int theFlag) {
1597 if(myAppendCoincident3D != theFlag){
1598 myAppendCoincident3D = theFlag;