text:
package org.lwjgl.stb;

import javax.annotation.*;

import java.nio.*;

import org.lwjgl.*;
import org.lwjgl.system.*;

import static org.lwjgl.system.Checks.*;
import static org.lwjgl.system.MemoryUtil.*;
import static org.lwjgl.system.MemoryStack.*;

/**
 * The opaque {@code stbrp_context} struct.
 *
 *
Layout

 *
 *

 * struct stbrp_context {
 *     int width;
 *     int height;
 *     int align;
 *     int init_mode;
 *     int heuristic;
 *     int num_nodes;
 *     {@link STBRPNode stbrp_node} * active_head;
 *     {@link STBRPNode stbrp_node} * free_head;
 *     {@link STBRPNode stbrp_node} {@link #extra}[2];
 * }

 */
@NativeType("struct stbrp_context")
public class STBRPContext extends Struct implements NativeResource {

    /** The struct size in bytes. */
    public static final int SIZEOF;

    /** The struct alignment in bytes. */
    public static final int ALIGNOF;

    /** The struct member offsets. */
    public static final int
        WIDTH,
        HEIGHT,
        ALIGN,
        INIT_MODE,
        HEURISTIC,
        NUM_NODES,
        ACTIVE_HEAD,
        FREE_HEAD,
        EXTRA;

    static {
        Layout layout = __struct(
            __member(4),
            __member(4),
            __member(4),
            __member(4),
            __member(4),
            __member(4),
            __member(POINTER_SIZE),
            __member(POINTER_SIZE),
            __array(STBRPNode.SIZEOF, STBRPNode.ALIGNOF, 2)
        );

        SIZEOF = layout.getSize();
        ALIGNOF = layout.getAlignment();

        WIDTH = layout.offsetof(0);
        HEIGHT = layout.offsetof(1);
        ALIGN = layout.offsetof(2);
        INIT_MODE = layout.offsetof(3);
        HEURISTIC = layout.offsetof(4);
        NUM_NODES = layout.offsetof(5);
        ACTIVE_HEAD = layout.offsetof(6);
        FREE_HEAD = layout.offsetof(7);
        EXTRA = layout.offsetof(8);
    }

    /**
     * Creates a {@code STBRPContext} instance at the current position of the specified {@link ByteBuffer} container. Changes to the buffer's content will be
     * visible to the struct instance and vice versa.
     *
     *
The created instance holds a strong reference to the container object.

     */
    public STBRPContext(ByteBuffer container) {
        super(memAddress(container), __checkContainer(container, SIZEOF));
    }

    @Override
    public int sizeof() { return SIZEOF; }

    /** @return the value of the {@code width} field. */
    public int width() { return nwidth(address()); }
    /** @return the value of the {@code height} field. */
    public int height() { return nheight(address()); }
    /** @return the value of the {@code align} field. */
    public int align() { return nalign(address()); }
    /** @return the value of the {@code init_mode} field. */
    public int init_mode() { return ninit_mode(address()); }
    /** @return the value of the {@code heuristic} field. */
    public int heuristic() { return nheuristic(address()); }
    /** @return the value of the {@code num_nodes} field. */
    public int num_nodes() { return nnum_nodes(address()); }
    /** @return a {@link STBRPNode} view of the struct pointed to by the {@code active_head} field. */
    @Nullable
    @NativeType("stbrp_node *")
    public STBRPNode active_head() { return nactive_head(address()); }
    /** @return a {@link STBRPNode} view of the struct pointed to by the {@code free_head} field. */
    @Nullable
    @NativeType("stbrp_node *")
    public STBRPNode free_head() { return nfree_head(address()); }
    /** we allocate two extra nodes so optimal user-node-count is {@code width} not {@code width+2} */
    @NativeType("stbrp_node[2]")
    public STBRPNode.Buffer extra() { return nextra(address()); }
    /** we allocate two extra nodes so optimal user-node-count is {@code width} not {@code width+2} */
    @NativeType("stbrp_node")
    public STBRPNode extra(int index) { return nextra(address(), index); }

    // -----------------------------------

    /** Returns a new {@code STBRPContext} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed. */
    public static STBRPContext malloc() {
        return wrap(STBRPContext.class, nmemAllocChecked(SIZEOF));
    }

    /** Returns a new {@code STBRPContext} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed. */
    public static STBRPContext calloc() {
        return wrap(STBRPContext.class, nmemCallocChecked(1, SIZEOF));
    }

    /** Returns a new {@code STBRPContext} instance allocated with {@link BufferUtils}. */
    public static STBRPContext create() {
        ByteBuffer container = BufferUtils.createByteBuffer(SIZEOF);
        return wrap(STBRPContext.class, memAddress(container), container);
    }

    /** Returns a new {@code STBRPContext} instance for the specified memory address. */
    public static STBRPContext create(long address) {
        return wrap(STBRPContext.class, address);
    }

    /** Like {@link #create(long) create}, but returns {@code null} if {@code address} is {@code NULL}. */
    @Nullable
    public static STBRPContext createSafe(long address) {
        return address == NULL ? null : wrap(STBRPContext.class, address);
    }

    /**
     * Returns a new {@link STBRPContext.Buffer} instance allocated with {@link MemoryUtil#memAlloc memAlloc}. The instance must be explicitly freed.
     *
     * @param capacity the buffer capacity
     */
    public static STBRPContext.Buffer malloc(int capacity) {
        return wrap(Buffer.class, nmemAllocChecked(__checkMalloc(capacity, SIZEOF)), capacity);
    }

    /**
     * Returns a new {@link STBRPContext.Buffer} instance allocated with {@link MemoryUtil#memCalloc memCalloc}. The instance must be explicitly freed.
     *
     * @param capacity the buffer capacity
     */
    public static STBRPContext.Buffer calloc(int capacity) {
        return wrap(Buffer.class, nmemCallocChecked(capacity, SIZEOF), capacity);
    }

    /**
     * Returns a new {@link STBRPContext.Buffer} instance allocated with {@link BufferUtils}.
     *
     * @param capacity the buffer capacity
     */
    public static STBRPContext.Buffer create(int capacity) {
        ByteBuffer container = __create(capacity, SIZEOF);
        return wrap(Buffer.class, memAddress(container), capacity, container);
    }

    /**
     * Create a {@link STBRPContext.Buffer} instance at the specified memory.
     *
     * @param address  the memory address
     * @param capacity the buffer capacity
     */
    public static STBRPContext.Buffer create(long address, int capacity) {
        return wrap(Buffer.class, address, capacity);
    }

    /** Like {@link #create(long, int) create}, but returns {@code null} if {@code address} is {@code NULL}. */
    @Nullable
    public static STBRPContext.Buffer createSafe(long address, int capacity) {
        return address == NULL ? null : wrap(Buffer.class, address, capacity);
    }

    // -----------------------------------

    /** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
    @Deprecated public static STBRPContext mallocStack() { return malloc(stackGet()); }
    /** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
    @Deprecated public static STBRPContext callocStack() { return calloc(stackGet()); }
    /** Deprecated for removal in 3.4.0. Use {@link #malloc(MemoryStack)} instead. */
    @Deprecated public static STBRPContext mallocStack(MemoryStack stack) { return malloc(stack); }
    /** Deprecated for removal in 3.4.0. Use {@link #calloc(MemoryStack)} instead. */
    @Deprecated public static STBRPContext callocStack(MemoryStack stack) { return calloc(stack); }
    /** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
    @Deprecated public static STBRPContext.Buffer mallocStack(int capacity) { return malloc(capacity, stackGet()); }
    /** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
    @Deprecated public static STBRPContext.Buffer callocStack(int capacity) { return calloc(capacity, stackGet()); }
    /** Deprecated for removal in 3.4.0. Use {@link #malloc(int, MemoryStack)} instead. */
    @Deprecated public static STBRPContext.Buffer mallocStack(int capacity, MemoryStack stack) { return malloc(capacity, stack); }
    /** Deprecated for removal in 3.4.0. Use {@link #calloc(int, MemoryStack)} instead. */
    @Deprecated public static STBRPContext.Buffer callocStack(int capacity, MemoryStack stack) { return calloc(capacity, stack); }

    /**
     * Returns a new {@code STBRPContext} instance allocated on the specified {@link MemoryStack}.
     *
     * @param stack the stack from which to allocate
     */
    public static STBRPContext malloc(MemoryStack stack) {
        return wrap(STBRPContext.class, stack.nmalloc(ALIGNOF, SIZEOF));
    }

    /**
     * Returns a new {@code STBRPContext} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
     *
     * @param stack the stack from which to allocate
     */
    public static STBRPContext calloc(MemoryStack stack) {
        return wrap(STBRPContext.class, stack.ncalloc(ALIGNOF, 1, SIZEOF));
    }

    /**
     * Returns a new {@link STBRPContext.Buffer} instance allocated on the specified {@link MemoryStack}.
     *
     * @param stack    the stack from which to allocate
     * @param capacity the buffer capacity
     */
    public static STBRPContext.Buffer malloc(int capacity, MemoryStack stack) {
        return wrap(Buffer.class, stack.nmalloc(ALIGNOF, capacity * SIZEOF), capacity);
    }

    /**
     * Returns a new {@link STBRPContext.Buffer} instance allocated on the specified {@link MemoryStack} and initializes all its bits to zero.
     *
     * @param stack    the stack from which to allocate
     * @param capacity the buffer capacity
     */
    public static STBRPContext.Buffer calloc(int capacity, MemoryStack stack) {
        return wrap(Buffer.class, stack.ncalloc(ALIGNOF, capacity, SIZEOF), capacity);
    }

    // -----------------------------------

    /** Unsafe version of {@link #width}. */
    public static int nwidth(long struct) { return UNSAFE.getInt(null, struct + STBRPContext.WIDTH); }
    /** Unsafe version of {@link #height}. */
    public static int nheight(long struct) { return UNSAFE.getInt(null, struct + STBRPContext.HEIGHT); }
    /** Unsafe version of {@link #align}. */
    public static int nalign(long struct) { return UNSAFE.getInt(null, struct + STBRPContext.ALIGN); }
    /** Unsafe version of {@link #init_mode}. */
    public static int ninit_mode(long struct) { return UNSAFE.getInt(null, struct + STBRPContext.INIT_MODE); }
    /** Unsafe version of {@link #heuristic}. */
    public static int nheuristic(long struct) { return UNSAFE.getInt(null, struct + STBRPContext.HEURISTIC); }
    /** Unsafe version of {@link #num_nodes}. */
    public static int nnum_nodes(long struct) { return UNSAFE.getInt(null, struct + STBRPContext.NUM_NODES); }
    /** Unsafe version of {@link #active_head}. */
    @Nullable public static STBRPNode nactive_head(long struct) { return STBRPNode.createSafe(memGetAddress(struct + STBRPContext.ACTIVE_HEAD)); }
    /** Unsafe version of {@link #free_head}. */
    @Nullable public static STBRPNode nfree_head(long struct) { return STBRPNode.createSafe(memGetAddress(struct + STBRPContext.FREE_HEAD)); }
    /** Unsafe version of {@link #extra}. */
    public static STBRPNode.Buffer nextra(long struct) { return STBRPNode.create(struct + STBRPContext.EXTRA, 2); }
    /** Unsafe version of {@link #extra(int) extra}. */
    public static STBRPNode nextra(long struct, int index) {
        return STBRPNode.create(struct + STBRPContext.EXTRA + check(index, 2) * STBRPNode.SIZEOF);
    }

    // -----------------------------------

    /** An array of {@link STBRPContext} structs. */
    public static class Buffer extends StructBuffer<STBRPContext, Buffer> implements NativeResource {

        private static final STBRPContext ELEMENT_FACTORY = STBRPContext.create(-1L);

        /**
         * Creates a new {@code STBRPContext.Buffer} instance backed by the specified container.
         *
         * Changes to the container's content will be visible to the struct buffer instance and vice versa. The two buffers' position, limit, and mark values
         * will be independent. The new buffer's position will be zero, its capacity and its limit will be the number of bytes remaining in this buffer divided
         * by {@link STBRPContext#SIZEOF}, and its mark will be undefined.
         *
         *
The created buffer instance holds a strong reference to the container object.

         */
        public Buffer(ByteBuffer container) {
            super(container, container.remaining() / SIZEOF);
        }

        public Buffer(long address, int cap) {
            super(address, null, -1, 0, cap, cap);
        }

        Buffer(long address, @Nullable ByteBuffer container, int mark, int pos, int lim, int cap) {
            super(address, container, mark, pos, lim, cap);
        }

        @Override
        protected Buffer self() {
            return this;
        }

        @Override
        protected STBRPContext getElementFactory() {
            return ELEMENT_FACTORY;
        }

        /** @return the value of the {@code width} field. */
        public int width() { return STBRPContext.nwidth(address()); }
        /** @return the value of the {@code height} field. */
        public int height() { return STBRPContext.nheight(address()); }
        /** @return the value of the {@code align} field. */
        public int align() { return STBRPContext.nalign(address()); }
        /** @return the value of the {@code init_mode} field. */
        public int init_mode() { return STBRPContext.ninit_mode(address()); }
        /** @return the value of the {@code heuristic} field. */
        public int heuristic() { return STBRPContext.nheuristic(address()); }
        /** @return the value of the {@code num_nodes} field. */
        public int num_nodes() { return STBRPContext.nnum_nodes(address()); }
        /** @return a {@link STBRPNode} view of the struct pointed to by the {@code active_head} field. */
        @Nullable
        @NativeType("stbrp_node *")
        public STBRPNode active_head() { return STBRPContext.nactive_head(address()); }
        /** @return a {@link STBRPNode} view of the struct pointed to by the {@code free_head} field. */
        @Nullable
        @NativeType("stbrp_node *")
        public STBRPNode free_head() { return STBRPContext.nfree_head(address()); }
        /** @return a {@link STBRPNode}.Buffer view of the {@link STBRPContext#extra} field. */
        @NativeType("stbrp_node[2]")
        public STBRPNode.Buffer extra() { return STBRPContext.nextra(address()); }
        /** @return a {@link STBRPNode} view of the struct at the specified index of the {@link STBRPContext#extra} field. */
        @NativeType("stbrp_node")
        public STBRPNode extra(int index) { return STBRPContext.nextra(address(), index); }

    }

}


text:
FROM java:8

ADD build/libs/spring-boot-demo-1-*.jar app.jar
RUN bash -c 'touch /app.jar'
EXPOSE 8080
ENTRYPOINT ["java","-Djava.security.egd=file:/dev/./urandom","-jar","/app.jar"]

redpajama_set_name: RedPajamaGithub


text:
package de.fhg.iais.asc.commons;

import java.io.File;
import java.io.IOException;

import org.apache.commons.io.FileUtils;

/**
 * Utilities for handling parent directories
 *
 * @author hjh
 */
public enum ParentDirectoryUtils {
    ;

    /**
     * Creates the parent directory for a {@link File}, throwing an {@link IOException} if it can't be
     * created.
     *
     * @param f the {@link File} to create the parent directory for
     * @throws IOException if the parent directory of {@code f} can't be created
     */
    public static void forceCreateParentDirectoryOf(File f) throws IOException {
        File parentFile = getParentDirectory(f);
        if ( parentFile != null ) {
            FileUtils.forceMkdir(parentFile);
        }
    }

    /**
     * Determines the parent directory of a {@link File}
     *
     * @param f the {@link File} to determine the parent directory for
     * @return the parent directory of {@code f} (as {@link File} object)
     */
    public static File getParentDirectory(File f) {
        File parentFile = f.getParentFile();
        if ( parentFile == null ) {
            parentFile = f.getAbsoluteFile().getParentFile();
        }

        return parentFile;
    }
}


text:
class ReserveMailer < ApplicationMailer
  def accepted(reserve)
    @library_group = LibraryGroup.site_config
    @reserve = reserve
    system_name = LibraryGroup.system_name(reserve.user.profile.locale)

    from = "#{system_name}] <#{@library_group.email}>"
    subject = "[#{system_name}] #{I18n.t('reserve_mailer.accepted')}"
    mail(from: from, to: reserve.user.email, cc: from, subject: subject)
  end

  def cancelled(reserve)
    @library_group = LibraryGroup.site_config
    @reserve = reserve
    system_name = LibraryGroup.system_name(reserve.user.profile.locale)

    from = "#{system_name}] <#{@library_group.email}>"
    subject = "[#{system_name}] #{I18n.t('reserve_mailer.cancelled')}"
    mail(from: from, to: reserve.user.email, cc: from, subject: subject)
  end

  def expired(reserve)
    @library_group = LibraryGroup.site_config
    @reserve = reserve
    system_name = LibraryGroup.system_name(reserve.user.profile.locale)

    from = "#{system_name}] <#{@library_group.email}>"
    subject = "[#{system_name}] #{I18n.t('reserve_mailer.expired')}"
    mail(from: from, to: reserve.user.email, cc: from, subject: subject)
  end

  def retained(reserve)
    @library_group = LibraryGroup.site_config
    @reserve = reserve
    system_name = LibraryGroup.system_name(reserve.user.profile.locale)

    from = "#{system_name}] <#{@library_group.email}>"
    subject = "[#{system_name}] #{I18n.t('reserve_mailer.retained')}"
    mail(from: from, to: reserve.user.email, cc: from, subject: subject)
  end

  def postponed(reserve)
    @library_group = LibraryGroup.site_config
    @reserve = reserve
    system_name = LibraryGroup.system_name(reserve.user.profile.locale)

    from = "#{system_name}] <#{@library_group.email}>"
    subject = "[#{system_name}] #{I18n.t('reserve_mailer.postponed')}"
    mail(from: from, to: reserve.user.email, cc: from, subject: subject)
  end
end


text:
/** @file  SIBImporter.cpp
 *  @brief Implementation of the SIB importer class.
 *
 *  The Nevercenter Silo SIB format is undocumented.
 *  All details here have been reverse engineered from
 *  studying the binary files output by Silo.
 *
 *  Nevertheless, this implementation is reasonably complete.
 */

#ifndef ASSIMP_BUILD_NO_SIB_IMPORTER

// internal headers
#include "SIBImporter.h"
#include "ByteSwapper.h"
#include "StreamReader.h"
#include "TinyFormatter.h"
//#include "../contrib/ConvertUTF/ConvertUTF.h"
#include "../contrib/utf8cpp/source/utf8.h"
#include <assimp/IOSystem.hpp>
#include <assimp/DefaultLogger.hpp>
#include <assimp/scene.h>
#include <assimp/importerdesc.h>

#include <map>

using namespace Assimp;

static const aiImporterDesc desc = {
    "Silo SIB Importer",
    "Richard Mitton (http://www.codersnotes.com/about)",
    "",
    "Does not apply subdivision.",
    aiImporterFlags_SupportBinaryFlavour,
    0, 0,
    0, 0,
    "sib"
};

struct SIBChunk {
    uint32_t    Tag;
    uint32_t    Size;
} PACK_STRUCT;

enum {
    POS,
    NRM,
    UV,
    N
};

typedef std::pair<uint32_t, uint32_t> SIBPair;

struct SIBEdge {
    uint32_t faceA, faceB;
    bool creased;
};

struct SIBMesh {
    aiMatrix4x4 axis;
    uint32_t numPts;
    std::vector<aiVector3D> pos, nrm, uv;
    std::vector<uint32_t> idx;
    std::vector<uint32_t> faceStart;
    std::vector<uint32_t> mtls;
    std::vector<SIBEdge> edges;
    std::map<SIBPair, uint32_t> edgeMap;
};

struct SIBObject {
    aiString name;
    aiMatrix4x4 axis;
    size_t meshIdx, meshCount;
};

struct SIB {
    std::vector<aiMaterial*> mtls;
    std::vector<aiMesh*> meshes;
    std::vector<aiLight*> lights;
    std::vector<SIBObject> objs, insts;
};

// ------------------------------------------------------------------------------------------------
static SIBEdge& GetEdge(SIBMesh* mesh, uint32_t posA, uint32_t posB) {
    SIBPair pair = (posA < posB) ? SIBPair(posA, posB) : SIBPair(posB, posA);
    std::map<SIBPair, uint32_t>::iterator it = mesh->edgeMap.find(pair);
    if (it != mesh->edgeMap.end())
        return mesh->edges[it->second];

    SIBEdge edge;
    edge.creased = false;
    edge.faceA = edge.faceB = 0xffffffff;
    mesh->edgeMap[pair] = static_cast<uint32_t>(mesh->edges.size());
    mesh->edges.push_back(edge);
    return mesh->edges.back();
}

// ------------------------------------------------------------------------------------------------
// Helpers for reading chunked data.

#define TAG(A,B,C,D) ((A << 24) | (B << 16) | (C << 8) | D)

static SIBChunk ReadChunk(StreamReaderLE* stream)
{
    SIBChunk chunk;
    chunk.Tag = stream->GetU4();
    chunk.Size = stream->GetU4();
    if (chunk.Size > stream->GetRemainingSizeToLimit())
        DefaultLogger::get()->error("SIB: Chunk overflow");
    ByteSwap::Swap4(&chunk.Tag);
    return chunk;
}

static aiColor3D ReadColor(StreamReaderLE* stream)
{
    float r = stream->GetF4();
    float g = stream->GetF4();
    float b = stream->GetF4();
    stream->GetU4(); // Colors have an unused(?) 4th component.
    return aiColor3D(r, g, b);
}

static void UnknownChunk(StreamReaderLE* /*stream*/, const SIBChunk& chunk)
{
    char temp[5] = {
        static_cast<char>(( chunk.Tag>>24 ) & 0xff),
        static_cast<char>(( chunk.Tag>>16 ) & 0xff),
        static_cast<char>(( chunk.Tag>>8 ) & 0xff),
        static_cast<char>(chunk.Tag & 0xff), '\0'
    };

    DefaultLogger::get()->warn((Formatter::format(), "SIB: Skipping unknown '",temp,"' chunk."));
}

// Reads a UTF-16LE string and returns it at UTF-8.
static aiString ReadString(StreamReaderLE *stream, uint32_t numWChars) {
    if ( nullptr == stream || 0 == numWChars ) {
        static const aiString empty;
        return empty;
    }

    // Allocate buffers (max expansion is 1 byte -> 4 bytes for UTF-8)
    std::vector<unsigned char> str;
    str.reserve( numWChars * 4 + 1 );
    uint16_t *temp = new uint16_t[ numWChars ];
    for ( uint32_t n = 0; n < numWChars; ++n ) {
        temp[ n ] = stream->GetU2();
    }

    // Convert it and NUL-terminate.
    const uint16_t *start( temp ), *end( temp + numWChars );
    utf8::utf16to8( start, end, back_inserter( str ) );
    str[ str.size() - 1 ] = '\0';

    // Return the final string.
    aiString result = aiString((const char *)&str[0]);
    delete[] temp;

    return result;
}

// ------------------------------------------------------------------------------------------------
// Constructor to be privately used by Importer
SIBImporter::SIBImporter() {
    // empty
}

// ------------------------------------------------------------------------------------------------
// Destructor, private as well
SIBImporter::~SIBImporter() {
    // empty
}

// ------------------------------------------------------------------------------------------------
// Returns whether the class can handle the format of the given file.
bool SIBImporter::CanRead( const std::string& pFile, IOSystem* /*pIOHandler*/, bool /*checkSig*/) const {
    return SimpleExtensionCheck(pFile, "sib");
}

// ------------------------------------------------------------------------------------------------
const aiImporterDesc* SIBImporter::GetInfo () const {
    return &desc;
}

// ------------------------------------------------------------------------------------------------
static void ReadVerts(SIBMesh* mesh, StreamReaderLE* stream, uint32_t count) {
    if ( nullptr == mesh || nullptr == stream ) {
        return;
    }

    mesh->pos.resize(count);
    for ( uint32_t n=0; n<count; ++n ) {
        mesh->pos[ n ].x = stream->GetF4();
        mesh->pos[ n ].y = stream->GetF4();
        mesh->pos[ n ].z = stream->GetF4();
    }
}

// ------------------------------------------------------------------------------------------------
static void ReadFaces(SIBMesh* mesh, StreamReaderLE* stream)
{
    uint32_t ptIdx = 0;
    while (stream->GetRemainingSizeToLimit() > 0)
    {
        uint32_t numPoints = stream->GetU4();

        // Store room for the N index channels, plus the point count.
        size_t pos = mesh->idx.size() + 1;
        mesh->idx.resize(pos + numPoints*N);
        mesh->idx[pos-1] = numPoints;
        uint32_t *idx = &mesh->idx[pos];

        mesh->faceStart.push_back(static_cast<uint32_t>(pos-1));
        mesh->mtls.push_back(0);

        // Read all the position data.
        // UV/normals will be supplied later.
        // Positions are supplied indexed already, so we preserve that
        // mapping. UVs are supplied uniquely, so we allocate unique indices.
        for (uint32_t n=0;n<numPoints;n++,idx+=N,ptIdx++)
        {
            uint32_t p = stream->GetU4();
            if (p >= mesh->pos.size())
                throw DeadlyImportError("Vertex index is out of range.");
            idx[POS] = p;
            idx[NRM] = ptIdx;
            idx[UV] = ptIdx;
        }
    }

    // Allocate data channels for normals/UVs.
    mesh->nrm.resize(ptIdx, aiVector3D(0,0,0));
    mesh->uv.resize(ptIdx, aiVector3D(0,0,0));

    mesh->numPts = ptIdx;
}

// ------------------------------------------------------------------------------------------------
static void ReadUVs(SIBMesh* mesh, StreamReaderLE* stream)
{
    while (stream->GetRemainingSizeToLimit() > 0)
    {
        uint32_t faceIdx = stream->GetU4();
        uint32_t numPoints = stream->GetU4();

        if (faceIdx >= mesh->faceStart.size())
            throw DeadlyImportError("Invalid face index.");

        uint32_t pos = mesh->faceStart[faceIdx];
        uint32_t *idx = &mesh->idx[pos + 1];

        for (uint32_t n=0;n<numPoints;n++,idx+=N)
        {
            uint32_t id = idx[UV];
            mesh->uv[id].x = stream->GetF4();
            mesh->uv[id].y = stream->GetF4();
        }
    }
}

// ------------------------------------------------------------------------------------------------
static void ReadMtls(SIBMesh* mesh, StreamReaderLE* stream)
{
    // Material assignments are stored run-length encoded.
    // Also, we add 1 to each material so that we can use mtl #0
    // as the default material.
    uint32_t prevFace = stream->GetU4();
    uint32_t prevMtl = stream->GetU4() + 1;
    while (stream->GetRemainingSizeToLimit() > 0)
    {
        uint32_t face = stream->GetU4();
        uint32_t mtl = stream->GetU4() + 1;
        while (prevFace < face)
        {
            if (prevFace >= mesh->mtls.size())
                throw DeadlyImportError("Invalid face index.");
            mesh->mtls[prevFace++] = prevMtl;
        }

        prevFace = face;
        prevMtl = mtl;
    }

    while (prevFace < mesh->mtls.size())
        mesh->mtls[prevFace++] = prevMtl;
}

// ------------------------------------------------------------------------------------------------
static void ReadAxis(aiMatrix4x4& axis, StreamReaderLE* stream)
{
    axis.a4 = stream->GetF4();
    axis.b4 = stream->GetF4();
    axis.c4 = stream->GetF4();
    axis.d4 = 1;
    axis.a1 = stream->GetF4();
    axis.b1 = stream->GetF4();
    axis.c1 = stream->GetF4();
    axis.d1 = 0;
    axis.a2 = stream->GetF4();
    axis.b2 = stream->GetF4();
    axis.c2 = stream->GetF4();
    axis.d2 = 0;
    axis.a3 = stream->GetF4();
    axis.b3 = stream->GetF4();
    axis.c3 = stream->GetF4();
    axis.d3 = 0;
}

// ------------------------------------------------------------------------------------------------
static void ReadEdges(SIBMesh* mesh, StreamReaderLE* stream)
{
    while (stream->GetRemainingSizeToLimit() > 0)
    {
        uint32_t posA = stream->GetU4();
        uint32_t posB = stream->GetU4();
        GetEdge(mesh, posA, posB);
    }
}

// ------------------------------------------------------------------------------------------------
static void ReadCreases(SIBMesh* mesh, StreamReaderLE* stream)
{
    while (stream->GetRemainingSizeToLimit() > 0)
    {
        uint32_t edge = stream->GetU4();
        if (edge >= mesh->edges.size())
            throw DeadlyImportError("SIB: Invalid edge index.");
        mesh->edges[edge].creased = true;
    }
}

// ------------------------------------------------------------------------------------------------
static void ConnectFaces(SIBMesh* mesh)
{
    // Find faces connected to each edge.
    size_t numFaces = mesh->faceStart.size();
    for (size_t faceIdx=0;faceIdx<numFaces;faceIdx++)
    {
        uint32_t *idx = &mesh->idx[mesh->faceStart[faceIdx]];
        uint32_t numPoints = *idx++;
        uint32_t prev = idx[(numPoints-1)*N+POS];

        for (uint32_t i=0;i<numPoints;i++,idx+=N)
        {
            uint32_t next = idx[POS];

            // Find this edge.
            SIBEdge& edge = GetEdge(mesh, prev, next);

            // Link this face onto it.
            // This gives potentially undesirable normals when used
            // with non-2-manifold surfaces, but then so does Silo to begin with.
            if (edge.faceA == 0xffffffff)
                edge.faceA = static_cast<uint32_t>(faceIdx);
            else if (edge.faceB == 0xffffffff)
                edge.faceB = static_cast<uint32_t>(faceIdx);

            prev = next;
        }
    }
}

// ------------------------------------------------------------------------------------------------
static aiVector3D CalculateVertexNormal(SIBMesh* mesh, uint32_t faceIdx, uint32_t pos,
                                        const std::vector<aiVector3D>& faceNormals)
{
    // Creased edges complicate this. We need to find the start/end range of the
    // ring of faces that touch this position.
    // We do this in two passes. The first pass is to find the end of the range,
    // the second is to work backwards to the start and calculate the final normal.
    aiVector3D vtxNormal;
    for (int pass=0;pass<2;pass++)
    {
        vtxNormal = aiVector3D(0, 0, 0);
        uint32_t startFaceIdx = faceIdx;
        uint32_t prevFaceIdx = faceIdx;

        // Process each connected face.
        while (true)
        {
            // Accumulate the face normal.
            vtxNormal += faceNormals[faceIdx];

            uint32_t nextFaceIdx = 0xffffffff;

            // Move to the next edge sharing this position.
            uint32_t* idx = &mesh->idx[mesh->faceStart[faceIdx]];
            uint32_t numPoints = *idx++;
            uint32_t posA = idx[(numPoints-1)*N+POS];
            for (uint32_t n=0;n<numPoints;n++,idx+=N)
            {
                uint32_t posB = idx[POS];

                // Test if this edge shares our target position.
                if (posA == pos || posB == pos)
                {
                    SIBEdge& edge = GetEdge(mesh, posA, posB);

                    // Non-manifold meshes can produce faces which share
                    // positions but have no edge entry, so check it.
                    if (edge.faceA == faceIdx || edge.faceB == faceIdx)
                    {
                        // Move to whichever side we didn't just come from.
                        if (!edge.creased) {
                            if (edge.faceA != prevFaceIdx && edge.faceA != faceIdx && edge.faceA != 0xffffffff)
                                nextFaceIdx = edge.faceA;
                            else if (edge.faceB != prevFaceIdx && edge.faceB != faceIdx && edge.faceB != 0xffffffff)
                                nextFaceIdx = edge.faceB;
                        }
                    }
                }

                posA = posB;
            }

            // Stop once we hit either an creased/unconnected edge, or we
            // wrapped around and hit our start point.
            if (nextFaceIdx == 0xffffffff || nextFaceIdx == startFaceIdx)
                break;

            prevFaceIdx = faceIdx;
            faceIdx = nextFaceIdx;
        }
    }

    // Normalize it.
    float len = vtxNormal.Length();
    if (len > 0.000000001f)
        vtxNormal /= len;
    return vtxNormal;
}

// ------------------------------------------------------------------------------------------------
static void CalculateNormals(SIBMesh* mesh)
{
    size_t numFaces = mesh->faceStart.size();

    // Calculate face normals.
    std::vector<aiVector3D> faceNormals(numFaces);
    for (size_t faceIdx=0;faceIdx<numFaces;faceIdx++)
    {
        uint32_t* idx = &mesh->idx[mesh->faceStart[faceIdx]];
        uint32_t numPoints = *idx++;

        aiVector3D faceNormal(0, 0, 0);

        uint32_t *prev = &idx[(numPoints-1)*N];

        for (uint32_t i=0;i<numPoints;i++)
        {
            uint32_t *next = &idx[i*N];

            faceNormal += mesh->pos[prev[POS]] ^ mesh->pos[next[POS]];
            prev = next;
        }

        faceNormals[faceIdx] = faceNormal;
    }

    // Calculate vertex normals.
    for (size_t faceIdx=0;faceIdx<numFaces;faceIdx++)
    {
        uint32_t* idx = &mesh->idx[mesh->faceStart[faceIdx]];
        uint32_t numPoints = *idx++;

        for (uint32_t i=0;i<numPoints;i++)
        {
            uint32_t pos = idx[i*N+POS];
            uint32_t nrm = idx[i*N+NRM];
            aiVector3D vtxNorm = CalculateVertexNormal(mesh, static_cast<uint32_t>(faceIdx), pos, faceNormals);
            mesh->nrm[nrm] = vtxNorm;
        }
    }
}

// ------------------------------------------------------------------------------------------------
struct TempMesh
{
    std::vector<aiVector3D> vtx;
    std::vector<aiVector3D> nrm;
    std::vector<aiVector3D> uv;
    std::vector<aiFace>     faces;
};

static void ReadShape(SIB* sib, StreamReaderLE* stream)
{
    SIBMesh smesh;
    aiString name;

    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk))
    {
        SIBChunk chunk = ReadChunk(stream);
        unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size);

        switch (chunk.Tag)
        {
        case TAG('M','I','R','P'): break; // mirror plane maybe?
        case TAG('I','M','R','P'): break; // instance mirror? (not supported here yet)
        case TAG('D','I','N','F'): break; // display info, not needed
        case TAG('P','I','N','F'): break; // ?
        case TAG('V','M','I','R'): break; // ?
        case TAG('F','M','I','R'): break; // ?
        case TAG('T','X','S','M'): break; // ?
        case TAG('F','A','H','S'): break; // ?
        case TAG('V','R','T','S'): ReadVerts(&smesh, stream, chunk.Size/12); break;
        case TAG('F','A','C','S'): ReadFaces(&smesh, stream); break;
        case TAG('F','T','V','S'): ReadUVs(&smesh, stream); break;
        case TAG('S','N','A','M'): name = ReadString(stream, chunk.Size/2); break;
        case TAG('F','A','M','A'): ReadMtls(&smesh, stream); break;
        case TAG('A','X','I','S'): ReadAxis(smesh.axis, stream); break;
        case TAG('E','D','G','S'): ReadEdges(&smesh, stream); break;
        case TAG('E','C','R','S'): ReadCreases(&smesh, stream); break;
        default:                   UnknownChunk(stream, chunk); break;
        }

        stream->SetCurrentPos(stream->GetReadLimit());
        stream->SetReadLimit(oldLimit);
    }

    ai_assert(smesh.faceStart.size() == smesh.mtls.size()); // sanity check

    // Silo doesn't store any normals in the file - we need to compute
    // them ourselves. We can't let AssImp handle it as AssImp doesn't
    // know about our creased edges.
    ConnectFaces(&smesh);
    CalculateNormals(&smesh);

    // Construct the transforms.
    aiMatrix4x4 worldToLocal = smesh.axis;
    worldToLocal.Inverse();
    aiMatrix4x4 worldToLocalN = worldToLocal;
    worldToLocalN.a4 = worldToLocalN.b4 = worldToLocalN.c4 = 0.0f;
    worldToLocalN.Inverse().Transpose();

    // Allocate final mesh data.
    // We'll allocate one mesh for each material. (we'll strip unused ones after)
    std::vector<TempMesh> meshes(sib->mtls.size());

    // Un-index the source data and apply to each vertex.
    for (unsigned fi=0;fi<smesh.faceStart.size();fi++)
    {
        uint32_t start = smesh.faceStart[fi];
        uint32_t mtl = smesh.mtls[fi];
        uint32_t *idx = &smesh.idx[start];

        if (mtl >= meshes.size())
        {
            DefaultLogger::get()->error("SIB: Face material index is invalid.");
            mtl = 0;
        }

        TempMesh& dest = meshes[mtl];

        aiFace face;
        face.mNumIndices = *idx++;
        face.mIndices = new unsigned[face.mNumIndices];
        for (unsigned pt=0;pt<face.mNumIndices;pt++,idx+=N)
        {
            size_t vtxIdx = dest.vtx.size();
            face.mIndices[pt] = static_cast<unsigned int>(vtxIdx);

            // De-index it. We don't need to validate here as
            // we did it when creating the data.
            aiVector3D pos = smesh.pos[idx[POS]];
            aiVector3D nrm = smesh.nrm[idx[NRM]];
            aiVector3D uv  = smesh.uv[idx[UV]];

            // The verts are supplied in world-space, so let's
            // transform them back into the local space of this mesh:
            pos = worldToLocal * pos;
            nrm = worldToLocalN * nrm;

            dest.vtx.push_back(pos);
            dest.nrm.push_back(nrm);
            dest.uv.push_back(uv);
        }
        dest.faces.push_back(face);
    }

    SIBObject obj;
    obj.name = name;
    obj.axis = smesh.axis;
    obj.meshIdx = sib->meshes.size();

    // Now that we know the size of everything,
    // we can build the final one-material-per-mesh data.
    for (size_t n=0;n<meshes.size();n++)
    {
        TempMesh& src = meshes[n];
        if (src.faces.empty())
            continue;

        aiMesh* mesh = new aiMesh;
        mesh->mName = name;
        mesh->mNumFaces = static_cast<unsigned int>(src.faces.size());
        mesh->mFaces = new aiFace[mesh->mNumFaces];
        mesh->mNumVertices = static_cast<unsigned int>(src.vtx.size());
        mesh->mVertices = new aiVector3D[mesh->mNumVertices];
        mesh->mNormals = new aiVector3D[mesh->mNumVertices];
        mesh->mTextureCoords[0] = new aiVector3D[mesh->mNumVertices];
        mesh->mNumUVComponents[0] = 2;
        mesh->mMaterialIndex = static_cast<unsigned int>(n);

        for (unsigned i=0;i<mesh->mNumVertices;i++)
        {
            mesh->mVertices[i] = src.vtx[i];
            mesh->mNormals[i] = src.nrm[i];
            mesh->mTextureCoords[0][i] = src.uv[i];
        }
        for (unsigned i=0;i<mesh->mNumFaces;i++)
        {
            mesh->mFaces[i] = src.faces[i];
        }

        sib->meshes.push_back(mesh);
    }

    obj.meshCount = sib->meshes.size() - obj.meshIdx;
    sib->objs.push_back(obj);
}

// ------------------------------------------------------------------------------------------------
static void ReadMaterial(SIB* sib, StreamReaderLE* stream)
{
    aiColor3D diff = ReadColor(stream);
    aiColor3D ambi = ReadColor(stream);
    aiColor3D spec = ReadColor(stream);
    aiColor3D emis = ReadColor(stream);
    float shiny = (float)stream->GetU4();

    uint32_t nameLen = stream->GetU4();
    aiString name = ReadString(stream, nameLen/2);
    uint32_t texLen = stream->GetU4();
    aiString tex = ReadString(stream, texLen/2);

    aiMaterial* mtl = new aiMaterial();
    mtl->AddProperty(&diff, 1, AI_MATKEY_COLOR_DIFFUSE);
    mtl->AddProperty(&ambi, 1, AI_MATKEY_COLOR_AMBIENT);
    mtl->AddProperty(&spec, 1, AI_MATKEY_COLOR_SPECULAR);
    mtl->AddProperty(&emis, 1, AI_MATKEY_COLOR_EMISSIVE);
    mtl->AddProperty(&shiny, 1, AI_MATKEY_SHININESS);
    mtl->AddProperty(&name, AI_MATKEY_NAME);
    if (tex.length > 0) {
        mtl->AddProperty(&tex, AI_MATKEY_TEXTURE_DIFFUSE(0));
        mtl->AddProperty(&tex, AI_MATKEY_TEXTURE_AMBIENT(0));
    }

    sib->mtls.push_back(mtl);
}

// ------------------------------------------------------------------------------------------------
static void ReadLightInfo(aiLight* light, StreamReaderLE* stream)
{
    uint32_t type = stream->GetU4();
    switch (type) {
    case 0: light->mType = aiLightSource_POINT; break;
    case 1: light->mType = aiLightSource_SPOT; break;
    case 2: light->mType = aiLightSource_DIRECTIONAL; break;
    default: light->mType = aiLightSource_UNDEFINED; break;
    }

    light->mPosition.x = stream->GetF4();
    light->mPosition.y = stream->GetF4();
    light->mPosition.z = stream->GetF4();
    light->mDirection.x = stream->GetF4();
    light->mDirection.y = stream->GetF4();
    light->mDirection.z = stream->GetF4();
    light->mColorDiffuse = ReadColor(stream);
    light->mColorAmbient = ReadColor(stream);
    light->mColorSpecular = ReadColor(stream);
    ai_real spotExponent = stream->GetF4();
    ai_real spotCutoff = stream->GetF4();
    light->mAttenuationConstant = stream->GetF4();
    light->mAttenuationLinear = stream->GetF4();
    light->mAttenuationQuadratic = stream->GetF4();

    // Silo uses the OpenGL default lighting model for it's
    // spot cutoff/exponent. AssImp unfortunately, does not.
    // Let's try and approximate it by solving for the
    // 99% and 1% percentiles.
    //    OpenGL: I = cos(angle)^E
    //   Solving: angle = acos(I^(1/E))
    ai_real E = ai_real( 1.0 ) / std::max(spotExponent, (ai_real)0.00001);
    ai_real inner = std::acos(std::pow((ai_real)0.99, E));
    ai_real outer = std::acos(std::pow((ai_real)0.01, E));

    // Apply the cutoff.
    outer = std::min(outer, AI_DEG_TO_RAD(spotCutoff));

    light->mAngleInnerCone = std::min(inner, outer);
    light->mAngleOuterCone = outer;
}

static void ReadLight(SIB* sib, StreamReaderLE* stream)
{
    aiLight* light = new aiLight();

    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk))
    {
        SIBChunk chunk = ReadChunk(stream);
        unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size);

        switch (chunk.Tag)
        {
        case TAG('L','N','F','O'): ReadLightInfo(light, stream); break;
        case TAG('S','N','A','M'): light->mName = ReadString(stream, chunk.Size/2); break;
        default:                   UnknownChunk(stream, chunk); break;
        }

        stream->SetCurrentPos(stream->GetReadLimit());
        stream->SetReadLimit(oldLimit);
    }

    sib->lights.push_back(light);
}

// ------------------------------------------------------------------------------------------------
static void ReadScale(aiMatrix4x4& axis, StreamReaderLE* stream)
{
    aiMatrix4x4 scale;
    scale.a1 = stream->GetF4();
    scale.b1 = stream->GetF4();
    scale.c1 = stream->GetF4();
    scale.d1 = stream->GetF4();
    scale.a2 = stream->GetF4();
    scale.b2 = stream->GetF4();
    scale.c2 = stream->GetF4();
    scale.d2 = stream->GetF4();
    scale.a3 = stream->GetF4();
    scale.b3 = stream->GetF4();
    scale.c3 = stream->GetF4();
    scale.d3 = stream->GetF4();
    scale.a4 = stream->GetF4();
    scale.b4 = stream->GetF4();
    scale.c4 = stream->GetF4();
    scale.d4 = stream->GetF4();

    axis = axis * scale;
}

static void ReadInstance(SIB* sib, StreamReaderLE* stream)
{
    SIBObject inst;
    uint32_t shapeIndex = 0;

    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk))
    {
        SIBChunk chunk = ReadChunk(stream);
        unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size);

        switch (chunk.Tag)
        {
        case TAG('D','I','N','F'): break; // display info, not needed
        case TAG('P','I','N','F'): break; // ?
        case TAG('A','X','I','S'): ReadAxis(inst.axis, stream); break;
        case TAG('I','N','S','I'): shapeIndex = stream->GetU4(); break;
        case TAG('S','M','T','X'): ReadScale(inst.axis, stream); break;
        case TAG('S','N','A','M'): inst.name = ReadString(stream, chunk.Size/2); break;
        default:                   UnknownChunk(stream, chunk); break;
        }

        stream->SetCurrentPos(stream->GetReadLimit());
        stream->SetReadLimit(oldLimit);
    }

    if ( shapeIndex >= sib->objs.size() ) {
        throw DeadlyImportError( "SIB: Invalid shape index." );
    }

    const SIBObject& src = sib->objs[shapeIndex];
    inst.meshIdx = src.meshIdx;
    inst.meshCount = src.meshCount;
    sib->insts.push_back(inst);
}

// ------------------------------------------------------------------------------------------------
static void CheckVersion(StreamReaderLE* stream)
{
    uint32_t version = stream->GetU4();
    if ( version < 1 || version > 2 ) {
        throw DeadlyImportError( "SIB: Unsupported file version." );
    }
}

static void ReadScene(SIB* sib, StreamReaderLE* stream)
{
    // Parse each chunk in turn.
    while (stream->GetRemainingSizeToLimit() >= sizeof(SIBChunk))
    {
        SIBChunk chunk = ReadChunk(stream);
        unsigned oldLimit = stream->SetReadLimit(stream->GetCurrentPos() + chunk.Size);

        switch (chunk.Tag)
        {
        case TAG('H','E','A','D'): CheckVersion(stream); break;
        case TAG('S','H','A','P'): ReadShape(sib, stream); break;
        case TAG('G','R','P','S'): break; // group assignment, we don't import this
        case TAG('T','E','X','P'): break; // ?
        case TAG('I','N','S','T'): ReadInstance(sib, stream); break;
        case TAG('M','A','T','R'): ReadMaterial(sib, stream); break;
        case TAG('L','G','H','T'): ReadLight(sib, stream); break;
        default:                   UnknownChunk(stream, chunk); break;
        }

        stream->SetCurrentPos(stream->GetReadLimit());
        stream->SetReadLimit(oldLimit);
    }
}

// ------------------------------------------------------------------------------------------------
// Imports the given file into the given scene structure.
void SIBImporter::InternReadFile(const std::string& pFile,
    aiScene* pScene, IOSystem* pIOHandler)
{
    StreamReaderLE stream(pIOHandler->Open(pFile, "rb"));

    // We should have at least one chunk
    if (stream.GetRemainingSize() < 16)
        throw DeadlyImportError("SIB file is either empty or corrupt: " + pFile);

    SIB sib;

    // Default material.
    aiMaterial* defmtl = new aiMaterial;
    aiString defname = aiString(AI_DEFAULT_MATERIAL_NAME);
    defmtl->AddProperty(&defname, AI_MATKEY_NAME);
    sib.mtls.push_back(defmtl);

    // Read it all.
    ReadScene(&sib, &stream);

    // Join the instances and objects together.
    size_t firstInst = sib.objs.size();
    sib.objs.insert(sib.objs.end(), sib.insts.begin(), sib.insts.end());
    sib.insts.clear();

    // Transfer to the aiScene.
    pScene->mNumMaterials = static_cast<unsigned int>(sib.mtls.size());
    pScene->mNumMeshes = static_cast<unsigned int>(sib.meshes.size());
    pScene->mNumLights = static_cast<unsigned int>(sib.lights.size());
    pScene->mMaterials = pScene->mNumMaterials ? new aiMaterial*[pScene->mNumMaterials] : NULL;
    pScene->mMeshes = pScene->mNumMeshes ? new aiMesh*[pScene->mNumMeshes] : NULL;
    pScene->mLights = pScene->mNumLights ? new aiLight*[pScene->mNumLights] : NULL;
    if (pScene->mNumMaterials)
        memcpy(pScene->mMaterials, &sib.mtls[0], sizeof(aiMaterial*) * pScene->mNumMaterials);
    if (pScene->mNumMeshes)
        memcpy(pScene->mMeshes, &sib.meshes[0], sizeof(aiMesh*) * pScene->mNumMeshes);
    if (pScene->mNumLights)
        memcpy(pScene->mLights, &sib.lights[0], sizeof(aiLight*) * pScene->mNumLights);

    // Construct the root node.
    size_t childIdx = 0;
    aiNode *root = new aiNode();
    root->mName.Set("<SIBRoot>");
    root->mNumChildren = static_cast<unsigned int>(sib.objs.size() + sib.lights.size());
    root->mChildren = root->mNumChildren ? new aiNode*[root->mNumChildren] : NULL;
    pScene->mRootNode = root;

    // Add nodes for each object.
    for (size_t n=0;n<sib.objs.size();n++)
    {
        ai_assert(root->mChildren);
        SIBObject& obj = sib.objs[n];
        aiNode* node = new aiNode;
        root->mChildren[childIdx++] = node;
        node->mName = obj.name;
        node->mParent = root;
        node->mTransformation = obj.axis;

        node->mNumMeshes = static_cast<unsigned int>(obj.meshCount);
        node->mMeshes = node->mNumMeshes ? new unsigned[node->mNumMeshes] : NULL;
        for (unsigned i=0;i<node->mNumMeshes;i++)
            node->mMeshes[i] = static_cast<unsigned int>(obj.meshIdx + i);

        // Mark instanced objects as being so.
        if (n >= firstInst)
        {
            node->mMetaData = aiMetadata::Alloc( 1 );
            node->mMetaData->Set( 0, "IsInstance", true );
        }
    }

    // Add nodes for each light.
    // (no transformation as the light is already in world space)
    for (size_t n=0;n<sib.lights.size();n++)
    {
        ai_assert(root->mChildren);
        aiLight* light = sib.lights[n];
        if ( nullptr != light ) {
            aiNode* node = new aiNode;
            root->mChildren[ childIdx++ ] = node;
            node->mName = light->mName;
            node->mParent = root;
        }
    }
}

#endif // !! ASSIMP_BUILD_NO_SIB_IMPORTER


text:
package gdpr

import (
	"github.com/prebid/go-gdpr/consentconstants"

	"github.com/prebid/prebid-server/config"
	"github.com/prebid/prebid-server/openrtb_ext"
)

// TCF2ConfigReader is an interface to access TCF2 configurations
type TCF2ConfigReader interface {
	BasicEnforcementVendors() map[string]struct{}
	FeatureOneEnforced() bool
	FeatureOneVendorException(openrtb_ext.BidderName) bool
	ChannelEnabled(config.ChannelType) bool
	IsEnabled() bool
	PurposeEnforced(consentconstants.Purpose) bool
	PurposeEnforcementAlgo(consentconstants.Purpose) config.TCF2EnforcementAlgo
	PurposeEnforcingVendors(consentconstants.Purpose) bool
	PurposeVendorExceptions(consentconstants.Purpose) map[openrtb_ext.BidderName]struct{}
	PurposeOneTreatmentEnabled() bool
	PurposeOneTreatmentAccessAllowed() bool
}

type TCF2ConfigBuilder func(hostConfig config.TCF2, accountConfig config.AccountGDPR) TCF2ConfigReader

type tcf2Config struct {
	HostConfig    config.TCF2
	AccountConfig config.AccountGDPR
}

// NewTCF2Config creates an instance of tcf2Config which implements the TCF2ConfigReader interface
func NewTCF2Config(hostConfig config.TCF2, accountConfig config.AccountGDPR) TCF2ConfigReader {
	return &tcf2Config{
		HostConfig:    hostConfig,
		AccountConfig: accountConfig,
	}
}

// IsEnabled indicates if TCF2 is enabled
func (tc *tcf2Config) IsEnabled() bool {
	return tc.HostConfig.Enabled
}

// ChannelEnabled checks if a given channel type is enabled at the account level. If it is not set at the
// account level, the host TCF2 enabled flag is used to determine if the channel type is enabled.
func (tc *tcf2Config) ChannelEnabled(channelType config.ChannelType) bool {
	if accountEnabled := tc.AccountConfig.EnabledForChannelType(channelType); accountEnabled != nil {
		return *accountEnabled
	}
	return tc.HostConfig.Enabled
}

// PurposeEnforced checks if full enforcement is turned on for a given purpose by first looking at the account
// settings, and if not set there, defaulting to the host configuration. With full enforcement enabled, the
// GDPR full enforcement algorithm will execute for that purpose determining legal basis; otherwise it's skipped.
func (tc *tcf2Config) PurposeEnforced(purpose consentconstants.Purpose) bool {
	if value, exists := tc.AccountConfig.PurposeEnforced(purpose); exists {
		return value
	}

	value := tc.HostConfig.PurposeEnforced(purpose)
	return value
}

// PurposeEnforcementAlgo checks the purpose enforcement algo for a given purpose by first
// looking at the account settings, and if not set there, defaulting to the host configuration.
func (tc *tcf2Config) PurposeEnforcementAlgo(purpose consentconstants.Purpose) config.TCF2EnforcementAlgo {
	if value, exists := tc.AccountConfig.PurposeEnforcementAlgo(purpose); exists {
		return value
	}
	return tc.HostConfig.PurposeEnforcementAlgo(purpose)
}

// PurposeEnforcingVendors checks if enforcing vendors is turned on for a given purpose by first looking at the
// account settings, and if not set there, defaulting to the host configuration. With enforcing vendors enabled,
// the GDPR full enforcement algorithm considers the GVL when determining legal basis; otherwise it's skipped.
func (tc *tcf2Config) PurposeEnforcingVendors(purpose consentconstants.Purpose) bool {
	if value, exists := tc.AccountConfig.PurposeEnforcingVendors(purpose); exists {
		return value
	}

	value := tc.HostConfig.PurposeEnforcingVendors(purpose)
	return value
}

// PurposeVendorExceptions returns the vendor exception map for the specified purpose if it exists for the account;
// otherwise it returns a nil map. If a bidder is a vendor exception, the GDPR full enforcement algorithm will
// bypass the legal basis calculation assuming the request is valid and there isn't a "deny all" publisher restriction
func (tc *tcf2Config) PurposeVendorExceptions(purpose consentconstants.Purpose) map[openrtb_ext.BidderName]struct{} {
	if value, exists := tc.AccountConfig.PurposeVendorExceptions(purpose); exists {
		return value
	}
	return tc.HostConfig.PurposeVendorExceptions(purpose)
}

// FeatureOneEnforced checks if special feature one is enforced by first looking at the account settings, and if not
// set there, defaulting to the host configuration. If it is enforced, PBS will determine whether geo information
// may be passed through in the bid request.
func (tc *tcf2Config) FeatureOneEnforced() bool {
	if value, exists := tc.AccountConfig.FeatureOneEnforced(); exists {
		return value
	}
	value := tc.HostConfig.FeatureOneEnforced()
	return value
}

// FeatureOneVendorException checks if the specified bidder is considered a vendor exception for special feature one
// by first looking at the account settings, and if not set there, defaulting to the host configuration. If a bidder
// is a vendor exception, PBS will bypass the pass geo calculation passing the geo information in the bid request.
func (tc *tcf2Config) FeatureOneVendorException(bidder openrtb_ext.BidderName) bool {
	if value, exists := tc.AccountConfig.FeatureOneVendorException(bidder); exists {
		return value
	}
	value := tc.HostConfig.FeatureOneVendorException(bidder)
	return value
}

// PurposeOneTreatmentEnabled checks if purpose one treatment is enabled by first looking at the account settings, and
// if not set there, defaulting to the host configuration.
func (tc *tcf2Config) PurposeOneTreatmentEnabled() bool {
	if value, exists := tc.AccountConfig.PurposeOneTreatmentEnabled(); exists {
		return value
	}
	value := tc.HostConfig.PurposeOneTreatmentEnabled()
	return value
}

// PurposeOneTreatmentAccessAllowed checks if purpose one treatment access is allowed by first looking at the account
// settings, and if not set there, defaulting to the host configuration.
func (tc *tcf2Config) PurposeOneTreatmentAccessAllowed() bool {
	if value, exists := tc.AccountConfig.PurposeOneTreatmentAccessAllowed(); exists {
		return value
	}
	value := tc.HostConfig.PurposeOneTreatmentAccessAllowed()
	return value
}

// BasicEnforcementVendors returns the basic enforcement map if it exists for the account; otherwise it returns
// an empty map. If a bidder is considered a basic enforcement vendor, the legal basis calculation for the bidder
// only considers consent to the purpose, not the vendor. The idea is that the publisher trusts this vendor to
// enforce the appropriate rules on their own. This only comes into play when enforceVendors is true as it lists
// those vendors that are exempt for vendor enforcement.
func (tc *tcf2Config) BasicEnforcementVendors() map[string]struct{} {
	if tc.AccountConfig.BasicEnforcementVendorsMap != nil {
		return tc.AccountConfig.BasicEnforcementVendorsMap
	}
	return make(map[string]struct{}, 0)
}


text:
require 'uri'
require 'domainatrix'

module Sherlock
  class Inspector
    include Sherlock::Utils::URL_Utils

    attr_accessor :url,:client
    attr_reader   :scheme,:fetched,:host,:domain,:path,:port,:params

    def initialize(url)
      setup_inspector(url)
    end

    def url=(url)
      setup_inspector(url)
    end

    #STATUS METHODS
    def exists?
      fetch_url_with_method('head')
      !@client.status.to_s.match(/^4[0-9]{2}/) ? true : false
    end

    def redirected?
      fetch_url_with_method('head')
      @client.status.to_s.match(/^3[0-9]{2}/) ? true : false
    end

    def success?
      fetch_url_with_method('head')
      @client.status.to_s.match(/^2[0-9]{2}/) ? true : false
    end

    #CURRENTLY ONLY SUPPORTING HTTP/HTTPS
    def fetchable?
      @scheme.downcase.to_s.match(/http/) ? true : false
    end

    def fetched?
      @client.fetched.eql?(true) ? true : false
    end

    def fetch
      @client.fetch
      @content = @client.content
      return self
    end

    private
    def fetch_url_with_method(request_method)
      if !fetched? && (@client.request_method != request_method)
        @client.request_method = request_method
      end
      return true
    end

    def setup_inspector(url)
      validate_url(url)
      @url       = sanitize_url(url)
      parsed_url = Domainatrix.parse(@url)
      @scheme    = parsed_url.scheme
      @host      = parsed_url.host
      @domain    = parsed_url.domain
      @path      = parsed_url.path
      @port      = parse_port(@url)
      @params    = parse_url_params(@url)
      @client    = Sherlock::Client.new(@url)
      @content   = @client.content
    end

    def method_missing(method_name, *args, &block)
      if @client.respond_to?(method_name)
        return @client.send(method_name, *args, &block)
      elsif @content.respond_to?(method_name)
        return @content.send(method_name, *args, &block)
      else
        return super
      end
    end
  end
end


text:
<!DOCTYPE html>

    <title>sf Admin</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta charset="utf-8">

    {!! HTML::style('assets/bootstrap/css/backend_bootstrap.css') !!}
    {!! HTML::style('assets/bootstrap/css/signin.css') !!}

 Admin

Forgot Password

                    {!! Form::open(array('class' => 'form-signup', 'id' => 'form-signin')) !!}

                    @if ($errors->has('forgot-password'))

                        ×{!! $errors->first('forgot-password', ':message') !!}

                    @endif

                    @if ($errors->has('email'))

                        ×{!! $errors->first('email', ':message') !!}

                    @endif

                            {!! Form::text('email', null,array('class' => 'form-control', 'placeholder'=>'Email', 'autofocus'=>'')) !!}

                    {!! Form::submit('Send Password', array('class' => 'btn btn-sm btn-primary btn-block', 'role'=>'button')) !!}
                    {!! Form::close() !!}


text:
function varargout = click(varargin)
% VL_CLICK  Click a point
%  P=VL_CLICK() let the user click a point in the current figure and
%  returns its coordinates in P. P is a two dimensiona vectors where
%  P(1) is the point X-coordinate and P(2) the point Y-coordinate. The
%  user can abort the operation by pressing any key, in which case the
%  empty matrix is returned.
%
%  P=VL_CLICK(N) lets the user select N points in a row. The user can
%  stop inserting points by pressing any key, in which case the
%  partial list is returned.
%
%  VL_CLICK() accepts the following options:
%
%  PlotMarker [0]::
%    Plot a marker as points are selected. The markers are deleted on
%    exiting the function.
%
%  See also:: VL_CLICKPOINT(), HELP_VLEAT().
[varargout{1:nargout}] = vl_click(varargin{:});