/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object can be used to retrieve data from input parameters and /// to store data in output parameters.</param> protected override void SolveInstance(IGH_DataAccess DA) { MeshGhData hE_MeshData = new MeshGhData(); if (!DA.GetData(0, ref hE_MeshData)) { return; } Paramdigma.Core.HalfEdgeMesh.Mesh hE_Mesh = hE_MeshData.Value; if (!hE_Mesh.IsTriangularMesh()) { AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Mesh is not triangular!"); return; } List <Vector3d> normals = new List <Vector3d>(); foreach (MeshVertex v in hE_Mesh.Vertices) { Paramdigma.Core.Geometry.Vector3d vect = new Paramdigma.Core.Geometry.Vector3d(); switch (Selection) { case NormalSelection.Equal: vect = Paramdigma.Core.Geometry.MeshGeometry.VertexNormalEquallyWeighted(v); break; case NormalSelection.Area: vect = Paramdigma.Core.Geometry.MeshGeometry.VertexNormalAreaWeighted(v); break; case NormalSelection.Angle: vect = Paramdigma.Core.Geometry.MeshGeometry.VertexNormalAngleWeighted(v); break; case NormalSelection.Gauss: vect = Paramdigma.Core.Geometry.MeshGeometry.VertexNormalGaussCurvature(v); break; case NormalSelection.Mean: vect = Paramdigma.Core.Geometry.MeshGeometry.VertexNormalMeanCurvature(v); break; case NormalSelection.Sphere: vect = Paramdigma.Core.Geometry.MeshGeometry.VertexNormalSphereInscribed(v); break; } normals.Add(new Vector3d(vect.X, vect.Y, vect.Z)); } DA.SetDataList(0, normals); }
/// <summary> /// This is the method that actually does the work. /// </summary> /// <param name="DA">The DA object is used to retrieve from inputs and store in outputs.</param> protected override void SolveInstance(GH.Kernel.IGH_DataAccess DA) { MeshGhData hE_MeshData = new MeshGhData(); if (!DA.GetData(0, ref hE_MeshData)) { return; } Paramdigma.Core.HalfEdgeMesh.Mesh hE_Mesh = hE_MeshData.Value; Paramdigma.Core.HalfEdgeMesh.MeshTopology topo = new Paramdigma.Core.HalfEdgeMesh.MeshTopology(hE_Mesh); topo.ComputeFaceAdjacency(); GH.DataTree <int> fvTopo = new GH.DataTree <int>(); GH.DataTree <int> feTopo = new GH.DataTree <int>(); GH.DataTree <int> ffTopo = new GH.DataTree <int>(); foreach (int key in topo.FaceVertex.Keys) { fvTopo.AddRange(topo.FaceVertex[key], new GH.Kernel.Data.GH_Path(key)); } foreach (int key in topo.FaceVertex.Keys) { feTopo.AddRange(topo.FaceVertex[key], new GH.Kernel.Data.GH_Path(key)); } foreach (int key in topo.FaceFace.Keys) { ffTopo.AddRange(topo.FaceFace[key], new GH.Kernel.Data.GH_Path(key)); } DA.SetDataTree(0, fvTopo); DA.SetDataTree(1, feTopo); DA.SetDataTree(2, ffTopo); }