GithubHelp home page GithubHelp logo

Comments (6)

AngusJohnson avatar AngusJohnson commented on August 21, 2024

Question: I understand that it is garbage input, but is there any reason to generate single-point output polys like this? Is this intended?

I suspect this is because your clipping path isn't as straight as (I'm guessing) you think it is.
clipper

from clipper2.

olologin avatar olologin commented on August 21, 2024

@AngusJohnson
Sorry, I don't understand what you mean by "Straight". Do you mean SUBJECTS_OPEN is not exact subpoly of CLIPS? I have no idea how it is possible.
In OpenClip.txt you can search for whole sequence of points from SUBJECTS_OPEN, it will be found 2 times, once in SUBJECTS_OPEN and once as subsequence of points in CLIPS.

from clipper2.

AngusJohnson avatar AngusJohnson commented on August 21, 2024

Sorry, I don't understand what you mean by "Straight".

What I mean is the edges of the clip path and subject path where they're almost touching aren't straight (see the image below). So while the subject path outlines a seemingly single very long single subject 'line', this subject polygon is actually broken into numerous polygons (ie the outlines of numerous line segments). So even if you just Unioned this subject, you'll still get multiple paths in the clipping solution.

clipper

from clipper2.

olologin avatar olologin commented on August 21, 2024

Yes, I am fully aware that my clip and subject polylines are not single straight lines and contain a lot of noise.

I spent some time on minimizing inputs, still I need ~600 points clipping poly to reproduce this behavior, but at least now I can fit it in test like this, cannot reduce it further:

TEST(Clipper2Tests, TestOpenClipProducesSinglePoints1)
{
	Clipper2Lib::ClipType ct = Clipper2Lib::ClipType::Intersection;
	Clipper2Lib::FillRule fr = Clipper2Lib::FillRule::EvenOdd;
	int64_t stored_area = 0, stored_count = 0;

	Clipper2Lib::Paths64 solution, solution_open;
	Clipper2Lib::Clipper64 c;
	Clipper2Lib::Paths64 subject;
	Clipper2Lib::Paths64 subject_open = { {{561987188, 277759647}, {561989245, 277759632}, {561991269, 277760004}, {561993309, 277760183}, {561997389, 277760540}, {562005550, 277761254}, {562021872, 277762682}, {562054515, 277765538}, {562119802, 277771250}, {562250375, 277782673}, {562511521, 277805521}, {563033814, 277851215}, {563556107, 277896910}, {563817254, 277919757}, {563947827, 277931181}, {564013114, 277936893}, {564045757, 277939749}, {564062078, 277941177}, {564070239, 277941891}, {564074320, 277942248}, {564076360, 277942426}, {564078417, 277942411}} };
	Clipper2Lib::Paths64 clip = { {{639288598, 284522449}, {689987154, 0}, {0, 228592139}, {2057, 228592124}, {2089172, 228774918}, {2091229, 228774903}, {4178343, 228957697}, {4180401, 228957682}, {6267515, 229140476}, {6269572, 229140461}, {8356687, 229323255}, {8358744, 229323239}, {10445858, 229506034}, {10447916, 229506018}, {12535030, 229688812}, {12537087, 229688797}, {14624202, 229871591}, {14626259, 229871576}, {16713374, 230054370}, {16715431, 230054355}, {18802545, 230237149}, {18804602, 230237134}, {20891717, 230419928}, {20893774, 230419912}, {22980889, 230602707}, {22982946, 230602691}, {25070060, 230785485}, {25072118, 230785470}, {27159232, 230968264}, {27161289, 230968249}, {29248404, 231151043}, {29250461, 231151028}, {31337576, 231333822}, {31339633, 231333807}, {33426747, 231516601}, {33428804, 231516586}, {35515919, 231699380}, {35517976, 231699364}, {37605091, 231882158}, {37607148, 231882143}, {39694262, 232064937}, {39696320, 232064922}, {41783434, 232247716}, {41785491, 232247701}, {43872606, 232430495}, {43874663, 232430480}, {45961777, 232613274}, {45963835, 232613259}, {48050949, 232796053}, {48053006, 232796037}, {50140121, 232978832}, {50142178, 232978816}, {52229293, 233161610}, {52231350, 233161595}, {54318464, 233344389}, {54320521, 233344374}, {56407636, 233527168}, {56409693, 233527153}, {58496808, 233709947}, {58498865, 233709932}, {60585979, 233892726}, {60588037, 233892710}, {62675151, 234075505}, {62677208, 234075489}, {64764323, 234258283}, {64766380, 234258268}, {66853494, 234441062}, {66855552, 234441047}, {68942666, 234623841}, {68944723, 234623826}, {71031838, 234806620}, {71033895, 234806605}, {73121010, 234989399}, {73123067, 234989383}, {75210181, 235172178}, {75212238, 235172162}, {77299353, 235354956}, {77301410, 235354941}, {79388525, 235537735}, {79390582, 235537720}, {81477696, 235720514}, {81479754, 235720499}, {83566868, 235903293}, {83568925, 235903278}, {85656040, 236086072}, {85658097, 236086057}, {87745212, 236268851}, {87747269, 236268835}, {89834383, 236451629}, {89836440, 236451614}, {91923555, 236634408}, {91925612, 236634393}, {94012727, 236817187}, {94014784, 236817172}, {96101898, 236999966}, {96103956, 236999951}, {98191070, 237182745}, {98193127, 237182730}, {100280242, 237365524}, {100282299, 237365508}, {102369413, 237548303}, {102371471, 237548287}, {104458585, 237731081}, {104460642, 237731066}, {106547757, 237913860}, {106549814, 237913845}, {108636929, 238096639}, {108638986, 238096624}, {110726100, 238279418}, {110728157, 238279403}, {112815272, 238462197}, {112817329, 238462181}, {114904444, 238644976}, {114906501, 238644960}, {116993615, 238827754}, {116995673, 238827739}, {119082787, 239010533}, {119084844, 239010518}, {121171959, 239193312}, {121174016, 239193297}, {123261130, 239376091}, {123263188, 239376076}, {125350302, 239558870}, {125352359, 239558854}, {127439474, 239741649}, {127441531, 239741633}, {129528646, 239924427}, {129530703, 239924412}, {131617817, 240107206}, {131619874, 240107191}, {133706989, 240289985}, {133709046, 240289970}, {135796161, 240472764}, {135798218, 240472749}, {137885332, 240655543}, {137887390, 240655528}, {139974504, 240838322}, {139976561, 240838306}, {142063676, 241021100}, {142065733, 241021085}, {144152848, 241203879}, {144154905, 241203864}, {146242019, 241386658}, {146244076, 241386643}, {148331191, 241569437}, {148333248, 241569422}, {150420363, 241752216}, {150422420, 241752201}, {152509534, 241934995}, {152511591, 241934979}, {154598706, 242117774}, {154600763, 242117758}, {156687878, 242300552}, {156689935, 242300537}, {158777049, 242483331}, {158779107, 242483316}, {160866221, 242666110}, {160868278, 242666095}, {162955393, 242848889}, {162957450, 242848874}, {165044565, 243031668}, {165046622, 243031652}, {167133736, 243214447}, {167135793, 243214431}, {169222908, 243397225}, {169224965, 243397210}, {171312080, 243580004}, {171314137, 243579989}, {173401251, 243762783}, {173403309, 243762768}, {175490423, 243945562}, {175492480, 243945547}, {177579595, 244128341}, {177581652, 244128325}, {179668766, 244311120}, {179670824, 244311104}, {181757938, 244493898}, {181759995, 244493883}, {183847110, 244676677}, {183849167, 244676662}, {185936282, 244859456}, {185938339, 244859441}, {188025453, 245042235}, {188027510, 245042220}, {190114625, 245225014}, {190116682, 245224999}, {192203797, 245407793}, {192205854, 245407777}, {194292968, 245590571}, {194295026, 245590556}, {196382140, 245773350}, {196384197, 245773335}, {198471312, 245956129}, {198473369, 245956114}, {200560484, 246138908}, {200562541, 246138893}, {202649655, 246321687}, {202651712, 246321672}, {204738827, 246504466}, {204740884, 246504450}, {206827999, 246687245}, {206830056, 246687229}, {208917170, 246870023}, {208919227, 246870008}, {211006342, 247052802}, {211008399, 247052787}, {213095514, 247235581}, {213097571, 247235566}, {215184685, 247418360}, {215186743, 247418345}, {217273857, 247601139}, {217275914, 247601123}, {219363029, 247783918}, {219365086, 247783902}, {221452201, 247966696}, {221454258, 247966681}, {223541372, 248149475}, {223543429, 248149460}, {225630544, 248332254}, {225632601, 248332239}, {227719716, 248515033}, {227721773, 248515018}, {229808887, 248697812}, {229810945, 248697796}, {231898059, 248880591}, {231900116, 248880575}, {233987231, 249063369}, {233989288, 249063354}, {236076402, 249246148}, {236078460, 249246133}, {238165574, 249428927}, {238167631, 249428912}, {240254746, 249611706}, {240256803, 249611691}, {242343918, 249794485}, {242345975, 249794470}, {244433089, 249977264}, {244435146, 249977248}, {246522261, 250160042}, {246524318, 250160027}, {248611433, 250342821}, {248613490, 250342806}, {250700604, 250525600}, {250702662, 250525585}, {252789776, 250708379}, {252791833, 250708364}, {254878948, 250891158}, {254881005, 250891143}, {256968120, 251073937}, {256970177, 251073921}, {259057291, 251256716}, {259059348, 251256700}, {261146463, 251439494}, {261148520, 251439479}, {263235635, 251622273}, {263237692, 251622258}, {265324806, 251805052}, {265326863, 251805037}, {267413978, 251987831}, {267416035, 251987816}, {269503150, 252170610}, {269505207, 252170594}, {271592321, 252353389}, {271594379, 252353373}, {273681493, 252536167}, {273683550, 252536152}, {275770665, 252718946}, {275772722, 252718931}, {277859837, 252901725}, {277861894, 252901710}, {279949008, 253084504}, {279951065, 253084489}, {282038180, 253267283}, {282040237, 253267267}, {284127352, 253450062}, {284129409, 253450046}, {286216523, 253632840}, {286218581, 253632825}, {288305695, 253815619}, {288307752, 253815604}, {290394867, 253998398}, {290396924, 253998383}, {292484038, 254181177}, {292486096, 254181162}, {294573210, 254363956}, {294575267, 254363941}, {296662382, 254546735}, {296664439, 254546719}, {298751554, 254729513}, {298753611, 254729498}, {300840725, 254912292}, {300842782, 254912277}, {302929897, 255095071}, {302931954, 255095056}, {305019069, 255277850}, {305021126, 255277835}, {307108240, 255460629}, {307110298, 255460614}, {309197412, 255643408}, {309199469, 255643392}, {311286584, 255826187}, {311288641, 255826171}, {313375756, 256008965}, {313377813, 256008950}, {315464927, 256191744}, {315466984, 256191729}, {317554099, 256374523}, {317556156, 256374508}, {319643271, 256557302}, {319645328, 256557287}, {321732442, 256740081}, {321734499, 256740065}, {323821614, 256922860}, {323823671, 256922844}, {325910786, 257105638}, {325912843, 257105623}, {327999957, 257288417}, {328002015, 257288402}, {330089129, 257471196}, {330091186, 257471181}, {332178301, 257653975}, {332180358, 257653960}, {334267473, 257836754}, {334269530, 257836738}, {336356644, 258019533}, {336358701, 258019517}, {338445816, 258202311}, {338447873, 258202296}, {340534988, 258385090}, {340537045, 258385075}, {342624159, 258567869}, {342626217, 258567854}, {344713331, 258750648}, {344715388, 258750633}, {346802503, 258933427}, {346804560, 258933412}, {348891674, 259116206}, {348893732, 259116190}, {350980846, 259298984}, {350982903, 259298969}, {353070018, 259481763}, {353072075, 259481748}, {355159190, 259664542}, {355161247, 259664527}, {357248361, 259847321}, {357250418, 259847306}, {359337533, 260030100}, {359339590, 260030085}, {361426705, 260212879}, {361428762, 260212863}, {363515876, 260395658}, {363517934, 260395642}, {365605048, 260578436}, {365607105, 260578421}, {367694220, 260761215}, {367696277, 260761200}, {369783391, 260943994}, {369785449, 260943979}, {371872563, 261126773}, {371874620, 261126758}, {373961735, 261309552}, {373963792, 261309536}, {376050907, 261492331}, {376052964, 261492315}, {378140078, 261675109}, {378142135, 261675094}, {380229250, 261857888}, {380231307, 261857873}, {382318422, 262040667}, {382320479, 262040652}, {384407593, 262223446}, {384409651, 262223431}, {386496765, 262406225}, {386498822, 262406210}, {388585937, 262589004}, {388587994, 262588988}, {390675109, 262771782}, {390677166, 262771767}, {392764280, 262954561}, {392766337, 262954546}, {394853452, 263137340}, {394855509, 263137325}, {396942624, 263320119}, {396944681, 263320104}, {399031795, 263502898}, {399033853, 263502883}, {401120967, 263685677}, {401123024, 263685661}, {403210139, 263868456}, {403212196, 263868440}, {405299310, 264051234}, {405301368, 264051219}, {407388482, 264234013}, {407390539, 264233998}, {409477654, 264416792}, {409479711, 264416777}, {411566826, 264599571}, {411568883, 264599556}, {413655997, 264782350}, {413658054, 264782334}, {415745169, 264965129}, {415747226, 264965113}, {417834341, 265147907}, {417836398, 265147892}, {419923512, 265330686}, {419925570, 265330671}, {422012684, 265513465}, {422014741, 265513450}, {424101856, 265696244}, {424103913, 265696229}, {426191027, 265879023}, {426193085, 265879007}, {428280199, 266061802}, {428282256, 266061786}, {430369371, 266244580}, {430371428, 266244565}, {432458543, 266427359}, {432460600, 266427344}, {434547714, 266610138}, {434549771, 266610123}, {436636886, 266792917}, {436638943, 266792902}, {438726058, 266975696}, {438728115, 266975681}, {440815229, 267158475}, {440817287, 267158459}, {442904401, 267341253}, {442906458, 267341238}, {444993573, 267524032}, {444995630, 267524017}, {447082745, 267706811}, {447084802, 267706796}, {449171916, 267889590}, {449173973, 267889575}, {451261088, 268072369}, {451263145, 268072354}, {453350260, 268255148}, {453352317, 268255132}, {455439431, 268437927}, {455441489, 268437911}, {457528603, 268620705}, {457530660, 268620690}, {459617775, 268803484}, {459619832, 268803469}, {461706946, 268986263}, {461709004, 268986248}, {463796118, 269169042}, {463798175, 269169027}, {465885290, 269351821}, {465887347, 269351805}, {467974462, 269534600}, {467976519, 269534584}, {470063633, 269717378}, {470065690, 269717363}, {472152805, 269900157}, {472154862, 269900142}, {474241977, 270082936}, {474244034, 270082921}, {476331148, 270265715}, {476333206, 270265700}, {478420320, 270448494}, {478422377, 270448478}, {480509492, 270631273}, {480511549, 270631257}, {482598663, 270814051}, {482600721, 270814036}, {484687835, 270996830}, {484689892, 270996815}, {486777007, 271179609}, {486779064, 271179594}, {488866179, 271362388}, {488868236, 271362373}, {490955350, 271545167}, {490957407, 271545152}, {493044522, 271727946}, {493046579, 271727930}, {495133694, 271910724}, {495135751, 271910709}, {497222865, 272093503}, {497224923, 272093488}, {499312037, 272276282}, {499314094, 272276267}, {501401209, 272459061}, {501403266, 272459046}, {503490381, 272641840}, {503492438, 272641825}, {505579552, 272824619}, {505581609, 272824603}, {507668724, 273007398}, {507670781, 273007382}, {509757896, 273190176}, {509759953, 273190161}, {511847067, 273372955}, {511849124, 273372940}, {513936239, 273555734}, {513938296, 273555719}, {516025411, 273738513}, {516027468, 273738498}, {518114582, 273921292}, {518116640, 273921276}, {520203754, 274104071}, {520205811, 274104055}, {522292926, 274286849}, {522294983, 274286834}, {524382098, 274469628}, {524384155, 274469613}, {526471269, 274652407}, {526473326, 274652392}, {528560441, 274835186}, {528562498, 274835171}, {530649613, 275017965}, {530651670, 275017949}, {532738784, 275200744}, {532740842, 275200728}, {534827956, 275383522}, {534830013, 275383507}, {536917128, 275566301}, {536919185, 275566286}, {539006299, 275749080}, {539008357, 275749065}, {541095471, 275931859}, {541097528, 275931844}, {543184643, 276114638}, {543186700, 276114623}, {545273815, 276297417}, {545275872, 276297401}, {547362986, 276480195}, {547365043, 276480180}, {549452158, 276662974}, {549454215, 276662959}, {551541330, 276845753}, {551543387, 276845738}, {553630501, 277028532}, {553632559, 277028517}, {555719673, 277211311}, {555721730, 277211296}, {557808845, 277394090}, {557810902, 277394074}, {559898017, 277576869}, {559900074, 277576853}, {561987188, 277759647}, {561989245, 277759632}, {561991269, 277760004}, {561993309, 277760183}, {561997389, 277760540}, {562005550, 277761254}, {562021872, 277762682}, {562054515, 277765538}, {562119802, 277771250}, {562250375, 277782673}, {562511521, 277805521}, {563033814, 277851215}, {563556107, 277896910}, {563817254, 277919757}, {563947827, 277931181}, {564013114, 277936893}, {564045757, 277939749}, {564062078, 277941177}, {564070239, 277941891}, {564074320, 277942248}, {564076360, 277942426}, {564078417, 277942411}, {578700562, 279221878}, {578702619, 279221863}, {580789734, 279404657}, {580791791, 279404642}, {582878905, 279587436}, {582880962, 279587420}, {584968077, 279770215}, {584970134, 279770199}, {587057249, 279952993}, {587059306, 279952978}, {589146420, 280135772}, {589148478, 280135757}, {591235592, 280318551}, {591237649, 280318536}, {593324764, 280501330}, {593326821, 280501315}, {595413935, 280684109}, {595415993, 280684094}, {597503107, 280866888}, {597505164, 280866872}, {599592279, 281049666}, {599594336, 281049651}, {601681451, 281232445}, {601683508, 281232430}, {603770622, 281415224}, {603772679, 281415209}, {605859794, 281598003}, {605861851, 281597988}, {607948966, 281780782}, {607951023, 281780767}, {610038137, 281963561}, {610040195, 281963545}, {612127309, 282146340}, {612129366, 282146324}, {614216481, 282329118}, {614218538, 282329103}, {616305653, 282511897}, {616307710, 282511882}, {618394824, 282694676}, {618396881, 282694661}, {620483996, 282877455}, {620486053, 282877440}, {622573168, 283060234}, {622575225, 283060218}, {624662339, 283243013}, {624664396, 283242997}, {626751511, 283425791}, {626753568, 283425776}, {628840683, 283608570}, {628842740, 283608555}, {630929854, 283791349}, {630931912, 283791334}, {633019026, 283974128}, {633021083, 283974113}, {635108198, 284156907}, {635110255, 284156891}, {637197370, 284339686}, {637199427, 284339670}} };

	c.AddOpenSubject(subject_open);
        // Uncomment line below to make clipper produce other output
        // clip[0].erase(clip[0].begin() + 14);
	c.AddClip(clip);
	if (c.Execute(ct, fr, solution, solution_open))
	{
		for (size_t i = 0; i < solution_open.size(); ++i)
		{
			if (solution_open[i].size() <= 1)
			{
				ASSERT_TRUE(false);
			}
		}
	}
}

As with previous input, subject_open is subsequence of clip.
Whole scene now looks like this (Every point is shown as arrow, a bit messy here):
image
If we zoom in to our subject poly (yellow here) it looks like this:
image
Zoom in even closer to the second point of subject (which is produced as single-point result):
image

With this input clipper produces single-point poly (which is second point of subject {561989245, 277759632}).
But if you remove any point from clip, for example 14th point - it is starting to produce 21-points poly, even though any component of clipping poly that should affect clipping is not changed, 14th point is located far away from subject poly.

Is such behavior expected? I just want to make sure it is not some unknown bug. In my opinion such input should result in empty output, or subject-poly output (because subject is on clipping poly, and we can define this as "outside" or "inside" respectively).

from clipper2.

AngusJohnson avatar AngusJohnson commented on August 21, 2024

Hi again, and thank you for your patience and persistence. Despite you very clearly indicating that your issue was when clipping open paths, I failed to register that until now. Sorry. (My ADHD strikes again!) Nevertheless, I didn't close this Issue because I suspected I hadn't fully understood your problem.

I think it's fair to state that (currently) where open paths overlap clipping boundaries, whether these overlapping segments are, or are not included in clipping solutions is undefined.

from clipper2.

olologin avatar olologin commented on August 21, 2024

Ok, thanks for explaining it.
I think if you are aware of such behavior and it is not a bug - we can close it.
Thanks again for making second version of this great library :)

from clipper2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.