Exemple #1
0
Int2 Renderer::originalPointToNative(const Int2 &originalPoint) const
{
    // From original point to letterbox point.
    double originalXPercent = static_cast<double>(originalPoint.getX()) /
                              static_cast<double>(Renderer::ORIGINAL_WIDTH);
    double originalYPercent = static_cast<double>(originalPoint.getY()) /
                              static_cast<double>(Renderer::ORIGINAL_HEIGHT);

    const auto letterbox = this->getLetterboxDimensions();
    Int2 letterboxPoint(
        static_cast<double>(letterbox.w) * originalXPercent,
        static_cast<double>(letterbox.h) * originalYPercent);

    // Then from letterbox point to native point.
    Int2 nativePoint(
        letterboxPoint.getX() + letterbox.x,
        letterboxPoint.getY() + letterbox.y);

    return nativePoint;
}
Exemple #2
0
std::unique_ptr<std::vector<char>> Compression::decompress(
        const std::vector<char>& data,
        const Schema& nativeSchema,
        const Schema* const wantedSchema,
        const std::size_t numPoints)
{
    if (!wantedSchema || *wantedSchema == nativeSchema)
    {
        return decompress(data, nativeSchema, numPoints);
    }

    // Get decompressor in the native schema.
    DecompressionStream decompressionStream(data);
    pdal::LazPerfDecompressor<DecompressionStream> decompressor(
            decompressionStream,
            nativeSchema.pdalLayout().dimTypes());

    // Allocate room for a single point in the native schema.
    std::vector<char> nativePoint(nativeSchema.pointSize());
    BinaryPointTable table(nativeSchema, nativePoint.data());
    pdal::PointRef pointRef(table, 0);

    // Get our result space, in the desired schema, ready.
    std::unique_ptr<std::vector<char>> decompressed(
            new std::vector<char>(numPoints * wantedSchema->pointSize(), 0));
    char* pos(decompressed->data());
    const char* end(pos + decompressed->size());

    while (pos < end)
    {
        decompressor.decompress(nativePoint.data(), nativePoint.size());

        for (const auto& d : wantedSchema->dims())
        {
            pointRef.getField(pos, d.id(), d.type());
            pos += d.size();
        }
    }

    return decompressed;
}