function calculateDTM()
{
    var current = 0;
    if(globalModelID == '')
    {
        globalModelID = createModel(globalModelName);
    }
    createMaterial(globalModelID);
    var RT = desiteAPI.getRootContainerList(globalModelName);
    var str = '<container ID="'+ globalDTMFolder +'" name="'+ globalDTMFolder +'" />';
    desiteAPI.createObjectFromXml(RT,str);
    for(var a = 0; a < __globalDTMData__.length; a++)
    {
        var check = [__globalDTMData__[a][2].length];
        for(var i =0 ; i< check.length; i++)
        {
            check[i] = 0;
        }
        for(var i =0; i< __globalDTMData__[a][2].length; i++)
        {
            var p1 = [__globalDTMData__[a][3][__globalDTMData__[a][2][i][1]][0] - __globalDTMData__[a][3][__globalDTMData__[a][2][i][0]][0],__globalDTMData__[a][3][__globalDTMData__[a][2][i][1]][1] - __globalDTMData__[a][3][__globalDTMData__[a][2][i][0]][1], __globalDTMData__[a][3][__globalDTMData__[a][2][i][1]][2] - __globalDTMData__[a][3][__globalDTMData__[a][2][i][0]][2]];
            var p2 = [__globalDTMData__[a][3][__globalDTMData__[a][2][i][2]][0] - __globalDTMData__[a][3][__globalDTMData__[a][2][i][0]][0],__globalDTMData__[a][3][__globalDTMData__[a][2][i][2]][1] - __globalDTMData__[a][3][__globalDTMData__[a][2][i][0]][1], __globalDTMData__[a][3][__globalDTMData__[a][2][i][2]][2] - __globalDTMData__[a][3][__globalDTMData__[a][2][i][0]][2]];
            var kp = [p1[1] * p2[2] - p1[2] * p2[1], p1[2] * p2[0] - p1[0] * p2[2], p1[0] * p2[1] - p1[1] * p2[0]];
            var kp_n = Math.sqrt(kp[0] * kp[0] + kp[1] * kp[1] + kp[2] * kp[2]);
            kp[0] = kp[0] / kp_n;
            kp[1] = kp[1] / kp_n;
            kp[2] = kp[2] / kp_n;
            var value = Math.acos(kp[2]) * 180.0 / Math.PI;
            var oP1 = __globalDTMData__[a][3][__globalDTMData__[a][2][i][0]];
            var oP2 = __globalDTMData__[a][3][__globalDTMData__[a][2][i][1]];
            var oP3 = __globalDTMData__[a][3][__globalDTMData__[a][2][i][2]];
            var l1 = [oP1[0] - oP2[0],oP1[1] - oP2[1],oP1[2] - oP2[2]];
            var l2 = [oP1[0] - oP3[0],oP1[1] - oP3[1],oP1[2] - oP3[2]];
            var l3 = [oP3[0] - oP2[0],oP3[1] - oP2[1],oP3[2] - oP2[2]];
            if(value > __dep__[0].value && value < (180.0 - __dep__[0].value))  
            {
                current = current + 1;
                if( Math.abs(l1[2]) > __dep__[1].value || Math.abs(l2[2]) > __dep__[1].value || Math.abs(l3[2]) > __dep__[1].value) 
                {
                    if(Math.abs(l1[2]) < Math.abs(l2[2]) && Math.abs(l1[2]) < Math.abs(l3[2]) && (oP1[2] > oP3[2] || oP2[2] > oP3[2]))
                    {
                        createGeometryDTM(oP1,oP2,'01, 02, 03, 05');
                        check[i] = 1;  
                    }
                    else if(Math.abs(l2[2]) < Math.abs(l1[2]) && Math.abs(l2[2]) < Math.abs(l3[2]) && (oP1[2] > oP2[2] || oP3[2] > oP2[2]))
                    {
                        createGeometryDTM(oP3,oP1,'01, 02, 03, 05');
                        check[i] = 1;  
                    }
                    else if(Math.abs(l3[2]) < Math.abs(l2[2]) && Math.abs(l3[2]) < Math.abs(l1[2]) && (oP2[2] > oP1[2] || oP3[2] > oP1[2]))
                    {
                        createGeometryDTM(oP2,oP3,'01, 02, 03, 05');
                        check[i] = 1;  
                    }
                }
                if(check[i])
                {
                    continue;
                }
                for(var j = i + 1; j < __globalDTMData__[a][2].length; j++)
                {
                    for(var k = 0; k < 3; k++)
                    {
                        var nP1 = __globalDTMData__[a][3][__globalDTMData__[a][2][i][k]];
                        for( var l = 0; l < 3; l++)
                        {
                            var nP2 = __globalDTMData__[a][3][__globalDTMData__[a][2][j][l]];
                            if(Math.sqrt((nP1[0] - nP2[0]) * (nP1[0] - nP2[0]) + (nP1[1] - nP2[1]) * (nP1[1] - nP2[1])) <= __dep__[1].value)
                            {
                                if(Math.abs(l1[2]) < Math.abs(l2[2]) && Math.abs(l1[2]) < Math.abs(l3[2]) && (oP1[2] > oP3[2] || oP2[2] > oP3[2]))
                                {
                                    createGeometryDTM(oP1,oP2,'01, 02, 03, 05');
                                    check[i] = 1;  
                                }
                                else if(Math.abs(l2[2]) < Math.abs(l1[2]) && Math.abs(l2[2]) < Math.abs(l3[2]) && (oP1[2] > oP2[2] || oP3[2] > oP2[2]))
                                {
                                    createGeometryDTM(oP3,oP1,'01, 02, 03, 05');
                                    check[i] = 1;  
                                }
                                else if(Math.abs(l3[2]) < Math.abs(l2[2]) && Math.abs(l3[2]) < Math.abs(l1[2]) && (oP2[2] > oP1[2] || oP3[2] > oP1[2]))
                                {
                                    createGeometryDTM(oP2,oP3,'01, 02, 03, 05');
                                    check[i] = 1;  
                                }
                            }
                            if(check[i])
                            {
                                break;
                            }
                        }
                        if(check[i])
                        {
                            break;
                        }
                    }
                    if(check[i])
                    {
                        break;
                    }
                }
            }
        }
    }
    return true;
}