diff --git a/smtk/bridge/discrete/CMakeLists.txt b/smtk/bridge/discrete/CMakeLists.txt index 802d5ed32ff527684b4fcf741f1fbd185bc93fc4..25d094d3a53175c1e594b7448f7068041f26332d 100644 --- a/smtk/bridge/discrete/CMakeLists.txt +++ b/smtk/bridge/discrete/CMakeLists.txt @@ -47,7 +47,6 @@ SET(DiscreteModelFiles ) SET(DiscreteOperationFiles - operation/vtkCMBApplyBathymetryFilter.cxx operation/vtkCMBModelPointsOperator.cxx operation/vtkEdgeSplitOperator.cxx operation/vtkEdgeSplitOperatorBase.cxx @@ -75,7 +74,6 @@ SET(DiscreteOperationFiles ) SET(DiscreteModelHeaders - operation/vtkCMBApplyBathymetryFilter.h operation/vtkCMBModelPointsOperator.h operation/vtkCMBMapToCMBModel.h operation/vtkCMBModelBuilder.h @@ -225,6 +223,7 @@ target_link_libraries(smtkDiscreteSession vtkPVVTKExtensionsDefault vtkSMTKReaderExt vtkSMTKDiscreteModel + vtkSMTKFilterExt ) if (SMTK_ENABLE_REMUS_SUPPORT) diff --git a/smtk/bridge/discrete/operators/BathymetryOperator.cxx b/smtk/bridge/discrete/operators/BathymetryOperator.cxx index 8e003401747143d5fe3d6b7e002e9cfc9277cedf..714fe35803f776a5275a96f5328c19186b78c550 100644 --- a/smtk/bridge/discrete/operators/BathymetryOperator.cxx +++ b/smtk/bridge/discrete/operators/BathymetryOperator.cxx @@ -12,7 +12,7 @@ #include "smtk/bridge/discrete/Session.h" #include "smtk/bridge/discrete/BathymetryHelper.h" -#include "smtk/bridge/discrete/operation/vtkCMBApplyBathymetryFilter.h" +#include "smtk/extension/vtk/filter/vtkCMBApplyBathymetryFilter.h" #include "smtk/attribute/Attribute.h" #include "smtk/attribute/Definition.h" diff --git a/smtk/extension/vtk/filter/CMakeLists.txt b/smtk/extension/vtk/filter/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..8de4f11dbbb79c3443dfa79e4180e6237cca29ed --- /dev/null +++ b/smtk/extension/vtk/filter/CMakeLists.txt @@ -0,0 +1,31 @@ + +set(srcs + vtkCMBApplyBathymetryFilter.cxx + ) + +set(headers + vtkCMBApplyBathymetryFilter.h +) + +set(${vtk-module}_NO_HeaderTest 1) +set(VTK_INSTALL_NO_HEADERS 1) +vtk_module_library(${vtk-module} ${srcs}) +target_include_directories(${vtk-module} + PUBLIC + $ + $ + $) + +# ... and make header compilation tests link properly: +smtk_install_library(${vtk-module}) + +# ... and install the export header +#has to be after the vtk_module_library +smtk_export_header(${vtk-module} Exports.h) + +if (SMTK_ENABLE_PARAVIEW_SUPPORT) + vtk_add_cs_wrapping(${vtk-module}) + smtk_install_library(${vtk-module}CS) +endif () + +smtk_public_headers(${headers}) diff --git a/smtk/extension/vtk/filter/module.cmake b/smtk/extension/vtk/filter/module.cmake new file mode 100644 index 0000000000000000000000000000000000000000..8c088e7432cf0d31549293b7a356a82a6ffd4905 --- /dev/null +++ b/smtk/extension/vtk/filter/module.cmake @@ -0,0 +1,11 @@ +set (__dependencies) + +vtk_module(vtkSMTKFilterExt + DEPENDS + vtkCommonCore + PRIVATE_DEPENDS + vtkFiltersGeneral + ${__dependencies} + TEST_DEPENDS + EXCLUDE_FROM_WRAP_HIERARCHY +) diff --git a/smtk/bridge/discrete/operation/vtkCMBApplyBathymetryFilter.cxx b/smtk/extension/vtk/filter/vtkCMBApplyBathymetryFilter.cxx similarity index 88% rename from smtk/bridge/discrete/operation/vtkCMBApplyBathymetryFilter.cxx rename to smtk/extension/vtk/filter/vtkCMBApplyBathymetryFilter.cxx index 9abe1cd7157cc29cacc0cd5e1cd5cd2e5d4a853c..1a4f687b6bedf996d7c15f167cc7f16353192438 100644 --- a/smtk/bridge/discrete/operation/vtkCMBApplyBathymetryFilter.cxx +++ b/smtk/extension/vtk/filter/vtkCMBApplyBathymetryFilter.cxx @@ -7,8 +7,7 @@ // the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR // PURPOSE. See the above copyright notice for more information. //========================================================================= - -#include "smtk/bridge/discrete/operation/vtkCMBApplyBathymetryFilter.h" +#include "smtk/extension/vtk/filter/vtkCMBApplyBathymetryFilter.h" #include "vtkCellArray.h" #include "vtkCellData.h" @@ -45,7 +44,7 @@ namespace{ } template void copyArrayZValues(T *t, vtkIdType size, - std::map& idToElevation, + std::vector& idToElevation, bool useHighLimit, double eleHigh, bool useLowLimit, double eleLow) { double dtmp; @@ -62,7 +61,7 @@ namespace{ class vtkCMBApplyBathymetryFilter::vtkCmbInternalTerrainInfo { public: - vtkCmbInternalTerrainInfo(vtkInformation* input, const double &radius, + vtkCmbInternalTerrainInfo(vtkInformation* input, const double &radius, double &invalid, bool useHighLimit, double eleHigh, bool useLowLimit, double eleLow); ~vtkCmbInternalTerrainInfo() { @@ -76,17 +75,19 @@ public: Radius = r; } - std::map IdToElevation; + std::vector IdToElevation; protected: double Radius; + double InvalidValue; vtkSmartPointer Locator; }; //----------------------------------------------------------------------------- vtkCMBApplyBathymetryFilter::vtkCmbInternalTerrainInfo::vtkCmbInternalTerrainInfo( - vtkInformation* inInfo, const double &radius, - bool useHighLimit, double eleHigh, bool useLowLimit, double eleLow): Radius(radius) - { + vtkInformation* inInfo, const double &radius, double &invalid, + bool useHighLimit, double eleHigh, bool useLowLimit, double eleLow) +: Radius(radius), InvalidValue(invalid) +{ //1. Create a set of points while removing all the z values from the points //and storing them in the map. //2. Create locater of the resulting 2D point set @@ -118,10 +119,10 @@ vtkCMBApplyBathymetryFilter::vtkCmbInternalTerrainInfo::vtkCmbInternalTerrainInf //second iteration is building the point set and elevation mapping vtkPoints *inputPoints = NULL; vtkPoints *points = vtkPoints::New(); - vtkIdType size, i, j; + vtkIdType size, i; double p[3]; double dtmp; - // Uniform Grids may not have the max number of points + // Uniform Grids may not have the max number of points if (gridInput) { vtkDataArray *dataArray = gridInput->GetPointData()->GetScalars("Elevation"); @@ -129,7 +130,9 @@ vtkCMBApplyBathymetryFilter::vtkCmbInternalTerrainInfo::vtkCmbInternalTerrainInf { return; } - points->Allocate(numPoints); + points->SetNumberOfPoints(numPoints); + this->IdToElevation.resize(numPoints); + vtkIdType at = 0; for (i = 0; numPoints; i++) { if (!gridInput->IsPointVisible(i)) @@ -143,9 +146,12 @@ vtkCMBApplyBathymetryFilter::vtkCmbInternalTerrainInfo::vtkCmbInternalTerrainInf //flatten z p[2] = 0.0; - j = points->InsertNextPoint(p); - this->IdToElevation[j]=dtmp; + points->SetPoint(at, p); + this->IdToElevation[at]=dtmp; + ++at; } + points->Resize(at); + this->IdToElevation.resize(at); } else { @@ -154,6 +160,8 @@ vtkCMBApplyBathymetryFilter::vtkCmbInternalTerrainInfo::vtkCmbInternalTerrainInf { inputPoints = pd->GetPoints(); size = inputPoints->GetNumberOfPoints(); + points->SetNumberOfPoints(size); + this->IdToElevation.resize(size); for (i=0; i < size; ++i) { //get the point @@ -164,12 +172,14 @@ vtkCMBApplyBathymetryFilter::vtkCmbInternalTerrainInfo::vtkCmbInternalTerrainInf //store the z value & flatten this->IdToElevation[i]=dtmp; p[2] = 0.0; - points->InsertPoint(i,p); + points->SetPoint(i,p); } } else if(imageInput) { size = imageInput->GetNumberOfPoints(); + points->SetNumberOfPoints(size); + this->IdToElevation.resize(size); vtkDataArray *dataArray = imageInput->GetPointData()->GetScalars("Elevation"); if(!dataArray || dataArray->GetNumberOfTuples() != size) { @@ -197,7 +207,7 @@ vtkCMBApplyBathymetryFilter::vtkCmbInternalTerrainInfo::vtkCmbInternalTerrainInf //flatten z p[2] = 0.0; - points->InsertPoint(i,p); + points->SetPoint(i,p); } } } @@ -230,16 +240,13 @@ T vtkCMBApplyBathymetryFilter::vtkCmbInternalTerrainInfo::getElevation( for ( vtkIdType i=0; i < size; ++i) { //average the elevation - it = this->IdToElevation.find(ids->GetId(i)); - if ( it != this->IdToElevation.end() ) - { - sum += it->second; - } + assert(ids->GetId(i)IdToElevation.size()); + sum += this->IdToElevation[ids->GetId(i)]; } ids->Delete(); //handle the zero size use case - T elev = static_cast((size == 0) ? dpoint[2] : sum/size); + T elev = static_cast((size == 0) ? InvalidValue : sum/size); return elev; } @@ -255,6 +262,7 @@ vtkCMBApplyBathymetryFilter::vtkCMBApplyBathymetryFilter() this->UseHighestZValue = false; this->UseLowestZValue = false; this->HighestZValue=this->LowestZValue=0.0; + this->InvalidValue = 0.0; } //----------------------------------------------------------------------------- @@ -268,7 +276,7 @@ vtkCMBApplyBathymetryFilter::~vtkCMBApplyBathymetryFilter() //---------------------------------------------------------------------------- int vtkCMBApplyBathymetryFilter::FillInputPortInformation(int port, - vtkInformation *info) + vtkInformation *info) { info->Set(vtkAlgorithm::INPUT_REQUIRED_DATA_TYPE(), "vtkDataSet"); info->Set(vtkAlgorithm::INPUT_IS_REPEATABLE(), 1); @@ -293,8 +301,8 @@ void vtkCMBApplyBathymetryFilter::RemoveSourceConnections() //---------------------------------------------------------------------------- int vtkCMBApplyBathymetryFilter::RequestData(vtkInformation* /*request*/, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector) + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { // get the info and input data vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); @@ -327,9 +335,9 @@ int vtkCMBApplyBathymetryFilter::RequestData(vtkInformation* /*request*/, //Construct the TerrainInfo first this->TerrainInfo = new vtkCmbInternalTerrainInfo( inputVector[1]->GetInformationObject(0), - this->ElevationRadius, this->UseHighestZValue, + this->ElevationRadius, this->InvalidValue, this->UseHighestZValue, this->HighestZValue, this->UseLowestZValue, this->LowestZValue); - if(this->TerrainInfo->IdToElevation.size()>0) + if(!this->TerrainInfo->IdToElevation.empty()) { validMesh = this->ApplyBathymetry(finalMesh->GetPoints()); } @@ -416,4 +424,5 @@ void vtkCMBApplyBathymetryFilter::PrintSelf(ostream& os, vtkIndent indent) os << indent << "ElevationRadius: " << this->ElevationRadius << std::endl; os << indent << "FlatZValue: " << this->FlatZValue << std::endl; os << indent << "FlattenZValues: " << this->FlattenZValues << std::endl; -} + os << indent << "InvalidValue: " << this->InvalidValue << std::endl; +} \ No newline at end of file diff --git a/smtk/bridge/discrete/operation/vtkCMBApplyBathymetryFilter.h b/smtk/extension/vtk/filter/vtkCMBApplyBathymetryFilter.h similarity index 91% rename from smtk/bridge/discrete/operation/vtkCMBApplyBathymetryFilter.h rename to smtk/extension/vtk/filter/vtkCMBApplyBathymetryFilter.h index ba35a89ebfda0ae0a2ab052bcdcb6a2b78cabe92..4fc7209df9f39786ee5ba77d614616c2ec07ba90 100644 --- a/smtk/bridge/discrete/operation/vtkCMBApplyBathymetryFilter.h +++ b/smtk/extension/vtk/filter/vtkCMBApplyBathymetryFilter.h @@ -14,12 +14,12 @@ #ifndef __smtkdiscrete_vtkCMBApplyBathymetryFilter_h #define __smtkdiscrete_vtkCMBApplyBathymetryFilter_h -#include "smtk/bridge/discrete/Exports.h" // For export macro +#include "smtk/extension/vtk/filter/Exports.h" // For export macro #include "vtkDataSetAlgorithm.h" class vtkPoints; -class SMTKDISCRETESESSION_EXPORT vtkCMBApplyBathymetryFilter : public vtkDataSetAlgorithm +class VTKSMTKFILTEREXT_EXPORT vtkCMBApplyBathymetryFilter : public vtkDataSetAlgorithm { public: static vtkCMBApplyBathymetryFilter *New(); @@ -75,6 +75,11 @@ public: vtkSetMacro(NoOP, bool); vtkGetMacro(NoOP, bool); + // Description: + // Value for when bathymetry field has no supporting data + vtkSetMacro(InvalidValue, double); + vtkGetMacro(InvalidValue, double); + //Description: //Remove all connections on port 0, dataset that will be altered //with bathymetry @@ -108,6 +113,7 @@ protected: double FlatZValue; bool FlattenZValues; bool NoOP; + double InvalidValue; class vtkCmbInternalTerrainInfo; vtkCmbInternalTerrainInfo *TerrainInfo;