Ticket #172 (closed: fixed)

Opened 12 years ago

Last modified 5 years ago

Fix track direction bug

Reported by: Nick Draper Owned by: Ronald Fowler
Priority: major Milestone: Iteration 10
Component: Keywords:
Cc: Blocked By:
Blocking: Tester:

Description

There is a bug that track find hits in both directions, when they should only report forward facing intersections.

I have tracked this down to this place.

void
      LineIntersectVisit::procTrack() 
      /*!
      Sorts the PtOut and distances
      with a closes first order.
      */
    {
      // Calculate the distances to the points
      DOut.resize(PtOut.size());
      transform(PtOut.begin(),PtOut.end(),DOut.begin(),
        boost::bind(&Geometry::V3D::distance,ATrack.getOrigin(),_1));
      return;
    }

The call to distance always returns a positive value, and therefore the selection code in object Intercept surface cannot exclude the reverse points.

    int
      Object::interceptSurface(Geometry::Track& UT) const
      /*!
      Given a track, fill the track with valid section
      \param UT :: Initial track
      \return Number of segments added
      */
    {
      int cnt(0);         // Number of intesections
      // Loop over all the surfaces.

      LineIntersectVisit LI(UT.getInit(),UT.getUVec());
      std::vector<const Surface*>::const_iterator vc;
      for(vc=SurList.begin();vc!=SurList.end();vc++)
      {
        (*vc)->acceptVisitor(LI);
      }
      const std::vector<Geometry::V3D>& IPts(LI.getPoints());
      const std::vector<double>& dPts(LI.getDistance());

      for(unsigned int i=0;i<IPts.size();i++)
      {
        if (dPts[i]>0.0)  // only interested in forward going points
        {
          // Is the point and enterance/exit Point
          const int flag=calcValidType(IPts[i],UT.getUVec());
          UT.addPoint(ObjName,flag,IPts[i]);
          cnt++;
        }
      }
      UT.buildLink();
      return UT.count();
    }

Change History

comment:1 Changed 12 years ago by Ronald Fowler

(In [1154]) Have changed the Line::lambdaPair function to only return the +ve solutions of quadratic surface/line intercepts. This makes cylinders, spheres and quadratic intercepts consistent with behaviour of planes, i.e. only return the intercept in the forward going line direction. Am not certain this is the intended behaviour in all cases. A number of test cases had to altered because of this change. Re #172

comment:2 Changed 12 years ago by Nick Draper

  • Status changed from new to closed
  • Resolution set to fixed

comment:3 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 1020

Note: See TracTickets for help on using tickets.