Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of uninitialized variable in NGon2D.ih #1540

Closed
danoan opened this issue Jan 5, 2021 · 1 comment
Closed

Use of uninitialized variable in NGon2D.ih #1540

danoan opened this issue Jan 5, 2021 · 1 comment

Comments

@danoan
Copy link
Contributor

danoan commented Jan 5, 2021

In line 98 of file DGtal/shapes/parametric/NGon2D.ih, the variable angle uses itself in its definition

  const double angle = t - myPhi + (angle < 0.0 ? NGON2D_2_PI : 0.);

I suggest to rewrite as

  double angle = t - myPhi;
  angle = (angle < 0.0) ? angle + NGON2D_2_PI : angle;

A consequence of this error can be materialized by digitizing a triangle

#include <DGtal/helpers/StdDefs.h>
#include <DGtal/io/boards/Board2D.h>

#include <DGtal/shapes/GaussDigitizer.h>
#include <DGtal/shapes/Shapes.h>
#include <DGtal/shapes/parametric/NGon2D.h>

int main(int argc, char* argv[]) {
  using namespace DGtal::Z2i;

  typedef DGtal::NGon2D<Space> Shape;
  double PI = 3.14159265359;
  Shape shape(0,0,20,3,PI/2);

  DGtal::GaussDigitizer<Space, Shape> gd;
  double h =0.5;
  gd.attach(shape);
  gd.init(shape.getLowerBound(), shape.getUpperBound(), h);

  Domain domain(gd.getDomain().lowerBound(),
                gd.getDomain().upperBound());
  DigitalSet output(domain);
  DGtal::Shapes<Domain>::digitalShaper(output, gd);

  DGtal::Board2D board;
  board << output;
  board.saveSVG("triangle.svg");

  return 0;
}

triangle

@phcerdan
Copy link
Member

Fixed in #1541

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants