public void Apply(IStencil stencil) { stencil.SetGridTransform(transform); dirty = true; int xStart, xEnd, yStart, yEnd; xStart = yStart = 0; xEnd = yEnd = resolution - 1; for (int y = yStart; y <= yEnd; y++) { int i = y * resolution + xStart; for (int x = xStart; x <= xEnd; x++, i++) { //var pos = voxels[i].WorldPos; //var color = stencil.IsOverlapping(voxels[i]) ? Color.green : Color.red; //Debug.DrawLine(pos, pos + Vector3.one * 0.01f, color); if (stencil.IsOverlapping(voxels[i])) { voxels[i].state = stencil.IsFilling(); } } } SetCrossings(stencil, xStart, xEnd, yStart, yEnd); }
private IList <Stencil_mapping> map_first_nodes( IStencil stencil, IFigure_representation target ) { //get arrays of stencil's subnodes // index = figure; // value = appearances of its subfigures in the beginning of the stencil IList <IList <ISubfigure> > appearances_in_stencil = new List <IList <ISubfigure> >(); //get array of target's subnodes IList <IList <ISubfigure> > appearances_in_target = new List <IList <ISubfigure> >(); //initialise combinator int figures_qty = appearances_in_stencil.Count; // array of figures -> // array of their appearances in the stencil -> // target's subfigure onto which it's mapped var combinator_input = new List <Mapping_enumerator_requirement>(); foreach (var appearances_in_source in appearances_in_stencil) { IFigure mapped_figure = appearances_in_source.First().referenced_figure; IReadOnlyList <ISubfigure> appearances_int_target = get_appearances_of_figure_in_graph(mapped_figure, target); combinator_input.Add( //array of stencil's subfigures which need mapping new Mapping_enumerator_requirement( appearances_in_source.Count, appearances_int_target.Count ) ); } Enumerator_of_orders enumerator_of_orders = new Enumerator_of_orders( combinator_input ); //transform iterations of combinator into potential mappings foreach (var combination in enumerator_of_orders) { var test = combination; } IList <IList <ISubfigure> > subnode_occurances = get_all_subnodes_occurances(stencil, target); IList <Stencil_mapping> potential_mappings = recombine_subnodes_as_mappings(subnode_occurances); return(potential_mappings); }
private IList <Stencil_mapping> map_stencil_onto_target( IStencil stencil, IFigure_representation target ) { IList <Stencil_mapping> potential_mappings = map_first_nodes(stencil, target); for (int i_node = 1; i_node < stencil.get_subfigures().Count; i_node++) { ISubfigure subfigure = stencil.get_subfigures()[i_node]; //map_next_node(potential_mappings, subfigure, target); } return(potential_mappings); }
private IList <IList <ISubfigure> > get_all_subnodes_occurances( IStencil stencil, IFigure_representation target ) { IList <IList <ISubfigure> > subnode_occurances = new List <IList <ISubfigure> >(); foreach (ISubfigure subfigure in stencil.get_first_subfigures()) { IList <ISubfigure> occurances = get_occurances_of_subnode_in_graph( subfigure.referenced_figure, target ); subnode_occurances.Add(occurances); } return(subnode_occurances); }
// public static IList<IFigure> apply_stencil( // Stencil stencil, // IReadOnlyList<IAction_group> action_groups // ) { // // stencils can be only applied to the Figures. // // conversion img: conversion of Action_istory into Figure // IFigure figure = create_figure_from_action_history(action_groups); // return apply_stencil(stencil, figure); // } public IList <IFigure> apply_stencil( IStencil stencil, IFigure_representation target ) { IList <Stencil_mapping> mappings = map_stencil_onto_target(stencil, target); foreach (Stencil_mapping mapping in mappings) { IReadOnlyList <IFigure> out_figures = extract_figures_out_of_projected_stencils(mapping); } return(null); }
private void EditVoxels(IStencil activeStencil, bool ignoreFilter = false) { int xStart, xEnd, yStart, yEnd; xStart = yStart = 0; xEnd = yEnd = chunkResolution - 1; // go in reverse order for neighbour handling for (int y = yEnd; y >= yStart; y--) { int i = y * chunkResolution + xEnd; for (int x = xEnd; x >= xStart; x--, i--) { var c = chunks[i]; if (ignoreFilter || gridsToEdit.Contains(c)) { c.Apply(activeStencil); } } } }
private void SetCrossings( IStencil stencil, int xStart, int xEnd, int yStart, int yEnd) { bool crossHorizontalGap = false; bool includeLastVerticalRow = false; bool crossVerticalGap = false; if (xStart > 0) { xStart -= 1; } if (xEnd == resolution - 1) { xEnd -= 1; crossHorizontalGap = xNeighbor != null; } if (yStart > 0) { yStart -= 1; } if (yEnd == resolution - 1) { yEnd -= 1; includeLastVerticalRow = true; crossVerticalGap = yNeighbor != null; } Voxel a, b; for (int y = yStart; y <= yEnd; y++) { int i = y * resolution + xStart; b = voxels[i]; for (int x = xStart; x <= xEnd; x++, i++) { a = b; b = voxels[i + 1]; stencil.SetHorizontalCrossing(a, b); stencil.SetVerticalCrossing(a, voxels[i + resolution]); } stencil.SetVerticalCrossing(b, voxels[i + resolution]); if (crossHorizontalGap) { dummyX.BecomeXDummyOf( xNeighbor.voxels[y * resolution], gridSize); stencil.SetHorizontalCrossing(b, dummyX); } } if (includeLastVerticalRow) { int i = voxels.Length - resolution + xStart; b = voxels[i]; for (int x = xStart; x <= xEnd; x++, i++) { a = b; b = voxels[i + 1]; stencil.SetHorizontalCrossing(a, b); if (crossVerticalGap) { dummyY.BecomeYDummyOf(yNeighbor.voxels[x], gridSize); stencil.SetVerticalCrossing(a, dummyY); } } if (crossVerticalGap) { dummyY.BecomeYDummyOf(yNeighbor.voxels[xEnd + 1], gridSize); stencil.SetVerticalCrossing(b, dummyY); } if (crossHorizontalGap) { dummyX.BecomeXDummyOf( xNeighbor.voxels[voxels.Length - resolution], gridSize); stencil.SetHorizontalCrossing(b, dummyX); } } }