コード例 #1
0
ファイル: LoadFile.cs プロジェクト: drt-ftl/VAME
    void scanCCT(string _line)
    {
        if (_line == "\r\n" || _line.Contains('X')) return;
        if (_line.StartsWith("STEPSIZE:"))
        {
            var ssText = _line.Split(':');
            float res;
            if (float.TryParse(ssText[1], out res))
                cctRes = res;
            return;
        }
        else if (_line.StartsWith("DISTANCE:"))
        {
            var ssText = _line.Split(':');
            float dist;
            if (float.TryParse(ssText[1], out dist))
                totalCctPathDistance = dist;
            return;
        }
        else if (_line.StartsWith("POINTS:"))
        {
            var ssText = _line.Split(':');
            int count;
            if (Int32.TryParse(ssText[1], out count))
                cctPointCount = count;
            return;
        }
        _line = _line.Trim();
        var chunks = _line.Split(',');
        var initial = 999999999f;
        var vertex = Vector3.one * initial;
        float x;
        float y;
        float z;
        float temperature;
        if (float.TryParse(chunks[0], out x))
        {
            vertex.x = x;
        }
        if (float.TryParse(chunks[2], out y))
        {
            vertex.y = y;
        }
        if (float.TryParse(chunks[1], out z))
        {
            vertex.z = z;
        }
        if (float.TryParse(chunks[3], out temperature))
        {
            if (vertex.x != initial && vertex.y != initial && vertex.z != initial)
            {
                var newPoint = new CCATpoint();
                newPoint.Position = vertex;
                if (vertex.x < cctMin.x)
                    cctMin.x = vertex.x;
                if (vertex.x > cctMax.x)
                    cctMax.x = vertex.x;
                if (vertex.y < cctMin.y)
                    cctMin.y = vertex.y;
                if (vertex.y > cctMax.y)
                    cctMax.y = vertex.y;
                if (vertex.z < cctMin.z)
                    cctMin.z = vertex.z;
                if (vertex.z > cctMax.z)
                    cctMax.z = vertex.z;

                newPoint.Temp = temperature;
                newPoint.Id = cctVerts.Count;
                cctVerts.Add(newPoint);
            }
        }
    }
コード例 #2
0
ファイル: LoadFile.cs プロジェクト: drt-ftl/VAME
 void ConvertGcdDataToPoints()
 {
     cctRes = fullGcdPathDistance / (cctPointCount + 1);
     var partialDistance = 0f;
     foreach (var v1 in gcdLineEndpoints)
     {
         var index = gcdLineEndpoints.IndexOf(v1);
         if (index == 0) continue;
         var v0 = gcdLineEndpoints[index - 1];
         var d = Vector3.Distance(v0, v1);
         var rem = cctRes - partialDistance;
         if (d < rem)
         {
             gcdPathDistance += d;
             partialDistance += d;
             continue;
         }
         var t = (rem / d);
         var m = v1 - v0;
         var p = new Vector3();
         p.x = v0.x + m.x * t;
         p.y = v0.y + m.y * t;
         p.z = v0.z + m.z * t;
         var newPoint = new CCATpoint();
         newPoint.Id = gcdPointVerts.Count;
         newPoint.Position = p;
         var line = gcdLines[index - 1];
         newPoint.Line = line;
         newPoint.t = t;
         gcdPointVerts.Add(newPoint);
         while ((t + cctRes / d) < 1)
         {
             t += (cctRes / d);
             p.x = v0.x + m.x * t;
             p.y = v0.y + m.y * t;
             p.z = v0.z + m.z * t;
             var _newPoint = new CCATpoint();
             _newPoint.Id = gcdPointVerts.Count;
             _newPoint.Position = p;
             line = gcdLines[index - 1];
             _newPoint.Line = line;
             _newPoint.t = t;
             gcdPointVerts.Add(_newPoint);
             gcdPathDistance += cctRes;
         }
         partialDistance = (1 - t) * d;
         gcdPathDistance += partialDistance;
     }
 }