Example #1
0
        /// <summary>
        /// Draw all entities stored in buffer
        /// </summary>
        public void Flush()
        {
            // initialize
            Vector3D vLight = CameraPosition - Target; vLight.Normalize();

            _boxDrawingCounter = 0;
            CurrentTransf      = null;
            System.Drawing.Graphics g = Graphics;
            g.Clear(BackgroundColor);

            if (EnableFaceSorting)
            {
                // sort face list
                FaceComparison faceComparer = new FaceComparison(GetWorldToEyeTransformation());
                Faces.Sort(faceComparer);
            }
            // draw background segments
            foreach (Segment s in SegmentsBackground)
            {
                Draw(s);
            }
            // draw background faces
            foreach (Face face in _facesBackground)
            {
                Draw(face, FaceDir.FRONT);
            }
            // draw all faces using solid / transparency
            foreach (Face face in Faces)
            {
                Draw(face, FaceDir.BACK);
            }
            // draw triangles
            foreach (Triangle tr in Triangles)
            {
                Draw(tr, FaceDir.FRONT);
            }

            // sort box list
            if (UseBoxelOrderer)
            {
                BoxelOrderer boxelOrderer = new BoxelOrderer(Boxes)
                {
                    Direction = Target - CameraPosition
                };
                Boxes = boxelOrderer.GetSortedList();
            }
            else
            {
                Boxes.Sort(new BoxComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
            }

            // sort cylinder list
            Cylinders.Sort(new CylinderComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));

            if (Cylinders.Count > 0)
            {
                // sort by Z
                List <Drawable> drawableList = new List <Drawable>();
                drawableList.AddRange(Boxes);
                drawableList.AddRange(Cylinders);
                drawableList.Sort(new DrawableComparerSimplifiedPainterAlgo());

                List <Box>      boxes         = new List <Box>();
                List <Cylinder> cylinders     = new List <Cylinder>();
                bool            processingBox = drawableList[0] is Box;
                foreach (Drawable drawable in drawableList)
                {
                    Box      b = drawable as Box;
                    Cylinder c = drawable as Cylinder;

                    if ((null != b) && processingBox)
                    {
                        boxes.Add(b);
                    }
                    else if ((null == b) && !processingBox)
                    {
                        cylinders.Add(c);
                    }
                    else
                    {
                        if (boxes.Count > 0)
                        {
                            BoxelOrderer boxelOrderer = new BoxelOrderer(boxes)
                            {
                                Direction = Target - CameraPosition
                            };
                            boxes = boxelOrderer.GetSortedList();
                            // draw boxes
                            foreach (Box bb in boxes)
                            {
                                Draw(bb);
                            }
                            // clear
                            boxes.Clear();
                        }
                        if (cylinders.Count > 0)
                        {
                            cylinders.Sort(new CylinderComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                            // draw cylinders
                            foreach (Cylinder cc in cylinders)
                            {
                                Draw(cc);
                            }
                            // clear
                            cylinders.Clear();
                        }
                        if (null != b)
                        {
                            boxes.Add(b);
                            processingBox = true;
                        }
                        else
                        {
                            cylinders.Add(c);
                            processingBox = false;
                        }
                    }
                }

                // remaining boxes
                BoxelOrderer boxelOrdererRem = new BoxelOrderer(boxes)
                {
                    Direction = Target - CameraPosition
                };
                boxes = boxelOrdererRem.GetSortedList();
                // draw boxes
                foreach (Box bb in boxes)
                {
                    Draw(bb);
                }

                // remaining cylinders
                cylinders.Sort(new CylinderComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                // draw cylinders
                foreach (Cylinder cc in cylinders)
                {
                    Draw(cc);
                }
                // clear
                boxes.Clear();
            }
            else
            {
                // draw all boxes
                foreach (Box box in Boxes)
                {
                    Draw(box);
                }
                // draw all triangles
                foreach (Triangle tr in Triangles)
                {
                    Draw(tr, FaceDir.FRONT);
                }
            }
            // images inst
            if (_listImageInst.Count > 0)
            {
                // --- sort image inst
                AnalysisHomo analysis   = _listImageInst[0].Analysis;
                BBox3D       bbox       = analysis.Solution.BBoxGlobal;
                List <Box>   boxesImage = new List <Box>();
                foreach (ImageInst imageInst in _listImageInst)
                {
                    boxesImage.Add(imageInst.ToBox());
                }

                if (UseBoxelOrderer && false) // NOT WORKING ?
                {
                    BoxelOrderer boxelOrderer = new BoxelOrderer(boxesImage)
                    {
                        TuneParam = 10.0,
                        Direction = Target - CameraPosition
                    };
                    boxesImage = boxelOrderer.GetSortedList();
                }
                else
                {
                    boxesImage.Sort(new BoxComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                }
                // ---

                List <ImageInst> listImageInstSorted = new List <ImageInst>();
                foreach (Box b in boxesImage)
                {
                    listImageInstSorted.Add(new ImageInst(analysis, new Vector3D(b.Length, b.Width, b.Height), b.BPosition));
                }

                // draw image inst
                foreach (ImageInst im in listImageInstSorted)
                {
                    Draw(im);
                }
            }
            // draw faces : end
            foreach (Face face in Faces)
            {
                Draw(face, FaceDir.FRONT);
            }

            // draw segment list (e.g. hatching)
            foreach (Segment seg in Segments)
            {
                Draw(seg);
            }

            // draw cotation cubes
            if (ShowDimensions)
            {
                foreach (DimensionCube qc in _dimensions)
                {
                    qc.Draw(this);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Draw all entities stored in buffer
        /// </summary>
        public void Flush()
        {
            // initialize
            Vector3D vLight = CameraPosition - Target; vLight.Normalize();

            CurrentTransf = null;
            System.Drawing.Graphics g = Graphics;
            g.Clear(BackgroundColor);

            if (EnableFaceSorting)
            {
                // sort face list
                FaceComparison faceComparer = new FaceComparison(GetWorldToEyeTransformation());
                Faces.Sort(faceComparer);
            }
            // draw background segments
            foreach (Segment s in SegmentsBackground)
            {
                Draw(s);
            }
            // draw background faces
            foreach (Face face in _facesBackground)
            {
                Draw(face, FaceDir.FRONT);
            }
            // draw all faces using solid / transparency
            foreach (Face face in Faces)
            {
                Draw(face, FaceDir.BACK);
            }
            // draw triangles
            foreach (Triangle tr in Triangles)
            {
                Draw(tr, FaceDir.FRONT);
            }

            var boxesImage1 = new List <BoxGeneric>();

            foreach (var imageInst in ListImageInst)
            {
                var b = imageInst.ToBox();
                boxesImage1.Add(b);
            }
            // sort box list
            if (UseBoxelOrderer)
            {
                BoxelOrderer boxelOrderer = new BoxelOrderer(Boxes, ViewDirection);
                Boxes = boxelOrderer.GetSortedList();

                var boxelOrderer2 = new BoxelOrderer(boxesImage1, ViewDirection);
                boxesImage1 = boxelOrderer2.GetSortedList();
            }
            else
            {
                Boxes.Sort(new DrawableComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
            }

            // sort cylinder list
            Cylinders.Sort(new DrawableComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));

            if (Cylinders.Count > 0)
            {
                // sort by Z
                var drawableList = new List <Drawable>();
                drawableList.AddRange(Boxes);
                drawableList.AddRange(Cylinders);
                drawableList.Sort(new DrawableComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));

                var boxes         = new List <BoxGeneric>();
                var cylinders     = new List <Cyl>();
                var processingBox = drawableList[0] is Box;
                foreach (Drawable drawable in drawableList)
                {
                    if ((drawable is Box box) && processingBox)
                    {
                        boxes.Add(box);
                    }
                    else if (drawable is Cyl cyl && !processingBox)
                    {
                        cylinders.Add(cyl);
                    }
Example #3
0
        /// <summary>
        /// Draw all entities stored in buffer
        /// </summary>
        public void Flush()
        {
            // initialize
            Vector3D vLight = _vCameraPos - _vTarget; vLight.Normalize();

            _boxDrawingCounter = 0;
            _currentTransf     = null;
            System.Drawing.Graphics g = Graphics;
            g.Clear(_backgroundColor);

            if (EnableFaceSorting)
            {
                // sort face list
                FaceComparison faceComparer = new FaceComparison(GetWorldToEyeTransformation());
                _faces.Sort(faceComparer);
            }
            // draw background segments
            foreach (Segment s in _segmentsBackground)
            {
                Draw(s);
            }
            // draw background faces
            foreach (Face face in _facesBackground)
            {
                Draw(face, FaceDir.FRONT);
            }
            // draw all faces using solid / transparency depending on
            foreach (Face face in _faces)
            {
                Draw(face, FaceDir.BACK);
            }

            // sort box list
            if (_useBoxelOrderer)
            {
                BoxelOrderer boxelOrderer = new BoxelOrderer(_boxes);
                boxelOrderer.Direction = _vTarget - _vCameraPos;
                _boxes = boxelOrderer.GetSortedList();
            }
            else
            {
                _boxes.Sort(new BoxComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
            }

            // sort cylinder list
            _cylinders.Sort(new CylinderComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));

            if (_cylinders.Count > 0)
            {
                // sort by Z
                List <Drawable> drawableList = new List <Drawable>();
                drawableList.AddRange(_boxes);
                drawableList.AddRange(_cylinders);
                drawableList.Sort(new DrawableComparerSimplifiedPainterAlgo());

                List <Box>      boxes         = new List <Box>();
                List <Cylinder> cylinders     = new List <Cylinder>();
                bool            processingBox = drawableList[0] is Box;
                foreach (Drawable drawable in drawableList)
                {
                    Box      b = drawable as Box;
                    Cylinder c = drawable as Cylinder;

                    if ((null != b) && processingBox)
                    {
                        boxes.Add(b);
                    }
                    else if ((null == b) && !processingBox)
                    {
                        cylinders.Add(c);
                    }
                    else
                    {
                        if (boxes.Count > 0)
                        {
                            BoxelOrderer boxelOrderer = new BoxelOrderer(boxes);
                            boxelOrderer.Direction = _vTarget - _vCameraPos;
                            boxes = boxelOrderer.GetSortedList();
                            // draw boxes
                            foreach (Box bb in boxes)
                            {
                                Draw(bb);
                            }
                            // clear
                            boxes.Clear();
                        }
                        if (cylinders.Count > 0)
                        {
                            cylinders.Sort(new CylinderComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                            // draw cylinders
                            foreach (Cylinder cc in cylinders)
                            {
                                Draw(cc);
                            }
                            // clear
                            cylinders.Clear();
                        }
                        if (null != b)
                        {
                            boxes.Add(b);
                            processingBox = true;
                        }
                        else
                        {
                            cylinders.Add(c);
                            processingBox = false;
                        }
                    }
                }

                // remaining boxes
                BoxelOrderer boxelOrdererRem = new BoxelOrderer(boxes);
                boxelOrdererRem.Direction = _vTarget - _vCameraPos;
                boxes = boxelOrdererRem.GetSortedList();
                // draw boxes
                foreach (Box bb in boxes)
                {
                    Draw(bb);
                }

                // remaining cylinders
                cylinders.Sort(new CylinderComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                // draw cylinders
                foreach (Cylinder cc in cylinders)
                {
                    Draw(cc);
                }
                // clear
                boxes.Clear();
            }
            else
            {
                // draw all boxes
                foreach (Box box in _boxes)
                {
                    Draw(box);
                }
            }
            // images inst
            if (_listImageInst.Count > 0)
            {
                // sort image inst
                _listImageInst.Sort(new ImageInstComparerSimplifierPainterAlgo(GetWorldToEyeTransformation()));
                // draw image inst
                foreach (ImageInst im in _listImageInst)
                {
                    Draw(im);
                }
            }
            // draw faces : end
            foreach (Face face in _faces)
            {
                Draw(face, FaceDir.FRONT);
            }

            // draw segment list (e.g. hatching)
            foreach (Segment seg in _segments)
            {
                Draw(seg);
            }

            // draw cotation cubes
            foreach (DimensionCube qc in _dimensions)
            {
                qc.Draw(this);
            }
        }
Example #4
0
        /// <summary>
        /// Draw all entities stored in buffer
        /// </summary>
        public void Flush()
        {
            // initialize
            Vector3D vLight = CameraPosition - Target; vLight.Normalize();

            CurrentTransf = null;
            System.Drawing.Graphics g = Graphics;
            g.Clear(BackgroundColor);

            if (EnableFaceSorting)
            {
                // sort face list
                FaceComparison faceComparer = new FaceComparison(GetWorldToEyeTransformation());
                Faces.Sort(faceComparer);
            }
            // draw background segments
            foreach (Segment s in SegmentsBackground)
            {
                Draw(s);
            }
            // draw background faces
            foreach (Face face in _facesBackground)
            {
                Draw(face, FaceDir.FRONT);
            }
            // draw all faces using solid / transparency
            foreach (Face face in Faces)
            {
                Draw(face, FaceDir.BACK);
            }
            // draw triangles
            foreach (Triangle tr in Triangles)
            {
                Draw(tr, FaceDir.FRONT);
            }

            List <Box> boxesImage1 = new List <Box>();

            foreach (ImageInst imageInst in ListImageInst)
            {
                Box b = imageInst.ToBox();
                boxesImage1.Add(b);
            }
            // sort box list
            if (UseBoxelOrderer)
            {
                BoxelOrderer boxelOrderer = new BoxelOrderer(Boxes, ViewDirection);
                Boxes = boxelOrderer.GetSortedList();

                BoxelOrderer boxelOrderer2 = new BoxelOrderer(boxesImage1, ViewDirection);
                boxesImage1 = boxelOrderer2.GetSortedList();
            }
            else
            {
                Boxes.Sort(new DrawableComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
            }

            // sort cylinder list
            Cylinders.Sort(new DrawableComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));

            if (Cylinders.Count > 0)
            {
                // sort by Z
                List <Drawable> drawableList = new List <Drawable>();
                drawableList.AddRange(Boxes);
                drawableList.AddRange(Cylinders);
                drawableList.Sort(new DrawableComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));

                List <Box> boxes         = new List <Box>();
                List <Cyl> cylinders     = new List <Cyl>();
                bool       processingBox = drawableList[0] is Box;
                foreach (Drawable drawable in drawableList)
                {
                    Box b = drawable as Box;
                    Cyl c = drawable as Cyl;

                    if ((null != b) && processingBox)
                    {
                        boxes.Add(b);
                    }
                    else if ((null == b) && !processingBox)
                    {
                        cylinders.Add(c);
                    }
                    else
                    {
                        if (boxes.Count > 0)
                        {
                            BoxelOrderer boxelOrderer = new BoxelOrderer(boxes, ViewDirection);
                            boxes = boxelOrderer.GetSortedList();
                            // draw boxes
                            foreach (Box bb in boxes)
                            {
                                bb.Draw(this);
                            }
                            // clear
                            boxes.Clear();
                        }
                        if (cylinders.Count > 0)
                        {
                            cylinders.Sort(new DrawableComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                            // draw cylinders
                            foreach (Cyl cc in cylinders)
                            {
                                cc.Draw(this);
                            }
                            // clear
                            cylinders.Clear();
                        }
                        if (null != b)
                        {
                            boxes.Add(b);
                            processingBox = true;
                        }
                        else
                        {
                            cylinders.Add(c);
                            processingBox = false;
                        }
                    }
                }

                // remaining boxes
                BoxelOrderer boxelOrdererRem = new BoxelOrderer(boxes, ViewDirection);
                boxes = boxelOrdererRem.GetSortedList();
                // draw boxes
                foreach (Box bb in boxes)
                {
                    bb.Draw(this);
                }

                // remaining cylinders
                cylinders.Sort(new DrawableComparerSimplifiedPainterAlgo(GetWorldToEyeTransformation()));
                // draw cylinders
                foreach (var cc in cylinders)
                {
                    cc.Draw(this);
                }
                // clear
                boxes.Clear();
            }
            else
            {
                // draw all boxes
                foreach (Box box in Boxes)
                {
                    box.Draw(this);
                }
                // draw all triangles
                foreach (Triangle tr in Triangles)
                {
                    Draw(tr, FaceDir.FRONT);
                }
            }
            // images inst
            if (ListImageInst.Count > 0)
            {
                // --- sort image inst
                List <ImageInst> listImageInstSorted = new List <ImageInst>();
                foreach (Box b in boxesImage1)
                {
                    var imageInst = ListImageInst.Find(i => i.PickId == b.PickId);
                    listImageInstSorted.Add(new ImageInst(b.PickId, imageInst.Content, b.Dim, b.BPosition));
                }

                // draw image inst
                foreach (ImageInst im in listImageInstSorted)
                {
                    Draw(im);
                }
                ListImageInst.Clear();
            }
            // draw faces : end
            foreach (Face face in Faces)
            {
                Draw(face, FaceDir.FRONT);
            }

            // draw segment list (e.g. hatching)
            foreach (Segment seg in Segments)
            {
                Draw(seg);
            }

            // draw cotation cubes
            if (ShowDimensions)
            {
                foreach (DimensionCube qc in Dimensions)
                {
                    qc.Draw(this);
                }
            }
        }