function walkRecursive()

in packages/maker.js/src/core/model.ts [566:618]


        function walkRecursive(modelContext: IModel, layer: string, offset: IPoint, route: string[], routeKey: string) {

            var newOffset = point.add(modelContext.origin, offset);
            layer = (layer != undefined) ? layer : '';

            if (modelContext.paths) {
                for (var pathId in modelContext.paths) {

                    var pathContext = modelContext.paths[pathId];
                    if (!pathContext) continue;

                    var walkedPath: IWalkPath = {
                        modelContext: modelContext,
                        layer: (pathContext.layer != undefined) ? pathContext.layer : layer,
                        offset: newOffset,
                        pathContext: pathContext,
                        pathId: pathId,
                        route: route.concat(['paths', pathId]),
                        routeKey: routeKey + (routeKey ? '.' : '') + 'paths' + JSON.stringify([pathId])
                    };

                    if (options.onPath) options.onPath(walkedPath);
                }
            }

            if (modelContext.models) {
                for (var modelId in modelContext.models) {

                    var childModel = modelContext.models[modelId];
                    if (!childModel) continue;

                    var walkedModel: IWalkModel = {
                        parentModel: modelContext,
                        layer: (childModel.layer != undefined) ? childModel.layer : layer,
                        offset: newOffset,
                        route: route.concat(['models', modelId]),
                        routeKey: routeKey + (routeKey ? '.' : '') + 'models' + JSON.stringify([modelId]),
                        childId: modelId,
                        childModel: childModel
                    };

                    if (options.beforeChildWalk) {
                        if (!options.beforeChildWalk(walkedModel)) continue;
                    }

                    walkRecursive(walkedModel.childModel, walkedModel.layer, newOffset, walkedModel.route, walkedModel.routeKey);

                    if (options.afterChildWalk) {
                        options.afterChildWalk(walkedModel);
                    }
                }
            }
        }