function startStatisticsInParallelepiped() {
    var app = App();
    if (app == null) return;
    var MinX = app.getMinX();
    var MaxX = app.getMaxX();
    var MinY = app.getMinY();
    var MaxY = app.getMaxY();
    var MinZ = app.getMinZ();
    var MaxZ = app.getMaxZ();
    var SX = MaxX - MinX;
    var SY = MaxY - MinY;
    var SZ = MaxZ - MinZ;
    var MeanR = parseFloat(document.FmMain.TMeanR.value);
    var meanr = parseFloat(document.FmMain.TMeanR2.value);
    var MeanRI = parseFloat(document.FmMain.TMeanRI.value);
    window.minx = eval(document.FmResults.TCalcMinX.value);
    window.maxx = eval(document.FmResults.TCalcMaxX.value);
    window.miny = eval(document.FmResults.TCalcMinY.value);
    window.maxy = eval(document.FmResults.TCalcMaxY.value);
    window.minz = eval(document.FmResults.TCalcMinZ.value);
    window.maxz = eval(document.FmResults.TCalcMaxZ.value);
    if (!app.startStatisticsInParallelepiped(
        minx, maxx, miny, maxy, minz, maxz,
        eval(document.FmResults.TCalcDXY.value)))
    {
        alert(app.getMsgStatisticsInParallelepiped());
        return;
    }
    document.FmResults.TCalcSX.value = app.sDouble(maxx-minx,2);
    document.FmResults.TCalcSY.value = app.sDouble(maxy-miny,2);
    document.FmResults.TCalcSZ.value = app.sDouble(maxz-minz,2);
    document.FmResults.TCalcV.value = app.sDouble((maxx-minx)*(maxy-miny)*(maxz-minz),5);
    document.FmResults.BStopStatisticsInParallelepiped.disabled = false;
    onTimerStatisticsInParallelepiped();
}
function stopStatisticsInParallelepiped() {
    var app = App();
    if (app == null) return;
    if (!app.stopStatisticsInParallelepiped()) {
        alert("Cannot stop statistics calculation due to the browser security policy");
        return;
    }
    document.FmResults.BStopStatisticsInParallelepiped.disabled = true;
}
function onTimerStatisticsInParallelepiped() {
    if (!canWork()) return;
    var app = App();
    if (app == null) return;
    var nAny = app.getObjCountInParallelepiped();
    if (nAny < -1) {
        setTimeout("onTimerStatisticsInParallelepiped()",1000);
        return;
    }
    document.FmResults.BStopStatisticsInParallelepiped.disabled = true;
    if (nAny >= 0) {
        document.FmResults.TObjCountInParallelepiped.value = nAny;
        var n = app.getObjCountPartiallyInParallelepiped();
        n = Math.max(n,1.0/64.0);
        document.FmResults.TObjCountPartiallyInParallelepiped.value = app.sDouble(n,5);
        document.FmResults.TObjCountFullyInParallelepiped.value = app.getObjCountFullyInParallelepiped();
        var w = app.getVolumeInParallelepiped();
        document.FmResults.TVolumeInParallelepiped.value = app.sDouble(w,5);
        document.FmResults.TVolumeInParallelepipedDivN.value = app.sDouble(w/n,5);
        document.FmResults.TEquivalentMeanRInParallelepiped.value = app.sDouble(Math.pow(w/n/(4.0/3.0*Math.PI),1.0/3.0),5);
        document.FmResults.TDensityInParallelepiped.value = app.sDouble(app.getDensityInParallelepiped(),5);
        var freeSurface = app.getFreeSurfaceInParallelepiped();
        document.FmResults.TFreeSurfaceInParallelepiped.value = app.sDouble(freeSurface,5);
        document.FmResults.TFreeSurfaceInParallelepipedDivXY.value = app.sDouble(freeSurface/((maxx-minx)*(maxy-miny)),3);
        document.FmResults.TFreeSurfaceInParallelepipedDivYZ.value = app.sDouble(freeSurface/((maxy-miny)*(maxz-minz)),3);
        document.FmResults.TFreeSurfaceInParallelepipedDivXZ.value = app.sDouble(freeSurface/((maxx-minx)*(maxz-minz)),3);
        document.FmResults.TFreeSurfaceInParallelepipedDivN.value = app.sDouble(freeSurface/n,5);
        document.FmResults.TFreeSurfaceInParallelepipedDivV.value = app.sDouble(freeSurface/((maxx-minx)*(maxy-miny)*(maxz-minz)),5);
        document.FmResults.TFreeSurfaceInParallelepipedDivVolume.value = app.sDouble(freeSurface/w,5);
        document.FmResults.TFreeSurfaceInParallelepipedRelative.value = app.sDouble(
            Math.pow(freeSurface/n/(4*Math.PI),3.0/2.0)/
            (w/n/(4.0/3.0*Math.PI)),5);
    }
}


function startStatisticsConduction() {
    var app = App();
    if (app == null) return;
    var phaseConductions = document.FmResults.TConductionPhaseConductions.value + "";
    var objIndex1 = parseInt(document.FmResults.TConductionObjIndex1.value);
    var objIndex2 = parseInt(document.FmResults.TConductionObjIndex2.value);
    var solverKind = document.FmResults.DConductionSolverKind.selectedIndex;
    var maxAllowedDiscrepancy = parseFloat(document.FmResults.TConductionMaxAllowedDiscrepancy.value);
    var applyCurrentInsteadVoltage = document.FmResults.DConductionApplyingKind.selectedIndex != 0;
    var startFromGoodApproximation = document.FmResults.CConductionStartFromGoodApproximation.checked;
    var recalculateNetwork = document.FmResults.CConductionRecalculateNetwork.checked;
    var ok = app.startStatisticsConduction(
        phaseConductions, objIndex1, objIndex2, solverKind, maxAllowedDiscrepancy,
        applyCurrentInsteadVoltage, startFromGoodApproximation, recalculateNetwork);
    document.FmResults.TConductionNodeCount.value = app.getConductionNodeCount();
    document.FmResults.TConductionResistorCount.value = app.getConductionResistorCount();
    document.FmResults.TConnectedComponentCount.value = app.getConnectedComponentCount();
    document.FmResults.TConductionObjIndex1.value = app.getConductionObjIndex1();
    document.FmResults.TConductionObjIndex2.value = app.getConductionObjIndex2();
    if (!ok) {
        alert(app.getMsgStatisticsConduction());
        document.FmResults.TConductionVoltage.value = app.sDouble(app.getConductionVoltage(),6);
        document.FmResults.TConductionCurrent.value = app.sDouble(app.getConductionCurrent(),6);
        document.FmResults.TConduction.value = app.sDouble(app.getConduction(),6);
        return;
    }
    document.FmResults.TConductionVoltage.value += " ?";
    document.FmResults.TConductionCurrent.value += " ?";
    document.FmResults.TConduction.value += " ?";
    document.FmResults.BStopStatisticsConduction.disabled = false;
    onTimerStatisticsConduction();
}
function stopStatisticsConduction() {
    var app = App();
    if (app == null) return;
    if (!app.stopStatisticsConduction()) {
        alert("Cannot stop statistics calculation due to the browser security policy");
        return;
    }
    document.FmResults.BStopStatisticsConduction.disabled = true;
}
function onTimerStatisticsConduction() {
    if (!canWork()) return;
    var app = App();
    if (app == null) return;
    if (!app.isConductionReady()) {
        setTimeout("onTimerStatisticsConduction()",1000);
        return;
    }
    document.FmResults.BStopStatisticsConduction.disabled = true;
    document.FmResults.TConductionNodeCount.value = app.getConductionNodeCount();
    document.FmResults.TConductionResistorCount.value = app.getConductionResistorCount();
    document.FmResults.TConnectedComponentCount.value = app.getConnectedComponentCount();
    document.FmResults.TConductionVoltage.value = app.sDouble(app.getConductionVoltage(),6);
    document.FmResults.TConductionCurrent.value = app.sDouble(app.getConductionCurrent(),6);
    document.FmResults.TConduction.value = app.sDouble(app.getConduction(),6);
    SetStatisticsConductionColorMaker();
}
function SetStatisticsConductionColorMaker() {
    if (!canWork()) return;
    var app = App();
    if (app == null) return;
    var i = document.FmResults.DConductionColorMaker.selectedIndex;
    if (i == 1)
        app.setVoltageGradientColorMaker(0x0000FF, 0xFF0000, 0xFFFFFF);
    else if (i == 2)
        app.setCurrentGradientColorMaker(0x0000FF, 0xFFFF00, 0xFFFFFF);
    else
        app.setDefaultColorMaker();
}

window.reportwindow = null;
function param(name, value) {
    return "\t<param name=\""+name+"\" value=\""+value+"\">\n";
}
function rotationButton(value,ortIx,ortIy,ortIz,ortJx,ortJy,ortJz) {
    return '<font face="Lucida Sans Unicode" size="4"><input type="button" '
        +'value="'+value+'" style="font-family: \'Lucida Sans Unicode\'; '
        +'width: 25px" language="JavaScript" onclick="document.AppletPackingMink.setPaintOrientation('
        +ortIx+','+ortIy+','+ortIz+','+ortJx+','+ortJy+','+ortJz
        +')"></font>\n';
}
function DetailReport() {
    var app = App();
    if (app == null) return;
    if (app.getObjCount()==0) {
        alert("There is no packed structure! Please, press the \"Execute\" button");
        return;
    }

    if ((document.FmResults.CReportPicture.checked || document.FmResults.CReportText.checked)
        && app.getObjCount()>5000)
        if (!confirm("Showing report for >5000 objects in the browser can take long time. "+
            "Do you wish to continue?")) return;

    var objCount=app.getObjCount();

    var report1="",report2="",report3="";
    var reporttitle= document.FmResults.TDetailReportTitle.value;
    if (reporttitle=="") reporttitle= "The packed structure";
    var p=reporttitle.indexOf("###");
    if (p!=-1)
        reporttitle= reporttitle.substring(0,p)+objCount+reporttitle.substring(p+3);
    window.reportwindow= window.open("","Report",
        "toolbar=0,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1");

    report1 = "<html>\n"
        +"<head>\n"
        +"<title>"+reporttitle+"</title>\n"
        +"<st"+"yle type=\"text/css\">\n"
        +"<"+"!-"+"-\n"
        +"  I {font-family: serif;}\n"
        +"-"+"-"+">\n"
        +"</st"+"yle>\n"
        +"</head>\n";
    report1+= "<body bgcolor=\"#FFFFFF\">\n";
    report1+= "<p align=\"right\"><font color=\"#800000\"><em>"
        +"To save this page, please use &quot;View&quot;&nbsp;/&nbsp;&quot;Source&quot; command (in the browser menu),<br>"
        +"and then please save the resuling text as &quot;.html&quot;-file by &quot;File&quot;&nbsp;/&nbsp;&quot;Save&nbsp;as...&quot;"
        +"</em></font></p>\n";
    if (reporttitle!="")
        report1+= "<h3>"+reporttitle+"</h3>\n";

    var needreportpicture= document.FmResults.CReportPicture.checked;
    var needreporttext= document.FmResults.CReportText.checked;

    reportwindow.document.open();
    var x,y,z,v;
    if (needreportpicture) {
        report1+= /*"<td valign=\"top\"><table border=\"1\" cellspacing=\"1\"><tr><td>\n"+*/
            "<div align=\"center\">\n"
            +"<form name=\"fmPaint\" style=\"margin: 0px\">\n<nobr>"
            +rotationButton("&rarr;", 0,0,-1, -1,0,0)   +"&nbsp;"
            +rotationButton("&larr;", 0,0,1, 1,0,0)     +"&nbsp;"
            +rotationButton("&darr;", -1,0,0, 0,0,1)    +"&nbsp;"
            +rotationButton("&uarr;", 1,0,0, 0,0,-1)    +"&nbsp;"
            +rotationButton("&harr;", 1,0,0, 0,1,0)     +"&nbsp;"
            +rotationButton("&#8626;", -1,0,0, 0,1,0)
            +"</nobr></form>"
            +"<applet codebase=\""+app.getCodeBase().toString()+"\" archive=\"packingmink.jar\" "
            +"code=\"AppletPackingMink.class\"\n"
            +"align=\"baseline\" width=\"800\" height=\"800\"\n"
            +"style=\"width:100%\"\n"
            +"id=\"AppletPackingMink\" name=\"AppletPackingMink\">\n"
            +param("AutoStart","false")
            +param("UseStatus","true")
            +param("MaxObjCount",parseInt(document.FmMain.TMaxObjCount.value))
            +param("MaxAverageGeneratrixSegmentsCount",parseFloat(document.FmMain.TMaxAverageGeneratrixSegmentsCount.value))
            +param("NeedObjCount",objCount)
            +param("GridXDim",parseInt(document.FmMain.TGridDim.value))
            +param("GridYDim",parseInt(document.FmMain.TGridDim.value))
            +param("GridZDim",parseInt(document.FmMain.TGridDim.value))
            +param("GridStep",parseFloat(document.FmMain.TGridStep.value))
            +param("PackingKind",document.FmMain.DPackingKind.options.selectedIndex)
            +param("PackInBunker",app.getPackInBunker())
            +param("BunX",parseFloat(document.FmMain.TBunX.value))
            +param("BunY",parseFloat(document.FmMain.TBunY.value))
            +param("BunZ",parseFloat(document.FmMain.TBunZ.value))
            +param("BunColors",document.FmMain.TBunColors.value)
            +param("NearestFrom",parseInt(document.FmMain.TNearestFrom.value))
            +param("RandomRotating",document.FmMain.CRandomRotating.checked)
            +param("CompactnessFactor",parseInt(document.FmMain.TCompactnessFactor.value))
            +param("RandomRadiusModel",document.FmMain.DRandomRadiusModel.selectedIndex)
            +param("RandomRadiusModel2",document.FmMain.DRandomRadiusModel2.selectedIndex)
            +param("RandomRadiusIncrementModel",document.FmMain.DRandomRadiusIncrementModel.selectedIndex)
            +param("MeanR",app.getMeanR())
            +param("DR",app.getDR())
            +param("MeanR2",app.getMeanR2())
            +param("DR2",app.getDR2())
            +param("MeanRI",app.getMeanRI())
            +param("DRI",app.getDRI())
            +param("SpherePolyhedraKinds",app.getSpherePolyhedraKinds())
            +param("FractionsOfKinds",app.getFractionsOfKinds())
            +param("VolumeFractionsMode",app.isVolumeFractionsMode())
            +param("PreferredDirectionsCount",app.getPreferredDirectionsCount())
            +param("PreferredDirections",app.getPreferredDirections(",","; "))
            +param("PreferredDirectionsDFi",app.getPreferredDirectionsDFi("; "))
            +(isNaN(x=parseFloat(document.FmMain.TPreferredStartX.value))?"":param("PreferredStartX",x))
            +(isNaN(x) || isNaN(v=parseFloat(document.FmMain.TPreferredStartDX.value))?"":param("PreferredStartDX",v))
            +(isNaN(y=parseFloat(document.FmMain.TPreferredStartY.value))?"":param("PreferredStartY",x))
            +(isNaN(y) || isNaN(v=parseFloat(document.FmMain.TPreferredStartDY.value))?"":param("PreferredStartDY",v))
//            +(isNaN(z=parseFloat(document.FmMain.TPreferredStartZ.value))?"":param("PreferredStartZ",x))
//            +(isNaN(z) || isNaN(v=parseFloat(document.FmMain.TPreferredStartDZ.value))?"":param("PreferredStartDZ",v))
            +param("UsedColors",app.getUsedColors())
            +param("RequiredNeighbourIndex",document.FmMain.TRequiredNeighbourIndex.value)
            +param("SameColorNeighboursCount",document.FmMain.DSameColorNeighboursCount.selectedIndex)
            +param("MaxInvisibleNeighboursCount",(3-document.FmMain.DMaxInvisibleNeighboursCount.selectedIndex))
            +param("NonRestrictedObjCount",parseInt(document.FmMain.TNonRestrictedObjCount.value))
            +param("RestrictedMaxD",app.getRestrictedMaxD())
            +param("WarningWhenCannotPack",document.FmMain.CWarningWhenCannotPack.checked)
            +param("PackTimeOut",document.FmMain.TPackTimeOut.value)
            +param("CheckAllPositions",document.FmMain.CCheckAllPositions.checked)

            +param("InvisibleColors",document.FmMain.TInvisibleColors.value)
            +param("PaintScale",800.0/500.0*parseFloat(document.FmPaint.TPaintScale.value))
            +param("StartingRotationX",3)
            +param("StartingRotationY",8)
            +param("RandomSequenceSeed",lastRandomSeed);

        if (!false/*document.FmResults.CReportExecutablePicture.checked*/) {
            report1+= "\t";
            report1+= app.getAllObjAppletParams(app.getSpecialObjCount(),objCount,1,"\n\t");
            report2+= "\n";
        }
        report2+= "</applet>\n"/*+"</td></tr></table>\n"*/;
        report2+= "</div>\n\n";
    }

    app.calculateStatistics();
    report2+= "<h4>Global statistic parameters of the packing</h4>";
    report2+= "<p>The number of packed sphere-polyhedra: "+app.getObjCount()+"<br>\n"+
        "Maximal radius of sphere circumscribed around sphere-polyhedron: "+app.getMaxR()+"<br>\n"+
        "Radius of containing sphere: "+app.getMaxD()+"<br>\n"+
        "Containing parallelepiped:<br>\n<small>"
            +"&nbsp;&nbsp;&nbsp;&nbsp;"+app.getMinX()+" &le; <i>x</i> &le; "+app.getMaxX()+",<br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;"+app.getMinY()+" &le; <i>y</i> &le; "+app.getMaxY()+",<br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;"+app.getMinZ()+" &le; <i>z</i> &le; "+app.getMaxZ()+",<br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;"+app.sDouble(app.getMaxX()-app.getMinX(),5)+" * "
                +app.sDouble(app.getMaxY()-app.getMinY(),5)+" * "
                +app.sDouble(app.getMaxZ()-app.getMinZ(),5)+"</small><br>\n"
        +"Summary volume of all objects: "+app.getSumV()+"\n";
    var cc = app.getColorCharacters()+""; // +"" is necessary in Mozilla, where this method returns JAVA String object

    report2+= "<p>Volumes, percents and number of objects touching some object for all colors "
        +"(syntax: <nobr>min..max, average &plusmn; average_quadratic_deviation):</nobr>\n<br>";
    var usedTouchingColors = 0;
    for (var k2 = 0; k2 < cc.length+1; k2++) {
        if (app.getNeighboursCountMax(0,k2)>0) usedTouchingColors++;
    }
    var objCount = app.getObjCount();
    var conductionPhaseMaxCount = app.getConductionPhaseMaxCount();
    report2+= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\">\n<tr>\n"
        +"<td rowspan=2 align=center valign=bottom><small>base color</small></td>"
        +(conductionPhaseMaxCount==0? "" :
            "<td rowspan=2 align=center valign=bottom><small>phase<br>conduction</small></td>")
        +"<td rowspan=2 align=center valign=bottom><small>number of<br>objects</small></td>"
        +"<td rowspan=2 align=center valign=bottom><small>% of<br>objects</small></td>"
        +"<td rowspan=2 align=center valign=bottom><small>mean<br>volume</small></td>"
        +"<td rowspan=2 align=center valign=bottom><small>summary<br>volume</small></td>"
        +"<td rowspan=2 align=center valign=bottom><small>% of<br>volume</small></td>"
        +"<td colspan="+usedTouchingColors+" align=center><small>touching color</small></td></tr>\n"
        +"<tr><td align=center><small>any</small></td>";
    for (var k2 = 1; k2 < cc.length+1; k2++) {
        if (app.getNeighboursCountMax(0,k2)>0)
            report2+= "<td bgcolor=\"#"+app.getColorAsHexForHTML(k2-1,100)+"\">&nbsp;</td>";
    }
    var sumV = app.getSumV();
    report2+= "</tr>\n";
    for (var k1 = 0; k1 < cc.length+1; k1++) {
        var n = k1==0? objCount: app.getObjCountPerColor(k1-1);
        if (n <= 0) continue;
        var v = k1==0? sumV: app.getObjVolumePerColor(k1-1);
        report2+= "<tr><td"+(k1==0?"":" bgcolor=\"#"+app.getColorAsHexForHTML(k1-1,100)+"\"")
            +">"+(k1==0?"<small>any</small>":"&nbsp;")+"</td>"
            +(conductionPhaseMaxCount==0? "" :
                "<td align=center><small><small>"+(k1==0?"&nbsp;":app.sDouble(app.getPhaseConduction(k1-1),5))+"</small></small></td>")
            +"<td align=center><small><small>"+n+"</small></small></td>"
            +"<td align=center><small><small>"+(k1==0?"&nbsp;":app.sDouble(100.0*n/objCount,1))+"</small></small></td>"
            +"<td align=center><small><small>"+app.sDouble(v/n,5)+"</small></small></td>"
            +"<td align=center><small><small>"+app.sDouble(v,3)+"</small></small></td>"
            +"<td align=center><small><small>"+(k1==0?"&nbsp;":app.sDouble(100.0*v/sumV,1))+"</small></small></td>";
        for (var k2 = 0; k2 < cc.length+1; k2++) {
            if (app.getNeighboursCountMax(0,k2)>0) {
                var max = app.getNeighboursCountMax(k1,k2);
                report2+= "<td nowrap>"
                    +(max == 0? "&nbsp;":
                        "<small><small>"+app.getNeighboursCountMin(k1,k2)
                        +".."+max
                        +", "+app.sDouble(app.getNeighboursCountAverage(k1,k2),k2==0?4:2)
                        +"&plusmn;"+app.sDouble(app.getNeighboursCountAQD(k1,k2),k2==0?4:2)
                        +"</small></small>")
                    +"</td>";
            }
        }
        report2+= "</tr>\n";
    }
    report2+= "</table>\n"
        +"<p>Mean density in the sphere with center (0,0,0) and the given radii <i>R</i>:</p>\n"
        +"<blockquote><table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n"
        +"<tr>\n"
        +"  <td align=\"right\"><i>R</i></td>\n"
        +"  <td align=\"right\">&nbsp;density</td>\n"
        +"  <td><small>&nbsp;&nbsp;</small></td>\n"
        +"  <td>&plusmn;&Delta;</td>\n"
    for (var k=0;k<=50;k++) {
        var R=app.getMaxD()*k/50.0;
        report2+=
            "<tr>\n"
            +"  <td align=\"right\"><small>"+R+"</small></td>\n"
            +"  <td align=\"right\"><small>"+
                density(R,
                    "</small></td>\n  <td></td>\n  <td><small>",
                    "</small></td>\n  <td></td>\n  <td><small>&nbsp;")
            +"</small></td>\n"
            +"</tr>\n";
    }
    report2+= "</table></blockquote>\n\n";

    var nAny = app.getObjCountInParallelepiped();
    if (nAny >= 0 && /*to be on the safe side:*/window.minx != null) {
        var n = app.getObjCountPartiallyInParallelepiped();
        n = Math.max(n,1.0/64.0);
        report2+= "<h4>Statistic parameters for the parallelepiled</h4>";
        report2+= "<p>The chosen parallelepiled:<br>\n<small>"
            +"&nbsp;&nbsp;&nbsp;&nbsp;"+minx+" &le; <i>x</i> &le; "+maxx+", <i>l<sub>x</sub></i> = "+app.sDouble(maxx-minx,5)+"<br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;"+miny+" &le; <i>y</i> &le; "+maxy+", <i>l<sub>y</sub></i> = "+app.sDouble(maxy-miny,5)+"<br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;"+minz+" &le; <i>z</i> &le; "+maxz+", <i>l<sub>z</sub></i> = "+app.sDouble(maxz-minz,5)+"<br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;volumne <i>V</i> = "+app.sDouble(maxx-minx,5)+" * "
                +app.sDouble(maxy-miny,5)+" * "
                +app.sDouble(maxz-minz,5)+" = "
                +app.sDouble((maxx-minx)*(maxy-miny)*(maxz-minz),5)+"</small></p>\n"
            +"<table border=0 cellpadding=0 cellspacing=0>\n"
            +"<tr><td>Number of objects in the parallelepiped: </td><td align=\"right\"><i>n</i> = </td><td>&nbsp;&nbsp;</td><td>"+app.sDouble(n,5)+"</td></tr>\n"
            +"<tr><td>Number of objects that are fully inside the parallelepiped:</td><td>&nbsp;</td><td>&nbsp;&nbsp;</td><td>"+app.getObjCountFullyInParallelepiped()+"</td></tr>\n"
            +"<tr><td>Number of objects that inside or intersects the parallelepiped:</td><td>&nbsp;</td><td>&nbsp;&nbsp;</td><td>"+nAny+"</td></tr>\n";
        var w = app.getVolumeInParallelepiped();
        var freeSurface = app.getFreeSurfaceInParallelepiped();
        report2+= "<tr><td>Occupied volume: </td><td align=\"right\"><i>w</i> = </td><td>&nbsp;</td><td>"+app.sDouble(w,5)+"</td></tr>\n"
            +"<tr><td>Average volume of an object: </td><td align=\"right\"><i>w</i> / <i>n</i> = </td><td>&nbsp;</td><td>"+app.sDouble(w/n,5)+"</td></tr>\n"
            +"<tr><td>Radius of the sphere which volume is equal to <i>w</i> / <i>n</i>: </td><td align=\"right\"><i>&rho;</i> = </td><td>&nbsp;</td><td>"+app.sDouble(Math.pow(w/n/(4.0/3.0*Math.PI),1.0/3.0),5)+"</td></tr>\n"
            +"<tr><td>Mean density: </td><td align=\"right\"><i>w</i> / <i>V</i> = </td><td>&nbsp;</td><td>"+app.sDouble(app.getDensityInParallelepiped(),5)+"</td></tr>\n"
            +"<tr><td>Free surface: </td><td align=\"right\"><i>s</i> = </td><td>&nbsp;</td><td>"+app.sDouble(freeSurface,5)+"</td></tr>\n"
            +"<tr><td>Free surface relatively the <i>xy</i>facet of this parallelepiped: "
            +"</td><td align=\"right\"><i>s</i> / (<i>l<sub>x</sub></i><i>l<sub>y</sub></i>) = </td><td>&nbsp;</td><td>"+app.sDouble(freeSurface/((maxx-minx)*(maxy-miny)),5)+"</td></tr>\n"
            +"<tr><td>Free surface relatively the <i>yz</i>facet of this parallelepiped: "
            +"</td><td align=\"right\"><i>s</i> / (<i>l<sub>y</sub></i><i>l<sub>z</sub></i>) = </td><td>&nbsp;</td><td>"+app.sDouble(freeSurface/((maxy-miny)*(maxz-minz)),5)+"</td></tr>\n"
            +"<tr><td>Free surface relatively the <i>xz</i>facet of this parallelepiped: "
            +"</td><td align=\"right\"><i>s</i> / (<i>l<sub>x</sub></i><i>l<sub>z</sub></i>) = </td><td>&nbsp;</td><td>"+app.sDouble(freeSurface/((maxx-minx)*(maxz-minz)),5)+"</td></tr>\n"
            +"<tr><td>Average free surface of an object: </td><td align=\"right\"><i>s</i> / <i>n</i> = </td><td>&nbsp;</td><td>"+app.sDouble(freeSurface/n,5)+"</td></tr>\n"
            +"<tr><td>Free surface relatively the volume of the parallelepiped: </td><td align=\"right\"><i>s</i> / <i>V</i> = </td><td>&nbsp;</td><td>"
                +app.sDouble(freeSurface/((maxx-minx)*(maxy-miny)*(maxz-minz)),5)+"</td></tr>\n"
            +"<tr><td>Free surface relatively the occuupied volume: </td><td align=\"right\"><i>s</i> / <i>w</i> = </td><td>&nbsp;</td><td valign=\"middle\">"+app.sDouble(freeSurface/w,5)+"</td></tr>\n"
            +"<tr><td>&quot;Relative&quot; free surface: </td><td align=\"right\">(<i>s</i>/4<i>&pi;n</i>)<sup>3/2</sup> / (&frac34;<i>w</i>/<i>&pi;n</i>) = "
                +"</td><td>&nbsp;</td>\n<td valign=\"middle\">"
                +app.sDouble(Math.pow(freeSurface/n/(4*Math.PI),3.0/2.0)/(w/n/(4.0/3.0*Math.PI)),5)+"</td></tr>\n"
            +"<tr><td colspan=\"4\">&nbsp;&nbsp;&nbsp;<small>(for a sphere, (<i>s</i>/4<i>&pi;n</i>)<sup>3/2</sup> = "
                +"&frac34;<i>w</i>/<i>&pi;n</i> = <i>R</i><sup>3</sup>)</small></td></tr>\n"
            +"</table>\n";
        report2+= "\n";
    }

    var isConductionReady = app.isConductionReady();
    if (isConductionReady) {
        report2+= "<h4>Conduction statistic parameters</h4>";
        report2+= "<p>Two objects selected for applying voltage:<br>\n<small>"
            +"&nbsp;&nbsp;&nbsp;&nbsp;"+app.getConductionObjIndex1()+" and "+app.getConductionObjIndex2()+"</p>\n"
            +"<table border=0 cellpadding=0 cellspacing=0>\n"
            +"<tr><td>Number of nodes (visible objects): </td><td align=\"right\"><i>n</i> = </td><td>&nbsp;</td><td>"+app.getConductionNodeCount()+"</td></tr>\n"
            +"<tr><td>Number of resistors (contacts): </td><td align=\"right\"><i>m</i> = </td><td>&nbsp;</td><td>"+app.getConductionResistorCount()+"</td></tr>\n"
            +"<tr><td>Number of connected visible components: </td><td align=\"right\">&nbsp;</td><td>&nbsp;</td><td>"+app.getConnectedComponentCount()+"</td></tr>\n"
            +"<tr><td>Voltage between selected objects: </td><td align=\"right\"><i>V</i> = </td><td>&nbsp;</td><td>"+app.getConductionVoltage()+"</td></tr>\n"
            +"<tr><td>Current between selected objects: </td><td align=\"right\"><i>I</i> = </td><td>&nbsp;</td><td>"+app.getConductionCurrent()+"</td></tr>\n"
            +"<tr><td>Conduction between selected objects: </td><td align=\"right\"><i>c</i> = </td><td>&nbsp;</td><td>"+app.getConduction()+"</td></tr>\n"
            +"<tr><td>Resistance between selected objects: </td><td align=\"right\"><i>R</i> = </td><td>&nbsp;</td><td>"+1.0/app.getConduction()+"</td></tr>\n"
            +"<tr><td>Final discrepancy of solving equations: </td><td align=\"right\">&epsilon; = </td><td>&nbsp;</td><td>"+app.getConductionLastDiscrepancy()+"</td></tr>\n"
            +"</table>\n\n";
    }

    if (needreporttext) {
        report2+= "<h4>Full description of the packing</h4>";
/*      report2+= "<p><em>Format of a line in the following list:</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;"
            +"<b>K</b>&nbsp;"
            +"C&nbsp;"
            +"<i>x</i>&nbsp;<i>y</i>&nbsp;<i>z</i>&nbsp;<i>r</i>&nbsp;\n"
            +"N&nbsp;"
            +"(<i>x</i><sub>1</sub>&nbsp;<i>y</i><sub>1</sub>&nbsp;<i>z</i><sub>1</sub>) "
            +"(<i>x</i><sub>2</sub>&nbsp;<i>y</i><sub>2</sub>&nbsp;<i>z</i><sub>2</sub>) ... "
            +"(<i>x</i><sub>N</sub>&nbsp;<i>y</i><sub>N</sub>&nbsp;<i>z</i><sub>N</sub>) \n"
            +"&nbsp;&nbsp;<i>V</i>\n"
            +"&nbsp;&nbsp;<i>S</i>\n"
            +"&nbsp;&nbsp;<i>m</i>\n"
            +"&nbsp;n<sub>1</sub>C<sub>1</sub>"
            +"&nbsp;n<sub>2</sub>C<sub>2</sub>"
            +"&nbsp;..."
            +"&nbsp;n<sub><i>m</i></sub>C<sub><i>m</i></sub><br>\n"
            +"<em>Here:</em><br>\n";
*/
        report2+= "<p><em>In the following table:</em><br>\n";
        report2+="&nbsp;&nbsp;&nbsp;&nbsp;<b>K</b><em> is an index of the sphere-polyhedron,</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;C<em> is a character code of it's color "
            +"(see the </em>&quot;Used colors&quot;<em> parameter),</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;<i>x</i>&nbsp;<i>y</i>&nbsp;<i>z</i>)<em> "
            +"are coordinates of it's center,</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;<i>r</i><em> is the radius of the generatrix sphere,</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;N<em> is the number of generatrix segments,</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;<nobr>[<i>A</i><sub><i>i</i></sub><i>B</i><sub><i>i</i></sub>], \n"
            +"<i>A</i><sub><i>i</i></sub>=&nbsp;(<i>x</i><sub><i>i</i></sub>,&nbsp;"
            +"<i>y</i><sub><i>i</i></sub>,&nbsp;<i>z</i><sub><i>i</i></sub>), "
            +"<i>B</i><sub><i>i</i></sub>=&nbsp;(<i>-x</i><sub><i>i</i></sub>,&nbsp;"
            +"-<i>y</i><sub><i>i</i></sub>,&nbsp;-<i>z</i><sub><i>i</i></sub>),</nobr> \n"
            +"<i>i&nbsp;</i>=&nbsp;1,&nbsp;...,&nbsp;N <em>are generatrix segments,</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;<i>V</i><em> is the volume of the spere=polyhedron,</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;<i>S</i><em> is the surface area of the spere=polyhedron,</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;<i>m</i> "
            +"<em>is the number of neighbours of the sphere-polyhedron,</em><br>\n"
            +"&nbsp;&nbsp;&nbsp;&nbsp;n<sub><i>i</i></sub>C<sub><i>i</i></sub> "
            +"<em>are indices and colors of these neighbours.</em></p>\n";
        report2+= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\">\n<tr>\n"
            +"  <td><b>K</b></td>\n"
            +"<td colspan=\"2\" align=\"center\">C</td>\n"
            +"<td><i>x</i></td><td><i>y</i></td><td><i>z</i></td><td><i>r</i></td>\n"
            +"<td>N</td>\n"
            +"<td>(<i>x</i><sub><i>i</i></sub>&nbsp;<i>y</i><sub><i>i</i></sub>&nbsp;"
            +"<i>z</i><sub><i>i</i></sub>)</td>\n"
            +"<td><i>V</i></td>\n"
            +"<td><i>S</i></td>\n"
            +"<td><i>m</i></td>\n"
            +"<td>n<sub><i>i</i></sub>C<sub><i>i</i></sub></td>\n"
            +"</tr><tr>\n"
            +"  <td nowrap><small>";
        report2+= "\t"+app.getAllObjHTML(0,objCount,1,
            "</small></td><td nowrap><small>",
            "</td>\n</tr><tr>\n  <td nowrap><small>",
            isConductionReady);
        report3+= "</tr>\n</table>\n\n";
    }
    report3+= "\n";
    report3+= "</body>\n";
    report3+= "</html>\n";
    reportwindow.document.writeln(report1+report2+report3);
    reportwindow.document.close();
    reportwindow.focus();
}


