60 lines
1.6 KiB
C#
60 lines
1.6 KiB
C#
|
|
using CaeMesh;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
|
|||
|
|
namespace RBFMorphing
|
|||
|
|
{
|
|||
|
|
[Serializable]
|
|||
|
|
public class Surface: AbstractClass
|
|||
|
|
{
|
|||
|
|
[NonSerialized]
|
|||
|
|
private readonly FeMesh _mesh;
|
|||
|
|
|
|||
|
|
[NonSerialized]
|
|||
|
|
private readonly List<int> _cache;
|
|||
|
|
|
|||
|
|
public Surface(FeMesh mesh, FeSurface surface) : base(EnumMorphMethod.Surface)
|
|||
|
|
{
|
|||
|
|
if (mesh == null || surface == null) throw new ArgumentNullException(nameof(Surface));
|
|||
|
|
|
|||
|
|
if (!mesh.Surfaces.ContainsKey(surface.Name)) throw new ArgumentNullException(nameof(Surface));
|
|||
|
|
|
|||
|
|
_mesh = mesh;
|
|||
|
|
_cache = new List<int>();
|
|||
|
|
if (mesh.Surfaces.ContainsKey(surface.Name))
|
|||
|
|
{
|
|||
|
|
Name = surface.Name;
|
|||
|
|
MakeCache();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
internal void MakeCache()
|
|||
|
|
{
|
|||
|
|
_cache.Clear();
|
|||
|
|
if (_mesh.Surfaces.TryGetValue(_name, out var surface)
|
|||
|
|
&& _mesh.NodeSets.TryGetValue(surface.NodeSetName, out var nodeSet))
|
|||
|
|
{
|
|||
|
|
_cache.AddRange(nodeSet.Labels);
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override List<FeNode> GetNodes()
|
|||
|
|
{
|
|||
|
|
List<FeNode> nodes = new List<FeNode>();
|
|||
|
|
|
|||
|
|
foreach (var id in _cache.Where(x => _mesh.Nodes.ContainsKey(x)))
|
|||
|
|
{
|
|||
|
|
_mesh.Nodes.TryGetValue(id, out var node);
|
|||
|
|
nodes.Add(node);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return nodes;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public override int[] Labels => _cache?.ToArray();
|
|||
|
|
|
|||
|
|
public override int Length => _cache.Count;
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|