
Wed, 06/10/2015 - 19:13
Forums:
I am trying to convert an interactive object to ais_shape as follows but it's failing.
m_pDocument->GetAISContext()->InitSelected();
Handle_AIS_InteractiveObject aRefObject = m_pDocument->GetAISContext()->SelectedInteractive();
m_pDocument->set_target_object(aRefObject);
Handle_AIS_Shape anIS = Handle_AIS_Shape::DownCast(aRefObject);
TopoDS_Shape shape = anIS->Shape();
My aRefObject is valid but anIS is coming null no values after DownCast. Please help me what could be the problem??
Regards
Sujan
Thu, 06/11/2015 - 11:32
Could it be that nothing is selected when you call SelectedInteractive()?
Thu, 06/11/2015 - 11:35
Your selection may not be an AIS_Shape. Check the selection using
AIS_InteractiveObject->IsKind(STANDARD_TYPE(AIS_Shape));
Thu, 06/11/2015 - 12:45
Yes now the shape is coming. I am trying to join two boxes, by the following. The face is coming properly for the second box but Location is not coming. So it's not connecting. Please help me to resolve it.
m_pDocument->GetAISContext()->InitSelected();
Handle_AIS_InteractiveObject aRefObject = m_pDocument->GetAISContext()->SelectedInteractive();
m_pDocument->set_target_object(aRefObject);
Handle_Standard_Transient anISTrans = Handle_Standard_Transient::DownCast(aRefObject);
Handle_AIS_Shape anIS = Handle_AIS_Shape::DownCast(anISTrans);
TopoDS_Shape shape = anIS->Shape();
TopLoc_Location aLoc;
TopoDS_Face cylindricalFace;
ofstream out("Debug.txt");
for( TopExp_Explorer ex(shape, TopAbs_FACE); ex.More(); ex.Next() )
{
TopoDS_Face currentFace = TopoDS::Face( ex.Current() );
BRepAdaptor_Surface brepAdaptorSurface( currentFace,Standard_True );
cout << ex.Depth();
out << brepAdaptorSurface.GetType() << "\n";
if( brepAdaptorSurface.GetType() == GeomAbs_Plane || brepAdaptorSurface.GetType() == GeomAbs_BSplineSurface )
{
aLoc = currentFace.Location();
break;
}
}
out.close();
Handle_AIS_ConnectedInteractive anInstance = new AIS_ConnectedInteractive;
anInstance->Connect (m_pDocument->get_source_object(), aLoc);
anInstance->Redisplay();
Thu, 06/11/2015 - 12:47
if( brepAdaptorSurface.GetType() == GeomAbs_Plane || brepAdaptorSurface.GetType() == GeomAbs_BSplineSurface )
{
aLoc = currentFace.Location();
break;
}
Here aLoc is coming NULL........I want to join one face of the box with the other box.
Please help me how can I do it..?