0027523: Visualization - selection owner contains obsolete shape
[occt.git] / src / QABugs / QABugs_19.cxx
index 7ee6034..4903457 100644 (file)
@@ -54,6 +54,7 @@
 #include <TopExp_Explorer.hxx>
 
 #include <SelectMgr_Filter.hxx>
+#include <StdSelect_BRepOwner.hxx>
 
 #include <Standard_Version.hxx>
 
@@ -1364,7 +1365,7 @@ static Standard_Integer OCC24945 (Draw_Interpretor& di, Standard_Integer argc, c
   return 0;
 }
 
-#include <Extrema_FuncExtPS.hxx>
+#include <Extrema_FuncPSNorm.hxx>
 #include <math_FunctionSetRoot.hxx>
 #include <math_Vector.hxx>
 #include <BRepBuilderAPI_MakeVertex.hxx>
@@ -1401,7 +1402,7 @@ static Standard_Integer OCC24137 (Draw_Interpretor& theDI, Standard_Integer theN
 
   gp_Pnt aPnt = BRep_Tool::Pnt (aVert), aRes;
 
-  Extrema_FuncExtPS    anExtFunc;
+  Extrema_FuncPSNorm    anExtFunc;
   math_FunctionSetRoot aRoot (anExtFunc, aNbIts);
 
   math_Vector aTolUV (1, 2), aUVinf  (1, 2), aUVsup  (1, 2), aFromUV (1, 2);
@@ -3740,7 +3741,6 @@ static Standard_Integer OCC25574 (Draw_Interpretor& theDI, Standard_Integer /*ar
     }
 
     // set the same angles in quaternion
-    gp_Quaternion aQuat;
     aQuat.SetEulerAngles (gp_EulerSequence(i), anAngle[0], anAngle[1], anAngle[2]);
 
     gp_Mat aRQ = aQuat.GetMatrix();
@@ -3808,7 +3808,6 @@ static Standard_Integer OCC25574 (Draw_Interpretor& theDI, Standard_Integer /*ar
     q.Set(0.06766916507860499, 0.21848101129786085, 0.11994599260380681,0.9660744746954637);
 
     q.GetEulerAngles(gp_Intrinsic_ZYX, alpha,beta, gamma);
-    Standard_Real alpha2,beta2,gamma2;
     q.GetEulerAngles(gp_Extrinsic_XYZ, alpha2,beta2,gamma2);
 
     // gp_Intrinsic_ZYX and gp_Extrinsic_XYZ should produce the same values of angles but in opposite order
@@ -5053,6 +5052,187 @@ static Standard_Integer OCC27048(Draw_Interpretor& theDI, Standard_Integer theAr
   return 0;
 }
 
+//========================================================================
+//function : OCC27065
+//purpose  : Tests overloaded method "Generated" of BRepOffsetAPI_MakePipe
+//========================================================================
+static Standard_Integer OCC27065(Draw_Interpretor& di,
+                                 Standard_Integer n, const char** a)
+{
+  if (n < 3) return 1;
+  BRep_Builder BB;
+
+  TopoDS_Shape SpineShape = DBRep::Get(a[1],TopAbs_WIRE);
+  if ( SpineShape.IsNull()) return 1;
+  TopoDS_Wire Spine = TopoDS::Wire(SpineShape);
+
+  TopoDS_Shape Profile = DBRep::Get(a[2]);
+  if ( Profile.IsNull()) return 1;
+
+  BRepOffsetAPI_MakePipe aPipeBuilder(Spine, Profile);
+  if (!aPipeBuilder.IsDone())
+  {
+    di << "Error: failed to create pipe\n";
+    return 1;
+  }
+
+  TopExp_Explorer Explo(Profile, TopAbs_SHELL);
+  TopoDS_Shape aShape;
+  TopTools_ListIteratorOfListOfShape itl;
+  if (Explo.More())
+  {
+    aShape = Explo.Current();
+    TopoDS_Compound res1;
+    BB.MakeCompound(res1);
+    itl.Initialize(aPipeBuilder.Generated(aShape));
+    for (; itl.More(); itl.Next())
+      BB.Add(res1, itl.Value());
+    DBRep::Set("res_shell", res1);
+  }
+
+  Explo.Init(Profile, TopAbs_FACE);
+  if (Explo.More())
+  {
+    aShape = Explo.Current();
+    TopoDS_Compound res2;
+    BB.MakeCompound(res2);
+    itl.Initialize(aPipeBuilder.Generated(aShape));
+    for (; itl.More(); itl.Next())
+      BB.Add(res2, itl.Value());
+    DBRep::Set("res_face", res2);
+  }
+  
+  Explo.Init(Profile, TopAbs_WIRE);
+  if (Explo.More())
+  {
+    aShape = Explo.Current();
+    TopoDS_Compound res3;
+    BB.MakeCompound(res3);
+    itl.Initialize(aPipeBuilder.Generated(aShape));
+    for (; itl.More(); itl.Next())
+      BB.Add(res3, itl.Value());
+    DBRep::Set("res_wire", res3);
+  }
+  
+  Explo.Init(Profile, TopAbs_EDGE);
+  if (Explo.More())
+  {
+    aShape = Explo.Current();
+    TopoDS_Compound res4;
+    BB.MakeCompound(res4);
+    itl.Initialize(aPipeBuilder.Generated(aShape));
+    for (; itl.More(); itl.Next())
+      BB.Add(res4, itl.Value());
+    DBRep::Set("res_edge", res4);
+  }
+  
+  Explo.Init(Profile, TopAbs_VERTEX);
+  if (Explo.More())
+  {
+    aShape = Explo.Current();
+    TopoDS_Compound res5;
+    BB.MakeCompound(res5);
+    itl.Initialize(aPipeBuilder.Generated(aShape));
+    for (; itl.More(); itl.Next())
+      BB.Add(res5, itl.Value());
+    DBRep::Set("res_vertex", res5);
+  }
+  
+  return 0;
+}
+
+//========================================================================
+//function : OCC27318
+//purpose  : Creates a box that is not listed in map of AIS objects of ViewerTest
+//========================================================================
+static Standard_Integer OCC27318 (Draw_Interpretor& /*theDI*/, Standard_Integer /*theArgc*/, const char** theArgv)
+{
+  const Handle(AIS_InteractiveContext)& aCtx = ViewerTest::GetAISContext();
+  if (aCtx.IsNull())
+  {
+    std::cout << "No interactive context. Use 'vinit' command before " << theArgv[0] << "\n";
+    return 1;
+  }
+
+  TopoDS_Shape aBox = BRepPrimAPI_MakeBox (20, 20, 20).Shape();
+  Handle(AIS_Shape) aBoxObj = new AIS_Shape (aBox);
+  aCtx->Display (aBoxObj, Standard_True);
+
+  return 0;
+}
+
+//========================================================================
+//function : OCC27523
+//purpose  : Checks recomputation of deactivated selection mode after object's redisplaying
+//========================================================================
+static Standard_Integer OCC27523 (Draw_Interpretor& theDI, Standard_Integer theArgNb, const char** theArgVec)
+{
+  if (theArgNb != 1)
+  {
+    std::cerr << "Error: wrong number of arguments! See usage:\n";
+    theDI.PrintHelp (theArgVec[0]);
+    return 1;
+  }
+
+  Handle(AIS_InteractiveContext) anAISContext = ViewerTest::GetAISContext();
+  if(anAISContext.IsNull())
+  {
+    std::cerr << "Error: no active view. Please call vinit.\n";
+    return 1;
+  }
+
+  gp_Pnt aStart (100, 100, 100);
+  gp_Pnt anEnd (300, 400, 600);
+  BRepBuilderAPI_MakeEdge anEdgeBuilder (aStart, anEnd);
+  TopoDS_Edge anEdge = anEdgeBuilder.Edge();
+  Handle(AIS_InteractiveObject) aTestAISShape = new AIS_Shape (anEdge);
+  anAISContext->Display (aTestAISShape);
+
+  // activate it in selection modes
+  TColStd_SequenceOfInteger aModes;
+  aModes.Append (AIS_Shape::SelectionMode ((TopAbs_ShapeEnum) TopAbs_VERTEX));
+
+  anAISContext->OpenLocalContext();
+  anAISContext->Deactivate (aTestAISShape);
+  anAISContext->Load (aTestAISShape, -1, true);
+  anAISContext->Activate (aTestAISShape, 0);
+  anAISContext->Deactivate (aTestAISShape, 0);
+
+  // activate in vertices mode
+  for (Standard_Integer anIt = 1; anIt <= aModes.Length(); ++anIt)
+  {
+    anAISContext->Activate (aTestAISShape, aModes (anIt));
+  }
+
+  TopoDS_Shape aVertexShape = BRepBuilderAPI_MakeVertex (gp_Pnt (75, 0, 0));
+  TopAbs_ShapeEnum aVertexShapeType = aVertexShape.ShapeType();
+  Handle(AIS_Shape)::DownCast (aTestAISShape)->Set (aVertexShape);
+  aTestAISShape->Redisplay();
+
+  anAISContext->AddOrRemoveSelected (aTestAISShape);
+
+  bool aValidShapeType = false;
+  for (anAISContext->InitSelected(); anAISContext->MoreSelected(); anAISContext->NextSelected())
+  {
+    Handle(SelectMgr_EntityOwner) anOwner = anAISContext->SelectedOwner();
+    Handle(StdSelect_BRepOwner) aBRO = Handle(StdSelect_BRepOwner)::DownCast (anOwner);
+    if (!aBRO.IsNull() && aBRO->HasShape())
+    {
+      TopoDS_Shape aShape = aBRO->Shape();
+
+      aValidShapeType = aShape.ShapeType() == aVertexShapeType;
+    }
+  }
+
+  if (!aValidShapeType)
+  {
+    std::cerr << "Error: shape type is invalid.\n";
+    return 1;
+  }
+
+  return 0;
+}
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -5163,5 +5343,16 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
                    "OCC27048 surf U V N\nCalculate value of surface N times in the point (U, V)",
                    __FILE__, OCC27048, group);
   
+  theCommands.Add ("OCC27065",
+                   "OCC27065 spine profile",
+                   __FILE__, OCC27065, group);
+
+  theCommands.Add ("OCC27318",
+                   "OCC27318: Creates a box that is not listed in map of AIS objects of ViewerTest",
+                   __FILE__, OCC27318, group);
+  theCommands.Add ("OCC27523",
+                   "OCC27523: Checks recomputation of deactivated selection mode after object's redisplaying",
+                   __FILE__, OCC27523, group);
+
   return;
 }