GithubHelp home page GithubHelp logo

Comments (3)

AngusJohnson avatar AngusJohnson commented on August 21, 2024 1

the red clip rect is long and narrow and it should not appear in the solution.

The red clip rect region was only included in the image above to show the location of the clipping rect.
It's not part of the solution.
The only parts of the solution in the image above are the 4 dark green very narrow rectangles.
These correspond to the 4 regions indicated by the coordinates in the box immediately above the image.

the solution's bounding box should have similar width and height as the rect, for below unittest, it will fail.

RectClip is an INTERSECTION operation so the solution will only be those regions where subject and clip rectangle overlap. So in this case, the width of a rectangle that bounds the solution would be considerably smaller than the width of the clip rect itself.

from clipper2.

AngusJohnson avatar AngusJohnson commented on August 21, 2024
void Test()
{
  Paths64 sub, clp, sol;
  Rect64 rect;
  sub.push_back(MakePath({ 559306,72464, 559090,72464, 559090,72454, 558178,72454, 558178,72464,
   557962,72464, 557962,72284, 558534,72284, 558534,72274, 558734,72274,
   558734,72284, 559306,72284 }));
  sub.push_back(MakePath({ 557306,72464, 557090,72464, 557090,72454, 556178,72454, 556178,72464,
   555962,72464, 555962,72284, 556534,72284, 556534,72274, 556734,72274,
   556734,72284, 557306,72284 }));

  rect = Rect64(551604, 72454, 560834, 72459);
  sol = ExecuteRectClip(rect, sub, false);
  std::cout << sol << std::endl;

  clp.push_back(rect.AsPath());
  SvgWriter svg;
  SvgAddSubject(svg, sub, FillRule::NonZero);
  SvgAddClip(svg, clp, FillRule::NonZero);
  SvgAddSolution(svg, sol, FillRule::NonZero, false);
  SvgSaveToFile(svg, "c:\\temp\\tmp.svg", 600,600);
  System("c:\\temp\\tmp.svg");
}

Looks fine to me.

558178,72454 , 558178,72459 , 557962,72459 , 557962,72454
559306,72454 , 559306,72459 , 559090,72459 , 559090,72454
556178,72454 , 556178,72459 , 555962,72459 , 555962,72454
557306,72454 , 557306,72459 , 557090,72459 , 557090,72454

tmp

from clipper2.

gigglesun avatar gigglesun commented on August 21, 2024

@AngusJohnson the red clip rect is long and narrow and it should not appear in the solution. the solution's bounding box should have similar width and height as the rect, for below unittest, it will fail.

    Paths64 sub, sol;
     Rect64 rect;

     sub.push_back(MakePath({559306,72464, 559090,72464, 559090,72454, 558178,72454, 558178,72464,
      557962,72464, 557962,72284, 558534,72284, 558534,72274, 558734,72274,
      558734,72284, 559306,72284}));

     sub.push_back(MakePath({ 557306,72464, 557090,72464, 557090,72454, 556178,72454, 556178,72464,
      555962,72464, 555962,72284, 556534,72284, 556534,72274, 556734,72274,
      556734,72284, 557306,72284 }));

     rect = Rect64(551604, 72454, 560834, 72459);
     sol = ExecuteRectClip(rect, sub, false);

    const auto sol_bounds = GetBounds(sol);
    EXPECT_EQ(sol_bounds.Width(), rect.Width());
    EXPECT_EQ(sol_bounds.Height(), rect.Height());

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.