Пример #1
0
        public void Generate(bool label = true)
        {
            ClashedJoints.Clear();
            ClashedRods.Clear();

            CalculateRodOffsets();
            GenerateRodMeshes();
            GenerateJointMeshes(label);
        }
Пример #2
0
        public Tuple <List <Tuple <int, int> >, List <int> > CalculateClashes()
        {
            ClashedRods.Clear();
            ClashedJoints.Clear();

            var rodKeys   = RodMeshes.Keys.ToList();
            var rodVals   = RodMeshes.Values.ToList();
            var jointKeys = JointMeshes.Keys.ToList();
            var jointVals = JointMeshes.Values.ToList();

            for (int i = 0; i < rodKeys.Count; i++)
            {
                for (int j = i + 1; j < rodKeys.Count; j++)
                {
                    if (ClashedRods.Contains(rodKeys[i]) && ClashedRods.Contains(rodKeys[j]))
                    {
                        continue;
                    }

                    var intersect = Rhino.Geometry.Intersect.Intersection.MeshMeshFast(rodVals[i], rodVals[j]);
                    if (intersect != null && intersect.Length > 0)
                    {
                        ClashedRods.Add(rodKeys[i]);
                        ClashedRods.Add(rodKeys[j]);
                    }
                }

                for (int j = 0; j < jointKeys.Count; j++)
                {
                    if (rodKeys[i].Item1 == jointKeys[j] || rodKeys[i].Item2 == jointKeys[j])
                    {
                        continue;
                    }

                    if (ClashedRods.Contains(rodKeys[i]) && ClashedJoints.Contains(jointKeys[j]))
                    {
                        continue;
                    }

                    foreach (var jv in jointVals[j])
                    {
                        var intersect = Rhino.Geometry.Intersect.Intersection.MeshMeshFast(rodVals[i], jv);
                        if (intersect != null && intersect.Length > 0)
                        {
                            ClashedRods.Add(rodKeys[i]);
                            ClashedJoints.Add(jointKeys[j]);
                            break;
                        }
                    }
                }
            }

            var hit = false;

            for (int i = 0; i < jointKeys.Count; i++)
            {
                for (int j = i + 1; j < jointKeys.Count; j++)
                {
                    if (ClashedJoints.Contains(jointKeys[i]) && ClashedJoints.Contains(jointKeys[j]))
                    {
                        continue;
                    }

                    foreach (var iv in jointVals[i])
                    {
                        foreach (var jv in jointVals[j])
                        {
                            var intersect = Rhino.Geometry.Intersect.Intersection.MeshMeshFast(iv, jv);
                            if (intersect != null && intersect.Length > 0)
                            {
                                ClashedJoints.Add(jointKeys[i]);
                                ClashedJoints.Add(jointKeys[j]);
                                hit = true;
                                break;
                            }
                        }
                        if (hit)
                        {
                            hit = false;
                            break;
                        }
                    }
                }
            }

            return(Tuple.Create(ClashedRods, ClashedJoints));
        }