Click here to Skip to main content
15,886,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi I use clip library with C++, but I get run time error when execute below instruction.
c.AddPaths(subj, ptSubject, false); if I use true instead of false, I don't get run time error, but I don't want to clip polygon. I want to clip lines.
look below code.
C++
Paths subj(2), clip(1), solution;
subj[0] <<IntPoint(180, 200) << IntPoint(260, 200);
subj[1] <<IntPoint(215, 160) << IntPoint(230, 190);
clip[0] <<IntPoint(190, 210) << IntPoint(240, 210) <<IntPoint(240, 130) << IntPoint(190, 130);
Clipper c;
c.AddPaths(subj, ptSubject, false);// run time error here
c.AddPaths(clip, ptClip, true);
c.Execute(ctIntersection, solution, pftNonZero, pftNonZero);

I get below run time error.
Unhandled exception at 0x77004598 in sample.exe: Microsoft C++ exception: ClipperLib::clipperException at memory location 0x009BF054.
Posted
Comments
barneyman 19-Sep-15 19:46pm    
have you tried catching the exception and using the what() method?
kave2011 19-Sep-15 20:03pm    
error is at line of 1060 from clipper.cpp inside AddPath method, at below instruction
int highI = (int)pg.size() -1;
sample.exe!ClipperLib::ClipperBase::AddPath(const std::vector<clipperlib::intpoint,std::allocator<clipperlib::intpoint> > & pg, ClipperLib::PolyType PolyTyp, bool Closed) Line 1060 C++
barneyman 20-Sep-15 0:45am    
http://sourceforge.net/p/polyclipping/code/HEAD/tree/trunk/cpp/clipper.cpp#l1061

it's not excepting on that line, but throwing just before it ...

learn how to catch and handle exceptions

http://www.tutorialspoint.com/cplusplus/cpp_exceptions_handling.htm
Richard MacCutchan 20-Sep-15 7:49am    
What is the value of variable c and what is the value of the parameters on the line that causes the error?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900