// 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
+// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
#include "SALOME_ExtractGeometry.h"
using namespace std;
+#if defined __GNUC__
+ #if __GNUC__ == 2
+ #define __GNUC_2__
+ #endif
+#endif
+
+//----------------------------------------------------------------------------
vtkStandardNewMacro(SALOME_ExtractGeometry);
-SALOME_ExtractGeometry::SALOME_ExtractGeometry()
+//----------------------------------------------------------------------------
+SALOME_ExtractGeometry
+::SALOME_ExtractGeometry():
+ myStoreMapping(false),
+ myIsDoneShallowCopy(false)
{}
-
-SALOME_ExtractGeometry::~SALOME_ExtractGeometry(){}
+SALOME_ExtractGeometry
+::~SALOME_ExtractGeometry()
+{}
-vtkIdType SALOME_ExtractGeometry::GetElemObjId(int theID){
- if(myElemVTK2ObjIds.empty() || theID > myElemVTK2ObjIds.size())
- return theID;
- return myElemVTK2ObjIds[theID];
+//----------------------------------------------------------------------------
+unsigned long int
+SALOME_ExtractGeometry
+::GetMTime()
+{
+ unsigned long int aTime = vtkExtractGeometry::GetMTime();
+ return aTime;
}
-vtkIdType SALOME_ExtractGeometry::GetNodeObjId(int theID){
- if(myNodeVTK2ObjIds.empty() || theID > myNodeVTK2ObjIds.size())
- return theID;
- return myNodeVTK2ObjIds[theID];
+//----------------------------------------------------------------------------
+vtkImplicitBoolean*
+SALOME_ExtractGeometry
+::GetImplicitBoolean()
+{
+ return myImplicitBoolean.GetPointer();
}
-void SALOME_ExtractGeometry::SetImplicitBoolean(vtkImplicitBoolean* theImplicitBoolean)
+void
+SALOME_ExtractGeometry
+::SetImplicitFunction(vtkImplicitFunction* theImplicitFunction)
{
- myImplicitBoolean = theImplicitBoolean;
- SetImplicitFunction(theImplicitBoolean);
+ myImplicitBoolean = dynamic_cast<vtkImplicitBoolean*>(theImplicitFunction);
+ vtkExtractGeometry::SetImplicitFunction(theImplicitFunction);
}
-void SALOME_ExtractGeometry::SetStoreMapping(bool theStoreMapping)
+//----------------------------------------------------------------------------
+void
+SALOME_ExtractGeometry
+::SetStoreMapping(bool theStoreMapping)
{
myStoreMapping = theStoreMapping;
Modified();
}
+bool
+SALOME_ExtractGeometry
+::GetStoreMapping() const
+{
+ return myStoreMapping;
+}
-void SALOME_ExtractGeometry::Execute()
+
+//----------------------------------------------------------------------------
+vtkIdType
+SALOME_ExtractGeometry
+::GetElemVTKId(vtkIdType theID)
{
- if(myImplicitBoolean.GetPointer()){
+ if(!myStoreMapping||myIsDoneShallowCopy){
+ return theID;
+ }
+ vtkIdType iEnd = myElemVTK2ObjIds.size();
+ for(vtkIdType i = 0; i < iEnd; i++)
+ if(myElemVTK2ObjIds[i] == theID)
+ return i;
+
+ return -1;
+}
+
+vtkIdType
+SALOME_ExtractGeometry
+::GetNodeVTKId(vtkIdType theID)
+{
+ if (!myStoreMapping||myIsDoneShallowCopy){
+ return theID;
+ }
+ vtkIdType iEnd = myNodeVTK2ObjIds.size();
+ for(vtkIdType i = 0; i < iEnd; i++)
+ if(myNodeVTK2ObjIds[i] == theID)
+ return i;
+
+ return -1;
+}
+
+
+//----------------------------------------------------------------------------
+vtkIdType
+SALOME_ExtractGeometry
+::GetElemObjId(int theVtkID)
+{
+ if (!myStoreMapping||myIsDoneShallowCopy){
+ return theVtkID;
+ }
+ //
+ if (theVtkID<myElemVTK2ObjIds.size()){
+ return myElemVTK2ObjIds[theVtkID];
+ }
+ return -1;
+}
+
+
+vtkIdType
+SALOME_ExtractGeometry
+::GetNodeObjId(int theVtkID)
+{
+ if (!myStoreMapping||myIsDoneShallowCopy){
+ return theVtkID;
+ }
+ //
+ if (theVtkID<myNodeVTK2ObjIds.size()){
+ return myNodeVTK2ObjIds[theVtkID];
+ }
+ return -1;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SALOME_ExtractGeometry
+::Execute()
+{
+ myElemVTK2ObjIds.clear();
+ myNodeVTK2ObjIds.clear();
+ //
+ myIsDoneShallowCopy = !this->ImplicitFunction;
+
+ if(!myIsDoneShallowCopy && myImplicitBoolean.GetPointer()){
if(vtkImplicitFunctionCollection* aFunction = myImplicitBoolean->GetFunction()){
- if(aFunction->GetNumberOfItems() == 0){
- vtkDebugMacro(<< "Extracting geometry - ShallowCopy");
- GetOutput()->ShallowCopy(GetInput());
- return;
- }
+ myIsDoneShallowCopy = aFunction->GetNumberOfItems() == 0;
}
}
+
+ if(myIsDoneShallowCopy){
+ GetOutput()->ShallowCopy(GetInput());
+ Modified();
+ return;
+ }
+
Execute2();
}
-void SALOME_ExtractGeometry::Execute2()
+void
+SALOME_ExtractGeometry
+::Execute2()
{
vtkIdType ptId, numPts, numCells, i, cellId, newCellId, newId, *pointMap;
vtkIdList *cellPts;
vtkCell *cell;
int numCellPts;
- float *x;
- float multiplier;
+ vtkFloatingPointType *x;
+ vtkFloatingPointType multiplier;
vtkPoints *newPts;
vtkIdList *newCellPts;
vtkDataSet *input = this->GetInput();
int npts;
numCells = input->GetNumberOfCells();
numPts = input->GetNumberOfPoints();
-
- vtkDebugMacro(<< "Extracting geometry");
if ( ! this->ImplicitFunction )
{
{
multiplier = 1.0;
}
- else
+ else
{
multiplier = -1.0;
}
outputPD->CopyAllocate(pd);
outputCD->CopyAllocate(cd);
vtkFloatArray *newScalars = NULL;
-
+
if(myStoreMapping){
- myElemVTK2ObjIds.clear();
myElemVTK2ObjIds.reserve(numCells);
- myNodeVTK2ObjIds.clear();
myNodeVTK2ObjIds.reserve(numPts);
}
{
newId = newPts->InsertNextPoint(x);
pointMap[ptId] = newId;
- myNodeVTK2ObjIds.push_back(ptId);
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
outputPD->CopyData(pd,ptId,newId);
}
}
// To extract boundary cells, we have to create supplemental information
if ( this->ExtractBoundaryCells )
{
- float val;
+ vtkFloatingPointType val;
newScalars = vtkFloatArray::New();
newScalars->SetNumberOfValues(numPts);
{
newId = newPts->InsertNextPoint(x);
pointMap[ptId] = newId;
- myNodeVTK2ObjIds.push_back(ptId);
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
outputPD->CopyData(pd,ptId,newId);
}
}
}
}
} //if don't want to extract boundary cells
-
+
else //want boundary cells
{
for ( npts=0, i=0; i < numCellPts; i++ )
x = input->GetPoint(ptId);
newId = newPts->InsertNextPoint(x);
pointMap[ptId] = newId;
- myNodeVTK2ObjIds.push_back(ptId);
+ if(myStoreMapping)
+ myNodeVTK2ObjIds.push_back(ptId);
outputPD->CopyData(pd,ptId,newId);
}
newCellPts->InsertId(i,pointMap[ptId]);
}
}//a boundary or interior cell
}//if mapping boundary cells
-
+
if ( npts >= numCellPts || (this->ExtractBoundaryCells && npts > 0) )
{
newCellId = output->InsertNextCell(cell->GetCellType(),newCellPts);
- myElemVTK2ObjIds.push_back(cellId);
+ if(myStoreMapping)
+ myElemVTK2ObjIds.push_back(cellId);
outputCD->CopyData(cd,cellId,newCellId);
}
}//for all cells
newCellPts->Delete();
output->SetPoints(newPts);
newPts->Delete();
-
+
if ( this->ExtractBoundaryCells )
{
newScalars->Delete();