Skip to content

Commit

Permalink
Added mesh extrude
Browse files Browse the repository at this point in the history
  • Loading branch information
joelhi committed Feb 20, 2021
1 parent ecd278c commit f50056a
Show file tree
Hide file tree
Showing 58 changed files with 448,177 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/Components/1_Make_Modify/MeshBoundaryEdgeLoops.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected override System.Drawing.Bitmap Icon
{
// You can add image files to your project resources and access them like this:
//return Resources.IconForThisComponent;
return Resource1.g3_gh_icons_42_copy;
return Resource1.g3_gh_icons_41_copy;
}
}
public override Guid ComponentGuid
Expand Down
5 changes: 4 additions & 1 deletion src/Components/2_Evaluate/VertexNormals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ protected override void SolveInstance(IGH_DataAccess DA)
List<Rhino.Geometry.Vector3d> vecs = new List<Rhino.Geometry.Vector3d>();

if (!mesh.HasVertexNormals)
MeshNormals.QuickCompute(mesh);
{
var normals = new MeshNormals(mesh);
normals.Compute();
}

foreach (var ind in mesh.VertexIndices())
{
Expand Down
2 changes: 1 addition & 1 deletion src/Components/7_Process/CompactMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected override System.Drawing.Bitmap Icon
{
get
{
return null;
return Resource1.g3_gh_icons_44_copy;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Components/7_Process/HoleFiller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected override System.Drawing.Bitmap Icon
{
// You can add image files to your project resources and access them like this:
//return Resources.IconForThisComponent;
return Resource1.g3_gh_icons_41_copy;
return Resource1.g3_gh_icons_40_copy;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Components/7_Process/IterativeHoleFiller.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ protected override void SolveInstance(IGH_DataAccess DA)

protected override System.Drawing.Bitmap Icon
{
get{ return Resource1.g3_gh_icons_43_copy; }
get{ return Resource1.g3_gh_icons_42_copy; }
}

public override Guid ComponentGuid
Expand Down
17 changes: 17 additions & 0 deletions src/Components/8_Volumetric/ExtrudeMesh.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public ExtrudeMesh()
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddParameter(new DMesh3_Param(), "Mesh", "dm3", "Mesh to extude", GH_ParamAccess.item);
pManager.AddNumberParameter("Distance", "d", "Distance to extrude", GH_ParamAccess.item, 1);
}

protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
Expand All @@ -35,7 +36,23 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager

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

DA.GetData(0, ref goo);
DA.GetData(1, ref dist);

DMesh3 mesh = new DMesh3(goo.Value);

MeshExtrudeMesh extruder = new MeshExtrudeMesh(mesh);
extruder.ExtrudedPositionF = (pos, normal, idx) => {return pos + normal.Multiply(dist);};

if (dist < 0)
extruder.IsPositiveOffset = false;

extruder.Extrude();

DA.SetData(0, extruder.Mesh);
}

protected override System.Drawing.Bitmap Icon
Expand Down
11 changes: 7 additions & 4 deletions src/Components/9_FileIO/DMesh3ToFile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ private void Menu_PanelTypeChanged(object sender, EventArgs e)
protected override void RegisterInputParams(GH_Component.GH_InputParamManager pManager)
{
pManager.AddParameter(new DMesh3_Param(), "Mesh", "dm3", "Mesh to write as a file", GH_ParamAccess.item);
pManager.AddTextParameter("File Path", "path", "File path without extension.", GH_ParamAccess.item);
pManager.AddTextParameter("Folder Path", "path", "Path to folder where file should be saved.", GH_ParamAccess.item);
pManager.AddTextParameter("File Name", "name", "File name without extension", GH_ParamAccess.item);
}

protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager pManager)
Expand All @@ -55,19 +56,21 @@ protected override void RegisterOutputParams(GH_Component.GH_OutputParamManager

protected override void SolveInstance(IGH_DataAccess DA)
{
this.Message = type.ToString();
this.Message = "." + type.ToString();

DMesh3_goo goo = null;
string path = "";
string file = "";

DA.GetData(0, ref goo);
DA.GetData(1, ref path);
DA.GetData(2, ref file);
DMesh3 mesh = new DMesh3(goo.Value);


IOWriteResult result = StandardMeshWriter.WriteFile(path + "." + type.ToString(), new List<WriteMesh>() { new WriteMesh(mesh) }, WriteOptions.Defaults);
IOWriteResult result = StandardMeshWriter.WriteFile(Path.Combine(path, file) + "." + type.ToString(), new List<WriteMesh>() { new WriteMesh(mesh) }, WriteOptions.Defaults);

DA.SetData(0, path + "." + type.ToString());
DA.SetData(0, Path.Combine(path,file) + "." + type.ToString());
}


Expand Down
9 changes: 9 additions & 0 deletions src/Core/gh3sharpUtil.cs → src/Core/g3ghUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ public static BoundedImplicitFunction3d MeshToImplicit(DMesh3 meshIn, int numcel
levelSet.Compute();
return new DenseGridTrilinearImplicit(levelSet.Grid, levelSet.GridOrigin, levelSet.CellSize);
}

public static Vector3f Multiply(this Vector3f vec,double val)
{
vec.x *= (float)val;
vec.y *= (float)val;
vec.z *= (float)val;

return vec;
}
}


Expand Down
7 changes: 7 additions & 0 deletions src/Resource1.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/Resource1.resx
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,9 @@
</data>
<data name="g3_gh_icons_39_copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\g3_gh_icons-39 copy.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="g3_gh_icons_40_copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\g3_gh_icons-40 copy.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="g3_gh_icons_41_copy" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>Resources\g3_gh_icons-41 copy.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
Expand Down
Binary file modified src/Resources/g3_gh_icons-01 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-02 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-03 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-04 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-05 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-06 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-07 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-08 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-09 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-10 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-11 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-12 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-13 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-14 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-15 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-16 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-17 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-18 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-19 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-20 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-21 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-22 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-23 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-24 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-25 copy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/Resources/g3_gh_icons-26 copy.png
Binary file modified src/Resources/g3_gh_icons-27 copy.png
Binary file modified src/Resources/g3_gh_icons-28 copy.png
Binary file modified src/Resources/g3_gh_icons-29 copy.png
Binary file modified src/Resources/g3_gh_icons-30 copy.png
Binary file modified src/Resources/g3_gh_icons-31 copy.png
Binary file modified src/Resources/g3_gh_icons-32 copy.png
Binary file modified src/Resources/g3_gh_icons-33 copy.png
Binary file modified src/Resources/g3_gh_icons-34 copy.png
Binary file modified src/Resources/g3_gh_icons-35 copy.png
Binary file modified src/Resources/g3_gh_icons-36 copy.png
Binary file modified src/Resources/g3_gh_icons-37 copy.png
Binary file modified src/Resources/g3_gh_icons-38 copy.png
Binary file modified src/Resources/g3_gh_icons-39 copy.png
Binary file added src/Resources/g3_gh_icons-40 copy.png
Binary file modified src/Resources/g3_gh_icons-41 copy.png
Binary file modified src/Resources/g3_gh_icons-42 copy.png
Binary file modified src/Resources/g3_gh_icons-43 copy.png
Binary file modified src/Resources/g3_gh_icons-44 copy.png
10 changes: 10 additions & 0 deletions src/g3-gh.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,16 @@
<None Remove="Resources\g3_gh_icons-33 copy.png" />
<None Remove="Resources\g3_gh_icons-32 copy.png" />
<None Remove="Resources\g3_gh_icons-06 copy.png" />
<None Remove="Resources\g3_gh_icons-35 copy.png" />
<None Remove="Resources\g3_gh_icons-10 copy.png" />
<None Remove="Resources\g3_gh_icons-20 copy.png" />
<None Remove="Resources\g3_gh_icons-03 copy.png" />
<None Remove="Resources\g3_gh_icons-37 copy.png" />
<None Remove="Resources\g3_gh_icons-36 copy.png" />
<None Remove="Resources\g3_gh_icons-04 copy.png" />
<None Remove="Resources\g3_gh_icons-05 copy.png" />
<None Remove="Resources\g3_gh_icons-30 copy.png" />
<None Remove="Resources\g3_gh_icons-19 copy.png" />
</ItemGroup>
<ItemGroup>
<Compile Update="Resource1.Designer.cs">
Expand Down
6 changes: 3 additions & 3 deletions src/gh-3sharpInfo.cs → src/g3ghInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
using Grasshopper;
using Grasshopper.Kernel;

namespace gh_3sharp
namespace g3gh
{
public class gh_3sharpInfo : GH_AssemblyInfo
{
public override string Name => "gh_3sharp Info";
public override string Name => "g3gh Info";

//Return a 24x24 pixel bitmap to represent this GHA library.
public override Bitmap Icon => null;
public override Bitmap Icon => Resource1.g3_gh_icons_06_copy;

//Return a short string describing the purpose of this GHA library.
public override string Description => "Grasshopper library to expose some functionality from the geometry3sharp library";
Expand Down
Loading

0 comments on commit f50056a

Please sign in to comment.