Beispiel #1
0
        public static List <JointCondition> FindJointConditions(List <Element> elements, double radius = 100.0, double end_threshold = 10.0, double merge_distance = 50.0)
        {
            if (elements.Count < 1)
            {
                throw new Exception("FindJointConditions(): No elements in list!");
            }

            var jcs = new List <JointCondition>();

            for (int i = 0; i < elements.Count - 1; ++i)
            {
                var crv0 = (elements[i] as BeamElement).Beam.Centreline;

                for (int j = i + 1; j < elements.Count; ++j)
                {
                    var crv1 = (elements[j] as BeamElement).Beam.Centreline;

                    var res = Rhino.Geometry.Intersect.Intersection.CurveCurve(crv0, crv1, radius, radius);

                    foreach (var r in res)
                    {
                        var pos = (r.PointA + r.PointB) / 2;

                        var tA = r.ParameterA;
                        var tB = r.ParameterB;

                        var lA = crv0.GetLength(new Interval(crv0.Domain.Min, tA));
                        var lB = crv1.GetLength(new Interval(crv1.Domain.Min, tB));

                        var crv0Length = crv0.GetLength();
                        var crv1Length = crv1.GetLength();

                        int case0 = Math.Abs(lA) < end_threshold || Math.Abs(lA - crv0Length) < end_threshold ? 0 : 1;
                        int case1 = Math.Abs(lB) < end_threshold || Math.Abs(lB - crv1Length) < end_threshold ? 0 : 1;

                        if ((case0 | (case1 << 1)) > 0 && Math.Abs(crv0.TangentAt(tA) * crv1.TangentAt(tB)) > 0.95)
                        {
                            case0 = 0;
                            case1 = 0;
                        }

                        var jc = new JointCondition(pos,
                                                    new List <JointConditionPart>()
                        {
                            new JointConditionPart(i, case0, tA),
                            new JointConditionPart(j, case1, tB)
                        });

                        jcs.Add(jc);
                    }
                }
            }

            return(MergeJointConditions(jcs, merge_distance));
        }
Beispiel #2
0
        public static List <JointCondition> FindJointConditions(List <Curve> curves, double radius = 100.0, double end_threshold = 10.0, double merge_distance = 50.0)
        {
            var jcs = new List <JointCondition>();

            for (int i = 0; i < curves.Count - 1; ++i)
            {
                for (int j = i + 1; j < curves.Count; ++j)
                {
                    var crv0 = curves[i];
                    var crv1 = curves[j];

                    var res = Rhino.Geometry.Intersect.Intersection.CurveCurve(crv0, crv1, radius, radius);

                    foreach (var r in res)
                    {
                        var pos = (r.PointA + r.PointB) / 2;

                        var tA = r.ParameterA;
                        var tB = r.ParameterB;

                        var lA = crv0.GetLength(new Interval(crv0.Domain.Min, tA));
                        var lB = crv1.GetLength(new Interval(crv1.Domain.Min, tB));

                        var crv0Length = crv0.GetLength();
                        var crv1Length = crv1.GetLength();

                        int case0 = Math.Abs(lA) < end_threshold || Math.Abs(lA - crv0Length) < end_threshold ? 0 : 1;
                        int case1 = Math.Abs(lB) < end_threshold || Math.Abs(lB - crv1Length) < end_threshold ? 0 : 1;

                        var jc = new JointCondition(pos,
                                                    new List <JointConditionPart>()
                        {
                            new JointConditionPart(i, case0, tA),
                            new JointConditionPart(j, case1, tB)
                        });

                        jcs.Add(jc);
                    }
                }
            }

            return(MergeJointConditions(jcs, merge_distance));
        }
Beispiel #3
0
 public void Absorb(JointCondition jc)
 {
     Parts.AddRange(jc.Parts);
     Parts = Parts.Distinct().ToList();
 }