-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007 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
// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
-
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
#include "SALOME_ExtractGeometry.h"
#include <vtkPointData.h>
#include <vtkUnstructuredGrid.h>
+#include <vtkInformation.h>
+#include <vtkInformationVector.h>
+
#include <vtkImplicitBoolean.h>
#include <vtkImplicitFunctionCollection.h>
-using namespace std;
-
#if defined __GNUC__
#if __GNUC__ == 2
#define __GNUC_2__
{}
-//----------------------------------------------------------------------------
-unsigned long int
-SALOME_ExtractGeometry
-::GetMTime()
-{
- unsigned long int aTime = vtkExtractGeometry::GetMTime();
- return aTime;
-}
-
-
//----------------------------------------------------------------------------
vtkImplicitBoolean*
SALOME_ExtractGeometry
::SetImplicitFunction(vtkImplicitFunction* theImplicitFunction)
{
myImplicitBoolean = dynamic_cast<vtkImplicitBoolean*>(theImplicitFunction);
- vtkExtractGeometry::SetImplicitFunction(theImplicitFunction);
+ Superclass::SetImplicitFunction(theImplicitFunction);
}
SALOME_ExtractGeometry
::SetStoreMapping(bool theStoreMapping)
{
- myStoreMapping = theStoreMapping;
- Modified();
+ if(myStoreMapping != theStoreMapping){
+ myStoreMapping = theStoreMapping;
+ Modified();
+ }
}
bool
SALOME_ExtractGeometry
::GetElemVTKId(vtkIdType theID)
{
- if(!myStoreMapping||myIsDoneShallowCopy){
+ if(!myStoreMapping || myIsDoneShallowCopy)
return theID;
- }
+
vtkIdType iEnd = myElemVTK2ObjIds.size();
for(vtkIdType i = 0; i < iEnd; i++)
if(myElemVTK2ObjIds[i] == theID)
SALOME_ExtractGeometry
::GetNodeVTKId(vtkIdType theID)
{
- if (!myStoreMapping||myIsDoneShallowCopy){
+ if(!myStoreMapping || myIsDoneShallowCopy)
return theID;
- }
+
vtkIdType iEnd = myNodeVTK2ObjIds.size();
for(vtkIdType i = 0; i < iEnd; i++)
if(myNodeVTK2ObjIds[i] == theID)
//----------------------------------------------------------------------------
vtkIdType
SALOME_ExtractGeometry
-::GetElemObjId(int theVtkID)
+::GetElemObjId(vtkIdType theVtkID)
{
- if (!myStoreMapping||myIsDoneShallowCopy){
+ if(!myStoreMapping || myIsDoneShallowCopy)
return theVtkID;
- }
- //
- if (theVtkID<myElemVTK2ObjIds.size()){
+
+ if(theVtkID < myElemVTK2ObjIds.size())
return myElemVTK2ObjIds[theVtkID];
- }
+
return -1;
}
vtkIdType
SALOME_ExtractGeometry
-::GetNodeObjId(int theVtkID)
+::GetNodeObjId(vtkIdType theVtkID)
{
- if (!myStoreMapping||myIsDoneShallowCopy){
+ if(!myStoreMapping || myIsDoneShallowCopy)
return theVtkID;
- }
- //
- if (theVtkID<myNodeVTK2ObjIds.size()){
+
+ if(theVtkID < myNodeVTK2ObjIds.size())
return myNodeVTK2ObjIds[theVtkID];
- }
+
return -1;
}
//----------------------------------------------------------------------------
-void
+int
SALOME_ExtractGeometry
-::Execute()
+::RequestData(vtkInformation *request,
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
{
+ // get the info objects
+ vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
+ vtkInformation *outInfo = outputVector->GetInformationObject(0);
+
+ // get the input and ouptut
+ vtkDataSet *input = vtkDataSet::SafeDownCast(
+ inInfo->Get(vtkDataObject::DATA_OBJECT()));
+ vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
+ outInfo->Get(vtkDataObject::DATA_OBJECT()));
+
myElemVTK2ObjIds.clear();
myNodeVTK2ObjIds.clear();
//
myIsDoneShallowCopy = !this->ImplicitFunction;
- if(!myIsDoneShallowCopy && myImplicitBoolean.GetPointer()){
- if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction()){
+ if(!myIsDoneShallowCopy && myImplicitBoolean.GetPointer())
+ if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction())
myIsDoneShallowCopy = aFunction->GetNumberOfItems() == 0;
- }
- }
if(myIsDoneShallowCopy){
- GetOutput()->ShallowCopy(GetInput());
- Modified();
- return;
+ output->ShallowCopy(input);
+ return 1;
}
-
- Execute2();
+
+ return RequestData2(request,inputVector,outputVector);
}
-void
+
+//----------------------------------------------------------------------------
+int
SALOME_ExtractGeometry
-::Execute2()
+::RequestData2(vtkInformation *vtkNotUsed(request),
+ vtkInformationVector **inputVector,
+ vtkInformationVector *outputVector)
{
+ // get the info objects
+ vtkInformation *inInfo = inputVector[0]->GetInformationObject(0);
+ vtkInformation *outInfo = outputVector->GetInformationObject(0);
+
+ // get the input and ouptut
+ vtkDataSet *input = vtkDataSet::SafeDownCast(
+ inInfo->Get(vtkDataObject::DATA_OBJECT()));
+ vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast(
+ outInfo->Get(vtkDataObject::DATA_OBJECT()));
+
vtkIdType ptId, numPts, numCells, i, cellId, newCellId, newId, *pointMap;
vtkIdList *cellPts;
vtkCell *cell;
vtkFloatingPointType multiplier;
vtkPoints *newPts;
vtkIdList *newCellPts;
- vtkDataSet *input = this->GetInput();
vtkPointData *pd = input->GetPointData();
vtkCellData *cd = input->GetCellData();
- vtkUnstructuredGrid *output = this->GetOutput();
vtkPointData *outputPD = output->GetPointData();
vtkCellData *outputCD = output->GetCellData();
int npts;
if ( ! this->ImplicitFunction )
{
vtkErrorMacro(<<"No implicit function specified");
- return;
+ return 0;
}
newCellPts = vtkIdList::New();
{
newId = newPts->InsertNextPoint(x);
pointMap[ptId] = newId;
- if(myStoreMapping)
- myNodeVTK2ObjIds.push_back(ptId);
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
outputPD->CopyData(pd,ptId,newId);
}
}
{
newId = newPts->InsertNextPoint(x);
pointMap[ptId] = newId;
- if(myStoreMapping)
- myNodeVTK2ObjIds.push_back(ptId);
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
outputPD->CopyData(pd,ptId,newId);
}
}
x = input->GetPoint(ptId);
newId = newPts->InsertNextPoint(x);
pointMap[ptId] = newId;
- if(myStoreMapping)
- myNodeVTK2ObjIds.push_back(ptId);
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
outputPD->CopyData(pd,ptId,newId);
}
newCellPts->InsertId(i,pointMap[ptId]);
{
newCellId = output->InsertNextCell(cell->GetCellType(),newCellPts);
if(myStoreMapping)
- myElemVTK2ObjIds.push_back(cellId);
+ myElemVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}//for all cells
}
output->Squeeze();
+
+ return 1;
}