55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
|
|
using System;
|
|||
|
|
using CaeMesh;
|
|||
|
|
using CsvHelper;
|
|||
|
|
using CsvHelper.Configuration;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using System.IO;
|
|||
|
|
|
|||
|
|
namespace RBFMorphing
|
|||
|
|
{
|
|||
|
|
[Serializable]
|
|||
|
|
public class ImportedNodes : AbstractClass
|
|||
|
|
{
|
|||
|
|
private readonly List<FeNode> _nodes;
|
|||
|
|
|
|||
|
|
public ImportedNodes() : base(EnumMorphMethod.ImportFile)
|
|||
|
|
{
|
|||
|
|
_nodes = new List<FeNode>();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override List<FeNode> GetNodes()
|
|||
|
|
{
|
|||
|
|
return _nodes;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override int[] Labels => null;
|
|||
|
|
|
|||
|
|
public override int Length => _nodes.Count;
|
|||
|
|
|
|||
|
|
private sealed class NodeMap: ClassMap<FeNode>
|
|||
|
|
{
|
|||
|
|
public NodeMap()
|
|||
|
|
{
|
|||
|
|
Map(n => n.Id).Name("id", "ID", "Id", "iD");
|
|||
|
|
Map(n => n.X).Name("x", "X");
|
|||
|
|
Map(n => n.Y).Name("y", "Y");
|
|||
|
|
Map(n => n.Z).Name("z", "Z");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public void LoadCsvFile(string fullPath)
|
|||
|
|
{
|
|||
|
|
using (var reader = new StreamReader(fullPath))
|
|||
|
|
using (var csv = new CsvReader(reader, CultureInfo.InvariantCulture))
|
|||
|
|
{
|
|||
|
|
csv.Context.RegisterClassMap<NodeMap>();
|
|||
|
|
|
|||
|
|
foreach (var record in csv.GetRecords<FeNode>())
|
|||
|
|
{
|
|||
|
|
_nodes.Add(record);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|