几何尺寸与公差论坛

 找回密码
 注册
查看: 82|回复: 1

PR 248952 Void Detection is not working for Auto Sphere (Inner/Outer)

[复制链接]
发表于 2009-3-11 20:06:07 | 显示全部楼层 |阅读模式
Void Detection is not working for Auto Sphere (Inner/Outer)
<< Yanhua Huang  --  07/02/07  17:11:25>>
Void Detection is not working for Auto Sphere.
Steps to reproduce:
1) import .cad file
2) import  .ip
Results:
Inner/Outer property imports incorrectly.
Sphere is with inner property  displayed in Edit Window when the Sphere is with outer  property.
Expected Results:
Identify whether Sphere is with inner or outer property via void detection.
<<END>>



<< Yanhua Huang  --  03/11/09  20:20:40>>
tested.
<<END>>
<< Changes made by Yanhua Huang -- 03/11/09  20:20:51>>
Action:  Domenico Varacalli to Yanhua Huang, Status:  RESOLVED to CLOSED
<<END>>
<< Tim Wernicke  --  12/12/07  19:20:02>>
Mimmo, could you please test the fix here?  Thanks.
<<END>>
<< Changes made by Tim Wernicke -- 12/12/07  19:20:06>>
Action:  Tim Wernicke to Domenico Varacalli
<<END>>
<< Yanhua Huang  --  12/12/07  16:33:16>>
Tim,
Please help me to test it. Thanks in advance.
Yanhua
<<END>>
<< Changes made by Yanhua Huang -- 12/12/07  16:33:35>>
Action:  Yanhua Huang to Tim Wernicke
<<END>>
<< Glenn Russell  --  12/06/07  12:53:36>>
Reviewed.  Thanks,
   -Glenn
<<END>>
<< Changes made by Glenn Russell -- 12/06/07  12:54:12>>
Action:  Glenn Russell to Yanhua Huang, Status:  REVIEW to RESOLVED
<<END>>
<< Changes made by Gianni Revello -- 12/06/07  09:56:25>>
Action:  Gianni Revello to Glenn Russell
<<END>>
<< Don Turcotte  --  08/03/07  11:49:16>>
This is now working for inner spheres which should be outer and also for outer spheres which should be inner.
Also corrected some minor problems in auto square slot, auto round slot, and auto cone related to the changes for inner/outer.
Files inserted to server
------------------------
V42\AUTOFEAT\AFCONECONTACT.CPP
V42\AUTOFEAT\AFSLOTROUNDCONTACT.CPP
V42\AUTOFEAT\AFSLOTSQUARECONTACT.CPP
V42\AUTOFEAT\AFSPHERECONTACT.CPP
V42\CONSFEAT\BASIC_SP.CPP
V42\INCLUDE\AFSPHERECONTACT.H
V42\INCLUDE\BASIC_SP.H
V43B\AUTOFEAT\AFCONECONTACT.CPP
V43B\AUTOFEAT\AFSLOTROUNDCONTACT.CPP
V43B\AUTOFEAT\AFSLOTSQUARECONTACT.CPP
V43B\AUTOFEAT\AFSPHERECONTACT.CPP
V43B\CONSFEAT\BASIC_SP.CPP
V43B\INCLUDE\AFSPHERECONTACT.H
V43B\INCLUDE\BASIC_SP.H
<<END>>
<< Changes made by Don Turcotte -- 08/03/07  11:49:36>>
Action:  Don Turcotte to Gianni Revello, Status:  OPEN to REVIEW
<<END>>
<< Don Turcotte  --  08/02/07  17:23:33>>
One of the issues with spheres is that the vector is used to point to the pole so for an inner sphere the vector points opposite to the approach direction.  I overrided GetOptimumTipVector(...) for spheres to account for this.  The VerifyFeature Inner/outer check now works correctly for both inners which should be outers and also outers which should be inners.  I will complete testing tomorrrow.
<<END>>
<< Don Turcotte  --  08/01/07  17:22:00>>
Modified the code to add a VerifyFeature method to check Inout.  Testing in V42 beta.
<<END>>
 楼主| 发表于 2009-3-11 20:06:27 | 显示全部楼层

回复: PR 248952 Void Detection is not working for Auto Sphere (Inner/Outer)

BOOL CPCDAFConeContact::VerifyFeature(BOOL bFullVerification/*=TRUE*/) // PR248951
{
  if( bFullVerification ) // called from path optimizer
  {
    // This method is used by the path optimzer when a program has been imported from the inspection plan in
    //   order to verify that the vector and INOUT flag are correct.
    BOOL bSaveHasUserDefinedHits = m_bHasUserDefinedHits;
    CPCDcommand * pOrigHits = m_Hits;
    m_Hits = NULL;

    CPCDcommand * pOrigSampleHits = m_SampleHits;
    m_SampleHits = NULL;
    int num_sample_hits = Pars.GetNumSampleHits(m_InitSampleHitsNeedToBeTaken);
    Pars.SetNumSampleHits(0);

    m_bHasUserDefinedHits = TRUE; // don't let CreatePathLinesForAFeature() generate hits
    m_bVerifyingFeature = TRUE; // don't care if there are best fit math errors during execution (CheckVector() measures with 1 hit)

    // First, verify vector
    BOOL bFlippedVector = FALSE;
    CPoint3 hit_point, hit_vector;

    gp(CENTROID, THEO, PART, global_align, hit_point);
    gp(VECTOR, THEO, PART, global_align, hit_vector);

    CPoint3 meas_vector;
    gp(VECTOR, MEAS, PART, global_align, meas_vector);

    m_Hits = gen_geometric_hit(m_pPartProgram, hit_point, hit_vector, BASIC_HIT, NULL);

    double MountVectorDotWithTipVector=0;
    if( !CheckVector(&MountVectorDotWithTipVector) || MountVectorDotWithTipVector < -0.087155)
    {
      bFlippedVector = TRUE; // PR245352
      hit_vector = - hit_vector;

      // regenerate the hit with the flipped vector
      m_Hits = remove_hits(m_Hits);
      m_Hits = gen_geometric_hit(m_pPartProgram, hit_point, hit_vector, BASIC_HIT, NULL);

      pp(VECTOR, THEO, PART, global_align, hit_vector);
      pp(VECTOR, TARG, PART, global_align, hit_vector);
      meas_vector = - meas_vector;
      pp(VECTOR, MEAS, PART, global_align, meas_vector);

      if( !CheckVector() )
      {
        // Flipping didn't work, so just restore the original vector.
        bFlippedVector = FALSE;
        hit_vector = - hit_vector;

        pp(VECTOR, THEO, PART, global_align, hit_vector);
        pp(VECTOR, TARG, PART, global_align, hit_vector);

        meas_vector = - meas_vector;
        pp(VECTOR, MEAS, PART, global_align, meas_vector);
      }
    }

    m_Hits = remove_hits(m_Hits);

    // Next verify that INOUT is set correctly
    BOOL bFlippedInOut = FALSE;
    m_bHasUserDefinedHits = FALSE; // let CreatePathLinesForAFeature() generate hits

    // Get the closest tip to use with the corrected vector.
    CPoint3 ph9vect;
    CPoint3 ph9vect2;
    double conical_range;
    GetOptimumTipVector(ph9vect,ph9vect2,&conical_range);

    double save_ph9_warn = global_ph9_warn;
    global_ph9_warn = conical_range;

    long nTipsOnProbe = CountTipsOnProbe(); // PR235149

    CString tip_id;
    CPCDtip_data * tip_data = get_closest_tip(m_pPartProgram, tip_id, ph9vect, 0.0, FALSE, ph9vect2);
    global_ph9_warn = save_ph9_warn;

    m_bHasVoidDetectHits = FALSE; // make sure we re-generate the hits for CreatePathLinesForAFeature()

    if( tip_data )
    {
      if( CreatePathLinesForAFeature(m_pPartProgram, tip_data, SINGLEFEATURE_CREATEPATH, this, TRUE, FALSE) )
      {
        // We had a collision, so trying flipping the INOUT bit
        sbit(INOUT,bit(INOUT)?0:1);
        bFlippedInOut = TRUE;

        // The vector on a cone is always from apex to large end.  If we change INOUT, we need to flip the vector.
        hit_vector = - hit_vector;
        pp(VECTOR, THEO, PART, global_align, hit_vector);
        pp(VECTOR, TARG, PART, global_align, hit_vector);

        meas_vector = - meas_vector;
        pp(VECTOR, MEAS, PART, global_align, meas_vector);

        DeleteTipIfAdded(tip_data,nTipsOnProbe); // PR235149
        GetOptimumTipVector(ph9vect,ph9vect2,&conical_range);

        save_ph9_warn = global_ph9_warn;
        global_ph9_warn = conical_range;

        long nTipsOnProbe = CountTipsOnProbe(); // PR235149

        CString tip_id;
        CPCDtip_data * tip_data = get_closest_tip(m_pPartProgram, tip_id, ph9vect, 0.0, FALSE, ph9vect2);
        global_ph9_warn = save_ph9_warn;

        if( tip_data )
        {
          if( CreatePathLinesForAFeature(m_pPartProgram, tip_data, SINGLEFEATURE_CREATEPATH, this, TRUE, FALSE) )
          {
            // We still have a collision, so just restore the INOUT bit
            sbit(INOUT,bit(INOUT)?0:1);
            bFlippedInOut = FALSE;

            // The vector on a cone is always from apex to large end.  If we change INOUT, we need to flip the vector.
            hit_vector = - hit_vector;
            pp(VECTOR, THEO, PART, global_align, hit_vector);
            pp(VECTOR, TARG, PART, global_align, hit_vector);

            meas_vector = - meas_vector;
            pp(VECTOR, MEAS, PART, global_align, meas_vector);
          }
        }
      }
      DeleteTipIfAdded(tip_data,nTipsOnProbe); // PR235149
    }

    sbit(PATH_OPTIMIZER_VECTOR_FLIP,FALSE); // Tell the path optimizer that this feature is ok // PR244312

    // PR244714 - If the feature has user defined hits, restore the original hits, else delete the original hits.
    m_bHasUserDefinedHits = bSaveHasUserDefinedHits;
    Pars.SetNumSampleHits(num_sample_hits);
    if( m_bHasUserDefinedHits )
    {
      m_Hits = remove_hits(m_Hits);
      m_Hits = pOrigHits;
      if( bFlippedInOut ) // flip the vectors on the hits
      {
        CPCDbasic_hit *my_hit = (CPCDbasic_hit*) m_Hits;
        while (my_hit)
        {
          CPoint3 Vector;
          my_hit->gp(VECTOR, THEO, PART, global_align, Vector);
          Vector = - Vector;
          my_hit->pp(VECTOR, THEO, PART, global_align, Vector);
          my_hit->pp(VECTOR, MEAS, PART, global_align, Vector);
          my_hit = (CPCDbasic_hit*) my_hit->next;
        }
      }

      m_SampleHits = pOrigSampleHits; // PR245352 - No sample hits were generated by VerifyFeature since num_sample_hits was temporarily set to 0.
      if( bFlippedVector ) // PR245352 - flip the vectors on the sample points
      {
        CPCDbasic_hit *my_hit = (CPCDbasic_hit*) m_SampleHits;
        while (my_hit)
        {
          CPoint3 Vector;
          my_hit->gp(VECTOR, THEO, PART, global_align, Vector);
          Vector = - Vector;
          my_hit->pp(VECTOR, THEO, PART, global_align, Vector);
          my_hit->pp(VECTOR, MEAS, PART, global_align, Vector);

          // PR246607 - Also move the THEO sample points by the thickness
          if(m_pPartProgram->m_bOptimizeAdjustTheoThickness)
          { // also need to adjust the theoretical values
            CPoint3 theo;
            my_hit->gp(CENTROID, THEO, PART, global_align, theo);
            CPoint3 thick;
            gp(THICKNESS, MEAS, PART, NULL, thick);
            CPoint3 theo_adjusted = theo + (Vector * thick[0]);
            my_hit->pp(CENTROID, THEO, PART, global_align, theo_adjusted);
            my_hit->pp(CENTROID, TARG, PART, global_align, theo_adjusted);
            my_hit->pp(CENTROID, MEAS, PART, global_align, theo_adjusted);
          }

          my_hit = (CPCDbasic_hit*) my_hit->next;
        }
      }
    }
    else
    {
      pOrigHits = remove_hits(pOrigHits);
      pOrigSampleHits = remove_hits(pOrigSampleHits);
      GenerateHits_Private(TRUE);
    }
    m_bVerifyingFeature = FALSE;
  }
  else // Just generate the hits (called from ip import)
  {
    GenerateHits_Private(TRUE);
  }

  return TRUE;
}
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-22 19:31 , Processed in 0.038772 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表