OpenCASCADE 6.9.1(估计从6.9.0开始),使用新的屏幕选择算法,我使用6.8开发的程序,升级到6.9.1之后,使用IVTK部分模型无法选中几何元素,经过调试发现6.9.1代码有BUG,导致数据丢失,无法判断选中的元素是否在选择范围,BUG出现的文件为SelectMgr_RectangularFrustum.cxx中的函数ScaleAndTransform
NCollection_Handle<SelectMgr_BaseFrustum> SelectMgr_RectangularFrustum::ScaleAndTransform (const Standard_Integer theScaleFactor,
const gp_Trsf& theTrsf)
{
Standard_ASSERT_RAISE (theScaleFactor > 0,
"Error! Pixel tolerance for selection should be greater than zero");
SelectMgr_RectangularFrustum* aRes = new SelectMgr_RectangularFrustum();
const Standard_Boolean isToScale = theScaleFactor != 1;
const Standard_Boolean isToTrsf = theTrsf.Form() != gp_Identity;
if (!isToScale && !isToTrsf)
return aRes ;//这里,当部分模型满足该条件,返回一个空的数据,使用该数据无法判断模型是否在区域
aRes->myIsOrthographic = myIsOrthographic;
SelectMgr_RectangularFrustum* aRef = this;
if (isToScale)
{
aRes->myNearPickedPnt = myNearPickedPnt;
aRes->myFarPickedPnt = myFarPickedPnt;
aRes->myViewRayDir = myViewRayDir;
const gp_Pnt2d aMinPnt (myMousePos.X() - theScaleFactor * 0.5,
myMousePos.Y() - theScaleFactor * 0.5);
const gp_Pnt2d aMaxPnt (myMousePos.X() + theScaleFactor * 0.5,
myMousePos.Y() + theScaleFactor * 0.5);
// recompute base frustum characteristics from scratch
computeFrustum (aMinPnt, aMaxPnt, myBuilder, aRes->myVertices, aRes->myEdgeDirs);
aRef = aRes;
}
if (isToTrsf)
{
aRes->myNearPickedPnt = aRef->myNearPickedPnt.Transformed (theTrsf);
aRes->myFarPickedPnt = aRef->myFarPickedPnt.Transformed (theTrsf);
aRes->myViewRayDir = aRes->myFarPickedPnt.XYZ() - aRes->myNearPickedPnt.XYZ();
// LeftTopNear
aRes->myVertices[0] = aRef->myVertices[0].Transformed (theTrsf);
// LeftTopFar
aRes->myVertices[1] = aRef->myVertices[1].Transformed (theTrsf);
// LeftBottomNear
aRes->myVertices[2] = aRef->myVertices[2].Transformed (theTrsf);
// LeftBottomFar
aRes->myVertices[3] = aRef->myVertices[3].Transformed (theTrsf);
// RightTopNear
aRes->myVertices[4] = aRef->myVertices[4].Transformed (theTrsf);
// RightTopFar
aRes->myVertices[5] = aRef->myVertices[5].Transformed (theTrsf);
// RightBottomNear
aRes->myVertices[6] = aRef->myVertices[6].Transformed (theTrsf);
// RightBottomFar
aRes->myVertices[7] = aRef->myVertices[7].Transformed (theTrsf);
// Horizontal
aRes->myEdgeDirs[0] = aRes->myVertices[4].XYZ() - aRes->myVertices[0].XYZ();
// Vertical
aRes->myEdgeDirs[1] = aRes->myVertices[2].XYZ() - aRes->myVertices[0].XYZ();
// LeftLower
aRes->myEdgeDirs[2] = aRes->myVertices[2].XYZ() - aRes->myVertices[3].XYZ();
// RightLower
aRes->myEdgeDirs[3] = aRes->myVertices[6].XYZ() - aRes->myVertices[7].XYZ();
// LeftUpper
aRes->myEdgeDirs[4] = aRes->myVertices[0].XYZ() - aRes->myVertices[1].XYZ();
// RightUpper
aRes->myEdgeDirs[5] = aRes->myVertices[4].XYZ() - aRes->myVertices[5].XYZ();
}
// compute frustum normals
computeNormals (aRes->myEdgeDirs, aRes->myPlanes);
cacheVertexProjections (aRes);
return NCollection_Handle<SelectMgr_BaseFrustum> (aRes);
}