Unable to select to model surface at the mouse point position

Hello,

We encountered a problem while developing the OCCT program that we're unable to select the step model surface at mouse point position.Sometimes we did not select the surface where the mouse point was located, but the back of the step model.

1. Here's the codes to import step model;
void OCCFeature::ImportStepFile(const char* fileName)
{
STEPControl_Reader aReader_Step;
aReader_Step.ReadFile(fileName);
aReader_Step.PrintCheckLoad(Standard_False, IFSelect_ItemsByEntity);
aReader_Step.TransferRoots();

TopoDS_Shape aShape = aReader_Step.OneShape();
Handle(AIS_Shape) aisShape = new AIS_Shape(aShape);
aisShape->SetColor(Quantity_NOC_GRAY);

this->Context->Display(aisShape, false);
this->Context->Activate(aisShape, AIS_Shape::SelectionMode(TopAbs_FACE));

this->View->FitAll();
}

2. Here's the codes to HighLight;
this->Context->MoveTo(x, y, this->View, true);

3. Here's the codes to Select;
this->Context->SelectDetected();
this->Context->UpdateCurrentViewer();

gkv311 n's picture

Could you share the model reproducing issue?

Vispec DMIS's picture

Sure. Please change the file suffix name from .info to .step, because we are unable to upload the .step file.

gkv311 n's picture

Indeed, you have stepped into the bug:

pload XDE VISUALIZATION
testreadstep d:/Boeing737RightWheel.stp s
vinit View1
vdisplay s -dispMode 1
vfit
vselmode s FACE 1
vpoint p 300 300 -2d -nosel
vmoveto  300 300
vstate -entities

The issue occur on Select3D_SensitiveCylinder (entity for picking cylindrical surfaces, which is new in OCCT 7.7 #0032547). Maybe you may try reporting a bug on Bugtracker.

Wang Yue's picture

In the function GetSensitiveForFace in the file StdSelect_BRepSelectionTool.cxx, if the following codes are commented out, for a body of revolution generated by rotating one polygon, the selection operation can be finished correctly.

else if (Handle(Geom_CylindricalSurface) aGeomCyl = Handle(Geom_CylindricalSurface)::DownCast (aSurf))
{
const gp_Cylinder aCyl = BRepAdaptor_Surface (theFace).Cylinder();
gp_Ax3 aPos = aCyl.Position();
gp_Dir aDirection = aPos.Direction();

if (isCylinderOrCone (theFace, aPos.Location(), aDirection))
{
const Standard_Real aRad = aCyl.Radius();
const Standard_Real aHeight = getCylinderHeight (aTriangulation, aLoc);

gp_Trsf aTrsf;
aPos.SetDirection (aDirection);
aTrsf.SetTransformation (aPos, gp::XOY());

Handle(Select3D_SensitiveCylinder) aSensSCyl = new Select3D_SensitiveCylinder (theOwner, aRad, aRad, aHeight, aTrsf, true);
theSensitiveList.Append (aSensSCyl);
return Standard_True;
}
}