- if(SUIT_Session::session()->activeApplication()->desktop()->activeWindow()->getViewManager()->getType()
- != OCCViewer_Viewer::Type() || tds.ShapeType() != TopAbs_EDGE)
- return false;
-
- OCCViewer_ViewPort3d* vp3d = ((OCCViewer_ViewWindow*)SUIT_Session::session()->activeApplication()->desktop()->activeWindow())->getViewPort();
- Handle( V3d_View) view3d = vp3d->getView();
- Standard_Real Width, Height;
- view3d->Size(Width, Height);
- const Standard_Real aHeight = (Width + Height) / 50.0;
-
- try {
- Standard_Real first, last;
- Handle(Geom_Curve) curv = BRep_Tool::Curve(TopoDS::Edge(tds), first, last);
- if(!curv->IsCN(1))
- return false;
-
- const Standard_Real param = (first+last) / 2.0;
- gp_Pnt middleParamPoint;
- gp_Vec V1;
- curv->D1( param, middleParamPoint, V1);
- if(V1.Magnitude() < Precision::Confusion())
- return false;
-
- /* Topology orientation not geom orientation */
- if(tds.Orientation() == TopAbs_REVERSED)
- V1 *= -1.0;
-
- gp_Ax2 anAxis( middleParamPoint, gp_Dir(V1));
- const Standard_Real radius1 = aHeight / 5.0;
- if(radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion()) {
- ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape();
- return true;
+ TopoDS_Shape ArrowCone;
+
+ SUIT_ViewWindow* view = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
+ if ( view && view->getViewManager()->getType() == OCCViewer_Viewer::Type() && shape.ShapeType() == TopAbs_EDGE ) {
+ Handle(V3d_View) view3d = ((OCCViewer_ViewWindow*)view)->getViewPort()->getView();
+ Standard_Real Width, Height;
+ view3d->Size( Width, Height );
+ const Standard_Real aHeight = (Width + Height) / 50.0;
+
+ try {
+ Standard_Real first, last;
+ Handle(Geom_Curve) curv = BRep_Tool::Curve( TopoDS::Edge( shape ), first, last );
+ if ( !curv.IsNull() && curv->IsCN(1) ) {
+ const Standard_Real param = ( first+last ) / 2.0;
+ gp_Pnt middleParamPoint;
+ gp_Vec V1;
+ curv->D1( param, middleParamPoint, V1 );
+ if ( V1.Magnitude() > Precision::Confusion() ) {
+ /* Topology orientation not geom orientation */
+ if ( shape.Orientation() == TopAbs_REVERSED )
+ V1 *= -1.0;
+
+ gp_Ax2 anAxis( middleParamPoint, gp_Dir( V1 ) );
+ const Standard_Real radius1 = aHeight / 5.0;
+ if ( radius1 > 10.0 * Precision::Confusion() && aHeight > 10.0 * Precision::Confusion() )
+ ArrowCone = BRepPrimAPI_MakeCone( anAxis, radius1, 0.0, aHeight ).Shape();
+ }
+ }
+ }
+ catch ( Standard_Failure& ) {
+ // OCC failures are hard to catch in GUI.
+ // This is because of the position for #include <Standard_ErrorHandler.hxx> that is very critical to find
+ // in SALOME environment : compilation error !