For all issues regarding the Forums use, please, refer to the Forum Rules.

Our Solutions

Need professional assistance?
Consider our:

Support Offerings

 

Need to speed up your development?
Have a look at our:

Samples & Tools

 

Need some functionality extending standard OCCT capabilities?
Check out our:

Adv. Components

Related pages

Interactive selection of vertex – no shape of type vertex

Stefan Sicklinger's picture
Forums: 

~~Interactive selection of vertex – no shape of type vertex

Hello,
I would like to raise the following question as I am new to OCCT 7.

I would like to interactively select a vertex of an edge. The edge is generated and displayed via the following code:

 //3D cartesian point
 gp_Pnt mGp_Pnt_Start = gp_Pnt(0., 0., 0.);
 gp_Pnt mGp_Pnt_End = gp_Pnt(0., 100., 100.);
 Handle(Geom_TrimmedCurve) aTrimmedCurve = GC_MakeSegment(mGp_Pnt_Start, mGp_Pnt_End);
 TopoDS_Edge mTopoEdge = BRepBuilderAPI_MakeEdge(aTrimmedCurve);

 Handle(AIS_Shape) aisSegmentB = new AIS_Shape(mTopoEdge);
 aisSegmentB->SetColor(Quantity_NOC_RED);
 aisSegmentB->SetWidth(4.);
 myOccViewer->getContext()->Display(aisSegmentB, 1, 1, Standard_True, Standard_True);

The interactive section within the 3dViewer seems to work as the vertices are highlighted when I hoover the mouse. However, when I check with this following code if the vertex is selected a edge (type=6) is return and no vertex.

void StartWindow::handleSelectionChanged(void){
 for (myOccViewer->getContext()->InitCurrent(); myOccViewer->getContext()->MoreCurrent(); myOccViewer->getContext()->NextCurrent())
 {
  Handle(AIS_InteractiveObject) anIO = myOccViewer->getContext()->SelectedInteractive();
  TopoDS_Shape vertexShape = Handle(AIS_Shape)::DownCast(anIO)->Shape();

  cout << "Here I get only 6: " << vertexShape.ShapeType() << endl;

  if (TopAbs_VERTEX == vertexShape.ShapeType())
  {
   gp_Pnt myPoint = BRep_Tool::Pnt(TopoDS::Vertex(vertexShape));
   cout << "=========="<< endl;
   cout << "X: " << myPoint.X() << endl;
   cout << "Y: " << myPoint.Y() << endl;
   cout << "Z: " << myPoint.Z() << endl;
   cout << "==========" << endl;
  }
  i++;
 }}

Could you please provide a hint what the problem might be? I looked already through the tutorial and could not find a solution to my problem.