scrawk / cgaldotnet Goto Github PK
View Code? Open in Web Editor NEWC# wrapper for CGAL
License: GNU General Public License v3.0
C# wrapper for CGAL
License: GNU General Public License v3.0
I noticed that in PostgreSQL using sfcgal extension you can create Polyhedrons using polygons with holes as surfaces. Is it possible to support this in this project?
First off, thank you for making this wrapper. It will really save my project.
Currently I have copied the binaries and referenced the CGALDotNet
and the CGALDotNetWrapper
dll into my project. When I start to use the code Visual Studio is showing me errors. This is the exact error:
'Kan bestand of assembly System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a of een van de afhankelijkheden hiervan niet laden. Het systeem kan het opgegeven bestand niet vinden.'
Translated into English 'Cannot find file or assembly.... or one of its dependencies could not be loaded. Cannot find the given file path`.
Do you have any idea what can create this error? My project is using System.Runtime 4.3.1, and the version 4.2.2.0 cannot be found within NuGet.
Looking forward to you reply.
Does CGALDotNet support Boolean operations on polygons containing arcs?
Can you give an example of performing Boolean operations on a circle and a square
Hi,
CGALDotNet works like a charm in Unity, but now I need to use it in a standard C# winform project.
Problem is, at the first instruction that uses CGALDotNet:
using CGALDotNet;
using CGALDotNetGeometry;
(...)
List<Point2d> points = new List<Point2d>(); // First CGALDotNet use in the program
the program throws a "System.IO.FileNotFoundException : Could not find file or assembly 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies".
I manually added a reference to the system.runtime.dll file that is used in a Unity project and spent a lot of time trying and searching, but could not find a solution.
Any ideas?
Core is LGPL: https://www.cgal.org/license.html
But lots of modules are GPL: https://doc.cgal.org/latest/Manual/packages.html
I'm wondering if you've got any insight into this that I've missed. I was hoping to use CGALDotNet in an Apache and MIT licenced project. I might have managed that by sticking to the LGPL parts (although I understand that makes Android builds problemmatic due to packaging).
However - GPL surely rules out any usage in non-GPL open source. And doesn't that mean CGALDotNet itself needs to be GPL as you're wrapping some of the GPL CGAL modules?
I'm not expecting but holding out a small hope you know a workaround for this as I'd love to use CGALDotNet.
Edited for clarity:
I have a polygon (array of Vector2s) and an array of polygons that represent interior holes. After I create the PolygonWithHoles2 instance using the outermost polygon, I then use the AddHole method for each of the holes. I would expect an interior skeleton generated using the PolygonWithHoles2 instance to respect the previously added holes. However, the resulting skeleton remains the same as though no holes had been added at all. I've attached images demonstrating this (Input polygons/holes depicted in red, generated lines depicted in pink). How do you create a skeleton with interior holes? Below is my code:
`
////Get the instance to the offset algorithm.
var instance = PolygonOffset2.Instance;
var polygon = new Polygon2<EIK>(args.Lines.First().Points.Select(p => new Point2d(p.X, p.Y)).ToArray());
if (polygon.IsClockWise) {
args.Lines.First().Points.Reverse();
polygon = new Polygon2<EIK>(args.Lines.First().Points.Select(p => new Point2d(p.X, p.Y)).ToArray());
}
var polygonWithHoles = new PolygonWithHoles2<EIK>(polygon);
foreach (var hole in args.Lines.Skip(1)) {
var polygonHole = new Polygon2<EIK>(hole.Points.Select(p => new Point2d(p.X, p.Y)).ToArray());
if (polygonHole.IsCounterClockWise) {
hole.Points.Reverse();
polygonHole = new Polygon2<EIK>(hole.Points.Select(p => new Point2d(p.X, p.Y)).ToArray());
}
polygonWithHoles.AddHole(polygonHole);
}
//The skeleton is return as a array of segments.
var skeleton = new List<Segment2d>();
instance.CheckInput = true;
instance.CreateInteriorSkeleton(polygonWithHoles, false, skeleton);
foreach (var segment in skeleton) {
Utils.AddToBmp(bmp, new Vector2[] {
new Vector2((float)segment.A.x, (float)segment.A.y),
new Vector2((float)segment.B.x, (float)segment.B.y)
}, Color.HotPink);
}
`
You have done a very good and hard job by converting all those functionality from CGAL to .net, as .net lacks good library for Meshing, etc.
My question is does this library supports split mesh by normal and a point , and also close the newly generated side ?
I am looking for some library which supports these functionalities with good performance. Currently I have tried Helix and Gradientspace library for the same.
As there doesn't seem to be a lot of robust straight skeleton implementations for .NET, it would be a great addition to the library.
Possibly helpful resource: https://github.com/martindevans/CGAL_StraightSkeleton_Wrapper
To create a Polygon from a list of points and faces is really fast. But retrieving back the points is really slow. Right now it's faster to export an PLY and run a compiled C++ script to read that file, run the code, write back a PLY file and load it back into the software. Our goal is to remove the time of writing/reading by using this library.
The GetPoints function takes about 10 seconds to run. Whereas GetTriangleIncides is instant. 36017 vertices and 222258 indices.
Any idea on how to get the points fast?
Hey @Scrawk,
First of all many thanks for creating and maintaining this repo!
I'm interested in using the Alpha Wrapping functionality released in the latest version of CGAL: https://www.cgal.org/2022/05/18/alpha_wrap/
Any chance you could add it to the wrapper?
Such amazing work!
I am wondering, which version of CGAL and Eigen you depend on, I have tried CGAL5.4, and Eigen 3, but I can't build the CGAL Wrapper project.
I tryed the method PolygonVisibility.ComputeVisibility , but encountered a AccessViolationException error bug.
Here is my code:
var points = new Point2d[]
{
new Point2d(0, 0),
new Point2d(5, 0),
new Point2d(5, 5),
new Point2d(0, 5),
};
var poly = new Polygon2<EEK>(points);
var pv = new PolygonVisibility<EEK>();
var pt = new Point2d(0, 0);
Polygon2<EEK> result;
pv.ComputeVisibility(pt, poly, out result);
The error is System.AccessViolationException:“Attempted to read or write protected memory. This is often an indication that other memory is corrupt.”
which appeared at pv.ComputeVisibility(pt, poly, out result);
My test:
var s1 = new Segment2d(0, 0, 1, 1);
var s2 = new Segment2d(0, 1, 1, 0);
var i = CGALIntersections.Intersection(s1, s2);
Expecting to find a point intersection at coordinates 0.5,0.5
but instead i.Type
is SEGMENT2
and i.Segment
is A=0,0 B=0,0
.
Hi @Scrawk,
Great job with porting the CGAL
library!
Recently, I conducted some benchmarks of your package compared to my package, BurstTriangulator
(and others). The package is targeted for C# (using Unity with the Burst compiler). I wanted to share the results with you. I believe you'll find them interesting, and I think other users may also be interested as well.
Below, you'll find a performance comparison for classic Delaunay triangulation (without refinement or constraints).
Best regards,
Andrzej
I tried to triangulate a polygon having holes, but only the main polygon is triangulated. Am I missing something or this is actually not possible?
Hi!
I believe that I have successfully created dynamic and static library files for MacOS.
Should I create a pull request with the Xcode project that creates the files?
Should I also upload the .dylib and the .a files?
The .dylib takes about 400MB whereas the .a takes about 2GB.
I built the library files on a M1 chip Mac.
This is the first time that I have done any such thing as building library files...
so I have no idea if the binaries would work on any system but mine.
I think that, at the very least, the Xcode project would compile and build in other systems, because people are able to change the path to the other required libraries and such.
I documented the project configuration, and the modifications I had to make to CGALWrapper so that it would compile in Xcode, in the Notes.txt file in the Xcode project.
I cannot be sure, though, that I did document all modifications. It's possible that I might have forgotten to document some. No idea.
Regards.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.