protected override void SolveInstance(IGH_DataAccess DA) { //get all the inputs double radius = 0.1; double startHeight = radius; Mesh inputMesh = new Mesh(); Polyline intersectionLine; List <PolylineCurve> sphInters; List <PolylineCurve> allInter = new List <PolylineCurve>(); int reps = 1; List <Mesh> qPanels = new List <Mesh>(); List <double> curvatures = new List <double>(); if (!DA.GetData(0, ref radius)) { radius = 0.2; } if (!DA.GetData(1, ref startHeight)) { startHeight = 0.2; } if (!DA.GetData(2, ref inputMesh)) { return; } if (!DA.GetData(3, ref reps)) { return; } //make a sphere packing class SpherePacking sphPacking = new SpherePacking(radius, inputMesh, startHeight, reps); intersectionLine = sphPacking.path; sphInters = sphPacking.sphIntersCurrent; var inter2 = sphPacking.intersectionsList; var pts = sphPacking.centers; //make the list of lists a single list for (int i = 0; i < inter2.Count; i++) { for (int j = 0; j < inter2[i].Count; j++) { allInter.Add(inter2[i][j]); } } for (int i = 0; i < sphPacking.groupsOfFour.Count; i++) { quadPanel qP = new quadPanel(sphPacking.groupsOfFour[i]); qPanels.Add(qP.mesh); curvatures.Add(qP.weights[0]); } DA.SetData(0, intersectionLine); DA.SetDataList(1, sphInters); DA.SetDataList(2, allInter); DA.SetDataList(3, qPanels); }
public Vector3d weightVector; //mean vector of cluster public KCluster(quadPanel centroid) { this.centroid = centroid; assignedInputs = new List <quadPanel>(); assignedMeshes = new List <Mesh>(); centroidWeights = centroid.weights; weightVector = new Vector3d(centroid.weights[0], centroid.weights[1], centroid.weights[2]); }
public double Distance(KCluster cluster, quadPanel input) { //euclidean distance between centroid weights and input weights double d = Math.Pow(cluster.weightVector.X - input.weights[0], 2) + Math.Pow(cluster.weightVector.Y - input.weights[1], 2) + Math.Pow(cluster.weightVector.Z - input.weights[2], 2); return(Math.Sqrt(d)); }
public double[] clusterWeights; //array of 3 weights public HCluster(quadPanel qP) { initQuad = qP; assignedInputs = new List <quadPanel>() { initQuad }; assignedMeshes = new List <Mesh>() { initQuad.mesh }; clusterWeights = initQuad.weights; meanVector = new Vector3d(0, 0, 0); }
public void Reset() { played = -100; counter = 0; qPans = new quadPanel[meshPanels.Count]; curv = new List <double>(); for (int i = 0; i < meshPanels.Count; i++) { quadPanel qPan = new quadPanel(meshPanels[i]); qPans[i] = qPan; curv.Add(qPan.weights[0]); } clusterGroup = new HClusterGroup(qPans); }
public void Start() { played = -100; qPans = new quadPanel[meshPanels.Count]; curv.Clear(); for (int i = 0; i < meshPanels.Count; i++) { quadPanel qPan = new quadPanel(meshPanels[i]); qPans[i] = qPan; curv.Add(qPan.weights[0]); } clusterGroup = new HClusterGroup(qPans); timer.Start(); }