clipperlib

Confused on Clipper in C#

末鹿安然 提交于 2021-01-28 07:09:58
问题 I'm creating a 2D game in Unity which has procedurally placed tiles. I want to simplify the collision geometry using Angus Johnson's Clipper library (specifically the union function), but I'm running into an issue with the library returning empty solutions and I'm not sure why. For reference, here are the Polygon Colliders I've been using to test. And here is a simplified version of the function I'm using to combine the geometry: List<List<Vector2>> unitedPolygons = new List<List<Vector2>>();

ClipperLib Clip multiple squares with rectangle produces 1 result

久未见 提交于 2020-01-24 13:26:25
问题 I'm using v6.4.2 of the C# version of the ClipperLib. I have a lot of squares making up a fishnet. I also have a rectangle. I want to get a result where only the squares that are inside the rectangle are returned and partially overlapped get clipped. The subjects are in green and the clip is in red: The result I get is the brown/gray rectangle, which is only one polygon: I would have expected to have 15 full squares and 13 clipped squares as a result. This is the code I'm using: var startX =

C++ Cannot Return Object From Function

橙三吉。 提交于 2020-01-06 03:33:47
问题 I am trying to use the C++ "Clipper Library" (http://www.angusj.com/delphi/clipper.php), but when I try to return one of the objects from the clipper library from a function, it seems to become null or is altered somehow Here is the function I wrote. The only relevant lines should be the last 3. ClipperLib::PolyTree MeshHandler::trianglesToPolyTreeUnion(std::vector<Triangle> triangles) { // Make all of the triangles CW for (auto& triangle : triangles) { triangle.makeClockwise(); } // Set up

Making holes in GeoJson Shapes - clipperLib

瘦欲@ 提交于 2019-12-24 15:59:29
问题 I have several overlapping shapes. I want to be able to make holes in the biggest shape that contains all the smaller shapes. the holes will represent the smaller shapes within the bigger shape. sample image: I am using the C# version of ClipperLib: const double precisionFactor = 1000000000000000.0; //precondition: all your polygons have the same orientation //(ie either clockwise or counter clockwise) Polygons polys = new Polygons(); multiPolygon.ForEach(x => { Polygon polygon = x.First()

Line and Polygon clipping returns empty Paths using Clipper library (c++)

北城以北 提交于 2019-12-24 08:27:20
问题 I am trying to split a polygon by a line using the Clipper library. After the execution of clipping, it returns empty path. Can someone suggest the right way to do the same. Paths clip(2),soln; clip[0] << IntPoint(-264,-210) << IntPoint(650,-209); Path sub = clip[0]; Path poly << IntPoint(531,49) << IntPoint(-21,49) << IntPoint(-970,-961) << IntPoint(-945,-1019) << IntPoint(1045,-1071) ; Clipper c; c.AddPath(poly,ptSubject,true); c.AddPath(sub,ptClip,true); c.Execute(ctIntersection,soln

Get all points within a triangle is causing an overflow

蓝咒 提交于 2019-12-20 05:46:16
问题 Well I'm lacking GraphicsPath in Unity (to fills polygon, draw them with and outline and utilities with shapes in general), so I'm doing my own implementation of it. Well, we could debate also which is the best option, but actually, I prefer this because I'm learning a lot. The idea is the following, given a polygon, we do an offset polygon (inwards and outwards) with ClipperLib, and later with LibTessDotNet we triangulate it, outputing this: Green, blue and yellow pixels are the sides of

Converting polygon coordinates from Double to Long for use with Clipper library

与世无争的帅哥 提交于 2019-12-19 17:41:32
问题 I have two polygons with their vertices stored as Double coordinates. I'd like to find the intersecting area of these polygons, so I'm looking at the Clipper library (C++ version). The problem is, Clipper only works with integer math (it uses the Long type). Is there a way I can safely transform both my polygons with the same scale factor, convert their coordinates to Longs, perform the Intersection algorithm with Clipper, and scale the resulting intersection polygon back down with the same

Converting polygon coordinates from Double to Long for use with Clipper library

陌路散爱 提交于 2019-12-19 17:41:31
问题 I have two polygons with their vertices stored as Double coordinates. I'd like to find the intersecting area of these polygons, so I'm looking at the Clipper library (C++ version). The problem is, Clipper only works with integer math (it uses the Long type). Is there a way I can safely transform both my polygons with the same scale factor, convert their coordinates to Longs, perform the Intersection algorithm with Clipper, and scale the resulting intersection polygon back down with the same

Polygon difference - strange results from Clipperlib

六月ゝ 毕业季﹏ 提交于 2019-12-10 19:03:29
问题 I am trying to create iso-area polygons ("donuts") from a set of contours. This is the process: Generate the contours. Sort the contours into a tree structure, such that all contours held within a specific contour are children of that contour. For each contour, execute a difference operation with all of its children, using Clipperlib. The resulting polygon(s) and holes constitute the iso-area "donut". These iso-areas can then be rendered as a contour map, or used for other purposes. Note that

Parallel line using Clipper library

六月ゝ 毕业季﹏ 提交于 2019-12-10 13:35:12
问题 I'm using CLIPPER library to offset line and trying to make parallel line. ClipperOffset co = new ClipperOffset(); co.AddPath (s, JoinType.jtRound, EndType.etOpenRound); co.Execute (ref solution, 15); Result is right image in attachment. I need parallel lines instead of offset line "around" main line. Does anyone know is it possible in Clipper or maybe anyone have any idea how to filter result points to remove unnecessary? 回答1: Using Endtype.etOpenButt while adding the path will help you: