#include <DBRep.hxx>
#include <DrawTrSurf.hxx>
#include <ViewerTest.hxx>
+#include <V3d_View.hxx>
#include <TopoDS_Shape.hxx>
#include <AIS_InteractiveContext.hxx>
#include <AIS_TexturedShape.hxx>
#include <TCollection_HAsciiString.hxx>
#include <GeomFill_Trihedron.hxx>
#include <BRepOffsetAPI_MakePipe.hxx>
+#include <Standard_Atomic.hxx>
#include <Standard_Version.hxx>
#ifdef HAVE_TBB
-#include <Standard_Atomic.hxx>
#include <tbb/blocked_range.h>
#include <tbb/parallel_for.h>
std::cout << "Usage : " << a[0] << "\n";
return 1;
}
-
- if (sizeof (char*) > 4) {
+
+ int i = sizeof (char*);
+ if (i > 4) {
std::cout << "64-bit architecture is not supported.\n";
return 0;
}
return 0;
}
+//=======================================================================
+//function : OCC25043
+//purpose :
+//=======================================================================
+#include <BRepAlgoAPI_Check.hxx>
+static Standard_Integer OCC25043 (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ if (theArgNb != 2) {
+ theDI << "Usage: " << theArgVec[0] << " shape\n";
+ return 1;
+ }
+
+ TopoDS_Shape aShape = DBRep::Get(theArgVec[1]);
+ if (aShape.IsNull())
+ {
+ theDI << theArgVec[1] << " shape is NULL\n";
+ return 1;
+ }
+
+ BRepAlgoAPI_Check anAlgoApiCheck(aShape, Standard_True, Standard_True);
+
+ if (!anAlgoApiCheck.IsValid())
+ {
+ BOPAlgo_ListIteratorOfListOfCheckResult anCheckIter(anAlgoApiCheck.Result());
+ for (; anCheckIter.More(); anCheckIter.Next())
+ {
+ const BOPAlgo_CheckResult& aCurCheckRes = anCheckIter.Value();
+ const BOPCol_ListOfShape& aCurFaultyShapes = aCurCheckRes.GetFaultyShapes1();
+ BOPCol_ListIteratorOfListOfShape aFaultyIter(aCurFaultyShapes);
+ for (; aFaultyIter.More(); aFaultyIter.Next())
+ {
+ const TopoDS_Shape& aFaultyShape = aFaultyIter.Value();
+
+ Standard_Boolean anIsFaultyShapeFound = Standard_False;
+ TopExp_Explorer anExp(aShape, aFaultyShape.ShapeType());
+ for (; anExp.More() && !anIsFaultyShapeFound; anExp.Next())
+ {
+ if (anExp.Current().IsEqual(aFaultyShape))
+ anIsFaultyShapeFound = Standard_True;
+ }
+
+ if (!anIsFaultyShapeFound)
+ {
+ theDI << "Error. Faulty Shape is NOT found in source shape.\n";
+ return 0;
+ }
+ else
+ {
+ theDI << "Info. Faulty shape if found in source shape\n";
+ }
+ }
+ }
+ }
+ else
+ {
+ theDI << "Error. Problems are not detected. Test is not performed.";
+ }
+
+ return 0;
+}
+
+//=======================================================================
+//function : OCC24606
+//purpose :
+//=======================================================================
+static Standard_Integer OCC24606 (Draw_Interpretor& theDI,
+ Standard_Integer theArgNb,
+ const char** theArgVec)
+{
+ if (theArgNb > 1)
+ {
+ std::cerr << "Error: incorrect number of arguments.\n";
+ theDI << "Usage : " << theArgVec[0] << "\n";
+ return 1;
+ }
+
+ Handle(V3d_View) aView = ViewerTest::CurrentView();
+ if (aView.IsNull())
+ {
+ std::cerr << "Errro: no active view, please call 'vinit'.\n";
+ return 1;
+ }
+
+ aView->DepthFitAll();
+ aView->FitAll();
+
+ return 0;
+}
+
//=======================================================================
//function : OCC23010
//purpose :
return 0;
}
+//=======================================================================
+//function : OCC25202
+//purpose :
+//=======================================================================
+#include <ShapeBuild_ReShape.hxx>
+static Standard_Integer OCC25202 ( Draw_Interpretor& theDI,
+ Standard_Integer theArgN,
+ const char** theArgVal)
+{
+ // 0 1 2 3 4 5 6
+ //reshape res shape numF1 face1 numF2 face2
+ if(theArgN < 7)
+ {
+ theDI << "Use: reshape res shape numF1 face1 numF2 face2\n";
+ return 1;
+ }
+
+ TopoDS_Shape aShape = DBRep::Get(theArgVal[2]);
+ const Standard_Integer aNumOfRE1 = Draw::Atoi(theArgVal[3]),
+ aNumOfRE2 = Draw::Atoi(theArgVal[5]);
+ TopoDS_Face aShapeForRepl1 = TopoDS::Face(DBRep::Get(theArgVal[4])),
+ aShapeForRepl2 = TopoDS::Face(DBRep::Get(theArgVal[6]));
+
+ if(aShape.IsNull())
+ {
+ theDI << theArgVal[2] << " is null shape\n";
+ return 1;
+ }
+
+ if(aShapeForRepl1.IsNull())
+ {
+ theDI << theArgVal[4] << " is not a replaced type\n";
+ return 1;
+ }
+
+ if(aShapeForRepl2.IsNull())
+ {
+ theDI << theArgVal[6] << " is not a replaced type\n";
+ return 1;
+ }
+
+
+ TopoDS_Shape aReplacedShape;
+ ShapeBuild_ReShape aReshape;
+
+ //////////////////// explode (begin)
+ TopTools_MapOfShape M;
+ M.Add(aShape);
+ Standard_Integer aNbShapes = 0;
+ for (TopExp_Explorer ex(aShape,TopAbs_FACE); ex.More(); ex.Next())
+ {
+ const TopoDS_Shape& Sx = ex.Current();
+ Standard_Boolean added = M.Add(Sx);
+ if (added)
+ {
+ aNbShapes++;
+ if(aNbShapes == aNumOfRE1)
+ {
+ aReplacedShape = Sx;
+
+ aReshape.Replace(aReplacedShape, aShapeForRepl1);
+ }
+
+ if(aNbShapes == aNumOfRE2)
+ {
+ aReplacedShape = Sx;
+
+ aReshape.Replace(aReplacedShape, aShapeForRepl2);
+ }
+ }
+ }
+ //////////////////// explode (end)
+
+ if(aReplacedShape.IsNull())
+ {
+ theDI << "There is not any shape for replacing.\n";
+ }
+
+ DBRep::Set (theArgVal[1],aReshape.Apply (aShape,TopAbs_WIRE,2));
+
+ return 0;
+}
+
+#include <ShapeFix_Wireframe.hxx>
+//=======================================================================
+//function : OCC7570
+//purpose :
+//=======================================================================
+static Standard_Integer OCC7570 (Draw_Interpretor& di, Standard_Integer n, const char** a)
+{
+ if (n != 2) {
+ di<<"Usage: "<<a[0]<<" invalid number of arguments"<<"\n";
+ return 1;
+ }
+ TopoDS_Shape in_shape (DBRep::Get (a[1]));
+ ShapeFix_Wireframe fix_tool (in_shape);
+ fix_tool.ModeDropSmallEdges () = Standard_True;
+ fix_tool.SetPrecision (1.e+6);
+ fix_tool.SetLimitAngle (0.01);
+ fix_tool.FixSmallEdges ();
+ TopoDS_Shape new_shape = fix_tool.Shape ();
+ return 0;
+}
+
+#include <AIS_TypeFilter.hxx>
+//=======================================================================
+//function : OCC25340
+//purpose :
+//=======================================================================
+static Standard_Integer OCC25340 (Draw_Interpretor& /*theDI*/,
+ Standard_Integer /*theArgNb*/,
+ const char** /*theArgVec*/)
+{
+ Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext();
+ if (aCtx.IsNull())
+ {
+ std::cerr << "Error: No opened viewer!\n";
+ return 1;
+ }
+ Handle(AIS_TypeFilter) aFilter = new AIS_TypeFilter (AIS_KOI_Shape);
+ aCtx->AddFilter (aFilter);
+ return 0;
+}
+
/*****************************************************************************/
+#include <GeomAPI_IntSS.hxx>
+//=======================================================================
+//function : OCC25100
+//purpose :
+//=======================================================================
+static Standard_Integer OCC25100 (Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
+{
+ if (argc < 2)
+ {
+ di << "the method requires a shape name\n";
+ return 1;
+ }
+
+ TopoDS_Shape S = DBRep::Get(argv[1]);
+ if ( S.IsNull() )
+ {
+ di << "Shape is empty" << "\n";
+ return 1;
+ }
+
+ TopExp_Explorer aFaceExp(S, TopAbs_FACE);
+ const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(TopoDS::Face(aFaceExp.Current()));
+
+ GeomAPI_IntSS anIntersector(aSurf, aSurf, Precision::Confusion());
+
+ if (!anIntersector.IsDone())
+ {
+ di << "Error. Intersection is not done\n";
+ return 1;
+ }
+
+ di << "Test complete\n";
+
+ return 0;
+}
+
+//=======================================================================
+//function : OCC25348
+//purpose :
+//=======================================================================
+static Standard_Integer OCC25348 (Draw_Interpretor& theDI,
+ Standard_Integer /*theArgNb*/,
+ const char** /*theArgVec*/)
+{
+ Handle(NCollection_IncAllocator) anAlloc1;
+ NCollection_List<int> aList1(anAlloc1);
+ for (int i=0; i < 10; i++)
+ {
+ Handle(NCollection_IncAllocator) anAlloc2;
+ NCollection_List<int> aList2(anAlloc2);
+ aList2.Append(i);
+ aList1.Assign(aList2);
+ }
+ theDI << "Test complete\n";
+ return 0;
+}
+
+#include <IntCurvesFace_ShapeIntersector.hxx>
+#include <BRepBndLib.hxx>
+//=======================================================================
+//function : OCC25413
+//purpose :
+//=======================================================================
+static Standard_Integer OCC25413 (Draw_Interpretor& di, Standard_Integer narg , const char** a)
+{
+ if (narg != 2) {
+ di << "Usage: " << a[0] << " invalid number of arguments" << "\n";
+ return 1;
+ }
+ TopoDS_Shape aShape = DBRep::Get (a[1]);
+
+ IntCurvesFace_ShapeIntersector Inter;
+ Inter.Load(aShape, Precision::Confusion());
+
+ Bnd_Box aBndBox;
+ BRepBndLib::Add(aShape, aBndBox);
+
+ gp_Dir aDir(0., 1., 0.);
+ const int N = 250;
+ Standard_Real xMin = aBndBox.CornerMin().X();
+ Standard_Real zMin = aBndBox.CornerMin().Z();
+ Standard_Real xMax = aBndBox.CornerMax().X();
+ Standard_Real zMax = aBndBox.CornerMax().Z();
+ Standard_Real xStep = (xMax - xMin) / N;
+ Standard_Real zStep = (zMax - zMin) / N;
+
+ for (Standard_Real x = xMin; x <= xMax; x += xStep)
+ for (Standard_Real z = zMin; z <= zMax; z += zStep)
+ {
+ gp_Pnt aPoint(x, 0.0, z);
+ gp_Lin aLine(aPoint, aDir);
+ Inter.PerformNearest(aLine, -100., 100.);
+ }
+ return 0;
+}
+
+
+#include <BOPAlgo_PaveFiller.hxx>
+//
+#include <BRepAlgoAPI_BooleanOperation.hxx>
+#include <BRepAlgoAPI_Common.hxx>
+#include <BRepAlgoAPI_Fuse.hxx>
+#include <BRepAlgoAPI_Cut.hxx>
+#include <BRepAlgoAPI_Section.hxx>
+//
+#include <BOPTools.hxx>
+//
+#include <BOPCol_MapOfShape.hxx>
+#include <BOPCol_ListOfShape.hxx>
+//=======================================================================
+//function : OCC25446
+//purpose :
+//=======================================================================
+static Standard_Integer OCC25446 (Draw_Interpretor& theDI,
+ Standard_Integer argc,
+ const char ** argv)
+{
+ if (argc != 5) {
+ theDI << "Usage: OCC25446 res b1 b2 op\n";
+ return 1;
+ }
+ //
+ TopoDS_Shape aS1 = DBRep::Get(argv[2]);
+ if (aS1.IsNull()) {
+ theDI << argv[2] << " shape is NULL\n";
+ return 1;
+ }
+ //
+ TopoDS_Shape aS2 = DBRep::Get(argv[3]);
+ if (aS2.IsNull()) {
+ theDI << argv[3] << " shape is NULL\n";
+ return 1;
+ }
+ //
+ Standard_Integer iOp;
+ BOPAlgo_Operation aOp;
+ //
+ iOp = Draw::Atoi(argv[4]);
+ if (iOp < 0 || iOp > 4) {
+ theDI << "Invalid operation type\n";
+ return 1;
+ }
+ aOp = (BOPAlgo_Operation)iOp;
+ //
+ Standard_Integer iErr;
+ BOPCol_ListOfShape aLS;
+ BOPAlgo_PaveFiller aPF;
+ //
+ aLS.Append(aS1);
+ aLS.Append(aS2);
+ aPF.SetArguments(aLS);
+ //
+ aPF.Perform();
+ iErr = aPF.ErrorStatus();
+ if (iErr) {
+ theDI << "Intersection failed with error status: " << iErr << "\n";
+ return 1;
+ }
+ //
+ BRepAlgoAPI_BooleanOperation* pBuilder = NULL;
+ //
+ switch (aOp) {
+ case BOPAlgo_COMMON:
+ pBuilder = new BRepAlgoAPI_Common(aS1, aS2, aPF);
+ break;
+ case BOPAlgo_FUSE:
+ pBuilder = new BRepAlgoAPI_Fuse(aS1, aS2, aPF);
+ break;
+ case BOPAlgo_CUT:
+ pBuilder = new BRepAlgoAPI_Cut (aS1, aS2, aPF);
+ break;
+ case BOPAlgo_CUT21:
+ pBuilder = new BRepAlgoAPI_Cut(aS1, aS2, aPF, Standard_False);
+ break;
+ case BOPAlgo_SECTION:
+ pBuilder = new BRepAlgoAPI_Section(aS1, aS2, aPF);
+ break;
+ default:
+ break;
+ }
+ //
+ iErr = pBuilder->ErrorStatus();
+ if (!pBuilder->IsDone()) {
+ theDI << "BOP failed with error status: " << iErr << "\n";
+ return 1;
+ }
+ //
+ const TopoDS_Shape& aRes = pBuilder->Shape();
+ DBRep::Set(argv[1], aRes);
+ //
+ BOPCol_MapOfShape aMapArgs, aMapShape;
+ BOPCol_MapIteratorOfMapOfShape aIt;
+ Standard_Boolean bIsDeletedHist, bIsDeletedMap;
+ TopAbs_ShapeEnum aType;
+ //
+ BOPTools::MapShapes(aS1, aMapArgs);
+ BOPTools::MapShapes(aS2, aMapArgs);
+ BOPTools::MapShapes(aRes, aMapShape);
+ //
+ aIt.Initialize(aMapArgs);
+ for (; aIt.More(); aIt.Next()) {
+ const TopoDS_Shape& aS = aIt.Value();
+ aType = aS.ShapeType();
+ if (!(aType==TopAbs_EDGE || aType==TopAbs_FACE ||
+ aType==TopAbs_VERTEX || aType==TopAbs_SOLID)) {
+ continue;
+ }
+ //
+ bIsDeletedHist = pBuilder->IsDeleted(aS);
+ bIsDeletedMap = !aMapShape.Contains(aS) &&
+ (pBuilder->Modified(aS).Extent() == 0);
+ //
+ if (bIsDeletedHist != bIsDeletedMap) {
+ theDI << "Error. Wrong value of IsDeleted flag.\n";
+ return 1;
+ }
+ }
+ //
+ theDI << "Test complete\n";
+ return 0;
+}
+
+//====================================================
+// Auxiliary functor class for the command OCC25545;
+// it gets access to a vertex with the given index and
+// checks that X coordinate of the point is equal to index;
+// if it is not so then a data race is reported.
+//====================================================
+struct OCC25545_Functor
+{
+ OCC25545_Functor(const std::vector<TopoDS_Shape>& theShapeVec)
+ : myShapeVec(&theShapeVec),
+ myIsRaceDetected(0)
+ {}
+
+ void operator()(size_t i) const
+ {
+ if (!myIsRaceDetected) {
+ const TopoDS_Vertex& aV = TopoDS::Vertex (myShapeVec->at(i));
+ gp_Pnt aP = BRep_Tool::Pnt (aV);
+ if (aP.X () != static_cast<double> (i)) {
+ Standard_Atomic_Increment(&myIsRaceDetected);
+ }
+ }
+ }
+
+ const std::vector<TopoDS_Shape>* myShapeVec;
+ mutable volatile int myIsRaceDetected;
+};
+
+//=======================================================================
+//function : OCC25545
+//purpose : Tests data race when concurrently accessing TopLoc_Location::Transformation()
+//=======================================================================
+#ifdef HAVE_TBB
+static Standard_Integer OCC25545 (Draw_Interpretor& di,
+ Standard_Integer,
+ const char **)
+{
+ // Place vertices in a vector, giving the i-th vertex the
+ // transformation that translates it on the vector (i,0,0) from the origin.
+ size_t n = 1000;
+ std::vector<TopoDS_Shape> aShapeVec (n);
+ std::vector<TopLoc_Location> aLocVec (n);
+ TopoDS_Shape aShape = BRepBuilderAPI_MakeVertex (gp::Origin ());
+ aShapeVec[0] = aShape;
+ for (size_t i = 1; i < n; ++i) {
+ gp_Trsf aT;
+ aT.SetTranslation (gp_Vec (1, 0, 0));
+ aLocVec[i] = aLocVec[i - 1] * aT;
+ aShapeVec[i] = aShape.Moved (aLocVec[i]);
+ }
+
+ // Evaluator function will access vertices geometry
+ // concurrently
+ OCC25545_Functor aFunc(aShapeVec);
+
+ //concurrently process
+ tbb::parallel_for (size_t (0), n, aFunc, tbb::simple_partitioner ());
+ QVERIFY (!aFunc.myIsRaceDetected);
+ return 0;
+}
+#else
+static Standard_Integer OCC25545 (Draw_Interpretor&,
+ Standard_Integer,
+ const char **argv)
+{
+ cout << "Test skipped: command " << argv[0] << " requires TBB library" << endl;
+ return 0;
+}
+#endif
+
+//=======================================================================
+//function : OCC25547
+//purpose :
+//=======================================================================
+#include <BRepMesh_GeomTool.hxx>
+#include <BRepAdaptor_Curve.hxx>
+#include <Geom_TrimmedCurve.hxx>
+#include <BRepBuilderAPI_MakeFace.hxx>
+#include <BRepAdaptor_HSurface.hxx>
+#include <BRepAdaptor_Surface.hxx>
+static Standard_Integer OCC25547(
+ Draw_Interpretor& theDI,
+ Standard_Integer /*argc*/,
+ const char ** /*argv*/)
+{
+ // The general aim of this test is to prevent linkage errors due to missed
+ // Standard_EXPORT attribute for static methods.
+
+ // However, start checking the main functionality at first.
+ const Standard_Real aFirstP = 0., aLastP = M_PI;
+ Handle(Geom_Circle) aCircle = new Geom_Circle(gp_Ax2(gp::Origin(), gp::DZ()), 10);
+ Handle(Geom_TrimmedCurve) aHalf = new Geom_TrimmedCurve(aCircle, aFirstP, aLastP);
+ TopoDS_Edge aEdge = BRepBuilderAPI_MakeEdge(aHalf);
+ BRepAdaptor_Curve aAdaptor(aEdge);
+ BRepMesh_GeomTool aGeomTool(aAdaptor, aFirstP, aLastP, 0.1, 0.5);
+
+ if (aGeomTool.NbPoints() == 0)
+ {
+ theDI << "Error. BRepMesh_GeomTool failed to discretize an arc.\n";
+ return 1;
+ }
+
+ // Test static methods.
+ TopoDS_Face aFace = BRepBuilderAPI_MakeFace(gp_Pln(gp::Origin(), gp::DZ()));
+ BRepAdaptor_Surface aSurf(aFace);
+ Handle(BRepAdaptor_HSurface) aHSurf = new BRepAdaptor_HSurface(aSurf);
+
+ gp_Pnt aPnt;
+ gp_Dir aNormal;
+ if (!BRepMesh_GeomTool::Normal(aHSurf, 10., 10., aPnt, aNormal))
+ {
+ theDI << "Error. BRepMesh_GeomTool failed to take a normal of surface.\n";
+ return 1;
+ }
+
+ gp_XY aRefPnts[4] = {
+ gp_XY(-10., -10.), gp_XY(10., 10.),
+ gp_XY(-10., 10.), gp_XY(10., -10.)
+ };
+
+ gp_Pnt2d aIntPnt;
+ Standard_Real aParams[2];
+ BRepMesh_GeomTool::IntFlag aIntFlag = BRepMesh_GeomTool::IntLinLin(
+ aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
+ aIntPnt.ChangeCoord(), aParams);
+
+ Standard_Real aDiff = aIntPnt.Distance(gp::Origin2d());
+ if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
+ {
+ theDI << "Error. BRepMesh_GeomTool failed to intersect two lines.\n";
+ return 1;
+ }
+
+ aIntFlag = BRepMesh_GeomTool::IntSegSeg(
+ aRefPnts[0], aRefPnts[1], aRefPnts[2], aRefPnts[3],
+ Standard_False, Standard_False, aIntPnt);
+
+ aDiff = aIntPnt.Distance(gp::Origin2d());
+ if (aIntFlag != BRepMesh_GeomTool::Cross || aDiff > Precision::PConfusion())
+ {
+ theDI << "Error. BRepMesh_GeomTool failed to intersect two segments.\n";
+ return 1;
+ }
+
+
+ theDI << "Test complete\n";
+ return 0;
+}
+
void QABugs::Commands_19(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
"\nOCAF persistence without setting environment variables",
__FILE__, OCC24925, group);
theCommands.Add ("OCC23010", "OCC23010 STEP_file", __FILE__, OCC23010, group);
+ theCommands.Add ("OCC25043", "OCC25043 shape", __FILE__, OCC25043, group);
+ theCommands.Add ("OCC24606", "OCC24606 : Tests ::FitAll for V3d view ('vfit' is for NIS view)", __FILE__, OCC24606, group);
+ theCommands.Add ("OCC25202", "OCC25202 res shape numF1 face1 numF2 face2", __FILE__, OCC25202, group);
+ theCommands.Add ("OCC7570", "OCC7570 shape", __FILE__, OCC7570, group);
+ theCommands.Add ("OCC25100", "OCC25100 shape", __FILE__, OCC25100, group);
+ theCommands.Add ("OCC25340", "OCC25340", __FILE__, OCC25340, group);
+ theCommands.Add ("OCC25348", "OCC25348", __FILE__, OCC25348, group);
+ theCommands.Add ("OCC25413", "OCC25413 shape", __FILE__, OCC25413, group);
+ theCommands.Add ("OCC25446", "OCC25446 res b1 b2 op", __FILE__, OCC25446, group);
+ theCommands.Add ("OCC25545",
+ "no args; tests data race when concurrently accessing \n"
+ "\t\tTopLoc_Location::Transformation()",
+ __FILE__, OCC25545, group);
+ theCommands.Add ("OCC25547", "OCC25547", __FILE__, OCC25547, group);
return;
}