예제 #1
0
        public Asystem(List <double> _values, Mesh _mesh, List <bool> _cull)
        {
            Apoints = new List <Apoint>();
            mesh    = _mesh;

            for (int i = 0; i < _mesh.Vertices.Count; i++)
            {
                if (_cull[i])
                {
                    Apoints.Add(new Apoint(_mesh.Vertices[i], i, _values));
                }
            }

            InitAll();
            InitNeighbours(_mesh);

            MeshTopologyVertexList all = _mesh.TopologyVertices;

            for (int i = 0; i < Apoints.Count; i++)
            {
                int[] connected = all.ConnectedTopologyVertices(Apoints[i].Index);
                for (int j = 0; j < connected.Length; j++)
                {
                    if (!_cull[connected[j]])
                    {
                        Apoints[i].EdgePoint = true;
                    }
                }
            }
        }
예제 #2
0
        public void InHull(Polyline _hull, bool _solid)
        {
            List <bool> inHull  = CheckHull(_hull);
            int         counter = inHull.Count;

            pairings = new List <Line>();
            List <Point3d> midpoints    = new List <Point3d>();
            List <int>     regionCounts = new List <int>();

            regionHulls = new List <Polyline>();

            for (int i = 0; i < regions.Count; i++)
            {
                regionCounts.Add(regions[i].Apoints.Count);
                midpoints.Add(GetCentroid(regions[i].Apoints, i));

                List <Point3d> forHull = new List <Point3d>();

                for (int j = 0; j < regions[i].Apoints.Count; j++)
                {
                    if (regions[i].Apoints[i].EdgePoint)
                    {
                        forHull.Add(regions[i].Apoints[i].Pos);
                    }
                }

                regionHulls.Add(new Polyline(forHull));
            }

            pointsInbetween = new List <Point3d>();
            pointsInbetween = midpoints;

            List <Apoint>          edgeApoints = new List <Apoint>();
            MeshTopologyVertexList connected   = mesh.TopologyVertices;

            for (int i = 0; i < Apoints.Count; i++)
            {
                if (Apoints[i].EdgePoint)
                {
                    bool inside = false;



                    int[] neighbours = connected.ConnectedTopologyVertices(i);

                    for (int j = 0; j < neighbours.Length; j++)
                    {
                        if (inHull[neighbours[j]])
                        {
                            inside = true;
                        }
                    }

                    if (inside)
                    {
                        pointsOnEdge.Add(Apoints[i].Pos);
                        edgeApoints.Add(Apoints[i]);
                    }
                }
            }

            Dictionary <string, Vector3d> directions = Directions(regions.Count, midpoints);

            for (int i = 0; i < edgeApoints.Count; i++)
            {
                double distance = double.MaxValue;
                int    region   = -1;

                for (int j = 0; j < regions.Count; j++)
                {
                    if (edgeApoints[i].regionIndex != j)
                    {
                        for (int k = 0; k < regions[j].Apoints.Count; k++)
                        {
                            double thisdist = edgeApoints[i].Pos.DistanceTo(regions[j].Apoints[k].Pos);

                            if (thisdist < distance)
                            {
                                distance = thisdist;
                                region   = j;
                            }
                        }
                    }
                }

                string   key = edgeApoints[i].regionIndex.ToString() + ">" + region.ToString();
                Vector3d v   = directions[key];

                Point3d pointResult = new Point3d();
                pointResult = Point3d.Add(edgeApoints[i].Pos, v);

                pairings.Add(new Line(edgeApoints[i].Pos, pointResult));
            }

            //if (!mesh.IsClosed)
            //{
            //    AddEdges(_solid);
            //}

            //for (int i = 0; i < _hull.SegmentCount; i++)
            //{
            //    for (int j = 0; j < Apoints.Count; j++)
            //    {
            //        if(inRegion[j])
            //        {
            //            double distance = _hull.SegmentAt(i).DistanceTo(Apoints[j].Pos, true);
            //            if (distance < 0.1) pointsOnEdge.Add(Apoints[j].Pos);
            //        }
            //    }
            //}

            bool stop = false;

            while (counter > 0 || stop)
            {
                for (int i = 0; i < regions.Count; i++)
                {
                    for (int j = 0; j < regions.Count; j++)
                    {
                        if (i != j)
                        {
                            CheckPoints(i, j, inHull, regionCounts, counter);
                        }
                    }
                }

                for (int i = 0; i < regionCounts.Count; i++)
                {
                    if (regionCounts[i] < 1)
                    {
                        for (int j = 0; j < inHull.Count; j++)
                        {
                            double smallest = double.MaxValue;
                            int    index    = -1;

                            for (int k = 0; k < pairings.Count; k++)
                            {
                                //   pairings[k].DistanceTo()
                            }
                        }
                        goto out1;
                    }
                }
            }

out1:
            ;
        }