mirror of
https://github.com/microsoft/vcpkg.git
synced 2024-11-27 14:49:00 +08:00
394 lines
14 KiB
Diff
394 lines
14 KiB
Diff
|
diff --git a/Accelerators/Vtkm/Filters/CMakeLists.txt b/Accelerators/Vtkm/Filters/CMakeLists.txt
|
||
|
index 14e84f1dd6e8b9da275045fe5d80868b2e52ad5a..3a41bc4d2bffca8c3df79da218443b90f8ceb7d3 100644
|
||
|
--- a/Accelerators/Vtkm/Filters/CMakeLists.txt
|
||
|
+++ b/Accelerators/Vtkm/Filters/CMakeLists.txt
|
||
|
@@ -46,6 +46,10 @@ foreach (class IN LISTS impl_classes)
|
||
|
list(APPEND headers "${class}.h")
|
||
|
endforeach ()
|
||
|
|
||
|
+list(APPEND sources
|
||
|
+ "vtkmClipInstantiationsWithField.cxx"
|
||
|
+ "vtkmClipInstantiationsWithImplicitFunction.cxx")
|
||
|
+
|
||
|
configure_file(
|
||
|
"${CMAKE_CURRENT_SOURCE_DIR}/vtkmConfigFilters.h.in"
|
||
|
"${CMAKE_CURRENT_BINARY_DIR}/vtkmConfigFilters.h"
|
||
|
diff --git a/Accelerators/Vtkm/Filters/vtkmClip.cxx b/Accelerators/Vtkm/Filters/vtkmClip.cxx
|
||
|
index 0b1dc86d3bedd425d4846f524818a68ada052ce9..65fec3110ebb6522900cbc965c5298031921e1e4 100644
|
||
|
--- a/Accelerators/Vtkm/Filters/vtkmClip.cxx
|
||
|
+++ b/Accelerators/Vtkm/Filters/vtkmClip.cxx
|
||
|
@@ -14,6 +14,7 @@
|
||
|
=========================================================================*/
|
||
|
|
||
|
#include "vtkmClip.h"
|
||
|
+#include "vtkmClipInternals.h"
|
||
|
|
||
|
#include "vtkCellIterator.h"
|
||
|
#include "vtkDataArray.h"
|
||
|
@@ -36,11 +37,9 @@
|
||
|
|
||
|
#include "vtkmFilterPolicy.h"
|
||
|
|
||
|
+#include <vtkm/cont/DataSet.h>
|
||
|
#include <vtkm/cont/RuntimeDeviceTracker.h>
|
||
|
|
||
|
-#include <vtkm/filter/ClipWithField.h>
|
||
|
-#include <vtkm/filter/ClipWithImplicitFunction.h>
|
||
|
-
|
||
|
#include <algorithm>
|
||
|
|
||
|
vtkStandardNewMacro(vtkmClip);
|
||
|
@@ -50,19 +49,17 @@ void vtkmClip::PrintSelf(std::ostream& os, vtkIndent indent)
|
||
|
{
|
||
|
this->Superclass::PrintSelf(os, indent);
|
||
|
|
||
|
- os << indent << "ClipValue: " << this->ClipValue << "\n";
|
||
|
+ os << indent << "ClipValue: " << this->GetClipValue() << "\n";
|
||
|
os << indent << "ClipFunction: \n";
|
||
|
- this->ClipFunction->PrintSelf(os, indent.GetNextIndent());
|
||
|
- os << indent << "ComputeScalars: " << this->ComputeScalars << "\n";
|
||
|
+ this->GetClipFunction()->PrintSelf(os, indent.GetNextIndent());
|
||
|
+ os << indent << "ComputeScalars: " << this->GetComputeScalars() << "\n";
|
||
|
}
|
||
|
|
||
|
//------------------------------------------------------------------------------
|
||
|
vtkmClip::vtkmClip()
|
||
|
- : ClipValue(0.)
|
||
|
- , ComputeScalars(true)
|
||
|
- , ClipFunction(nullptr)
|
||
|
- , ClipFunctionConverter(new tovtkm::ImplicitFunctionConverter)
|
||
|
+ : Internals(new vtkmClip::internals)
|
||
|
{
|
||
|
+ this->Internals->ClipFunctionConverter.reset(new tovtkm::ImplicitFunctionConverter());
|
||
|
// Clip active point scalars by default
|
||
|
this->SetInputArrayToProcess(
|
||
|
0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS, vtkDataSetAttributes::SCALARS);
|
||
|
@@ -75,24 +72,54 @@ vtkmClip::~vtkmClip() = default;
|
||
|
vtkMTimeType vtkmClip::GetMTime()
|
||
|
{
|
||
|
vtkMTimeType mTime = this->Superclass::GetMTime();
|
||
|
- if (this->ClipFunction)
|
||
|
+ if (this->GetClipFunction())
|
||
|
{
|
||
|
- mTime = std::max(mTime, this->ClipFunction->GetMTime());
|
||
|
+ mTime = std::max(mTime, this->GetClipFunction()->GetMTime());
|
||
|
}
|
||
|
return mTime;
|
||
|
}
|
||
|
|
||
|
+//------------------------------------------------------------------------------
|
||
|
+double vtkmClip::GetClipValue()
|
||
|
+{
|
||
|
+ return this->Internals->ClipValue;
|
||
|
+}
|
||
|
+
|
||
|
+//------------------------------------------------------------------------------
|
||
|
+void vtkmClip::SetClipValue(double val)
|
||
|
+{
|
||
|
+ this->Internals->ClipValue = val;
|
||
|
+}
|
||
|
+
|
||
|
+//------------------------------------------------------------------------------
|
||
|
+bool vtkmClip::GetComputeScalars()
|
||
|
+{
|
||
|
+ return this->Internals->ComputeScalars;
|
||
|
+}
|
||
|
+
|
||
|
+//------------------------------------------------------------------------------
|
||
|
+void vtkmClip::SetComputeScalars(bool val)
|
||
|
+{
|
||
|
+ this->Internals->ComputeScalars = val;
|
||
|
+}
|
||
|
+
|
||
|
//------------------------------------------------------------------------------
|
||
|
void vtkmClip::SetClipFunction(vtkImplicitFunction* clipFunction)
|
||
|
{
|
||
|
- if (this->ClipFunction != clipFunction)
|
||
|
+ if (this->GetClipFunction() != clipFunction)
|
||
|
{
|
||
|
- this->ClipFunction = clipFunction;
|
||
|
- this->ClipFunctionConverter->Set(clipFunction);
|
||
|
+ this->Internals->ClipFunction = clipFunction;
|
||
|
+ this->Internals->ClipFunctionConverter->Set(clipFunction);
|
||
|
this->Modified();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
+//------------------------------------------------------------------------------
|
||
|
+vtkImplicitFunction* vtkmClip::GetClipFunction()
|
||
|
+{
|
||
|
+ return this->Internals->ClipFunction;
|
||
|
+}
|
||
|
+
|
||
|
//------------------------------------------------------------------------------
|
||
|
int vtkmClip::RequestData(
|
||
|
vtkInformation*, vtkInformationVector** inInfoVec, vtkInformationVector* outInfoVec)
|
||
|
@@ -111,7 +138,7 @@ int vtkmClip::RequestData(
|
||
|
// Find the scalar array:
|
||
|
int assoc = this->GetInputArrayAssociation(0, inInfoVec);
|
||
|
vtkDataArray* scalars = this->GetInputArrayToProcess(0, inInfoVec);
|
||
|
- if (!this->ClipFunction &&
|
||
|
+ if (!this->GetClipFunction() &&
|
||
|
(assoc != vtkDataObject::FIELD_ASSOCIATION_POINTS || scalars == nullptr ||
|
||
|
scalars->GetName() == nullptr || scalars->GetName()[0] == '\0'))
|
||
|
{
|
||
|
@@ -129,37 +156,18 @@ int vtkmClip::RequestData(
|
||
|
{
|
||
|
// Convert inputs to vtkm objects:
|
||
|
auto fieldsFlag =
|
||
|
- this->ComputeScalars ? tovtkm::FieldsFlag::PointsAndCells : tovtkm::FieldsFlag::None;
|
||
|
+ this->GetComputeScalars() ? tovtkm::FieldsFlag::PointsAndCells : tovtkm::FieldsFlag::None;
|
||
|
auto in = tovtkm::Convert(input, fieldsFlag);
|
||
|
|
||
|
// Run filter:
|
||
|
vtkm::cont::DataSet result;
|
||
|
- if (this->ClipFunction)
|
||
|
+ if (this->GetClipFunction())
|
||
|
{
|
||
|
- vtkm::filter::ClipWithImplicitFunction functionFilter;
|
||
|
- auto function = this->ClipFunctionConverter->Get();
|
||
|
- if (function.GetValid())
|
||
|
- {
|
||
|
- functionFilter.SetImplicitFunction(function);
|
||
|
- result = functionFilter.Execute(in);
|
||
|
- }
|
||
|
+ result = this->Internals->ExecuteClipWithImplicitFunction(in);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
- vtkm::filter::ClipWithField fieldFilter;
|
||
|
- if (!this->ComputeScalars)
|
||
|
- {
|
||
|
- // explicitly convert just the field we need
|
||
|
- auto inField = tovtkm::Convert(scalars, assoc);
|
||
|
- in.AddField(inField);
|
||
|
- // don't pass this field
|
||
|
- fieldFilter.SetFieldsToPass(
|
||
|
- vtkm::filter::FieldSelection(vtkm::filter::FieldSelection::MODE_NONE));
|
||
|
- }
|
||
|
-
|
||
|
- fieldFilter.SetActiveField(scalars->GetName(), vtkm::cont::Field::Association::POINTS);
|
||
|
- fieldFilter.SetClipValue(this->ClipValue);
|
||
|
- result = fieldFilter.Execute(in);
|
||
|
+ result = this->Internals->ExecuteClipWithField(in, scalars, assoc);
|
||
|
}
|
||
|
|
||
|
// Convert result to output:
|
||
|
@@ -169,7 +177,7 @@ int vtkmClip::RequestData(
|
||
|
return 0;
|
||
|
}
|
||
|
|
||
|
- if (!this->ClipFunction && this->ComputeScalars)
|
||
|
+ if (!this->GetClipFunction() && this->GetComputeScalars())
|
||
|
{
|
||
|
output->GetPointData()->SetActiveScalars(scalars->GetName());
|
||
|
}
|
||
|
@@ -189,8 +197,8 @@ int vtkmClip::RequestData(
|
||
|
<< "Falling back to serial implementation.");
|
||
|
|
||
|
vtkNew<vtkTableBasedClipDataSet> filter;
|
||
|
- filter->SetClipFunction(this->ClipFunction);
|
||
|
- filter->SetValue(this->ClipValue);
|
||
|
+ filter->SetClipFunction(this->GetClipFunction());
|
||
|
+ filter->SetValue(this->GetClipValue());
|
||
|
filter->SetInputData(input);
|
||
|
filter->Update();
|
||
|
output->ShallowCopy(filter->GetOutput());
|
||
|
diff --git a/Accelerators/Vtkm/Filters/vtkmClip.h b/Accelerators/Vtkm/Filters/vtkmClip.h
|
||
|
index edb3cebfadc9ebeddf3c5030716ba532c0e149fe..6f33d36460d72de340eb81bb321ee868d70e6b5b 100644
|
||
|
--- a/Accelerators/Vtkm/Filters/vtkmClip.h
|
||
|
+++ b/Accelerators/Vtkm/Filters/vtkmClip.h
|
||
|
@@ -32,13 +32,6 @@
|
||
|
|
||
|
class vtkImplicitFunction;
|
||
|
|
||
|
-namespace tovtkm
|
||
|
-{
|
||
|
-
|
||
|
-class ImplicitFunctionConverter;
|
||
|
-
|
||
|
-} // namespace tovtkm
|
||
|
-
|
||
|
class VTKACCELERATORSVTKMFILTERS_EXPORT vtkmClip : public vtkUnstructuredGridAlgorithm
|
||
|
{
|
||
|
public:
|
||
|
@@ -50,15 +43,15 @@ public:
|
||
|
* The scalar value to use when clipping the dataset. Values greater than
|
||
|
* ClipValue are preserved in the output dataset. Default is 0.
|
||
|
*/
|
||
|
- vtkGetMacro(ClipValue, double);
|
||
|
- vtkSetMacro(ClipValue, double);
|
||
|
+ double GetClipValue();
|
||
|
+ void SetClipValue(double);
|
||
|
|
||
|
/**
|
||
|
* If true, all input point data arrays will be mapped onto the output
|
||
|
* dataset. Default is true.
|
||
|
*/
|
||
|
- vtkGetMacro(ComputeScalars, bool);
|
||
|
- vtkSetMacro(ComputeScalars, bool);
|
||
|
+ bool GetComputeScalars();
|
||
|
+ void SetComputeScalars(bool);
|
||
|
|
||
|
/**
|
||
|
* Set the implicit function with which to perform the clipping. If set,
|
||
|
@@ -66,7 +59,7 @@ public:
|
||
|
* function.
|
||
|
*/
|
||
|
void SetClipFunction(vtkImplicitFunction*);
|
||
|
- vtkGetObjectMacro(ClipFunction, vtkImplicitFunction);
|
||
|
+ vtkImplicitFunction* GetClipFunction();
|
||
|
|
||
|
vtkMTimeType GetMTime() override;
|
||
|
|
||
|
@@ -87,17 +80,13 @@ protected:
|
||
|
~vtkmClip() override;
|
||
|
|
||
|
int RequestData(vtkInformation*, vtkInformationVector**, vtkInformationVector*) override;
|
||
|
-
|
||
|
int FillInputPortInformation(int port, vtkInformation* info) override;
|
||
|
|
||
|
- double ClipValue;
|
||
|
- bool ComputeScalars;
|
||
|
-
|
||
|
- vtkImplicitFunction* ClipFunction;
|
||
|
- std::unique_ptr<tovtkm::ImplicitFunctionConverter> ClipFunctionConverter;
|
||
|
-
|
||
|
vtkTypeBool ForceVTKm = false;
|
||
|
|
||
|
+ struct internals;
|
||
|
+ std::unique_ptr<internals> Internals;
|
||
|
+
|
||
|
private:
|
||
|
vtkmClip(const vtkmClip&) = delete;
|
||
|
void operator=(const vtkmClip&) = delete;
|
||
|
diff --git a/Accelerators/Vtkm/Filters/vtkmClipInstantiationsWithField.cxx b/Accelerators/Vtkm/Filters/vtkmClipInstantiationsWithField.cxx
|
||
|
new file mode 100644
|
||
|
index 0000000000000000000000000000000000000000..e81b5cdab62a436ef09afac33ffa0599cb9dd2a8
|
||
|
--- /dev/null
|
||
|
+++ b/Accelerators/Vtkm/Filters/vtkmClipInstantiationsWithField.cxx
|
||
|
@@ -0,0 +1,39 @@
|
||
|
+/*=========================================================================
|
||
|
+
|
||
|
+ Program: Visualization Toolkit
|
||
|
+ Module: vtkmClipInstantiationsWithField.cxx
|
||
|
+
|
||
|
+ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
|
+ All rights reserved.
|
||
|
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
+
|
||
|
+ This software is distributed WITHOUT ANY WARRANTY; without even
|
||
|
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
|
+ PURPOSE. See the above copyright notice for more information.
|
||
|
+
|
||
|
+=========================================================================*/
|
||
|
+
|
||
|
+#include "vtkmClipInternals.h"
|
||
|
+#include "vtkmlib/DataSetConverters.h"
|
||
|
+
|
||
|
+#include <vtkm/filter/ClipWithField.h>
|
||
|
+
|
||
|
+//------------------------------------------------------------------------------
|
||
|
+vtkm::cont::DataSet vtkmClip::internals::ExecuteClipWithField(
|
||
|
+ vtkm::cont::DataSet& in, vtkDataArray* scalars, int assoc)
|
||
|
+{
|
||
|
+ vtkm::filter::ClipWithField fieldFilter;
|
||
|
+ if (!this->ComputeScalars)
|
||
|
+ {
|
||
|
+ // explicitly convert just the field we need
|
||
|
+ auto inField = tovtkm::Convert(scalars, assoc);
|
||
|
+ in.AddField(inField);
|
||
|
+ // don't pass this field
|
||
|
+ fieldFilter.SetFieldsToPass(
|
||
|
+ vtkm::filter::FieldSelection(vtkm::filter::FieldSelection::MODE_NONE));
|
||
|
+ }
|
||
|
+
|
||
|
+ fieldFilter.SetActiveField(scalars->GetName(), vtkm::cont::Field::Association::POINTS);
|
||
|
+ fieldFilter.SetClipValue(this->ClipValue);
|
||
|
+ return fieldFilter.Execute(in);
|
||
|
+}
|
||
|
diff --git a/Accelerators/Vtkm/Filters/vtkmClipInstantiationsWithImplicitFunction.cxx b/Accelerators/Vtkm/Filters/vtkmClipInstantiationsWithImplicitFunction.cxx
|
||
|
new file mode 100644
|
||
|
index 0000000000000000000000000000000000000000..04a637a92d487b019742bbf81884750c48ba105d
|
||
|
--- /dev/null
|
||
|
+++ b/Accelerators/Vtkm/Filters/vtkmClipInstantiationsWithImplicitFunction.cxx
|
||
|
@@ -0,0 +1,35 @@
|
||
|
+/*=========================================================================
|
||
|
+
|
||
|
+ Program: Visualization Toolkit
|
||
|
+ Module: vtkmClipInstantiationsWithImplicitFunction.cxx
|
||
|
+
|
||
|
+ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
|
+ All rights reserved.
|
||
|
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
+
|
||
|
+ This software is distributed WITHOUT ANY WARRANTY; without even
|
||
|
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
|
+ PURPOSE. See the above copyright notice for more information.
|
||
|
+
|
||
|
+=========================================================================*/
|
||
|
+
|
||
|
+#include "vtkmClipInternals.h"
|
||
|
+#include "vtkmlib/DataSetConverters.h"
|
||
|
+
|
||
|
+#include <vtkm/filter/ClipWithImplicitFunction.h>
|
||
|
+
|
||
|
+//------------------------------------------------------------------------------
|
||
|
+vtkm::cont::DataSet vtkmClip::internals::ExecuteClipWithImplicitFunction(vtkm::cont::DataSet& in)
|
||
|
+{
|
||
|
+ auto function = this->ClipFunctionConverter->Get();
|
||
|
+
|
||
|
+ vtkm::cont::DataSet result;
|
||
|
+ if (function.GetValid())
|
||
|
+ {
|
||
|
+ vtkm::filter::ClipWithImplicitFunction functionFilter;
|
||
|
+ functionFilter.SetImplicitFunction(function);
|
||
|
+ result = functionFilter.Execute(in);
|
||
|
+ }
|
||
|
+
|
||
|
+ return result;
|
||
|
+}
|
||
|
diff --git a/Accelerators/Vtkm/Filters/vtkmClipInternals.h b/Accelerators/Vtkm/Filters/vtkmClipInternals.h
|
||
|
new file mode 100644
|
||
|
index 0000000000000000000000000000000000000000..5384347bf9d48f04f5d2847753c92b64fc82346e
|
||
|
--- /dev/null
|
||
|
+++ b/Accelerators/Vtkm/Filters/vtkmClipInternals.h
|
||
|
@@ -0,0 +1,37 @@
|
||
|
+/*=========================================================================
|
||
|
+
|
||
|
+ Program: Visualization Toolkit
|
||
|
+ Module: vtkmClipInternals.h
|
||
|
+
|
||
|
+ Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
|
||
|
+ All rights reserved.
|
||
|
+ See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
|
||
|
+
|
||
|
+ This software is distributed WITHOUT ANY WARRANTY; without even
|
||
|
+ the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||
|
+ PURPOSE. See the above copyright notice for more information.
|
||
|
+
|
||
|
+=========================================================================*/
|
||
|
+
|
||
|
+#ifndef vtkmClipInternals_h
|
||
|
+#define vtkmClipInternals_h
|
||
|
+
|
||
|
+#include "vtkDataArray.h"
|
||
|
+#include "vtkmClip.h"
|
||
|
+#include "vtkmlib/ImplicitFunctionConverter.h"
|
||
|
+
|
||
|
+#include <vtkm/cont/DataSet.h>
|
||
|
+
|
||
|
+struct vtkmClip::internals
|
||
|
+{
|
||
|
+ double ClipValue = .0;
|
||
|
+ bool ComputeScalars = true;
|
||
|
+
|
||
|
+ vtkImplicitFunction* ClipFunction = nullptr;
|
||
|
+ std::unique_ptr<tovtkm::ImplicitFunctionConverter> ClipFunctionConverter;
|
||
|
+
|
||
|
+ vtkm::cont::DataSet ExecuteClipWithImplicitFunction(vtkm::cont::DataSet&);
|
||
|
+ vtkm::cont::DataSet ExecuteClipWithField(vtkm::cont::DataSet&, vtkDataArray*, int);
|
||
|
+};
|
||
|
+
|
||
|
+#endif
|