You code snippet is incomplete. I'm unable to reproduce the problem - cylinder is selected as expected, so maybe your complete scenario has some different elements.
#include <AIS_Shape.hxx>
#include <BRepPrimAPI_MakeBox.hxx>
#include <BRepPrimAPI_MakeSphere.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepPrimAPI_MakeCone.hxx>
#include <BRepPrimAPI_MakeTorus.hxx>
Handle(AIS_Shape) CreateBox(double width, double height, double length)
{
TopoDS_Shape shape = BRepPrimAPI_MakeBox(width, height, length).Shape();
return new AIS_Shape(shape);
}
Handle(AIS_Shape) CreateSphere(double radius)
{
TopoDS_Shape shape = BRepPrimAPI_MakeSphere(radius).Shape();
return new AIS_Shape(shape);
}
Handle(AIS_Shape) CreateCylinder(double radius, double height)
{
TopoDS_Shape shape = BRepPrimAPI_MakeCylinder(radius, height).Shape();
return new AIS_Shape(shape);
}
Handle(AIS_Shape) CreateCone(double bottomRadius, double topRadius, double height)
{
TopoDS_Shape shape = BRepPrimAPI_MakeCone(bottomRadius, topRadius, height).Shape();
return new AIS_Shape(shape);
}
Handle(AIS_Shape) CreateTorus(double majorRadius, double minorRadius)
{
TopoDS_Shape shape = BRepPrimAPI_MakeTorus(majorRadius, minorRadius).Shape();
return new AIS_Shape(shape);
}
static Standard_Integer VTest (Draw_Interpretor&,
Standard_Integer theArgNb,
const char** theArgVec)
{
if (ViewerTest::GetAISContext().IsNull()) { return 1; }
Handle(AIS_Shape) aCyl = CreateCylinder (100, 200);
ViewerTest::Display ("s", aCyl);
ViewerTest::CurrentView()->FitAll();
Graphic3d_Vec2i minPos(-1000000, -1000000);
Graphic3d_Vec2i maxPos(1000000, 1000000);
ViewerTest::GetAISContext()->SelectRectangle(minPos, maxPos, ViewerTest::CurrentView());
ViewerTest::CurrentView()->Redraw();
return 0;
}pload VISUALIZATION MODELING
vinit View1
vtest