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;
}