Skip to main content
  • Home
  • Development
  • Documentation
  • Donate
  • Operational login
  • Browse the archive

swh logo
SoftwareHeritage
Software
Heritage
Archive
Features
  • Search

  • Downloads

  • Save code now

  • Add forge now

  • Help

  • 062bf3d
  • /
  • VofDataUtils
  • /
  • Grid
  • /
  • GridData.h
Raw File Download

To reference or cite the objects present in the Software Heritage archive, permalinks based on SoftWare Hash IDentifiers (SWHIDs) must be used.
Select below a type of object currently browsed in order to display its associated SWHID and permalink.

  • content
  • directory
content badge
swh:1:cnt:6bb2a779fc6833ad0e15ba2baa9381f1b1ced914
directory badge
swh:1:dir:ea777418dfe39c945fc3cd3aae27eb67872744e4

This interface enables to generate software citations, provided that the root directory of browsed objects contains a citation.cff or codemeta.json file.
Select below a type of object currently browsed in order to generate citations for them.

  • content
  • directory
(requires biblatex-software package)
Generating citation ...
(requires biblatex-software package)
Generating citation ...
GridData.h
#pragma once

#include <cstring>
#include <stdexcept>

#include <vtkSmartPointer.h>
#include <vtkType.h>

#include "../VtkUtil/VtkUtilArray.h"
#include "DomainInfo.h"
#include "GridTypes.h"

namespace VofFlow {
    template<typename ArrayT>
    vtkSmartPointer<ArrayT> extractExtent(const DomainInfo& domainInfo, extent_t extent,
        vtkSmartPointer<ArrayT> array) {
        // Validate requested extent is fully within the array extent.
        if (extent[0] < domainInfo.localExtent()[0] || extent[1] > domainInfo.localExtent()[1] ||
            extent[2] < domainInfo.localExtent()[2] || extent[3] > domainInfo.localExtent()[3] ||
            extent[4] < domainInfo.localExtent()[4] || extent[5] > domainInfo.localExtent()[5]) {
            throw std::runtime_error("Requested extent is out of bounds!");
        }

        const int numComponents = array->GetNumberOfComponents();
        const auto extDim = Grid::extentDimensions(extent);

        vtkSmartPointer<ArrayT> result = vtkSmartPointer<ArrayT>::New();
        result->SetName(array->GetName());
        result->SetNumberOfComponents(numComponents);
        result->SetNumberOfTuples(Grid::extentNumCells(extent));

        for (int z = 0; z < extDim[2]; z++) {
            for (int y = 0; y < extDim[1]; y++) {
                vtkIdType fromIdx = domainInfo.localExtentCoordToIdx(extent[0], extent[2] + y, extent[4] + z);
                vtkIdType toIdx = z * extDim[1] * extDim[0] + y * extDim[0];
                auto* fromPtr = getTuplePointer(array, fromIdx);
                auto* toPtr = getTuplePointer(result, toIdx);
                std::memcpy(toPtr, fromPtr, extDim[0] * numComponents * sizeof(typename ArrayT::ValueType));
            }
        }

        return result;
    }
} // namespace VofFlow

back to top

Software Heritage — Copyright (C) 2015–2026, The Software Heritage developers. License: GNU AGPLv3+.
The source code of Software Heritage itself is available on our development forge.
The source code files archived by Software Heritage are available under their own copyright and licenses.
Terms of use: Archive access, API— Content policy— Contact— JavaScript license information— Web API