public override bool Apply(HinterShapeBase hinterShape) { if (hinterShape.Builder.FunctionName != FunctionNames.LineTwoPoints) { return(false); } var lineShape = (LineHinterShape)hinterShape; if (lineShape.Point1.IsEqual(lineShape.Point2)) { return(false); } var axisDir = GetPointsDirection(lineShape.Point1, lineShape.Point2); foreach (var direction in _lineDirections) { if (hinterShape.Builder.Node.Index == direction.Key) { continue; } var result = LinesAxisMatch(axisDir, direction.Value, Options.ParallelAngle); if (!result) { continue; } var constraint = AddConstraint(lineShape, Hinter2D.HinterShapes[direction.Key], FunctionName); if (constraint != null) { constraintNodes.Add(constraint); } return(true); } return(false); }
public override bool Apply(HinterShapeBase hinterShape) { if (hinterShape.Builder.FunctionName != FunctionNames.LineTwoPoints) { return(false); } var lineShape = (LineHinterShape)hinterShape; var result = AxisParallel(lineShape.Point1, lineShape.Point2, Options.ParallelAngle); if (!result) { return(false); } AddConstraint(lineShape, _function); var builder = new NodeBuilder(hinterShape.Builder.Node) { Color = Color.DarkOrange }; builder.ExecuteFunction(); return(true); }
public override bool Apply(HinterShapeBase hinterShape) { if (hinterShape.Builder.FunctionName != FunctionNames.Point) { return(false); } var pointShape = (PointHinterShape)hinterShape; var sourcePoint = pointShape.Position; var refByList = _graph.GetReferredBy(hinterShape.Builder.Node); foreach (var shape in Hinter2D.HinterShapes.Values) { if (shape.Builder.FunctionName != FunctionNames.LineTwoPoints) { continue; } var line = (LineHinterShape)shape; if (refByList.Contains(shape.Builder.Node.Index)) { continue; } var result = CheckAndApplyPointMiddleOfLine(pointShape, line, sourcePoint); if (result) { return(true); } } return(false); }
protected NodeBuilder AddConstraint(HinterShapeBase shape, HinterShapeBase destination, string constraintName) { if (shape.Builder.Node.Index != destination.Builder.Node.Index) { return(AddConstraint(shape.Builder.Node, destination.Builder.Node, constraintName)); } return(null); }
private HinterShapeBase GetHinterShape(NodeBuilder builder) { HinterShapeCreatorBase creator; HinterShapeBase shape = null; if (_hinterShapeCreators.TryGetValue(builder.FunctionName, out creator)) { shape = creator.Create(builder); } return(shape); }
public abstract bool Apply(HinterShapeBase hinterShape);
protected void AddConstraint(HinterShapeBase shape, string constraintName) { AddConstraint(shape.Builder.Node, constraintName); }