/// <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(IGH_DataAccess DA) { GH_HeMesh3d hemGoo = null; if (!DA.GetData(0, ref hemGoo)) { return; } int start = -1; if (!DA.GetData(1, ref start)) { return; } List <double> factors = new List <double>(); DA.GetDataList(2, factors); var mesh = hemGoo.Value.Duplicate(); var f = mesh.Faces[start]; // unroll var last = factors.Count - 1; HeMeshUnroller.Unroll(mesh, mesh.Faces[start], he => factors[Math.Min(he >> 1, last)]); // set normals var fn = f.GetNormal(v => v.Position); mesh.Vertices.Action(v => v.Normal = fn); DA.SetData(0, new GH_HeMesh3d(mesh)); }
/// <summary> /// /// </summary> /// <param name="DA"></param> private void InitializeSolver(IGH_DataAccess DA, DynamicRemesher.Settings settings) { GH_HeMesh3d source = null; if (!DA.GetData(0, ref source)) { return; } IGH_Goo targetGoo = null; if (!DA.GetData(1, ref targetGoo)) { return; } var featsGoo = new List <GH_ObjectWrapper>(); DA.GetDataList(2, featsGoo); var target = CreateSurfaceFeature(targetGoo); var features = featsGoo.Select(obj => (IFeature)obj.Value).Concat(CreateBoundaryFeatures(source)); _solver = DynamicRemesher.Solver.Create(source.Value, target, features, settings); }
/// <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(IGH_DataAccess DA) { GH_HeMesh3d hemGoo = null; int start = -1; if (!DA.GetData(0, ref hemGoo)) { return; } if (!DA.GetData(1, ref start)) { return; } var mesh = hemGoo.Value.Duplicate(); var f = mesh.Faces[start]; // unroll HeMeshUnroller.Unroll(mesh, mesh.Faces[start]); // set normals var fn = f.GetNormal(v => v.Position); mesh.Vertices.Action(v => v.Normal = fn); DA.SetData(0, new GH_HeMesh3d(mesh)); }
/// <inheritdoc /> protected override void SolveInstance(IGH_DataAccess DA) { GH_HeMesh3d hemGoo = null; if (!DA.GetData(0, ref hemGoo)) { return; } DA.SetData(0, new GH_HeMesh3d(hemGoo.Value.GetDual())); }
/// <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) { GH_HeMesh3d mesh = null; if (!DA.GetData(0, ref mesh)) { return; } var result = mesh.Value.Faces.Select(f => f.IsRemoved ? 0.0 : f.GetPlanarity(v => v.Position)); DA.SetDataList(0, result); }
/// <inheritdoc /> protected override void SolveInstance(IGH_DataAccess DA) { GH_HeMesh3d mesh = null; if (!DA.GetData(0, ref mesh)) { return; } var result = mesh.Value.GetHoles().Select(he0 => { var poly = new Polyline(he0.Circulate.Select(he => (Point3d)he.Start.Position)); poly.Add(poly[0]); return(new GH_Curve(poly.ToNurbsCurve())); }); DA.SetDataList(0, result); }
/// <inheritdoc /> protected override void SolveInstance(IGH_DataAccess DA) { GH_HeMesh3d hemGoo = null; if (!DA.GetData(0, ref hemGoo)) { return; } int start = -1; if (!DA.GetData(1, ref start)) { return; } List <double> factors = new List <double>(); DA.GetDataList(2, factors); var mesh = new HeMesh3d(hemGoo.Value); var f = mesh.Faces[start]; // ensures mesh is unrollable HeMeshUnroller.DetachFaceCycles(mesh, f); // perform unroll var unrolled = new Vec3d[mesh.Vertices.Count]; var last = factors.Count - 1; HeMeshUnroller.Unroll(mesh, f, (v, p) => unrolled[v] = p, he => factors[Math.Min(he >> 1, last)]); // set vertex attributes var fn = f.GetNormal(v => v.Position); mesh.Vertices.Action(v => { v.Position = unrolled[v]; v.Normal = fn; }); DA.SetData(0, new GH_HeMesh3d(mesh)); }
/// <inheritdoc /> protected override void SolveInstance(IGH_DataAccess DA) { GH_HeMesh3d mesh = null; if (!DA.GetData(0, ref mesh)) { return; } var result = mesh.Value.Faces.Select(f => { if (f.IsUnused) { return(new GH_Curve()); } var poly = new Polyline(f.Halfedges.Select(he => (Point3d)he.Start.Position)); poly.Add(poly[0]); return(new GH_Curve(poly.ToNurbsCurve())); }); DA.SetDataList(0, result); }
/// <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) { int state = 0; if (!DA.GetData(6, ref state)) { return; } // reset if (state == 0) { _solver = null; return; } // initialize if (_solver == null) { GH_HeMesh3d source = null; if (!DA.GetData(0, ref source)) { return; } GH_Mesh target = null; if (!DA.GetData(1, ref target)) { return; } var feats = new List <GH_ObjectWrapper>(); DA.GetDataList(2, feats); _solver = DynamicRemesher.Solver.Create( source.Value.Duplicate(), new MeshFeature(target.Value), feats.Select(f => (IFeature)f.Value) ); } // update dynamic parameters GH_ObjectWrapper goo = null; // update fields if (DA.GetData(3, ref goo)) { _solver.LengthField = (IField3d <double>)goo.Value; } else { _solver.LengthField = null; } // update settings if (!DA.GetData(4, ref goo)) { return; } _solver.Settings = (DynamicRemesher.Settings)goo.Value; int subSteps = 0; DA.GetData(5, ref subSteps); // step for (int i = 0; i < subSteps; i++) { _solver.Step(); } _print.AppendLine($"{_solver.StepCount} steps"); // output DA.SetData(0, new GH_String(_print.ToString())); DA.SetData(1, new GH_HeMesh3d(HeMesh3d.Factory.CreateCopy(_solver.Mesh, _setV, delegate { }, delegate { }))); // recall if (state == 1) { ExpireSolution(true); } _print.Clear(); }