--- /dev/null
+// SALOME OBJECT : kernel of SALOME component
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File : VTKViewer_GeometryFilter.cxx
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "VTKViewer_AppendFilter.h"
+
+#include "VTKViewer_ConvexTool.h"
+
+#include <vtkSmartPointer.h>
+#include <vtkCellArray.h>
+#include <vtkCellData.h>
+#include <vtkGenericCell.h>
+#include <vtkHexahedron.h>
+#include <vtkMergePoints.h>
+#include <vtkObjectFactory.h>
+#include <vtkPointData.h>
+#include <vtkPolyData.h>
+#include <vtkPyramid.h>
+#include <vtkStructuredGrid.h>
+#include <vtkTetra.h>
+#include <vtkUnsignedCharArray.h>
+#include <vtkUnstructuredGrid.h>
+#include <vtkVoxel.h>
+#include <vtkWedge.h>
+#include <vtkDataSetCollection.h>
+
+#include <vector>
+#include <map>
+using namespace std;
+
+
+#ifdef _DEBUG_
+//static int MYDEBUG = 0;
+//static int MYDEBUGWITHFILES = 0;
+#else
+//static int MYDEBUG = 0;
+//static int MYDEBUGWITHFILES = 0;
+#endif
+
+#if defined __GNUC__
+ #if __GNUC__ == 2
+ #define __GNUC_2__
+ #endif
+#endif
+
+vtkCxxRevisionMacro(VTKViewer_AppendFilter, "$Revision$");
+vtkStandardNewMacro(VTKViewer_AppendFilter);
+
+VTKViewer_AppendFilter
+::VTKViewer_AppendFilter()
+{
+ myDoMappingFlag=false;
+}
+
+VTKViewer_AppendFilter
+::~VTKViewer_AppendFilter()
+{}
+
+void
+VTKViewer_AppendFilter
+::SetDoMappingFlag(const bool theFlag)
+{
+ myDoMappingFlag=theFlag;
+}
+
+bool
+VTKViewer_AppendFilter
+::DoMappingFlag() const
+{
+ return myDoMappingFlag;
+}
+
+void
+VTKViewer_AppendFilter
+::SetPoints(vtkPoints* thePoints)
+{
+ myPoints = thePoints;
+}
+
+vtkPoints*
+VTKViewer_AppendFilter
+::GetPoints()
+{
+ return myPoints.GetPointer();
+}
+
+void
+VTKViewer_AppendFilter
+::Execute()
+{
+ if (myPoints.GetPointer()) {
+ MakeOutput();
+ }
+ else {
+ vtkAppendFilter::Execute();
+ }
+ if (myDoMappingFlag){
+ DoMapping();
+ }
+}
+
+void
+VTKViewer_AppendFilter
+::Reset()
+{
+ myNodeIds.clear();
+ myCellIds.clear();
+ myNodeRanges.clear();
+ myCellRanges.clear();
+ myNodeMapObjIDVtkID.clear();
+ myCellMapObjIDVtkID.clear();
+}
+//==================================================================
+// function: DoMapping
+// purpose :
+//==================================================================
+void
+VTKViewer_AppendFilter
+::DoMapping()
+{
+ int i, j, i1, i2, iNodeCnt, iCellCnt;
+ IteratorOfDataMapOfIntegerInteger aMapIt;
+ vtkIdType aNbPnts, aNbCells, aId;
+ vtkDataSet *pDS;
+ //
+ Reset();
+ //
+ iNodeCnt=0;
+ iCellCnt=0;
+ for (i=0; i<NumberOfInputs; ++i) {
+ pDS=(vtkDataSet *)Inputs[i];
+ //
+ // Nodes
+ if (!myPoints.GetPointer()) {
+ aNbPnts=pDS->GetNumberOfPoints();
+ i1=myNodeIds.size();
+ i2=i1+aNbPnts-1;
+ myNodeRanges.push_back(i1);
+ myNodeRanges.push_back(i2);
+ //
+ for(j=0; j<aNbPnts; ++j) {
+ aId=(vtkIdType)j;
+ myNodeIds.push_back(aId);
+ //
+ aMapIt=myNodeMapObjIDVtkID.find(aId);
+ if (aMapIt==myNodeMapObjIDVtkID.end()) {
+ // if not found
+ myNodeMapObjIDVtkID[aId]=iNodeCnt;
+ }
+ ++iNodeCnt;
+ }
+ }
+ //
+ // Cells
+ aNbCells=pDS->GetNumberOfCells();
+ i1=myCellIds.size();
+ i2=i1+aNbCells-1;
+ myCellRanges.push_back(i1);
+ myCellRanges.push_back(i2);
+ for(j=0; j<aNbCells; ++j) {
+ aId=(vtkIdType)j;
+ myCellIds.push_back(aId);
+ //
+ aMapIt=myCellMapObjIDVtkID.find(aId);
+ if (aMapIt==myCellMapObjIDVtkID.end()) {
+ // if not found
+ myCellMapObjIDVtkID[aId]=iCellCnt;
+ }
+ ++iCellCnt;
+ }
+ }
+}
+
+//---------------------------------------------------------------
+vtkIdType
+VTKViewer_AppendFilter
+::GetPointOutputID(vtkIdType theInputID)
+{
+ if (myPoints.GetPointer()) {
+ return theInputID;
+ }
+ //
+ int aVtkID=-1;
+ IteratorOfDataMapOfIntegerInteger aMapIt;
+ //
+ aMapIt=myNodeMapObjIDVtkID.find(theInputID);
+ if (aMapIt!=myNodeMapObjIDVtkID.end()) {
+ // found
+ PairOfDataMapOfIntegerInteger& aPair=(*aMapIt);
+ aVtkID=aPair.second;
+ }
+ return aVtkID;
+}
+
+
+//---------------------------------------------------------------
+vtkIdType
+VTKViewer_AppendFilter
+::GetCellOutputID(vtkIdType theInputID)
+{
+ int aVtkID=-1;
+ IteratorOfDataMapOfIntegerInteger aMapIt;
+ //
+ aMapIt=myCellMapObjIDVtkID.find(theInputID);
+ if (aMapIt!=myCellMapObjIDVtkID.end()) {
+ // found
+ PairOfDataMapOfIntegerInteger& aPair=(*aMapIt);
+ aVtkID=aPair.second;
+ }
+ return aVtkID;
+}
+
+
+//---------------------------------------------------------------
+vtkIdType
+VTKViewer_AppendFilter
+::GetPointInputID(vtkIdType theOutputID,
+ vtkIdType& theInputDataSetID)
+{
+ if (myPoints.GetPointer()) {
+ theInputDataSetID=0;
+ return theOutputID;
+ }
+ //
+ int aNb, aNbRanges, aRetID, i, i1, i2, j;
+ //
+ aRetID=-1;
+ theInputDataSetID=-1;
+ //
+ aNb=myNodeIds.size();
+ if (theOutputID<0 || theOutputID>=aNb) {
+ return aRetID;
+ }
+ //
+ aRetID=(int)myNodeIds[theOutputID];
+ //
+ aNbRanges=myNodeRanges.size()/2;
+ for (i=0; i<aNbRanges; ++i) {
+ j=2*i;
+ i1=myNodeRanges[j];
+ i2=myNodeRanges[j+1];
+ if (theOutputID>=i1 && theOutputID<=i2) {
+ theInputDataSetID=i;
+ }
+ }
+ //
+ return aRetID;
+}
+
+
+//---------------------------------------------------------------
+vtkIdType
+VTKViewer_AppendFilter
+::GetCellInputID(vtkIdType theOutputID,
+ vtkIdType& theInputDataSetID)
+{
+ int aNb, aNbRanges, aRetID, i, i1, i2, j;
+ //
+ aRetID=-1;
+ theInputDataSetID=-1;
+ //
+ aNb=myCellIds.size();
+ if (theOutputID<0 || theOutputID>=aNb) {
+ return aRetID;
+ }
+ //
+ aRetID=(int)myCellIds[theOutputID];
+ //
+ aNbRanges=myCellRanges.size()/2;
+ for (i=0; i<aNbRanges; ++i) {
+ j=2*i;
+ i1=myCellRanges[j];
+ i2=myCellRanges[j+1];
+ if (theOutputID>=i1 && theOutputID<=i2) {
+ theInputDataSetID=i;
+ }
+ }
+ //
+ return aRetID;
+}
+
+
+//---------------------------------------------------------------
+void
+VTKViewer_AppendFilter
+::MakeOutput()
+{
+ int idx;
+ vtkIdType numPts, numCells, newCellId, cellId;
+ vtkCellData *cd;
+ vtkIdList *ptIds;
+ vtkDataSet *ds;
+ vtkUnstructuredGrid *output = this->GetOutput();
+ //
+ numPts = myPoints->GetNumberOfPoints();
+ if (numPts < 1) {
+ return;
+ }
+ //
+ numCells = 0;
+ for (idx = 0; idx < this->NumberOfInputs; ++idx) {
+ ds = (vtkDataSet *)(this->Inputs[idx]);
+ if (ds != NULL) {
+ if ( ds->GetNumberOfPoints() <= 0 && ds->GetNumberOfCells() <= 0 ) {
+ continue; //no input, just skip
+ }
+ numCells += ds->GetNumberOfCells();
+ }//if non-empty dataset
+ }//for all inputs
+ if (numCells < 1) {
+ return;
+ }
+ //
+ // Now can allocate memory
+ output->Allocate(numCells);
+ ptIds = vtkIdList::New();
+ ptIds->Allocate(VTK_CELL_SIZE);
+ //
+ // Append each input dataset together
+ //
+ // 1.points
+ output->SetPoints(myPoints.GetPointer());
+ // 2.cells
+ for (idx = 0; idx < this->NumberOfInputs; ++idx) {
+ ds = (vtkDataSet *)(this->Inputs[idx]);
+ if (ds != NULL) {
+ numCells = ds->GetNumberOfCells();
+ cd = ds->GetCellData();
+ // copy cell and cell data
+ for (cellId=0; cellId<numCells; cellId++) {
+ ds->GetCellPoints(cellId, ptIds);
+ newCellId = output->InsertNextCell(ds->GetCellType(cellId), ptIds);
+ }
+ }
+ }
+ //
+ ptIds->Delete();
+}
+
using namespace std;
-#ifdef _DEBUG_
-static int MYDEBUG = 0;
-#else
-static int MYDEBUG = 0;
-#endif
-
#if defined __GNUC__
#if __GNUC__ == 2
#define __GNUC_2__
#endif
#endif
+//----------------------------------------------------------------------------
vtkCxxRevisionMacro(VTKViewer_GeometryFilter, "$Revision$");
vtkStandardNewMacro(VTKViewer_GeometryFilter);
VTKViewer_GeometryFilter::VTKViewer_GeometryFilter():
myShowInside(0),
- myStoreMapping(0)
+ myStoreMapping(0),
+ myIsWireframeMode(0)
{}
{}
+//----------------------------------------------------------------------------
void VTKViewer_GeometryFilter::Execute()
{
vtkDataSet *input= this->GetInput();
}
-void VTKViewer_GeometryFilter::SetStoreMapping(int theStoreMapping){
- myStoreMapping = theStoreMapping;
- this->Modified();
-}
-
-
-vtkIdType VTKViewer_GeometryFilter::GetElemObjId(int theVtkID){
- if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
-#if defined __GNUC_2__
- return myVTK2ObjIds[theVtkID];
-#else
- return myVTK2ObjIds.at(theVtkID);
-#endif
-}
-
-
+//----------------------------------------------------------------------------
void VTKViewer_GeometryFilter::UnstructuredGridExecute()
{
vtkUnstructuredGrid *input= (vtkUnstructuredGrid *)this->GetInput();
vtkPointData *outputPD = output->GetPointData();
vtkCellData *outputCD = output->GetCellData();
- //vtkCellArray *Verts, *Lines, *Polys, *Strips;
vtkIdList *cellIds, *faceIds;
char *cellVis;
vtkIdType newCellId;
outputCD->CopyAllocate(cd,numCells,numCells/2);
output->Allocate(numCells/4+1,numCells);
- //Verts = vtkCellArray::New();
- //Verts->Allocate(numCells/4+1,numCells);
- //Lines = vtkCellArray::New();
- //Lines->Allocate(numCells/4+1,numCells);
- //Polys = vtkCellArray::New();
- //Polys->Allocate(numCells/4+1,numCells);
- //Strips = vtkCellArray::New();
- //Strips->Allocate(numCells/4+1,numCells);
// Loop over the cells determining what's visible
if (!allVisible)
case VTK_LINE:
case VTK_POLY_LINE:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_QUAD:
case VTK_POLYGON:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_TRIANGLE_STRIP:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
case VTK_PIXEL:
newCellId = output->InsertNextCell(aCellType,npts,pts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
break;
faceIds->InsertNextId(pts[faceVerts[0]]);
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
- numFacePts = 3;
aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[i]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
faceIds->InsertNextId(pts[faceVerts[3]]);
- numFacePts = 4;
aCellType = VTK_QUAD;
+ numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[PixelConvert[i]]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
faceIds->InsertNextId(pts[faceVerts[3]]);
- numFacePts = 4;
aCellType = VTK_QUAD;
+ numFacePts = 4;
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[i]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
faceIds->InsertNextId(pts[faceVerts[0]]);
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
- numFacePts = 3;
aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
if (faceVerts[3] >= 0)
{
faceIds->InsertNextId(pts[faceVerts[3]]);
- numFacePts = 4;
aCellType = VTK_QUAD;
+ numFacePts = 4;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[i]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
faceIds->InsertNextId(pts[faceVerts[0]]);
faceIds->InsertNextId(pts[faceVerts[1]]);
faceIds->InsertNextId(pts[faceVerts[2]]);
- numFacePts = 3;
aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
if (faceVerts[3] >= 0)
{
faceIds->InsertNextId(pts[faceVerts[3]]);
- numFacePts = 4;
aCellType = VTK_QUAD;
+ numFacePts = 4;
}
input->GetCellNeighbors(cellId, faceIds, cellIds);
- if ( cellIds->GetNumberOfIds() <= 0 || myShowInside == 1 ||
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ||
(!allVisible && !cellVis[cellIds->GetId(0)]) )
{
for ( i=0; i < numFacePts; i++)
- {
aNewPts[i] = pts[faceVerts[i]];
- }
newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping){
- myVTK2ObjIds.push_back(cellId); //apo
- }
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}
break;
}
//Quadratic cells
- case VTK_QUADRATIC_EDGE: {
- newCellId = output->InsertNextCell(VTK_POLY_LINE,npts,pts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- break;
- }
- case VTK_QUADRATIC_TRIANGLE: {
- numFacePts = 6;
- aCellType = VTK_POLYGON;
-
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[3];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[4];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[5];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
- break;
- }
- case VTK_QUADRATIC_QUAD: {
- numFacePts = 8;
- aCellType = VTK_POLYGON;
-
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[4];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[5];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[6];
- aNewPts[6] = pts[3];
- aNewPts[7] = pts[7];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
- break;
- }
- case VTK_QUADRATIC_TETRA: {
- numFacePts = 8;
- aCellType = VTK_POLYGON;
-
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[4];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[5];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[6];
- aNewPts[6] = pts[3];
- aNewPts[7] = pts[7];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
- break;
- }
- case VTK_QUADRATIC_HEXAHEDRON: {
- numFacePts = 8;
- aCellType = VTK_POLYGON;
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[8];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[17];
- aNewPts[4] = pts[5];
- aNewPts[5] = pts[12];
- aNewPts[6] = pts[4];
- aNewPts[7] = pts[16];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[1];
- aNewPts[1] = pts[9];
- aNewPts[2] = pts[2];
- aNewPts[3] = pts[18];
- aNewPts[4] = pts[6];
- aNewPts[5] = pts[13];
- aNewPts[6] = pts[5];
- aNewPts[7] = pts[17];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[2];
- aNewPts[1] = pts[10];
- aNewPts[2] = pts[3];
- aNewPts[3] = pts[19];
- aNewPts[4] = pts[7];
- aNewPts[5] = pts[14];
- aNewPts[6] = pts[6];
- aNewPts[7] = pts[18];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[3];
- aNewPts[1] = pts[11];
- aNewPts[2] = pts[0];
- aNewPts[3] = pts[16];
- aNewPts[4] = pts[4];
- aNewPts[5] = pts[15];
- aNewPts[6] = pts[7];
- aNewPts[7] = pts[19];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[0];
- aNewPts[1] = pts[8];
- aNewPts[2] = pts[1];
- aNewPts[3] = pts[9];
- aNewPts[4] = pts[2];
- aNewPts[5] = pts[10];
- aNewPts[6] = pts[3];
- aNewPts[7] = pts[11];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- //---------------------------------------------------------------
- aNewPts[0] = pts[4];
- aNewPts[1] = pts[12];
- aNewPts[2] = pts[5];
- aNewPts[3] = pts[13];
- aNewPts[4] = pts[6];
- aNewPts[5] = pts[14];
- aNewPts[6] = pts[7];
- aNewPts[7] = pts[15];
-
- newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
- if(myStoreMapping)
- myVTK2ObjIds.push_back(cellId);
-
- outputCD->CopyData(cd,cellId,newCellId);
-
- break;
- }
- } //switch
+ case VTK_QUADRATIC_EDGE:
+ case VTK_QUADRATIC_TRIANGLE:
+ case VTK_QUADRATIC_QUAD:
+ case VTK_QUADRATIC_TETRA:
+ case VTK_QUADRATIC_HEXAHEDRON:
+ if(!myIsWireframeMode){
+ vtkGenericCell *cell = vtkGenericCell::New();
+ input->GetCell(cellId,cell);
+ vtkIdList *pts = vtkIdList::New();
+ vtkPoints *coords = vtkPoints::New();
+ vtkIdList *cellIds = vtkIdList::New();
+ vtkIdType newCellId;
+
+ if ( cell->GetCellDimension() == 1 ) {
+ aCellType = VTK_LINE;
+ numFacePts = 2;
+ cell->Triangulate(0,pts,coords);
+ for (i=0; i < pts->GetNumberOfIds(); i+=2) {
+ aNewPts[0] = pts->GetId(i);
+ aNewPts[1] = pts->GetId(i+1);
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ }
+ }
+ else if ( cell->GetCellDimension() == 2 ) {
+ aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
+ cell->Triangulate(0,pts,coords);
+ for (i=0; i < pts->GetNumberOfIds(); i+=3) {
+ aNewPts[0] = pts->GetId(i);
+ aNewPts[1] = pts->GetId(i+1);
+ aNewPts[2] = pts->GetId(i+2);
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ }
+ }
+ else //3D nonlinear cell
+ {
+ aCellType = VTK_TRIANGLE;
+ numFacePts = 3;
+ for (int j=0; j < cell->GetNumberOfFaces(); j++){
+ vtkCell *face = cell->GetFace(j);
+ input->GetCellNeighbors(cellId, face->PointIds, cellIds);
+ if ( cellIds->GetNumberOfIds() <= 0 || myShowInside ) {
+ face->Triangulate(0,pts,coords);
+ for (i=0; i < pts->GetNumberOfIds(); i+=3) {
+ aNewPts[0] = pts->GetId(i);
+ aNewPts[1] = pts->GetId(i+1);
+ aNewPts[2] = pts->GetId(i+2);
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+ outputCD->CopyData(cd,cellId,newCellId);
+ }
+ }
+ }
+ } //3d cell
+ cellIds->Delete();
+ coords->Delete();
+ pts->Delete();
+ cell->Delete();
+ break;
+ }else{
+ switch(aCellType){
+ case VTK_QUADRATIC_EDGE: {
+ aCellType = VTK_POLY_LINE;
+ numFacePts = 3;
+
+ aNewPts[0] = pts[0];
+ aNewPts[2] = pts[1];
+ aNewPts[1] = pts[2];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+ break;
+ }
+ case VTK_QUADRATIC_TRIANGLE: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 6;
+
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[3];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[4];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[5];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+ break;
+ }
+ case VTK_QUADRATIC_QUAD: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 8;
+
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[4];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[5];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[6];
+ aNewPts[6] = pts[3];
+ aNewPts[7] = pts[7];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+ break;
+ }
+ case VTK_QUADRATIC_TETRA: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 6;
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[4];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[5];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[6];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[7];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[8];
+ aNewPts[4] = pts[1];
+ aNewPts[5] = pts[4];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[1];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[9];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[5];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[2];
+ aNewPts[1] = pts[9];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[7];
+ aNewPts[4] = pts[0];
+ aNewPts[5] = pts[6];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ break;
+ }
+ case VTK_QUADRATIC_HEXAHEDRON: {
+ aCellType = VTK_POLYGON;
+ numFacePts = 8;
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[17];
+ aNewPts[4] = pts[5];
+ aNewPts[5] = pts[12];
+ aNewPts[6] = pts[4];
+ aNewPts[7] = pts[16];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[1];
+ aNewPts[1] = pts[9];
+ aNewPts[2] = pts[2];
+ aNewPts[3] = pts[18];
+ aNewPts[4] = pts[6];
+ aNewPts[5] = pts[13];
+ aNewPts[6] = pts[5];
+ aNewPts[7] = pts[17];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[2];
+ aNewPts[1] = pts[10];
+ aNewPts[2] = pts[3];
+ aNewPts[3] = pts[19];
+ aNewPts[4] = pts[7];
+ aNewPts[5] = pts[14];
+ aNewPts[6] = pts[6];
+ aNewPts[7] = pts[18];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[3];
+ aNewPts[1] = pts[11];
+ aNewPts[2] = pts[0];
+ aNewPts[3] = pts[16];
+ aNewPts[4] = pts[4];
+ aNewPts[5] = pts[15];
+ aNewPts[6] = pts[7];
+ aNewPts[7] = pts[19];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[0];
+ aNewPts[1] = pts[8];
+ aNewPts[2] = pts[1];
+ aNewPts[3] = pts[9];
+ aNewPts[4] = pts[2];
+ aNewPts[5] = pts[10];
+ aNewPts[6] = pts[3];
+ aNewPts[7] = pts[11];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ //---------------------------------------------------------------
+ aNewPts[0] = pts[4];
+ aNewPts[1] = pts[12];
+ aNewPts[2] = pts[5];
+ aNewPts[3] = pts[13];
+ aNewPts[4] = pts[6];
+ aNewPts[5] = pts[14];
+ aNewPts[6] = pts[7];
+ aNewPts[7] = pts[15];
+
+ newCellId = output->InsertNextCell(aCellType,numFacePts,aNewPts);
+ if(myStoreMapping)
+ myVTK2ObjIds.push_back(cellId);
+
+ outputCD->CopyData(cd,cellId,newCellId);
+
+ break;
+ }}
+ }
+ } //switch
} //if visible
} //for all cells
- if(MYDEBUG && myStoreMapping){
- for(int i = 0, iEnd = myVTK2ObjIds.size(); i < iEnd; i++){
- cout<<myVTK2ObjIds[i]<<", ";
- }
- cout<<"\n";
- }
-
- // Update ourselves and release memory
- //
- //output->SetVerts(Verts);
- //Verts->Delete();
- //output->SetLines(Lines);
- //Lines->Delete();
- //output->SetPolys(Polys);
- //Polys->Delete();
- //output->SetStrips(Strips);
- //Strips->Delete();
-
output->Squeeze();
vtkDebugMacro(<<"Extracted " << input->GetNumberOfPoints() << " points,"
}
-void VTKViewer_GeometryFilter::SetInside(int theShowInside){
- if(myShowInside == theShowInside) return;
+//----------------------------------------------------------------------------
+void
+VTKViewer_GeometryFilter
+::SetInside(int theShowInside)
+{
+ if(myShowInside == theShowInside)
+ return;
+
myShowInside = theShowInside;
this->Modified();
}
-int VTKViewer_GeometryFilter::GetInside(){
+
+int
+VTKViewer_GeometryFilter
+::GetInside()
+{
return myShowInside;
}
+
+
+//----------------------------------------------------------------------------
+void
+VTKViewer_GeometryFilter
+::SetWireframeMode(int theIsWireframeMode)
+{
+ if(myIsWireframeMode == theIsWireframeMode)
+ return;
+
+ myIsWireframeMode = theIsWireframeMode;
+ this->Modified();
+}
+
+int
+VTKViewer_GeometryFilter
+::GetWireframeMode()
+{
+ return myIsWireframeMode;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VTKViewer_GeometryFilter
+::SetStoreMapping(int theStoreMapping)
+{
+ if(myStoreMapping == theStoreMapping)
+ return;
+
+ myStoreMapping = theStoreMapping;
+ this->Modified();
+}
+
+int
+VTKViewer_GeometryFilter
+::GetStoreMapping()
+{
+ return myStoreMapping;
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType VTKViewer_GeometryFilter::GetElemObjId(int theVtkID){
+ if(myVTK2ObjIds.empty() || theVtkID > myVTK2ObjIds.size()) return -1;
+#if defined __GNUC_2__
+ return myVTK2ObjIds[theVtkID];
+#else
+ return myVTK2ObjIds.at(theVtkID);
+#endif
+}