public override Wrapper VisitPose(PreposeGesturesParser.PoseContext context) { var bt = new CompositeBodyTransform(); var br = new CompositeBodyRestriction(); var ds = new CompositeDelayedStatement(); foreach (var s in context.statement()) { Contract.Assert(s != null); var w = this.Visit(s); Contract.Assert(w != null); var statement = w.GetValue(); if (statement != null) { if (statement is CompositeBodyTransform) { bt = bt.Compose((CompositeBodyTransform)statement); continue; } if (statement is CompositeBodyRestriction) { br = br.And((CompositeBodyRestriction)statement); continue; } if (statement is CompositeDelayedStatement) { ds = ds.Compose((CompositeDelayedStatement)statement); continue; } throw new ArgumentException("Wrong return type"); } } var pose = new Pose(context.ID().GetText(), bt, br, ds); if (this.Poses.ContainsKey(pose.Name)) { throw new ArgumentException("Pose " + pose.Name + " has been previosly seen."); } this.Poses.Add(pose.Name, pose); return(new Wrapper(pose)); }
// this is the rotate action working as a transform // this was temporarily changed to make the rotate action work as a restriction as shown blow public override Wrapper VisitRotate_direction_transform(PreposeGesturesParser.Rotate_direction_transformContext context) { var delayed = new CompositeDelayedStatement(); var direction = (Direction)this.Visit(context.direction()); var degreesText = context.NUMBER().GetText(); var degrees = Convert.ToInt32(degreesText); foreach (var b in context.body_part()) { var converted = (JointGroup)this.Visit(b); delayed = delayed.Compose( converted.Aggregate(joint => new CompositeDelayedStatement( new RotateDelayedStatement(joint, direction, degrees)))); } return(new Wrapper(delayed)); }