├── output
└── .keep
├── voxeltools.png
├── docs
├── 01-bunny-mesh.png
├── 02-open-mesh.png
├── 01-bunny-voxels.png
├── 03. Brep
│ ├── output.gif
│ ├── palette.png
│ ├── Frame_00000.png
│ ├── Frame_00001.png
│ ├── Frame_00002.png
│ ├── Frame_00003.png
│ ├── Frame_00004.png
│ ├── Frame_00005.png
│ ├── Frame_00006.png
│ ├── Frame_00007.png
│ ├── Frame_00008.png
│ ├── Frame_00009.png
│ ├── Frame_00010.png
│ ├── Frame_00011.png
│ ├── Frame_00012.png
│ ├── Frame_00013.png
│ ├── Frame_00014.png
│ ├── Frame_00015.png
│ ├── Frame_00016.png
│ ├── Frame_00017.png
│ ├── Frame_00018.png
│ ├── Frame_00019.png
│ └── Frame_00020.png
├── 01-voxelate-bunny.gh
├── 03-voxelate-tower.gh
├── 05-voxelate-curve.gh
├── 06-voxelate-points.gh
├── 01-bunny-description.png
├── 03-voxelate-cylinder.gh
├── 04-voxelate-cylinder.gh
├── 02-open-mesh-voxelized.png
├── 02-voxelate-open-meshes.gh
├── 05. Spiral
│ ├── Frame_00000.png
│ ├── Frame_00001.png
│ ├── Frame_00002.png
│ ├── Frame_00003.png
│ ├── Frame_00004.png
│ ├── Frame_00005.png
│ ├── Frame_00006.png
│ ├── Frame_00007.png
│ ├── Frame_00008.png
│ ├── Frame_00009.png
│ ├── Frame_00010.png
│ ├── Frame_00011.png
│ ├── Frame_00012.png
│ ├── Frame_00013.png
│ ├── Frame_00014.png
│ ├── Frame_00015.png
│ ├── Frame_00016.png
│ ├── Frame_00017.png
│ ├── Frame_00018.png
│ ├── Frame_00019.png
│ └── Frame_00020.png
└── 06. Points
│ ├── Frame_00000.png
│ ├── Frame_00001.png
│ ├── Frame_00002.png
│ ├── Frame_00003.png
│ ├── Frame_00004.png
│ ├── Frame_00005.png
│ ├── Frame_00006.png
│ ├── Frame_00007.png
│ ├── Frame_00008.png
│ ├── Frame_00009.png
│ ├── Frame_00010.png
│ ├── Frame_00011.png
│ ├── Frame_00012.png
│ ├── Frame_00013.png
│ ├── Frame_00014.png
│ ├── Frame_00015.png
│ ├── Frame_00016.png
│ ├── Frame_00017.png
│ ├── Frame_00018.png
│ ├── Frame_00019.png
│ └── Frame_00020.png
├── VoxelTools
├── Icons
│ ├── VT_Boxes.png
│ ├── VT_GridXOR.png
│ ├── VT_CreateGrid.png
│ ├── VT_Decompose.png
│ ├── VT_GridToHex.png
│ ├── VT_GridToList.png
│ ├── VT_GridUnion.png
│ ├── VT_PointCloud.png
│ ├── VT_Statistics.png
│ ├── Source
│ │ ├── VoxelTools.ai
│ │ ├── ScalarTools.ai
│ │ └── VoxelTools.afdesign
│ ├── VT_GridFromHex.png
│ ├── VT_GridIntersect.png
│ ├── VT_GridInverse.png
│ ├── VT_VoxelateBrep.png
│ ├── ScalarTools
│ │ ├── ST-11.png
│ │ ├── ST_XOR.png
│ │ ├── ST_Invert.png
│ │ ├── ST_Join.png
│ │ ├── ST_ToList.png
│ │ ├── ST_Compare.png
│ │ ├── ST_Subtract.png
│ │ ├── ST_CreateGrid.png
│ │ ├── ST_Decompose.png
│ │ ├── ST_Intersect.png
│ │ ├── ST_PointCloud.png
│ │ ├── ST_Statistics.png
│ │ └── ST_VoxelateBrep.png
│ ├── VT_GridDifference.png
│ └── VT_ConstructFromList.png
├── Properties
│ ├── Settings.settings
│ ├── Settings.Designer.cs
│ └── AssemblyInfo.cs
├── Helper
│ ├── DocumentHelper.cs
│ ├── ComponentHelper.cs
│ ├── GeometryHelper.cs
│ ├── PixelGridMeshHelper.cs
│ ├── DataAccessHelper.cs
│ └── RenderHelper.cs
├── Components
│ ├── ScalarGrid
│ │ ├── BaseScalarComponent.cs
│ │ ├── ScalarGridCreateComponent.cs
│ │ └── ScalarGridVisualizeComponent.cs
│ ├── VoxelGrid
│ │ ├── VoxelGridFromHex.cs
│ │ ├── VoxelGridDimensions.cs
│ │ ├── VoxelGridToHex.cs
│ │ ├── VoxelGridInvert.cs
│ │ ├── VoxelGridIntersect.cs
│ │ ├── VoxelGridSubtract.cs
│ │ ├── VoxelGridExclusive.cs
│ │ ├── VoxelGridFromList.cs
│ │ ├── VoxelGridToList.cs
│ │ ├── VoxelGridCreateComponent.cs
│ │ ├── VoxelGridUnion.cs
│ │ ├── VoxelGridMeshHull.cs
│ │ ├── VoxelGridAccessibleRoof.cs
│ │ ├── VoxelGridBoxes.cs
│ │ └── VoxelGridStatistics.cs
│ ├── Upgrades
│ │ ├── UpgradeMeshHull.cs
│ │ └── UpgradeVoxelGridToBoxes.cs
│ ├── PixelGrid
│ │ ├── PixelGridCreateComponent.cs
│ │ ├── PixelGridMesh.cs
│ │ ├── PixelGridToList.cs
│ │ └── PixelGridPixelateComponent.cs
│ └── Obsolete
│ │ ├── VoxelGridBoxesObsolete.cs
│ │ ├── VoxelGridMeshHullObsolete.cs
│ │ └── VoxelGridLimiterObsolete.cs
├── VoxelToolsInfo.cs
├── Param
│ ├── Param_ScalarGrid.cs
│ └── Param_PixelGrid.cs
├── .gitignore
└── Types
│ ├── GH_ScalarGrid.cs
│ ├── GH_PixelGrid.cs
│ └── GH_VoxelGrid.cs
├── manifest.yml
├── VoxelGeometry
├── Interfaces
│ ├── IGrid2D.cs
│ └── IGrid3D.cs
├── .gitignore
├── Properties
│ └── AssemblyInfo.cs
├── VoxelGrid3D.cs
├── VoxelGeometry.csproj
├── ScalarGrid3D.cs
├── PixelGrid2D.cs
├── BitGrid3D.cs
└── Grid2D.cs
├── LICENCE
├── VoxelTools.sln
├── README.md
└── .gitignore
/output/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/voxeltools.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/voxeltools.png
--------------------------------------------------------------------------------
/docs/01-bunny-mesh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/01-bunny-mesh.png
--------------------------------------------------------------------------------
/docs/02-open-mesh.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/02-open-mesh.png
--------------------------------------------------------------------------------
/docs/01-bunny-voxels.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/01-bunny-voxels.png
--------------------------------------------------------------------------------
/docs/03. Brep/output.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/output.gif
--------------------------------------------------------------------------------
/docs/01-voxelate-bunny.gh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/01-voxelate-bunny.gh
--------------------------------------------------------------------------------
/docs/03-voxelate-tower.gh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03-voxelate-tower.gh
--------------------------------------------------------------------------------
/docs/03. Brep/palette.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/palette.png
--------------------------------------------------------------------------------
/docs/05-voxelate-curve.gh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05-voxelate-curve.gh
--------------------------------------------------------------------------------
/docs/06-voxelate-points.gh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06-voxelate-points.gh
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_Boxes.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_Boxes.png
--------------------------------------------------------------------------------
/docs/01-bunny-description.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/01-bunny-description.png
--------------------------------------------------------------------------------
/docs/03-voxelate-cylinder.gh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03-voxelate-cylinder.gh
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00000.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00000.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00001.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00002.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00003.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00004.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00004.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00005.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00005.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00006.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00006.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00007.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00007.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00008.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00008.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00009.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00009.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00010.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00010.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00011.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00011.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00012.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00012.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00013.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00013.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00014.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00014.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00015.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00015.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00016.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00016.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00017.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00017.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00018.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00018.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00019.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00019.png
--------------------------------------------------------------------------------
/docs/03. Brep/Frame_00020.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/03. Brep/Frame_00020.png
--------------------------------------------------------------------------------
/docs/04-voxelate-cylinder.gh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/04-voxelate-cylinder.gh
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_GridXOR.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_GridXOR.png
--------------------------------------------------------------------------------
/docs/02-open-mesh-voxelized.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/02-open-mesh-voxelized.png
--------------------------------------------------------------------------------
/docs/02-voxelate-open-meshes.gh:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/02-voxelate-open-meshes.gh
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00000.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00000.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00001.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00002.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00003.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00004.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00004.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00005.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00005.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00006.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00006.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00007.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00007.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00008.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00008.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00009.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00009.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00010.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00010.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00011.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00011.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00012.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00012.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00013.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00013.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00014.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00014.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00015.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00015.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00016.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00016.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00017.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00017.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00018.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00018.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00019.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00019.png
--------------------------------------------------------------------------------
/docs/05. Spiral/Frame_00020.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/05. Spiral/Frame_00020.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00000.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00000.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00001.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00001.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00002.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00002.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00003.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00003.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00004.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00004.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00005.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00005.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00006.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00006.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00007.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00007.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00008.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00008.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00009.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00009.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00010.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00010.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00011.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00011.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00012.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00012.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00013.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00013.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00014.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00014.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00015.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00015.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00016.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00016.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00017.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00017.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00018.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00018.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00019.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00019.png
--------------------------------------------------------------------------------
/docs/06. Points/Frame_00020.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/docs/06. Points/Frame_00020.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_CreateGrid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_CreateGrid.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_Decompose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_Decompose.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_GridToHex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_GridToHex.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_GridToList.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_GridToList.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_GridUnion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_GridUnion.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_PointCloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_PointCloud.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_Statistics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_Statistics.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/Source/VoxelTools.ai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/Source/VoxelTools.ai
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_GridFromHex.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_GridFromHex.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_GridIntersect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_GridIntersect.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_GridInverse.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_GridInverse.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_VoxelateBrep.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_VoxelateBrep.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST-11.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST-11.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_XOR.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_XOR.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/Source/ScalarTools.ai:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/Source/ScalarTools.ai
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_GridDifference.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_GridDifference.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_Invert.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_Invert.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_Join.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_Join.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_ToList.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_ToList.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/VT_ConstructFromList.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/VT_ConstructFromList.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_Compare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_Compare.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_Subtract.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_Subtract.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/Source/VoxelTools.afdesign:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/Source/VoxelTools.afdesign
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_CreateGrid.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_CreateGrid.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_Decompose.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_Decompose.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_Intersect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_Intersect.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_PointCloud.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_PointCloud.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_Statistics.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_Statistics.png
--------------------------------------------------------------------------------
/VoxelTools/Icons/ScalarTools/ST_VoxelateBrep.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/arendvw/voxeltools/HEAD/VoxelTools/Icons/ScalarTools/ST_VoxelateBrep.png
--------------------------------------------------------------------------------
/manifest.yml:
--------------------------------------------------------------------------------
1 | ---
2 | name: VoxelTools
3 | version: 1.0.3
4 | authors:
5 | - Arend van Waart
6 | description: Allows usage of Voxel Geometry in Grasshopper
7 | url: https://github.com/arendvw/ScriptParasite
8 | secret:
9 | id: 43b6cb74-76cb-4047-96fc-e10aea638d3a
10 |
--------------------------------------------------------------------------------
/VoxelTools/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/VoxelGeometry/Interfaces/IGrid2D.cs:
--------------------------------------------------------------------------------
1 | using Rhino.Geometry;
2 |
3 | namespace StudioAvw.Voxels.Geometry.Interfaces
4 | {
5 |
6 | public interface IGrid2D
7 | {
8 | bool IsValid { get; }
9 | Rectangle3d BBox { get; }
10 | Plane Plane { get; }
11 | Point2i SizeUV { get; set; }
12 | Point2d PixelSize { get; }
13 | Point3d PointAt(Point2d ptUV);
14 | Point3d PointAt(Point2i ptUV);
15 | Point3d PointAt(int iUV);
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/VoxelTools/Helper/DocumentHelper.cs:
--------------------------------------------------------------------------------
1 | using Rhino;
2 |
3 | namespace StudioAvw.Voxels.Helper
4 | {
5 | public static class DocumentHelper
6 | {
7 | ///
8 | /// Safely get model tolerance -- use the active RhinoDoc where present, otherwise return a default.
9 | ///
10 | ///
11 | public static double GetModelTolerance()
12 | {
13 | return RhinoDoc.ActiveDoc?.ModelAbsoluteTolerance ?? 0.01;
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/VoxelGeometry/Interfaces/IGrid3D.cs:
--------------------------------------------------------------------------------
1 | using Rhino.Geometry;
2 |
3 | namespace StudioAvw.Voxels.Geometry.Interfaces
4 | {
5 |
6 | public interface IGrid3D
7 | {
8 | bool IsValid { get; }
9 |
10 | Box BBox { get; }
11 | Plane Plane { get; }
12 | Point3i SizeUVW { get; set; }
13 |
14 | Point3d VoxelSize { get; }
15 | Point3d EvaluatePoint(Point3d ptUVW);
16 | Point3d EvaluatePoint(Point3i ptUvw);
17 | Point3d EvaluatePoint(int voxelIndex);
18 | }
19 | }
20 |
--------------------------------------------------------------------------------
/VoxelGeometry/.gitignore:
--------------------------------------------------------------------------------
1 | /bin/Release/VoxelGeometry.dll
2 | /bin/Release/VoxelGeometry.pdb
3 | /obj/Debug/DesignTimeResolveAssemblyReferencesInput.cache
4 | /obj/Debug/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
5 | /obj/Debug/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
6 | /obj/Debug/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
7 | /obj/Debug/VoxelGeometry.csprojResolveAssemblyReference.cache
8 | /obj/Release/DesignTimeResolveAssemblyReferencesInput.cache
9 | /obj/Release/TemporaryGeneratedFile_036C0B5B-1481-4323-8D20-8F5ADCB23D92.cs
10 | /obj/Release/TemporaryGeneratedFile_5937a670-0e60-4077-877b-f7221da3dda1.cs
11 | /obj/Release/TemporaryGeneratedFile_E7A71F73-0F8D-4B9B-B56E-8E70B10BC5D3.cs
12 | /obj/Release/VoxelGeometry.csproj.FileListAbsolute.txt
13 | /obj/Release/VoxelGeometry.csprojResolveAssemblyReference.cache
14 | /obj/Release/VoxelGeometry.dll
15 | /obj/Release/VoxelGeometry.pdb
16 |
--------------------------------------------------------------------------------
/VoxelTools/Components/ScalarGrid/BaseScalarComponent.cs:
--------------------------------------------------------------------------------
1 | using Grasshopper.Kernel;
2 |
3 | namespace StudioAvw.Voxels.Components.ScalarGrid
4 | {
5 | ///
6 | /// Provides abstract functionality for all Scalar comonents
7 | /// Currently only extends GH_Component
8 | ///
9 | public abstract class BaseScalarComponent : GH_Component
10 | {
11 | // just pass it along
12 | ///
13 | /// Default constructor
14 | ///
15 | ///
16 | ///
17 | ///
18 | ///
19 | ///
20 | public BaseScalarComponent(string name, string nickname, string description, string category, string subCategory) : base(name, nickname, description, category, subCategory)
21 | {
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/LICENCE:
--------------------------------------------------------------------------------
1 | MIT LICENCE
2 | Copyright 2020 Arend van Waart
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 |
6 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 |
8 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--------------------------------------------------------------------------------
/VoxelTools/Helper/ComponentHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Grasshopper.Kernel;
3 |
4 | namespace StudioAvw.Voxels.Helper
5 | {
6 | class ComponentHelper
7 | {
8 | ///
9 | public static T FetchData(int position, IGH_DataAccess DA)
10 | {
11 | var temp = default(T);
12 | DA.GetData(position, ref temp);
13 | return temp;
14 | }
15 |
16 | public static T FetchData(string position, IGH_DataAccess DA)
17 | {
18 | var temp = default(T);
19 | DA.GetData(position, ref temp);
20 | return temp;
21 | }
22 |
23 | public static List FetchDataList(int position, IGH_DataAccess DA)
24 | {
25 | var temp = new List();
26 | DA.GetDataList(position, temp);
27 | return temp;
28 | }
29 |
30 | public static List FetchDataList(string position, IGH_DataAccess DA)
31 | {
32 | var temp = new List ();
33 | DA.GetDataList(position, temp);
34 | return temp;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/VoxelTools/VoxelToolsInfo.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel;
4 |
5 | namespace StudioAvw.Voxels
6 | {
7 |
8 | public class VoxelToolsInfo : GH_AssemblyInfo
9 | {
10 | public override string Name => "VoxelTools";
11 |
12 | public override Bitmap Icon =>
13 | //Return a 24x24 pixel bitmap to represent this GHA library.
14 | Images.VT_PointCloud;
15 |
16 | public override string Description =>
17 | //Return a short string describing the purpose of this GHA library.
18 | "VoxelTools offers lightweight voxel-geometry for grasshopper";
19 |
20 | public override Guid Id => new Guid("43b6cb74-76cb-4047-96fc-e10aea638d3a");
21 |
22 | public override string Version => "1.0.3";
23 |
24 | public override GH_LibraryLicense AssemblyLicense => GH_LibraryLicense.opensource;
25 |
26 | public override string AuthorName =>
27 | //Return a string identifying you or your company.
28 | "Arend van Waart";
29 |
30 | public override string AuthorContact => "https://github.com/arendvw";
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/VoxelTools/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace StudioAvw.Voxels.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/VoxelTools/Helper/GeometryHelper.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using Grasshopper.Kernel.Types;
3 |
4 | namespace StudioAvw.Voxels.Helper
5 | {
6 | class GeometryHelper
7 | {
8 | ///
9 | /// Find geometry in list of geometric goo that can be cast to a certain object.
10 | ///
11 | ///
12 | ///
13 | ///
14 | ///
15 | public static Dictionary TryCastGeometry(Dictionary geometry, bool removeWhenFound)
16 | {
17 | var collected = new Dictionary();
18 | foreach (var igg in geometry)
19 | {
20 | if (igg.Value.CastTo(out T outputObject))
21 | {
22 | collected.Add(igg.Key,outputObject);
23 | if (removeWhenFound)
24 | {
25 | geometry.Remove(igg.Key);
26 | }
27 | }
28 | }
29 | return collected;
30 | }
31 |
32 | public static Dictionary TryCastGeometry(Dictionary geometryIndex)
33 | {
34 | return TryCastGeometry(geometryIndex, false);
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/VoxelGeometry/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("VoxelGeometry")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("VoxelGeometry")]
13 | [assembly: AssemblyCopyright("Copyright © 2014")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("99a46336-f848-4d96-9ee8-656e4a600b00")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.3")]
36 | [assembly: AssemblyFileVersion("1.0.3")]
37 | [assembly: InternalsVisibleTo("VoxelTools")]
--------------------------------------------------------------------------------
/VoxelTools.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 16
4 | VisualStudioVersion = 16.0.30104.148
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoxelGeometry", "VoxelGeometry\VoxelGeometry.csproj", "{58E945DA-0909-4F25-890E-3FABEA67FDC9}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VoxelTools", "VoxelTools\VoxelTools.csproj", "{F4684117-6C67-4703-A26B-7BF9D533832B}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {58E945DA-0909-4F25-890E-3FABEA67FDC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {58E945DA-0909-4F25-890E-3FABEA67FDC9}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {58E945DA-0909-4F25-890E-3FABEA67FDC9}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {58E945DA-0909-4F25-890E-3FABEA67FDC9}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {F4684117-6C67-4703-A26B-7BF9D533832B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {F4684117-6C67-4703-A26B-7BF9D533832B}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {F4684117-6C67-4703-A26B-7BF9D533832B}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {F4684117-6C67-4703-A26B-7BF9D533832B}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {CC5022B5-5BCC-4321-9A85-2F17E30FEAAE}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/VoxelTools/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 | using Rhino.PlugIns;
5 |
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("VoxelTools")]
11 | [assembly: AssemblyDescription("Provides Finite Element VoxelGrids as Plugin for Grasshopper")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("StudioAvw")]
14 | [assembly: AssemblyProduct("VoxelTools")]
15 | [assembly: AssemblyCopyright("Copyright © StudioAvw 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | // The following GUID is for the ID of the typelib if this project is exposed to COM
25 | [assembly: Guid("43b6cb74-76cb-4047-96fc-e10aea638d3a")] // This will also be the Guid of the Rhino plug-in
26 |
27 | // Version information for an assembly consists of the following four values:
28 | //
29 | // Major Version
30 | // Minor Version
31 | // Build Number
32 | // Revision
33 | //
34 | // You can specify all the values or you can default the Build and Revision Numbers
35 | // by using the '*' as shown below:
36 | [assembly: AssemblyVersion("1.0.3")]
37 | [assembly: AssemblyFileVersion("1.0.3")]
38 | [assembly: InternalsVisibleTo("Grasshopper")]
--------------------------------------------------------------------------------
/VoxelTools/Param/Param_ScalarGrid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using StudioAvw.Voxels.Types;
6 |
7 | namespace StudioAvw.Voxels.Param
8 | {
9 | ///
10 | /// Scalargrid Param
11 | ///
12 | public class Param_ScalarGrid : GH_PersistentParam
13 | {
14 | ///
15 | /// Provides a gh_param for a scalar grid
16 | ///
17 | public Param_ScalarGrid()
18 | : base(new GH_InstanceDescription("ScalarGrid", "SG", "Represents a collection of Scalar Grids", "Voxels", "Param"))
19 | {
20 | }
21 |
22 |
23 | ///
24 | /// Unique id
25 | ///
26 | public override Guid ComponentGuid => new Guid("{A09F682D-FF3B-49ED-923C-676B8F961FF7}");
27 |
28 |
29 | ///
30 | /// What to do when right click: set one scalargrid
31 | /// Current: nothing
32 | ///
33 | ///
34 | ///
35 | protected override GH_GetterResult Prompt_Plural(ref List values)
36 | {
37 | return GH_GetterResult.cancel;
38 | }
39 |
40 | ///
41 | /// What to do when right click: set one scalargrid
42 | /// Current: nothing
43 | ///
44 | ///
45 | ///
46 | protected override GH_GetterResult Prompt_Singular(ref GH_ScalarGrid value)
47 | {
48 | return GH_GetterResult.cancel;
49 | }
50 |
51 | ///
52 | /// Icon of a pointcloud
53 | ///
54 | protected override Bitmap Icon => Images.ST_PointCloud;
55 |
56 | ///
57 | /// Show in main bar
58 | ///
59 | public override GH_Exposure Exposure => GH_Exposure.primary;
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridFromHex.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel;
4 | using StudioAvw.Voxels.Geometry;
5 | using StudioAvw.Voxels.Param;
6 | using StudioAvw.Voxels.Helper;
7 |
8 | namespace StudioAvw.Voxels.Components.VoxelGrid
9 | {
10 | ///
11 | /// Create list of hexadecimal numbers
12 | ///
13 | public class VoxelGridFromHex : BaseVoxelComponent
14 | {
15 | ///
16 | /// Initializes a new instance of the VoxelGridIntersect class.
17 | ///
18 | public VoxelGridFromHex()
19 | : base("VoxelGrid From Hex String", "VGFromHex",
20 | "Convert a voxelgrid from a hexadecimal string",
21 | "Voxels", "Input/Output")
22 | {
23 | }
24 |
25 | ///
26 | /// Registers all the input parameters for this component.
27 | ///
28 | protected override void RegisterInputParams(GH_InputParamManager pManager)
29 | {
30 | pManager.AddTextParameter("Hex", "H", "Hexadecimal string describing the grid", GH_ParamAccess.item);
31 |
32 | }
33 |
34 | ///
35 | /// Registers all the output parameters for this component.
36 | ///
37 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
38 | {
39 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations", GH_ParamAccess.item);
40 | }
41 |
42 | ///
43 | /// This is the method that actually does the work.
44 | ///
45 | /// The DA object is used to retrieve from inputs and store in outputs.
46 | protected override void SolveInstance(IGH_DataAccess DA)
47 | {
48 | var hex = "";
49 | DA.GetData(0, ref hex);
50 | var output = ByteHelper.ToVoxelGrid(ByteHelper.Decompress(ByteHelper.StringToByteArray(hex)));
51 | DA.SetData(0, output);
52 | }
53 |
54 | ///
55 | /// Provides an Icon for the component.
56 | ///
57 | protected override Bitmap Icon =>
58 | //You can add image files to your project resources and access them like this:
59 | // return Resources.IconForThisComponent;
60 | Images.VT_GridFromHex;
61 |
62 | ///
63 | /// Gets the unique ID for this component. Do not change this ID after release.
64 | ///
65 | public override Guid ComponentGuid => new Guid("{08A46861-EF75-4579-A427-379C5576B73A}");
66 | }
67 | }
--------------------------------------------------------------------------------
/VoxelTools/Helper/PixelGridMeshHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Rhino.Geometry;
5 | using StudioAvw.Voxels.Geometry;
6 |
7 | namespace StudioAvw.Voxels.Helper
8 | {
9 | public static class PixelGridMeshHelper
10 | {
11 | public static Mesh GenerateMesh(this PixelGrid2D pixelGrid, Color trueColor, Color falseColor)
12 | {
13 | var m = new Mesh();
14 | var sizeU = pixelGrid.PixelSize[0]/2;
15 | var sizeV = pixelGrid.PixelSize[1]/2;
16 |
17 | var pts = new Point3d[] {
18 | new Point3d(-sizeU, -sizeV, 0),
19 | new Point3d(-sizeU, sizeV, 0),
20 | new Point3d(sizeU, sizeV, 0),
21 | new Point3d(sizeU, -sizeV, 0)
22 | };
23 |
24 | var pln = pixelGrid.Plane;
25 |
26 | for (var i = 0; i < pixelGrid.Count; i++)
27 | {
28 | var pt = pixelGrid.PointAt(i);
29 | pln.Origin = pt;
30 |
31 | var p3fs = new List();
32 | foreach (var ptd in pts)
33 | {
34 | var worldpt = pln.PointAt(ptd.X, ptd.Y, ptd.Z);
35 | p3fs.Add(new Point3f((float)worldpt.X, (float)worldpt.Y, (float)worldpt.Z));
36 | }
37 |
38 | // try to use unique vertices
39 | var cCount = m.Vertices.Count;
40 | m.Vertices.AddVertices(p3fs);
41 | var iFaceIndex = m.Faces.Count;
42 | var facenormal = Vector3d.CrossProduct(p3fs[1] - p3fs[0], p3fs[2] - p3fs[0]);
43 | if (Vector3d.VectorAngle(facenormal, pln.Normal) > Math.PI / 2)
44 | {
45 | m.Faces.AddFace(cCount + 3, cCount + 2, cCount + 1, cCount);
46 | }
47 | else
48 | {
49 | m.Faces.AddFace(cCount, cCount + 1, cCount + 2, cCount + 3);
50 | }
51 |
52 | if (pixelGrid[i] == true)
53 | {
54 | m.VertexColors.Add(trueColor); m.VertexColors.Add(trueColor); m.VertexColors.Add(trueColor); m.VertexColors.Add(trueColor);
55 | }
56 | else
57 | {
58 | m.VertexColors.Add(falseColor); m.VertexColors.Add(falseColor); m.VertexColors.Add(falseColor); m.VertexColors.Add(falseColor);
59 | }
60 | m.FaceNormals.SetFaceNormal(iFaceIndex, pln.Normal);
61 | m.Normals.ComputeNormals();
62 | m.Compact();
63 | }
64 | return m;
65 | }
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridDimensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using Rhino.Geometry;
6 | using StudioAvw.Voxels.Geometry;
7 | using StudioAvw.Voxels.Param;
8 |
9 | namespace StudioAvw.Voxels.Components.VoxelGrid
10 | {
11 | ///
12 | /// Enumerate the voxel grid
13 | ///
14 | public class VoxelGridDimensions : BaseVoxelComponent
15 | {
16 | ///
17 | /// Initializes a new instance of the VoxelGridIntersect class.
18 | ///
19 | public VoxelGridDimensions()
20 | : base("VoxelGrid Dimensions", "VGDimensions",
21 | "Get the dimensions of a voxelgrid",
22 | "Voxels", "Analysis")
23 | {
24 | }
25 |
26 | ///
27 | /// Registers all the input parameters for this component.
28 | ///
29 | protected override void RegisterInputParams(GH_InputParamManager pManager)
30 | {
31 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "Voxelgrid to analyse", GH_ParamAccess.item);
32 | }
33 |
34 | ///
35 | /// Registers all the output parameters for this component.
36 | ///
37 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
38 | {
39 | pManager.AddPointParameter("Voxelsize", "S", "X, Y, Z size of a voxel", GH_ParamAccess.item);
40 | pManager.AddPointParameter("Voxelcount", "C", "Amount of voxels in X, Y and Z direction", GH_ParamAccess.item);
41 | }
42 |
43 | ///
44 | /// This is the method that actually does the work.
45 | ///
46 | /// The DA object is used to retrieve from inputs and store in outputs.
47 | protected override void SolveInstance(IGH_DataAccess DA)
48 | {
49 | var vg = default(VoxelGrid3D);
50 | DA.GetData(0, ref vg);
51 |
52 | DA.SetData(0, vg.VoxelSize);
53 | DA.SetData(1, vg.SizeUVW.ToPoint3D());
54 | }
55 |
56 | ///
57 | /// Provides an Icon for the component.
58 | ///
59 | protected override Bitmap Icon =>
60 | //You can add image files to your project resources and access them like this:
61 | // return Resources.IconForThisComponent;
62 | Images.VT_Decompose;
63 |
64 | ///
65 | /// Gets the unique ID for this component. Do not change this ID after release.
66 | ///
67 | public override Guid ComponentGuid => new Guid("{3123E7DD-38F8-4050-A31A-03524B21776A}");
68 | }
69 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridToHex.cs:
--------------------------------------------------------------------------------
1 | #region
2 |
3 | using System;
4 | using System.Drawing;
5 | using Grasshopper.Kernel;
6 | using StudioAvw.Voxels.Geometry;
7 | using StudioAvw.Voxels.Param;
8 | using StudioAvw.Voxels.Helper;
9 |
10 | #endregion
11 |
12 | namespace StudioAvw.Voxels.Components.VoxelGrid
13 | {
14 | ///
15 | /// Convert voxelgrid to hexadecimal number
16 | ///
17 | public class VoxelGridHex : BaseVoxelComponent
18 | {
19 | ///
20 | /// Initializes a new instance of the VoxelGridIntersect class.
21 | ///
22 | ///
23 | public VoxelGridHex()
24 | : base("VoxelGrid To Hex String", "VGToHex",
25 | "Convert a voxelgrid to a hexadecimal string",
26 | "Voxels", "Input/Output")
27 | {
28 | }
29 |
30 | ///
31 | /// Provides an Icon for the component.
32 | ///
33 | protected override Bitmap Icon =>
34 | //You can add image files to your project resources and access them like this:
35 | // return Resources.IconForThisComponent;
36 | Images.VT_GridToHex;
37 |
38 | ///
39 | /// Gets the unique ID for this component. Do not change this ID after release.
40 | ///
41 | public override Guid ComponentGuid => new Guid("{1338ADC7-CF4C-4A59-8F25-73031DAEF4A2}");
42 |
43 | ///
44 | /// Registers all the input parameters for this component.
45 | ///
46 | /// Use the pManager to register new parameters. pManager is never null.
47 | protected override void RegisterInputParams(GH_InputParamManager pManager)
48 | {
49 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations",
50 | GH_ParamAccess.item);
51 | }
52 |
53 | ///
54 | /// Registers all the output parameters for this component.
55 | ///
56 | /// Use the pManager to register new parameters. pManager is never null.
57 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
58 | {
59 | pManager.AddTextParameter("Hex", "H", "Hexadecimal string describing the grid", GH_ParamAccess.item);
60 | }
61 |
62 | ///
63 | /// This is the method that actually does the work.
64 | ///
65 | /// The da object is used to retrieve from inputs and store in outputs.
66 | protected override void SolveInstance(IGH_DataAccess da)
67 | {
68 | var vg = default(VoxelGrid3D);
69 | da.GetData(0, ref vg);
70 | var output = ByteHelper.ByteToHex(ByteHelper.Compress(ByteHelper.ToByte(vg)));
71 | da.SetData(0, output);
72 | }
73 | }
74 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/Upgrades/UpgradeMeshHull.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Grasshopper.Kernel;
3 | using Grasshopper.Kernel.Parameters;
4 | using Grasshopper.Kernel.Types;
5 | using StudioAvw.Voxels.Components.VoxelGrid;
6 | using StudioAvw.Voxels.Helper;
7 |
8 | namespace StudioAvw.Voxels.Components.Upgrades
9 | {
10 | ///
11 | /// A class implementing IGH_UpgradeObject to enable the "Upgrade component" menu to recognize out of date "Restore State" components.
12 | ///
13 | ///
14 | public class UpgradeMeshHull : IGH_UpgradeObject
15 | {
16 | ///
17 | /// Upgrade an existing object.
18 | ///
19 | /// Object to upgrade.
20 | /// Document that contains the object.
21 | /// https://discourse.mcneel.com/t/how-to-handle-input-output-definition-changes-when-a-component-gets-updated-in-a-new-version/64635/5
22 | ///
23 | /// The newly created object on success, null on failure.
24 | ///
25 | public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
26 | {
27 | // ReSharper disable once UseNegatedPatternMatching
28 | var component = target as IGH_Component;
29 | var comp = GH_UpgradeUtil.SwapComponents(component, UpgradeTo, true);
30 | if (comp == null)
31 | {
32 | return null;
33 | }
34 | var param = new Param_Boolean();
35 | param.PersistentData.Append(new GH_Boolean(false));
36 | param.Name = "Fake Shadow";
37 | param.NickName = "FS";
38 | param.Description = "Add fake shadow to the mesh, it can help to visualize the grid.";
39 | param.Access = GH_ParamAccess.item;
40 | comp.Params.Input.Add(param);
41 | return comp;
42 | }
43 |
44 | ///
45 | /// Gets the ComponentGuid of the old object (the object to be updated).
46 | ///
47 | public Guid UpgradeFrom => new Guid("{E99F9A6C-2568-40B4-9AE8-73423442BA96}");
48 |
49 | ///
50 | /// Gets the ComponentGuid of the new object (the object that will be inserted).
51 | ///
52 | public Guid UpgradeTo => new Guid("{2C2E9FB7-2018-4F5E-BDA9-C56A171709F0}");
53 |
54 | ///
55 | /// Return a DateTime object that indicates when this upgrade mechanism was written,
56 | /// so that it becomes possible to distinguish competing upgrade mechanisms.
57 | ///
58 | public DateTime Version => new DateTime(2020, 5, 25);
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/VoxelTools/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 |
11 | [Dd]ebug/
12 | [Rr]elease/
13 | x64/
14 | build/
15 | [Bb]in/
16 | [Oo]bj/
17 |
18 | # MSTest test Results
19 | [Tt]est[Rr]esult*/
20 | [Bb]uild[Ll]og.*
21 |
22 | *_i.c
23 | *_p.c
24 | *.ilk
25 | *.meta
26 | *.obj
27 | *.pch
28 | *.pdb
29 | *.pgc
30 | *.pgd
31 | *.rsp
32 | *.sbr
33 | *.tlb
34 | *.tli
35 | *.tlh
36 | *.tmp
37 | *.tmp_proj
38 | *.log
39 | *.vspscc
40 | *.vssscc
41 | .builds
42 | *.pidb
43 | *.log
44 | *.scc
45 |
46 | # Visual C++ cache files
47 | ipch/
48 | *.aps
49 | *.ncb
50 | *.opensdf
51 | *.sdf
52 | *.cachefile
53 |
54 | # Visual Studio profiler
55 | *.psess
56 | *.vsp
57 | *.vspx
58 |
59 | # Guidance Automation Toolkit
60 | *.gpState
61 |
62 | # ReSharper is a .NET coding add-in
63 | _ReSharper*/
64 | *.[Rr]e[Ss]harper
65 |
66 | # TeamCity is a build add-in
67 | _TeamCity*
68 |
69 | # DotCover is a Code Coverage Tool
70 | *.dotCover
71 |
72 | # NCrunch
73 | *.ncrunch*
74 | .*crunch*.local.xml
75 |
76 | # Installshield output folder
77 | [Ee]xpress/
78 |
79 | # DocProject is a documentation generator add-in
80 | DocProject/buildhelp/
81 | DocProject/Help/*.HxT
82 | DocProject/Help/*.HxC
83 | DocProject/Help/*.hhc
84 | DocProject/Help/*.hhk
85 | DocProject/Help/*.hhp
86 | DocProject/Help/Html2
87 | DocProject/Help/html
88 |
89 | # Click-Once directory
90 | publish/
91 |
92 | # Publish Web Output
93 | *.Publish.xml
94 | *.pubxml
95 |
96 | # NuGet Packages Directory
97 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
98 | #packages/
99 |
100 | # Windows Azure Build Output
101 | csx
102 | *.build.csdef
103 |
104 | # Windows Store app package directory
105 | AppPackages/
106 |
107 | # Others
108 | sql/
109 | *.Cache
110 | ClientBin/
111 | [Ss]tyle[Cc]op.*
112 | ~$*
113 | *~
114 | *.dbmdl
115 | *.[Pp]ublish.xml
116 | *.pfx
117 | *.publishsettings
118 |
119 | # RIA/Silverlight projects
120 | Generated_Code/
121 |
122 | # Backup & report files from converting an old project file to a newer
123 | # Visual Studio version. Backup files are not needed, because we have git ;-)
124 | _UpgradeReport_Files/
125 | Backup*/
126 | UpgradeLog*.XML
127 | UpgradeLog*.htm
128 |
129 | # SQL Server files
130 | App_Data/*.mdf
131 | App_Data/*.ldf
132 |
133 | # =========================
134 | # Windows detritus
135 | # =========================
136 |
137 | # Windows image file caches
138 | Thumbs.db
139 | ehthumbs.db
140 |
141 | # Folder config file
142 | Desktop.ini
143 |
144 | # Recycle Bin used on file shares
145 | $RECYCLE.BIN/
146 |
147 | # Mac crap
148 | .DS_Store
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridInvert.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel;
4 | using StudioAvw.Voxels.Geometry;
5 | using StudioAvw.Voxels.Param;
6 |
7 | namespace StudioAvw.Voxels.Components.VoxelGrid
8 | {
9 | ///
10 | /// invert the voxelgrid
11 | ///
12 | public class VoxelGridInvert : BaseVoxelComponent
13 | {
14 | ///
15 | /// Initializes a new instance of the VoxelGridIntersect class.
16 | ///
17 | public VoxelGridInvert()
18 | : base("VoxelGrid Boolean Invert", "VGInvert",
19 | "Invert a voxel grid",
20 | "Voxels", "Boolean")
21 | {
22 | }
23 |
24 | ///
25 | /// Registers all the input parameters for this component.
26 | ///
27 | protected override void RegisterInputParams(GH_InputParamManager pManager)
28 | {
29 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations", GH_ParamAccess.item);
30 | }
31 |
32 | ///
33 | /// Registers all the output parameters for this component.
34 | ///
35 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
36 | {
37 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations", GH_ParamAccess.item);
38 | }
39 |
40 | ///
41 | /// This is the method that actually does the work.
42 | ///
43 | /// The DA object is used to retrieve from inputs and store in outputs.
44 | protected override void SolveInstance(IGH_DataAccess DA)
45 | {
46 | var vg = default(VoxelGrid3D);
47 | DA.GetData(0, ref vg);
48 | vg = (VoxelGrid3D)vg.Clone();
49 |
50 | if (vg == null || !vg.IsValid)
51 | {
52 | return;
53 | }
54 |
55 | for (var i = 0; i < vg.Count; i++)
56 | {
57 | vg[i] = !vg[i];
58 | }
59 | DA.SetData(0, vg);
60 | AddRenderGrid(vg);
61 | }
62 |
63 | ///
64 | /// Provides an Icon for the component.
65 | ///
66 | protected override Bitmap Icon =>
67 | //You can add image files to your project resources and access them like this:
68 | // return Resources.IconForThisComponent;
69 | Images.VT_GridInverse;
70 |
71 | ///
72 | /// Gets the unique ID for this component. Do not change this ID after release.
73 | ///
74 | public override Guid ComponentGuid => new Guid("{0CB9D055-2AE4-4B00-8B55-558C22175933}");
75 | }
76 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/Upgrades/UpgradeVoxelGridToBoxes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Grasshopper.Kernel;
3 | using Grasshopper.Kernel.Parameters;
4 | using Grasshopper.Kernel.Types;
5 | using StudioAvw.Voxels.Components.VoxelGrid;
6 | using StudioAvw.Voxels.Helper;
7 |
8 | namespace StudioAvw.Voxels.Components.Upgrades
9 | {
10 | ///
11 | /// A class implementing IGH_UpgradeObject to enable the "Upgrade component" menu to recognize out of date "Restore State" components.
12 | ///
13 | ///
14 | public class UpgradeVoxelGridToBoxes : IGH_UpgradeObject
15 | {
16 | ///
17 | /// Upgrade an existing object.
18 | ///
19 | /// Object to upgrade.
20 | /// Document that contains the object.
21 | /// https://discourse.mcneel.com/t/how-to-handle-input-output-definition-changes-when-a-component-gets-updated-in-a-new-version/64635/5
22 | ///
23 | /// The newly created object on success, null on failure.
24 | ///
25 | public IGH_DocumentObject Upgrade(IGH_DocumentObject target, GH_Document document)
26 | {
27 | // ReSharper disable once UseNegatedPatternMatching
28 | var component = target as IGH_Component;
29 | var comp = GH_UpgradeUtil.SwapComponents(component, UpgradeTo, true);
30 | if (comp == null)
31 | {
32 | return null;
33 | }
34 | var param = new Param_Integer();
35 | DataAccessHelper.AddEnumOptionsToParam(param);
36 | param.PersistentData.Append(new GH_Integer(1));
37 | param.Name = "Selection";
38 | param.NickName = "S";
39 | param.Description = "0 = all false voxels, 1 = all true voxels(default), -1 = all voxels";
40 | param.Access = GH_ParamAccess.item;
41 | comp.Params.Input.Add(param);
42 | return comp;
43 | }
44 |
45 | ///
46 | /// Gets the ComponentGuid of the old object (the object to be updated).
47 | ///
48 | public Guid UpgradeFrom => new Guid("{d8f14822-91e4-417a-931c-a42455a07361}");
49 |
50 | ///
51 | /// Gets the ComponentGuid of the new object (the object that will be inserted).
52 | ///
53 | public Guid UpgradeTo => new Guid("{01E3D92A-DD7D-4A20-B754-20186CC5AC8D}");
54 |
55 | ///
56 | /// Return a DateTime object that indicates when this upgrade mechanism was written,
57 | /// so that it becomes possible to distinguish competing upgrade mechanisms.
58 | ///
59 | public DateTime Version => new DateTime(2020, 5, 22);
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridIntersect.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using StudioAvw.Voxels.Geometry;
6 | using StudioAvw.Voxels.Param;
7 |
8 | namespace StudioAvw.Voxels.Components.VoxelGrid
9 | {
10 | ///
11 | /// GH Component to intersect two voxelgrids
12 | ///
13 | public class VoxelGridIntersect : BaseVoxelComponent
14 | {
15 | ///
16 | /// Initializes a new instance of the VoxelGridIntersect class.
17 | ///
18 | public VoxelGridIntersect()
19 | : base("VoxelGrid Boolean Intersect", "VGIntersect",
20 | "Intersection result of two grids",
21 | "Voxels", "Boolean")
22 | {
23 | }
24 |
25 | ///
26 | /// Registers all the input parameters for this component.
27 | ///
28 | protected override void RegisterInputParams(GH_InputParamManager pManager)
29 | {
30 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations", GH_ParamAccess.list);
31 | }
32 |
33 | ///
34 | /// Registers all the output parameters for this component.
35 | ///
36 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
37 | {
38 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations", GH_ParamAccess.item);
39 | }
40 |
41 | ///
42 | /// This is the method that actually does the work.
43 | ///
44 | /// The DA object is used to retrieve from inputs and store in outputs.
45 | protected override void SolveInstance(IGH_DataAccess da)
46 | {
47 | var grids = new List ();
48 | da.GetDataList(0, grids);
49 | if (grids.Count == 0)
50 | {
51 | return;
52 | }
53 |
54 | var outGrid = (VoxelGrid3D)grids[0].Clone();
55 | for (var i = 1; i < grids.Count; i++)
56 | {
57 | outGrid.And(grids[i]);
58 | }
59 | da.SetData(0, outGrid);
60 | AddRenderGrid(outGrid);
61 | }
62 |
63 | ///
64 | /// Provides an Icon for the component.
65 | ///
66 | protected override Bitmap Icon =>
67 | //You can add image files to your project resources and access them like this:
68 | // return Resources.IconForThisComponent;
69 | Images.VT_GridIntersect;
70 |
71 | ///
72 | /// Gets the unique ID for this component. Do not change this ID after release.
73 | ///
74 | public override Guid ComponentGuid => new Guid("{c30ffc42-2b0f-4f88-a1f2-84e4a510a006}");
75 | }
76 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridSubtract.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using StudioAvw.Voxels.Geometry;
6 | using StudioAvw.Voxels.Param;
7 |
8 | namespace StudioAvw.Voxels.Components.VoxelGrid
9 | {
10 | ///
11 | /// GH Component to subtract grid A from grid B
12 | ///
13 | public class VoxelGridSubtract : BaseVoxelComponent
14 | {
15 | ///
16 | /// Initializes a new instance of the VoxelGridIntersect class.
17 | ///
18 | public VoxelGridSubtract()
19 | : base("VoxelGrid Boolean Subtract", "VGSubtract",
20 | "Subtract grid 1..n from the first grid",
21 | "Voxels", "Boolean")
22 | {
23 | }
24 |
25 | ///
26 | /// Registers all the input parameters for this component.
27 | ///
28 | protected override void RegisterInputParams(GH_InputParamManager pManager)
29 | {
30 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations", GH_ParamAccess.list);
31 | }
32 |
33 | ///
34 | /// Registers all the output parameters for this component.
35 | ///
36 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
37 | {
38 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations", GH_ParamAccess.item);
39 | }
40 |
41 | ///
42 | /// This is the method that actually does the work.
43 | ///
44 | /// The DA object is used to retrieve from inputs and store in outputs.
45 | protected override void SolveInstance(IGH_DataAccess DA)
46 | {
47 | var grids = new List ();
48 | DA.GetDataList(0, grids);
49 | if (grids.Count == 0)
50 | {
51 | return;
52 | }
53 |
54 | var outGrid = (VoxelGrid3D)grids[0].Clone();
55 | for (var i = 1; i < grids.Count; i++)
56 | {
57 | outGrid.Subtract(grids[i]);
58 | }
59 | DA.SetData(0, outGrid);
60 | AddRenderGrid(outGrid);
61 | }
62 |
63 | ///
64 | /// Provides an Icon for the component.
65 | ///
66 | protected override Bitmap Icon =>
67 | //You can add image files to your project resources and access them like this:
68 | // return Resources.IconForThisComponent;
69 | Images.VT_GridDifference;
70 |
71 | ///
72 | /// Gets the unique ID for this component. Do not change this ID after release.
73 | ///
74 | public override Guid ComponentGuid => new Guid("{6AC05026-BBA2-4FBD-ABEB-AC868E99D96E}");
75 | }
76 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridExclusive.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using StudioAvw.Voxels.Geometry;
6 | using StudioAvw.Voxels.Param;
7 |
8 | namespace StudioAvw.Voxels.Components.VoxelGrid
9 | {
10 | ///
11 | /// Exclusive OR (XOR) operation for two grids. Remove overlapping parts.
12 | ///
13 | public class VoxelGridExclusive : BaseVoxelComponent
14 | {
15 | ///
16 | /// Initializes a new instance of the VoxelGridIntersect class.
17 | ///
18 | public VoxelGridExclusive()
19 | : base("VoxelGrid Boolean Exclusive", "VGExclusive",
20 | "Join multiple grids: remove overlapping boxes; keep the boxes that are unique to all grids",
21 | "Voxels", "Boolean")
22 | {
23 | }
24 |
25 | ///
26 | /// Registers all the input parameters for this component.
27 | ///
28 | protected override void RegisterInputParams(GH_InputParamManager pManager)
29 | {
30 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations", GH_ParamAccess.list);
31 | }
32 |
33 | ///
34 | /// Registers all the output parameters for this component.
35 | ///
36 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
37 | {
38 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the intersection operations", GH_ParamAccess.item);
39 | }
40 |
41 | ///
42 | /// This is the method that actually does the work.
43 | ///
44 | /// The DA object is used to retrieve from inputs and store in outputs.
45 | protected override void SolveInstance(IGH_DataAccess DA)
46 | {
47 | var grids = new List ();
48 | DA.GetDataList(0, grids);
49 | if (grids.Count == 0)
50 | {
51 | return;
52 | }
53 |
54 | var outGrid = (VoxelGrid3D)grids[0].Clone();
55 | for (var i = 1; i < grids.Count; i++)
56 | {
57 | outGrid.Xor(grids[i]);
58 | }
59 | DA.SetData(0, outGrid);
60 | AddRenderGrid(outGrid);
61 | }
62 |
63 | ///
64 | /// Provides an Icon for the component.
65 | ///
66 | protected override Bitmap Icon =>
67 | //You can add image files to your project resources and access them like this:
68 | // return Resources.IconForThisComponent;
69 | Images.VT_GridXOR;
70 |
71 | ///
72 | /// Gets the unique ID for this component. Do not change this ID after release.
73 | ///
74 | public override Guid ComponentGuid => new Guid("{AA68E498-45E7-44BE-B8F8-34BDF5F52EAD}");
75 | }
76 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridFromList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using StudioAvw.Voxels.Geometry;
6 | using StudioAvw.Voxels.Param;
7 |
8 | namespace StudioAvw.Voxels.Components.VoxelGrid
9 | {
10 | ///
11 | /// Create grid from list of booleans
12 | ///
13 | public class VoxelGridFromList : BaseVoxelComponent
14 | {
15 | ///
16 | /// Initializes a new instance of the VoxelGridIntersect class.
17 | ///
18 | public VoxelGridFromList()
19 | : base("VoxelGrid From List", "VGList",
20 | "Set the voxel values from a list of booleans",
21 | "Voxels", "Create")
22 | {
23 | }
24 |
25 | ///
26 | /// Registers all the input parameters for this component.
27 | ///
28 | protected override void RegisterInputParams(GH_InputParamManager pManager)
29 | {
30 | pManager.AddParameter(new Param_VoxelGrid(), "Grid", "G", "The grid to modify", GH_ParamAccess.item);
31 | pManager.AddBooleanParameter("Bool", "B", "True/false value for all cells", GH_ParamAccess.list);
32 | }
33 |
34 | ///
35 | /// Registers all the output parameters for this component.
36 | ///
37 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
38 | {
39 | pManager.AddParameter(new Param_VoxelGrid(), "Grid", "G", "The modified grid", GH_ParamAccess.list);
40 | }
41 |
42 | ///
43 | /// This is the method that actually does the work.
44 | ///
45 | /// The DA object is used to retrieve from inputs and store in outputs.
46 | protected override void SolveInstance(IGH_DataAccess DA)
47 | {
48 | var grid = default(VoxelGrid3D);
49 | var vals = new List();
50 | DA.GetData(0, ref grid);
51 | grid = (VoxelGrid3D)grid.Clone();
52 |
53 | DA.GetDataList(1, vals);
54 | var max = Math.Min(grid.Grid.Count, vals.Count);
55 |
56 | for (var i = 0; i < max; i++)
57 | {
58 | grid.SetValue(i, vals[i]);
59 | }
60 |
61 | DA.SetData(0, grid);
62 | AddRenderGrid(grid);
63 | }
64 |
65 | ///
66 | /// Provides an Icon for the component.
67 | ///
68 | protected override Bitmap Icon =>
69 | //You can add image files to your project resources and access them like this:
70 | // return Resources.IconForThisComponent;
71 | Images.VT_ConstructFromList;
72 |
73 | ///
74 | /// Gets the unique ID for this component. Do not change this ID after release.
75 | ///
76 | public override Guid ComponentGuid => new Guid("{E487FE7B-0416-49F2-BDD3-FE6CB0938D25}");
77 | }
78 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridToList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using Rhino.Geometry;
6 | using StudioAvw.Voxels.Geometry;
7 | using StudioAvw.Voxels.Param;
8 |
9 | namespace StudioAvw.Voxels.Components.VoxelGrid
10 | {
11 | ///
12 | /// Enumerate the voxel grid
13 | ///
14 | public class VoxelGridToList : BaseVoxelComponent
15 | {
16 | ///
17 | /// Initializes a new instance of the VoxelGridIntersect class.
18 | ///
19 | public VoxelGridToList()
20 | : base("VoxelGrid To List", "VGList",
21 | "Decompose a Voxel Grid to a Boolean List",
22 | "Voxels", "Analysis")
23 | {
24 | }
25 |
26 | ///
27 | /// Registers all the input parameters for this component.
28 | ///
29 | protected override void RegisterInputParams(GH_InputParamManager pManager)
30 | {
31 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grid to decompose", GH_ParamAccess.item);
32 | }
33 |
34 | ///
35 | /// Registers all the output parameters for this component.
36 | ///
37 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
38 | {
39 | pManager.AddBooleanParameter("Bool", "B", "True/false value for all cells", GH_ParamAccess.list);
40 | pManager.AddPointParameter("Pts", "P", "All points that belong to the grid", GH_ParamAccess.list);
41 | }
42 |
43 | ///
44 | /// This is the method that actually does the work.
45 | ///
46 | /// The DA object is used to retrieve from inputs and store in outputs.
47 | protected override void SolveInstance(IGH_DataAccess DA)
48 | {
49 | var vg = default(VoxelGrid3D);
50 | DA.GetData(0, ref vg);
51 |
52 | var values = new List();
53 | var location = new List();
54 | if (vg == null || !vg.IsValid)
55 | {
56 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The (input) voxelgrid was invalid");
57 | return;
58 | }
59 |
60 | for (var i = 0; i < vg.SizeUVW.SelfProduct(); i++)
61 | {
62 | values.Add(vg.GetValue(i));
63 | location.Add(vg.EvaluatePoint(i));
64 | }
65 | DA.SetDataList(0, values);
66 | DA.SetDataList(1, location);
67 | }
68 |
69 | ///
70 | /// Provides an Icon for the component.
71 | ///
72 | protected override Bitmap Icon =>
73 | //You can add image files to your project resources and access them like this:
74 | // return Resources.IconForThisComponent;
75 | Images.VT_GridToList;
76 |
77 | ///
78 | /// Gets the unique ID for this component. Do not change this ID after release.
79 | ///
80 | public override Guid ComponentGuid => new Guid("{1FD64427-290E-4CB7-9512-69ACC62E5256}");
81 | }
82 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridCreateComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel;
4 | using Rhino.Geometry;
5 | using StudioAvw.Voxels.Geometry;
6 | using StudioAvw.Voxels.Param;
7 |
8 | namespace StudioAvw.Voxels.Components.VoxelGrid
9 | {
10 | ///
11 | /// Create a voxelgrid from any type of geometry
12 | ///
13 | public class VoxelGridCreateComponent : BaseVoxelComponent
14 | {
15 | ///
16 | /// Initializes a new instance of the VoxelGridCreate class.
17 | ///
18 | public VoxelGridCreateComponent()
19 | : base("Create VoxelGrid", "VoxCreate",
20 | "Create an empty voxelgrid",
21 | "Voxels", "Create")
22 | {
23 | }
24 |
25 | ///
26 | /// Registers all the input parameters for this component.
27 | ///
28 | protected override void RegisterInputParams(GH_InputParamManager pManager)
29 | {
30 | pManager.AddBoxParameter("BoundingBox", "BB", "The bounding box in which the grid will be created", GH_ParamAccess.item);
31 | pManager.AddNumberParameter("SizeX", "X", "Size of a pixel in x direction", GH_ParamAccess.item);
32 | pManager.AddNumberParameter("SizeY", "Y", "Size of a pixel in Y direction", GH_ParamAccess.item);
33 | pManager.AddNumberParameter("SizeZ", "Z", "Size of a pixel in Z direction", GH_ParamAccess.item);
34 | }
35 |
36 | ///
37 | /// Registers all the output parameters for this component.
38 | ///
39 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
40 | {
41 | pManager.AddParameter(new Param_VoxelGrid());
42 | }
43 |
44 | ///
45 | /// This is the method that actually does the work.
46 | ///
47 | /// The DA object is used to retrieve from inputs and store in outputs.
48 | protected override void SolveInstance(IGH_DataAccess DA)
49 | {
50 | var bb = new Box();
51 | double x, y, z;
52 | x = y = z = 0;
53 | DA.GetData(1, ref x);
54 | DA.GetData(2, ref y);
55 | DA.GetData(3, ref z);
56 | DA.GetData(0, ref bb);
57 |
58 | var vg = new VoxelGrid3D(bb, new Point3d(x,y,z));
59 |
60 | if (!vg.IsValid)
61 | {
62 | AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Result was an invalid grid");
63 | }
64 |
65 | DA.SetData(0, (VoxelGrid3D) vg.Clone());
66 | AddRenderGrid(vg);
67 | }
68 |
69 | ///
70 | /// Provides an Icon for the component.
71 | ///
72 | protected override Bitmap Icon =>
73 | //You can add image files to your project resources and access them like this:
74 | // return Resources.IconForThisComponent;
75 | Images.VT_CreateGrid;
76 |
77 | ///
78 | /// Gets the unique ID for this component. Do not change this ID after release.
79 | ///
80 | public override Guid ComponentGuid => new Guid("{623edb3b-0d3e-4ff6-a04a-20dcbd7e1ab5}");
81 | }
82 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/ScalarGrid/ScalarGridCreateComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel;
4 | using Rhino.Geometry;
5 | using StudioAvw.Voxels.Geometry;
6 | using StudioAvw.Voxels.Param;
7 | using StudioAvw.Voxels.Types;
8 |
9 | namespace StudioAvw.Voxels.Components.ScalarGrid
10 | {
11 | ///
12 | /// Creates a scalar grid
13 | ///
14 | public class ScalarGridCreateComponent : BaseScalarComponent
15 | {
16 | ///
17 | /// Initializes a new instance of the VoxelGridCreate class.
18 | ///
19 | public ScalarGridCreateComponent()
20 | : base("Create Scalar Grid", "ScaVoxCreate",
21 | "Create an empty scalarlgrid",
22 | "Voxels", "Scalar")
23 | {
24 | }
25 |
26 |
27 | ///
28 | /// Registers all the input parameters for this component.
29 | ///
30 | protected override void RegisterInputParams(GH_InputParamManager pManager)
31 | {
32 |
33 | pManager.AddBoxParameter("BoundingBox", "BB", "The bounding box in which the grid will be created", GH_ParamAccess.item);
34 | pManager.AddNumberParameter("SizeX", "X", "Size of a pixel in x direction", GH_ParamAccess.item);
35 | pManager.AddNumberParameter("SizeY", "Y", "Size of a pixel in Y direction", GH_ParamAccess.item);
36 | pManager.AddNumberParameter("SizeZ", "Z", "Size of a pixel in Z direction", GH_ParamAccess.item);
37 | }
38 |
39 | ///
40 | /// Registers all the output parameters for this component.
41 | ///
42 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
43 | {
44 | pManager.AddParameter(new Param_ScalarGrid());
45 | }
46 |
47 | ///
48 | /// This is the method that actually does the work.
49 | ///
50 | /// The DA object is used to retrieve from inputs and store in outputs.
51 | protected override void SolveInstance(IGH_DataAccess DA)
52 | {
53 | var bb = new Box();
54 | double x, y, z;
55 | x = y = z = 0;
56 | DA.GetData(1, ref x);
57 | DA.GetData(2, ref y);
58 | DA.GetData(3, ref z);
59 | DA.GetData(0, ref bb);
60 |
61 | var vg = new ScalarGrid3D(bb, new Point3d(x,y,z));
62 |
63 | if (!vg.IsValid)
64 | {
65 | AddRuntimeMessage(GH_RuntimeMessageLevel.Warning, "Result was an invalid grid");
66 | }
67 |
68 | DA.SetData(0, new GH_ScalarGrid(vg));
69 | }
70 |
71 | ///
72 | /// Provides an Icon for the component.
73 | ///
74 | protected override Bitmap Icon =>
75 | //You can add image files to your project resources and access them like this:
76 | // return Resources.IconForThisComponent;
77 | Images.ST_CreateGrid;
78 |
79 | ///
80 | /// Gets the unique ID for this component. Do not change this ID after release.
81 | ///
82 | public override Guid ComponentGuid => new Guid("{880FC894-98AB-497E-82FC-63F8F9689CBC}");
83 | }
84 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/PixelGrid/PixelGridCreateComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel;
4 | using Rhino.Geometry;
5 | using StudioAvw.Voxels.Components.VoxelGrid;
6 | using StudioAvw.Voxels.Geometry;
7 | using StudioAvw.Voxels.Param;
8 | using StudioAvw.Voxels.Helper;
9 | using StudioAvw.Voxels.Types;
10 |
11 | namespace StudioAvw.Voxels.Components.PixelGrid
12 | {
13 | ///
14 | /// Create a voxelgrid from any type of geometry
15 | /// WARNING: This is an experiment without any useful application
16 | ///
17 | public class PixelGridCreateComponent : BaseVoxelComponent
18 | {
19 | ///
20 | /// Initializes a new instance of the PixelGridCreate class.
21 | ///
22 | public PixelGridCreateComponent()
23 | : base("Create PixelGrid", "PixelCreate",
24 | "Create an empty pixelgrid",
25 | "Pixels", "Create")
26 | {
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_InputParamManager pManager)
33 | {
34 | pManager.AddRectangleParameter("BoundingBox", "BB", "The bounding box in which the grid will be created", GH_ParamAccess.item);
35 | pManager.AddNumberParameter("SizeX", "X", "Size of a pixel in x direction", GH_ParamAccess.item);
36 | pManager.AddNumberParameter("SizeY", "Y", "Size of a pixel in Y direction", GH_ParamAccess.item);
37 | }
38 |
39 | ///
40 | /// Registers all the output parameters for this component.
41 | ///
42 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
43 | {
44 | pManager.AddParameter(new Param_PixelGrid());
45 | }
46 |
47 | ///
48 | /// This is the method that actually does the work.
49 | ///
50 | /// The DA object is used to retrieve from inputs and store in outputs.
51 | protected override void SolveInstance(IGH_DataAccess DA)
52 | {
53 | var bb = DA.Fetch("BoundingBox");
54 | var x = DA.Fetch("SizeX");
55 | var y = DA.Fetch("SizeY");
56 |
57 | var vg = new PixelGrid2D(bb, new Point2d(x, y));
58 |
59 | if (!vg.IsValid)
60 | {
61 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Result was an invalid grid");
62 | }
63 |
64 | DA.SetData(0, new GH_PixelGrid((PixelGrid2D)vg.Clone()));
65 | }
66 |
67 | ///
68 | /// Provides an Icon for the component.
69 | ///
70 | protected override Bitmap Icon =>
71 | //You can add image files to your project resources and access them like this:
72 | // return Resources.IconForThisComponent;
73 | Images.VT_CreateGrid;
74 |
75 | ///
76 | /// Gets the unique ID for this component. Do not change this ID after release.
77 | ///
78 | public override Guid ComponentGuid => new Guid("{AEA8BCDD-CE5B-4FEC-8902-500C8F0218FB}");
79 |
80 | public override GH_Exposure Exposure => GH_Exposure.hidden;
81 | }
82 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/PixelGrid/PixelGridMesh.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel;
4 | using Grasshopper.Kernel.Types;
5 | using Rhino.Geometry;
6 | using StudioAvw.Voxels.Geometry;
7 | using StudioAvw.Voxels.Param;
8 | using StudioAvw.Voxels.Helper;
9 |
10 | namespace StudioAvw.Voxels.Components.PixelGrid
11 | {
12 | ///
13 | /// Create a voxelgrid mesh hull describing the outer hull of the voxel grid
14 | /// WARNING: This is an experiment without any useful application
15 | ///
16 | public class PixelGridMesh : GH_Component
17 | {
18 | ///
19 | /// Initializes a new instance of the MyComponent1 class.
20 | ///
21 | public PixelGridMesh()
22 | : base("PixelGrid To Mesh Hull", "PixMeshHull", "Generate a mesh from a pixelgrid",
23 | "Pixels", "Analysis")
24 | {
25 | }
26 |
27 | ///
28 | /// Registers all the input parameters for this component.
29 | ///
30 | protected override void RegisterInputParams(GH_InputParamManager pManager)
31 | {
32 | pManager.AddParameter(new Param_PixelGrid());
33 |
34 | pManager.AddColourParameter("TrueColour", "T", "Color for true cells", GH_ParamAccess.item, Color.Black);
35 | pManager.AddColourParameter("FalseColour", "F", "Color for false cells", GH_ParamAccess.item, Color.White);
36 | }
37 |
38 | ///
39 | /// Registers all the output parameters for this component.
40 | ///
41 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
42 | {
43 | pManager.AddMeshParameter("Mesh", "M", "A Mesh of the hull of the VoxelGrid", GH_ParamAccess.item);
44 | }
45 |
46 | ///
47 | /// This is the method that actually does the work.
48 | ///
49 | /// The DA object is used to retrieve from inputs and store in outputs.
50 | protected override void SolveInstance(IGH_DataAccess DA)
51 | {
52 | /*
53 | * todo: select mesh box or simple box
54 | */
55 | var pg = DA.Fetch (0);
56 | var trueColor = DA.Fetch(1);
57 | var falseColor = DA.Fetch(2);
58 |
59 | if (pg == null || !pg.IsValid)
60 | {
61 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The (input) voxelgrid was invalid");
62 | return;
63 | }
64 | var m = pg.GenerateMesh(trueColor, falseColor);
65 | DA.SetData(0, new GH_Mesh(m));
66 |
67 | }
68 |
69 | ///
70 | /// Provides an Icon for the component.
71 | ///
72 | protected override Bitmap Icon =>
73 | //You can add image files to your project resources and access them like this:
74 | // return Resources.IconForThisComponent;
75 | Images.VT_Decompose;
76 |
77 | ///
78 | /// Gets the unique ID for this component. Do not change this ID after release.
79 | ///
80 | public override Guid ComponentGuid => new Guid("{4DAA6753-C19D-4CB0-AAE6-08E09D8F6918}");
81 |
82 | public override GH_Exposure Exposure => GH_Exposure.hidden;
83 | }
84 | }
--------------------------------------------------------------------------------
/VoxelGeometry/VoxelGrid3D.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using Rhino.Geometry;
3 |
4 | namespace StudioAvw.Voxels.Geometry
5 | {
6 | ///
7 | /// A grid containing voxel information
8 | ///
9 | public class VoxelGrid3D : BitGrid3D
10 | {
11 | #region Constructors (3)
12 |
13 | ///
14 | /// Create a voxelgrid from a boundingbox, voxelsize and bitarray
15 | /// BitArray is not copied but injected directly in the grid.
16 | ///
17 | ///
18 | /// Size of the pixel
19 | ///
20 | public VoxelGrid3D(Box boundingBox, Point3d voxelDimensions, BitArray grid)
21 | {
22 | Initialize(boundingBox, voxelDimensions);
23 | Grid = grid;
24 | }
25 |
26 | ///
27 | /// Create a grid of a encapsulating box, a width/height (pz) and a pHeight, and a printDel (a print delegate which can log the output of the class);
28 | ///
29 | /// The boundingbox
30 | /// A point3d with the length of a pixel in x, y and z dimensions
31 | public VoxelGrid3D(Box boundingBox, Point3d voxelDimensions)
32 | {
33 | Initialize(boundingBox, voxelDimensions);
34 | var bta = new BitArray(SizeUVW.SelfProduct(), false);
35 | bta.SetAll(false);
36 | Grid = bta;
37 | }
38 |
39 | ///
40 | /// VoxelGrid constructor: Copies (clone) a VoxelGrid from another voxelGrid
41 | /// Complexity O(n) for voxelsize
42 | ///
43 | ///
44 | public VoxelGrid3D(VoxelGrid3D vg)
45 | {
46 | // struct: should be copy
47 | this.BBox = vg.BBox;
48 | // struct: should be copy
49 | VoxelSize = vg.VoxelSize;
50 | // struct: should be copy
51 | SizeUVW = vg.SizeUVW;
52 | // class: needs deep copy
53 | Grid = new BitArray(vg.Grid.Count);
54 | for (var i = 0; i < vg.Grid.Count; i++)
55 | {
56 | Grid[i] = vg.Grid[i];
57 | }
58 | }
59 |
60 | #endregion Constructors
61 |
62 | #region Methods (5)
63 |
64 | // Public Methods (4)
65 |
66 | ///
67 | /// Clone the object
68 | ///
69 | ///
70 | public override object Clone()
71 | {
72 | var vg = new VoxelGrid3D(this.BBox, VoxelSize);
73 | for (var i = 0; i < Count; i++)
74 | {
75 | if (this[i])
76 | {
77 | vg[i] = true;
78 | }
79 | }
80 | return vg;
81 | }
82 |
83 | ///
84 | /// Copy the voxelgrid to an empty grid.
85 | ///
86 | ///
87 | public VoxelGrid3D CloneEmpty()
88 | {
89 | return new VoxelGrid3D(BBox, VoxelSize);
90 | }
91 |
92 | #endregion Methods
93 |
94 | public bool PointInGrid(Point3i subPt)
95 | {
96 | return !(subPt < Point3i.Origin || subPt >= SizeUVW);
97 | }
98 | }
99 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridUnion.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using StudioAvw.Voxels.Geometry;
6 | using StudioAvw.Voxels.Param;
7 |
8 | namespace StudioAvw.Voxels.Components.VoxelGrid
9 | {
10 | ///
11 | /// Join to voxelgrids together
12 | ///
13 | public class VoxelGridUnion : BaseVoxelComponent
14 | {
15 | ///
16 | /// Initializes a new instance of the VoxelGridIntersect class.
17 | ///
18 | public VoxelGridUnion()
19 | : base("VoxelGrid Boolean Union", "VGUnion",
20 | "Join multiple grids",
21 | "Voxels", "Boolean")
22 | {
23 | }
24 |
25 | ///
26 | /// Registers all the input parameters for this component.
27 | ///
28 | protected override void RegisterInputParams(GH_InputParamManager pManager)
29 | {
30 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The grids for the union operation", GH_ParamAccess.list);
31 | }
32 |
33 | ///
34 | /// Registers all the output parameters for this component.
35 | ///
36 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
37 | {
38 | pManager.AddParameter(new Param_VoxelGrid(), "Grids", "G", "The merged grid", GH_ParamAccess.item);
39 | }
40 |
41 | ///
42 | /// This is the method that actually does the work.
43 | ///
44 | /// The DA object is used to retrieve from inputs and store in outputs.
45 | protected override void SolveInstance(IGH_DataAccess da)
46 | {
47 | var grids = new List ();
48 | da.GetDataList(0, grids);
49 | if (grids.Count == 0)
50 | {
51 | return;
52 | }
53 |
54 | var outGrid = (VoxelGrid3D) grids[0].Clone();
55 | for (var i = 1; i < grids.Count; i++)
56 | {
57 | if (outGrid.Count != grids[i].Count)
58 | {
59 | AddRuntimeMessage(GH_RuntimeMessageLevel.Warning,
60 | $"Grid {i} is of a different size than grid 0, skipping this grid");
61 | return;
62 | }
63 | else
64 | {
65 | for (var j = 0; j < outGrid.Count; j++)
66 | {
67 | outGrid[j] = outGrid[j] || grids[i][j];
68 | }
69 | }
70 | }
71 | da.SetData(0, outGrid);
72 | AddRenderGrid(outGrid);
73 | }
74 |
75 | ///
76 | /// Provides an Icon for the component.
77 | ///
78 | protected override Bitmap Icon =>
79 | //You can add image files to your project resources and access them like this:
80 | // return Resources.IconForThisComponent;
81 | Images.VT_GridUnion;
82 |
83 | ///
84 | /// Gets the unique ID for this component. Do not change this ID after release.
85 | ///
86 | public override Guid ComponentGuid => new Guid("{89BF7550-970B-492D-BDDC-334028F60EFC}");
87 | }
88 | }
--------------------------------------------------------------------------------
/VoxelGeometry/VoxelGeometry.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {58E945DA-0909-4F25-890E-3FABEA67FDC9}
8 | Library
9 | Properties
10 | StudioAvw.Voxels.Geometry
11 | VoxelGeometry
12 | v4.6
13 | 512
14 |
15 |
16 |
17 | true
18 | full
19 | false
20 | bin\Debug\
21 | DEBUG;TRACE
22 | prompt
23 | 4
24 | false
25 |
26 |
27 | pdbonly
28 | true
29 | bin\Release\
30 | TRACE
31 | prompt
32 | 4
33 | false
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
66 |
67 |
68 | 5.12.50810.13095
69 |
70 |
71 |
72 |
73 | Erase "$(TargetDir)RhinoCommon.dll"
74 |
75 |
--------------------------------------------------------------------------------
/VoxelTools/Components/PixelGrid/PixelGridToList.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using Rhino.Geometry;
6 | using StudioAvw.Voxels.Components.VoxelGrid;
7 | using StudioAvw.Voxels.Geometry;
8 | using StudioAvw.Voxels.Param;
9 | using StudioAvw.Voxels.Helper;
10 |
11 | namespace StudioAvw.Voxels.Components.PixelGrid
12 | {
13 | ///
14 | /// Enumerate the voxel grid
15 | /// WARNING: This is an experiment without any useful application
16 | ///
17 | public class PixelGridToList : BaseVoxelComponent
18 | {
19 | ///
20 | /// Initializes a new instance of the VoxelGridIntersect class.
21 | ///
22 | public PixelGridToList()
23 | : base("PixelGridToList", "PGList",
24 | "Decompose a Voxel Grid to a Boolean List",
25 | "Pixels", "Analysis")
26 | {
27 | }
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_InputParamManager pManager)
33 | {
34 | pManager.AddParameter(new Param_PixelGrid(), "Grids", "G", "The grid to decompose", GH_ParamAccess.item);
35 | }
36 |
37 | ///
38 | /// Registers all the output parameters for this component.
39 | ///
40 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
41 | {
42 | pManager.AddBooleanParameter("Bool", "B", "True/false value for all cells", GH_ParamAccess.list);
43 | pManager.AddPointParameter("Pts", "P", "All points that belong to the grid", GH_ParamAccess.list);
44 | pManager.AddRectangleParameter("BBox", "BB", "The boundingbox of the grid", GH_ParamAccess.item);
45 | }
46 |
47 | ///
48 | /// This is the method that actually does the work.
49 | ///
50 | /// The DA object is used to retrieve from inputs and store in outputs.
51 | protected override void SolveInstance(IGH_DataAccess da)
52 | {
53 | var pg = da.Fetch(0);
54 |
55 |
56 | var values = new List();
57 | var location = new List();
58 | if (pg == null || !pg.IsValid)
59 | {
60 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The (input) voxelgrid was invalid");
61 | return;
62 | }
63 |
64 | for (var i = 0; i < pg.SizeUV.SelfProduct(); i++)
65 | {
66 | values.Add(pg.ValueAt(i));
67 | location.Add(pg.PointAt(i));
68 | }
69 | da.SetDataList(0, values);
70 | da.SetDataList(1, location);
71 | da.SetData(2, pg.BBox);
72 | }
73 |
74 | ///
75 | /// Provides an Icon for the component.
76 | ///
77 | protected override Bitmap Icon =>
78 | //You can add image files to your project resources and access them like this:
79 | // return Resources.IconForThisComponent;
80 | Images.VT_GridToList;
81 |
82 | ///
83 | /// Gets the unique ID for this component. Do not change this ID after release.
84 | ///
85 | public override Guid ComponentGuid => new Guid("{C04D2F2F-71B9-4A68-9617-5DA396BEDE2A}");
86 |
87 | public override GH_Exposure Exposure => GH_Exposure.hidden;
88 | }
89 | }
--------------------------------------------------------------------------------
/VoxelTools/Helper/DataAccessHelper.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using Grasshopper.Kernel;
4 | using Grasshopper.Kernel.Data;
5 | using Grasshopper.Kernel.Parameters;
6 | using Grasshopper.Kernel.Types;
7 |
8 | namespace StudioAvw.Voxels.Helper
9 | {
10 | static class DataAccessHelper
11 | {
12 | internal static void AddEnumOptionsToParam(Param_Integer cfParam)
13 | {
14 | foreach (int cfType in Enum.GetValues(typeof(T)))
15 | {
16 | var name = Enum.GetName(typeof(T), cfType);
17 | cfParam.AddNamedValue(name, cfType);
18 | }
19 | }
20 |
21 | ///
22 | /// Fetch data at index position
23 | ///
24 | ///
25 | ///
26 | ///
27 | ///
28 | public static T Fetch(this IGH_DataAccess DA, int position)
29 | {
30 | var temp = default(T);
31 | DA.GetData(position, ref temp);
32 | return temp;
33 | }
34 | ///
35 | /// Fetch data with name
36 | ///
37 | ///
38 | ///
39 | ///
40 | ///
41 | public static T Fetch(this IGH_DataAccess DA, string name)
42 | {
43 | var temp = default(T);
44 | DA.GetData(name, ref temp);
45 | return temp;
46 | }
47 |
48 | ///
49 | /// Fetch data list with position
50 | ///
51 | ///
52 | ///
53 | ///
54 | ///
55 | public static List FetchList(this IGH_DataAccess DA, int position)
56 | {
57 | var temp = new List();
58 | DA.GetDataList(position, temp);
59 | return temp;
60 | }
61 |
62 | ///
63 | /// Fetch data list with name
64 | ///
65 | ///
66 | ///
67 | ///
68 | ///
69 | public static List FetchList(this IGH_DataAccess DA, string name)
70 | {
71 | var temp = new List ();
72 | DA.GetDataList(name, temp);
73 | return temp;
74 | }
75 | ///
76 | /// Fetch structure with position
77 | ///
78 | ///
79 | ///
80 | ///
81 | ///
82 | public static GH_Structure FetchTree(this IGH_DataAccess DA, int position) where T : IGH_Goo
83 | {
84 | DA.GetDataTree(position, out GH_Structure temp);
85 | return temp;
86 | }
87 |
88 | ///
89 | /// Fetch structure with name
90 | ///
91 | ///
92 | ///
93 | ///
94 | ///
95 | public static GH_Structure FetchTree(this IGH_DataAccess DA, string name) where T : IGH_Goo
96 | {
97 | DA.GetDataTree(name, out GH_Structure temp);
98 | return temp;
99 | }
100 | }
101 | }
102 |
--------------------------------------------------------------------------------
/VoxelTools/Components/Obsolete/VoxelGridBoxesObsolete.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using Rhino.Geometry;
6 | using StudioAvw.Voxels.Geometry;
7 | using StudioAvw.Voxels.Param;
8 |
9 | namespace StudioAvw.Voxels.Components.Obsolete
10 | {
11 | ///
12 | /// Converts voxels to their containing boxes
13 | ///
14 | [Obsolete]
15 | public class VoxelGridBoxesObsolete : GH_Component
16 | {
17 | /// TODO: Add this class as old/replaced
18 | /// Add new class that implements the points in a correct way
19 | /// This class has been used before to enumerate all the points in a grid
20 | ///
21 | /// Initializes a new instance of the MyComponent1 class.
22 | ///
23 | public VoxelGridBoxesObsolete()
24 | : base("VoxelGrid To Boxes", "VoxBox",
25 | "Get a list of boxes from a voxelgrid",
26 | "Voxels", "Analysis")
27 | {
28 | }
29 |
30 | ///
31 | /// Registers all the input parameters for this component.
32 | ///
33 | protected override void RegisterInputParams(GH_InputParamManager pManager)
34 | {
35 | pManager.AddParameter(new Param_VoxelGrid());
36 | }
37 |
38 | ///
39 | /// Registers all the output parameters for this component.
40 | ///
41 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
42 | {
43 | pManager.AddBoxParameter("Boxes", "BOX", "A list of boxes that are contained in the grid", GH_ParamAccess.list);
44 | pManager.AddPointParameter("Points", "PTS", "A list of all points contained", GH_ParamAccess.list);
45 | }
46 |
47 | ///
48 | /// This is the method that actually does the work.
49 | ///
50 | /// The DA object is used to retrieve from inputs and store in outputs.
51 | protected override void SolveInstance(IGH_DataAccess da)
52 | {
53 | /*
54 | * todo: select mesh box or simple box
55 | */
56 | var vg = default(VoxelGrid3D);
57 | da.GetData(0, ref vg);
58 | if (vg == null || !vg.IsValid)
59 | {
60 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The (input) voxelgrid was invalid");
61 | return;
62 | }
63 | vg = (VoxelGrid3D) vg.Clone();
64 |
65 | var boxes = new List ();
66 | var values = new List();
67 |
68 |
69 | for (var i = 0; i < vg.SizeUVW.SelfProduct(); i++)
70 | {
71 | values.Add(vg.EvaluatePoint(i));
72 | if (vg.GetValue(i) == true)
73 | {
74 | boxes.Add(vg.CreateBox(i));
75 | }
76 | }
77 | da.SetDataList(0, boxes);
78 | da.SetDataList(1, values);
79 |
80 |
81 | // get top faces
82 | // get bottom faces
83 | }
84 |
85 | ///
86 | /// Provides an Icon for the component.
87 | ///
88 | protected override Bitmap Icon =>
89 | //You can add image files to your project resources and access them like this:
90 | // return Resources.IconForThisComponent;
91 | Images.VT_Decompose;
92 |
93 |
94 | public override GH_Exposure Exposure => GH_Exposure.hidden;
95 |
96 | ///
97 | /// Gets the unique ID for this component. Do not change this ID after release.
98 | ///
99 | public override Guid ComponentGuid => new Guid("{d8f14822-91e4-417a-931c-a42455a07361}");
100 |
101 | }
102 | }
--------------------------------------------------------------------------------
/VoxelTools/Param/Param_PixelGrid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using Rhino.Geometry;
6 | using StudioAvw.Voxels.Helper;
7 | using StudioAvw.Voxels.Types;
8 |
9 | namespace StudioAvw.Voxels.Param
10 | {
11 | ///
12 | /// Scalargrid Param
13 | ///
14 | // ReSharper disable once InconsistentNaming
15 | public class Param_PixelGrid : GH_PersistentParam
16 | {
17 | ///
18 | /// Provides a gh_param for a scalar grid
19 | ///
20 | public Param_PixelGrid()
21 | : base(new GH_InstanceDescription("PixelGrid", "PG", "Represents a collection of Pixel Grids", "Voxels", "Parameter"))
22 | {
23 | ClearData();
24 | }
25 |
26 |
27 | ///
28 | /// Unique id
29 | ///
30 | public override Guid ComponentGuid => new Guid("{713F3FB0-6DF8-4412-BD12-C81614132217}");
31 |
32 | public void DrawViewportMeshes(IGH_PreviewArgs args)
33 | {
34 | try
35 | {
36 | EnsureMeshCache();
37 |
38 | foreach (var m in _meshCache)
39 | {
40 | args.Display.DrawMeshFalseColors(m);
41 | }
42 | }
43 | catch { }
44 |
45 | }
46 |
47 | public bool Hidden { get; set; } = false;
48 |
49 | public bool IsPreviewCapable => true;
50 |
51 | private List _meshCache;
52 | private BoundingBox _bboxCache;
53 | private bool _hasMeshCache = false;
54 | private void EnsureMeshCache()
55 | {
56 |
57 | if (_hasMeshCache == true) { return; };
58 | foreach (var ghGoo in m_data.AllData(true))
59 | {
60 | var pg = (GH_PixelGrid) ghGoo;
61 | var m = pg.Value.GenerateMesh(Color.Black, Color.White);
62 | _bboxCache.Union(pg.Value.BBox.BoundingBox);
63 | _meshCache.Add(m);
64 | }
65 | _hasMeshCache = true;
66 | }
67 |
68 | ///
69 | ///
70 | ///
71 | public override void ClearData()
72 | {
73 | base.ClearData();
74 | if (_meshCache != null)
75 | {
76 | foreach (var m in _meshCache)
77 | {
78 | m.Dispose();
79 | }
80 | }
81 | _meshCache = new List();
82 | _bboxCache = BoundingBox.Empty;
83 | _hasMeshCache = false;
84 | }
85 |
86 | public BoundingBox ClippingBox => _bboxCache;
87 |
88 | ///
89 | /// What to do when right click: set one scalargrid
90 | /// Current: nothing
91 | ///
92 | ///
93 | ///
94 | protected override GH_GetterResult Prompt_Plural(ref List values)
95 | {
96 | return GH_GetterResult.cancel;
97 | }
98 |
99 | ///
100 | /// What to do when right click: set one scalargrid
101 | /// Current: nothing
102 | ///
103 | ///
104 | ///
105 | protected override GH_GetterResult Prompt_Singular(ref GH_PixelGrid value)
106 | {
107 | return GH_GetterResult.cancel;
108 | }
109 |
110 | ///
111 | /// Icon of a pointcloud
112 | ///
113 | protected override Bitmap Icon => Images.VT_PointCloud;
114 |
115 | ///
116 | /// Show in main bar
117 | ///
118 | public override GH_Exposure Exposure => GH_Exposure.hidden;
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/VoxelGeometry/ScalarGrid3D.cs:
--------------------------------------------------------------------------------
1 | using System.Collections;
2 | using Rhino.Geometry;
3 |
4 | namespace StudioAvw.Voxels.Geometry
5 | {
6 | /// Refactor the scalar tools to be an extension
7 | ///
8 | /// Grid with scalar (floating point) values.
9 | ///
10 | public class ScalarGrid3D : Grid3D
11 | {
12 | ///
13 | /// Create a grid of a encapsulating box, a width/height (pz) and a pHeight, and a printDel (a print delegate which can log the output of the class);
14 | ///
15 | /// The boundingbox
16 | /// A point3d with the length of a pixel in x, y and z dimensions
17 | public ScalarGrid3D(Box boundingBox, Point3d pixelDimensions)
18 | : base(boundingBox, pixelDimensions)
19 | {
20 | Grid = new float[SizeUVW.SelfProduct()];
21 | }
22 |
23 | ///
24 | /// Empty constructor
25 | ///
26 | // ReSharper disable once UnusedMember.Global
27 | public ScalarGrid3D() { }
28 |
29 | ///
30 | /// Return the amount of true voxels that have a value higher than 0
31 | ///
32 | /// Amount of non-zero voxels
33 | public int VoxelCount()
34 | {
35 | if (!IsValid)
36 | {
37 | return -1;
38 | }
39 | var count = 0;
40 | for (var i = 0; i < Count; i++)
41 | {
42 | if (this[i] > 0)
43 | {
44 | count++;
45 | }
46 | }
47 | return count;
48 | }
49 |
50 | ///
51 | /// Get the value of of a voxel relative to voxel with number i
52 | ///
53 | /// The voxel number to get a relative position for
54 | /// Relative coordinates to the voxel, e.g. (1,0,0) for a voxel to the right
55 | /// The value of the relative voxel
56 | public float GetRelativePointValue(int voxelIndex, Point3i relativeVoxel)
57 | {
58 | var pt = Point3i.IndexToPointUvw(SizeUVW, voxelIndex) + relativeVoxel;
59 | if (new Point3i(0, 0, 0) > pt || pt >= SizeUVW)
60 | {
61 | return float.NaN;
62 | }
63 | return GetValue(pt);
64 | }
65 |
66 | // calculate planes: foreach plane in the grid find the nodes and connect them.
67 | // and generate a mesh.
68 | // calculate edges: foreach edge in the grid get the edges
69 |
70 | ///
71 | /// Clone the object
72 | ///
73 | ///
74 | public override object Clone()
75 | {
76 | var vg = new ScalarGrid3D(BBox, VoxelSize);
77 | for (var i = 0; i < Count; i++)
78 | {
79 | vg[i] = this[i];
80 | }
81 | return vg;
82 | }
83 |
84 | ///
85 | /// Set a relative point
86 | ///
87 | ///
88 | ///
89 | public override void SetValue(int voxelIndex, float fVxValue)
90 | {
91 | Grid[voxelIndex] = fVxValue;
92 | }
93 |
94 |
95 | ///
96 | /// Get point
97 | ///
98 | ///
99 | ///
100 | public override float GetValue(int voxelIndex)
101 | {
102 | return Grid[voxelIndex];
103 | }
104 |
105 | ///
106 | /// Get the enumerator for the values in the grid
107 | ///
108 | ///
109 | public override IEnumerator GetEnumerator()
110 | {
111 | return Grid.GetEnumerator();
112 | }
113 |
114 | }
115 | }
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Voxel Tools
2 | The voxel tools offer ligthweight voxel geometry for Rhino.
3 | It allows you to quickly generate and manipulate voxelated geometry from meshes, breps, curves and points, and offers boolean operation between voxelgrids. It can convert voxelgrids to solid mesh hulls.
4 |
5 | ## Installation
6 | **Rhino 6/7**
7 | Use the yak package manager in Rhino 6 or Rhino 7, using the command `TestPackageManager` in Rhino 6 or `PackageManger` in Rhino 7, and search for VoxelTools
8 |
9 | **Alternatively: Rhino 5/6/7**:
10 | Download the VoxelTools.zip, and place it in `%appdata%/components`.
11 |
12 | ## Usage
13 |
14 | ### Voxelate geometry
15 | - Closed mesh [01_closed_mesh.gh](docs/01_closed_mesh.gh)
16 | - Open Mesh with attractor distance [02_closed_mesh.gh](docs/02_open_mesh.gh)
17 | - Closed Brep [03_closed_brep.gh](docs/03_closed_brep.gh)
18 | - Open Brep with attractor distance [04_open_brep.gh](docs/04_open_brep.gh)
19 | - Curve with attractor distance [05_curve.gh](docs/05_curve.gh)
20 | - Points with attractor distance [06_points.gh](docs/06_points.gh)
21 |
22 | #### Boolean operations
23 | For grids of the same size, you can do boolean operations. Boolean operations on voxelgrids are very quick and lightweight.
24 | - Add
25 | - Subtract
26 | - XOR
27 | - Invert
28 |
29 | #### Analysis
30 | - Voxelgrid to boxes
31 | - Voxelgrid statistics
32 | - Voxelgrid to mesh hull
33 |
34 | #### Serialization
35 | - Export voxelgrid to string
36 | - Import voxelgrid from string
37 | - Voxelgrid to List
38 | - Voxelgrid from List
39 |
40 | ## Need Help?
41 | - Please use the github issue tracker if you find bugs
42 | - For support please do not e-mail me personally, but find me (@arendvw) on the [McNeel forum](https://discourse.mcneel.com), use the tag `VoxelTools`
43 |
44 | ## Version History
45 | ### Voxeltools 1.0: release 25th of May 2020
46 | - Cleaned up code base and merged old projects for open source release\
47 | - Component GridToBoxes: Made both outputs consistent, added output selector
48 | - Mesh casting: Default casting to mesh is now without false colors
49 | - Mesh hull: Added non-default option to add false colors to the mesh
50 | - Voxelate Meshes: Closed meshes are now voxelized much better
51 | - Voxelate Curves: Curves are voxelated faster and more precise
52 | - Voxelate Open Breps: Open breps can now also be voxelized with an attractor distance
53 | - Improved warnings in marching cubes from boolean grid
54 | - Added icons for grid to hex and hex to grid
55 | - Obscured non-obvious (pixelgrid) or why factory specific components
56 | - Added documentation
57 |
58 | ### Voxeltools 0.1: Released 2013-2014
59 | Legacy VoxelTools - Legacy version that has circulated on the forums, The Why Factory and other places.
60 | Use this version if somehow your older scripts are not compatible with the new version, but upgrade when you can.
61 |
62 | ## Licence
63 | MIT Licence
64 |
65 | ## Roadmap
66 | - Document scalar grids
67 | - Document C# scripting usage using VoxelGeometry.dll
68 | - Document Marching cubes
69 | - Import/Export for voxbin common voxel formats
70 | - Import/export 3d shapenet
71 | - Rotation / movement of voxelgrids
72 | - Union of non-uniformly sized grids
73 | - Offset / Grow / Shrink
74 |
75 | ## Author
76 | Arend van Waart, arend@studioavw.nl
77 |
78 | ## Thanks to
79 | David Rutten, Sander Mulders, Huib Plomp, Adrien Ravon, Leo Stuckart, Boudewijn Thomas, Marek Nosek
80 |
81 | ### [The Why Factory](https://thewhyfactory.com/) Studio Porous Structures
82 | Winy Maas, Alexander Sverdlov, Rob Nijsse, Bas Wijnbeld, Manthan Mevada, M.F. Hercules, Mitalee Parikh, Olga Berning, Peng Zhao, Xiao Du, Rudo Valentijn Koot, M.A. Heredia Moreno, Alberto González Ruiz, Narinna Gyulkhasyan
83 |
84 | ### [The Why Factory](https://thewhyfactory.com/) Studio Egocity
85 | Winy Maas, Adrien Ravon, Felix Madrazo, Charles Ducerisier, Chun Hoi Hui, Francesco Barone, Félix Borel, Iason Stathatos, Javier López-Menchero Ortiz de Salazar, Lucile Dugal, Marek Nosek, Matteo Pavanello, Niels Baljet, Olga Terzi, Prokop Matej, Tarryn Leeferink, Wen Jun Tan, Woo Soojung, Zichen Liu, Loes Thijssen
86 |
87 | ## Publications
88 | [PoroCity, Opening up Solidity](https://www.naibooksellers.nl/porocity-opening-up-solidity-the-why-factory.html)
89 |
--------------------------------------------------------------------------------
/VoxelGeometry/PixelGrid2D.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 | using Rhino.Geometry;
4 |
5 | namespace StudioAvw.Voxels.Geometry
6 | {
7 | ///
8 | /// A grid containing voxel information
9 | ///
10 | public class PixelGrid2D : Grid2D
11 | {
12 | #region Constructors (3)
13 |
14 | ///
15 | /// Create a voxelgrid from a boundingbox, voxelsize and bitarray
16 | /// BitArray is not copied but injected directly in the grid.
17 | ///
18 | ///
19 | /// Size of the pixel
20 | ///
21 | public PixelGrid2D(Rectangle3d boundingBox, Point2d voxelDimensions, BitArray grid)
22 | : base()
23 | {
24 | Initialize(boundingBox, voxelDimensions);
25 | Grid = grid;
26 | }
27 |
28 | private void Initialize(Rectangle3d boundingBox, Point2d pixelDimensions)
29 | {
30 | _BBox = boundingBox;
31 | _PixelSize = pixelDimensions;
32 |
33 | int iX = Convert.ToInt16(Math.Floor(boundingBox.X.Length / pixelDimensions.X));
34 | int iY = Convert.ToInt16(Math.Floor(boundingBox.Y.Length / pixelDimensions.Y));
35 |
36 | var size = new Point2i(iX, iY);
37 | SizeUV = size;
38 | }
39 |
40 | ///
41 | /// Create a grid of a encapsulating box, a width/height (pz) and a pHeight, and a printDel (a print delegate which can log the output of the class);
42 | ///
43 | /// The boundingbox
44 | /// A point3d with the length of a pixel in x, y and z dimensions
45 | public PixelGrid2D(Rectangle3d boundingBox, Point2d voxelDimensions)
46 | : base()
47 | {
48 | Initialize(boundingBox, voxelDimensions);
49 | var bta = new BitArray(SizeUV.SelfProduct(), false);
50 | bta.SetAll(false);
51 | Grid = bta;
52 | }
53 |
54 | ///
55 | /// VoxelGrid constructor: Copies (clone) a VoxelGrid from another voxelGrid
56 | /// Complexity O(n) for voxelsize
57 | ///
58 | ///
59 | public PixelGrid2D(PixelGrid2D vg)
60 | {
61 | // struct: should be copy
62 | _BBox = vg._BBox;
63 | // struct: should be copy
64 | _PixelSize = vg.PixelSize;
65 | // struct: should be copy
66 | SizeUV = vg.SizeUV;
67 | // class: needs deep copy
68 | Grid = new BitArray(vg.Grid.Count);
69 | for (var i = 0; i < vg.Grid.Count; i++)
70 | {
71 | Grid[i] = vg.Grid[i];
72 | }
73 | }
74 |
75 | #endregion Constructors
76 |
77 | #region Methods (5)
78 |
79 | // Public Methods (4)
80 |
81 | ///
82 | /// Clone the object
83 | ///
84 | ///
85 | public override object Clone()
86 | {
87 | var vg = new PixelGrid2D(_BBox, _PixelSize);
88 | for (var i = 0; i < Count; i++)
89 | {
90 | vg[i] = this[i];
91 | }
92 | return vg;
93 | }
94 |
95 | ///
96 | /// Copy the voxelgrid to an empty grid.
97 | ///
98 | ///
99 | public PixelGrid2D CloneEmpty()
100 | {
101 | return new PixelGrid2D(BBox, PixelSize);
102 | }
103 |
104 | #endregion Methods
105 |
106 | ///
107 | /// Get the value of the voxel ant
108 | ///
109 | ///
110 | ///
111 | public override bool ValueAt(int iUV)
112 | {
113 | return Grid[iUV];
114 | }
115 |
116 | public override void SetValue(int iUV, bool value)
117 | {
118 | Grid[iUV] = value;
119 | }
120 |
121 | public override IEnumerator GetEnumerator()
122 | {
123 | return _Grid.GetEnumerator();
124 | }
125 |
126 | public override int Count => _Grid.Count;
127 |
128 |
129 | public delegate void EnumeratePixels(int x);
130 |
131 | }
132 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/ScalarGrid/ScalarGridVisualizeComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using Rhino.Display;
6 | using Rhino.Geometry;
7 | using StudioAvw.Voxels.Geometry;
8 | using StudioAvw.Voxels.Param;
9 | using StudioAvw.Voxels.Helper;
10 |
11 | namespace StudioAvw.Voxels.Components.ScalarGrid
12 | {
13 | ///
14 | /// Get the hull of a scalar grid using marching cubes (YAY BLOBS)
15 | ///
16 | public class ScalarGridVisualizeComponent : BaseScalarComponent
17 | {
18 | ///
19 | /// Initializes a new instance of the VoxelGridIntersect class.
20 | ///
21 | public ScalarGridVisualizeComponent()
22 | : base("Visualize Scalar Grid", "ScalarGridVis",
23 | "Show the values of a scalar grid in 3d",
24 | "Voxels", "Scalar")
25 | {
26 | }
27 |
28 |
29 | ///
30 | /// Registers all the input parameters for this component.
31 | ///
32 | protected override void RegisterInputParams(GH_InputParamManager pManager)
33 | {
34 | pManager.AddParameter(new Param_ScalarGrid(), "Grids", "G", "The grid render each node's value", GH_ParamAccess.item);
35 | //pManager.AddNumberParameter("Size", "S", "Text size for labels", GH_ParamAccess.item);
36 | pManager.AddTextParameter("Format", "F", "Format number notation", GH_ParamAccess.item, "{0:0.00}");
37 | }
38 |
39 |
40 |
41 | ///
42 | /// Registers all the output parameters for this component.
43 | ///
44 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
45 | {
46 | //pManager.AddMeshParameter("Mesh", "M", "Marching cube output", GH_ParamAccess.item);
47 | //pManager.AddIntegerParameter("cubeindex", "ci", "bla", GH_ParamAccess.list);
48 | }
49 |
50 | private readonly List _renderBuffer = new List();
51 | private string _renderFormat;
52 |
53 | public override bool IsPreviewCapable => true;
54 |
55 | protected override void BeforeSolveInstance()
56 | {
57 |
58 | _renderFormat = null;
59 | base.BeforeSolveInstance();
60 | _renderBuffer.Clear();
61 | }
62 |
63 | ///
64 | /// This is the method that actually does the work.
65 | ///
66 | /// The DA object is used to retrieve from inputs and store in outputs.
67 | protected override void SolveInstance(IGH_DataAccess DA)
68 | {
69 |
70 | var sc = ComponentHelper.FetchData(0, DA);
71 | var text = ComponentHelper.FetchData(1, DA);
72 |
73 | _renderBuffer.Add(sc);
74 | _renderFormat = text;
75 | }
76 |
77 | BoundingBox _clippingBox = BoundingBox.Unset;
78 |
79 | public override BoundingBox ClippingBox
80 | {
81 | get
82 | {
83 | if (_clippingBox.Equals(BoundingBox.Unset))
84 | {
85 | var bb = BoundingBox.Empty;
86 | foreach (var sc in _renderBuffer)
87 | {
88 | bb.Union(sc.BBox.BoundingBox);
89 | }
90 | _clippingBox = bb;
91 | }
92 | return _clippingBox;
93 | }
94 | }
95 |
96 | public override void DrawViewportWires(IGH_PreviewArgs args)
97 | {
98 | foreach (var sc in _renderBuffer)
99 | {
100 | for (var i = 0; i < sc.SizeUVW.SelfProduct(); i++)
101 | {
102 | var pt = sc.EvaluatePoint(i);
103 | args.Display.DrawPoint(pt, PointStyle.X, 10, args.WireColour);
104 | args.Display.Draw2dText(string.Format(_renderFormat, sc.GetValue(i)), args.WireColour, pt, false);
105 | }
106 | }
107 |
108 | }
109 |
110 |
111 | ///
112 | /// Provides an Icon for the component.
113 | ///
114 | protected override Bitmap Icon =>
115 | Images.ST_ToList;
116 |
117 | ///
118 | /// Gets the unique ID for this component. Do not change this ID after release.
119 | ///
120 | public override Guid ComponentGuid => new Guid("{0033E73A-AF86-42D6-94BC-87FC1F5B7F19}");
121 | }
122 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/Obsolete/VoxelGridMeshHullObsolete.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using Rhino.Geometry;
6 | using StudioAvw.Voxels.Geometry;
7 | using StudioAvw.Voxels.Helper;
8 | using StudioAvw.Voxels.Param;
9 |
10 | namespace StudioAvw.Voxels.Components.Obsolete
11 | {
12 | ///
13 | /// Create a voxelgrid mesh hull describing the outer hull of the voxel grid
14 | ///
15 | public class VoxelGridMeshHullObsolete : GH_Component
16 | {
17 | ///
18 | /// Initializes a new instance of the MyComponent1 class.
19 | ///
20 | public VoxelGridMeshHullObsolete()
21 | : base("VoxelGrid To Mesh Hull", "VoxMeshHull",
22 | "Generate a mesh of a Voxelgrid",
23 | "Voxels", "Analysis")
24 | {
25 | }
26 |
27 | ///
28 | /// Registers all the input parameters for this component.
29 | ///
30 | protected override void RegisterInputParams(GH_InputParamManager pManager)
31 | {
32 | pManager.AddParameter(new Param_VoxelGrid());
33 | }
34 |
35 | ///
36 | /// Registers all the output parameters for this component.
37 | ///
38 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
39 | {
40 | //FaceDirections = new Vector3d[6] { vg.BBox.Plane.XAxis, -vg.BBox.Plane.XAxis, vg.BBox.Plane.YAxis, -vg.BBox.Plane.YAxis, vg.BBox.Plane.ZAxis, -vg.BBox.Plane.ZAxis };
41 | pManager.AddMeshParameter("Mesh", "M", "A Mesh of the hull of the VoxelGrid", GH_ParamAccess.item);
42 | pManager.AddMeshParameter("+X", "+X", "Meshes with the normal in the X direction", GH_ParamAccess.item);
43 | pManager.AddMeshParameter("-X", "-X", "Meshes with the normal in the -X direction", GH_ParamAccess.item);
44 | pManager.AddMeshParameter("+Y", "+Y", "Meshes with the normal in the Y direction", GH_ParamAccess.item);
45 | pManager.AddMeshParameter("-Y", "-Y", "Meshes with the normal in the -Y direction", GH_ParamAccess.item);
46 | pManager.AddMeshParameter("+Z", "+Z", "Meshes with the normal in the Z direction", GH_ParamAccess.item);
47 | pManager.AddMeshParameter("-Z", "-Z", "Meshes with the normal in the -Z direction", GH_ParamAccess.item);
48 | }
49 |
50 | ///
51 | /// This is the method that actually does the work.
52 | ///
53 | /// The DA object is used to retrieve from inputs and store in outputs.
54 | protected override void SolveInstance(IGH_DataAccess DA)
55 | {
56 | /*
57 | * todo: select mesh box or simple box
58 | */
59 | var vg = default(VoxelGrid3D);
60 | DA.GetData(0, ref vg);
61 |
62 | if (vg == null || !vg.IsValid)
63 | {
64 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The (input) voxelgrid was invalid");
65 | return;
66 | }
67 |
68 | var m = VoxelGridMeshHelper.VoxelGridToMesh(vg);
69 | var meshes = new List ();
70 | try
71 | {
72 | meshes = VoxelGridMeshHelper.VoxelGridToMeshByPlanes(vg);
73 | }
74 | catch (Exception e)
75 | {
76 | throw new Exception($"Creating multiple meshes failed: {e.ToString()}");
77 | }
78 | VoxelGridMeshHelper.addFakeShadow(ref m, new Vector3d(-0.495633, 0.142501, 0.856762), 1.0, Color.White, Color.Black);
79 | DA.SetData(0, m);
80 |
81 | if (meshes.Count == 6)
82 | {
83 | for (var i = 1; i <= meshes.Count; i++)
84 | {
85 | DA.SetData(i, meshes[i - 1]);
86 | }
87 | }
88 | else
89 | {
90 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error,"Getting world planes failed");
91 | }
92 | // get top faces
93 | // get bottom faces
94 | }
95 |
96 | ///
97 | /// Provides an Icon for the component.
98 | ///
99 | protected override Bitmap Icon =>
100 | //You can add image files to your project resources and access them like this:
101 | // return Resources.IconForThisComponent;
102 | Images.VT_Decompose;
103 |
104 | ///
105 | /// Gets the unique ID for this component. Do not change this ID after release.
106 | ///
107 | public override Guid ComponentGuid => new Guid("{E99F9A6C-2568-40B4-9AE8-73423442BA96}");
108 |
109 | public override GH_Exposure Exposure => GH_Exposure.hidden;
110 | }
111 | }
--------------------------------------------------------------------------------
/VoxelTools/Helper/RenderHelper.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // TODO: Update copyright text.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | using System.Collections.Generic;
8 | using Rhino.Geometry;
9 | using StudioAvw.Voxels.Geometry.Interfaces;
10 |
11 | namespace StudioAvw.Voxels.Helper
12 | {
13 | ///
14 | /// TODO: Update summary.
15 | ///
16 | public static class RenderHelper
17 | {
18 | public static void GenerateGridPreviewLines(IGrid3D renderGrid, out List renderDottedLines, out List renderLines)
19 | {
20 | renderDottedLines = new List ();
21 | renderLines = new List ();
22 |
23 | for (var k = 0; k <= renderGrid.SizeUVW.X; k++)
24 | {
25 | var pt1 = renderGrid.EvaluatePoint(new Point3d(k-0.5, -0.5, -0.5));
26 | var pt2 = renderGrid.EvaluatePoint(new Point3d(k-0.5, renderGrid.SizeUVW.Y - 0.5, -0.5));
27 | var l = new Line(pt1, pt2);
28 | renderLines.Add(l);
29 |
30 | }
31 |
32 | for (var m = 0; m <= renderGrid.SizeUVW.Y; m++)
33 | {
34 | var pt1 = renderGrid.EvaluatePoint(new Point3d(-0.5, m-0.5, -0.5));
35 | var pt2 = renderGrid.EvaluatePoint(new Point3d(renderGrid.SizeUVW.X-0.5, m-0.5, -0.5));
36 | var l = new Line(pt1, pt2);
37 | renderLines.Add(l);
38 | }
39 |
40 | // x = 0, y =0, z = 1
41 | {
42 | var pt1 = renderGrid.EvaluatePoint(new Point3d(-0.5, -0.5, -0.5));
43 | var pt2 = renderGrid.EvaluatePoint(new Point3d(-0.5, -0.5, renderGrid.SizeUVW.Z-0.5));
44 | var l = new Line(pt1, pt2);
45 | renderLines.Add(l);
46 | }
47 |
48 | // x = 1, y =0, z = 1
49 | {
50 | var pt1 = renderGrid.EvaluatePoint(new Point3d(renderGrid.SizeUVW.X-0.5, -0.5, -0.5));
51 | var pt2 = renderGrid.EvaluatePoint(new Point3d(renderGrid.SizeUVW.X-0.5, -0.5, renderGrid.SizeUVW.Z-0.5));
52 | var l = new Line(pt1, pt2);
53 | renderLines.Add(l);
54 | }
55 |
56 | // x = 0, y =0, z = 1
57 | {
58 | var pt1 = renderGrid.EvaluatePoint(new Point3d(renderGrid.SizeUVW.X-0.5, renderGrid.SizeUVW.Y-0.5, 0-0.5));
59 | var pt2 = renderGrid.EvaluatePoint(new Point3d(renderGrid.SizeUVW.X-0.5, renderGrid.SizeUVW.Y-0.5, renderGrid.SizeUVW.Z-0.5));
60 | var l = new Line(pt1, pt2);
61 | renderLines.Add(l);
62 | }
63 |
64 |
65 | // x = 0, y =1, z = 1
66 | {
67 | var pt1 = renderGrid.EvaluatePoint(new Point3d(-0.5, renderGrid.SizeUVW.Y - 0.5, -0.5));
68 | var pt2 = renderGrid.EvaluatePoint(new Point3d(- 0.5, renderGrid.SizeUVW.Y - 0.5, renderGrid.SizeUVW.Z - 0.5));
69 | var l = new Line(pt1, pt2);
70 | renderLines.Add(l);
71 | }
72 |
73 | // top curves
74 | // x = 0, y =1, z = 1
75 | {
76 | var pt1 = renderGrid.EvaluatePoint(new Point3d(-0.5, renderGrid.SizeUVW.Y - 0.5, renderGrid.SizeUVW.Z - 0.5));
77 | var pt2 = renderGrid.EvaluatePoint(new Point3d(renderGrid.SizeUVW.X - 0.5, renderGrid.SizeUVW.Y - 0.5, renderGrid.SizeUVW.Z - 0.5));
78 | var l = new Line(pt1, pt2);
79 | renderLines.Add(l);
80 | }
81 |
82 |
83 | // top curves
84 | // x = 0, y =1, z = 1
85 | {
86 | var pt1 = renderGrid.EvaluatePoint(new Point3d(renderGrid.SizeUVW.X - 0.5, -0.5, renderGrid.SizeUVW.Z - 0.5));
87 | var pt2 = renderGrid.EvaluatePoint(new Point3d(renderGrid.SizeUVW.X - 0.5, renderGrid.SizeUVW.Y - 0.5, renderGrid.SizeUVW.Z - 0.5));
88 | var l = new Line(pt1, pt2);
89 | renderLines.Add(l);
90 | }
91 |
92 | // top curves
93 | // x = 0, y =1, z = 1
94 | {
95 | var pt1 = renderGrid.EvaluatePoint(new Point3d(-0.5, -0.5, renderGrid.SizeUVW.Z - 0.5));
96 | var pt2 = renderGrid.EvaluatePoint(new Point3d(-0.5, renderGrid.SizeUVW.Y - 0.5, renderGrid.SizeUVW.Z - 0.5));
97 | var l = new Line(pt1, pt2);
98 | renderLines.Add(l);
99 | }
100 |
101 |
102 | // top curves
103 | // x = 0, y =1, z = 1
104 | {
105 | var pt1 = renderGrid.EvaluatePoint(new Point3d(-0.5, -0.5, renderGrid.SizeUVW.Z - 0.5));
106 | var pt2 = renderGrid.EvaluatePoint(new Point3d(renderGrid.SizeUVW.X - 0.5, -0.5
107 | , renderGrid.SizeUVW.Z - 0.5));
108 | var l = new Line(pt1, pt2);
109 | renderLines.Add(l);
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/VoxelTools/Types/GH_ScalarGrid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Grasshopper.Kernel.Types;
3 | using StudioAvw.Voxels.Geometry;
4 |
5 | namespace StudioAvw.Voxels.Types
6 | {
7 | ///
8 | /// The GH Wrapper for ScalarGrid, that provides metadata, and casting support for scalar grids.
9 | ///
10 | public class GH_ScalarGrid : GH_Goo
11 | {
12 |
13 | ///
14 | /// Constructor: create a new Scalar Grid form a previous scalar grid
15 | ///
16 | ///
17 | public GH_ScalarGrid(ScalarGrid3D sc)
18 | : base()
19 | {
20 | Value = sc;
21 | }
22 |
23 | ///
24 | /// Create an empty / invalid scalar grid
25 | ///
26 | public GH_ScalarGrid()
27 | : base()
28 | {
29 | }
30 |
31 | ///
32 | /// Duplicate a scalar grid
33 | ///
34 | ///
35 | public override IGH_Goo Duplicate()
36 | {
37 | var duplicate = new GH_ScalarGrid();
38 | duplicate.Value = (ScalarGrid3D) Value.Clone();
39 | return duplicate;
40 |
41 | }
42 |
43 | ///
44 | /// Returns true if ScalarGrid is Valid
45 | ///
46 | public override bool IsValid => Value.IsValid;
47 |
48 | ///
49 | /// Show a string with information on the VoxelGrid
50 | ///
51 | ///
52 | public override string ToString()
53 | {
54 | if (Value == null)
55 | {
56 | return "Null/void Voxelgrid";
57 | }
58 | if (!Value.IsValid)
59 | {
60 | return $"Invalid ScalarGrid [{Value.SizeUVW.X},{Value.SizeUVW.Y},{Value.SizeUVW.Z}]";
61 | }
62 | return $"ScalarGrid [{Value.SizeUVW.X},{Value.SizeUVW.Y},{Value.SizeUVW.Z}={Value.SizeUVW.SelfProduct()}]";
63 |
64 | /*
65 | return String.Format("VoxelGrid [{0},{1},{2}={3}] with Cell Size [{4.0},{5.0},{6.0}] with {7} Voxels",
66 | Value.Size.x, Value.Size.y, Value.Size.z, Value.Size.selfProduct(),
67 | Value.VoxelSize.X, Value.VoxelSize.Y, Value.VoxelSize.Z,
68 | Value.VoxelCount()
69 | );*/
70 | }
71 |
72 | ///
73 | /// Human readable type description
74 | ///
75 | public override string TypeDescription => "ScalarGrid";
76 |
77 | ///
78 | /// Human Readable TypeName
79 | ///
80 | public override string TypeName => "ScalarGrid";
81 |
82 | ///
83 | /// Underlying ScalarGrid
84 | ///
85 | ///
86 | public override object ScriptVariable()
87 | {
88 | return Value;
89 | }
90 |
91 | ///
92 | /// This function is called when Grasshopper needs to convert this
93 | /// instance of TriStateType into some other type Q.
94 | ///
95 | ///
96 | ///
97 | ///
98 | public override bool CastTo(ref Q target)
99 | {
100 | //First, see if Q is similar to the Integer primitive.
101 | if (typeof(Q).IsAssignableFrom(typeof(string)))
102 | {
103 | target = (Q)(object)ToString();
104 | return true;
105 | }
106 |
107 | //First, see if Q is similar to the Integer primitive.
108 | if (typeof(Q).IsAssignableFrom(typeof(ScalarGrid3D)))
109 | {
110 | object ptr = Value;
111 | target = (Q)ptr;
112 | return true;
113 | }
114 |
115 | //We could choose to also handle casts to Boolean, GH_Boolean,
116 | //Double and GH_Number, but this is left as an exercise for the reader.
117 | return false;
118 | }
119 |
120 | ///
121 | /// This function is called when Grasshopper needs to convert other data
122 | /// into TriStateType.
123 | ///
124 | ///
125 | ///
126 | public override bool CastFrom(object source)
127 | {
128 | //Abort immediately on bogus data.
129 | if (source == null) { return false; }
130 |
131 | //Use the Grasshopper Integer converter. By specifying GH_Conversion.Both
132 | //we will get both exact and fuzzy results. You should always try to use the
133 | //methods available through GH_Convert as they are extensive and consistent.
134 | if (source.GetType().IsAssignableFrom(typeof(ScalarGrid3D)))
135 | {
136 | Value = (ScalarGrid3D)source;
137 | return true;
138 | }
139 |
140 | //We've exhausted the possible conversions, it seems that source
141 | //cannot be converted into a TriStateType after all.
142 | return false;
143 | }
144 | }
145 | }
146 |
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridMeshHull.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using Grasshopper.Kernel.Parameters;
6 | using Rhino.Geometry;
7 | using StudioAvw.Voxels.Geometry;
8 | using StudioAvw.Voxels.Param;
9 | using StudioAvw.Voxels.Helper;
10 |
11 | namespace StudioAvw.Voxels.Components.VoxelGrid
12 | {
13 | ///
14 | /// Create a voxelgrid mesh hull describing the outer hull of the voxel grid
15 | ///
16 | public class VoxelGridMeshHull : GH_Component
17 | {
18 | ///
19 | /// Initializes a new instance of the MyComponent1 class.
20 | ///
21 | public VoxelGridMeshHull()
22 | : base("VoxelGrid To Mesh Hull", "VoxMeshHull",
23 | "Generate a mesh of a Voxelgrid",
24 | "Voxels", "Analysis")
25 | {
26 | }
27 |
28 | ///
29 | /// Registers all the input parameters for this component.
30 | ///
31 | protected override void RegisterInputParams(GH_InputParamManager pManager)
32 | {
33 | pManager.AddParameter(new Param_VoxelGrid());
34 | pManager.AddBooleanParameter("Fake Shadow", "FS", "Add fake shadow to the mesh, it can help to visualize the grid.",
35 | GH_ParamAccess.item, false);
36 | }
37 |
38 | ///
39 | /// Registers all the output parameters for this component.
40 | ///
41 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
42 | {
43 | //FaceDirections = new Vector3d[6] { vg.BBox.Plane.XAxis, -vg.BBox.Plane.XAxis, vg.BBox.Plane.YAxis, -vg.BBox.Plane.YAxis, vg.BBox.Plane.ZAxis, -vg.BBox.Plane.ZAxis };
44 | pManager.AddMeshParameter("Mesh", "M", "A Mesh of the hull of the VoxelGrid", GH_ParamAccess.item);
45 | pManager.AddMeshParameter("+X", "+X", "Meshes with the normal in the X direction", GH_ParamAccess.item);
46 | pManager.AddMeshParameter("-X", "-X", "Meshes with the normal in the -X direction", GH_ParamAccess.item);
47 | pManager.AddMeshParameter("+Y", "+Y", "Meshes with the normal in the Y direction", GH_ParamAccess.item);
48 | pManager.AddMeshParameter("-Y", "-Y", "Meshes with the normal in the -Y direction", GH_ParamAccess.item);
49 | pManager.AddMeshParameter("+Z", "+Z", "Meshes with the normal in the Z direction", GH_ParamAccess.item);
50 | pManager.AddMeshParameter("-Z", "-Z", "Meshes with the normal in the -Z direction", GH_ParamAccess.item);
51 | }
52 |
53 | ///
54 | /// This is the method that actually does the work.
55 | ///
56 | /// The DA object is used to retrieve from inputs and store in outputs.
57 | protected override void SolveInstance(IGH_DataAccess da)
58 | {
59 | /*
60 | * todo: select mesh box or simple box
61 | */
62 | bool fakeShadow = false;
63 | var vg = default(VoxelGrid3D);
64 | da.GetData(0, ref vg);
65 | da.GetData(1, ref fakeShadow);
66 |
67 | var meshes = new List();
68 | if (vg == null || !vg.IsValid)
69 | {
70 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The (input) voxelgrid was invalid");
71 | return;
72 | }
73 |
74 | var m = VoxelGridMeshHelper.VoxelGridToMesh(vg);
75 | try
76 | {
77 | meshes = VoxelGridMeshHelper.VoxelGridToMeshByPlanes(vg);
78 | }
79 | catch (Exception e)
80 | {
81 | throw new Exception($"Creating multiple meshes failed: {e.ToString()}");
82 | }
83 |
84 | if (fakeShadow)
85 | {
86 | VoxelGridMeshHelper.addFakeShadow(ref m, new Vector3d(-0.495633, 0.142501, 0.856762), 1.0, Color.White, Color.Black);
87 | }
88 |
89 | da.SetData(0, m);
90 |
91 | if (meshes.Count == 6)
92 | {
93 | for (var i = 1; i <= meshes.Count; i++)
94 | {
95 | var mesh = meshes[i - 1];
96 | if (fakeShadow)
97 | {
98 | VoxelGridMeshHelper.addFakeShadow(ref mesh, new Vector3d(-0.495633, 0.142501, 0.856762), 1.0,
99 | Color.White, Color.Black);
100 | }
101 | da.SetData(i, mesh);
102 | }
103 | }
104 | else
105 | {
106 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error,"Getting world planes failed");
107 | }
108 | // get top faces
109 | // get bottom faces
110 | }
111 |
112 | ///
113 | /// Provides an Icon for the component.
114 | ///
115 | protected override Bitmap Icon =>
116 | //You can add image files to your project resources and access them like this:
117 | // return Resources.IconForThisComponent;
118 | Images.VT_Decompose;
119 |
120 | ///
121 | /// Gets the unique ID for this component. Do not change this ID after release.
122 | ///
123 | public override Guid ComponentGuid => new Guid("{2C2E9FB7-2018-4F5E-BDA9-C56A171709F0}");
124 | }
125 | }
--------------------------------------------------------------------------------
/VoxelTools/Types/GH_PixelGrid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel.Types;
4 | using Rhino.Geometry;
5 | using StudioAvw.Voxels.Geometry;
6 | using StudioAvw.Voxels.Helper;
7 |
8 | namespace StudioAvw.Voxels.Types
9 | {
10 | ///
11 | /// The GH Wrapper for PixelGrid, that provides metadata, and casting support for PixelGrids.
12 | ///
13 | public class GH_PixelGrid : GH_Goo
14 | {
15 |
16 | ///
17 | /// Constructor: create a new PixelGrid form a previous PixelGrid
18 | ///
19 | ///
20 | public GH_PixelGrid(PixelGrid2D sc)
21 | : base()
22 | {
23 | Value = sc;
24 | }
25 |
26 | ///
27 | /// Create an empty / invalid PixelGrid
28 | ///
29 | public GH_PixelGrid()
30 | : base()
31 | {
32 | }
33 |
34 | ///
35 | /// Duplicate a PixelGrid
36 | ///
37 | ///
38 | public override IGH_Goo Duplicate()
39 | {
40 | var duplicate = new GH_PixelGrid();
41 | duplicate.Value = (PixelGrid2D)Value.Clone();
42 | return duplicate;
43 |
44 | }
45 |
46 | ///
47 | /// Returns true if PixelGrid is Valid
48 | ///
49 | public override bool IsValid => Value.IsValid;
50 |
51 | ///
52 | /// Show a string with information on the PixelGrid
53 | ///
54 | ///
55 | public override string ToString()
56 | {
57 |
58 | if (Value == null)
59 | {
60 | return "Null/void PixelGrid";
61 | }
62 | if (!Value.IsValid)
63 | {
64 | return $"Invalid PixelGrid [{Value.SizeUV.X},{Value.SizeUV.Y}]";
65 | }
66 |
67 | var truecount = 0;
68 | foreach (bool b in Value.Grid)
69 | {
70 | if (b)
71 | {
72 | truecount++;
73 | }
74 | }
75 |
76 | return $"PixelGrid [{Value.SizeUV.X},{Value.SizeUV.Y}={Value.SizeUV.SelfProduct()} true={truecount}]";
77 | }
78 |
79 | ///
80 | /// Human readable type description
81 | ///
82 | public override string TypeDescription => "PixelGrid";
83 |
84 | ///
85 | /// Human Readable TypeName
86 | ///
87 | public override string TypeName => "PixelGrid";
88 |
89 | ///
90 | /// Underlying PixelGrid
91 | ///
92 | ///
93 | public override object ScriptVariable()
94 | {
95 | return Value;
96 | }
97 |
98 | ///
99 | /// This function is called when Grasshopper needs to convert this
100 | /// instance of TriStateType into some other type Q.
101 | ///
102 | ///
103 | ///
104 | ///
105 | public override bool CastTo(ref Q target)
106 | {
107 | //First, see if Q is similar to the Integer primitive.
108 | if (typeof(Q).IsAssignableFrom(typeof(string)))
109 | {
110 | target = (Q)(object)ToString();
111 | return true;
112 | }
113 |
114 | //First, see if Q is similar to the Integer primitive.
115 | if (typeof(Q).IsAssignableFrom(typeof(PixelGrid2D)))
116 | {
117 | object ptr = Value;
118 | target = (Q)ptr;
119 | return true;
120 | }
121 |
122 | if (typeof(Q).IsAssignableFrom(typeof(GH_Mesh)))
123 | {
124 | var m = Value.GenerateMesh(Color.Black, Color.White);
125 | var ghm = new GH_Mesh(m);
126 | target = (Q)(object)ghm;
127 | return true;
128 | }
129 |
130 | //We could choose to also handle casts to Boolean, GH_Boolean,
131 | //Double and GH_Number, but this is left as an exercise for the reader.
132 | return false;
133 | }
134 |
135 | ///
136 | /// This function is called when Grasshopper needs to convert other data
137 | /// into TriStateType.
138 | ///
139 | ///
140 | ///
141 | public override bool CastFrom(object source)
142 | {
143 | //Abort immediately on bogus data.
144 | if (source == null) { return false; }
145 |
146 | //Use the Grasshopper Integer converter. By specifying GH_Conversion.Both
147 | //we will get both exact and fuzzy results. You should always try to use the
148 | //methods available through GH_Convert as they are extensive and consistent.
149 | if (source.GetType().IsAssignableFrom(typeof(PixelGrid2D)))
150 | {
151 | Value = (PixelGrid2D)source;
152 | return true;
153 | }
154 |
155 |
156 | //We've exhausted the possible conversions, it seems that source
157 | //cannot be converted into a TriStateType after all.
158 | return false;
159 | }
160 | }
161 | }
162 |
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridAccessibleRoof.cs:
--------------------------------------------------------------------------------
1 | //
2 | // Copyright (c) 2013 StudioAvw. All rights reserved
3 | // Arend van Waart
4 | //
5 |
6 | using System;
7 | using System.Drawing;
8 | using Grasshopper.Kernel;
9 | using StudioAvw.Voxels.Geometry;
10 | using StudioAvw.Voxels.Param;
11 |
12 | namespace StudioAvw.Voxels.Components.VoxelGrid
13 | {
14 | ///
15 | /// Counts the number of accessible roofs and outputs them in two different lists
16 | ///
17 | public class VoxelGridRoofObsolete : BaseVoxelComponent
18 | {
19 | #region Constructors (1)
20 |
21 | ///
22 | /// Initializes a new instance of the VoxelGridRoofObsolete class.
23 | ///
24 | public VoxelGridRoofObsolete()
25 | : base("VoxelGrid RoofAccess", "VoxGridRoof",
26 | "Check if voxels have accessible roof pixels",
27 | "Voxels", "Analysis")
28 | {
29 | }
30 |
31 | #endregion Constructors
32 |
33 | #region Properties (2)
34 |
35 | ///
36 | /// Gets the unique ID for this component. Do not change this ID after release.
37 | ///
38 | public override Guid ComponentGuid => new Guid("{FB7ED4B6-421B-4302-AA5B-DADA34AA2CCA}");
39 |
40 | ///
41 | /// Provides an Icon for the component.
42 | ///
43 | protected override Bitmap Icon =>
44 | //You can add image files to your project resources and access them like this:
45 | // return Resources.IconForThisComponent;
46 | Images.VT_Statistics;
47 |
48 | #endregion Properties
49 |
50 | #region Methods (3)
51 |
52 | // Protected Methods (3)
53 |
54 | ///
55 | /// Registers all the input parameters for this component.
56 | ///
57 | protected override void RegisterInputParams(GH_InputParamManager pManager)
58 | {
59 | pManager.AddParameter(new Param_VoxelGrid());
60 | }
61 |
62 | ///
63 | /// Registers all the output parameters for this component.
64 | ///
65 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
66 | {
67 | pManager.AddParameter(new Param_VoxelGrid(), "HasAccessible", "HA", "Voxels with roof access", GH_ParamAccess.item);
68 | pManager.AddParameter(new Param_VoxelGrid(), "IsRoof", "IR", "Voxels with roofs that can be accessed", GH_ParamAccess.item);
69 | pManager.AddParameter(new Param_VoxelGrid(), "Access via stairs", "AS", "Voxels access via stairs", GH_ParamAccess.item);
70 | }
71 |
72 | ///
73 | /// This is the method that actually does the work.
74 | ///
75 | /// The DA object is used to retrieve from inputs and store in outputs.
76 | protected override void SolveInstance(IGH_DataAccess DA)
77 | {
78 | var vg = default(VoxelGrid3D);
79 | DA.GetData(0, ref vg);
80 |
81 | var isRoof = new VoxelGrid3D(vg.BBox, vg.VoxelSize);
82 | var hasAccessible = new VoxelGrid3D(vg.BBox, vg.VoxelSize);
83 | var accessViaStairs = new VoxelGrid3D(vg.BBox, vg.VoxelSize);
84 |
85 | var tr = new Point3i(0, 0, 1);
86 | var t1 = new Point3i(0, 1, 1);
87 | var t2 = new Point3i(1, 0, 1);
88 | var t3 = new Point3i(-1, 0, 1);
89 | var t4 = new Point3i(0, -1, 1);
90 |
91 | for (var i = 0; i < vg.Count; i++)
92 | {
93 | if (vg[i] == false)
94 | {
95 | continue;
96 | }
97 | // there's nothing above us.. only sky
98 | if (vg.GetRelativePointValue(i, tr) == 0)
99 | {
100 | var accessible = false;
101 | if (vg.GetRelativePointValue(i, t1) == 1)
102 | {
103 | accessible = true;
104 | hasAccessible.SetRelativePointValue(i, t1, true);
105 | }
106 | if (vg.GetRelativePointValue(i, t2) == 1)
107 | {
108 | accessible = true;
109 | hasAccessible.SetRelativePointValue(i, t2, true);
110 | }
111 | if (vg.GetRelativePointValue(i, t3) == 1)
112 | {
113 | accessible = true;
114 | hasAccessible.SetRelativePointValue(i, t3, true);
115 | }
116 | if (vg.GetRelativePointValue(i, t4) == 1)
117 | {
118 | accessible = true;
119 | hasAccessible.SetRelativePointValue(i, t4, true);
120 | }
121 |
122 | if (accessible)
123 | {
124 | isRoof[i] = true;
125 | }
126 | else
127 | {
128 | accessViaStairs[i] = true;
129 | }
130 | }
131 | }
132 |
133 | DA.SetData(0, hasAccessible);
134 | DA.SetData(1, isRoof);
135 | DA.SetData(2, accessViaStairs);
136 | }
137 |
138 | public override GH_Exposure Exposure => GH_Exposure.hidden;
139 |
140 | #endregion Methods
141 | }
142 | }
--------------------------------------------------------------------------------
/VoxelTools/Components/PixelGrid/PixelGridPixelateComponent.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using Grasshopper.Kernel.Types;
6 | using Rhino.Geometry;
7 | using StudioAvw.Voxels.Geometry;
8 | using StudioAvw.Voxels.Param;
9 | using StudioAvw.Voxels.Helper;
10 | using StudioAvw.Voxels.Types;
11 |
12 | namespace StudioAvw.Voxels.Components.PixelGrid
13 | {
14 | ///
15 | /// Add brep to the voxelgrid
16 | /// WARNING: This is an experiment without any useful application
17 | ///
18 | public class PixelGridPixelateComponent : GH_Component
19 | {
20 | ///
21 | /// Initializes a new instance of the MyComponent1 class.
22 | ///
23 | public PixelGridPixelateComponent()
24 | : base("PixelateGeometry", "PixGeo",
25 | "Adds any geometry to a PixelGrid",
26 | "Pixels", "Create")
27 | {
28 | }
29 |
30 | ///
31 | /// Registers all the input parameters for this component.
32 | ///
33 | protected override void RegisterInputParams(GH_InputParamManager pManager)
34 | {
35 | pManager.AddGeometryParameter("Geometry","G", "Geometry to voxelate", GH_ParamAccess.list);
36 | pManager.AddParameter(new Param_PixelGrid());
37 | }
38 |
39 | ///
40 | /// Registers all the output parameters for this component.
41 | ///
42 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
43 | {
44 | pManager.AddParameter(new Param_PixelGrid());
45 | }
46 |
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess DA)
53 | {
54 | //1 divide the brep by the Z components of the grid (get Z values on plane of the grid
55 | //2 intersect the grid for reach Z value -> planar surface the results
56 | //3 check for each pixel if it is closer than the
57 | var geometry = DA.FetchList(0);
58 | var pg = DA.Fetch(1);
59 | pg = (PixelGrid2D)pg.Clone();
60 |
61 | if (pg == null || !pg.IsValid)
62 | {
63 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The (input) voxelgrid was invalid");
64 | return;
65 | }
66 |
67 |
68 | var geometryIndex = new Dictionary();
69 | for (int i = 0, count = geometry.Count; i < count; i++)
70 | {
71 | geometryIndex.Add(i, geometry[i]);
72 | }
73 |
74 | var ptList = GeometryHelper.TryCastGeometry(geometryIndex, false);
75 | var curveList = GeometryHelper.TryCastGeometry(geometryIndex, false);
76 |
77 | foreach (var pt in ptList.Values)
78 | {
79 | AddPoint3d(pg, pt);
80 | }
81 |
82 | foreach (var c in curveList.Values)
83 | {
84 | AddCurve(pg, c);
85 | }
86 |
87 | DA.SetData(0, new GH_PixelGrid((PixelGrid2D) pg.Clone()));
88 |
89 | }
90 |
91 | private void AddCurve(PixelGrid2D pg, Curve c)
92 | {
93 | var projection = Transform.PlanarProjection(pg.Plane);
94 | c.Transform(projection);
95 |
96 | if (c.IsClosed)
97 | {
98 | var bb = c.GetBoundingBox(pg.Plane);
99 | PixelGrid2D.EnumeratePixels testDelB
100 | = delegate(int i) {
101 |
102 | };
103 |
104 | for (var i = 0; i < pg.Count; i++)
105 | {
106 | var pt = pg.PointAt(i);
107 | var pc = c.Contains(pt, pg.Plane);
108 | if (pc.HasFlag(PointContainment.Inside) || pc.HasFlag(PointContainment.Coincident))
109 | {
110 | pg.SetValue(i, true);
111 | }
112 | }
113 | }
114 | }
115 |
116 | private void AddPoint3d(PixelGrid2D pg, Point3d pt)
117 | {
118 | pg.Plane.RemapToPlaneSpace(pt, out var p);
119 | var ix = (p.X - pg.BBox.X.Min - pg.PixelSize.X / 2) / pg.PixelSize.X;
120 | var iy = (p.Y - pg.BBox.Y.Min - pg.PixelSize.Y / 2) / pg.PixelSize.Y;
121 |
122 |
123 | var pti = pg.ClosestPoint(pt);
124 |
125 | pti = new Point2i(ix, iy);
126 | if (new Point2i(0, 0) > pti || pti >= pg.SizeUV)
127 | {
128 | return;
129 | }
130 | pg[pti] = true;
131 | }
132 |
133 |
134 | ///
135 | /// Provides an Icon for the component.
136 | ///
137 | protected override Bitmap Icon =>
138 | //You can add image files to your project resources and access them like this:
139 | // return Resources.IconForThisComponent;
140 | Images.VT_VoxelateBrep;
141 |
142 | ///
143 | /// Gets the unique ID for this component. Do not change this ID after release.
144 | ///
145 | public override Guid ComponentGuid => new Guid("{B646EB8C-7FC4-4880-88B4-307BACD4B77C}");
146 |
147 | public override GH_Exposure Exposure => GH_Exposure.hidden;
148 | }
149 | }
--------------------------------------------------------------------------------
/VoxelTools/Types/GH_VoxelGrid.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel.Types;
4 | using Rhino.Geometry;
5 | using StudioAvw.Voxels.Geometry;
6 | using StudioAvw.Voxels.Helper;
7 |
8 | namespace StudioAvw.Voxels.Types
9 | {
10 | ///
11 | /// The GH_VoxelGrid data type. Takes care of casting from and to voxelgrids.
12 | ///
13 | public class GH_VoxelGrid : GH_Goo
14 | {
15 |
16 | public GH_VoxelGrid() { }
17 | public GH_VoxelGrid(VoxelGrid3D grid)
18 | {
19 | Value = (VoxelGrid3D) grid.Clone();
20 | }
21 | ///
22 | /// Duplicate the Voxel Grid
23 | ///
24 | ///
25 | public override IGH_Goo Duplicate()
26 | {
27 |
28 | var duplicate = new GH_VoxelGrid();
29 | duplicate.Value = (VoxelGrid3D) Value.Clone();
30 | return duplicate;
31 |
32 | }
33 |
34 | ///
35 | /// Returns true if grid is valid
36 | ///
37 | public override bool IsValid => Value.IsValid;
38 |
39 | ///
40 | /// Creates a string of the voxelgrid
41 | ///
42 | ///
43 | public override string ToString()
44 | {
45 | if (Value == null)
46 | {
47 | return "Null/void Voxelgrid";
48 | }
49 | if (!Value.IsValid)
50 | {
51 | return $"Invalid VoxelGrid [{Value.SizeUVW.X},{Value.SizeUVW.Y},{Value.SizeUVW.Z}]";
52 | }
53 | return
54 | $"VoxelGrid [{Value.SizeUVW.X},{Value.SizeUVW.Y},{Value.SizeUVW.Z}={Value.SizeUVW.SelfProduct()}] True = {Value.CountNonZero}";
55 |
56 | }
57 |
58 |
59 | ///
60 | /// Returns a human readable explanation of the tpye
61 | ///
62 | public override string TypeDescription => "VoxelGrid";
63 |
64 | ///
65 | /// Type of component
66 | ///
67 | public override string TypeName => "VoxelGrid";
68 |
69 | ///
70 | /// Returns the underlying voxelgrid
71 | ///
72 | /// VoxelGrid
73 | public override object ScriptVariable()
74 | {
75 | return Value;
76 | }
77 |
78 |
79 | ///
80 | /// This function is called when Grasshopper needs to convert this
81 | /// instance of TriStateType into some other type Q.
82 | ///
83 | ///
84 | ///
85 | ///
86 | public override bool CastTo(ref Q target)
87 | {
88 | //First, see if Q is similar to the Integer primitive.
89 | if (typeof(Q).IsAssignableFrom(typeof(VoxelGrid3D)))
90 | {
91 | object ptr = Value;
92 | target = (Q)ptr;
93 | return true;
94 | }
95 |
96 | if (typeof(Q).IsAssignableFrom(typeof(GH_Mesh)))
97 | {
98 | var m = VoxelGridMeshHelper.VoxelGridToMesh(Value);
99 | // don't add fake meshes..
100 | // VoxelGridMeshHelper.addFakeShadow(ref m, new Vector3d(-0.495633, 0.142501, 0.856762), 1.0, Color.White, Color.Black);
101 | var ghm = new GH_Mesh(m);
102 | target = (Q)(object)ghm;
103 | return true;
104 | }
105 |
106 | //First, see if Q is similar to the Integer primitive.
107 | if (typeof(Q).IsAssignableFrom(typeof(string)))
108 | {
109 | target = (Q)(object)ToString();
110 | return true;
111 | }
112 |
113 | //We could choose to also handle casts to Boolean, GH_Boolean,
114 | //Double and GH_Number, but this is left as an exercise for the reader.
115 | return false;
116 | }
117 |
118 |
119 | ///
120 | /// This function is called when Grasshopper needs to convert other data
121 | /// into TriStateType.
122 | ///
123 | ///
124 | ///
125 | public override bool CastFrom(object source)
126 | {
127 | //Abort immediately on bogus data.
128 | if (source == null) { return false; }
129 |
130 | //Use the Grasshopper Integer converter. By specifying GH_Conversion.Both
131 | //we will get both exact and fuzzy results. You should always try to use the
132 | //methods available through GH_Convert as they are extensive and consistent.
133 | if (source.GetType().IsAssignableFrom(typeof(VoxelGrid3D)))
134 | {
135 | Value = (VoxelGrid3D) ((VoxelGrid3D)source).Clone();
136 | return true;
137 | }
138 | //We've exhausted the possible conversions, it seems that source
139 | //cannot be converted into a TriStateType after all.
140 | return false;
141 | }
142 |
143 | /*
144 | public override bool Write(GH_IO.Serialization.GH_IWriter writer)
145 | {
146 | bool rc = base.Write(writer);
147 | writer.RemoveChunk("PersistentData");
148 | // save structure
149 | writer.SetString("PersistentDataHack", myZippedString);
150 |
151 | }
152 |
153 | public override bool Read(GH_IO.Serialization.GH_IReader reader)
154 | {
155 | reader.GetString(
156 | }*/
157 | }
158 | }
159 |
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridBoxes.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 | using Grasshopper.Kernel;
8 | using Grasshopper.Kernel.Parameters;
9 | using Grasshopper.Kernel.Types;
10 | using Rhino.Geometry;
11 | using StudioAvw.Voxels.Geometry;
12 | using StudioAvw.Voxels.Helper;
13 | using StudioAvw.Voxels.Param;
14 |
15 | namespace StudioAvw.Voxels.Components.VoxelGrid
16 | {
17 |
18 |
19 | ///
20 | /// Converts voxels to their containing boxes
21 | ///
22 | public class VoxelGridBoxes : GH_Component
23 | {
24 | /// TODO: Add this class as old/replaced
25 | /// Add new class that implements the points in a correct way
26 | /// This class has been used before to enumerate all the points in a grid
27 | ///
28 | /// Initializes a new instance of the MyComponent1 class.
29 | ///
30 | public VoxelGridBoxes()
31 | : base("VoxelGrid To Boxes", "VoxBox",
32 | "Get a list of boxes from a voxelgrid. Warning: Can severely slow down your computer for large grids.",
33 | "Voxels", "Analysis")
34 | {
35 | }
36 |
37 | public enum SelectionType
38 | {
39 | True = 1,
40 | False = 0,
41 | All = -1,
42 | }
43 |
44 | ///
45 | /// Registers all the input parameters for this component.
46 | ///
47 | protected override void RegisterInputParams(GH_InputParamManager pManager)
48 | {
49 | pManager.AddParameter(new Param_VoxelGrid());
50 | var param = new Param_Integer();
51 | DataAccessHelper.AddEnumOptionsToParam(param);
52 | param.PersistentData.Append(new GH_Integer(1));
53 | pManager.AddParameter(new Param_Integer(), "Selection", "S", "0 = all false voxels, 1 = all true voxels (default), -1 = all voxels", GH_ParamAccess.item);
54 | }
55 |
56 | ///
57 | /// Registers all the output parameters for this component.
58 | ///
59 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
60 | {
61 | pManager.AddBoxParameter("Boxes", "BOX", "A list of boxes that are contained in the grid", GH_ParamAccess.list);
62 | pManager.AddPointParameter("Points", "PTS", "A list of all points contained", GH_ParamAccess.list);
63 | }
64 |
65 | ///
66 | /// This is the method that actually does the work.
67 | ///
68 | /// The DA object is used to retrieve from inputs and store in outputs.
69 | protected override void SolveInstance(IGH_DataAccess da)
70 | {
71 | /*
72 | * todo: select mesh box or simple box
73 | */
74 | var vg = default(VoxelGrid3D);
75 | da.GetData(0, ref vg);
76 | if (vg == null || !vg.IsValid)
77 | {
78 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "The (input) voxelgrid was invalid");
79 | return;
80 | }
81 |
82 | vg = (VoxelGrid3D)vg.Clone();
83 |
84 | int selectionInt = 0;
85 | if (!da.GetData(1, ref selectionInt) || selectionInt < -1 || selectionInt > 1)
86 | {
87 | AddRuntimeMessage(GH_RuntimeMessageLevel.Error, "Invalid selection given, only -1, 0, or 1 are valid values");
88 | }
89 |
90 | var type = (SelectionType) selectionInt;
91 |
92 | var boxes = new List();
93 | var values = new List();
94 |
95 | switch (type)
96 | {
97 | case SelectionType.True:
98 | for (var i = 0; i < vg.SizeUVW.SelfProduct(); i++)
99 | {
100 | if (!vg.GetValue(i)) continue;
101 |
102 | boxes.Add(vg.CreateBox(i));
103 | values.Add(vg.EvaluatePoint(i));
104 | }
105 | break;
106 | case SelectionType.False:
107 | for (var i = 0; i < vg.SizeUVW.SelfProduct(); i++)
108 | {
109 | if (vg.GetValue(i)) continue;
110 |
111 | boxes.Add(vg.CreateBox(i));
112 | values.Add(vg.EvaluatePoint(i));
113 | }
114 | break;
115 | case SelectionType.All:
116 | for (var i = 0; i < vg.SizeUVW.SelfProduct(); i++)
117 | {
118 | boxes.Add(vg.CreateBox(i));
119 | values.Add(vg.EvaluatePoint(i));
120 | }
121 | break;
122 | default:
123 | // this should never happen, validated above.
124 | throw new ArgumentOutOfRangeException();
125 | }
126 |
127 | da.SetDataList(0, boxes);
128 | da.SetDataList(1, values);
129 | }
130 |
131 | ///
132 | /// Provides an Icon for the component.
133 | ///
134 | protected override Bitmap Icon =>
135 | //You can add image files to your project resources and access them like this:
136 | // return Resources.IconForThisComponent;
137 | Images.VT_Boxes;
138 |
139 | ///
140 | /// Gets the unique ID for this component. Do not change this ID after release.
141 | ///
142 | public override Guid ComponentGuid => new Guid("{01E3D92A-DD7D-4A20-B754-20186CC5AC8D}");
143 | }
144 | }
145 |
--------------------------------------------------------------------------------
/VoxelTools/Components/VoxelGrid/VoxelGridStatistics.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Drawing;
3 | using Grasshopper.Kernel;
4 | using StudioAvw.Voxels.Geometry;
5 | using StudioAvw.Voxels.Param;
6 |
7 | namespace StudioAvw.Voxels.Components.VoxelGrid
8 | {
9 |
10 | ///
11 | /// Get numerical statistics about the voxel grid
12 | ///
13 | public class VoxelGridStatistics : BaseVoxelComponent
14 | {
15 | ///
16 | /// Initializes a new instance of the MyComponent1 class.
17 | ///
18 | public VoxelGridStatistics()
19 | : base("VoxelGrid Statistics", "VoxGridStat",
20 | "Get numerical statistics of a voxelgrid",
21 | "Voxels", "Analysis")
22 | {
23 | }
24 |
25 | ///
26 | /// Registers all the input parameters for this component.
27 | ///
28 | protected override void RegisterInputParams(GH_InputParamManager pManager)
29 | {
30 | pManager.AddParameter(new Param_VoxelGrid());
31 | }
32 |
33 | ///
34 | /// Registers all the output parameters for this component.
35 | ///
36 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
37 | {
38 | pManager.AddNumberParameter("Surfaces", "F", "The amount of surfaces in the grid", GH_ParamAccess.item);
39 | pManager.AddNumberParameter("Facade", "F", "The amount of facades in the grid", GH_ParamAccess.item);
40 | pManager.AddNumberParameter("Terraces", "T", "The amount of terraces in the grid", GH_ParamAccess.item);
41 | pManager.AddNumberParameter("Overhang", "O", "The amount of overhanging faces in the grid", GH_ParamAccess.item);
42 | pManager.AddNumberParameter("Footprint", "Fp", "The amount of surfaces touching the ground", GH_ParamAccess.item);
43 | pManager.AddNumberParameter("VoxelCount", "Vc", "The amount of cells in the grid", GH_ParamAccess.item);
44 | pManager.AddNumberParameter("VoidCount", "VoC", "The amount of void in the grid", GH_ParamAccess.item);
45 | pManager.AddNumberParameter("Porosity", "P", "The area per volume ratio (meters)", GH_ParamAccess.item);
46 | }
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess DA)
53 | {
54 | var vg = default(VoxelGrid3D);
55 | DA.GetData(0, ref vg);
56 | var facade = 0;
57 | double facadeArea = 0;
58 |
59 | var terraces = 0;
60 | double terraceArea = 0;
61 |
62 | var trusses = 0;
63 | double trussArea = 0;
64 |
65 | var floor = 0;
66 | double floorArea = 0;
67 |
68 |
69 | var f1 = new Point3i(1, 0, 0);
70 | var f2 = new Point3i(0, 1, 0);
71 | var f3 = new Point3i(-1, 0, 0);
72 | var f4 = new Point3i(0, -1, 0);
73 | var t1 = new Point3i(0, 0, 1);
74 | var tr = new Point3i(0, 0, -1);
75 |
76 | for (var i = 0; i < vg.Count; i++)
77 | {
78 | if (vg[i] == false)
79 | {
80 | continue;
81 | }
82 |
83 | if (vg.GetRelativePointValue(i, f1) != 1)
84 | {
85 | facade++;
86 | facadeArea += vg.VoxelSize.Y*vg.VoxelSize.Z;
87 | }
88 | if (vg.GetRelativePointValue(i, f2) != 1)
89 | {
90 | facade++;
91 | facadeArea += vg.VoxelSize.X * vg.VoxelSize.Z;
92 | }
93 | if (vg.GetRelativePointValue(i, f3) != 1)
94 | {
95 | facade++;
96 | facadeArea += vg.VoxelSize.Y * vg.VoxelSize.Z;
97 | }
98 | if (vg.GetRelativePointValue(i, f4) != 1)
99 | {
100 | facade++;
101 | facadeArea += vg.VoxelSize.X * vg.VoxelSize.Z;
102 | }
103 | if (vg.GetRelativePointValue(i, t1) != 1)
104 | {
105 | terraces++;
106 | terraceArea += vg.VoxelSize.X * vg.VoxelSize.Z;
107 | }
108 | if (vg.GetRelativePointValue(i, tr) == 0)
109 | {
110 | trusses++;
111 | trussArea += vg.VoxelSize.X * vg.VoxelSize.Z;
112 | }
113 | if (vg.GetRelativePointValue(i, tr) == -1)
114 | {
115 | floor++;
116 | floorArea += vg.VoxelSize.X * vg.VoxelSize.Z;
117 | }
118 | }
119 |
120 | DA.SetData("Surfaces", facade + terraces +floor + trusses);
121 | DA.SetData("Facade", facade);
122 | DA.SetData("Terraces", terraces);
123 | DA.SetData("Overhang", trusses);
124 | DA.SetData("Footprint", floor);
125 | var gridCount = vg.CountNonZero;
126 | DA.SetData("VoxelCount", gridCount);
127 | DA.SetData("VoidCount", vg.Count - gridCount);
128 | DA.SetData("Porosity", (facadeArea + terraceArea + trussArea + floorArea) / (gridCount * vg.VoxelSize[0] * vg.VoxelSize[1] * vg.VoxelSize[2]));
129 | }
130 |
131 | ///
132 | /// Provides an Icon for the component.
133 | ///
134 | protected override Bitmap Icon =>
135 | //You can add image files to your project resources and access them like this:
136 | // return Resources.IconForThisComponent;
137 | Images.VT_Statistics;
138 |
139 | ///
140 | /// Gets the unique ID for this component. Do not change this ID after release.
141 | ///
142 | public override Guid ComponentGuid => new Guid("{19412CC0-E6FC-4D89-BA7C-70D1DC23AD33}");
143 | }
144 | }
--------------------------------------------------------------------------------
/VoxelGeometry/BitGrid3D.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections;
3 |
4 | namespace StudioAvw.Voxels.Geometry
5 | {
6 | ///
7 | /// A bit grid is a simple x,y,z grid containing boolean values
8 | ///
9 | public class BitGrid3D : Grid3D
10 | {
11 | #region Constructors (1)
12 |
13 | ///
14 | /// Create empty bit grid
15 | ///
16 | public BitGrid3D() { }
17 |
18 | #endregion Constructors
19 |
20 | #region Properties (1)
21 |
22 | ///
23 | /// Count the amount of true values in the grid
24 | ///
25 | public int CountNonZero
26 | {
27 | get
28 | {
29 | var count = 0;
30 | if (Grid == null)
31 | {
32 | return 0;
33 | }
34 | for (var i = 0; i < Grid.Count; i++)
35 | {
36 | if (GetValue(i))
37 | {
38 | count++;
39 | }
40 | }
41 | return count;
42 | }
43 | }
44 |
45 | #endregion Properties
46 |
47 | #region Methods (12)
48 |
49 | // Public Methods (12)
50 |
51 | ///
52 | /// Set the values to the result of an AND operation with grid bt
53 | ///
54 | ///
55 | public void And(BitGrid3D bt)
56 | {
57 | if (bt.Count != Count)
58 | {
59 | throw new Exception("Grids are of different sizes");
60 | }
61 |
62 | for (var i = 0; i < Count; i++)
63 | {
64 | SetValue(i, GetValue(i) && bt.GetValue(i));
65 | }
66 | }
67 |
68 | ///
69 | /// Clone the object
70 | ///
71 | ///
72 | public override object Clone()
73 | {
74 | return MemberwiseClone();
75 | }
76 |
77 | ///
78 | /// Get the enumerator of the grid
79 | ///
80 | ///
81 | public override IEnumerator GetEnumerator()
82 | {
83 | return Grid.GetEnumerator();
84 | }
85 |
86 | ///
87 | /// Get the value of a relativePosition voxel, defined by a Point3i size.
88 | ///
89 | ///
90 | ///
91 | ///
92 | /// returns 0 if empty
93 | /// returns -1 if non existant
94 | /// returns 1 if true
95 | ///
96 | ///
97 | public sbyte GetRelativePointValue(int voxelIndex, Point3i relativePosition)
98 | {
99 | var pt = (Point3i.IndexToPointUvw(SizeUVW, voxelIndex)) + relativePosition;
100 | if (new Point3i(0, 0, 0) > pt || pt >= SizeUVW)
101 | {
102 | return -1;
103 | }
104 | return GetValue(pt) ? (sbyte)1 : (sbyte)0;
105 | }
106 |
107 | ///
108 | /// Get value of point voxelIndex
109 | ///
110 | ///
111 | ///
112 | public override bool GetValue(int voxelIndex)
113 | {
114 | return Grid.Get(voxelIndex);
115 | }
116 |
117 | ///
118 | /// Inverse the grid
119 | ///
120 | public void Not()
121 | {
122 | for (var i = 0; i < Count; i++)
123 | {
124 | SetValue(i, (!GetValue(i)));
125 | }
126 | }
127 |
128 | ///
129 | /// Set values to the result of an OR operation with grid bt
130 | ///
131 | ///
132 | public void Or(BitGrid3D bt)
133 | {
134 | if (bt.Count != Count)
135 | {
136 | throw new Exception("Grids are of different sizes");
137 | }
138 |
139 | for (var idx = 0; idx < Count; idx++)
140 | {
141 | SetValue(idx, GetValue(idx) || bt.GetValue(idx));
142 | }
143 | }
144 |
145 | ///
146 | /// Set a relativePosition point value to value X
147 | ///
148 | ///
149 | ///
150 | ///
151 | public void SetRelativePointValue(int voxelIndex, Point3i relativePosition, bool value)
152 | {
153 | var pt = Point3i.IndexToPointUvw(SizeUVW, voxelIndex) + relativePosition;
154 | if (new Point3i(0, 0, 0) > pt || pt >= SizeUVW)
155 | {
156 | return;
157 | }
158 |
159 | this[pt] = value;
160 | }
161 |
162 | ///
163 | /// Set point to value bool
164 | ///
165 | /// voxel index
166 | ///
167 | public override void SetValue(int voxelIndex, bool value)
168 | {
169 | if (voxelIndex >= Grid.Count || voxelIndex < 0)
170 | {
171 | return;
172 | }
173 | Grid.Set(voxelIndex, value);
174 | }
175 |
176 | ///
177 | /// Set the result to be the result of a subtraction with grid bt
178 | ///
179 | ///
180 | public void Subtract(BitGrid3D bt)
181 | {
182 | if (bt.Count != Count)
183 | {
184 | throw new Exception("Grids are of different sizes");
185 | }
186 |
187 | for (var i = 0; i < Count; i++)
188 | {
189 | if (this[i] && bt[i])
190 | {
191 | this[i] = false;
192 | }
193 | }
194 | }
195 |
196 | ///
197 | /// Set the values of this grid to the result of a XOR operation with grid bt.
198 | ///
199 | ///
200 | public void Xor(BitGrid3D bt)
201 | {
202 | if (bt.Count != Count)
203 | {
204 | throw new Exception("Grids are of different sizes");
205 | }
206 |
207 | for (var i = 0; i < Count; i++)
208 | {
209 | SetValue(i, GetValue(i) ^ bt.GetValue(i));
210 | }
211 | }
212 |
213 | #endregion Methods
214 | }
215 | }
216 |
--------------------------------------------------------------------------------
/VoxelTools/Components/Obsolete/VoxelGridLimiterObsolete.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Drawing;
4 | using Grasshopper.Kernel;
5 | using StudioAvw.Voxels.Components.VoxelGrid;
6 | using StudioAvw.Voxels.Geometry;
7 | using StudioAvw.Voxels.Param;
8 |
9 | namespace StudioAvw.Voxels.Components.Obsolete
10 | {
11 | ///
12 | /// Component that adds or removes voxels from a grid to meet a fixed amount of voxels.
13 | /// [Obsolete] This script was used in the why factory, but was always a bad idea anyway.
14 | ///
15 | public class VoxelGridLimiterObsolete : BaseVoxelComponent
16 | {
17 | ///
18 | /// Initializes a new instance of the MyComponent1 class.
19 | ///
20 | public VoxelGridLimiterObsolete()
21 | : base("VoxelGrid Limit Amount of Voxels", "VoxGridLimit",
22 | "Limit the amount of voxels in the grid",
23 | "Voxels", "Create")
24 | {
25 |
26 | }
27 |
28 | ///
29 | /// Registers all the input parameters for this component.
30 | ///
31 | protected override void RegisterInputParams(GH_InputParamManager pManager)
32 | {
33 | pManager.AddParameter(new Param_VoxelGrid());
34 | pManager.AddParameter(new Param_VoxelGrid(), "Exclusion zome", "EVG", "A grid with voxels that cannot be accessed", GH_ParamAccess.item);
35 | pManager[1].Optional = true;
36 | pManager.AddIntegerParameter("Limit", "L", "Limit the amount to voxels to this amount", GH_ParamAccess.item);
37 | }
38 |
39 | ///
40 | /// Registers all the output parameters for this component.
41 | ///
42 | protected override void RegisterOutputParams(GH_OutputParamManager pManager)
43 | {
44 |
45 | pManager.AddParameter(new Param_VoxelGrid());
46 | }
47 |
48 | ///
49 | /// This is the method that actually does the work.
50 | ///
51 | /// The DA object is used to retrieve from inputs and store in outputs.
52 | protected override void SolveInstance(IGH_DataAccess da)
53 | {
54 | var vg = default(VoxelGrid3D);
55 | da.GetData(0, ref vg);
56 |
57 | vg = (VoxelGrid3D) vg.Clone();
58 |
59 | var i = 0;
60 | da.GetData(2, ref i);
61 |
62 | if (vg.CountNonZero > i)
63 | {
64 | LimitGrid(ref vg, i);
65 |
66 | } else if (vg.CountNonZero < i)
67 | {
68 | IncreaseGrid(ref vg, i);
69 | }
70 | AddRenderGrid(vg);
71 | da.SetData(0, vg);
72 | }
73 |
74 | private void IncreaseGrid(ref VoxelGrid3D vg, int count)
75 | {
76 | var trueCount = vg.CountNonZero;
77 | var possibleLocations = new List();
78 | var foundRoof = false;
79 | for (var z = vg.SizeUVW.Z - 1; z >= 0; z--)
80 | {
81 | if (foundRoof)
82 | {
83 | break;
84 | }
85 |
86 | for (var y = 0; y < vg.SizeUVW.Y; y++)
87 | {
88 | for (var x = 0; x < vg.SizeUVW.X; x++)
89 | {
90 | var pt = new Point3i(x, y, z);
91 | if (vg[pt] != true) continue;
92 | foundRoof = true;
93 | possibleLocations.Add(Point3i.PointUvwToIndex(vg.SizeUVW, pt));
94 | }
95 | }
96 | }
97 |
98 | // location division
99 | // goal-current
100 | // difference: the first x voxels get extra.
101 | // then add x voxels to each location.
102 |
103 | var difference = count - trueCount;
104 | var height = Convert.ToInt32(Math.Floor((double)difference / possibleLocations.Count));
105 | var rest = difference % possibleLocations.Count;
106 |
107 | for (var i = 0; i < possibleLocations.Count; i++)
108 | {
109 | var makeheight = height;
110 | if (rest > 0)
111 | {
112 | makeheight += 1;
113 | rest--;
114 | }
115 |
116 | for (var j = 1; j <= makeheight; j++)
117 | {
118 | var pt = new Point3i(0, 0, j);
119 | var position = Point3i.IndexToPointUvw(vg.SizeUVW, possibleLocations[i]) + pt;
120 | vg[position] = true;
121 | }
122 | }
123 |
124 | if (vg.CountNonZero != count)
125 | {
126 | // the grid is empty / reaches to the roof.
127 | // add from the bottom.
128 | IncreaseGridFromBottom(ref vg, count);
129 | }
130 |
131 |
132 | }
133 |
134 | ///
135 | /// Add voxels to the grid building up from the bottom to the top.
136 | ///
137 | /// VoxelGrid
138 | /// Amount of voxels to be added.
139 | private void IncreaseGridFromBottom(ref VoxelGrid3D vg, int count)
140 | {
141 | var trueIncCount = vg.CountNonZero;
142 | for (var z = 0; z < vg.SizeUVW.Z; z++)
143 | {
144 | for (var y = 0; y < vg.SizeUVW.Y; y++)
145 | {
146 | for (var x = 0; x < vg.SizeUVW.X; x++)
147 | {
148 | var pt = new Point3i(x, y, z);
149 | if (vg[pt] == false)
150 | {
151 | vg[pt] = true;
152 | trueIncCount++;
153 | if (trueIncCount == count)
154 | {
155 | return;
156 | }
157 | }
158 | }
159 | }
160 | }
161 | }
162 |
163 | private static void LimitGrid(ref VoxelGrid3D vg, int i)
164 | {
165 | // limit, start with Z size.
166 | var trueCount = vg.CountNonZero;
167 | for (var z = vg.SizeUVW.Z - 1; z >= 0; z--)
168 | {
169 | for (var y = 0; y < vg.SizeUVW.Y; y++)
170 | {
171 | for (var x = 0; x < vg.SizeUVW.X; x++)
172 | {
173 | if (vg[new Point3i(x, y, z)])
174 | {
175 | vg[new Point3i(x, y, z)] = false;
176 | trueCount--;
177 | }
178 | if (trueCount == i)
179 | {
180 | return;
181 | }
182 | }
183 | }
184 | }
185 | }
186 |
187 | public override GH_Exposure Exposure => GH_Exposure.hidden;
188 |
189 | ///
190 | /// Provides an Icon for the component.
191 | ///
192 | protected override Bitmap Icon =>
193 | //You can add image files to your project resources and access them like this:
194 | // return Resources.IconForThisComponent;
195 | Images.VT_Statistics;
196 |
197 | ///
198 | /// Gets the unique ID for this component. Do not change this ID after release.
199 | ///
200 | public override Guid ComponentGuid => new Guid("{E7A9CAF0-D295-4A4D-937D-550EF3EE3944}");
201 | }
202 | }
--------------------------------------------------------------------------------
/VoxelGeometry/Grid2D.cs:
--------------------------------------------------------------------------------
1 | // -----------------------------------------------------------------------
2 | //
3 | // TODO: Update copyright text.
4 | //
5 | // -----------------------------------------------------------------------
6 |
7 | using System;
8 | using System.Collections;
9 | using Rhino.Geometry;
10 | using StudioAvw.Voxels.Geometry.Interfaces;
11 |
12 | namespace StudioAvw.Voxels.Geometry
13 | {
14 | ///
15 | /// A 2d optimized alternative to the voxelgrid.
16 | ///
17 | public abstract class Grid2D : IEnumerable, ICloneable, IGrid2D
18 | {
19 | protected Rectangle3d _BBox;
20 | protected Point2d _PixelSize;
21 | protected Point2i _SizeUV;
22 | protected T _Grid;
23 |
24 |
25 | public Grid2D() : base() { }
26 |
27 | ///
28 | /// Construct a pixelgrid
29 | ///
30 | ///
31 | ///
32 | ///
33 | public Grid2D(Rectangle3d boundingBox, Point2d pxielDimensions, T grid)
34 | : base()
35 | {
36 | _BBox = boundingBox;
37 | _PixelSize = pxielDimensions;
38 |
39 | int iX = Convert.ToInt16(Math.Floor(boundingBox.X.Length / pxielDimensions.X));
40 | int iY = Convert.ToInt16(Math.Floor(boundingBox.Y.Length / pxielDimensions.Y));
41 |
42 | var gridsize = new Point2i(iX, iY);
43 | SizeUV = gridsize;
44 | Grid = grid;
45 | }
46 |
47 |
48 |
49 | ///
50 | /// Set or get the bounding region of the box
51 | ///
52 | public Rectangle3d BBox => _BBox;
53 |
54 | ///
55 | ///
56 | ///
57 | ///
58 | ///
59 | ///
60 | public Point2i GetRelativeUV(int iVx, Point2i ptRelVx)
61 | {
62 | var pt = IndexUV(iVx) + ptRelVx;
63 | if (new Point2i(0, 0) > pt || pt >= SizeUV)
64 | {
65 | throw new Exception("Index does not exist");
66 | }
67 |
68 | return pt;
69 | }
70 |
71 | ///
72 | /// Return the value of the voxel at index
73 | ///
74 | ///
75 | ///
76 | public abstract Y ValueAt(int index);
77 |
78 | ///
79 | /// Return a value at index
80 | ///
81 | ///
82 | ///
83 | public Y ValueAt(Point2i index)
84 | {
85 | return ValueAt(UVIndex(index));
86 | }
87 |
88 | ///
89 | ///
90 | ///
91 | ///
92 | ///
93 | public Point2i IndexUV(int index)
94 | {
95 | return (_SizeUV % index);
96 | }
97 |
98 | ///
99 | /// Convert a point2i location to the index of the point in the bitarray
100 | ///
101 | ///
102 | ///
103 | public int UVIndex(Point2i uv)
104 | {
105 | return uv^_SizeUV;
106 | }
107 |
108 | ///
109 | /// Dimensions of a voxel
110 | ///
111 | public Point2d PixelSize { get => _PixelSize;
112 | set => _PixelSize = value;
113 | }
114 |
115 | ///
116 | /// Amount of cells in the grid in x and y directions
117 | ///
118 | public Point2i SizeUV { get => _SizeUV;
119 | set => _SizeUV = value;
120 | }
121 |
122 | ///
123 | /// Values of the grid
124 | ///
125 | public T Grid { get => _Grid;
126 | set => _Grid = value;
127 | }
128 |
129 | ///
130 | ///
131 | ///
132 | public Plane Plane => _BBox.Plane;
133 |
134 | ///
135 | /// Clone the object
136 | ///
137 | ///
138 | public abstract object Clone();
139 |
140 | // Indexer declaration:
141 | public Y this[int index]
142 | {
143 |
144 | get => ValueAt(index);
145 | set => SetValue(index, value);
146 | }
147 |
148 | // Indexer declaration:
149 | public Y this[Point2i index]
150 | {
151 |
152 | get => ValueAt(index);
153 | set => SetValue(index, value);
154 | }
155 |
156 | ///
157 | /// Set value of voxel with index
158 | ///
159 | /// index of voxel
160 | /// value of voxel
161 | public abstract void SetValue(int index, Y value);
162 |
163 | ///
164 | /// Set value of Voxel
165 | ///
166 | ///
167 | ///
168 | public void SetValue(Point2i index, Y value)
169 | {
170 | SetValue(UVIndex(index), value);
171 | }
172 |
173 | ///
174 | /// Return the enumerator
175 | ///
176 | ///
177 | public abstract IEnumerator GetEnumerator();
178 |
179 | public bool IsValid => SizeUV.SelfProduct() > 0 && SizeUV.IsPositiveNonZero();
180 |
181 | ///
182 | /// Gets World coordinates for UVW coordinate
183 | ///
184 | ///
185 | ///
186 | public Point3d PointAt(Point3d p)
187 | {
188 | return PointAt(p, Plane);
189 | }
190 |
191 | public Point3d PointAt(Point2d p)
192 | {
193 | return PointAt(new Point3d(p.X,p.Y,0), Plane);
194 | }
195 |
196 | ///
197 | /// Gets World coordinates for UVW coordinate
198 | ///
199 | /// Voxel location
200 | /// Voxel in world coordinates
201 | public Point3d PointAt(Point2i ptUV)
202 | {
203 | return PointAt(new Point3d(ptUV.X,ptUV.Y, 0), Plane);
204 | }
205 |
206 | ///
207 | /// Gets World coordinates for UVW coordinate
208 | ///
209 | /// Voxel number
210 | ///
211 | public Point3d PointAt(int iUVW)
212 | {
213 | return PointAt(SizeUV % iUVW);
214 | }
215 |
216 | ///
217 | /// Gets World coordinates for UVW coordinate
218 | ///
219 | /// Point in voxel space
220 | /// Orientation for voxel grid
221 | /// Point in 3d (World) space
222 | public Point3d PointAt(Point3d pUV, Plane pln)
223 | {
224 | var centerX = pUV.X * _PixelSize.X + _BBox.X.Min + _PixelSize.X / 2;
225 | var centerY = pUV.Y * _PixelSize.Y + _BBox.Y.Min + _PixelSize.Y / 2;
226 | return pln.PointAt(centerX, centerY);
227 | }
228 |
229 | public Point2i ClosestPoint (Point3d pt)
230 | {
231 | Plane.RemapToPlaneSpace(pt, out var p);
232 | var ix = (p.X - BBox.X.Min - PixelSize.X / 2) / PixelSize.X;
233 | var iy = (p.Y - BBox.Y.Min - PixelSize.Y / 2) / PixelSize.Y;
234 | return new Point2i(ix,iy);
235 | }
236 |
237 | public abstract int Count { get; }
238 |
239 | }
240 | }
241 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | dist/*
2 | yak.exe
3 | output/*
4 |
5 | ## Ignore Visual Studio temporary files, build results, and
6 | ## files generated by popular Visual Studio add-ons.
7 | ##
8 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
9 |
10 | # User-specific files
11 | *.rsuser
12 | *.suo
13 | *.user
14 | *.userosscache
15 | *.sln.docstates
16 |
17 | # User-specific files (MonoDevelop/Xamarin Studio)
18 | *.userprefs
19 |
20 | # Mono auto generated files
21 | mono_crash.*
22 |
23 | # Build results
24 | [Dd]ebug/
25 | [Dd]ebugPublic/
26 | [Rr]elease/
27 | [Rr]eleases/
28 | x64/
29 | x86/
30 | [Ww][Ii][Nn]32/
31 | [Aa][Rr][Mm]/
32 | [Aa][Rr][Mm]64/
33 | bld/
34 | [Bb]in/
35 | [Oo]bj/
36 | [Ll]og/
37 | [Ll]ogs/
38 |
39 | # Visual Studio 2015/2017 cache/options directory
40 | .vs/
41 | # Uncomment if you have tasks that create the project's static files in wwwroot
42 | #wwwroot/
43 |
44 | # Visual Studio 2017 auto generated files
45 | Generated\ Files/
46 |
47 | # MSTest test Results
48 | [Tt]est[Rr]esult*/
49 | [Bb]uild[Ll]og.*
50 |
51 | # NUnit
52 | *.VisualState.xml
53 | TestResult.xml
54 | nunit-*.xml
55 |
56 | # Build Results of an ATL Project
57 | [Dd]ebugPS/
58 | [Rr]eleasePS/
59 | dlldata.c
60 |
61 | # Benchmark Results
62 | BenchmarkDotNet.Artifacts/
63 |
64 | # .NET Core
65 | project.lock.json
66 | project.fragment.lock.json
67 | artifacts/
68 |
69 | # ASP.NET Scaffolding
70 | ScaffoldingReadMe.txt
71 |
72 | # StyleCop
73 | StyleCopReport.xml
74 |
75 | # Files built by Visual Studio
76 | *_i.c
77 | *_p.c
78 | *_h.h
79 | *.ilk
80 | *.meta
81 | *.obj
82 | *.iobj
83 | *.pch
84 | *.pdb
85 | *.ipdb
86 | *.pgc
87 | *.pgd
88 | *.rsp
89 | *.sbr
90 | *.tlb
91 | *.tli
92 | *.tlh
93 | *.tmp
94 | *.tmp_proj
95 | *_wpftmp.csproj
96 | *.log
97 | *.vspscc
98 | *.vssscc
99 | .builds
100 | *.pidb
101 | *.svclog
102 | *.scc
103 |
104 | # Chutzpah Test files
105 | _Chutzpah*
106 |
107 | # Visual C++ cache files
108 | ipch/
109 | *.aps
110 | *.ncb
111 | *.opendb
112 | *.opensdf
113 | *.sdf
114 | *.cachefile
115 | *.VC.db
116 | *.VC.VC.opendb
117 |
118 | # Visual Studio profiler
119 | *.psess
120 | *.vsp
121 | *.vspx
122 | *.sap
123 |
124 | # Visual Studio Trace Files
125 | *.e2e
126 |
127 | # TFS 2012 Local Workspace
128 | $tf/
129 |
130 | # Guidance Automation Toolkit
131 | *.gpState
132 |
133 | # ReSharper is a .NET coding add-in
134 | _ReSharper*/
135 | *.[Rr]e[Ss]harper
136 | *.DotSettings.user
137 |
138 | # TeamCity is a build add-in
139 | _TeamCity*
140 |
141 | # DotCover is a Code Coverage Tool
142 | *.dotCover
143 |
144 | # AxoCover is a Code Coverage Tool
145 | .axoCover/*
146 | !.axoCover/settings.json
147 |
148 | # Coverlet is a free, cross platform Code Coverage Tool
149 | coverage*[.json, .xml, .info]
150 |
151 | # Visual Studio code coverage results
152 | *.coverage
153 | *.coveragexml
154 |
155 | # NCrunch
156 | _NCrunch_*
157 | .*crunch*.local.xml
158 | nCrunchTemp_*
159 |
160 | # MightyMoose
161 | *.mm.*
162 | AutoTest.Net/
163 |
164 | # Web workbench (sass)
165 | .sass-cache/
166 |
167 | # Installshield output folder
168 | [Ee]xpress/
169 |
170 | # DocProject is a documentation generator add-in
171 | DocProject/buildhelp/
172 | DocProject/Help/*.HxT
173 | DocProject/Help/*.HxC
174 | DocProject/Help/*.hhc
175 | DocProject/Help/*.hhk
176 | DocProject/Help/*.hhp
177 | DocProject/Help/Html2
178 | DocProject/Help/html
179 |
180 | # Click-Once directory
181 | publish/
182 |
183 | # Publish Web Output
184 | *.[Pp]ublish.xml
185 | *.azurePubxml
186 | # Note: Comment the next line if you want to checkin your web deploy settings,
187 | # but database connection strings (with potential passwords) will be unencrypted
188 | *.pubxml
189 | *.publishproj
190 |
191 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
192 | # checkin your Azure Web App publish settings, but sensitive information contained
193 | # in these scripts will be unencrypted
194 | PublishScripts/
195 |
196 | # NuGet Packages
197 | *.nupkg
198 | # NuGet Symbol Packages
199 | *.snupkg
200 | # The packages folder can be ignored because of Package Restore
201 | **/[Pp]ackages/*
202 | # except build/, which is used as an MSBuild target.
203 | !**/[Pp]ackages/build/
204 | # Uncomment if necessary however generally it will be regenerated when needed
205 | #!**/[Pp]ackages/repositories.config
206 | # NuGet v3's project.json files produces more ignorable files
207 | *.nuget.props
208 | *.nuget.targets
209 |
210 | # Microsoft Azure Build Output
211 | csx/
212 | *.build.csdef
213 |
214 | # Microsoft Azure Emulator
215 | ecf/
216 | rcf/
217 |
218 | # Windows Store app package directories and files
219 | AppPackages/
220 | BundleArtifacts/
221 | Package.StoreAssociation.xml
222 | _pkginfo.txt
223 | *.appx
224 | *.appxbundle
225 | *.appxupload
226 |
227 | # Visual Studio cache files
228 | # files ending in .cache can be ignored
229 | *.[Cc]ache
230 | # but keep track of directories ending in .cache
231 | !?*.[Cc]ache/
232 |
233 | # Others
234 | ClientBin/
235 | ~$*
236 | *~
237 | *.dbmdl
238 | *.dbproj.schemaview
239 | *.jfm
240 | *.pfx
241 | *.publishsettings
242 | orleans.codegen.cs
243 |
244 | # Including strong name files can present a security risk
245 | # (https://github.com/github/gitignore/pull/2483#issue-259490424)
246 | #*.snk
247 |
248 | # Since there are multiple workflows, uncomment next line to ignore bower_components
249 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
250 | #bower_components/
251 |
252 | # RIA/Silverlight projects
253 | Generated_Code/
254 |
255 | # Backup & report files from converting an old project file
256 | # to a newer Visual Studio version. Backup files are not needed,
257 | # because we have git ;-)
258 | _UpgradeReport_Files/
259 | Backup*/
260 | UpgradeLog*.XML
261 | UpgradeLog*.htm
262 | ServiceFabricBackup/
263 | *.rptproj.bak
264 |
265 | # SQL Server files
266 | *.mdf
267 | *.ldf
268 | *.ndf
269 |
270 | # Business Intelligence projects
271 | *.rdl.data
272 | *.bim.layout
273 | *.bim_*.settings
274 | *.rptproj.rsuser
275 | *- [Bb]ackup.rdl
276 | *- [Bb]ackup ([0-9]).rdl
277 | *- [Bb]ackup ([0-9][0-9]).rdl
278 |
279 | # Microsoft Fakes
280 | FakesAssemblies/
281 |
282 | # GhostDoc plugin setting file
283 | *.GhostDoc.xml
284 |
285 | # Node.js Tools for Visual Studio
286 | .ntvs_analysis.dat
287 | node_modules/
288 |
289 | # Visual Studio 6 build log
290 | *.plg
291 |
292 | # Visual Studio 6 workspace options file
293 | *.opt
294 |
295 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
296 | *.vbw
297 |
298 | # Visual Studio LightSwitch build output
299 | **/*.HTMLClient/GeneratedArtifacts
300 | **/*.DesktopClient/GeneratedArtifacts
301 | **/*.DesktopClient/ModelManifest.xml
302 | **/*.Server/GeneratedArtifacts
303 | **/*.Server/ModelManifest.xml
304 | _Pvt_Extensions
305 |
306 | # Paket dependency manager
307 | .paket/paket.exe
308 | paket-files/
309 |
310 | # FAKE - F# Make
311 | .fake/
312 |
313 | # CodeRush personal settings
314 | .cr/personal
315 |
316 | # Python Tools for Visual Studio (PTVS)
317 | __pycache__/
318 | *.pyc
319 |
320 | # Cake - Uncomment if you are using it
321 | # tools/**
322 | # !tools/packages.config
323 |
324 | # Tabs Studio
325 | *.tss
326 |
327 | # Telerik's JustMock configuration file
328 | *.jmconfig
329 |
330 | # BizTalk build output
331 | *.btp.cs
332 | *.btm.cs
333 | *.odx.cs
334 | *.xsd.cs
335 |
336 | # OpenCover UI analysis results
337 | OpenCover/
338 |
339 | # Azure Stream Analytics local run output
340 | ASALocalRun/
341 |
342 | # MSBuild Binary and Structured Log
343 | *.binlog
344 |
345 | # NVidia Nsight GPU debugger configuration file
346 | *.nvuser
347 |
348 | # MFractors (Xamarin productivity tool) working folder
349 | .mfractor/
350 |
351 | # Local History for Visual Studio
352 | .localhistory/
353 |
354 | # BeatPulse healthcheck temp database
355 | healthchecksdb
356 |
357 | # Backup folder for Package Reference Convert tool in Visual Studio 2017
358 | MigrationBackup/
359 |
360 | # Ionide (cross platform F# VS Code tools) working folder
361 | .ionide/
362 |
363 | # Fody - auto-generated XML schema
364 | FodyWeavers.xsd
--------------------------------------------------------------------------------