import { createBounds, extendBounds, } from "@intelligentgraphics/ig.gfx.core";
const roundToMM = (value) => Math.round(value * 1000) / 1000;
/**
 * Provides the dimensions of elements inside of the graphical scene
 *
 * @export
 * @class SceneDimensionsProvider
 * @implements {IMeasurementDimensionsProvider}
 */
export class MeasurementSceneDimensionsProvider {
    constructor(api) {
        this.api = api;
    }
    getGroupDimensions(articles) {
        const bounds = createBounds();
        for (const { gfxId } of articles) {
            const articleBounds = this.api.GetBounds(gfxId, "World");
            extendBounds(bounds, articleBounds.min);
            extendBounds(bounds, articleBounds.max);
        }
        return this.createDimensions(bounds);
    }
    getArticleDimensions(article) {
        const bounds = this.api.GetBounds(article.gfxId, "World");
        return this.createDimensions(bounds);
    }
    createDimensions(bounds) {
        return {
            width: roundToMM(bounds.max.x - bounds.min.x),
            height: roundToMM(bounds.max.y - bounds.min.y),
            depth: roundToMM(bounds.max.z - bounds.min.z),
        };
    }
}
