1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: PartSet_Filters.cpp
4 // Created: 19 Jun 2015
5 // Author: Natalia ERMOLAEVA
7 #include "PartSet_FilterInfinite.h"
9 #include <AIS_InteractiveObject.hxx>
10 #include <AIS_Shape.hxx>
11 #include <TopoDS_Shape.hxx>
12 #include <StdSelect_BRepOwner.hxx>
14 IMPLEMENT_STANDARD_HANDLE(PartSet_FilterInfinite, SelectMgr_Filter);
15 IMPLEMENT_STANDARD_RTTIEXT(PartSet_FilterInfinite, SelectMgr_Filter);
17 Standard_Boolean PartSet_FilterInfinite::IsOk(const Handle(SelectMgr_EntityOwner)& theOwner) const
19 Standard_Boolean aValid = Standard_True;
20 Handle(AIS_InteractiveObject) anAISObj =
21 Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
22 if (!anAISObj.IsNull()) {
23 Handle(AIS_InteractiveObject) anObj =
24 Handle(AIS_InteractiveObject)::DownCast(theOwner->Selectable());
25 Handle(AIS_Shape) aAISShape = Handle(AIS_Shape)::DownCast(anObj);
26 if (!aAISShape.IsNull()) {
27 TopoDS_Shape anAISShape = aAISShape->Shape();
28 if (!anAISShape.IsNull() && anAISShape.Infinite()) {
29 aValid = Standard_False;
30 // for infinite object, the selection is possible only for shapes of owners, which are coincide
31 // to the shape of corresponded AIS object. In other words, for axis, only edge can be selected
32 // (vertices are not selectable), for planes, only faces can be selected (not edges or vertices)
33 TopoDS_Shape anOwnerShape;
34 Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast(theOwner);
35 if( !aBRO.IsNull() ) {
36 anOwnerShape = aBRO->Shape();
37 if (!anOwnerShape.IsNull()) {
38 aValid = anAISShape.ShapeType() == anOwnerShape.ShapeType();