31 #include <vtkCellData.h> 32 #include <vtkCellIterator.h> 33 #include <vtkDoubleArray.h> 34 #include <vtkIdList.h> 44 :
SizeFieldBase(_ds, arrayID, _dev_mult, _maxIsmin,
"ValueSF") {
45 std::cout <<
"ValSizeField constructed" << std::endl;
53 int dim = da->GetNumberOfComponents();
54 std::vector<double> values(dim, 0.0);
55 int numPointsInCell = cell_point_ids->GetNumberOfIds();
57 for (
int j = 0; j < numPointsInCell; ++j) {
58 std::vector<double> comps(dim);
59 da->GetTuple(cell_point_ids->GetId(j), comps.data());
60 for (
int i = 0; i < dim; ++i) {
61 values[i] += comps[i] / numPointsInCell;
70 vtkDataSet *
ds, vtkDataArray *
da) {
71 std::vector<std::vector<double>> result;
72 result.reserve(ds->GetNumberOfCells());
74 vtkCellIterator *it = ds->NewCellIterator();
75 for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) {
86 std::vector<double> result;
87 result.reserve(ds->GetNumberOfCells());
89 vtkCellIterator *it = ds->NewCellIterator();
90 for (it->InitTraversal(); !it->IsDoneWithTraversal(); it->GoToNextCell()) {
104 if (values.empty()) {
105 std::cerr <<
"size array hasn't been populated!" << std::endl;
112 da2->SetName(
sfname.c_str());
113 da2->SetNumberOfComponents(1);
114 for (vtkIdType i = 0; i <
ds->GetNumberOfCells(); ++i)
115 da2->InsertNextTypedTuple(&values[i]);
116 ds->GetCellData()->AddArray(da2);
vtkSmartPointer< vtkDataSet > ds
geoMeshBase * New(MeshType meshType)
Create a new mesh object.
vtkSmartPointer< vtkDataArray > da
static std::vector< double > computeValAtCell(vtkIdList *cell_point_ids, vtkDataArray *da)
ValSizeField(vtkDataSet *_ds, int arrayID, double _dev_mult, bool _maxIsmin)
void mutateValues(std::vector< double > &values) const
static std::vector< std::vector< double > > computeValAtAllCells(vtkDataSet *ds, vtkDataArray *da)
void computeSizeField(vtkDataArray *da) override
static std::vector< double > computeL2ValAtAllCells(vtkDataSet *ds, vtkDataArray *da)
T l2_Norm(const std::vector< T > &x)