|
楼主 |
发表于 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;
} |
|