Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
rms80 committed Nov 6, 2017
1 parent 0c2ad4d commit 8e55174
Show file tree
Hide file tree
Showing 10 changed files with 97 additions and 15 deletions.
6 changes: 3 additions & 3 deletions g3MeshConvert/App.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
</configuration>
</configuration>
3 changes: 2 additions & 1 deletion g3MeshConvert/g3MeshConvert.csproj
Expand Up @@ -9,9 +9,10 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>g3MeshConvert</RootNamespace>
<AssemblyName>g3MeshConvert</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
2 changes: 1 addition & 1 deletion geometry3Sharp
6 changes: 3 additions & 3 deletions geometry3Test/App.config
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6"/>
</startup>
</configuration>
</configuration>
3 changes: 2 additions & 1 deletion geometry3Test/Program.cs
Expand Up @@ -85,7 +85,8 @@ static void Main()

//test_Polygon.test_svg();
//test_Polygon.test_tiling();
test_Polygon.test_convex_hull();
//test_Polygon.test_convex_hull_2();
test_Polygon.test_min_box_2();

System.Console.WriteLine("Done tests, press enter key to exit");
System.Console.ReadLine();
Expand Down
2 changes: 1 addition & 1 deletion geometry3Test/Properties/Resources.Designer.cs

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

2 changes: 1 addition & 1 deletion geometry3Test/Properties/Settings.Designer.cs

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

11 changes: 9 additions & 2 deletions geometry3Test/TestUtil.cs
Expand Up @@ -250,7 +250,14 @@ public static Vector2d[] RandomPoints(int Count, Random r, Vector2d center, doub
return v;
}

public static double[] RandomScalars(int Count, Random r, Interval1d range)
{
double[] v = new double[Count];
for (int k = 0; k < Count; ++k) {
v[k] = range.a + r.NextDouble() * range.Length;
}
return v;
}


}
}
}
3 changes: 2 additions & 1 deletion geometry3Test/geometry3Test.csproj
Expand Up @@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>geometry3Test</RootNamespace>
<AssemblyName>geometry3Test</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<StartupObject>frame3Test.Program</StartupObject>
Expand All @@ -28,6 +28,7 @@
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
Expand Down
74 changes: 73 additions & 1 deletion geometry3Test/test_Polygon.cs
Expand Up @@ -61,7 +61,7 @@ public static void test_tiling()



public static void test_convex_hull()
public static void test_convex_hull_2()
{
Random r = new Random(31337);

Expand Down Expand Up @@ -107,5 +107,77 @@ public static void test_convex_hull()
}










public static void test_min_box_2()
{
Random r = new Random(31337);

bool write_svg = false;
int contained_circles_N = 100;
int test_iters = 1000;

//LocalProfiler p = new LocalProfiler();
//p.Start("Hulls");

QueryNumberType[] modes = new QueryNumberType[] { QueryNumberType.QT_DOUBLE, QueryNumberType.QT_INT64 };
//QueryNumberType[] modes = new QueryNumberType[] { QueryNumberType.QT_DOUBLE };

foreach (var queryMode in modes) {

for (int k = 0; k < test_iters; ++k) {

int N = contained_circles_N;
double scale = (r.NextDouble() + 0.1) * 1024.0;
Interval1d radRange = new Interval1d(10, 100);

Vector2d[] pts = TestUtil.RandomPoints(N, r, Vector2d.Zero, scale);
double[] radius = TestUtil.RandomScalars(N, r, new Interval1d(radRange));

double eps = MathUtil.Epsilonf;

SVGWriter svg = (write_svg) ? new SVGWriter() : null;

List<Vector2d> accumPts = new List<Vector2d>();
for ( int i = 0; i < pts.Length; ++i ) {
Polygon2d circ = Polygon2d.MakeCircle(radius[i], 16, radius[i]);
circ.Translate(pts[i]);
accumPts.AddRange(circ.Vertices);

if ( svg != null )
svg.AddPolygon(circ, SVGWriter.Style.Outline("black", 1.0f));
}

ContMinBox2 contbox = new ContMinBox2(accumPts, 0.001, queryMode, false);
Box2d box = contbox.MinBox;

if (svg != null) {
svg.AddPolygon(new Polygon2d(box.ComputeVertices()), SVGWriter.Style.Outline("red", 2.0f));
svg.Write(TestUtil.GetTestOutputPath("contbox.svg"));
}

foreach (Vector2d v in accumPts) {
if (box.Contains(v))
continue;
double d = box.DistanceSquared(v);
if (d < eps)
continue;
System.Console.WriteLine("test_min_box_2: Point {0} not contained!", v);
}
}
}

//p.StopAll();
//System.Console.WriteLine(p.AllTimes());
}



}
}

0 comments on commit 8e55174

Please sign in to comment.