mirror of
https://github.com/eliasstepanik/OSCADSharpDotnet7.git
synced 2026-01-21 10:18:28 +00:00
Added basic solids:
- Cube - Cylinder - Sphere As well as Vector3
This commit is contained in:
parent
35f82b9a85
commit
ff4da516e5
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace OSCADSharp
|
namespace OSCADSharp
|
||||||
{
|
{
|
||||||
public class OSCADObject
|
public abstract class OSCADObject
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,10 +1,10 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
<ProjectGuid>e420ce17-2f13-4abc-87d7-c9744df39d3d</ProjectGuid>
|
<ProjectGuid>{E420CE17-2F13-4ABC-87D7-C9744DF39D3D}</ProjectGuid>
|
||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
<RootNamespace>OSCADSharp</RootNamespace>
|
<RootNamespace>OSCADSharp</RootNamespace>
|
||||||
@ -30,24 +30,22 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System"/>
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
<Reference Include="System.Core"/>
|
<Reference Include="System.Xml.Linq" />
|
||||||
<Reference Include="System.Xml.Linq"/>
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
<Reference Include="System.Data.DataSetExtensions"/>
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
<Reference Include="Microsoft.CSharp"/>
|
<Reference Include="System.Xml" />
|
||||||
|
|
||||||
<Reference Include="System.Data"/>
|
|
||||||
|
|
||||||
<Reference Include="System.Net.Http"/>
|
|
||||||
|
|
||||||
<Reference Include="System.Xml"/>
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Class1.cs" />
|
<Compile Include="OSCADObject.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Solids\Cube.cs" />
|
||||||
|
<Compile Include="Solids\Cylinder.cs" />
|
||||||
|
<Compile Include="Solids\Sphere.cs" />
|
||||||
|
<Compile Include="Vector3.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
@ -57,5 +55,4 @@
|
|||||||
<Target Name="AfterBuild">
|
<Target Name="AfterBuild">
|
||||||
</Target>
|
</Target>
|
||||||
-->
|
-->
|
||||||
|
</Project>
|
||||||
</Project>
|
|
||||||
28
OSCADSharp/OSCADSharp/Solids/Cube.cs
Normal file
28
OSCADSharp/OSCADSharp/Solids/Cube.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OSCADSharp.Solids
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A Cube geometry
|
||||||
|
/// </summary>
|
||||||
|
public class Cube
|
||||||
|
{
|
||||||
|
#region Attributes
|
||||||
|
/// <summary>
|
||||||
|
/// The Size of the cube in terms of X/Y/Z units
|
||||||
|
/// </summary>
|
||||||
|
public Vector3 Size { get; set; } = new Vector3(1, 1, 1);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// If True, the center of the cube will be at 0, 0, 0
|
||||||
|
///
|
||||||
|
/// If False (default) one corner will be centered at 0,0, 0, with the cube extending into the positive octant (positive X/Y/Z)
|
||||||
|
/// </summary>
|
||||||
|
public bool Center { get; set; } = false;
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
100
OSCADSharp/OSCADSharp/Solids/Cylinder.cs
Normal file
100
OSCADSharp/OSCADSharp/Solids/Cylinder.cs
Normal file
@ -0,0 +1,100 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OSCADSharp.Solids
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A Cylinder geometry
|
||||||
|
/// </summary>
|
||||||
|
public class Cylinder
|
||||||
|
{
|
||||||
|
#region Attributes
|
||||||
|
/// <summary>
|
||||||
|
/// Height of the cylinder or cone
|
||||||
|
/// </summary>
|
||||||
|
public double Height { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Radius of cylinder. r1 = r2 = r.
|
||||||
|
/// </summary>
|
||||||
|
public double Radius {
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return (Radius1 + Radius2) / 2;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.Radius1 = value;
|
||||||
|
this.Radius2 = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Radius, bottom of cone.
|
||||||
|
/// </summary>
|
||||||
|
public double Radius1 { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Radius, top of cone.
|
||||||
|
/// </summary>
|
||||||
|
public double Radius2 { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Diameter of cylinder. r1 = r2 = d /2.
|
||||||
|
/// </summary>
|
||||||
|
public double Diameter
|
||||||
|
{
|
||||||
|
get { return this.Radius * 2; }
|
||||||
|
set { this.Radius = value / 2; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Diameter, bottom of cone. r1 = d1 /2
|
||||||
|
/// </summary>
|
||||||
|
public double Diameter1
|
||||||
|
{
|
||||||
|
get { return this.Radius1 * 2; }
|
||||||
|
set { this.Radius1 = value / 2; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Diameter, top of cone. r2 = d2 /2
|
||||||
|
/// </summary>
|
||||||
|
public double Diameter2
|
||||||
|
{
|
||||||
|
get { return this.Radius2 * 2; }
|
||||||
|
set { this.Radius2 = value / 2; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Denotes the initial positioning of the cylinder
|
||||||
|
/// false: (default), z ranges from 0 to h
|
||||||
|
/// true: z ranges from -h/2 to +h/2
|
||||||
|
/// </summary>
|
||||||
|
public bool Center { get; set; } = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Minimum angle (in degrees) of each cylinder fragment.
|
||||||
|
/// ($fa in OpenSCAD)
|
||||||
|
/// </summary>
|
||||||
|
public int MinimumAngle { get; set; } = 12;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Minimum circumferential length of each fragment.
|
||||||
|
/// ($fs in OpenSCAD)
|
||||||
|
/// </summary>
|
||||||
|
public int MinimumCircumferentialLength { get; set; } = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of fragments in 360 degrees. Values of 3 or more override MinimumAngle and MinimumCircumferentialLength
|
||||||
|
/// ($fn in OpenSCAD)
|
||||||
|
/// </summary>
|
||||||
|
public int Resolution { get; set; } = 0;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
44
OSCADSharp/OSCADSharp/Solids/Sphere.cs
Normal file
44
OSCADSharp/OSCADSharp/Solids/Sphere.cs
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OSCADSharp.Solids
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A Sphere geometry
|
||||||
|
/// </summary>
|
||||||
|
public class Sphere
|
||||||
|
{
|
||||||
|
#region Attributes
|
||||||
|
/// <summary>
|
||||||
|
/// This is the radius of the sphere
|
||||||
|
/// </summary>
|
||||||
|
public double Radius { get; set; } = 1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is the diameter of the sphere
|
||||||
|
/// </summary>
|
||||||
|
public double Diameter { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Minimum angle (in degrees) of each cylinder fragment.
|
||||||
|
/// ($fa in OpenSCAD)
|
||||||
|
/// </summary>
|
||||||
|
public int MinimumAngle { get; set; } = 12;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Minimum circumferential length of each fragment.
|
||||||
|
/// ($fs in OpenSCAD)
|
||||||
|
/// </summary>
|
||||||
|
public int MinimumCircumferentialLength { get; set; } = 2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of fragments in 360 degrees. Values of 3 or more override MinimumAngle and MinimumCircumferentialLength
|
||||||
|
/// ($fn in OpenSCAD)
|
||||||
|
/// </summary>
|
||||||
|
public int Resolution { get; set; } = 0;
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
27
OSCADSharp/OSCADSharp/Vector3.cs
Normal file
27
OSCADSharp/OSCADSharp/Vector3.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace OSCADSharp
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A Three-Dimensional vector
|
||||||
|
///
|
||||||
|
/// Can be used to represent a direction, or a point in space
|
||||||
|
/// </summary>
|
||||||
|
public class Vector3
|
||||||
|
{
|
||||||
|
public double X { get; set; }
|
||||||
|
public double Y { get; set; }
|
||||||
|
public double Z { get; set; }
|
||||||
|
|
||||||
|
public Vector3(double x = 0, double y = 0, double z = 0)
|
||||||
|
{
|
||||||
|
this.X = x;
|
||||||
|
this.Y = y;
|
||||||
|
this.Z = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user