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

region.removeHalfspace(surface, side (+1, -1) ) seg faults #427

Open
GiudGiud opened this issue Jul 2, 2019 · 0 comments
Open

region.removeHalfspace(surface, side (+1, -1) ) seg faults #427

GiudGiud opened this issue Jul 2, 2019 · 0 comments

Comments

@GiudGiud
Copy link
Contributor

GiudGiud commented Jul 2, 2019

When trying to modify a geometry manually (not a common use case), with the surface, and region containing the halfspace having been defined from Python, I get a seg fault. Posting the code below if someone has an idea of why. My guess is memory ownership issues.

`
/**

  • @brief Removes a Node from this Region.
  • @details //FIXME Does not handle complex CSG cells, only intersections
  • @param surface the surface of Halfspace to remove
  • @param halfspace the side of that surface
    /
    void Region::removeHalfspace(Surface
    surface, int halfspace) {

if (surface != NULL) {

std::vector<Region*>::iterator iter1;

/* Loop through nodes in region to check for the same Halfspace */
for ( ; iter1 != _nodes.end();) {

    if (dynamic_cast<Halfspace*>(*iter1)) {
      Halfspace* iter2 = dynamic_cast<Halfspace*>(*iter1);
      if (iter2->getSurface()->getId() == surface->getId() && 
          iter2->getHalfspace() == halfspace) {

        //delete iter2; FIXME Memory leak (seg faults with and without)
        _nodes.erase(iter1);
    }
  }
  else
    ++iter1;
}

}
}
`

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

No branches or pull requests

1 participant