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
Takeshi Mita's picture

Hello,

I encountered a similar problem.

If the camera is set to perspective, some types of shapes, like cylinder and cone, and shapes built by boolean operations using such shapes are not selected by rectangle selection. I attached a TCL script to reproduce the problem by modifying a sample in the page https://draw.sview.ru/modeling-solids-primitives/.

I would like to know whether some additional settings are required for the perspective camera option or if it is a bug that needs to be fixed.

Tried OCCT Versions were 7.7.0, 7.8.0, and 7.8.1 on Windows 10; the problem was reproduced on all of them.

Thank you in advance.

Attachments: 
Dmitrii Pasukhin's picture

Hello.thank toy for sharing. I assume issue is related with: 5

https://tracker.dev.opencascade.org/view.php?id=33664

I will increase priority for the issue! The problem resolved, but solution needs improvements.

Best regards, Dmitrii.