@@ -341,7 +341,8 @@ export class OperationService {
341341 row . forEach ( ( cell , j ) => {
342342 const select_col = ( factor_in_repeats === 1 ) ? j % op_input . drafts [ select_array ] . warps : j ;
343343 if ( op_input . drafts [ select_array ] . hasCell ( select_row , select_col ) ) {
344- cell . setHeddle ( op_input . drafts [ select_array ] . pattern [ select_row ] [ select_col ] . getHeddle ( ) ) ;
344+ const pattern = op_input . drafts [ select_array ] . pattern ;
345+ cell . setHeddle ( pattern [ select_row ] [ select_col ] . getHeddle ( ) ) ;
345346 } else {
346347 cell . setHeddle ( null ) ;
347348 }
@@ -669,63 +670,71 @@ export class OperationService {
669670 const selvedge : Operation = {
670671 name : 'selvedge' ,
671672 displayname : 'selvedge' ,
672- dx : 'adds a selvedge of a user defined with both sides of the input draft. User can specify the number of row repeats in the selvedge' ,
673+ dx : 'adds a selvedge of a user defined width (in ends) on both sides of the input draft. The second input functions as the selvedge pattern, and if none is selected, a selvedge is generated ' ,
673674 params : [
674675 { name : 'width' ,
675676 type : 'number' ,
676677 min : 1 ,
677678 max : 100 ,
678679 value : 12 ,
679680 dx : "the width in warps of the selvedge"
680- } ,
681- { name : 'repeats' ,
682- type : 'number' ,
683- min : 1 ,
684- max : 100 ,
685- value : 1 ,
686- dx : "the number of pics to repeat each selvedge structure, usually equal to the number of shuttles thrown"
687681 }
688682 ] ,
689- max_inputs : 1 ,
683+ max_inputs : 2 ,
690684 perform : ( op_inputs : Array < OpInput > ) => {
691685 const op_input = op_inputs [ 0 ] ;
686+ if ( op_input . drafts . length == 0 ) return Promise . resolve ( [ ] ) ;
687+
688+ const num_systems = utilInstance . filterToUniqueValues ( op_input . drafts [ 0 ] . rowSystemMapping ) . length ;
689+ const height = 2 * num_systems ;
692690
693- const height = 2 * op_input . params [ 1 ] ;
694691
695- const pattern :Array < Array < Cell > > = [ ] ;
696- for ( let i = 0 ; i < height ; i ++ ) {
697- pattern . push ( [ ] ) ;
698- let alt : boolean = i < op_input . params [ 1 ] ;
699- for ( let j = 0 ; j < 2 ; j ++ ) {
700- pattern [ i ] [ j ] = ( ( alt && j % 2 == 0 ) || ( ! alt && j % 2 == 1 ) ) ? new Cell ( true ) : new Cell ( false ) ;
692+ let pattern :Array < Array < Cell > > = [ ] ;
693+
694+ if ( op_input . drafts . length == 2 ) {
695+ pattern = op_input . drafts [ 1 ] . pattern ;
696+ } else {
697+ for ( let i = 0 ; i < height ; i ++ ) {
698+ pattern . push ( [ ] ) ;
699+ let alt : boolean = i < num_systems ;
700+ for ( let j = 0 ; j < 2 ; j ++ ) {
701+ pattern [ i ] [ j ] = ( ( alt && j % 2 == 0 ) || ( ! alt && j % 2 == 1 ) ) ? new Cell ( true ) : new Cell ( false ) ;
702+ }
701703 }
702704 }
705+
706+
707+
708+ const input : Draft = op_input . drafts [ 0 ] ;
709+ const d : Draft = new Draft ( { warps : input . warps + op_input . params [ 0 ] * 2 , wefts : input . wefts } ) ;
710+
711+
712+ for ( let i = 0 ; i < d . wefts ; i ++ ) {
713+ for ( let j = 0 ; j < d . warps ; j ++ ) {
714+ if ( j < op_input . params [ 0 ] ) {
715+ //left selvedge
716+ d . pattern [ i ] [ j ] . setHeddle ( pattern [ ( i + 1 ) % pattern . length ] [ j % pattern [ 0 ] . length ] . getHeddle ( ) ) ;
703717
704- let outputs : Array < Draft > = [ ] ;
705- if ( op_input . drafts . length == 0 ) {
706- const d : Draft = new Draft ( { warps :op_input . params [ 0 ] * 2 , wefts : height } ) ;
707- d . fill ( pattern , 'original' ) ;
708- outputs . push ( d ) ;
709- } else {
710- outputs = op_input . drafts . map ( input => {
711- const d : Draft = new Draft ( { warps : input . warps + op_input . params [ 0 ] * 2 , wefts : input . wefts } ) ;
712- d . fill ( pattern , 'original' ) ;
713- if ( op_input . drafts . length > 0 ) {
714- this . transferSystemsAndShuttles ( d , op_input . drafts , op_input . params , 'first' ) ;
715- d . gen_name = this . formatName ( op_input . drafts , "sel" )
718+ } else if ( j < op_input . params [ 0 ] + input . warps ) {
719+ //pattern
720+ d . pattern [ i ] [ j ] . setHeddle ( input . pattern [ i ] [ j - op_input . params [ 0 ] ] . getHeddle ( ) ) ;
721+
722+ } else {
723+ //right selvedge
724+ d . pattern [ i ] [ j ] . setHeddle ( pattern [ i % pattern . length ] [ j % pattern [ 0 ] . length ] . getHeddle ( ) ) ;
716725
717726 }
718- for ( let i = 0 ; i < input . wefts ; i ++ ) {
719- for ( let j = 0 ; j < input . warps ; j ++ ) {
720- d . pattern [ i ] [ j + op_input . params [ 0 ] ] . setHeddle ( input . pattern [ i ] [ j ] . getHeddle ( ) ) ;
721- }
722- }
727+ }
728+ }
729+
730+ if ( op_input . drafts . length > 0 ) {
731+ this . transferSystemsAndShuttles ( d , op_input . drafts , op_input . params , 'first' ) ;
732+ d . gen_name = this . formatName ( op_input . drafts , "sel" )
723733
724- return d ;
725- } ) ;
726734 }
727735
728- return Promise . resolve ( outputs ) ;
736+
737+ return Promise . resolve ( [ d ] ) ;
729738 }
730739 }
731740
@@ -3028,8 +3037,7 @@ export class OperationService {
30283037 total_warps = utilInstance . lcm ( all_warps ) ;
30293038
30303039
3031- //create a map from layers to drafts
3032- const section_draft_map : Array < any > = child_inputs . map ( el => { return { section : el . params [ 0 ] - 1 , draft : el . drafts . shift ( ) } } ) ;
3040+ const section_draft_map : Array < any > = child_inputs . map ( el => { return { section : el . inlet - 1 , draft : el . drafts . shift ( ) } } ) ;
30333041 const first_draft : Draft = section_draft_map [ 0 ] . draft ;
30343042
30353043 const d :Draft = new Draft ( {
@@ -3282,8 +3290,8 @@ export class OperationService {
32823290 this . ops . push ( shifty ) ;
32833291 this . ops . push ( layer ) ;
32843292 this . ops . push ( selvedge ) ;
3285- this . ops . push ( bindweftfloats ) ;
3286- this . ops . push ( bindwarpfloats ) ;
3293+ // this.ops.push(bindweftfloats);
3294+ // this.ops.push(bindwarpfloats);
32873295 this . ops . push ( joinleft ) ;
32883296 this . ops . push ( jointop ) ;
32893297 this . ops . push ( slope ) ;
@@ -3322,7 +3330,7 @@ export class OperationService {
33223330 this . classification . push (
33233331 { category : 'block design' ,
33243332 dx : "1 input, 1 output, describes the arragements of regions in a weave. Fills region with input draft" ,
3325- ops : [ imagemap , rect , crop , trim , margin , tile ]
3333+ ops : [ rect , crop , trim , margin , tile ]
33263334 }
33273335 ) ;
33283336 this . classification . push (
@@ -3334,7 +3342,7 @@ export class OperationService {
33343342 this . classification . push (
33353343 { category : 'combine' ,
33363344 dx : "2 inputs, 1 output, operations take more than one input and integrate them into a single draft in some way" ,
3337- ops : [ interlace , splicein , assignlayers , layer , fill , joinleft , dynamic_join_left , jointop ] }
3345+ ops : [ imagemap , interlace , splicein , assignlayers , layer , fill , joinleft , dynamic_join_left , jointop ] }
33383346 ) ;
33393347
33403348 this . classification . push (
0 commit comments