示例#1
0
        /// <summary>
        /// Skip items from iter.
        /// </summary>
        /// <param name="iter">Target iterate</param>
        /// <param name="count">Number of count.</param>
        /// <returns>Skipped sequence.</returns>
        private static IEnumerable <object> SkipIterate(Iterate iter, int count)
        {
            if (iter == null)
            {
                throw new ArgumentNullException(nameof(iter));
            }

            if (count < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(count));
            }

            var fi = typeof(Iterate).GetField("_next", BindingFlags.Instance | BindingFlags.NonPublic);

            Debug.Assert(fi != null);

            long i = 0;

            while (i < count)
            {
                var n = (Iterate)iter.next();

                // clear _next cache in previous
                fi.SetValue(iter, null);

                iter = n;

                ++i;
            }

            return(iter);
        }
示例#2
0
        /// <summary>
        /// return LinkedList of generic class post order
        /// </summary>
        /// <param name="iterate"></param>
        /// <returns></returns>
        public LinkedList <T> PostOrder(Iterate iterate = null)
        {
            LinkedList <T> ret = new LinkedList <T>();

            if (this.Root == null)
            {
                return(ret);
            }
            Stack    s     = new Stack(this.Count);
            Node <T> act   = this.Root;
            int      count = 0;

            while (this.Count > count)
            {
                this.FindLeftLeaf(act, s, 2);
                if (s.Count == 0)
                {
                    break;
                }

                act = (Node <T>)s.Pop();
                if (s.Count > 0 && (Node <T>)s.Peek() == act)
                {
                    act = act.Right;
                }
                else
                {
                    ret.AddLast(act.Data);
                    iterate?.Invoke(act.Data);
                    act = null;
                }
            }
            return(ret);
        }
示例#3
0
        /// <summary>
        /// returns LinkedList of generic class in order
        /// </summary>
        /// <param name="iterate"></param>
        /// <returns></returns>
        public LinkedList <T> InOrder(Iterate iterate = null)
        {
            LinkedList <T> ret = new LinkedList <T>();

            if (this.Root == null)
            {
                return(ret);
            }
            Stack    s     = new Stack(this.Count / 2);
            Node <T> act   = Root; // start at root
            int      count = 0;

            while (count < this.Count)     // go through all items in the tree
            {
                this.FindLeftLeaf(act, s); // save path to from act to the left leaf into stack
                act = (Node <T>)s.Pop();   // get last added to print

                ret.AddLast(act.Data);
                iterate?.Invoke(act.Data);
                count++;

                act = act.Right; // don't forget about right side
            }

            return(ret);
        }
示例#4
0
        /// <summary>
        /// return LinkedList of generic class in pre order
        /// </summary>
        /// <param name="iterate"></param>
        /// <returns></returns>
        public LinkedList <T> PreOrder(Iterate iterate = null)
        {
            LinkedList <T> ret = new LinkedList <T>();

            if (this.Root == null)
            {
                return(ret);
            }
            Stack    s   = new Stack(this.Count / 2 + 1); // cannot be more than half of the nodes in the stack
            Node <T> act = this.Root;

            s.Push(act);
            int count = 0;

            while (count < this.Count)   // go through all items in the tree
            {
                act = (Node <T>)s.Pop(); // get last added to print

                ret.AddLast(act.Data);
                iterate?.Invoke(act.Data);

                count++;

                if (act.Right != null)
                {
                    s.Push(act.Right);
                }
                if (act.Left != null)
                {
                    s.Push(act.Left);
                }
            }

            return(ret);
        }
示例#5
0
        private static string BuildReflectedFullName(SqlTagContext ctx, Iterate parentIteratorTag, string propertyName)
        {
            if (parentIteratorTag != null)
            {
                var parentIteratorContext = ctx.GetAttribute(parentIteratorTag) as IterateContext;
                var indexOfIndexer        = propertyName.IndexOf(THIS_ENUMERATOR_PLACEHOLDER);

                if (parentIteratorContext == null)
                {
                    return(propertyName);
                }

                if (indexOfIndexer == 0)
                {
                    // the property name is a reflection name relative to the iterate.
                    propertyName = propertyName.Substring(indexOfIndexer + THIS_ENUMERATOR_PLACEHOLDER.Length);
                    propertyName = String.Format("{0}[{1}].{2}", parentIteratorTag.Property, parentIteratorContext.Index, propertyName);

                    var parentOrParentIteratorTag = FindParentIteratorTag(ctx, parentIteratorTag);

                    if (parentOrParentIteratorTag != null)
                    {
                        return(BuildReflectedFullName(ctx, parentOrParentIteratorTag, propertyName));
                    }
                }
                else if (propertyName.IndexOf(ENUMERATOR_PLACEHOLDER) > -1)
                {
                    return(propertyName + "[" + parentIteratorContext.Index + "]"); //Parameter-Index-Dynamic
                }
            }

            return(propertyName);
        }
        /// <summary>
        /// Return true, if after generation a new process should be startet.
        /// </summary>
        public override bool OnPictureCreated(Iterate iter, PictureData pictureData)
        {
            StepEnds();

            bool retVal = _currentStep < _steps;
            if (retVal)
                PrepareStep();
            else
                BatchEnds();
            return retVal;
        }
示例#7
0
 protected virtual void OnIterate()
 {
     // it is not usually necessary to override this; generally alternative functionality can be put in a second function which calls this
     Debug.WriteLine("Iterate at " + Environment.TickCount);
     IsAtScanStart = false;
     Iterate?.Invoke(this, m_Direction);
     if (IterateCanRepeat && ScanTime > 0)
     {
         m_Timer.Start(ScanTime, OnIterate, Timings.ScanTime);
     }
 }
示例#8
0
        /// <summary>
        /// Deserializes the specified configuration in an <see cref="Iterate"/> object
        /// </summary>
        /// <param name="configuration">The configuration.</param>
        /// <returns></returns>
        public override SqlTag Deserialize(IConfiguration configuration)
        {
            Iterate iterate = new Iterate(accessorFactory);

            iterate.Prepend     = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "prepend");
            iterate.Property    = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "property");
            iterate.Close       = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "close");
            iterate.Conjunction = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "conjunction");
            iterate.Open        = ConfigurationUtils.GetStringAttribute(configuration.Attributes, "open");

            return(iterate);
        }
示例#9
0
        public SqlTag Deserialize(XmlNode node)
        {
            Iterate             iterate    = new Iterate(this._configScope.DataExchangeFactory.AccessorFactory);
            NameValueCollection attributes = NodeUtils.ParseAttributes(node, this._configScope.Properties);

            iterate.Prepend     = NodeUtils.GetStringAttribute(attributes, "prepend");
            iterate.Property    = NodeUtils.GetStringAttribute(attributes, "property");
            iterate.Close       = NodeUtils.GetStringAttribute(attributes, "close");
            iterate.Conjunction = NodeUtils.GetStringAttribute(attributes, "conjunction");
            iterate.Open        = NodeUtils.GetStringAttribute(attributes, "open");
            return(iterate);
        }
示例#10
0
 /// <summary>
 /// Is called, if result picture is created.
 /// Return true if new rendering should be startet.
 /// </summary>
 public bool PictureIsCreated(Iterate iter, PictureData pictureData)
 {
     if (_batchProcess != null)
     {
         bool retVal = _batchProcess.OnPictureCreated(iter, pictureData);
         if (!retVal)
         {
             _batchProcess = null;
         }
         return(retVal);
     }
     return(false);
 }
示例#11
0
 public bool Export(string fileName, Iterate iter, PictureData pictureData)
 {
     foreach (SceneExporter sceneExporter in _exporters)
     {
         if (sceneExporter.FileTypeIsSupported(fileName))
         {
             SceneExporter exporter = CreateExporter(sceneExporter, iter, pictureData);
             exporter.Export(fileName);
             return(true);
         }
     }
     return(false);
 }
        /// <summary>
        /// Return true, if after generation a new process should be startet.
        /// </summary>
        /// <returns></returns>
        public override bool OnPictureCreated(Iterate iter, PictureData pictureData)
        {
            StepEnds();

            bool retVal = _currentStep < _steps;

            if (retVal)
            {
                PrepareStep();
            }
            else
            {
                BatchEnds();
            }
            return(retVal);
        }
示例#13
0
        public LinkedList <T> GetAll <T>(T Record, Iterate <T> iterate = null) where T : IRecord <T>
        {
            LinkedList <T> ret      = new LinkedList <T>();
            int            position = 0;

            byte[] arr = new byte[Record.GetSize()];
            while (position < this.LastAddress)
            {
                Record = Record.Clone();
                br.BaseStream.Seek(position, SeekOrigin.Begin);
                br.Read(arr, 0, Record.GetSize());
                Record.FromByteArray(arr);
                ret.AddLast(Record);
                iterate?.Invoke(Record);
                position += Record.GetSize();
            }
            return(ret);
        }
示例#14
0
        /// <summary>
        /// Start Computing. Is called while rendering an animation.
        /// </summary>
        public void Run(int updateSteps)
        {
            _currentProgress = 0;
            _master.Progress(_currentProgress);
            System.Diagnostics.Debug.WriteLine("PaintJob.Run " + updateSteps.ToString());
            _parameters       = ParameterDict.Current.Clone();
            _updateSteps      = updateSteps;
            _currentProgressd = 100.0 / (double)(_updateSteps);
            for (int i = 0; i < _updateSteps; i++)
            {
                if (_abort)
                {
                    return;
                }
                _iterate = new Iterate(_parameters, this, false);
                if (_lastIterate != null)
                {
                    _iterate.SetOldData(_lastIterate.GraphicInfo, _lastIterate.PictureData, i);
                }
                if (_abort)
                {
                    return;
                }
                _iterate.StartAsync();
                _iterate.Wait();
                if (_abort)
                {
                    return;
                }
                _lastIterate      = _iterate;
                _currentProgress += _currentProgressd;
                _master.Progress(_currentProgress);
            }
            Renderer renderer = PictureArtFactory.Create(_iterate.PictureData, _iterate.LastUsedFormulas, ParameterDict.Current.Clone());

            renderer.Paint(_graphics);
            if (_abort)
            {
                return;
            }
            _master.Progress(0);
        }
示例#15
0
 /// <summary>
 /// Create instance of SceneExporter wth type as template.
 /// </summary>
 SceneExporter CreateExporter(SceneExporter template, Iterate iter, PictureData pictureData)
 {
     if (template is ObjFileExporter)
     {
         return(new ObjFileExporter(iter, pictureData));
     }
     if (template is VrmlSceneExporter)
     {
         return(new VrmlSceneExporter(iter, pictureData));
     }
     if (template is WebGlExporter)
     {
         return(new WebGlExporter(iter, pictureData));
     }
     if (template is X3DomExporter)
     {
         return(new X3DomExporter(iter, pictureData));
     }
     return(null);
 }
示例#16
0
        public void IteratorOver <T>(List <T> aList, Iterate <T> aTitle, Iterate <T> aBody, Iterate <T> aFooter)
        {
            int index = 0;

            foreach (T entity in aList)
            {
                if (index == 0)
                {
                    aTitle(entity, index);
                }

                else if (index == aList.Count() - 1)
                {
                    aFooter(entity, index);
                }

                else
                {
                    aBody(entity, index);
                }
                index++;
            }
        }
示例#17
0
        public void IteratorOver(DataTable aList, Iterate <DataRow> aTitle, Iterate <DataRow> aBody, Iterate <DataRow> aFooter)
        {
            int index = 0;

            foreach (DataRow entity in aList.Rows)
            {
                if (index == 0)
                {
                    aTitle(entity, index);
                }

                else if (index == aList.Rows.Count - 1)
                {
                    aFooter(entity, index);
                }

                else
                {
                    aBody(entity, index);
                }
                index++;
            }
        }
示例#18
0
 public IEnumerator <ArgsHelper> GetEnumerator()
 {
     return(Iterate.GetEnumerator());
 }
示例#19
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Navigator"/> class.
 /// </summary>
 public Navigator(Iterate iter)
 {
 }
示例#20
0
 public void Init(Iterate iter, PictureData pictureData)
 {
     CreateMesh();
     _meshTool.Init(iter, pictureData);
 }
示例#21
0
        public void Init(Iterate iter, PictureData pictureData)
        {
            _iterate     = iter;
            _pictureData = pictureData;
            _useDistance = !Fractrace.Basic.ParameterDict.Current.GetBool("Export.X3d.ClosedSurface");
            double minx         = Double.MaxValue;
            double miny         = Double.MaxValue;
            double minz         = Double.MaxValue;
            double maxx         = Double.MinValue;
            double maxy         = Double.MinValue;
            double maxz         = Double.MinValue;
            int    currentIndex = 0;

            for (int i = 0; i < _pictureData.Width; i++)
            {
                for (int j = 0; j < _pictureData.Height; j++)
                {
                    if (_pictureData.Points[i, j] != null)
                    {
                        PixelInfo point = Transform(_pictureData.Points[i, j]);
                        if (minx > point.Coord.X)
                        {
                            minx = point.Coord.X;
                        }
                        if (miny > point.Coord.Y)
                        {
                            miny = point.Coord.Y;
                        }
                        if (minz > point.Coord.Z)
                        {
                            minz = point.Coord.Z;
                        }
                        if (maxx < point.Coord.X)
                        {
                            maxx = point.Coord.X;
                        }
                        if (maxy < point.Coord.Y)
                        {
                            maxy = point.Coord.Y;
                        }
                        if (maxz < point.Coord.Z)
                        {
                            maxz = point.Coord.Z;
                        }
                        currentIndex++;
                    }
                }
            }
            if (currentIndex == 0)
            {
                _valid = false;
                return;
            }
            _radius      = maxz - minz + maxy - miny + maxx - minx;
            _centerx     = (maxx + minx) / 2.0;
            _centery     = (maxy + miny) / 2.0;
            _centerz     = (maxz + minz) / 2.0;
            _needScaling = _radius < 0.01;
            // Rounding scale parameters to allow combine different 3d scenes at later time.
            int    noOfDigits = 1;
            double d          = 1;

            if (_needScaling || AlwaysScale)
            {
                while (d > _radius)
                {
                    d /= 10.0;
                    noOfDigits++;
                }
                noOfDigits -= 3;
                _radius     = d;
                if (noOfDigits > 1)
                {
                    _centerx = Math.Round(_centerx, noOfDigits);
                    _centery = Math.Round(_centery, noOfDigits);
                    _centerz = Math.Round(_centerz, noOfDigits);
                }
            }

            // Maximal Distance to draw triangle.
            double noOfPoints = Math.Max(_pictureData.Width, _pictureData.Height);

            _maxDist = Fractrace.Basic.ParameterDict.Current.GetDouble("Export.X3d.ClosedSurfaceDist") * _radius / noOfPoints;
        }
示例#22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public ObjFileExporter(Iterate iter, PictureData pictureData) : base(iter, pictureData)
 {
 }
示例#23
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public WebGlExporter(Iterate iter, PictureData pictureData) : base(iter, pictureData)
 {
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public VrmlSceneExporter(Iterate iter, PictureData pictureData) : base(iter, pictureData)
 {
 }
示例#25
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public X3DomExporter(Iterate iter, PictureData pictureData)
     : base(iter, pictureData)
 {
 }
示例#26
0
 /// <summary>
 /// Return true, if after generation a new process should be startet.
 /// </summary>
 public virtual bool OnPictureCreated(Iterate iter, PictureData pictureData)
 {
     return false;
 }
示例#27
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public WebGlExporter(Iterate iter, PictureData pictureData)
     : base(iter,  pictureData)
 {
 }
示例#28
0
        public Mesh Update(Iterate iter, PictureData pictureData)
        {
            _iterate = iter;
            _pictureData = pictureData;
            // TODO: Update _mesh data

            List<Coord2D> pointList = new List<Coord2D>();

            int[,] pointIndex = new int[_pictureData.Width + 1, _pictureData.Height + 1];

            int currentIndex = _mesh._coordinates.Count/3; // lenght of pointindex in _mesh??
            for (int i = 0; i < _pictureData.Width; i++)
            {
                for (int j = 0; j < _pictureData.Height; j++)
                {
                    if (_pictureData.Points[i, j] != null)
                    {
                        Coord2D coord = new Coord2D(i, j);
                        pointIndex[i, j] = currentIndex;
                        pointList.Add(coord);
                        currentIndex++;
                    }
                    else
                    {
                        pointIndex[i, j] = -1;
                    }
                }
            }

            // to test for invalid pdata
            double maxcol = 0;

            foreach (Coord2D coord in pointList)
            {
                PixelInfo pInfo = Transform(_pictureData.Points[coord.X, coord.Y]);
                if (pInfo != null && pInfo.Coord != null && pInfo.AdditionalInfo != null)
                {

                    double x, y, z;

                    if (_needScaling || AlwaysScale)
                    {
                        x = (pInfo.Coord.X - _centerx) / _radius;
                        y = (pInfo.Coord.Y - _centery) / _radius;
                        z = (pInfo.Coord.Z - _centerz) / _radius;
                    }
                    else
                    {
                        // Scale by 1000
                        x = 1000.0 * pInfo.Coord.X;
                        y = 1000.0 * pInfo.Coord.Y;
                        z = 1000.0 * pInfo.Coord.Z;
                    }

                    _mesh._coordinates.Add((float)x);
                    _mesh._coordinates.Add((float)y);
                    _mesh._coordinates.Add((float)z);

                    double red = pInfo.AdditionalInfo.red2;
                    double green = pInfo.AdditionalInfo.green2;
                    double blue = pInfo.AdditionalInfo.blue2;

                    _mesh._colors.Add((float)red);
                    _mesh._colors.Add((float)green);
                    _mesh._colors.Add((float)blue);

                    // test for invalid data only
                    if (maxcol < red)
                        maxcol = red;
                    if (maxcol < green)
                        maxcol = green;
                    if (maxcol < blue)
                        maxcol = blue;

                }
            }

            for (int i = 0; i < _pictureData.Width; i++)
            {
                for (int j = 0; j < _pictureData.Height; j++)
                {
                    if (_pictureData.Points[i, j] != null)
                    {
                        PixelInfo point1 = _pictureData.Points[i, j];
                        if (point1.Coord.X > 1000 && point1.Coord.X < -1000 && point1.Coord.Y > 1000 && point1.Coord.Y < -1000 && point1.Coord.Z > 1000 && point1.Coord.Z < -1000)
                        {
                            System.Diagnostics.Debug.WriteLine("Error");
                        }
                        if (i > 0 && j > 0 && _pictureData.Points[i - 1, j - 1] != null)
                        {

                            if (_pictureData.Points[i - 1, j] != null)
                            {
                                // triangle 1
                                bool useTriangle = true;
                                if (_useDistance)
                                {
                                    PixelInfo point2 = _pictureData.Points[i - 1, j];
                                    PixelInfo point3 = _pictureData.Points[i - 1, j - 1];
                                    if (Dist(point1, point2) > _maxDist || Dist(point1, point3) > _maxDist)
                                        useTriangle = false;
                                }
                                if (useTriangle)
                                {
                                    _mesh._faces.Add(pointIndex[i, j]);
                                    _mesh._faces.Add(pointIndex[i - 1, j]);
                                    _mesh._faces.Add(pointIndex[i - 1, j - 1]);

                                    _mesh._normales.Add((float)point1.Normal.X);
                                    _mesh._normales.Add((float)point1.Normal.Y);
                                    _mesh._normales.Add((float)point1.Normal.Z);

                                }
                            }
                            if (_pictureData.Points[i, j - 1] != null)
                            {
                                // triangle 2
                                bool useTriangle = true;
                                if (_useDistance)
                                {
                                    PixelInfo point2 = _pictureData.Points[i - 1, j - 1];
                                    PixelInfo point3 = _pictureData.Points[i, j - 1];
                                    if (Dist(point1, point2) > _maxDist || Dist(point1, point3) > _maxDist)
                                        useTriangle = false;
                                }
                                if (useTriangle)
                                {
                                    _mesh._faces.Add(pointIndex[i, j]);
                                    _mesh._faces.Add(pointIndex[i - 1, j - 1]);
                                    _mesh._faces.Add(pointIndex[i, j - 1]);

                                    _mesh._normales.Add((float)point1.Normal.X);
                                    _mesh._normales.Add((float)point1.Normal.Y);
                                    _mesh._normales.Add((float)point1.Normal.Z);

                                }
                            }
                        }
                    }
                }
            }
            if (maxcol < 0.0001)
            {
                _valid = false;
            }
            return _mesh;
        }
示例#29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Navigator"/> class.
 /// </summary>
 public Navigator(Iterate iter)
 {
 }
示例#30
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public MeshTool(Iterate iter, PictureData pictureData)
 {
     _iterate = iter;
     _pictureData = pictureData;
 }
示例#31
0
 /// <summary>
 /// Initialisation with the iteration object of the last render. 
 /// </summary>
 /// <param name="iter">The iter.</param>
 public void Init(Iterate iter)
 {
     _iterate = iter;
 }
示例#32
0
        public Mesh Update(Iterate iter, PictureData pictureData)
        {
            _iterate     = iter;
            _pictureData = pictureData;
            // TODO: Update _mesh data

            List <Coord2D> pointList = new List <Coord2D>();

            int[,] pointIndex = new int[_pictureData.Width + 1, _pictureData.Height + 1];

            int currentIndex = _mesh.Coordinates.Count / 3; // lenght of pointindex in _mesh??

            for (int i = 0; i < _pictureData.Width; i++)
            {
                for (int j = 0; j < _pictureData.Height; j++)
                {
                    if (_pictureData.Points[i, j] != null)
                    {
                        Coord2D coord = new Coord2D(i, j);
                        pointIndex[i, j] = currentIndex;
                        pointList.Add(coord);
                        currentIndex++;
                    }
                    else
                    {
                        pointIndex[i, j] = -1;
                    }
                }
            }

            // to test for invalid pdata
            double maxcol = 0;

            foreach (Coord2D coord in pointList)
            {
                PixelInfo pInfo = Transform(_pictureData.Points[coord.X, coord.Y]);
                if (pInfo != null && pInfo.Coord != null && pInfo.AdditionalInfo != null)
                {
                    double x, y, z;

                    if (_needScaling || AlwaysScale)
                    {
                        x = (pInfo.Coord.X - _centerx) / _radius;
                        y = (pInfo.Coord.Y - _centery) / _radius;
                        z = (pInfo.Coord.Z - _centerz) / _radius;
                    }
                    else
                    {
                        // Scale by 1000
                        x = 1000.0 * pInfo.Coord.X;
                        y = 1000.0 * pInfo.Coord.Y;
                        z = 1000.0 * pInfo.Coord.Z;
                    }

                    _mesh.Coordinates.Add((float)x);
                    _mesh.Coordinates.Add((float)y);
                    _mesh.Coordinates.Add((float)z);

                    double red   = pInfo.AdditionalInfo.red2;
                    double green = pInfo.AdditionalInfo.green2;
                    double blue  = pInfo.AdditionalInfo.blue2;

                    _mesh.Colors.Add((float)red);
                    _mesh.Colors.Add((float)green);
                    _mesh.Colors.Add((float)blue);

                    // test for invalid data only
                    if (maxcol < red)
                    {
                        maxcol = red;
                    }
                    if (maxcol < green)
                    {
                        maxcol = green;
                    }
                    if (maxcol < blue)
                    {
                        maxcol = blue;
                    }
                }
            }

            for (int i = 0; i < _pictureData.Width; i++)
            {
                for (int j = 0; j < _pictureData.Height; j++)
                {
                    if (_pictureData.Points[i, j] != null)
                    {
                        PixelInfo point1 = _pictureData.Points[i, j];
                        if (point1.Coord.X > 1000 && point1.Coord.X < -1000 && point1.Coord.Y > 1000 && point1.Coord.Y < -1000 && point1.Coord.Z > 1000 && point1.Coord.Z < -1000)
                        {
                            System.Diagnostics.Debug.WriteLine("Error");
                        }
                        if (i > 0 && j > 0 && _pictureData.Points[i - 1, j - 1] != null)
                        {
                            if (_pictureData.Points[i - 1, j] != null)
                            {
                                // triangle 1
                                bool useTriangle = true;
                                if (_useDistance)
                                {
                                    PixelInfo point2 = _pictureData.Points[i - 1, j];
                                    PixelInfo point3 = _pictureData.Points[i - 1, j - 1];
                                    if (Dist(point1, point2) > _maxDist || Dist(point1, point3) > _maxDist)
                                    {
                                        useTriangle = false;
                                    }
                                }
                                if (useTriangle)
                                {
                                    _mesh.Faces.Add(pointIndex[i, j]);
                                    _mesh.Faces.Add(pointIndex[i - 1, j]);
                                    _mesh.Faces.Add(pointIndex[i - 1, j - 1]);

                                    _mesh.Normales.Add((float)point1.Normal.X);
                                    _mesh.Normales.Add((float)point1.Normal.Y);
                                    _mesh.Normales.Add((float)point1.Normal.Z);
                                }
                            }
                            if (_pictureData.Points[i, j - 1] != null)
                            {
                                // triangle 2
                                bool useTriangle = true;
                                if (_useDistance)
                                {
                                    PixelInfo point2 = _pictureData.Points[i - 1, j - 1];
                                    PixelInfo point3 = _pictureData.Points[i, j - 1];
                                    if (Dist(point1, point2) > _maxDist || Dist(point1, point3) > _maxDist)
                                    {
                                        useTriangle = false;
                                    }
                                }
                                if (useTriangle)
                                {
                                    _mesh.Faces.Add(pointIndex[i, j]);
                                    _mesh.Faces.Add(pointIndex[i - 1, j - 1]);
                                    _mesh.Faces.Add(pointIndex[i, j - 1]);

                                    _mesh.Normales.Add((float)point1.Normal.X);
                                    _mesh.Normales.Add((float)point1.Normal.Y);
                                    _mesh.Normales.Add((float)point1.Normal.Z);
                                }
                            }
                        }
                    }
                }
            }
            if (maxcol < 0.0001)
            {
                _valid = false;
            }
            return(_mesh);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public VrmlSceneExporter(Iterate iter, PictureData pictureData)
     : base(iter,pictureData)
 {
 }
示例#34
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public MeshTool(Iterate iter, PictureData pictureData)
 {
     _iterate     = iter;
     _pictureData = pictureData;
 }
示例#35
0
 /// <summary>
 /// Is called, if result picture is created.
 /// Return true if new rendering should be startet.
 /// </summary>
 public bool PictureIsCreated(Iterate iter, PictureData pictureData)
 {
     if (_batchProcess!=null)
     {
         bool retVal= _batchProcess.OnPictureCreated( iter,  pictureData);
         if (!retVal)
             _batchProcess = null;
         return retVal;
     }
     return false;
 }
示例#36
0
 public void Update(Iterate iter, PictureData pictureData)
 {
     _mesh = _meshTool.Update(iter, pictureData);
 }
示例#37
0
 public void Update(Iterate iter, PictureData pictureData)
 {
     _mesh = _meshTool.Update( iter,  pictureData);
 }
示例#38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public X3DomExporter(Iterate iter, PictureData pictureData) : base(iter, pictureData)
 {
 }
示例#39
0
 public void Init(Iterate iter, PictureData pictureData)
 {
     CreateMesh();
     _meshTool.Init(iter, pictureData);
 }
示例#40
0
 /// <summary>
 /// Initialisation with the iteration object of the last render.
 /// </summary>
 /// <param name="iter">The iter.</param>
 public void Init(Iterate iter)
 {
     _iterate = iter;
 }
示例#41
0
        public void Init(Iterate iter, PictureData pictureData)
        {
            _iterate = iter;
            _pictureData = pictureData;
            _useDistance = !Fractrace.Basic.ParameterDict.Current.GetBool("Export.X3d.ClosedSurface");
            double minx = Double.MaxValue;
            double miny = Double.MaxValue;
            double minz = Double.MaxValue;
            double maxx = Double.MinValue;
            double maxy = Double.MinValue;
            double maxz = Double.MinValue;
            int currentIndex = 0;

            for (int i = 0; i < _pictureData.Width; i++)
            {
                for (int j = 0; j < _pictureData.Height; j++)
                {
                    if (_pictureData.Points[i, j] != null)
                    {
                        PixelInfo point = Transform(_pictureData.Points[i, j]);
                        if (minx > point.Coord.X)
                            minx = point.Coord.X;
                        if (miny > point.Coord.Y)
                            miny = point.Coord.Y;
                        if (minz > point.Coord.Z)
                            minz = point.Coord.Z;
                        if (maxx < point.Coord.X)
                            maxx = point.Coord.X;
                        if (maxy < point.Coord.Y)
                            maxy = point.Coord.Y;
                        if (maxz < point.Coord.Z)
                            maxz = point.Coord.Z;
                        currentIndex++;
                    }
                }
            }
            if (currentIndex == 0)
            {
                _valid = false;
                return;
            }
            _radius = maxz - minz + maxy - miny + maxx - minx;
            _centerx = (maxx + minx) / 2.0;
            _centery = (maxy + miny) / 2.0;
            _centerz = (maxz + minz) / 2.0;
            _needScaling = _radius < 0.01;
            // Rounding scale parameters to allow combine different 3d scenes at later time.
            int noOfDigits = 1;
            double d = 1;
            if (_needScaling || AlwaysScale)
            {
                while (d > _radius)
                {
                    d /= 10.0;
                    noOfDigits++;
                }
                noOfDigits -= 3;
                _radius = d;
                if (noOfDigits > 1)
                {
                    _centerx = Math.Round(_centerx, noOfDigits);
                    _centery = Math.Round(_centery, noOfDigits);
                    _centerz = Math.Round(_centerz, noOfDigits);
                }
            }

            // Maximal Distance to draw triangle.
            double noOfPoints = Math.Max(_pictureData.Width, _pictureData.Height);
            _maxDist = Fractrace.Basic.ParameterDict.Current.GetDouble("Export.X3d.ClosedSurfaceDist") * _radius / noOfPoints;
        }
示例#42
0
 IEnumerator IEnumerable.GetEnumerator()
 {
     return(Iterate.GetEnumerator());
 }
示例#43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X3dExporter"/> class.
 /// </summary>
 public SceneExporter(Iterate iter, PictureData pictureData)
 {
     _iterate     = iter;
     _pictureData = pictureData;
 }