-
Notifications
You must be signed in to change notification settings - Fork 8
/
SphereConduit.cs
77 lines (70 loc) · 2.77 KB
/
SphereConduit.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//'Pachyderm-Acoustic: Geometrical Acoustics for Rhinoceros (GPL) by Arthur van der Harten
//'
//'This file is part of Pachyderm-Acoustic.
//'
//'Copyright (c) 2008-2019, Arthur van der Harten
//'Pachyderm-Acoustic is free software; you can redistribute it and/or modify
//'it under the terms of the GNU General Public License as published
//'by the Free Software Foundation; either version 3 of the License, or
//'(at your option) any later version.
//'Pachyderm-Acoustic is distributed in the hope that it will be useful,
//'but WITHOUT ANY WARRANTY; without even the implied warranty of
//'MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
//'GNU General Public License for more details.
//'
//'You should have received a copy of the GNU General Public
//'License along with Pachyderm-Acoustic; if not, write to the Free Software
//'Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
using Rhino.Geometry;
using Rhino.Display;
using System.Collections.Generic;
using Pachyderm_Acoustic.Numeric.TimeDomain;
namespace Pachyderm_Acoustic
{
namespace UI
{
/// <summary>
/// A conduit used to display spatial data.
/// </summary>
public class SphereConduit : DisplayConduit
{
Rhino.Geometry.Mesh Sphere;
public Pach_Graphics.colorscale C;
public Sphere_Plot plot;
Hare.Geometry.Point center;
public SphereConduit(Sphere_Plot plot_in, Hare.Geometry.Point center_in, Pach_Graphics.colorscale C_in, double[] V_Bounds_in)
{
plot = plot_in;
center = center_in;
C = C_in;
Instance = this;
}
public static SphereConduit Instance
{
get;
private set;
}
protected override void PostDrawObjects(DrawEventArgs e)
{
e.Display.DrawMeshFalseColors(Sphere);
}
/// <summary>
/// Allows user to change the colors of the particles.
/// </summary>
/// <param name="Colors"></param>
/// <param name="Values"></param>
public void SetColorScale(Pach_Graphics.colorscale C_in)
{
C = C_in;
}
public void Data_in(double[] magnitude, double[] bounds, double display_diameter)
{
Mesh m = Utilities.RC_PachTools.Hare_to_RhinoMesh(plot.Output(magnitude, bounds[0], bounds[1], display_diameter), true);
for (int i = 0; i < magnitude.Length; i++) m.VertexColors.Add(C.GetValue(magnitude[i], bounds[0], bounds[1]));
m.UnifyNormals();
Sphere = m;
this.Enabled = true;
}
}
}
}