|
楼主 |
发表于 2008-5-27 11:48:45
|
显示全部楼层
回复: Task 103855 – Parallelism of plane with projection length and width
1.
V44B\DIMENS\DIM_PARA.CPP
CPCDdim_parallel::CPCDdim_parallel(CPCDpart_program *pProgram, CBitVector in_flagword,
CPCDcommand* in_feature1,
CPCDcommand* in_feature2,
LPCTSTR in_id,
m_matlCondPrimary = DAT_RFS;
m_matlCondSecondary = DAT_RFS;
m_matlCondTertiary = DAT_RFS;
m_pDrf = NULL;
m_bPlaneProjectedZone = FALSE;
m_bPlaneProjectionMajorMinor = TRUE;
m_PlaneProjectedZoneLength = 0.0;
m_PlaneProjectedZoneWidth = 0.0;
}
void CPCDdim_parallel::GetProjectedCornerPoints(CPCDcommand * pFeature,double length,double width,CArray<CPoint3,CPoint3> & points)
{
if( pFeature )
{
CPoint3 centroid;
pFeature->gp(CENTROID, MEAS, PART, global_align, centroid);
CPoint3 vector;
pFeature->gp(VECTOR, MEAS, PART, global_align, vector);
CPoint3 major;
// Figure out which workplane makes sense to project onto the measured plane by using
// the THEO vector of the plane. Projecting the workplane onto the measured plane will
// allow us to determine the directions of length and width.
CPoint3 theo_vector;
pFeature->gp(VECTOR, THEO, PART, global_align, theo_vector);
int Index = 0;
(void)theo_vector.maxabs(&Index);
// Get the orientation of length and width.
switch( Index )
{
case 0: // max THEO component in X
major = CPoint3(0.,1.,0.); // MAJOR == Y
break;
case 1: // max THEO component in Y
major = CPoint3(1.,0.,0.); // MAJOR == X
break;
case 2: // max THEO component in Z
major = CPoint3(1.,0.,0.); // MAJOR == X
break;
}
CPoint3 third = vector.cross(major);
CPoint3 length_dir = third.cross(vector);
length_dir.normalize();
CPoint3 width_dir = vector.cross(length_dir);
width_dir.normalize();
CPoint3 machine_pt;
CPoint3 corner_pt = centroid;
ConvertCoordinateSystem(PART,ZPAXIS,corner_pt,MACHINE,TOP,machine_pt,global_align,FALSE,this);
points.Add(machine_pt);
corner_pt += length * length_dir;
ConvertCoordinateSystem(PART,ZPAXIS,corner_pt,MACHINE,TOP,machine_pt,global_align,FALSE,this);
points.Add(machine_pt);
corner_pt += width * width_dir;
ConvertCoordinateSystem(PART,ZPAXIS,corner_pt,MACHINE,TOP,machine_pt,global_align,FALSE,this);
points.Add(machine_pt);
corner_pt -= length * length_dir;
ConvertCoordinateSystem(PART,ZPAXIS,corner_pt,MACHINE,TOP,machine_pt,global_align,FALSE,this);
points.Add(machine_pt);
}
} |
|