/// <summary> /// Hier können eigene Renderer zugeschaltet werden: /// </summary> /// <returns></returns> public static Renderer Create(PictureData pdata,Formulas formula) { Renderer retVal = null; switch (ParameterDict.Current["Composite.Renderer"]) { case "": case "PlasicRenderer": case "6": //retVal = new PlasicRenderer(pdata.Clone()); retVal = new FloatPlasicRenderer(pdata.Clone()); break; case "FastPreviewRenderer": case "8": retVal = new FastPreviewRenderer(pdata.Clone()); break; default: //retVal = new PlasicRenderer(pdata.Clone()); retVal = new FloatPlasicRenderer(pdata.Clone()); break; } if (retVal != null) retVal.Init(formula); return retVal; }
/// <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; }
//! Return deep copy. public PictureData Clone() { PictureData retVal = new PictureData(_width, _height); retVal.Points = new PixelInfo[_width + 1, _height + 1]; for (int i = 0; i <= _width; i++) { for (int j = 0; j <= _height; j++) { if (Points[i, j] != null) { retVal.Points[i, j] = Points[i, j].Clone(); } } } return retVal; }
//! Return deep copy. public PictureData Clone() { PictureData retVal = new PictureData(_width, _height); retVal.Points = new PixelInfo[_width + 1, _height + 1]; for (int i = 0; i <= _width; i++) { for (int j = 0; j <= _height; j++) { if (Points[i, j] != null) { retVal.Points[i, j] = Points[i, j].Clone(); } } } return(retVal); }
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; }
/// <summary> /// Create surface model. /// </summary> public void ComputeOneStep() { ImageCreationStarts(); if (_paras != null) { _paras.InComputing = true; } this.WindowState = FormWindowState.Normal; if (Scheduler.GrandScheduler.Exemplar.inComputeOneStep) { return; } try { Scheduler.GrandScheduler.Exemplar.inComputeOneStep = true; SetPictureBoxSize(); string tempParameterHash = GetParameterHashWithoutPictureArt(); _paras.Assign(); if (_oldParameterHashWithoutPictureArt == tempParameterHash) { // Update last render for better quality _currentUpdateStep++; DataTypes.GraphicData oldData = null; DataTypes.PictureData oldPictureData = null; if (_iterate != null && !_iterate.InAbort) { oldData = _iterate.GraphicInfo; oldPictureData = _iterate.PictureData; } _iterate = new Iterate(_width, _height, this, false); _updateCount++; _iterate.SetOldData(oldData, oldPictureData, _updateCount); if (!ParameterDict.Current.GetBool("View.Pipeline.UpdatePreview")) { _iterate._oneStepProgress = _inPreview; } else { _iterate._oneStepProgress = false; } if (_updateCount > ParameterDict.Current.GetDouble("View.UpdateSteps") + 1) { _iterate._oneStepProgress = true; } _iterate.StartAsync(_paras.Parameter, _paras.Cycles, _paras.ScreenSize, _paras.Formula == -2, !ParameterDict.Current.GetBool("Transformation.Camera.IsometricProjection")); } else { // Initiate new rendering { // Stop subrendering, if some formula parameters changed if (_currentUpdateStep > 0) { _currentUpdateStep = 0; if (_paras != null) { _paras.InComputing = false; } Scheduler.GrandScheduler.Exemplar.inComputeOneStep = false; _oldParameterHashWithoutPictureArt = ""; _updateCount = 1; } _oldParameterHashWithoutPictureArt = tempParameterHash; _paras.Assign(); _updateCount = 1; _iterate = new Iterate(_width, _height, this, false); _iterate._oneStepProgress = false; _iterate.StartAsync(_paras.Parameter, _paras.Cycles, _paras.ScreenSize, _paras.Formula == -2, !ParameterDict.Current.GetBool("Transformation.Camera.IsometricProjection")); } } } catch (System.Exception ex) { System.Windows.Forms.MessageBox.Show(ex.ToString()); if (_paras != null) { _paras.InComputing = false; } Scheduler.GrandScheduler.Exemplar.inComputeOneStep = false; } }
public void Init(Iterate iter, PictureData pictureData) { CreateMesh(); _meshTool.Init(iter, pictureData); }
/// <summary> /// Set data of the last iteration with the same rendering parameters. /// </summary> public void SetOldData(DataTypes.GraphicData oldData, DataTypes.PictureData oldPictureData, int updateCount) { _oldData = oldData; _oldPictureData = oldPictureData; _updateCount = updateCount; }
/// <summary> /// Split computing in threads. /// </summary> public void StartAsync(FracValues act_val, int zyklen, double screensize, int formula, bool perspective) { _start = true; System.Diagnostics.Debug.WriteLine("Iter start"); _actVal = act_val; _cycles = zyklen; _screensize = screensize; _formula = formula; _perspective = perspective; _availableY = 0; int noOfThreads = ParameterDict.Current.GetInt("Computation.NoOfThreads"); if (noOfThreads == 1) { Generate(act_val, zyklen, screensize, formula, perspective); _starter.ComputationEnds(); return; } _startCount = noOfThreads; _pData = new PictureData(_width, _height); for (int i = 0; i < noOfThreads; i++) { System.Threading.ThreadStart tStart = new System.Threading.ThreadStart(Start); System.Threading.Thread thread = new System.Threading.Thread(tStart); thread.Start(); } }
/// <summary> /// Initialisation /// </summary> public Iterate(int width, int height, IAsyncComputationStarter starter, bool isRightView) { _starter = starter; _gData = new GraphicData(width, height); _pData = new PictureData(width, height); this._width = width; this._height = height; this._isRightView = isRightView; }
/// <summary> /// Initialisation /// </summary> public Iterate(int width, int height) { _gData = new GraphicData(width, height); _pData = new PictureData(width, height); this._width = width; this._height = height; }
/// <summary> /// Initialisierung /// </summary> /// <param name="pData"></param> public Formulas(PictureData pData) { this.pData = pData; }
/// <summary> /// Return true, if after generation a new process should be startet. /// </summary> public virtual bool OnPictureCreated(Iterate iter, PictureData pictureData) { return false; }
/// <summary> /// Initializes a new instance of the <see cref="X3dExporter"/> class. /// </summary> public WebGlExporter(Iterate iter, PictureData pictureData) : base(iter, pictureData) { }
/// <summary> /// Initialisation /// </summary> public Renderer(PictureData pData) { this.pData = pData; }
public ComponentRenderer(PictureData pData) : base(pData) { }
/// <summary> /// Initializes a new instance of the <see cref="X3dExporter"/> class. /// </summary> public X3DomExporter(Iterate iter, PictureData pictureData) : base(iter, pictureData) { }
public void Update(Iterate iter, PictureData pictureData) { _mesh = _meshTool.Update( iter, pictureData); }
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 MeshTool(Iterate iter, PictureData pictureData) { _iterate = iter; _pictureData = pictureData; }
/// <summary> /// Initialisation. /// </summary> /// <param name="pData"></param> public FastPreviewRenderer(PictureData pData) : base(pData) { }
public Iterate(ParameterDict parameterDict, IAsyncComputationStarter starter, bool isRightView=false) { _parameterDict = parameterDict; _starter = starter; _width = parameterDict.GetWidth(); _height=parameterDict.GetHeight(); _gData = new GraphicData(_width, _height); _pData = new PictureData(_width, _height); this._isRightView = isRightView; }
/// <summary> /// Initialisierung /// </summary> /// <param name="pData"></param> public FrontViewRenderer(PictureData pData) : base(pData) { }
/// <summary> /// Initialisation. /// </summary> public SmallMemoryRenderer(PictureData pData) : base(pData) { _pictureData = new FloatPictureData(pData.Width, pData.Height); }
/// <summary> /// call Generate(m_act_val, m_zyklen, m_raster, m_screensize, m_formula, m_perspective) auf. /// </summary> protected void Start() { Generate(_actVal, _cycles, _screensize, _formula, _perspective); lock (_startCountLock) { _startCount--; } if (_startCount == 0) { if (_starter != null) { if (_abort) { if (_oldData != null) { _gData = _oldData; } if (_oldPictureData != null) { _pData = _oldPictureData; } } System.Diagnostics.Debug.WriteLine("Iter ends"); _start = false; _starter.ComputationEnds(); } } }
/// <summary> /// Initialisierung /// </summary> /// <param name="pData"></param> public ScienceRendererBase(PictureData pData) : base(pData) { }
/// <summary> /// Initializes a new instance of the <see cref="X3dExporter"/> class. /// </summary> public VrmlSceneExporter(Iterate iter, PictureData pictureData) : base(iter,pictureData) { }
/// <summary> /// Initialisation. /// </summary> /// <param name="pData"></param> public RenderBase(PictureData pData) : base(pData) { }
/// <summary> /// Initialisation. /// </summary> /// <param name="pData"></param> public PlasicRenderer(PictureData pData) : base(pData) { }
/// <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; }