Ticket #86: placement-debug.patch

File placement-debug.patch, 2.8 kB (added by artem, 8 months ago)
  • src/placement_finder.cpp

     
    549549      const double initial_distance = distance; 
    550550       
    551551      std::auto_ptr<placement_element> current_placement(new placement_element); 
     552      std::cerr << std::endl << "   Trying new placement at: " << index << ", distance: " << distance << std::endl; 
    552553 
    553554      double string_height = p.info.get_dimensions().second; 
    554555      double old_x = path_positions[index-1].x; 
     
    561562      double dy = new_y - old_y; 
    562563       
    563564      double segment_length = path_distances[index]; 
    564        
     565 
    565566      current_placement->starting_x = old_x + dx*distance/segment_length; 
    566567      current_placement->starting_y = old_y + dy*distance/segment_length; 
    567568      double angle = atan2(-dy, dx); 
     
    584585         c = ci.character; 
    585586 
    586587         //Coordinates this character will start at 
     588         std::cerr << "length:" << segment_length << std::endl; 
     589         assert(segment_length != 0); 
    587590         double start_x = old_x + dx*distance/segment_length; 
    588591         double start_y = old_y + dy*distance/segment_length; 
    589592         //Coordinates this character ends at, calculated below 
    590593         double end_x = 0; 
    591594         double end_y = 0; 
    592           
    593          if (segment_length - distance  >= ci.width)  
     595 
     596         if (segment_length - distance  >= ci.width) 
    594597         { 
    595598            //if the distance remaining in this segment is enough, we just go further along the segment 
    596599            distance += ci.width; 
     
    626629               start_x, start_y, ci.width,  
    627630               old_x, old_y, new_x, new_y,  
    628631               end_x, end_y); //results are stored in end_x, end_y 
     632            assert(!isnan(end_y)); 
     633            assert(!isnan(end_x)); 
    629634 
    630635            //Need to calculate distance on the new segment 
    631636            distance = sqrt(pow(old_x - end_x, 2) + pow(old_y - end_y, 2)); 
     
    669674         current_placement->add_node(c,render_x - current_placement->starting_x,  
    670675                                       -render_y + current_placement->starting_y,  
    671676                                       render_angle); 
     677         std::cerr << "   add_node: " << render_x << "," << current_placement->starting_x << "," <<  render_y << "," << current_placement->starting_y << "," << render_angle << std::endl; 
    672678          
    673679         //Normalise to 0 <= angle < 2PI 
    674680         while (render_angle >= 2*M_PI) 
     
    779785      double A = dx * dx + dy * dy; 
    780786      double B = 2 * (dx * (x1 - cx) + dy * (y1 - cy)); 
    781787      double C = (x1 - cx) * (x1 - cx) + (y1 - cy) * (y1 - cy) - radius * radius; 
     788      assert(!isnan(B)); 
    782789    
    783790      double det = B * B - 4 * A * C; 
    784791      if (A <= 0.0000001 || det < 0)