From: Roy Stogner <roystgnr@ic...>  20060623 15:38:20

On Thu, 22 Jun 2006, Derek Gaston wrote: > elem::contains_point() is using the same flawed logic to decide > whether or not the point is contained in the element (meaning the > newton iterations). What's happening is that the newton iterations > are failing to converge so severely that the final guess as where the > point is... actually lies within the element! Thus giving a false > positive. This is what I was afraid of  the fix is as I suggested the other day: if the Newton iteration doesn't converge, return a point like (1.e6,1.e6,1.e6) so we don't get a false positive from contains_point(). > So here's the deal... inverse_map is _NOT_ a good idea to use for > finding out if the point lies within the element! I think I disagree. These Newton failures should only happen if the element is badly twisted or if the point is outside the element, right? So in that case, if we just return a junk point when Newton fails, we should still get correct results. > My question is this: contains_point() is a virtual function right? > Can we not just override it in the concrete classes so that we don't > have to do this newton thing at all? I mean a quad4 should be able to > figure out pretty quickly whether or not a point lies in it.... > without all the newton iteration stuff. Sure we can leave the newton > stuff to fall back on in case we don't want to implement > contains_point in a concrete_class... but for elements for which it > would be easy (maybe even trivial?) to do it for manually... why not? > PS: Yes, this is me "volunteering" to go write contains_point() > functions for all our dang elements ;) Works for me! I'm not sure how much of an improvement you can make in general, but at the very least it might be a little optimization for TRI3/QUAD4. For the more complicated geometric elements you might try testing has_affine_map() first  if the element transformation is affine (and I don't know about your weird smoothed meshes but in my meshes most of the elements are affine) then you can implement contains_point with n_sides inequality tests.  Roy 