Cylinder and Cone are not selected

Hi,

I'm trying to make a rubber band selection feature. But I've found a weird situation.

When I drag all shapes in my view, some specific shapes were not selected. It was Cylinder and Cone

Here is my sample test code. I made 5 functions for creating shapes. Box, Sphere, Cylinder, Cone, Torus. Like below..

Handle(AISShape) CreateBox(double width, double height, double length)
{
    TopoDS_Shape shape = BRepPrimAPI_MakeBox(width, height, length).Shape();
    return new AIS_Shape(shape);
}

Handle(AISShape) CreateSphere(double radius)
{
    TopoDS_Shape shape = BRepPrimAPI_MakeSphere(radius).Shape();
    return new AIS_Shape(shape);
}

Handle(AISShape) CreateCylinder(double radius, double height)
{
    TopoDS_Shape shape = BRepPrimAPI_MakeCylinder(radius, height).Shape();
    return new AIS_Shape(shape);
}

Handle(AISShape) CreateCone(double bottomRadius, double topRadius, double height)
{
    TopoDS_Shape shape = BRepPrimAPI_MakeCone(bottomRadius, topRadius, height).Shape();
    return new AIS_Shape(shape);
}

Handle(AISShape) CreateTorus(double majorRadius, double minorRadius)
{
    TopoDS_Shape shape = BRepPrimAPI_MakeTorus(majorRadius, minorRadius).Shape();
    return new AIS_Shape(shape);
}

And for testing, I called the below lines. It should select all shapes in the scene.

Graphic3d_Vec2i minPos(-1000000, -1000000);
Graphic3d_Vec2i maxPos(1000000, 1000000);

context->SelectRectangle(minPos, maxPos, view);

But it selects all shapes except Cylinder and Cone !! Box, Sphere, and Torus were selected correctly. Am I doing wrong something? I'm using the OCCT 7.6.1

Kirill Gavrilov's picture

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