1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: ModuleBase_ViewerPrs.cpp
4 // Created: 20 Apr 2014
5 // Author: Natalia ERMOLAEVA
7 #include "ModuleBase_ViewerPrs.h"
9 #include <ModuleBase_ResultPrs.h>
11 ModuleBase_ViewerPrs::ModuleBase_ViewerPrs()
16 ModuleBase_ViewerPrs::ModuleBase_ViewerPrs(ObjectPtr theResult,
17 const GeomShapePtr& theShape,
18 Handle_SelectMgr_EntityOwner theOwner)
19 : myResult(theResult),
25 ModuleBase_ViewerPrs::~ModuleBase_ViewerPrs()
29 bool ModuleBase_ViewerPrs::operator==(const ModuleBase_ViewerPrs& thePrs)
31 bool isEqualResult = (myResult.get() == thePrs.object().get());
32 bool isEqualShape = (!myShape.get() && !thePrs.shape().get()) ||
33 (myShape.get() && myShape->isEqual(thePrs.shape()));
34 bool isEqualIO = (myInteractive == thePrs.interactive()) == Standard_True;
36 bool isEqualOwner = (myOwner.Access() == thePrs.owner().Access());
37 if (isEqualResult && isEqualShape && isEqualIO &&
38 !isEqualOwner) { /// owners are different
39 // as we might loading object with the same shape in different modes like
40 // "objects" and "other", it is possible that two owners are created linked
41 // to one shape. We should accept such ViewerPrs as equal to current in order
42 // to do not use the same <result, shape> twice
43 Handle(StdSelect_BRepOwner) anOwner1 = Handle(StdSelect_BRepOwner)::DownCast(myOwner);
44 Handle(StdSelect_BRepOwner) anOwner2 = Handle(StdSelect_BRepOwner)::DownCast(thePrs.owner());
45 if (!anOwner1.IsNull() && !anOwner2.IsNull())
46 isEqualOwner = anOwner1->Shape() == anOwner2->Shape();
49 if (isEqualResult && isEqualShape &&
50 !isEqualIO) { /// AIS are different
51 // check that the owner is a fictive owner for compsolid object, created in the
52 // ComputeSelection of ModuleBase_ResultPrs. A new owner is created there for each subsolid
53 // and set in the sub-solid AIS. ViewerPrs of these fictive owners are accepted as equal
54 // as they use the same shape and result(of compsolid)
55 Handle(ModuleBase_BRepOwner) aCSolidOwner1 = Handle(ModuleBase_BRepOwner)::DownCast(myOwner);
56 Handle(ModuleBase_BRepOwner) aCSolidOwner2 = Handle(ModuleBase_BRepOwner)::DownCast(thePrs.owner());
57 isEqualIO = !aCSolidOwner1.IsNull() && !aCSolidOwner2.IsNull();
58 if (!aCSolidOwner1.IsNull() && !aCSolidOwner1.IsNull())
59 isEqualOwner = aCSolidOwner1->Shape() == aCSolidOwner1->Shape();
62 return isEqualResult && isEqualShape && isEqualOwner && isEqualIO;