1 // Copyright (C) 2007-2012 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.
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>
58 #include "utilities.h"
66 #define VTK_XVERSION (VTK_MAJOR_VERSION*10000+VTK_MINOR_VERSION*100+VTK_BUILD_VERSION)
69 //#define USE_ROBUST_TRIANGULATION
71 ///////////////////////////////////////////////////////////////////////////////////////////////
72 // VSR 26/10/2012: fix of regression (issue 21924) - increased memory consumption
73 // for displaying of 3d elements, introduced by fix for issue 20314.
75 // The macro SHOW_COINCIDING_3D_PAL20314, when defined, allows correct visualization of
76 // coincident 3d elements but causes substantial increasing of memory consumption, as all 3d
77 // elements are always shown, even if they are totally covered by surrounding faces.
78 // If this macro is not defined (commented), the behaviour is defined by another macro -
79 // SHOW_COINCIDING_3D_PAL21924, as follows:
80 // - If SHOW_COINCIDING_3D_PAL21924 is defined, an alternative solution for computing
81 // visibility of 3d elements is used; this solution allows to fix problem with visibility
82 // of coinciding 3d elements in most cases (though some cases might not work), while not
83 // causing significant increasing of memory consumption.
84 // - If SHOW_COINCIDING_3D_PAL21924 is not defined (commented), coinciding 3d elements are
85 // not shown at all (this corresponds to the state before issue 20314 fixing).
86 ///////////////////////////////////////////////////////////////////////////////////////////////
87 //#define SHOW_COINCIDING_3D_PAL20314
88 #ifndef SHOW_COINCIDING_3D_PAL20314
89 #define SHOW_COINCIDING_3D_PAL21924
91 ///////////////////////////////////////////////////////////////////////////////////////////////
93 vtkCxxRevisionMacro(VTKViewer_GeometryFilter, "$Revision$");
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(
148 vtkDataSet *dataSetInput,
150 vtkInformation *outInfo)
153 vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)dataSetInput;
154 vtkCellArray *Connectivity = input->GetCells();
156 if ( Connectivity == NULL )
158 vtkDebugMacro(<<"Nothing to extract");
167 vtkPoints *p = input->GetPoints();
168 vtkIdType numCells=input->GetNumberOfCells();
169 vtkPointData *pd = input->GetPointData();
170 vtkCellData *cd = input->GetCellData();
171 vtkPointData *outputPD = output->GetPointData();
173 VTKViewer_OrderedTriangulator anOrderedTriangulator;
174 VTKViewer_DelaunayTriangulator aDelaunayTriangulator;
176 vtkCellData *outputCD = output->GetCellData();
177 vtkGenericCell *cell = vtkGenericCell::New();
179 vtkIdList *cellIds = vtkIdList::New();
180 vtkIdList *faceIds = vtkIdList::New();
181 vtkIdList *cellIdsTmp = vtkIdList::New();
182 vtkIdList *faceIdsTmp = vtkIdList::New();
186 int faceId, *faceVerts, numFacePts;
187 vtkFloatingPointType *x;
188 vtkIdType PixelConvert[4];
189 // Change the type from int to vtkIdType in order to avoid compilation errors while using VTK
190 // from ParaView-3.4.0 compiled on 64-bit Debian platform with VTK_USE_64BIT_IDS = ON
191 vtkIdType aNewPts[VTK_CELL_SIZE];
193 unsigned char updateLevel = (unsigned char)(output->GetUpdateGhostLevel());
194 unsigned char *cellGhostLevels = 0;
201 vtkDebugMacro(<<"Executing geometry filter for unstructured grid input");
203 vtkDataArray* temp = 0;
206 temp = cd->GetArray("vtkGhostLevels");
208 if ( (!temp) || (temp->GetDataType() != VTK_UNSIGNED_CHAR)
209 || (temp->GetNumberOfComponents() != 1))
211 vtkDebugMacro("No appropriate ghost levels field available.");
215 cellGhostLevels = ((vtkUnsignedCharArray*)temp)->GetPointer(0);
218 // Determine nature of what we have to do
219 if ( (!this->CellClipping) && (!this->PointClipping) &&
220 (!this->ExtentClipping) )
228 cellVis = new char[numCells];
231 // Issue 0020115: [CEA 308] Quadratic elements visualization
232 // Fix of remark described in note 0005222 - SIGSEGV
233 vtkPoints* outputPoints = vtkPoints::New();
234 outputPoints->DeepCopy(input->GetPoints());
235 output->SetPoints(outputPoints);
236 outputPoints->Delete();
238 outputPD->PassData(pd);
240 outputCD->CopyAllocate(cd,numCells,numCells/2);
242 output->Allocate(numCells/4+1,numCells);
244 // Loop over the cells determining what's visible
247 for (cellId=0, Connectivity->InitTraversal();
248 Connectivity->GetNextCell(npts,pts);
252 if ( ( this->CellClipping && cellId < this->CellMinimum ) ||
253 cellId > this->CellMaximum )
259 for (i=0; i < npts; i++)
261 x = p->GetPoint(pts[i]);
262 if ( ( ( ( this->PointClipping && (pts[i] < this->PointMinimum ) ) ||
263 pts[i] > this->PointMaximum) ) ||
264 ( this->ExtentClipping &&
265 ( x[0] < this->Extent[0] || x[0] > this->Extent[1] ||
266 x[1] < this->Extent[2] || x[1] > this->Extent[3] ||
267 x[2] < this->Extent[4] || x[2] > this->Extent[5] )) )
271 }//point/extent clipping
273 }//if point clipping needs checking
275 }//if not all visible
277 // Loop over all cells now that visibility is known
278 // (Have to compute visibility first for 3D cell boundarys)
279 int progressInterval = numCells/20 + 1;
280 TMapOfVectorId aDimension2VTK2ObjIds;
282 myVTK2ObjIds.clear();
283 myVTK2ObjIds.reserve(numCells);
285 for (cellId=0, Connectivity->InitTraversal();
286 Connectivity->GetNextCell(npts,pts);
289 //Progress and abort method support
290 if ( !(cellId % progressInterval) )
292 vtkDebugMacro(<<"Process cell #" << cellId);
293 this->UpdateProgress ((float)cellId/numCells);
296 // Handle ghost cells here. Another option was used cellVis array.
297 if (cellGhostLevels && cellGhostLevels[cellId] > updateLevel)
298 { // Do not create surfaces in outer ghost cells.
302 if (allVisible || cellVis[cellId]) //now if visible extract geometry
304 //special code for nonlinear cells - rarely occurs, so right now it
306 vtkIdType aCellType = input->GetCellType(cellId);
313 case VTK_POLY_VERTEX:
314 newCellId = output->InsertNextCell(aCellType,npts,pts);
316 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
318 outputCD->CopyData(cd,cellId,newCellId);
323 newCellId = output->InsertNextCell(aCellType,npts,pts);
325 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
326 outputCD->CopyData(cd,cellId,newCellId);
332 newCellId = output->InsertNextCell(aCellType,npts,pts);
334 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
335 outputCD->CopyData(cd,cellId,newCellId);
338 case VTK_TRIANGLE_STRIP:
339 newCellId = output->InsertNextCell(aCellType,npts,pts);
341 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
342 outputCD->CopyData(cd,cellId,newCellId);
346 newCellId = output->InsertNextCell(aCellType,npts,pts);
348 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
349 outputCD->CopyData(cd,cellId,newCellId);
352 case VTK_CONVEX_POINT_SET: {
353 bool anIsOk = anOrderedTriangulator.Execute(input,
358 GetAppendCoincident3D(),
364 aDimension2VTK2ObjIds,
367 aDelaunayTriangulator.Execute(input,
372 GetAppendCoincident3D(),
378 aDimension2VTK2ObjIds,
384 #ifdef SHOW_COINCIDING_3D_PAL21924
386 for (int ai=0; ai<npts; ai++)
387 faceIdsTmp->InsertNextId(pts[ai]);
388 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
390 for (faceId = 0; faceId < 4; faceId++)
393 faceVerts = vtkTetra::GetFaceArray(faceId);
394 faceIds->InsertNextId(pts[faceVerts[0]]);
395 faceIds->InsertNextId(pts[faceVerts[1]]);
396 faceIds->InsertNextId(pts[faceVerts[2]]);
397 aCellType = VTK_TRIANGLE;
399 input->GetCellNeighbors(cellId, faceIds, cellIds);
400 #ifdef SHOW_COINCIDING_3D_PAL21924
402 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
403 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
405 bool process = nbNeighbors <= 0;
407 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
409 if ( process || myShowInside ||
410 (!allVisible && !cellVis[cellIds->GetId(0)]) )
412 for ( i=0; i < numFacePts; i++)
413 aNewPts[i] = pts[faceVerts[i]];
414 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
416 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
417 outputCD->CopyData(cd,cellId,newCellId);
423 #ifdef SHOW_COINCIDING_3D_PAL21924
425 for (int ai=0; ai<npts; ai++)
426 faceIdsTmp->InsertNextId(pts[ai]);
427 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
429 for (faceId = 0; faceId < 6; faceId++)
432 faceVerts = vtkVoxel::GetFaceArray(faceId);
433 faceIds->InsertNextId(pts[faceVerts[0]]);
434 faceIds->InsertNextId(pts[faceVerts[1]]);
435 faceIds->InsertNextId(pts[faceVerts[2]]);
436 faceIds->InsertNextId(pts[faceVerts[3]]);
437 aCellType = VTK_QUAD;
439 input->GetCellNeighbors(cellId, faceIds, cellIds);
440 #ifdef SHOW_COINCIDING_3D_PAL21924
442 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
443 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
445 bool process = nbNeighbors <= 0;
447 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
449 if ( process || myShowInside ||
450 (!allVisible && !cellVis[cellIds->GetId(0)]) )
452 for ( i=0; i < numFacePts; i++)
453 aNewPts[i] = pts[faceVerts[PixelConvert[i]]];
454 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
456 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
457 outputCD->CopyData(cd,cellId,newCellId);
462 case VTK_HEXAHEDRON: {
463 #ifdef SHOW_COINCIDING_3D_PAL21924
465 for (int ai=0; ai<npts; ai++)
466 faceIdsTmp->InsertNextId(pts[ai]);
467 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
469 for (faceId = 0; faceId < 6; faceId++)
472 faceVerts = vtkHexahedron::GetFaceArray(faceId);
473 faceIds->InsertNextId(pts[faceVerts[0]]);
474 faceIds->InsertNextId(pts[faceVerts[1]]);
475 faceIds->InsertNextId(pts[faceVerts[2]]);
476 faceIds->InsertNextId(pts[faceVerts[3]]);
477 aCellType = VTK_QUAD;
479 input->GetCellNeighbors(cellId, faceIds, cellIds);
480 #ifdef SHOW_COINCIDING_3D_PAL21924
482 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
483 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
485 bool process = nbNeighbors <= 0;
487 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
489 if ( process || myShowInside ||
490 (!allVisible && !cellVis[cellIds->GetId(0)]) )
492 for ( i=0; i < numFacePts; i++)
493 aNewPts[i] = pts[faceVerts[i]];
494 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
496 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
497 outputCD->CopyData(cd,cellId,newCellId);
503 #ifdef SHOW_COINCIDING_3D_PAL21924
505 for (int ai=0; ai<npts; ai++)
506 faceIdsTmp->InsertNextId(pts[ai]);
507 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
509 for (faceId = 0; faceId < 5; faceId++)
512 faceVerts = vtkWedge::GetFaceArray(faceId);
513 faceIds->InsertNextId(pts[faceVerts[0]]);
514 faceIds->InsertNextId(pts[faceVerts[1]]);
515 faceIds->InsertNextId(pts[faceVerts[2]]);
516 aCellType = VTK_TRIANGLE;
518 if (faceVerts[3] >= 0)
520 faceIds->InsertNextId(pts[faceVerts[3]]);
521 aCellType = VTK_QUAD;
525 input->GetCellNeighbors(cellId, faceIds, cellIds);
526 #ifdef SHOW_COINCIDING_3D_PAL21924
528 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
529 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
531 bool process = nbNeighbors <= 0;
533 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
535 if ( process || myShowInside ||
536 (!allVisible && !cellVis[cellIds->GetId(0)]) )
538 for ( i=0; i < numFacePts; i++)
539 aNewPts[i] = pts[faceVerts[i]];
540 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
542 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
543 outputCD->CopyData(cd,cellId,newCellId);
548 case VTK_HEXAGONAL_PRISM: {
549 #ifdef SHOW_COINCIDING_3D_PAL21924
551 for (int ai=0; ai<npts; ai++)
552 faceIdsTmp->InsertNextId(pts[ai]);
553 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
555 for (faceId = 0; faceId < 8; faceId++)
557 faceVerts = vtkHexagonalPrism::GetFaceArray(faceId);
559 faceIds->InsertNextId(pts[faceVerts[0]]);
560 faceIds->InsertNextId(pts[faceVerts[1]]);
561 faceIds->InsertNextId(pts[faceVerts[2]]);
562 faceIds->InsertNextId(pts[faceVerts[3]]);
563 aCellType = VTK_QUAD;
565 if (faceVerts[5] >= 0)
567 faceIds->InsertNextId(pts[faceVerts[4]]);
568 faceIds->InsertNextId(pts[faceVerts[5]]);
569 aCellType = VTK_POLYGON;
572 input->GetCellNeighbors(cellId, faceIds, cellIds);
573 #ifdef SHOW_COINCIDING_3D_PAL21924
575 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
576 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
578 bool process = nbNeighbors <= 0;
580 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
582 if ( process || myShowInside ||
583 (!allVisible && !cellVis[cellIds->GetId(0)]) )
585 for ( i=0; i < numFacePts; i++)
586 aNewPts[i] = pts[faceVerts[i]];
587 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
589 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
590 outputCD->CopyData(cd,cellId,newCellId);
596 #ifdef SHOW_COINCIDING_3D_PAL21924
598 for (int ai=0; ai<npts; ai++)
599 faceIdsTmp->InsertNextId(pts[ai]);
600 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
602 for (faceId = 0; faceId < 5; faceId++)
605 faceVerts = vtkPyramid::GetFaceArray(faceId);
606 faceIds->InsertNextId(pts[faceVerts[0]]);
607 faceIds->InsertNextId(pts[faceVerts[1]]);
608 faceIds->InsertNextId(pts[faceVerts[2]]);
609 aCellType = VTK_TRIANGLE;
611 if (faceVerts[3] >= 0)
613 faceIds->InsertNextId(pts[faceVerts[3]]);
614 aCellType = VTK_QUAD;
617 input->GetCellNeighbors(cellId, faceIds, cellIds);
618 #ifdef SHOW_COINCIDING_3D_PAL21924
620 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
621 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
623 bool process = nbNeighbors <= 0;
625 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
627 if ( process || myShowInside ||
628 (!allVisible && !cellVis[cellIds->GetId(0)]) )
630 for ( i=0; i < numFacePts; i++)
631 aNewPts[i] = pts[faceVerts[i]];
632 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
634 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
635 outputCD->CopyData(cd,cellId,newCellId);
641 #if VTK_XVERSION > 50700
644 //MESSAGE("VTK_POLYHEDRON geometry filter");
645 vtkIdType nFaces = 0;
646 vtkIdType* ptIds = 0;
648 input->GetFaceStream(cellId, nFaces, ptIds);
649 #ifdef SHOW_COINCIDING_3D_PAL21924
651 for (int ai=0; ai<npts; ai++)
652 faceIdsTmp->InsertNextId(pts[ai]);
653 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
655 for (faceId = 0; faceId < nFaces; faceId++)
658 numFacePts = ptIds[idp];
659 //MESSAGE("numFacePts="<< numFacePts);
661 for (i = 0; i < numFacePts; i++)
663 //MESSAGE("ptIds[" << idp + i << "]=" << ptIds[idp + i]);
664 faceIds->InsertNextId(ptIds[idp + i]);
670 aCellType = VTK_TRIANGLE;
673 aCellType = VTK_QUAD;
676 aCellType = VTK_POLYGON;
679 // TODO understand and fix display of several polyhedrons
680 input->GetCellNeighbors(cellId, faceIds, cellIds);
681 #ifdef SHOW_COINCIDING_3D_PAL21924
683 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
684 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
686 bool process = nbNeighbors <= 0;
688 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
690 if (process || myShowInside
691 || (!allVisible && !cellVis[cellIds->GetId(0)]))
693 for (i = 0; i < numFacePts; i++)
694 aNewPts[i] = ptIds[pt0 + i];
695 newCellId = output->InsertNextCell(aCellType, numFacePts, aNewPts);
697 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
698 outputCD->CopyData(cd, cellId, newCellId);
705 case VTK_QUADRATIC_EDGE:
706 case VTK_QUADRATIC_TRIANGLE:
707 case VTK_QUADRATIC_QUAD:
708 case VTK_BIQUADRATIC_QUAD:
709 case VTK_QUADRATIC_TETRA:
710 case VTK_QUADRATIC_HEXAHEDRON:
711 case VTK_TRIQUADRATIC_HEXAHEDRON:
712 case VTK_QUADRATIC_WEDGE:
713 case VTK_QUADRATIC_PYRAMID:
714 if(!myIsWireframeMode) {
715 input->GetCell(cellId,cell);
716 vtkIdList *lpts = vtkIdList::New();
717 vtkPoints *coords = vtkPoints::New();
718 vtkIdList *cellIds = vtkIdList::New();
721 if ( cell->GetCellDimension() == 1 ) {
722 vtkIdType arcResult = -1;
724 arcResult = Build1DArc(cellId, input, output, pts, myMaxArcAngle);
725 newCellId = arcResult;
728 if(!myIsBuildArc || arcResult == -1 ) {
729 aCellType = VTK_LINE;
731 cell->Triangulate(0,lpts,coords);
732 for (i=0; i < lpts->GetNumberOfIds(); i+=2) {
733 aNewPts[0] = lpts->GetId(i);
734 aNewPts[1] = lpts->GetId(i+1);
735 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
737 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
738 outputCD->CopyData(cd,cellId,newCellId);
743 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
744 outputCD->CopyData(cd,cellId,newCellId);
747 else if ( cell->GetCellDimension() == 2 ) {
749 aCellType = VTK_TRIANGLE;
751 cell->Triangulate(0,lpts,coords);
752 for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
753 aNewPts[0] = lpts->GetId(i);
754 aNewPts[1] = lpts->GetId(i+1);
755 aNewPts[2] = lpts->GetId(i+2);
756 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
758 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
759 outputCD->CopyData(cd,cellId,newCellId);
763 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds,true);
766 else //3D nonlinear cell
768 #ifdef SHOW_COINCIDING_3D_PAL21924
772 case VTK_QUADRATIC_TETRA: npts1 = 4; break;
773 case VTK_QUADRATIC_HEXAHEDRON: npts1 = 8; break;
774 case VTK_TRIQUADRATIC_HEXAHEDRON: npts1 = 8; break;
775 case VTK_QUADRATIC_WEDGE: npts1 = 6; break;
776 case VTK_QUADRATIC_PYRAMID: npts1 = 5; break;
779 for (int ai=0; ai<npts; ai++)
780 faceIdsTmp->InsertNextId(pts[ai]);
781 input->GetCellNeighbors(cellId, faceIdsTmp, cellIdsTmp);
784 aCellType = VTK_TRIANGLE;
786 for (int j=0; j < cell->GetNumberOfFaces(); j++){
787 vtkCell *face = cell->GetFace(j);
788 input->GetCellNeighbors(cellId, face->PointIds, cellIds);
789 #ifdef SHOW_COINCIDING_3D_PAL21924
791 for(int ai=0;ai<cellIds->GetNumberOfIds();ai++) {
792 if (cellIdsTmp->IsId(cellIds->GetId(ai)) == -1) nbNeighbors++;
794 bool process = nbNeighbors <= 0;
796 bool process = cellIds->GetNumberOfIds() <= 0 || GetAppendCoincident3D();
798 if ( process || myShowInside ) {
799 face->Triangulate(0,lpts,coords);
800 for (i=0; i < lpts->GetNumberOfIds(); i+=3) {
801 aNewPts[0] = lpts->GetId(i);
802 aNewPts[1] = lpts->GetId(i+1);
803 aNewPts[2] = lpts->GetId(i+2);
804 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
806 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
807 outputCD->CopyData(cd,cellId,newCellId);
811 } //3d nonlinear cell
816 } else { // wireframe
818 case VTK_QUADRATIC_EDGE: {
819 vtkIdType arcResult =-1;
821 arcResult = Build1DArc(cellId, input, output, pts,myMaxArcAngle);
822 newCellId = arcResult;
824 if(!myIsBuildArc || arcResult == -1) {
825 aCellType = VTK_POLY_LINE;
832 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
836 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
838 outputCD->CopyData(cd,cellId,newCellId);
841 case VTK_QUADRATIC_TRIANGLE: {
843 aCellType = VTK_POLYGON;
853 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
855 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
857 outputCD->CopyData(cd,cellId,newCellId);
860 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds);
863 case VTK_BIQUADRATIC_QUAD:
864 case VTK_QUADRATIC_QUAD: {
866 aCellType = VTK_POLYGON;
878 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
880 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
882 outputCD->CopyData(cd,cellId,newCellId);
885 BuildArcedPolygon(cellId,input,output,aDimension2VTK2ObjIds);
888 case VTK_QUADRATIC_TETRA: {
889 aCellType = VTK_POLYGON;
892 //---------------------------------------------------------------
900 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
902 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
904 outputCD->CopyData(cd,cellId,newCellId);
906 //---------------------------------------------------------------
914 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
916 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
918 outputCD->CopyData(cd,cellId,newCellId);
920 //---------------------------------------------------------------
928 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
930 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
932 outputCD->CopyData(cd,cellId,newCellId);
934 //---------------------------------------------------------------
942 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
944 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
946 outputCD->CopyData(cd,cellId,newCellId);
950 case VTK_QUADRATIC_WEDGE: {
951 aCellType = VTK_POLYGON;
953 //---------------------------------------------------------------
961 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
963 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
964 outputCD->CopyData(cd,cellId,newCellId);
966 //---------------------------------------------------------------
971 aNewPts[3] = pts[10];
973 aNewPts[5] = pts[11];
974 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
976 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
977 outputCD->CopyData(cd,cellId,newCellId);
979 //---------------------------------------------------------------
985 aNewPts[3] = pts[14];
987 aNewPts[5] = pts[11];
989 aNewPts[7] = pts[12];
990 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
992 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
993 outputCD->CopyData(cd,cellId,newCellId);
995 //---------------------------------------------------------------
998 aNewPts[1] = pts[13];
1000 aNewPts[3] = pts[10];
1001 aNewPts[4] = pts[5];
1002 aNewPts[5] = pts[14];
1003 aNewPts[6] = pts[2];
1004 aNewPts[7] = pts[7];
1005 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1007 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1008 outputCD->CopyData(cd,cellId,newCellId);
1010 //---------------------------------------------------------------
1012 aNewPts[0] = pts[0];
1013 aNewPts[1] = pts[12];
1014 aNewPts[2] = pts[3];
1015 aNewPts[3] = pts[9];
1016 aNewPts[4] = pts[4];
1017 aNewPts[5] = pts[13];
1018 aNewPts[6] = pts[1];
1019 aNewPts[7] = pts[6];
1020 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1022 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1023 outputCD->CopyData(cd,cellId,newCellId);
1026 case VTK_TRIQUADRATIC_HEXAHEDRON:
1027 case VTK_QUADRATIC_HEXAHEDRON: {
1028 aCellType = VTK_POLYGON;
1031 //---------------------------------------------------------------
1032 aNewPts[0] = pts[0];
1033 aNewPts[1] = pts[8];
1034 aNewPts[2] = pts[1];
1035 aNewPts[3] = pts[17];
1036 aNewPts[4] = pts[5];
1037 aNewPts[5] = pts[12];
1038 aNewPts[6] = pts[4];
1039 aNewPts[7] = pts[16];
1041 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1043 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1045 outputCD->CopyData(cd,cellId,newCellId);
1047 //---------------------------------------------------------------
1048 aNewPts[0] = pts[1];
1049 aNewPts[1] = pts[9];
1050 aNewPts[2] = pts[2];
1051 aNewPts[3] = pts[18];
1052 aNewPts[4] = pts[6];
1053 aNewPts[5] = pts[13];
1054 aNewPts[6] = pts[5];
1055 aNewPts[7] = pts[17];
1057 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1059 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1061 outputCD->CopyData(cd,cellId,newCellId);
1063 //---------------------------------------------------------------
1064 aNewPts[0] = pts[2];
1065 aNewPts[1] = pts[10];
1066 aNewPts[2] = pts[3];
1067 aNewPts[3] = pts[19];
1068 aNewPts[4] = pts[7];
1069 aNewPts[5] = pts[14];
1070 aNewPts[6] = pts[6];
1071 aNewPts[7] = pts[18];
1073 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1075 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1077 outputCD->CopyData(cd,cellId,newCellId);
1079 //---------------------------------------------------------------
1080 aNewPts[0] = pts[3];
1081 aNewPts[1] = pts[11];
1082 aNewPts[2] = pts[0];
1083 aNewPts[3] = pts[16];
1084 aNewPts[4] = pts[4];
1085 aNewPts[5] = pts[15];
1086 aNewPts[6] = pts[7];
1087 aNewPts[7] = pts[19];
1089 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1091 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1093 outputCD->CopyData(cd,cellId,newCellId);
1095 //---------------------------------------------------------------
1096 aNewPts[0] = pts[0];
1097 aNewPts[1] = pts[8];
1098 aNewPts[2] = pts[1];
1099 aNewPts[3] = pts[9];
1100 aNewPts[4] = pts[2];
1101 aNewPts[5] = pts[10];
1102 aNewPts[6] = pts[3];
1103 aNewPts[7] = pts[11];
1105 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1107 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1109 outputCD->CopyData(cd,cellId,newCellId);
1111 //---------------------------------------------------------------
1112 aNewPts[0] = pts[4];
1113 aNewPts[1] = pts[12];
1114 aNewPts[2] = pts[5];
1115 aNewPts[3] = pts[13];
1116 aNewPts[4] = pts[6];
1117 aNewPts[5] = pts[14];
1118 aNewPts[6] = pts[7];
1119 aNewPts[7] = pts[15];
1121 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1123 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1125 outputCD->CopyData(cd,cellId,newCellId);
1129 case VTK_QUADRATIC_PYRAMID: {
1130 aCellType = VTK_POLYGON;
1133 //---------------------------------------------------------------
1134 aNewPts[0] = pts[0];
1135 aNewPts[1] = pts[8];
1136 aNewPts[2] = pts[3];
1137 aNewPts[3] = pts[12];
1138 aNewPts[4] = pts[4];
1139 aNewPts[5] = pts[9];
1141 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1143 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1145 outputCD->CopyData(cd,cellId,newCellId);
1147 //---------------------------------------------------------------
1148 aNewPts[0] = pts[0];
1149 aNewPts[1] = pts[9];
1150 aNewPts[2] = pts[4];
1151 aNewPts[3] = pts[10];
1152 aNewPts[4] = pts[1];
1153 aNewPts[5] = pts[5];
1155 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1157 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1159 outputCD->CopyData(cd,cellId,newCellId);
1161 //---------------------------------------------------------------
1162 aNewPts[0] = pts[1];
1163 aNewPts[1] = pts[10];
1164 aNewPts[2] = pts[4];
1165 aNewPts[3] = pts[11];
1166 aNewPts[4] = pts[2];
1167 aNewPts[5] = pts[6];
1169 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1171 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1173 outputCD->CopyData(cd,cellId,newCellId);
1175 //---------------------------------------------------------------
1176 aNewPts[0] = pts[2];
1177 aNewPts[1] = pts[11];
1178 aNewPts[2] = pts[4];
1179 aNewPts[3] = pts[12];
1180 aNewPts[4] = pts[3];
1181 aNewPts[5] = pts[7];
1183 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1185 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1187 outputCD->CopyData(cd,cellId,newCellId);
1189 //---------------------------------------------------------------
1191 aNewPts[0] = pts[0];
1192 aNewPts[1] = pts[5];
1193 aNewPts[2] = pts[1];
1194 aNewPts[3] = pts[6];
1195 aNewPts[4] = pts[2];
1196 aNewPts[5] = pts[7];
1197 aNewPts[6] = pts[3];
1198 aNewPts[7] = pts[8];
1200 newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1202 InsertId( cellId, aCellType, myVTK2ObjIds, aDimension2VTK2ObjIds );
1204 outputCD->CopyData(cd,cellId,newCellId);
1207 } // case VTK_QUADRATIC_PYRAMID:
1217 vtkDebugMacro(<<"Extracted " << input->GetNumberOfPoints() << " points,"
1218 << output->GetNumberOfCells() << " cells.");
1224 cellIdsTmp->Delete();
1225 faceIdsTmp->Delete();
1232 // to sort myVTK2ObjIds vector by cell dimension (ascending)
1233 if( myStoreMapping && !aDimension2VTK2ObjIds.empty() )
1235 myVTK2ObjIds.clear();
1236 for( vtkIdType aDimension = 0; aDimension <= 2; aDimension++ )
1238 TMapOfVectorId::const_iterator anIter = aDimension2VTK2ObjIds.find( aDimension );
1239 if( anIter != aDimension2VTK2ObjIds.end() )
1241 const TVectorId& aCellIds = anIter->second;
1242 TVectorId::const_iterator anIdIter, anIdIterEnd = aCellIds.end();
1243 for( anIdIter = aCellIds.begin(); anIdIter != anIdIterEnd; anIdIter++ )
1245 const vtkIdType aCellId = *anIdIter;
1246 myVTK2ObjIds.push_back( aCellId );
1256 VTKViewer_GeometryFilter
1257 ::InsertId( const vtkIdType theCellId,
1258 const vtkIdType theCellType,
1259 TVectorId& theVTK2ObjIds,
1260 TMapOfVectorId& theDimension2VTK2ObjIds )
1262 theVTK2ObjIds.push_back( theCellId );
1265 switch( theCellType )
1268 case VTK_POLY_VERTEX:
1276 case VTK_TRIANGLE_STRIP:
1284 TVectorId& aCellIds = theDimension2VTK2ObjIds[ aDimension ];
1285 aCellIds.push_back( theCellId );
1289 VTKViewer_GeometryFilter
1290 ::SetInside(int theShowInside)
1292 if(myShowInside == theShowInside)
1295 myShowInside = theShowInside;
1300 VTKViewer_GeometryFilter
1303 return myShowInside;
1308 VTKViewer_GeometryFilter
1309 ::SetWireframeMode(int theIsWireframeMode)
1311 if(myIsWireframeMode == theIsWireframeMode)
1314 myIsWireframeMode = theIsWireframeMode;
1319 VTKViewer_GeometryFilter
1320 ::GetWireframeMode()
1322 return myIsWireframeMode;
1327 VTKViewer_GeometryFilter
1328 ::SetStoreMapping(int theStoreMapping)
1330 if(myStoreMapping == theStoreMapping)
1333 myStoreMapping = theStoreMapping;
1338 VTKViewer_GeometryFilter
1341 return myStoreMapping;
1345 vtkIdType VTKViewer_GeometryFilter::GetElemObjId( int theVtkID )
1347 if( theVtkID < 0 || theVtkID >= (int)myVTK2ObjIds.size() )
1349 return myVTK2ObjIds[theVtkID];
1353 void VTKViewer_GeometryFilter::BuildArcedPolygon(vtkIdType cellId,
1354 vtkUnstructuredGrid* input,
1355 vtkPolyData *output,
1356 TMapOfVectorId& theDimension2VTK2ObjIds,
1358 vtkIdType aCellType = VTK_POLYGON;
1359 vtkIdType *aNewPoints = NULL;
1360 vtkIdType aNbPoints = 0;
1361 vtkIdType newCellId;
1363 //Input and output cell data
1364 vtkCellData *cd = input->GetCellData();
1365 vtkCellData *outputCD = output->GetCellData();
1367 //Input and output scalars on point data
1368 vtkDataArray* inputScalars = input->GetPointData()->GetScalars();
1369 vtkDataArray* outputScalars = output->GetPointData()->GetScalars();
1371 std::vector<vtkPoints*> aCollection;
1372 std::vector< std::vector<double> > aScalarCollection;
1374 vtkCell* aCell = input->GetCell(cellId);
1375 switch(aCell->GetCellType()) {
1376 case VTK_QUADRATIC_TRIANGLE:
1378 //Get All points from input cell
1379 Pnt P0 = CreatePnt( aCell, inputScalars, 0 );
1380 Pnt P1 = CreatePnt( aCell, inputScalars, 1 );
1381 Pnt P2 = CreatePnt( aCell, inputScalars, 2 );
1382 Pnt P3 = CreatePnt( aCell, inputScalars, 3 );
1383 Pnt P4 = CreatePnt( aCell, inputScalars, 4 );
1384 Pnt P5 = CreatePnt( aCell, inputScalars, 5 );
1386 VTKViewer_ArcBuilder aBuilder1(P0,P3,P1,myMaxArcAngle); //Build arc using 0, 3 and 1 points
1388 cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1391 VTKViewer_ArcBuilder aBuilder2(P1,P4,P2,myMaxArcAngle); //Build arc using 1, 4 and 2 points
1393 cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1396 VTKViewer_ArcBuilder aBuilder3(P2,P5,P0,myMaxArcAngle); //Build arc using 2, 5 and 0 points
1398 cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1401 aCollection.push_back(aBuilder1.GetPoints());
1402 aCollection.push_back(aBuilder2.GetPoints());
1403 aCollection.push_back(aBuilder3.GetPoints());
1405 aScalarCollection.push_back(aBuilder1.GetScalarValues());
1406 aScalarCollection.push_back(aBuilder2.GetScalarValues());
1407 aScalarCollection.push_back(aBuilder3.GetScalarValues());
1410 case VTK_BIQUADRATIC_QUAD:
1411 case VTK_QUADRATIC_QUAD:
1413 //Get All points from input cell
1414 Pnt P0 = CreatePnt( aCell, inputScalars, 0 );
1415 Pnt P1 = CreatePnt( aCell, inputScalars, 1 );
1416 Pnt P2 = CreatePnt( aCell, inputScalars, 2 );
1417 Pnt P3 = CreatePnt( aCell, inputScalars, 3 );
1418 Pnt P4 = CreatePnt( aCell, inputScalars, 4 );
1419 Pnt P5 = CreatePnt( aCell, inputScalars, 5 );
1420 Pnt P6 = CreatePnt( aCell, inputScalars, 6 );
1421 Pnt P7 = CreatePnt( aCell, inputScalars, 7 );
1423 VTKViewer_ArcBuilder aBuilder1(P0,P4,P1,myMaxArcAngle); //Build arc using 0, 4 and 1 points
1425 cout << "Quadrangle arc 1 " << ( aBuilder1.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1428 VTKViewer_ArcBuilder aBuilder2(P1,P5,P2,myMaxArcAngle); //Build arc using 1, 5 and 2 points
1430 cout << "Quadrangle arc 2 " << ( aBuilder2.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1433 VTKViewer_ArcBuilder aBuilder3(P2,P6,P3,myMaxArcAngle); //Build arc using 2, 6 and 3 points
1435 cout << "Quadrangle arc 3 " << ( aBuilder3.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1438 VTKViewer_ArcBuilder aBuilder4(P3,P7,P0,myMaxArcAngle); //Build arc using 3, 7 and 0 points
1440 cout << "Quadrangle arc 4 " << ( aBuilder4.GetStatus() == VTKViewer_ArcBuilder::Arc_Done ? "" : "NOT " ) << "done !!!" << endl;
1443 aCollection.push_back(aBuilder1.GetPoints());
1444 aCollection.push_back(aBuilder2.GetPoints());
1445 aCollection.push_back(aBuilder3.GetPoints());
1446 aCollection.push_back(aBuilder4.GetPoints());
1448 aScalarCollection.push_back(aBuilder1.GetScalarValues());
1449 aScalarCollection.push_back(aBuilder2.GetScalarValues());
1450 aScalarCollection.push_back(aBuilder3.GetScalarValues());
1451 aScalarCollection.push_back(aBuilder4.GetScalarValues());
1454 default: //Unsupported cell type
1459 const vtkIdType numFacePts = 3;
1460 vtkIdList *pts = vtkIdList::New();
1461 vtkPoints *coords = vtkPoints::New();
1462 aCellType = VTK_TRIANGLE;
1463 vtkIdType aNewPts[numFacePts];
1464 vtkIdType aTriangleId;
1466 vtkPolygon *aPlg = vtkPolygon::New();
1467 std::map<int, double> aPntId2ScalarValue;
1468 aNbPoints = MergevtkPoints(aCollection, aScalarCollection, aPlg->GetPoints(), aPntId2ScalarValue, aNewPoints);
1469 aPlg->GetPointIds()->SetNumberOfIds(aNbPoints);
1471 for(vtkIdType i = 0; i < aNbPoints;i++) {
1472 aPlg->GetPointIds()->SetId(i, aNewPoints[i]);
1475 aPlg->Triangulate(0,pts,coords);
1477 for (vtkIdType i=0; i < pts->GetNumberOfIds(); i+=3) {
1478 aNewPts[0] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i));
1479 aNewPts[1] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+1));
1480 aNewPts[2] = output->GetPoints()->InsertNextPoint(coords->GetPoint(i+2));
1483 outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i)]);
1484 outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+1)]);
1485 outputScalars->InsertNextTuple1(aPntId2ScalarValue[pts->GetId(i+2)]);
1488 aTriangleId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
1491 InsertId( cellId, aCellType, myVTK2ObjIds, theDimension2VTK2ObjIds );
1492 outputCD->CopyData(cd,cellId,aTriangleId);
1499 std::map<int, double> aPntId2ScalarValue;
1500 aNbPoints = MergevtkPoints(aCollection, aScalarCollection, output->GetPoints(), aPntId2ScalarValue, aNewPoints);
1502 for(vtkIdType i = 0; i < aNbPoints; i++)
1503 outputScalars->InsertNextTuple1(aPntId2ScalarValue[aNewPoints[i]]);
1504 newCellId = output->InsertNextCell(aCellType,aNbPoints,aNewPoints);
1505 outputCD->CopyData(cd,cellId,newCellId);
1508 InsertId( cellId, aCellType, myVTK2ObjIds, theDimension2VTK2ObjIds );
1512 delete [] aNewPoints;
1516 void VTKViewer_GeometryFilter::SetQuadraticArcMode(bool theFlag)
1518 if(myIsBuildArc != theFlag) {
1519 myIsBuildArc = theFlag;
1523 bool VTKViewer_GeometryFilter::GetQuadraticArcMode() const
1525 return myIsBuildArc;
1528 void VTKViewer_GeometryFilter::SetQuadraticArcAngle(vtkFloatingPointType theMaxAngle)
1530 if(myMaxArcAngle != theMaxAngle) {
1531 myMaxArcAngle = theMaxAngle;
1536 vtkFloatingPointType VTKViewer_GeometryFilter:: GetQuadraticArcAngle() const
1538 return myMaxArcAngle;
1541 int VTKViewer_GeometryFilter::GetAppendCoincident3D() const {
1542 // VSR 26/10/2012: see description of SHOW_COINCIDING_3D_PAL20314
1543 // in the top of this file
1544 #ifdef SHOW_COINCIDING_3D_PAL20314
1545 return myAppendCoincident3D;
1551 void VTKViewer_GeometryFilter::SetAppendCoincident3D(int theFlag) {
1552 if(myAppendCoincident3D != theFlag){
1553 myAppendCoincident3D = theFlag;