Esempio n. 1
0
        public static void updateInnerLines(LineSegment3d line, LineSegment3d prepareline, double dist, List <LineSegment3d> innerlines)
        {
            bool haveLinesOverlapped = false;

            foreach (LineSegment3d innerLine in innerlines)
            {
                if (WallRecognizer.isSegmentsProjectionOverlapped(prepareline, innerLine))
                {
                    haveLinesOverlapped = true;
                    break;
                }
            }

            if (haveLinesOverlapped)
            {
                // update the innerlines
                List <LineSegment3d> preparelines = new List <LineSegment3d>();
                foreach (LineSegment3d innerLine in innerlines)
                {
                    if (WallRecognizer.isSegmentsProjectionOverlapped(prepareline, innerLine))
                    {
                        Line3d innerline3d = WallRecognizer.toLine3d(innerLine.StartPoint, innerLine.EndPoint);
                        double innerDist   = innerline3d.GetDistanceTo(line.StartPoint);
                        if (DoubleExtensions.Larger(innerDist, dist))
                        {
                            if (!preparelines.Contains(prepareline))
                            {
                                preparelines.Add(prepareline);
                            }
                        }
                        else
                        {
                            if (!preparelines.Contains(innerLine))
                            {
                                preparelines.Add(innerLine);
                            }
                        }
                    }
                    else
                    {
                        if (!preparelines.Contains(innerLine))
                        {
                            preparelines.Add(innerLine);
                        }
                    }
                }

                // copy preparelines to innerlines
                innerlines.Clear();
                foreach (LineSegment3d innerLine in preparelines)
                {
                    innerlines.Add(innerLine);
                }
            }
            else
            {
                innerlines.Add(prepareline);
            }
        }
Esempio n. 2
0
        public static List <LineSegment3d> getWallline(LineSegment3d line, IEnumerable <LineSegment3d> entities)
        {
            double width = maxWallWidth + 1;

            // step 1: get the parallel lines in the loop: skip the colinear line
            var dir           = line.Direction;
            var parallelLines = new List <LineSegment3d>();

            foreach (LineSegment3d tmpLine in entities)
            {
                if (line != tmpLine)
                {
                    if (dir.IsParallelTo(tmpLine.Direction) &&
                        (!tmpLine.IsOn(line.StartPoint) || tmpLine.IsOn(line.EndPoint))) // check if colinear line
                    {
                        parallelLines.Add(WallRecognizer.toLineSegment3d(tmpLine.StartPoint, tmpLine.EndPoint));
                    }
                }
            }

            List <LineSegment3d> innerlines = new List <LineSegment3d>();

            // step 2: get poper innerlines
            foreach (LineSegment3d line1 in parallelLines)
            {
                Line3d line3d = WallRecognizer.toLine3d(line1.StartPoint, line1.EndPoint);
                // skip the colinear line and the two lines should be projection overlapped
                if (!line3d.IsOn(line.StartPoint) && WallRecognizer.isSegmentsProjectionOverlapped(line1, line))
                {
                    double dist = line3d.GetDistanceTo(line.StartPoint);
                    if (DoubleExtensions.Larger(500, dist))
                    {
                        updateInnerLines(line, line1, dist, innerlines);
                    }

                    /*// pixel to millemeter
                     * dist = (dist * MILLIMETER_TO_METER) / PIXEL_TO_M_FACTOR;
                     * // the dist should > minWallWidth & < maxWallWidth
                     * if (DoubleExtensions.Larger(dist, minWallWidth) && DoubleExtensions.Larger(maxWallWidth, dist))
                     * {
                     *  //width = Math.Round(dist);
                     *  updateInnerLines(line1, dist, innerlines);
                     * }*/
                }
            }

            return(innerlines);
        }
Esempio n. 3
0
        public static WallInfor getWallinfors(List <LineSegment3d> outLines, List <LineSegment3d> allLines)
        {
            WallInfor wallInfor = new WallInfor();
            // step1: get the biggest length of outline
            var index  = 0;
            var length = outLines[index].Length;
            int size   = outLines.Count;

            for (int i = 1; i < size; i++)
            {
                if (DoubleExtensions.Larger(outLines[i].Length, length))
                {
                    index  = i;
                    length = outLines[index].Length;
                }
            }

            var currentWallInfor = wallInfor;

            // step2: get the outline wall infor
            for (int i = 0; i < size; i++)
            {
                var line = outLines[(i + index) % size];
                // skip the line if it is in part exist wall infor
                if (!isPartOfWallinfor(line, wallInfor))
                {
                    List <LineSegment3d> innerlines = WallRecognizer.getWallline(line, allLines);
                    // set the wall infor
                    currentWallInfor.outline    = line;
                    currentWallInfor.innerlines = innerlines;
                    currentWallInfor.next       = new WallInfor();
                    currentWallInfor            = currentWallInfor.next;
                }
            }

            return(wallInfor);
        }