Skip to content

Commit

Permalink
Final Touches
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhi committed Mar 6, 2021
1 parent 3ae5a61 commit 2d01e58
Show file tree
Hide file tree
Showing 9 changed files with 696,977 additions and 21 deletions.
Binary file modified .DS_Store
Binary file not shown.
Binary file removed allComponents.gh
Binary file not shown.
Binary file added examples/example_file.gh
Binary file not shown.
105,398 changes: 105,398 additions & 0 deletions examples/stanfordbunny.obj

Large diffs are not rendered by default.

105,400 changes: 105,400 additions & 0 deletions examples/stanfordbunny.off

Large diffs are not rendered by default.

486,159 changes: 486,159 additions & 0 deletions examples/stanfordbunny.stl

Large diffs are not rendered by default.

30 changes: 9 additions & 21 deletions src/Components/1_Make_Modify/SetMeshColours.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,42 +17,25 @@ namespace g3gh.Components.MakeModify
{
public class SetMeshColours : GH_Component
{
/// <summary>
/// Each implementation of GH_Component must provide a public
/// constructor without any arguments.
/// Category represents the Tab in which the component will appear,
/// Subcategory the panel. If you use non-existing tab or panel names,
/// new tabs/panels will automatically be created.
/// </summary>

public SetMeshColours()
: base("Set Mesh Vertex Colours", "setCols",
"Set the vertex colours of a mesh.",
g3ghUtil.pluginName, "1_Make_Modify")
{
}

/// <summary>
/// Registers all the input parameters for this component.
/// </summary>
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddParameter(new DMesh3_Param(), "Mesh", "dm3", "Mesh to assign vertex colours to", GH_ParamAccess.item);
pManager.AddColourParameter("Colours", "cols", "List of vertex colours for mesh", GH_ParamAccess.list);
}

/// <summary>
/// Registers all the output parameters for this component.
/// </summary>
protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
{
pManager.AddParameter(new DMesh3_Param(), "Mesh", "dm3", "Mesh with vertex colours", GH_ParamAccess.item);
}

/// <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)
{

Expand All @@ -65,16 +48,21 @@ protected override void SolveInstance(IGH_DataAccess DA)
DMesh3 msh = new DMesh3(goo.Value);

msh.EnableVertexColors(new g3.Vector3f(0.5, 0.5, 0.5));

var indices = msh.VertexIndices();

if (cols.Count == msh.VertexCount)
{
for (int i = 0; i < cols.Count; i++)
int counter = 0;
foreach (int i in indices)
{
msh.SetVertexColor(i, new g3.Vector3f((float)cols[i].R / 255, (float)cols[i].G / 255, (float)cols[i].B / 255));
msh.SetVertexColor(i, new g3.Vector3f((float)cols[counter].R / 255, (float)cols[counter].G / 255, (float)cols[counter].B / 255));
counter++;
}
}
else if (cols.Count == 1)
{
for (int i = 0; i < cols.Count; i++)
foreach (int i in indices)
{
msh.SetVertexColor(i, new g3.Vector3f((float)cols[0].R / 255, (float)cols[0].G / 255, (float)cols[0].B / 255));
}
Expand Down
11 changes: 11 additions & 0 deletions src/Components/2_Evaluate/Measurements.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager

protected override void SolveInstance(IGH_DataAccess DA)
{
DMesh3_goo goo = null;

DA.GetData(0, ref goo);

DMesh3 msh = new DMesh3(goo.Value);

var volArea = MeshMeasurements.VolumeArea(msh, msh.TriangleIndices(), msh.GetVertex);

DA.SetData(0, volArea[1]);
DA.SetData(1, volArea[0]);

}

public override GH_Exposure Exposure
Expand Down
File renamed without changes.

0 comments on commit 2d01e58

Please sign in to comment.