+ if( !aBRO.IsNull() && aBRO->HasShape() ) {
+ TopoDS_Shape aShape = aBRO->Shape();
+ Handle(ModuleBase_ResultPrs) aPrsObj =
+ Handle(ModuleBase_ResultPrs)::DownCast(aBRO->Selectable());
+ if (!aPrsObj.IsNull()) {
+ if (aPrsObj->isSubstituted()) {
+ if (aPrsObj->Shape().IsSame(aShape))
+ aShape = aPrsObj->originalShape();
+ }
+ }
+ // the located method is called in the context to obtain the shape by the SelectedShape()
+ // method, so the shape is located by the same rules
+ aShape = aShape.Located(aBRO->Location() * aShape.Location());
+#ifdef BEFORE_TRIHEDRON_PATCH
+#ifndef DEBUG_DELIVERY
+ if (aShape.IsNull())
+ aShape = findAxisShape(anIO);
+#endif
+#endif
+ if (!aShape.IsNull()) {
+ std::shared_ptr<GeomAPI_Shape> aGeomShape =
+ std::shared_ptr<GeomAPI_Shape>(new GeomAPI_Shape());
+ aGeomShape->setImpl(new TopoDS_Shape(aShape));
+ thePrs->setShape(aGeomShape);
+ }
+ } else {
+#ifdef DEBUG_DELIVERY
+ // Fill by trihedron shapes
+#ifdef BEFORE_TRIHEDRON_PATCH
+ Handle(AIS_Axis) aAxis = Handle(AIS_Axis)::DownCast(anIO);
+ DocumentPtr aDoc = ModelAPI_Session::get()->moduleDocument();
+ int aSize = aDoc->size(ModelAPI_ResultConstruction::group());
+ ObjectPtr aObj;
+ if (!aAxis.IsNull()) {
+ // an Axis from Trihedron
+ gp_Lin aLine = aAxis->Component()->Lin();
+ gp_Dir aDir = aLine.Direction();
+ std::string aAxName;
+ if (aDir.X() == 1.)
+ aAxName = "OX";
+ else if (aDir.Y() == 1.)
+ aAxName = "OY";
+ else if (aDir.Z() == 1.)
+ aAxName = "OZ";
+ if (aAxName.length() > 0) {
+ ResultPtr aAx;
+ for (int i = 0; i < aSize; i++) {
+ aObj = aDoc->object(ModelAPI_ResultConstruction::group(), i);
+ if (aObj->data()->name() == aAxName) {
+ aAx = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ break;
+ }
+ }
+ if (aAx.get()) {
+ thePrs->setObject(aAx);
+ thePrs->setShape(aAx->shape());
+ return;
+ }
+ }
+ } else {
+ Handle(AIS_Point) aPoint = Handle(AIS_Point)::DownCast(anIO);
+ if (!aPoint.IsNull()) {
+ // An origin point from trihedron
+ ResultPtr aOrigin;
+ for (int i = 0; i < aSize; i++) {
+ aObj = aDoc->object(ModelAPI_ResultConstruction::group(), i);
+ if (aObj->data()->name() == "Origin") {
+ aOrigin = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ break;
+ }
+ }
+ if (aOrigin.get()) {
+ thePrs->setObject(aOrigin);
+ thePrs->setShape(aOrigin->shape());
+ return;
+ }
+ }
+ }
+#else
+ /// find axis direction
+ Handle(AIS_TrihedronOwner) aTrihedronOwner = Handle(AIS_TrihedronOwner)::DownCast(theOwner);
+ if (!aTrihedronOwner.IsNull()) {
+ const Prs3d_DatumParts& aPart = aTrihedronOwner->DatumPart();
+ std::wstring aName;
+ switch (aPart) {
+ case Prs3d_DP_Origin: aName = L"Origin"; break;
+ case Prs3d_DP_XAxis: aName = L"OX"; break;
+ case Prs3d_DP_YAxis: aName = L"OY"; break;
+ case Prs3d_DP_ZAxis: aName = L"OZ"; break;
+ default: break;
+ }
+ if (aName.length() > 0) {
+ DocumentPtr aDoc = ModelAPI_Session::get()->moduleDocument();
+ int aSize = aDoc->size(ModelAPI_ResultConstruction::group());
+ ObjectPtr aObj;
+ ResultPtr aResult;
+ for (int i = 0; i < aSize; i++) {
+ aObj = aDoc->object(ModelAPI_ResultConstruction::group(), i);
+ if (aObj->data()->name() == aName) {
+ aResult = std::dynamic_pointer_cast<ModelAPI_ResultConstruction>(aObj);
+ break;
+ }
+ }
+ if (aResult.get()) {
+ thePrs->setObject(aResult);
+ thePrs->setShape(aResult->shape());
+ return;
+ }
+ }
+ }
+#endif
+#endif
+ }
+