diff --git a/src/BRepAlgo/BRepAlgo_Loop.cxx b/src/BRepAlgo/BRepAlgo_Loop.cxx index 8fb739c23c..ba6b1e6052 100644 --- a/src/BRepAlgo/BRepAlgo_Loop.cxx +++ b/src/BRepAlgo/BRepAlgo_Loop.cxx @@ -42,12 +42,14 @@ #include #include +//#define OCCT_DEBUG_ALGO +//#define DRAW #ifdef DRAW #include #pragma comment(lib,"TKDraw") #endif #ifdef OCCT_DEBUG_ALGO -Standard_Boolean AffichLoop = Standard_False; +Standard_Boolean AffichLoop = Standard_True; Standard_Integer NbLoops = 0; Standard_Integer NbWires = 1; static char* name = new char[100]; @@ -58,7 +60,8 @@ static char* name = new char[100]; //purpose : //======================================================================= -BRepAlgo_Loop::BRepAlgo_Loop() +BRepAlgo_Loop::BRepAlgo_Loop(): + myTolConf (0.001) { } @@ -185,7 +188,6 @@ static TopoDS_Vertex UpdateClosedEdge(const TopoDS_Edge& E, Standard_Boolean OnStart = 0, OnEnd = 0; //// modified by jgv, 13.04.04 for OCC5634 //// TopExp::Vertices (E,V1,V2); - //Standard_Real Tol = Precision::Confusion(); Standard_Real Tol = BRep_Tool::Tolerance( V1 ); /////////////////////////////////////////////// @@ -427,13 +429,12 @@ static void StoreInMVE (const TopoDS_Face& F, TopoDS_Edge& E, TopTools_IndexedDataMapOfShapeListOfShape& MVE, Standard_Boolean& YaCouture, - TopTools_DataMapOfShapeShape& VerticesForSubstitute ) + TopTools_DataMapOfShapeShape& VerticesForSubstitute, + const Standard_Real theTolConf) { TopoDS_Vertex V1, V2, V; TopTools_ListOfShape Empty; - Standard_Real Tol = 0.001; //5.e-05; //5.e-07; -// gp_Pnt P1, P2, P; gp_Pnt P1, P; BRep_Builder BB; for (Standard_Integer iV = 1; iV <= MVE.Extent(); iV++) @@ -449,7 +450,7 @@ static void StoreInMVE (const TopoDS_Face& F, { V1 = TopoDS::Vertex( itl.Value() ); P1 = BRep_Tool::Pnt( V1 ); - if (P.IsEqual( P1, Tol ) && !V.IsSame(V1)) + if (P.IsEqual( P1, theTolConf ) && !V.IsSame(V1)) { V.Orientation( V1.Orientation() ); if (VerticesForSubstitute.IsBound( V1 )) @@ -574,7 +575,7 @@ void BRepAlgo_Loop::Perform() TopoDS_Edge& E = TopoDS::Edge(itl1.Value()); if (!Emap.Add(E)) continue; - StoreInMVE(myFace,E,MVE,YaCouture,myVerticesForSubstitute); + StoreInMVE(myFace,E,MVE,YaCouture,myVerticesForSubstitute, myTolConf); } } } @@ -586,7 +587,7 @@ void BRepAlgo_Loop::Perform() for (itl.Initialize(myConstEdges); itl.More(); itl.Next()) { TopoDS_Edge& E = TopoDS::Edge(itl.Value()); if (DejaVu.Add(E)) - StoreInMVE(myFace,E,MVE,YaCouture,myVerticesForSubstitute); + StoreInMVE(myFace,E,MVE,YaCouture,myVerticesForSubstitute, myTolConf); } #ifdef DRAW @@ -626,42 +627,42 @@ void BRepAlgo_Loop::Perform() //-------------------------------- RemovePendingEdges(MVE); - if (MVE.Extent() == 0) break; + if (MVE.Extent() == 0) break; //-------------------------------- // Start edge. //-------------------------------- EF = CE = TopoDS::Edge(MVE(1).First()); - TopExp::Vertices(CE,V1,V2); + TopExp::Vertices(CE, V1, V2); //-------------------------------- // VF vertex start of new wire //-------------------------------- - if (CE.Orientation() == TopAbs_FORWARD) { CV = VF = V1;} - else { CV = VF = V2;} + if (CE.Orientation() == TopAbs_FORWARD) { CV = VF = V1; } + else { CV = VF = V2; } if (!MVE.Contains(CV)) continue; TopTools_ListOfShape& aListEdges = MVE.ChangeFromKey(CV); - for ( itl.Initialize(aListEdges); itl.More(); itl.Next()) { + for (itl.Initialize(aListEdges); itl.More(); itl.Next()) { if (itl.Value().IsEqual(CE)) { - aListEdges.Remove(itl); - break; + aListEdges.Remove(itl); + break; } } - End = Standard_False; - + End = Standard_False; + while (!End) { //------------------------------- // Construction of a wire. //------------------------------- - TopExp::Vertices(CE,V1,V2); + TopExp::Vertices(CE, V1, V2); if (!CV.IsSame(V1)) CV = V1; else CV = V2; - B.Add (NW,CE); + B.Add(NW, CE); UsedEdges.Add(CE); if (!MVE.Contains(CV) || MVE.FindFromKey(CV).IsEmpty()) { End = Standard_True; } else { - End = !SelectEdge(myFace,CE,CV,NE,MVE.ChangeFromKey(CV)); + End = !SelectEdge(myFace, CE, CV, NE, MVE.ChangeFromKey(CV)); if (!End) { CE = NE; if (MVE.FindFromKey(CV).IsEmpty()) @@ -672,35 +673,41 @@ void BRepAlgo_Loop::Perform() //-------------------------------------------------- // Add new wire to the set of wires //------------------------------------------------ - Standard_Real Tol = 0.001; //5.e-05; //5.e-07; - TopExp_Explorer explo( NW, TopAbs_VERTEX ); - for (; explo.More(); explo.Next()) - { - const TopoDS_Vertex& aV = TopoDS::Vertex( explo.Current() ); - Handle(BRep_TVertex)& TV = *((Handle(BRep_TVertex)*) &(aV).TShape()); - TV->Tolerance( Tol ); - TV->Modified( Standard_True ); - } - for (explo.Init( NW, TopAbs_EDGE ); explo.More(); explo.Next()) - { - const TopoDS_Edge& aE = TopoDS::Edge( explo.Current() ); - Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*) &(aE).TShape()); - TE->Tolerance( Tol ); - TE->Modified( Standard_True ); - } - if (VF.IsSame(CV) && SamePnt2d(VF,EF,CE,myFace)) + if (VF.IsSame(CV)) { - NW.Closed (Standard_True); - myNewWires.Append (NW); + if (SamePnt2d(VF, EF, CE, myFace)) + { + NW.Closed(Standard_True); + myNewWires.Append(NW); + } + else if(BRep_Tool::Tolerance(VF) < myTolConf) + { + BRep_Builder aBB; + aBB.UpdateVertex(VF, myTolConf); + if (SamePnt2d(VF, EF, CE, myFace)) + { + NW.Closed(Standard_True); + myNewWires.Append(NW); + } +#ifdef OCCT_DEBUG_ALGO + else + { + std::cout << "BRepAlgo_Loop: Open Wire" << std::endl; + if (AffichLoop) + std::cout << "OpenWire is : NW_" << NbLoops << "_" << NbWires << std::endl; + } +#endif + } } #ifdef OCCT_DEBUG_ALGO else { - std::cout <<"BRepAlgo_Loop: Open Wire"<& theAddStatus1, const Handle(BRepExtrema_TriangleSet)& theSet2, const BRepExtrema_ShapeList& theShapeList1, const BRepExtrema_ShapeList& theShapeList2) @@ -55,6 +57,7 @@ BRepExtrema_ProximityDistTool::BRepExtrema_ProximityDistTool (const Handle(BRepE { LoadTriangleSets (theSet1, theSet2); LoadShapeLists (theShapeList1, theShapeList2); + LoadAdditionalPointsFirstSet (theAddVertices1, theAddStatus1); } //======================================================================= @@ -69,7 +72,7 @@ void BRepExtrema_ProximityDistTool::LoadTriangleSets (const Handle(BRepExtrema_T } //======================================================================= -//function : LoadTriangleSets +//function : LoadShapeLists //purpose : Loads the given list of subshapes into the proximity tool //======================================================================= void BRepExtrema_ProximityDistTool::LoadShapeLists (const BRepExtrema_ShapeList& theShapeList1, @@ -78,23 +81,33 @@ void BRepExtrema_ProximityDistTool::LoadShapeLists (const BRepExtrema_ShapeList& myShapeList1 = theShapeList1; myShapeList2 = theShapeList2; } -//======================================================================= -//function : Perform -//purpose : Performs searching of the proximity distance -//======================================================================= -void BRepExtrema_ProximityDistTool::Perform() -{ - SetBVHSet (mySet2.get()); - const BVH_Array3d& aVertices1 = mySet1->GetVertices(); - Standard_Integer aVtxSize = (Standard_Integer)aVertices1.size(); +//======================================================================= +//function : LoadAdditionalPointsFirstSet +//purpose : Loads given additional vertices and their statuses +//======================================================================= +void BRepExtrema_ProximityDistTool::LoadAdditionalPointsFirstSet (const BVH_Array3d& theAddVertices1, + const NCollection_Vector& theAddStatus1) +{ + myAddVertices1 = theAddVertices1; + myAddStatus1 = theAddStatus1; +} + +//======================================================================= +//function : goThroughtSet1 +//purpose : Goes throught vertices from the 1st set +//======================================================================= +void BRepExtrema_ProximityDistTool::goThroughtSet1 (const BVH_Array3d& theVertices1, + const Standard_Boolean theIsAdditionalSet) +{ + Standard_Integer aVtxSize = (Standard_Integer)theVertices1.size(); Standard_Integer aVtxStep = Max (myNbSamples1 <= 0 ? 1 : aVtxSize / myNbSamples1, 1); for (Standard_Integer aVtxIdx = 0; aVtxIdx < aVtxSize; aVtxIdx += aVtxStep) { myDistance = std::numeric_limits::max(); myMinDistance = std::numeric_limits::max(); myIsDone = Standard_False; - SetObject (aVertices1[aVtxIdx]); + SetObject (theVertices1[aVtxIdx]); ComputeDistance(); @@ -102,20 +115,31 @@ void BRepExtrema_ProximityDistTool::Perform() if (IsDone() && myDistance > myProxDist) { - myPnt1 = aVertices1[aVtxIdx]; + myPnt1 = theVertices1[aVtxIdx]; myPnt2 = myExtremaPoint; myProxDist = myDistance; myProxVtxIdx1 = aVtxIdx; + myIsProxVtx1FromAddSet = theIsAdditionalSet; myProxPrjState = myExtPrjState; } } +} - myIsDone = myProxDist > -1.; +//======================================================================= +//function : Perform +//purpose : Performs searching of the proximity distance +//======================================================================= +void BRepExtrema_ProximityDistTool::Perform() +{ + SetBVHSet (mySet2.get()); + goThroughtSet1 (mySet1->GetVertices(), Standard_False); + goThroughtSet1 (myAddVertices1, Standard_True); - if (myIsDone) - { - DefineStatusProxPnt(); - } + myIsDone = myProxDist > -1.; + if (myIsDone) + { + DefineStatusProxPnt(); + } } static Standard_Real pointBoxSquareMaxDistance (const BVH_Vec3d& thePoint, @@ -247,7 +271,12 @@ Standard_Real BRepExtrema_ProximityDistTool::ComputeDistance() return myDistance; } -static Standard_Boolean isNodeOnBorder (const Standard_Integer theNodeIdx, const Handle (Poly_Triangulation)& theTr) +//======================================================================= +//function : IsNodeOnBorder +//purpose : Returns true if the node is on the boarder +//======================================================================= +Standard_Boolean BRepExtrema_ProximityDistTool::IsNodeOnBorder (const Standard_Integer theNodeIdx, + const Handle(Poly_Triangulation)& theTr) { Poly_Connect aPolyConnect (theTr); @@ -279,12 +308,49 @@ static Standard_Boolean isNodeOnBorder (const Standard_Integer theNodeIdx, const return Standard_False; } +//======================================================================= +//function : IsEdgeOnBorder +//purpose : Returns true if the edge is on the boarder +//======================================================================= +Standard_Boolean BRepExtrema_ProximityDistTool::IsEdgeOnBorder (const Standard_Integer theTrgIdx, + const Standard_Integer theFirstEdgeNodeIdx, + const Standard_Integer theSecondEdgeNodeIdx, + const Handle(Poly_Triangulation)& theTr) +{ + Poly_Connect aPolyConnect (theTr); + + Standard_Integer aAdjTrg[3]; + aPolyConnect.Triangles (theTrgIdx, aAdjTrg[0], aAdjTrg[1], aAdjTrg[2]); //indices of adjacent triangles + + for (Standard_Integer j = 0; j < 3; j++) + { + Standard_Integer k = (j + 1) % 3; + if (aAdjTrg[j] == 0) //free segment of triangle + { + //are ends of free segment and it is a part of border + if (j == theFirstEdgeNodeIdx && + k == theSecondEdgeNodeIdx) + { + return Standard_True; + } + } + } + + return Standard_False; +} + //======================================================================= //function : defineStatusProxPnt1 //purpose : Defines the status of proximity point from 1st BVH //======================================================================= void BRepExtrema_ProximityDistTool::defineStatusProxPnt1() { + if (myIsProxVtx1FromAddSet) + { + myPntStatus1 = myAddStatus1[myProxVtxIdx1]; + return; + } + Standard_Integer aFaceID1 = mySet1->GetShapeIDOfVtx (myProxVtxIdx1); if (myShapeList1 (aFaceID1).ShapeType() == TopAbs_EDGE) @@ -314,9 +380,9 @@ void BRepExtrema_ProximityDistTool::defineStatusProxPnt1() TopLoc_Location aLocation; const TopoDS_Face& aF = TopoDS::Face (myShapeList1 (aFaceID1)); - Handle (Poly_Triangulation) aTr = BRep_Tool::Triangulation (aF, aLocation); + Handle(Poly_Triangulation) aTr = BRep_Tool::Triangulation (aF, aLocation); - if (isNodeOnBorder (aNodeIdx, aTr)) + if (IsNodeOnBorder (aNodeIdx, aTr)) { myPntStatus1 = ProxPnt_Status_BORDER; } @@ -398,7 +464,7 @@ void BRepExtrema_ProximityDistTool::defineStatusProxPnt2() { TopLoc_Location aLocation; const TopoDS_Face& aF = TopoDS::Face (myShapeList2 (aFaceID2)); - Handle (Poly_Triangulation) aTr = BRep_Tool::Triangulation (aF, aLocation); + Handle(Poly_Triangulation) aTr = BRep_Tool::Triangulation (aF, aLocation); NCollection_Array1 aVtxIndicesOfTrg; mySet2->GetVtxIndices (aTrgIdx, aVtxIndicesOfTrg); @@ -408,7 +474,7 @@ void BRepExtrema_ProximityDistTool::defineStatusProxPnt2() Standard_Integer aNodeNum = myProxPrjState.GetNumberOfFirstNode(); Standard_Integer aNodeIdx = mySet2->GetVtxIdxInShape (aVtxIndicesOfTrg[aNodeNum]) + 1; - if (isNodeOnBorder (aNodeIdx, aTr)) + if (IsNodeOnBorder (aNodeIdx, aTr)) { myPntStatus2 = ProxPnt_Status_BORDER; } @@ -419,27 +485,18 @@ void BRepExtrema_ProximityDistTool::defineStatusProxPnt2() } else if (myProxPrjState.GetPrjState() == BVH_PrjState::BVH_PrjStateInTriangle_EDGE) { - myPntStatus2 = ProxPnt_Status_MIDDLE; - - Poly_Connect aPolyConnect (aTr); Standard_Integer aTrgIdxInShape = mySet2->GetTrgIdxInShape (aTrgIdx) + 1; - Standard_Integer aAdjTrg[3]; - aPolyConnect.Triangles (aTrgIdxInShape, aAdjTrg[0], aAdjTrg[1], aAdjTrg[2]); //indices of adjacent triangles - - for (Standard_Integer j = 0; j < 3; j++) + if (IsEdgeOnBorder (aTrgIdxInShape, + myProxPrjState.GetNumberOfFirstNode(), + myProxPrjState.GetNumberOfLastNode(), + aTr)) { - Standard_Integer k = (j + 1) % 3; - if (aAdjTrg[j] == 0) //free segment of triangle - { - //aVtxIndicesOfTrg[j] and aVtxIndicesOfTrg[k] are ends of free segment and it is a part of border - if (j == myProxPrjState.GetNumberOfFirstNode() && - k == myProxPrjState.GetNumberOfLastNode()) - { - myPntStatus2 = ProxPnt_Status_BORDER; - break; - } - } + myPntStatus2 = ProxPnt_Status_BORDER; + } + else + { + myPntStatus2 = ProxPnt_Status_MIDDLE; } } //else if (myProxPrjState.GetPrjState() == BVH_PrjState::BVH_PrjStateInTriangle_EDGE) } diff --git a/src/BRepExtrema/BRepExtrema_ProximityDistTool.hxx b/src/BRepExtrema/BRepExtrema_ProximityDistTool.hxx index 3739fff1ad..da6d5de076 100644 --- a/src/BRepExtrema/BRepExtrema_ProximityDistTool.hxx +++ b/src/BRepExtrema/BRepExtrema_ProximityDistTool.hxx @@ -21,6 +21,7 @@ #include #include #include +#include //! Tool class for computation the proximity distance from first //! primitive set to second one that is the maximal from minimum @@ -93,6 +94,8 @@ public: //! Creates new tool for the given element sets. Standard_EXPORT BRepExtrema_ProximityDistTool (const Handle(BRepExtrema_TriangleSet)& theSet1, const Standard_Integer theNbSamples1, + const BVH_Array3d& theAddVertices1, + const NCollection_Vector& theAddStatus1, const Handle(BRepExtrema_TriangleSet)& theSet2, const BRepExtrema_ShapeList& theShapeList1, const BRepExtrema_ShapeList& theShapeList2); @@ -107,6 +110,10 @@ public: Standard_EXPORT void LoadShapeLists (const BRepExtrema_ShapeList& theShapeList1, const BRepExtrema_ShapeList& theShapeList2); + //! Loads given additional vertices and their statuses. + void LoadAdditionalPointsFirstSet (const BVH_Array3d& theAddVertices1, + const NCollection_Vector& theAddStatus1); + //! Performs searching of the proximity distance. Standard_EXPORT void Perform(); @@ -121,6 +128,20 @@ public: //! @name Reject/Accept implementations Standard_EXPORT virtual Standard_Boolean Accept (const Standard_Integer theSgmIdx, const Standard_Real&) Standard_OVERRIDE; +public: + + //! Returns true if the node is on the boarder. + Standard_EXPORT static Standard_Boolean IsNodeOnBorder (const Standard_Integer theNodeIdx, + const Handle (Poly_Triangulation)& theTr); + + //! Returns true if the edge is on the boarder. + Standard_EXPORT static Standard_Boolean IsEdgeOnBorder (const Standard_Integer theTrgIdx, + const Standard_Integer theFirstEdgeNodeIdx, + const Standard_Integer theSecondEdgeNodeIdx, + const Handle (Poly_Triangulation)& theTr); + +public: + //! Returns points on triangles sets, which provide the proximity distance. void ProximityPoints (BVH_Vec3d& thePoint1, BVH_Vec3d& thePoint2) const { @@ -148,6 +169,10 @@ protected: private: + //! Goes throught vertices from the 1st set. + void goThroughtSet1 (const BVH_Array3d& aVertices1, + const Standard_Boolean theIsAdditionalSet); + //! Defines the status of proximity point from 1st BVH. void defineStatusProxPnt1(); @@ -183,6 +208,11 @@ private: Standard_Integer myNbSamples1; //!< Number of samples points on the first shape + //! Is vertex corresponding to proximity point of 1st shape from additional set + Standard_Integer myIsProxVtx1FromAddSet; + BVH_Array3d myAddVertices1; //!< Additional vertices on the 1st shape + NCollection_Vector myAddStatus1; //!< Status of additional vertices on the 1st shape + //! Vertex index from 1st BVH corresponding to proximity point of 1st shape Standard_Integer myProxVtxIdx1; diff --git a/src/BRepExtrema/BRepExtrema_ProximityValueTool.cxx b/src/BRepExtrema/BRepExtrema_ProximityValueTool.cxx index a816be8b8f..66a2bd1d4f 100644 --- a/src/BRepExtrema/BRepExtrema_ProximityValueTool.cxx +++ b/src/BRepExtrema/BRepExtrema_ProximityValueTool.cxx @@ -1,4 +1,4 @@ -// Created on: 2022-08-08 +// Created on: 2022-08-08 // Created by: Kseniya NOSULKO // Copyright (c) 2022 OPEN CASCADE SAS // @@ -14,17 +14,32 @@ // commercial license or contractual agreement. #include +#include + +#include +#include +#include +#include +#include +#include +#include +#include //======================================================================= //function : BRepExtrema_ProximityValueTool //purpose : Creates new unitialized proximity tool //======================================================================= BRepExtrema_ProximityValueTool::BRepExtrema_ProximityValueTool() -: myDistance (std::numeric_limits::max()), +: myIsRefinementRequired1 (Standard_False), + myIsRefinementRequired2 (Standard_False), + myDistance (std::numeric_limits::max()), myIsDone (Standard_False), myNbSamples1(0), myNbSamples2(0) -{} +{ + // Should be initialized later + myIsInitS1 = myIsInitS2 = Standard_False; +} //======================================================================= //function : BRepExtrema_ProximityValueTool @@ -34,13 +49,15 @@ BRepExtrema_ProximityValueTool::BRepExtrema_ProximityValueTool (const Handle(BRe const Handle(BRepExtrema_TriangleSet)& theSet2, const BRepExtrema_ShapeList& theShapeList1, const BRepExtrema_ShapeList& theShapeList2) -: myDistance (std::numeric_limits::max()), +: myIsRefinementRequired1 (Standard_False), + myIsRefinementRequired2 (Standard_False), + myDistance (std::numeric_limits::max()), myIsDone (Standard_False), - myNbSamples1(0), - myNbSamples2(0) + myNbSamples1 (0), + myNbSamples2 (0) { - LoadTriangleSets (theSet1, theSet2); LoadShapeLists (theShapeList1, theShapeList2); + LoadTriangleSets (theSet1, theSet2); } //======================================================================= @@ -53,7 +70,94 @@ void BRepExtrema_ProximityValueTool::LoadTriangleSets (const Handle(BRepExtrema_ mySet1 = theSet1; mySet2 = theSet2; - myIsDone = Standard_False; + MarkDirty(); +} + +//======================================================================= +//function : calcEdgeRefinementStep +//purpose : Calculates the edge refinement step +//======================================================================= +static Standard_Real calcEdgeRefinementStep (const TopoDS_Edge& theEdge, + const Standard_Integer theNbNodes) +{ + if (theNbNodes < 2) + return 0; + + BRepAdaptor_Curve aBAC (theEdge); + Standard_Real aLen = GCPnts_AbscissaPoint::Length (aBAC); + return aLen / (Standard_Real)(theNbNodes - 1); +} + +//======================================================================= +//function : calcFaceRefinementStep +//purpose : Calculates the face refinement step as an approximate square +// (Shape area / number triangles) * 2 +//======================================================================= +static Standard_Real calcFaceRefinementStep (const TopoDS_Face& theFace, + const Standard_Integer theNbTrg) +{ + if (theNbTrg < 1) + return 0; + + GProp_GProps props; + BRepGProp::SurfaceProperties (theFace, props); + Standard_Real aArea = props.Mass(); + return 2 * (aArea / (Standard_Real)theNbTrg); +} + +//======================================================================= +//function : getInfoForRefinement +//purpose : Gets shape data for further refinement +//======================================================================= +Standard_Boolean BRepExtrema_ProximityValueTool::getInfoForRefinement (const TopoDS_Shape& theShape, + TopAbs_ShapeEnum& theShapeType, + Standard_Integer& theNbNodes, + Standard_Real& theStep) +{ + if (theShape.ShapeType() == TopAbs_FACE) + { + theShapeType = TopAbs_FACE; + TopoDS_Face aF = TopoDS::Face (theShape); + + TopLoc_Location aLocation; + Handle(Poly_Triangulation) aTriangulation = BRep_Tool::Triangulation (aF, aLocation); + + if (aTriangulation.IsNull()) + { + return Standard_False; + } + + theNbNodes = aTriangulation->NbNodes(); + Standard_Integer aNbTrg = aTriangulation->NbTriangles(); + theStep = calcFaceRefinementStep (aF, aNbTrg); + } + else if (theShape.ShapeType() == TopAbs_EDGE) + { + theShapeType = TopAbs_EDGE; + TopoDS_Edge aE = TopoDS::Edge (theShape); + + TopLoc_Location aLocation; + Handle(Poly_Polygon3D) aPolygon = BRep_Tool::Polygon3D (aE, aLocation); + + if (aPolygon.IsNull()) + { + return Standard_False; + } + + theNbNodes = aPolygon->NbNodes(); + theStep = calcEdgeRefinementStep (aE, theNbNodes); + } + else + { + return Standard_False; + } + + if (theStep < Precision::Confusion()) + { + return Standard_False; + } + + return Standard_True; } //======================================================================= @@ -66,7 +170,13 @@ void BRepExtrema_ProximityValueTool::LoadShapeLists (const BRepExtrema_ShapeList myShapeList1 = theShapeList1; myShapeList2 = theShapeList2; - myIsDone = Standard_False; + myShape1 = theShapeList1 (0); + myIsInitS1 = getInfoForRefinement (myShape1, myShapeType1, myNbNodes1, myStep1); + + myShape2 = theShapeList2 (0); + myIsInitS2 = getInfoForRefinement (myShape2, myShapeType2, myNbNodes2, myStep2); + + MarkDirty(); } //======================================================================= @@ -79,7 +189,7 @@ void BRepExtrema_ProximityValueTool::SetNbSamplePoints(const Standard_Integer th myNbSamples1 = theSamples1; myNbSamples2 = theSamples2; - myIsDone = Standard_False; + MarkDirty(); } //======================================================================= @@ -88,6 +198,8 @@ void BRepExtrema_ProximityValueTool::SetNbSamplePoints(const Standard_Integer th //======================================================================= Standard_Real BRepExtrema_ProximityValueTool::computeProximityDist (const Handle(BRepExtrema_TriangleSet)& theSet1, const Standard_Integer theNbSamples1, + const BVH_Array3d& theAddVertices1, + const NCollection_Vector& theAddStatus1, const Handle(BRepExtrema_TriangleSet)& theSet2, const BRepExtrema_ShapeList& theShapeList1, const BRepExtrema_ShapeList& theShapeList2, @@ -96,7 +208,8 @@ Standard_Real BRepExtrema_ProximityValueTool::computeProximityDist (const Handle ProxPnt_Status& thePointStatus1, ProxPnt_Status& thePointStatus2) const { - BRepExtrema_ProximityDistTool aProxDistTool (theSet1, theNbSamples1, theSet2, theShapeList1, theShapeList2); + BRepExtrema_ProximityDistTool aProxDistTool (theSet1, theNbSamples1, theAddVertices1, theAddStatus1, + theSet2, theShapeList1, theShapeList2); aProxDistTool.Perform(); if (!aProxDistTool.IsDone()) @@ -108,21 +221,311 @@ Standard_Real BRepExtrema_ProximityValueTool::computeProximityDist (const Handle return aProxDistTool.ProximityDistance(); } +//======================================================================= +//function : getEdgeAdditionalVertices +//purpose : Gets additional vertices and their statuses on the edge with the input step +//======================================================================= +Standard_Boolean BRepExtrema_ProximityValueTool::getEdgeAdditionalVertices ( + const TopoDS_Edge& theEdge, + const Standard_Real theStep, + BVH_Array3d& theAddVertices, + NCollection_Vector& theAddStatuses) +{ + BRepAdaptor_Curve aBAC (theEdge); + + if (!aBAC.Is3DCurve() || theStep < Precision::Confusion()) + { + return Standard_False; + } + + Standard_Real aLen = GCPnts_AbscissaPoint::Length (aBAC); + Standard_Integer aNbSamplePoints = (Standard_Integer) (aLen / theStep) + 1; + + GCPnts_QuasiUniformAbscissa aGCPnts (aBAC, Max (3, aNbSamplePoints)); + + if (!aGCPnts.IsDone()) + return Standard_False; + + Standard_Integer aNbNodes = aGCPnts.NbPoints(); + for (Standard_Integer aVertIdx = 2; aVertIdx < aNbNodes; ++aVertIdx) //don't add extreme points + { + Standard_Real aPar = aGCPnts.Parameter (aVertIdx); + gp_Pnt aP = aBAC.Value (aPar); + + theAddVertices.push_back (BVH_Vec3d (aP.X(), aP.Y(), aP.Z())); + theAddStatuses.Append (ProxPnt_Status::ProxPnt_Status_MIDDLE); + } + + return Standard_True; +} + +//======================================================================= +//function : doRecurTrgSplit +//purpose : Splits the triangle into two ones recursively, halving the longest side +// untill the area of ​​the current triangle > input step +//! @param theTrg points of the triangle to be splitted +//! @param theEdgesStatus status of triangle edges - on the border or middle of the face +//! @param theTol telerance used in search of coincidence points +//! @param theStep minimum area of ​​the resulting triangle +//! @param theAddVertices vertices obtained halving sides +//! @param theAddStatuses status of obtained vertices - on the border or middle of the face, +//! from triangulation of which the input triangle is +//======================================================================= +void BRepExtrema_ProximityValueTool::doRecurTrgSplit (const gp_Pnt (&theTrg)[3], + const ProxPnt_Status (&theEdgesStatus)[3], + const Standard_Real theTol, + const Standard_Real theStep, + BVH_Array3d& theAddVertices, + NCollection_Vector& theAddStatuses) +{ + gp_XYZ aTrgSide1 = theTrg[1].Coord() - theTrg[0].Coord(); + gp_XYZ aTrgSide2 = theTrg[2].Coord() - theTrg[0].Coord(); + Standard_Real aTrgArea = 0.5 * aTrgSide1.CrossMagnitude (aTrgSide2); + + if (aTrgArea - theStep < Precision::SquareConfusion()) + return; + + Standard_Real aD[3] { theTrg[0].Distance (theTrg[1]), + theTrg[1].Distance (theTrg[2]), + theTrg[2].Distance (theTrg[0]) }; + Standard_Integer aBisectedEdgeIdx = aD[0] > aD[1] ? (aD[0] > aD[2] ? 0 : 2) : (aD[1] > aD[2] ? 1 : 2); + gp_Pnt aCenterOfMaxSide (theTrg[aBisectedEdgeIdx].Coord()); + aCenterOfMaxSide.BaryCenter (0.5, theTrg[(aBisectedEdgeIdx + 1) % 3], 0.5); + + Bnd_Box aBox; + aBox.Add (aCenterOfMaxSide); + aBox.Enlarge (theTol); + myInspector.SetCurrent (aCenterOfMaxSide.Coord()); + myCells.Inspect (aBox.CornerMin().XYZ(), aBox.CornerMax().XYZ(), myInspector); + + if (myInspector.IsNeedAdd()) //is point aCenterOfMaxSide unique + { + BVH_Vec3d aBisectingPnt (aCenterOfMaxSide.X(), aCenterOfMaxSide.Y(), aCenterOfMaxSide.Z()); + theAddVertices.push_back (aBisectingPnt); + theAddStatuses.Append (theEdgesStatus[aBisectedEdgeIdx]); + myInspector.Add (aCenterOfMaxSide.Coord()); + myCells.Add (static_cast(theAddVertices.size()), + aBox.CornerMin().XYZ(), aBox.CornerMax().XYZ()); + } + + gp_Pnt aTrg1[3] = { theTrg[0], theTrg[1], theTrg[2] }; + gp_Pnt aTrg2[3] = { theTrg[0], theTrg[1], theTrg[2] }; + ProxPnt_Status aEdgesStatus1[3] = { theEdgesStatus[0], theEdgesStatus[1], theEdgesStatus[2] }; + ProxPnt_Status aEdgesStatus2[3] = { theEdgesStatus[0], theEdgesStatus[1], theEdgesStatus[2] }; + switch (aBisectedEdgeIdx) + { + case 0: + aTrg1[0] = aTrg2[1] = aCenterOfMaxSide; + aEdgesStatus1[2] = aEdgesStatus2[1] = ProxPnt_Status::ProxPnt_Status_MIDDLE; + break; + case 1: + aTrg1[1] = aTrg2[2] = aCenterOfMaxSide; + aEdgesStatus1[0] = aEdgesStatus2[2] = ProxPnt_Status::ProxPnt_Status_MIDDLE; + break; + case 2: + aTrg1[2] = aTrg2[0] = aCenterOfMaxSide; + aEdgesStatus1[1] = aEdgesStatus2[0] = ProxPnt_Status::ProxPnt_Status_MIDDLE; + break; + } + + doRecurTrgSplit (aTrg1, aEdgesStatus1, theTol, theStep, theAddVertices, theAddStatuses); + doRecurTrgSplit (aTrg2, aEdgesStatus2, theTol, theStep, theAddVertices, theAddStatuses); +} + +static Standard_Real getModelRange (const TopLoc_Location& theLocation, + const Handle(Poly_Triangulation)& theTr) +{ + Bnd_Box aBox; + theTr->MinMax (aBox, theLocation.Transformation()); + Standard_Real aXm = 0.0, aYm = 0.0, aZm = 0.0, aXM = 0.0, aYM = 0.0, aZM = 0.0; + aBox.Get (aXm, aYm, aZm, aXM, aYM, aZM); + Standard_Real aRange = aXM - aXm; + aRange = Max (aRange, aYM - aYm); + aRange = Max (aRange, aZM - aZm); + + return aRange; +} + +static void getNodesOfTrg (const Standard_Integer theTriIdx, + const TopLoc_Location& theLocation, + const Handle (Poly_Triangulation)& theTr, + gp_Pnt (&theTrg)[3]) +{ + Standard_Integer aVtxIdx1; + Standard_Integer aVtxIdx2; + Standard_Integer aVtxIdx3; + + theTr->Triangle (theTriIdx).Get (aVtxIdx1, aVtxIdx2, aVtxIdx3); + + gp_Pnt aVtx1 = theTr->Node (aVtxIdx1); + aVtx1.Transform (theLocation); + theTrg[0] = aVtx1; + + gp_Pnt aVtx2 = theTr->Node (aVtxIdx2); + aVtx2.Transform (theLocation); + theTrg[1] = aVtx2; + + gp_Pnt aVtx3 = theTr->Node (aVtxIdx3); + aVtx3.Transform (theLocation); + theTrg[2] = aVtx3; +} + +// Gets status of triangle edges - on the border or middle of the face +static void getEdgesStatus(const Standard_Integer theTriIdx, + const Handle(Poly_Triangulation)& theTr, + ProxPnt_Status (&theEdgesStatus1)[3]) +{ + for (Standard_Integer j = 0; j < 3; j++) + { + Standard_Integer k = (j + 1) % 3; + + if (BRepExtrema_ProximityDistTool::IsEdgeOnBorder (theTriIdx, j, k, theTr)) + { + theEdgesStatus1[j] = ProxPnt_Status::ProxPnt_Status_BORDER; + } + else + { + theEdgesStatus1[j] = ProxPnt_Status::ProxPnt_Status_MIDDLE; + } + } +} + +//======================================================================= +//function : getFaceAdditionalVertices +//purpose : Gets additional vertices and their statuses on the face with the input step (triangle square) +//======================================================================= +Standard_Boolean BRepExtrema_ProximityValueTool::getFaceAdditionalVertices ( + const TopoDS_Face& theFace, + const Standard_Real theStep, + BVH_Array3d& theAddVertices, + NCollection_Vector& theAddStatuses) +{ + Standard_Real aTol = Precision::Confusion(); + + TopLoc_Location aLocation; + Handle(Poly_Triangulation) aTr = BRep_Tool::Triangulation (theFace, aLocation); + + if (aTr.IsNull()) + { + return Standard_False; + } + + myCells.Reset (Max (aTol, getModelRange (aLocation, aTr) / IntegerLast())); + + for (Standard_Integer aTriIdx = 1; aTriIdx <= aTr->NbTriangles(); ++aTriIdx) + { + gp_Pnt aTrg[3]; + ProxPnt_Status aEdgesStatus[3]; + getNodesOfTrg (aTriIdx, aLocation, aTr, aTrg); + getEdgesStatus (aTriIdx, aTr, aEdgesStatus); + doRecurTrgSplit (aTrg, aEdgesStatus, aTol, theStep, theAddVertices, theAddStatuses); + } + + return Standard_True; +} + +//======================================================================= +//function : getShapesVertices +//purpose : Gets additional vertices on shapes with refining a coarser one if it's needed +//======================================================================= +Standard_Boolean BRepExtrema_ProximityValueTool::getShapesAdditionalVertices() +{ + // estimate the density of meshes of shapes to add points to a coarcer one + // target steps for refinement + Standard_Real aStep1 = myStep1; + Standard_Real aStep2 = myStep2; + + if ((myShapeType1 == TopAbs_EDGE) && (myShapeType2 == TopAbs_EDGE)) + { + if (myNbSamples1 > myNbNodes1) // 1st edge needs refinement + { + aStep1 = calcEdgeRefinementStep (TopoDS::Edge (myShape1), myNbSamples1); + myIsRefinementRequired1 = Standard_True; + } + + if (myNbSamples2 > myNbNodes2) // 2nd edge needs refinement + { + aStep2 = calcEdgeRefinementStep (TopoDS::Edge (myShape2), myNbSamples2); + myIsRefinementRequired2 = Standard_True; + } + + if (aStep1 / aStep2 > 2.) // 1st edge needs refinement + { + myIsRefinementRequired1 = Standard_True; + aStep1 = aStep2; + } + else if (aStep2 / aStep1 > 2.) // 2nd edge needs refinement + { + myIsRefinementRequired2 = Standard_True; + aStep2 = aStep1; + } + + if (myIsRefinementRequired1) + { + if (!getEdgeAdditionalVertices (TopoDS::Edge (myShape1), aStep1, myAddVertices1, myAddStatus1)) + { + return Standard_False; + } + } + + if (myIsRefinementRequired2) + { + if (!getEdgeAdditionalVertices (TopoDS::Edge (myShape2), aStep2, myAddVertices2, myAddStatus2)) + { + return Standard_False; + } + } + } + else if ((myShapeType1 == TopAbs_FACE) && (myShapeType2 == TopAbs_FACE)) + { + if (aStep1 / aStep2 > 2) // 1st face needs refinement + { + myIsRefinementRequired1 = Standard_True; + aStep1 = myStep2; + } + else if (aStep2 / aStep1 > 2.) // 2nd face needs refinement + { + myIsRefinementRequired2 = Standard_True; + aStep2 = myStep1; + } + + if (myIsRefinementRequired1) + { + return getFaceAdditionalVertices (TopoDS::Face (myShape1), aStep1, myAddVertices1, myAddStatus1); + } + + if (myIsRefinementRequired2) + { + return getFaceAdditionalVertices (TopoDS::Face (myShape2), aStep2, myAddVertices2, myAddStatus2); + } + } + + return Standard_True; +} + //======================================================================= //function : Perform //purpose : Performs the computation of the proximity value //======================================================================= void BRepExtrema_ProximityValueTool::Perform (Standard_Real& theTolerance) { - myIsDone = Standard_False; + if (!myIsInitS1 || !myIsInitS2 || (myShapeType1 != myShapeType2)) + return; + + //get vertices on shapes with refining a coarser mesh if it's needed + if (!getShapesAdditionalVertices()) + return; // max(min) dist from the 1st shape to the 2nd one BVH_Vec3d aP1_1, aP1_2; ProxPnt_Status aPointStatus1_1 = ProxPnt_Status::ProxPnt_Status_UNKNOWN; ProxPnt_Status aPointStatus1_2 = ProxPnt_Status::ProxPnt_Status_UNKNOWN; - Standard_Real aProximityDist1 = computeProximityDist (mySet1, myNbSamples1, mySet2, myShapeList1, myShapeList2, - aP1_1, aP1_2, aPointStatus1_1, aPointStatus1_2); + Standard_Real aProximityDist1 = computeProximityDist (mySet1, myNbSamples1, myAddVertices1, myAddStatus1, + mySet2, + myShapeList1, myShapeList2, + aP1_1, aP1_2, + aPointStatus1_1, aPointStatus1_2); if (aProximityDist1 < 0.) return; @@ -132,8 +535,11 @@ void BRepExtrema_ProximityValueTool::Perform (Standard_Real& theTolerance) ProxPnt_Status aPointStatus2_1 = ProxPnt_Status::ProxPnt_Status_UNKNOWN; ProxPnt_Status aPointStatus2_2 = ProxPnt_Status::ProxPnt_Status_UNKNOWN; - Standard_Real aProximityDist2 = computeProximityDist (mySet2, myNbSamples2, mySet1, myShapeList2, myShapeList1, - aP2_2, aP2_1, aPointStatus2_2, aPointStatus2_1); + Standard_Real aProximityDist2 = computeProximityDist (mySet2, myNbSamples2, myAddVertices2, myAddStatus2, + mySet1, + myShapeList2, myShapeList1, + aP2_2, aP2_1, + aPointStatus2_2, aPointStatus2_1); if (aProximityDist2 < 0.) return; @@ -159,3 +565,23 @@ void BRepExtrema_ProximityValueTool::Perform (Standard_Real& theTolerance) myIsDone = Standard_True; theTolerance = myDistance; } + +//======================================================================= +//function : Inspect +//purpose : Used for selection and storage of coinciding nodes +//======================================================================= +NCollection_CellFilter_Action BRepExtrema_VertexInspector::Inspect (const Standard_Integer theTarget) +{ + myIsNeedAdd = Standard_True; + + const gp_XYZ& aPnt = myPoints.Value (theTarget - 1); + Standard_Real aDx, aDy, aDz; + aDx = myCurrent.X() - aPnt.X(); + aDy = myCurrent.Y() - aPnt.Y(); + aDz = myCurrent.Z() - aPnt.Z(); + + if ((aDx * aDx <= myTol) && (aDy * aDy <= myTol) && (aDz * aDz <= myTol)) + myIsNeedAdd = Standard_False; + + return CellFilter_Keep; +} \ No newline at end of file diff --git a/src/BRepExtrema/BRepExtrema_ProximityValueTool.hxx b/src/BRepExtrema/BRepExtrema_ProximityValueTool.hxx index 09610c8d92..ca65c28104 100644 --- a/src/BRepExtrema/BRepExtrema_ProximityValueTool.hxx +++ b/src/BRepExtrema/BRepExtrema_ProximityValueTool.hxx @@ -1,4 +1,4 @@ -// Created on: 2022-08-08 +// Created on: 2022-08-08 // Created by: Kseniya NOSULKO // Copyright (c) 2022 OPEN CASCADE SAS // @@ -18,9 +18,67 @@ #include #include +#include +#include + +typedef NCollection_Vector VectorOfPoint; + +//! Class BRepExtrema_VertexInspector +//! derived from NCollection_CellFilter_InspectorXYZ +//! This class define the Inspector interface for CellFilter algorithm, +//! working with gp_XYZ points in 3d space. +//! Used in search of coincidence points with a certain tolerance. +class BRepExtrema_VertexInspector : public NCollection_CellFilter_InspectorXYZ +{ +public: + typedef Standard_Integer Target; + + //! Constructor; remembers the tolerance + BRepExtrema_VertexInspector() + : myTol (Precision::SquareConfusion()), + myIsNeedAdd (Standard_True) + {} + + //! Keep the points used for comparison + void Add (const gp_XYZ& thePnt) + { + myPoints.Append (thePnt); + } + + //! Set tolerance for comparison of point coordinates + void SetTol (const Standard_Real theTol) + { + myTol = theTol; + } + + //! Set current point to search for coincidence + void SetCurrent (const gp_XYZ& theCurPnt) + { + myCurrent = theCurPnt; + myIsNeedAdd = Standard_True; + } + + Standard_Boolean IsNeedAdd() + { + return myIsNeedAdd; + } + + //! Implementation of inspection method + Standard_EXPORT NCollection_CellFilter_Action Inspect (const Standard_Integer theTarget); + +private: + Standard_Real myTol; + Standard_Boolean myIsNeedAdd; + VectorOfPoint myPoints; + gp_XYZ myCurrent; +}; + +typedef NCollection_CellFilter BRepExtrema_CellFilter; +typedef typename BRepExtrema_ProximityDistTool::ProxPnt_Status ProxPnt_Status; //! Tool class for computation of the proximity value from one BVH //! primitive set to another, solving max(min) problem. +//! Handles only edge/edge or face/face cases. //! This tool is not intended to be used independently, and is integrated //! in other classes, implementing algorithms based on shape tessellation //! (BRepExtrema_ShapeProximity and BRepExtrema_SelfIntersection). @@ -29,8 +87,6 @@ //! on the quality of input tessellation(s). class BRepExtrema_ProximityValueTool { -public: - typedef typename BRepExtrema_ProximityDistTool::ProxPnt_Status ProxPnt_Status; public: @@ -86,9 +142,17 @@ public: private: + //! Gets shape data for further refinement. + Standard_Boolean getInfoForRefinement (const TopoDS_Shape& theShapes, + TopAbs_ShapeEnum& theShapeType, + Standard_Integer& theNbNodes, + Standard_Real& theStep); + //! Returns the computed proximity value from first BVH to another one. Standard_Real computeProximityDist (const Handle(BRepExtrema_TriangleSet)& theSet1, const Standard_Integer theNbSamples1, + const BVH_Array3d& theAddVertices1, + const NCollection_Vector& theAddStatus1, const Handle(BRepExtrema_TriangleSet)& theSet2, const BRepExtrema_ShapeList& theShapeList1, const BRepExtrema_ShapeList& theShapeList2, @@ -97,6 +161,29 @@ private: ProxPnt_Status& thePointStatus1, ProxPnt_Status& thePointStatus2) const; + //! Gets additional vertices on shapes with refining a coarser one if it's needed. + Standard_Boolean getShapesAdditionalVertices(); + + //! Gets additional vertices and their statuses on the edge with the input step. + Standard_Boolean getEdgeAdditionalVertices (const TopoDS_Edge& theEdge, + const Standard_Real theStep, + BVH_Array3d& theAddVertices, + NCollection_Vector& theAddStatuses); + + //! Gets additional vertices and their statuses on the face with the input step (triangle square). + Standard_Boolean getFaceAdditionalVertices (const TopoDS_Face& theFace, + const Standard_Real theStep, + BVH_Array3d& theAddVertices, + NCollection_Vector& theAddStatuses); + + //! Splits the triangle recursively, halving the longest side + //! to the area of ​​the current triangle > input step + void doRecurTrgSplit (const gp_Pnt (&theTrg)[3], + const ProxPnt_Status (&theEdgesStatus)[3], + const Standard_Real theTol, + const Standard_Real theStep, + BVH_Array3d& theAddVertices, + NCollection_Vector& theAddStatuses); private: //! Set of all mesh primitives of the 1st shape. @@ -109,6 +196,35 @@ private: //! List of subshapes of the 2nd shape. BRepExtrema_ShapeList myShapeList2; + //! The 1st shape. + TopoDS_Shape myShape1; + //! The 2nd shape. + TopoDS_Shape myShape2; + + BVH_Array3d myAddVertices1; //!< Additional vertices on the 1st shape if its mesh is coarser. + BVH_Array3d myAddVertices2; //!< Additional vertices on the 2nd shape if its mesh is coarser. + + NCollection_Vector myAddStatus1; //!< Status of additional vertices on the 1st shape. + NCollection_Vector myAddStatus2; //!< Status of additional vertices on the 2nd shape. + + Standard_Boolean myIsInitS1; //!< Is the 1st shape initialized? + Standard_Boolean myIsInitS2; //!< Is the 2nd shape initialized? + + Standard_Boolean myIsRefinementRequired1; //!< Flag about the need to refine the 1st shape. + Standard_Boolean myIsRefinementRequired2; //!< Flag about the need to refine the 2nd shape. + + Standard_Integer myNbNodes1; //!< Number of nodes in triangulation of the 1st shape. + Standard_Integer myNbNodes2; //!< Number of nodes in triangulation of the 2nd shape. + + Standard_Real myStep1; //!< Step for getting vertices on the 1st shape. + Standard_Real myStep2; //!< Step for getting vertices on the 2nd shape. + + BRepExtrema_CellFilter myCells; + BRepExtrema_VertexInspector myInspector; + + TopAbs_ShapeEnum myShapeType1; //!< 1st shape type. + TopAbs_ShapeEnum myShapeType2; //!< 2nd shape type. + Standard_Real myDistance; //!< Distance Standard_Boolean myIsDone; //!< State of the algorithm diff --git a/src/BRepExtrema/BRepExtrema_ShapeProximity.cxx b/src/BRepExtrema/BRepExtrema_ShapeProximity.cxx index 09efa4e585..034f25e66e 100644 --- a/src/BRepExtrema/BRepExtrema_ShapeProximity.cxx +++ b/src/BRepExtrema/BRepExtrema_ShapeProximity.cxx @@ -129,6 +129,7 @@ void BRepExtrema_ShapeProximity::Perform() myElementSet2); myProxValTool.LoadShapeLists (myShapeList1, myShapeList2); + myProxValTool.SetNbSamplePoints (myNbSamples1, myNbSamples2); myProxValTool.Perform (myTolerance); myProxValTool.ProximityPoints(myProxPoint1, myProxPoint2); diff --git a/src/BRepExtrema/BRepExtrema_ShapeProximity.hxx b/src/BRepExtrema/BRepExtrema_ShapeProximity.hxx index c6f6d77721..63f56a941f 100644 --- a/src/BRepExtrema/BRepExtrema_ShapeProximity.hxx +++ b/src/BRepExtrema/BRepExtrema_ShapeProximity.hxx @@ -37,7 +37,8 @@ //! on distance less than the given tolerance from each other. //! //! Second approach: -//! Compute the proximity value between two shapes if the tolerance is not defined (Precision::Infinite()). +//! Compute the proximity value between two shapes (handles only edge/edge or face/face cases) +//! if the tolerance is not defined (Precision::Infinite()). //! In this case the proximity value is a minimal thickness of a layer containing both shapes. //! //! For the both approaches the high performance is achieved through the use of existing @@ -46,8 +47,6 @@ //! triangulation). class BRepExtrema_ShapeProximity { -public: - typedef typename BRepExtrema_ProximityValueTool::ProxPnt_Status ProxPnt_Status; public: diff --git a/src/BRepFill/BRepFill_TrimShellCorner.cxx b/src/BRepFill/BRepFill_TrimShellCorner.cxx index 77efa8fbab..ddbf218fd4 100644 --- a/src/BRepFill/BRepFill_TrimShellCorner.cxx +++ b/src/BRepFill/BRepFill_TrimShellCorner.cxx @@ -56,6 +56,7 @@ #include #include #include +#include static TopoDS_Edge FindEdgeCloseToBisectorPlane(const TopoDS_Vertex& theVertex, TopoDS_Compound& theComp, @@ -534,6 +535,26 @@ BRepFill_TrimShellCorner::MakeFacesNonSec(const Standard_Integer if(bHasNewEdge) { aNewEdge.Orientation(TopAbs_FORWARD); + + // Refer to BrepFill_Sweep.cxx BuildEdge Construct an edge via an iso + gp_Pnt P1, P2; + Standard_Real p11, p12, p21, p22; + P1 = BRep_Tool::Pnt(TopExp::FirstVertex(TopoDS::Edge(aNewEdge))); + P2 = BRep_Tool::Pnt(TopExp::LastVertex(TopoDS::Edge(aNewEdge))); + + TopoDS_Edge aERef = TopoDS::Edge(fit == 1 ? aE1 : aE2); + p11 = P1.Distance(BRep_Tool::Pnt(TopExp::FirstVertex(aERef))); + p22 = P2.Distance(BRep_Tool::Pnt(TopExp::LastVertex(aERef))); + p12 = P1.Distance(BRep_Tool::Pnt(TopExp::LastVertex(aERef))); + p21 = P2.Distance(BRep_Tool::Pnt(TopExp::FirstVertex(aERef))); + + if (p11 > p12 && p22 > p21) { + aNewEdge.Reverse(); + } + + // for nonPlane surface, we should add pCurve + Handle(ShapeFix_Edge) sfe = new ShapeFix_Edge(); + sfe->FixAddPCurve(aNewEdge, TopoDS::Face(aFace), Standard_False); } TopTools_ListOfShape aOrderedList; diff --git a/src/BRepLib/BRepLib.cxx b/src/BRepLib/BRepLib.cxx index a381c6c48c..bac141645c 100644 --- a/src/BRepLib/BRepLib.cxx +++ b/src/BRepLib/BRepLib.cxx @@ -802,7 +802,7 @@ static void GetEdgeTol(const TopoDS_Edge& theEdge, } if(temp > d2) d2 = temp; } - d2 = 1.5*sqrt(d2); + d2 = 1.05*sqrt(d2); theEdTol = d2; } @@ -884,10 +884,6 @@ static void UpdShTol(const TopTools_DataMapOfShapeReal& theShToTol, case TopAbs_VERTEX: { const Handle(BRep_TVertex)& aTV = *((Handle(BRep_TVertex)*)&aNsh.TShape()); - // - if(aTV->Locked()) - throw TopoDS_LockedShape("BRep_Builder::UpdateVertex"); - // if (theVForceUpdate) aTV->Tolerance(aTol); else @@ -1709,8 +1705,8 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, for (iCur=1; iCur<=nbV; iCur++) { tol=0; const TopoDS_Vertex& V = TopoDS::Vertex(parents.FindKey(iCur)); - Bnd_Box box; - box.Add(BRep_Tool::Pnt(V)); + gp_Pnt aPV = BRep_Tool::Pnt(V); + Standard_Real aMaxDist = 0.; gp_Pnt p3d; for (lConx.Initialize(parents(iCur)); lConx.More(); lConx.Next()) { const TopoDS_Edge& E = TopoDS::Edge(lConx.Value()); @@ -1732,8 +1728,10 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, if (!C.IsNull()) { // edge non degenerated p3d = C->Value(par); p3d.Transform(L.Transformation()); - box.Add(p3d); - } + Standard_Real aDist = p3d.SquareDistance(aPV); + if (aDist > aMaxDist) + aMaxDist = aDist; + } } else if (cr->IsCurveOnSurface()) { const Handle(Geom_Surface)& Su = cr->Surface(); @@ -1745,21 +1743,22 @@ static void InternalUpdateTolerances(const TopoDS_Shape& theOldShape, gp_Pnt2d p2d = PC->Value(par); p3d = Su->Value(p2d.X(),p2d.Y()); p3d.Transform(L.Transformation()); - box.Add(p3d); + Standard_Real aDist = p3d.SquareDistance(aPV); + if (aDist > aMaxDist) + aMaxDist = aDist; if (!PC2.IsNull()) { p2d = PC2->Value(par); p3d = Su->Value(p2d.X(),p2d.Y()); p3d.Transform(L.Transformation()); - box.Add(p3d); + aDist = p3d.SquareDistance(aPV); + if (aDist > aMaxDist) + aMaxDist = aDist; } } itcr.Next(); } } - Standard_Real aXmin, aYmin, aZmin, aXmax, aYmax, aZmax; - box.Get(aXmin, aYmin, aZmin, aXmax, aYmax, aZmax); - aXmax -= aXmin; aYmax -= aYmin; aZmax -= aZmin; - tol = Max(tol,sqrt(aXmax*aXmax+aYmax*aYmax+aZmax*aZmax)); + tol = Max(tol, sqrt(aMaxDist)); tol += 2.*Epsilon(tol); // Standard_Real aVTol = BRep_Tool::Tolerance(V); diff --git a/src/BRepOffset/BRepOffset_MakeOffset.cxx b/src/BRepOffset/BRepOffset_MakeOffset.cxx index 7da4639d31..5d4d00d3db 100644 --- a/src/BRepOffset/BRepOffset_MakeOffset.cxx +++ b/src/BRepOffset/BRepOffset_MakeOffset.cxx @@ -336,8 +336,10 @@ static BRepOffset_Error checkSinglePoint(const Standard_Real theUParam, const NCollection_Vector& theBadPoints); //--------------------------------------------------------------------- -static void UpdateTolerance ( TopoDS_Shape& myShape, - const TopTools_IndexedMapOfShape& myFaces); +static void UpdateTolerance ( TopoDS_Shape& theShape, + const TopTools_IndexedMapOfShape& theFaces, + const TopoDS_Shape& theInitShape); + static Standard_Real ComputeMaxDist(const gp_Pln& thePlane, const Handle(Geom_Curve)& theCrv, const Standard_Real theFirst, @@ -1036,8 +1038,16 @@ void BRepOffset_MakeOffset::MakeOffsetShape(const Message_ProgressRange& theRang // MAJ Tolerance edge and Vertex // ---------------------------- if (!myOffsetShape.IsNull()) { - UpdateTolerance (myOffsetShape,myFaces); - BRepLib::UpdateTolerances( myOffsetShape ); + if (myThickening) + { + UpdateTolerance(myOffsetShape, myFaces, myShape); + } + else + { + TopoDS_Shape aDummy; + UpdateTolerance(myOffsetShape, myFaces, aDummy); + } + BRepLib::UpdateTolerances(myOffsetShape); } CorrectConicalFaces(); @@ -3165,13 +3175,38 @@ void BRepOffset_MakeOffset::MakeMissingWalls (const Message_ProgressRange& theRa } //if both edges are arcs of circles if (NewFace.IsNull()) { - BRepLib_MakeFace MF(theWire, Standard_True); //Only plane - if (MF.Error() == BRepLib_FaceDone) + Standard_Real anEdgeTol = BRep_Tool::Tolerance(anEdge); + //Tolerances of input shape should not be increased by BRepLib_MakeFace + BRepLib_FindSurface aFindPlane(theWire, anEdgeTol, Standard_True); //only plane + IsPlanar = Standard_False; + if(aFindPlane.Found() && aFindPlane.ToleranceReached() <= anEdgeTol) { - NewFace = MF.Face(); - IsPlanar = Standard_True; + Standard_Real f, l; + Handle(Geom_Curve) aGC = BRep_Tool::Curve(anEdge, f, l); + Handle(Geom_Plane) aPln = Handle(Geom_Plane)::DownCast(aFindPlane.Surface()); + Standard_Real aMaxDist = ComputeMaxDist(aPln->Pln(), aGC, f, l); + if (aMaxDist <= anEdgeTol) + { + BRepLib_MakeFace MF(aPln->Pln(), theWire); + if (MF.IsDone()) + { + NewFace = MF.Face(); + TopoDS_Iterator anItE(theWire); + for (; anItE.More(); anItE.Next()) + { + const TopoDS_Edge& anE = TopoDS::Edge(anItE.Value()); + if (anE.IsSame(anEdge)) + continue; + aGC = BRep_Tool::Curve(anE, f, l); + aMaxDist = ComputeMaxDist(aPln->Pln(), aGC, f, l); + BB.UpdateEdge(anE, aMaxDist); + } + IsPlanar = Standard_True; + } + } } - else //Extrusion (by thrusections) + // + if(!IsPlanar) //Extrusion (by thrusections) { Handle(Geom_Curve) EdgeCurve = BRep_Tool::Curve(anEdge, fpar, lpar); Handle(Geom_TrimmedCurve) TrEdgeCurve = @@ -3185,7 +3220,6 @@ void BRepOffset_MakeOffset::MakeMissingWalls (const Message_ProgressRange& theRa ThrusecGenerator.AddCurve( TrOffsetCurve ); ThrusecGenerator.Perform( Precision::PConfusion() ); theSurf = ThrusecGenerator.Surface(); - //theSurf = new Geom_SurfaceOfLinearExtrusion( TrOffsetCurve, OffsetDir ); Standard_Real Uf, Ul, Vf, Vl; theSurf->Bounds(Uf, Ul, Vf, Vl); TopLoc_Location Loc; @@ -3272,8 +3306,14 @@ void BRepOffset_MakeOffset::MakeMissingWalls (const Message_ProgressRange& theRa BB.Range( anE3, FirstPar, LastPar ); } } - BRepLib::SameParameter(NewFace); - BRepTools::Update(NewFace); + + if (!IsPlanar) + { + // For planar faces these operations are useless, + // because there are no curves on surface + BRepLib::SameParameter(NewFace); + BRepTools::Update(NewFace); + } //Check orientation TopAbs_Orientation anOr = OrientationOfEdgeInFace(anEdge, aFaceOfEdge); TopAbs_Orientation OrInNewFace = OrientationOfEdgeInFace(anEdge, NewFace); @@ -3781,6 +3821,7 @@ void BRepOffset_MakeOffset::EncodeRegularity () #endif } + //======================================================================= //function : ComputeMaxDist //purpose : @@ -3807,13 +3848,15 @@ Standard_Real ComputeMaxDist(const gp_Pln& thePlane, } return sqrt(aMaxDist)*1.05; } + //======================================================================= -//function : UpDateTolerance +//function : UpdateTolerance //purpose : //======================================================================= void UpdateTolerance (TopoDS_Shape& S, - const TopTools_IndexedMapOfShape& Faces) + const TopTools_IndexedMapOfShape& Faces, + const TopoDS_Shape& theInitShape) { BRep_Builder B; TopTools_MapOfShape View; @@ -3829,12 +3872,31 @@ void UpdateTolerance (TopoDS_Shape& S, } } - Standard_Real Tol; - TopExp_Explorer ExpF; - for (ExpF.Init(S, TopAbs_FACE); ExpF.More(); ExpF.Next()) + // The edges of initial shape are not modified + TopTools_MapOfShape aMapInitF; + if (!theInitShape.IsNull()) { - const TopoDS_Shape& F = ExpF.Current(); - if (Faces.Contains(F)) + TopExp_Explorer anExpF(theInitShape, TopAbs_FACE); + for (; anExpF.More(); anExpF.Next()) { + aMapInitF.Add(anExpF.Current()); + TopExp_Explorer anExpE; + for (anExpE.Init(anExpF.Current(), TopAbs_EDGE); anExpE.More(); anExpE.Next()) { + View.Add(anExpE.Current()); + TopoDS_Iterator anItV(anExpE.Current()); + for (; anItV.More(); anItV.Next()) + { + View.Add(anItV.Value()); + } + } + } + } + + Standard_Real Tol; + TopExp_Explorer anExpF(S, TopAbs_FACE); + for (; anExpF.More(); anExpF.Next()) + { + const TopoDS_Shape& F = anExpF.Current(); + if (Faces.Contains(F) || aMapInitF.Contains(F)) { continue; } @@ -3843,6 +3905,7 @@ void UpdateTolerance (TopoDS_Shape& S, for (Exp.Init(F, TopAbs_EDGE); Exp.More(); Exp.Next()) { TopoDS_Edge E = TopoDS::Edge(Exp.Current()); Standard_Boolean isUpdated = Standard_False; + Standard_Real aCurrTol = BRep_Tool::Tolerance(E); if (aBAS.GetType() == GeomAbs_Plane) { //Edge does not seem to have pcurve on plane, @@ -3850,17 +3913,22 @@ void UpdateTolerance (TopoDS_Shape& S, Standard_Real aFirst, aLast; Handle(Geom_Curve) aCrv = BRep_Tool::Curve(E, aFirst, aLast); Standard_Real aMaxDist = ComputeMaxDist(aBAS.Plane(), aCrv, aFirst, aLast); - E.Locked (Standard_False); - B.UpdateEdge(E, aMaxDist); - isUpdated = Standard_True; + if (aMaxDist > aCurrTol) + { + B.UpdateEdge(E, aMaxDist); + isUpdated = Standard_True; + } } if (View.Add(E)) { - + E.Locked(Standard_False); BRepCheck_Edge EdgeCorrector(E); Tol = EdgeCorrector.Tolerance(); - B.UpdateEdge(E, Tol); - isUpdated = Standard_True; + if (Tol > aCurrTol) + { + B.UpdateEdge(E, Tol); + isUpdated = Standard_True; + } } if (isUpdated) { @@ -3869,11 +3937,11 @@ void UpdateTolerance (TopoDS_Shape& S, TopExp::Vertices(E, V[0], V[1]); for (Standard_Integer i = 0; i <= 1; i++) { + V[i].Locked(Standard_False); if (View.Add(V[i])) { Handle(BRep_TVertex) TV = Handle(BRep_TVertex)::DownCast(V[i].TShape()); TV->Tolerance(0.); BRepCheck_Vertex VertexCorrector(V[i]); - V[i].Locked (Standard_False); B.UpdateVertex(V[i], VertexCorrector.Tolerance()); // use the occasion to clean the vertices. (TV->ChangePoints()).Clear(); @@ -4953,6 +5021,53 @@ Standard_Boolean BRepOffset_MakeOffset::IsPlanar() if (aPlanarityChecker.IsPlanar()) { gp_Pln aPln = aPlanarityChecker.Plan(); + Standard_Real u1, u2, v1, v2, um, vm; + aSurf->Bounds(u1, u2, v1, v2); + Standard_Boolean isInf1 = Precision::IsInfinite(u1), isInf2 = Precision::IsInfinite(u2); + if (!isInf1 && !isInf2) + { + um = (u1 + u2) / 2.; + } + else if(isInf1 && !isInf2) + { + um = u2 - 1.; + } + else if(!isInf1 && isInf2) + { + um = u1 + 1.; + } + else //isInf1 && isInf2 + { + um = 0.; + } + isInf1 = Precision::IsInfinite(v1), isInf2 = Precision::IsInfinite(v2); + if (!isInf1 && !isInf2) + { + vm = (v1 + v2) / 2.; + } + else if (isInf1 && !isInf2) + { + vm = v2 - 1.; + } + else if(!isInf1 && isInf2) + { + vm = v1 + 1.; + } + else //isInf1 && isInf2 + { + vm = 0.; + } + gp_Pnt aP; + gp_Vec aD1, aD2; + aBAS.D1(um, vm, aP, aD1, aD2); + gp_Vec aNorm = aD1.Crossed(aD2); + gp_Dir aPlnNorm = aPln.Position().Direction(); + if (aNorm.Dot(aPlnNorm) < 0.) + { + aPlnNorm.Reverse(); + gp_Ax1 anAx(aPln.Position().Location(), aPlnNorm); + aPln.SetAxis(anAx); + } Handle(Geom_Plane) aPlane = new Geom_Plane(aPln); TopoDS_Face aPlanarFace; aBB.MakeFace(aPlanarFace, aPlane, aTolForFace); diff --git a/src/BSplCLib/BSplCLib.cxx b/src/BSplCLib/BSplCLib.cxx index cae229290b..6a2aa5f112 100644 --- a/src/BSplCLib/BSplCLib.cxx +++ b/src/BSplCLib/BSplCLib.cxx @@ -4234,6 +4234,133 @@ void BSplCLib::Resolution( Standard_Real& Poles, UTolerance = Tolerance3D / RealSmall(); } +//======================================================================= +// function : Intervals +// purpose : +//======================================================================= +Standard_Integer BSplCLib::Intervals (const TColStd_Array1OfReal& theKnots, + const TColStd_Array1OfInteger& theMults, + Standard_Integer theDegree, + Standard_Boolean isPeriodic, + Standard_Integer theContinuity, + Standard_Real theFirst, + Standard_Real theLast, + Standard_Real theTolerance, + TColStd_Array1OfReal* theIntervals) +{ + // remove all knots with multiplicity less or equal than (degree - continuity) except first and last + Standard_Integer aFirstIndex = isPeriodic ? 1 : FirstUKnotIndex (theDegree, theMults); + Standard_Integer aLastIndex = isPeriodic ? theKnots.Size() : LastUKnotIndex (theDegree, theMults); + TColStd_Array1OfReal aNewKnots (1, aLastIndex - aFirstIndex + 1); + Standard_Integer aNbNewKnots = 0; + for (Standard_Integer anIndex = aFirstIndex; anIndex <= aLastIndex; anIndex++) + { + if (theMults(anIndex) > (theDegree - theContinuity) || + anIndex == aFirstIndex || + anIndex == aLastIndex) + { + aNbNewKnots++; + aNewKnots(aNbNewKnots) = theKnots[anIndex]; + } + } + aNewKnots.Resize (1, aNbNewKnots, Standard_True); + + // the range boundaries + Standard_Real aCurFirst = theFirst; + Standard_Real aCurLast = theLast; + Standard_Real aPeriod = 0.0; + Standard_Integer aFirstPeriod = 0; + Standard_Integer aLastPeriod = 0; + // move boundaries into period + if (isPeriodic) + { + Standard_Real aLower = theKnots.First(); + Standard_Real anUpper = theKnots.Last(); + aPeriod = anUpper - aLower; + + while (aCurFirst < aLower) + { + aCurFirst += aPeriod; + aFirstPeriod--; + } + while (aCurLast < aLower) + { + aCurLast += aPeriod; + aLastPeriod--; + } + while (aCurFirst >= anUpper) + { + aCurFirst -= aPeriod; + aFirstPeriod += 1; + } + while (aCurLast >= anUpper) + { + aCurLast -= aPeriod; + aLastPeriod += 1; + } + } + // locate the left and nearest knot for boundaries + Standard_Integer anIndex1 = 0; + Standard_Integer anIndex2 = 0; + Standard_Real aDummyDouble; + // we use version of LocateParameter that doesn't need multiplicities + LocateParameter(theDegree, aNewKnots, TColStd_Array1OfInteger(), aCurFirst, Standard_False, 1, aNbNewKnots, anIndex1, aDummyDouble); + LocateParameter(theDegree, aNewKnots, TColStd_Array1OfInteger(), aCurLast, Standard_False, 1, aNbNewKnots, anIndex2, aDummyDouble); + // the case when the beginning of the range coincides with the next knot + if (anIndex1 < aNbNewKnots && Abs(aNewKnots[anIndex1 + 1] - aCurFirst) < theTolerance) + { + anIndex1 += 1; + } + // the case when the ending of the range coincides with the current knot + if (aNbNewKnots && Abs(aNewKnots[anIndex2] - aCurLast) < theTolerance) + { + anIndex2 -= 1; + } + Standard_Integer aNbIntervals = anIndex2 - anIndex1 + 1 + (aLastPeriod - aFirstPeriod) * (aNbNewKnots - 1); + + // fill the interval array + if (theIntervals) + { + theIntervals->Resize (1, aNbIntervals + 1, Standard_False); + if (isPeriodic && aLastPeriod != aFirstPeriod) + { + Standard_Integer anIndex = 1; + // part from the begging of range to the end of the first period + for (Standard_Integer i = anIndex1; i < aNewKnots.Size(); i++, anIndex++) + { + theIntervals->ChangeValue(anIndex) = aNewKnots[i] + aFirstPeriod * aPeriod; + } + // full periods + for (Standard_Integer aPeriodNum = aFirstPeriod + 1; aPeriodNum < aLastPeriod; aPeriodNum++) + { + for (Standard_Integer i = 1; i < aNewKnots.Size(); i++, anIndex++) + { + theIntervals->ChangeValue(anIndex) = aNewKnots[i] + aPeriodNum * aPeriod; + } + } + // part from the begging of the last period to the end of range + for (Standard_Integer i = 1; i <= anIndex2; i++, anIndex++) + { + theIntervals->ChangeValue(anIndex) = aNewKnots[i] + aLastPeriod * aPeriod; + } + } + else + { + Standard_Integer anIndex = 1; + for (Standard_Integer i = anIndex1; i <= anIndex2; i++, anIndex++) + { + theIntervals->ChangeValue(anIndex) = aNewKnots[i] + aFirstPeriod * aPeriod; + } + } + // update the first position (the begging of range doesn't coincide with the knot at anIndex1 in general) + theIntervals->ChangeValue(1) = theFirst; + // write the ending of the range (we didn't write it at all) + theIntervals->ChangeValue(aNbIntervals + 1) = theLast; + } + + return aNbIntervals; +} + //======================================================================= // function: FlatBezierKnots // purpose : diff --git a/src/BSplCLib/BSplCLib.hxx b/src/BSplCLib/BSplCLib.hxx index 92efed9613..710c204375 100644 --- a/src/BSplCLib/BSplCLib.hxx +++ b/src/BSplCLib/BSplCLib.hxx @@ -1456,8 +1456,26 @@ public: //! we have |f (u1) - f (u0)| < Tolerance3D Standard_EXPORT static void Resolution (const TColgp_Array1OfPnt2d& Poles, const TColStd_Array1OfReal* Weights, const Standard_Integer NumPoles, const TColStd_Array1OfReal& FlatKnots, const Standard_Integer Degree, const Standard_Real Tolerance3D, Standard_Real& UTolerance); - - + //! Splits the given range to BSpline intervals of given continuity + //! @param[in] theKnots the knots of BSpline + //! @param[in] theMults the knots' multiplicities + //! @param[in] theDegree the degree of BSpline + //! @param[in] isPeriodic the periodicity of BSpline + //! @param[in] theContinuity the target interval's continuity + //! @param[in] theFirst the begin of the target range + //! @param[in] theLast the end of the target range + //! @param[in] theTolerance the tolerance + //! @param[in,out] theIntervals the array to store intervals if isn't nullptr + //! @return the number of intervals + Standard_EXPORT static Standard_Integer Intervals (const TColStd_Array1OfReal& theKnots, + const TColStd_Array1OfInteger& theMults, + Standard_Integer theDegree, + Standard_Boolean isPeriodic, + Standard_Integer theContinuity, + Standard_Real theFirst, + Standard_Real theLast, + Standard_Real theTolerance, + TColStd_Array1OfReal* theIntervals); protected: diff --git a/src/BSplCLib/BSplCLib_2.cxx b/src/BSplCLib/BSplCLib_2.cxx index acef2d983a..0ae8628e5c 100644 --- a/src/BSplCLib/BSplCLib_2.cxx +++ b/src/BSplCLib/BSplCLib_2.cxx @@ -1157,82 +1157,97 @@ void BSplCLib::MergeBSplineKnots index, num_knots ; if (StartValue < EndValue - Tolerance) { - TColStd_Array1OfReal knots1(1,Knots1.Length()) ; - TColStd_Array1OfReal knots2(1,Knots2.Length()) ; - degree = Degree1 + Degree2 ; - index = 1 ; + TColStd_Array1OfReal knots1(1, Knots1.Length()); + TColStd_Array1OfReal knots2(1, Knots2.Length()); + degree = Degree1 + Degree2; + index = 1; - for (ii = Knots1.Lower() ; ii <= Knots1.Upper() ; ii++) { - knots1(index) = Knots1(ii) ; - index += 1 ; + for (ii = Knots1.Lower(); ii <= Knots1.Upper(); ii++) { + knots1(index) = Knots1(ii); + index += 1; } - index = 1 ; + index = 1; - for (ii = Knots2.Lower() ; ii <= Knots2.Upper() ; ii++) { - knots2(index) = Knots2(ii) ; - index += 1 ; + for (ii = Knots2.Lower(); ii <= Knots2.Upper(); ii++) { + knots2(index) = Knots2(ii); + index += 1; } BSplCLib::Reparametrize(StartValue, - EndValue, - knots1) ; - - BSplCLib::Reparametrize(StartValue, - EndValue, - knots2) ; - num_knots = 0 ; - jj = 1 ; + EndValue, + knots1); - for (ii = 1 ; ii <= knots1.Length() ; ii++) { + BSplCLib::Reparametrize(StartValue, + EndValue, + knots2); + num_knots = 0; + jj = 1; + + for (ii = 1; ii <= knots1.Length(); ii++) { while (jj <= knots2.Length() && knots2(jj) <= knots1(ii) - Tolerance) { - jj += 1 ; - num_knots += 1 ; + jj += 1; + num_knots += 1; } while (jj <= knots2.Length() && knots2(jj) <= knots1(ii) + Tolerance) { - jj += 1 ; + jj += 1; } - num_knots += 1 ; + num_knots += 1; } - NewKnots = - new TColStd_HArray1OfReal(1,num_knots) ; + NewKnots = + new TColStd_HArray1OfReal(1, num_knots); NewMults = - new TColStd_HArray1OfInteger(1,num_knots) ; - num_knots = 1 ; - jj = 1 ; + new TColStd_HArray1OfInteger(1, num_knots); + num_knots = 1; + jj = 1; - for (ii = 1 ; ii <= knots1.Length() ; ii++) { + for (ii = 1; ii <= knots1.Length(); ii++) { while (jj <= knots2.Length() && knots2(jj) <= knots1(ii) - Tolerance) { - NewKnots->ChangeArray1()(num_knots) = knots2(jj) ; - NewMults->ChangeArray1()(num_knots) = Mults2(jj) + Degree1 ; - jj += 1 ; - num_knots += 1 ; + NewKnots->ChangeArray1()(num_knots) = knots2(jj); + NewMults->ChangeArray1()(num_knots) = Mults2(jj) + Degree1; + jj += 1; + num_knots += 1; } - set_mults_flag = 0 ; + set_mults_flag = 0; while (jj <= knots2.Length() && knots2(jj) <= knots1(ii) + Tolerance) { - continuity = Min(Degree1 - Mults1(ii), Degree2 - Mults2(jj)) ; - set_mults_flag = 1 ; - NewMults->ChangeArray1()(num_knots) = degree - continuity ; - jj += 1 ; + continuity = Min(Degree1 - Mults1(ii), Degree2 - Mults2(jj)); + set_mults_flag = 1; + NewMults->ChangeArray1()(num_knots) = degree - continuity; + jj += 1; } - NewKnots->ChangeArray1()(num_knots) = knots1(ii) ; - if (! set_mults_flag) { - NewMults->ChangeArray1()(num_knots) = Mults1(ii) + Degree2 ; + NewKnots->ChangeArray1()(num_knots) = knots1(ii); + if (!set_mults_flag) { + NewMults->ChangeArray1()(num_knots) = Mults1(ii) + Degree2; } - num_knots += 1 ; + num_knots += 1; } - num_knots -= 1 ; - NewMults->ChangeArray1()(1) = degree + 1 ; - NewMults->ChangeArray1()(num_knots) = degree + 1 ; - index = 0 ; + num_knots -= 1; + NewMults->ChangeArray1()(1) = degree + 1; + NewMults->ChangeArray1()(num_knots) = degree + 1; + index = 0; - for (ii = 1 ; ii <= num_knots ; ii++) { - index += NewMults->Value(ii) ; + for (ii = 1; ii <= num_knots; ii++) { + index += NewMults->Value(ii); } - NumPoles = index - degree - 1 ; + NumPoles = index - degree - 1; + } + else + { + degree = Degree1 + Degree2; + num_knots = 2; + NewKnots = + new TColStd_HArray1OfReal(1, num_knots); + NewKnots->ChangeArray1()(1) = StartValue; + NewKnots->ChangeArray1()(num_knots) = EndValue; + + NewMults = + new TColStd_HArray1OfInteger(1, num_knots); + NewMults->ChangeArray1()(1) = degree + 1; + NewMults->ChangeArray1()(num_knots) = degree + 1; + NumPoles = BSplCLib::NbPoles(degree, Standard_False, NewMults->Array1()); } } diff --git a/src/DrawTrSurf/DrawTrSurf_Debug.cxx b/src/DrawTrSurf/DrawTrSurf_Debug.cxx index 1daa12d677..0a2a4b002d 100644 --- a/src/DrawTrSurf/DrawTrSurf_Debug.cxx +++ b/src/DrawTrSurf/DrawTrSurf_Debug.cxx @@ -27,7 +27,7 @@ // intended for use from debugger prompt (Command Window in Visual Studio) //! Save geometric object identified by pointer to handle -const char* DrawTrSurf_Set (const char* theNameStr, void* theHandlePtr) +Standard_EXPORT const char* DrawTrSurf_Set (const char* theNameStr, void* theHandlePtr) { if (theNameStr == 0 || theHandlePtr == 0) { @@ -57,7 +57,7 @@ const char* DrawTrSurf_Set (const char* theNameStr, void* theHandlePtr) } //! Set point to DRAW variable -const char* DrawTrSurf_SetPnt (const char* theNameStr, void* thePntPtr) +Standard_EXPORT const char* DrawTrSurf_SetPnt (const char* theNameStr, void* thePntPtr) { if (theNameStr == 0 || thePntPtr == 0) { @@ -77,7 +77,7 @@ const char* DrawTrSurf_SetPnt (const char* theNameStr, void* thePntPtr) } //! Set 2d point to DRAW variable -const char* DrawTrSurf_SetPnt2d (const char* theNameStr, void* thePnt2dPtr) +Standard_EXPORT const char* DrawTrSurf_SetPnt2d (const char* theNameStr, void* thePnt2dPtr) { if (theNameStr == 0 || thePnt2dPtr == 0) { @@ -102,17 +102,17 @@ const char* DrawTrSurf_SetPnt2d (const char* theNameStr, void* thePnt2dPtr) // work with them (DBX could, on SUN Solaris). #ifndef _MSC_VER -const char* DrawTrSurf_Set (const char* name, const Handle(Standard_Transient)& G) +Standard_EXPORT const char* DrawTrSurf_Set (const char* name, const Handle(Standard_Transient)& G) { return DrawTrSurf_Set (name, (void*)&G); } -const char* DrawTrSurf_Set (const char* theName, const gp_Pnt& thePnt) +Standard_EXPORT const char* DrawTrSurf_Set (const char* theName, const gp_Pnt& thePnt) { return DrawTrSurf_SetPnt (theName, (void*)&thePnt); } -const char* DrawTrSurf_Set (const char* theName, const gp_Pnt2d& thePnt2d) +Standard_EXPORT const char* DrawTrSurf_Set (const char* theName, const gp_Pnt2d& thePnt2d) { return DrawTrSurf_SetPnt2d (theName, (void*)&thePnt2d); } diff --git a/src/Extrema/Extrema_ExtCC.cxx b/src/Extrema/Extrema_ExtCC.cxx index def27cbe5e..06481b5539 100644 --- a/src/Extrema/Extrema_ExtCC.cxx +++ b/src/Extrema/Extrema_ExtCC.cxx @@ -674,7 +674,10 @@ void Extrema_ExtCC::PrepareParallelResult(const Standard_Real theUt11, Extrema_ExtPElC ExtPCir(aPCirc2, Extrema_CurveTool::Circle (*myC[0]), Precision::Confusion(), theUt11, theUt12); - + if (ExtPCir.NbExt() < 1) + { + continue; + } Standard_Real aMinSqD = ExtPCir.SquareDistance(1); for (Standard_Integer anExtID = 2; anExtID <= ExtPCir.NbExt(); anExtID++) { diff --git a/src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx b/src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx index f6727ca8e7..10b014ae43 100644 --- a/src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx +++ b/src/Geom2dAdaptor/Geom2dAdaptor_Curve.cxx @@ -58,65 +58,6 @@ static const Standard_Real PosTol = Precision::PConfusion() / 2; IMPLEMENT_STANDARD_RTTIEXT(Geom2dAdaptor_Curve, Adaptor2d_Curve2d) -static void DefinFPeriod(const Standard_Real theLower, - const Standard_Real theUpper, - const Standard_Real theEps, - const Standard_Real thePeriod, - Standard_Real &theCurFirst, - Standard_Integer &theFPer); - -static void DefinLPeriod(const Standard_Real theLower, - const Standard_Real theUpper, - const Standard_Real theEps, - const Standard_Real thePeriod, - Standard_Real &theCurLast, - Standard_Integer &theLPer); - -static Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK, - const TColStd_Array1OfInteger& theTM, - const TColStd_Array1OfInteger& theInter, - const Standard_Integer theCurDegree, - const Standard_Integer theNb, - const Standard_Integer theNbInt, - const Standard_Real theFirst, - const Standard_Real theLast, - const Standard_Real theEps, - const Standard_Boolean thePeriodicCur, - Standard_Integer theNbIntervals, - Standard_Real theLower = 0, - Standard_Real thePeriod = 0, - Standard_Integer theIndex1 = 0, - Standard_Integer theIndex2 = 0); - -static void WriteIntervals(const TColStd_Array1OfReal &theTK, - const TColStd_Array1OfInteger &theInter, - const Standard_Integer theNbInt, - const Standard_Integer theIndex1, - const Standard_Integer theIndex2, - const Standard_Real theCurPeriod, - const Standard_Boolean theFlagForFirst, - TColStd_Array1OfReal &theT, - TColStd_Array1OfInteger &theFinalIntervals, - Standard_Integer &theNbIntervals, - Standard_Integer &theCurInt); - -static void SpreadInt(const TColStd_Array1OfReal &theTK, - const TColStd_Array1OfInteger &theTM, - const TColStd_Array1OfInteger &theInter, - const Standard_Integer theCurDegree, - const Standard_Integer theNb, - const Standard_Integer theFPer, - const Standard_Integer theLPer, - const Standard_Integer theNbInt, - const Standard_Real theLower, - const Standard_Real theFirst, - const Standard_Real theLast, - const Standard_Real thePeriod, - const Standard_Real theLastParam, - const Standard_Real theEps, - TColStd_Array1OfReal &theT, - Standard_Integer &theNbIntervals); - //======================================================================= //function : ShallowCopy //purpose : @@ -354,158 +295,6 @@ GeomAbs_Shape Geom2dAdaptor_Curve::Continuity() const } } -//======================================================================= -//function : DefinFPeriod -//purpose : -//======================================================================= - -void DefinFPeriod(const Standard_Real theLower, - const Standard_Real theUpper, - const Standard_Real theEps, - const Standard_Real thePeriod, - Standard_Real &theCurFirst, - Standard_Integer &theFPer) -{ - if (theCurFirst >= theLower) - { - while (theCurFirst >= theUpper) - { - theCurFirst = theCurFirst - thePeriod; - theFPer++; - } - if (Abs(theUpper - theCurFirst) <= theEps) - { - theFPer++; - theCurFirst = theLower; - } - } - else - { - while (theCurFirst < theLower) - { - theCurFirst = theCurFirst + thePeriod; - if (Abs(theLower - theCurFirst) > theEps) - { - theFPer--; - } - } - - if (Abs(theUpper - theCurFirst) <= theEps) - { - theCurFirst = theLower; - } - } -} - -//======================================================================= -//function : DefinLPeriod -//purpose : -//======================================================================= - -void DefinLPeriod(const Standard_Real theLower, - const Standard_Real theUpper, - const Standard_Real theEps, - const Standard_Real thePeriod, - Standard_Real &theCurLast, - Standard_Integer &theLPer) -{ - if (theCurLast >= theLower) - { - if ((theCurLast >= theUpper) && (Abs(theCurLast - theUpper) <= theEps)) - { - theCurLast = theUpper; - } - else - { - while (theCurLast >= theUpper) - { - theCurLast = theCurLast - thePeriod; - theLPer++; - } - if (Abs(theUpper - theCurLast) <= theEps) - { - theCurLast = theLower; - } - } - } - else - { - while (theCurLast < theLower) - { - theCurLast = theCurLast + thePeriod; - if (Abs(theLower - theCurLast) > theEps) - { - theLPer--; - } - } - if (Abs(theUpper - theCurLast) <= theEps) - { - theCurLast = theLower; - } - } -} - -//======================================================================= -//function : LocalNbIntervals -//purpose : -//======================================================================= - -Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK, - const TColStd_Array1OfInteger& theTM, - const TColStd_Array1OfInteger& theInter, - const Standard_Integer theCurDegree, - const Standard_Integer theNb, - const Standard_Integer theNbInt, - const Standard_Real theFirst, - const Standard_Real theLast, - const Standard_Real theEps, - const Standard_Boolean thePeriodicCur, - Standard_Integer theNbIntervals, - Standard_Real theLower, - Standard_Real thePeriod, - Standard_Integer theIndex1, - Standard_Integer theIndex2) -{ - Standard_Real aNewFirst = theFirst; - Standard_Real aNewLast = theLast; - if (theIndex1 == 0) - { - BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theFirst, - thePeriodicCur, 1, theNb, theIndex1, aNewFirst); - } - if (theIndex2 == 0) - { - BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theLast, - thePeriodicCur, 1, theNb, theIndex2, aNewLast); - } - // Protection against theFirst = UFirst - eps, which located as ULast - eps - if (thePeriodicCur && ((aNewLast - aNewFirst) < Precision::PConfusion())) - { - if (Abs(aNewLast - theLower) < Precision::PConfusion()) - { - aNewLast += thePeriod; - } - else - { - aNewFirst -= thePeriod; - } - } - - if (Abs(aNewFirst - theTK(theIndex1 + 1)) < theEps) - { - theIndex1++; - } - if ((aNewLast - theTK(theIndex2)) > theEps) - { - theIndex2++; - } - for (Standard_Integer i = 1; i <= theNbInt; i++) - { - if (theInter(i) > theIndex1 && theInter(i) < theIndex2) theNbIntervals++; - } - return theNbIntervals; -} - //======================================================================= //function : NbIntervals //purpose : @@ -513,187 +302,49 @@ Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK, Standard_Integer Geom2dAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const { - Standard_Integer myNbIntervals = 1; - Standard_Integer NbSplit; - if (myTypeCurve == GeomAbs_BSplineCurve) { - Standard_Integer FirstIndex = myBSplineCurve->FirstUKnotIndex(); - Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex(); - TColStd_Array1OfInteger Inter(1, LastIndex - FirstIndex + 1); - Standard_Boolean aContPer = (S >= Continuity()) && myBSplineCurve->IsPeriodic(); - Standard_Boolean aContNotPer = (S > Continuity()) && !myBSplineCurve->IsPeriodic(); - if (aContPer || aContNotPer) { - Standard_Integer Cont; - switch (S) { - case GeomAbs_G1: - case GeomAbs_G2: - throw Standard_DomainError("Geom2dAdaptor_Curve::NbIntervals"); - break; - case GeomAbs_C0: - myNbIntervals = 1; - break; - case GeomAbs_C1: - case GeomAbs_C2: - case GeomAbs_C3: - case GeomAbs_CN: - { - if (S == GeomAbs_C1) Cont = 1; - else if (S == GeomAbs_C2) Cont = 2; - else if (S == GeomAbs_C3) Cont = 3; - else Cont = myBSplineCurve->Degree(); - Standard_Integer Degree = myBSplineCurve->Degree(); - Standard_Integer NbKnots = myBSplineCurve->NbKnots(); - TColStd_Array1OfInteger Mults(1, NbKnots); - myBSplineCurve->Multiplicities(Mults); - NbSplit = 1; - Standard_Integer Index = FirstIndex; - Inter(NbSplit) = Index; - Index++; - NbSplit++; - while (Index < LastIndex) - { - if (Degree - Mults(Index) < Cont) - { - Inter(NbSplit) = Index; - NbSplit++; - } - Index++; - } - Inter(NbSplit) = Index; - - Standard_Integer NbInt = NbSplit - 1; - - Standard_Integer Nb = myBSplineCurve->NbKnots(); - TColStd_Array1OfReal TK(1, Nb); - TColStd_Array1OfInteger TM(1, Nb); - myBSplineCurve->Knots(TK); - myBSplineCurve->Multiplicities(TM); - Standard_Real Eps = Min(Resolution(Precision::Confusion()), - Precision::PConfusion()); - - myNbIntervals = 1; - - if (!myBSplineCurve->IsPeriodic()) - { - myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - myFirst, myLast, Eps, Standard_False, myNbIntervals); - } - else - { - Standard_Real aCurFirst = myFirst; - Standard_Real aCurLast = myLast; - - Standard_Real aLower = myBSplineCurve->FirstParameter(); - Standard_Real anUpper = myBSplineCurve->LastParameter(); - - if ((Abs(aCurFirst - aLower) < Eps) && (aCurFirst < aLower)) - { - aCurFirst = aLower; - } - if ((Abs(aCurLast - anUpper) < Eps) && (aCurLast < anUpper)) - { - aCurLast = anUpper; - } - - Standard_Real aPeriod = myBSplineCurve->Period(); - Standard_Integer aLPer = 1; Standard_Integer aFPer = 1; - - if ((Abs(aLower - myFirst) < Eps) && (aCurFirst < aLower)) - { - aCurFirst = aLower; - } - else - { - DefinFPeriod(aLower, anUpper, - Eps, aPeriod, aCurFirst, aFPer); - } - DefinLPeriod(aLower, anUpper, - Eps, aPeriod, aCurLast, aLPer); - - if ((Abs(aLower - myFirst) < Eps) && (Abs(anUpper - myLast) < Eps)) - { - myNbIntervals = NbInt; - } - else - { - Standard_Integer aSumPer = Abs(aLPer - aFPer); - - Standard_Real aFirst = 0; - if (aLower < 0 && anUpper == 0) - { - if (Abs(aCurLast) < Eps) - { - aCurLast = 0; - } - aFirst = aLower; - } - - if (aSumPer <= 1) - { - if ((Abs(myFirst - TK(Nb) - aPeriod * (aFPer - 1)) <= Eps) && (myLast < (TK(Nb) + aPeriod * (aLPer - 1)))) - { - myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod); - return myNbIntervals; - } - if ((Abs(myFirst - aLower) < Eps) && (Abs(myLast - anUpper) < Eps)) - { - myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod); - return myNbIntervals; - } - } - - if (aSumPer != 0) - { - Standard_Integer aFInt = 0; - Standard_Integer aLInt = 0; - Standard_Integer aPInt = NbInt; - - if ((aCurFirst != aPeriod) || ((aCurFirst != anUpper) && (Abs(myFirst) < Eps))) - { - aFInt = 1; - } - if ((aCurLast != 0) && (aCurLast != anUpper)) - { - aLInt = 1; - } - - aFInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - aCurFirst, anUpper, Eps, Standard_True, aFInt, aLower, aPeriod); - - if (aCurLast == anUpper) - { - aLInt = NbInt; - } - else - { - if (Abs(aCurLast - aFirst) > Eps) - { - aLInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - aFirst, aCurLast, Eps, Standard_True, aLInt, aLower, aPeriod, 1); - } - else - { - aLInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - aFirst, aCurLast, Eps, Standard_True, aLInt, aLower, aPeriod); - } - } - - myNbIntervals = aFInt + aLInt + aPInt * (aSumPer - 1); - } - else - { - myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - aCurFirst, aCurLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod); - } - } - } - } - break; - } + if (myTypeCurve == GeomAbs_BSplineCurve) + { + if ((!myBSplineCurve->IsPeriodic() && S <= Continuity()) || S == GeomAbs_C0) + { + return 1; } + + Standard_Integer aDegree = myBSplineCurve->Degree(); + Standard_Integer aCont; + + switch (S) + { + case GeomAbs_C1: + aCont = 1; + break; + case GeomAbs_C2: + aCont = 2; + break; + case GeomAbs_C3: + aCont = 3; + break; + case GeomAbs_CN: + aCont = aDegree; + break; + default: + throw Standard_DomainError ("Geom2dAdaptor_Curve::NbIntervals()"); + } + + Standard_Real anEps = Min(Resolution(Precision::Confusion()), Precision::PConfusion()); + + return BSplCLib::Intervals(myBSplineCurve->Knots(), + myBSplineCurve->Multiplicities(), + aDegree, + myBSplineCurve->IsPeriodic(), + aCont, + myFirst, + myLast, + anEps, + nullptr); } + else if (myTypeCurve == GeomAbs_OffsetCurve){ + Standard_Integer myNbIntervals = 1; GeomAbs_Shape BaseS=GeomAbs_C0; switch(S){ case GeomAbs_G1: @@ -705,208 +356,14 @@ Standard_Integer Geom2dAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const case GeomAbs_C2: BaseS = GeomAbs_C3; break; default: BaseS = GeomAbs_CN; } - Geom2dAdaptor_Curve anAdaptor( Handle(Geom2d_OffsetCurve)::DownCast(myCurve)->BasisCurve() ); + Geom2dAdaptor_Curve anAdaptor (Handle(Geom2d_OffsetCurve)::DownCast(myCurve)->BasisCurve(), myFirst, myLast); myNbIntervals = anAdaptor.NbIntervals(BaseS); + return myNbIntervals; } - return myNbIntervals; -} - -//======================================================================= -//function : WriteIntervals -//purpose : -//======================================================================= - -void WriteIntervals(const TColStd_Array1OfReal &theTK, - const TColStd_Array1OfInteger &theInter, - const Standard_Integer theNbInt, - const Standard_Integer theIndex1, - const Standard_Integer theIndex2, - const Standard_Real theCurPeriod, - const Standard_Boolean theFlagForFirst, - TColStd_Array1OfReal &theT, - TColStd_Array1OfInteger &theFinalIntervals, - Standard_Integer &theNbIntervals, - Standard_Integer &theCurInt) -{ - if (theFlagForFirst) - { - for (Standard_Integer anId = 1; anId <= theNbInt; anId++) - { - if (theInter(anId) > theIndex1 && theInter(anId) <= theIndex2) - { - theNbIntervals++; - theFinalIntervals(theNbIntervals) = theInter(anId); - } - } - } else { - for (Standard_Integer anId = 1; anId <= theNbInt; anId++) - { - if (theInter(anId) > theIndex1 && theInter(anId) < theIndex2) - { - theNbIntervals++; - theFinalIntervals(theNbIntervals) = theInter(anId); - } - } - } - - theFinalIntervals(theNbIntervals + 1) = theIndex2; - - for (Standard_Integer anId = theCurInt; anId <= theNbIntervals + 1; anId++) - { - theT(anId) = theTK(theFinalIntervals(anId)) + theCurPeriod; - theCurInt++; - } -} - -//======================================================================= -//function : SpreadInt -//purpose : -//======================================================================= -void SpreadInt(const TColStd_Array1OfReal &theTK, - const TColStd_Array1OfInteger &theTM, - const TColStd_Array1OfInteger &theInter, - const Standard_Integer theCurDegree, - const Standard_Integer theNb, - const Standard_Integer theFPer, - const Standard_Integer theLPer, - const Standard_Integer theNbInt, - const Standard_Real theLower, - const Standard_Real theFirst, - const Standard_Real theLast, - const Standard_Real thePeriod, - const Standard_Real theLastParam, - const Standard_Real theEps, - TColStd_Array1OfReal &theT, - Standard_Integer &theNbIntervals) -{ - Standard_Integer anIndex1 = 0; - Standard_Integer anIndex2 = 0; - Standard_Real aNewFirst, aNewLast; - Standard_Integer anUpper; - BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theFirst, - Standard_True, 1, theNb, anIndex1, aNewFirst); - BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theLastParam, - Standard_True, 1, theNb, anIndex2, aNewLast); - - if (Abs(aNewFirst - theTK(anIndex1 + 1)) < theEps) - { - anIndex1++; - } - if ((aNewLast - theTK(anIndex2)) > theEps) - { - anIndex2++; - } - theNbIntervals = 1; - - if (anIndex1 == theNb) - { - anIndex1 = 1; - } - - // Count the max number of boundaries of intervals - if (Abs(theLPer - theFPer) > 1) - { - anUpper = theNb - anIndex1 + anIndex2 + (theLPer - theFPer - 1) * theNb + 1; - } - else - { - anUpper = theNb - anIndex1 + anIndex2 + 1; - } - - if (theLPer == theFPer) - { - anUpper = theInter.Upper(); - } - TColStd_Array1OfInteger aFinalIntervals(1, anUpper); - aFinalIntervals(1) = anIndex1; - - // If first and last are in the same period - if ((Abs(theLPer - theFPer) == 0)) - { - Standard_Integer aCurInt = 1; - Standard_Real aCurPeriod = theFPer * thePeriod; - - if (theFirst == aNewFirst && theLast == aNewLast) - { - aCurPeriod = 0; - } - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - anIndex2, aCurPeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt); - return; - } - - // If the first and the last are in neighboring periods - if (Abs(theLPer - theFPer) == 1) - { - Standard_Integer aCurInt = 1; - - if (Abs(theLastParam - theLower) < theEps) - { - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - return; - } - else - { - // For period with first - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - // For period with last - theNbIntervals++; - WriteIntervals(theTK, theInter, theNbInt, 1, - anIndex2, theLPer * thePeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt); - return; - } - } - // If the first and the last are far apart - if (Abs(theLPer - theFPer) > 1) - { - Standard_Integer aCurInt = 1; - if (Abs(theLastParam - theLower) < theEps) - { - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - - Standard_Integer aNbPer = Abs(theLPer - theFPer); - Standard_Integer aCurPer = theFPer + 1; - - while (aNbPer > 1) - { - theNbIntervals++; - WriteIntervals(theTK, theInter, theNbInt, 1, - theNb, aCurPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - - aNbPer--; - aCurPer++; - } - return; - } - else - { - // For period with first - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - - Standard_Integer aNbPer = Abs(theLPer - theFPer); - Standard_Integer aCurPer = theFPer + 1; - while (aNbPer > 1) - { - theNbIntervals++; - WriteIntervals(theTK, theInter, theNbInt, 1, - theNb, aCurPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - - aNbPer--; - aCurPer++; - } - // For period with last - theNbIntervals++; - WriteIntervals(theTK, theInter, theNbInt, 1, - anIndex2, theLPer * thePeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt); - return; - } + return 1; } } @@ -915,156 +372,53 @@ void SpreadInt(const TColStd_Array1OfReal &theTK, //purpose : //======================================================================= -void Geom2dAdaptor_Curve::Intervals(TColStd_Array1OfReal& T, - const GeomAbs_Shape S ) const +void Geom2dAdaptor_Curve::Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const { - Standard_Integer myNbIntervals = 1; - Standard_Integer NbSplit; - if (myTypeCurve == GeomAbs_BSplineCurve) { - Standard_Integer FirstIndex = myBSplineCurve->FirstUKnotIndex(); - Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex(); - TColStd_Array1OfInteger Inter (1, LastIndex-FirstIndex+1); - Standard_Boolean aContPer = (S >= Continuity()) && myBSplineCurve->IsPeriodic(); - Standard_Boolean aContNotPer = (S > Continuity()) && !myBSplineCurve->IsPeriodic(); - if (aContPer || aContNotPer) { - Standard_Integer Cont; - switch ( S) { - case GeomAbs_G1: - case GeomAbs_G2: - throw Standard_DomainError("Geom2dAdaptor_Curve::NbIntervals"); - break; - case GeomAbs_C0: - myNbIntervals = 1; - break; - case GeomAbs_C1: - case GeomAbs_C2: - case GeomAbs_C3: - case GeomAbs_CN: - { - if (S == GeomAbs_C1) Cont = 1; - else if (S == GeomAbs_C2) Cont = 2; - else if (S == GeomAbs_C3) Cont = 3; - else Cont = myBSplineCurve->Degree(); - Standard_Integer Degree = myBSplineCurve->Degree(); - Standard_Integer NbKnots = myBSplineCurve->NbKnots(); - TColStd_Array1OfInteger Mults(1, NbKnots); - myBSplineCurve->Multiplicities(Mults); - NbSplit = 1; - Standard_Integer Index = FirstIndex; - Inter(NbSplit) = Index; - Index++; - NbSplit++; - while (Index < LastIndex) - { - if (Degree - Mults(Index) < Cont) - { - Inter(NbSplit) = Index; - NbSplit++; - } - Index++; - } - Inter(NbSplit) = Index; - Standard_Integer NbInt = NbSplit - 1; - - Standard_Integer Nb = myBSplineCurve->NbKnots(); - Standard_Integer Index1 = 0; - Standard_Integer Index2 = 0; - Standard_Real newFirst, newLast; - TColStd_Array1OfReal TK(1, Nb); - TColStd_Array1OfInteger TM(1, Nb); - myBSplineCurve->Knots(TK); - myBSplineCurve->Multiplicities(TM); - Standard_Real Eps = Min(Resolution(Precision::Confusion()), - Precision::PConfusion()); - - if (!myBSplineCurve->IsPeriodic()) - { - BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myFirst, - myBSplineCurve->IsPeriodic(), - 1, Nb, Index1, newFirst); - BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myLast, - myBSplineCurve->IsPeriodic(), - 1, Nb, Index2, newLast); - - - // On decale eventuellement les indices - // On utilise une "petite" tolerance, la resolution ne doit - // servir que pour les tres longue courbes....(PRO9248) - if (Abs(newFirst - TK(Index1 + 1)) < Eps) Index1++; - if (newLast - TK(Index2) > Eps) Index2++; - - Inter(1) = Index1; - myNbIntervals = 1; - for (Standard_Integer i = 1; i <= NbInt; i++) { - if (Inter(i) > Index1 && Inter(i) < Index2) { - myNbIntervals++; - Inter(myNbIntervals) = Inter(i); - } - } - Inter(myNbIntervals + 1) = Index2; - - Standard_Integer ii = T.Lower() - 1; - for (Standard_Integer I = 1; I <= myNbIntervals + 1; I++) { - T(ii + I) = TK(Inter(I)); - } - } - else - { - Standard_Real aFirst = myFirst; - Standard_Real aLast = myLast; - - Standard_Real aCurFirst = aFirst; - Standard_Real aCurLast = aLast; - - Standard_Real aPeriod = myBSplineCurve->Period(); - Standard_Real aLower = myBSplineCurve->FirstParameter(); - Standard_Real anUpper = myBSplineCurve->LastParameter(); - - Standard_Integer aLPer = 0; Standard_Integer aFPer = 0; - - if (Abs(myFirst - aLower) <= Eps) - { - aCurFirst = aLower; - aFirst = aCurFirst; - } - if (Abs(myLast - anUpper) <= Eps) - { - aCurLast = anUpper; - aLast = aCurLast; - } - - if ((Abs(aLower - myFirst) < Eps) && (aCurFirst < aLower)) - { - aCurFirst = aLower; - } - else - { - DefinFPeriod(aLower, anUpper, - Eps, aPeriod, aCurFirst, aFPer); - } - DefinLPeriod(aLower, anUpper, - Eps, aPeriod, aCurLast, aLPer); - - if (myFirst == aLower) - { - aFPer = 0; - } - - SpreadInt(TK, TM, Inter, myBSplineCurve->Degree(), Nb, aFPer, aLPer, NbInt, aLower, myFirst, myLast, aPeriod, - aCurLast, Eps, T, myNbIntervals); - T(T.Lower()) = aFirst; - T(T.Lower() + myNbIntervals) = aLast; - return; - - } - } - T(T.Lower()) = myFirst; - T(T.Lower() + myNbIntervals) = myLast; + if (myTypeCurve == GeomAbs_BSplineCurve) + { + if ((!myBSplineCurve->IsPeriodic() && S <= Continuity()) || S == GeomAbs_C0) + { + T( T.Lower() ) = myFirst; + T( T.Lower() + 1 ) = myLast; return; - } } + + Standard_Integer aDegree = myBSplineCurve->Degree(); + Standard_Integer aCont; + + switch (S) + { + case GeomAbs_C1: + aCont = 1; + break; + case GeomAbs_C2: + aCont = 2; + break; + case GeomAbs_C3: + aCont = 3; + break; + case GeomAbs_CN: + aCont = aDegree; + break; + default: + throw Standard_DomainError ("Geom2dAdaptor_Curve::Intervals()"); + } + + Standard_Real anEps = Min(Resolution(Precision::Confusion()), Precision::PConfusion()); + + BSplCLib::Intervals(myBSplineCurve->Knots(), + myBSplineCurve->Multiplicities(), + aDegree, + myBSplineCurve->IsPeriodic(), + aCont, + myFirst, + myLast, + anEps, + &T); } + else if (myTypeCurve == GeomAbs_OffsetCurve){ + Standard_Integer myNbIntervals = 1; GeomAbs_Shape BaseS=GeomAbs_C0; switch(S){ case GeomAbs_G1: @@ -1077,13 +431,18 @@ void Geom2dAdaptor_Curve::Intervals(TColStd_Array1OfReal& T, default: BaseS = GeomAbs_CN; } - Geom2dAdaptor_Curve anAdaptor( Handle(Geom2d_OffsetCurve)::DownCast(myCurve)->BasisCurve() ); + Geom2dAdaptor_Curve anAdaptor (Handle(Geom2d_OffsetCurve)::DownCast(myCurve)->BasisCurve(), myFirst, myLast); myNbIntervals = anAdaptor.NbIntervals(BaseS); anAdaptor.Intervals(T, BaseS); + T( T.Lower() ) = myFirst; + T( T.Lower() + myNbIntervals ) = myLast; } - T( T.Lower() ) = myFirst; - T( T.Lower() + myNbIntervals ) = myLast; + else + { + T( T.Lower() ) = myFirst; + T( T.Lower() + 1 ) = myLast; + } } //======================================================================= diff --git a/src/Geom2dConvert/Geom2dConvert.cxx b/src/Geom2dConvert/Geom2dConvert.cxx index dd3ba3da94..a120df013b 100644 --- a/src/Geom2dConvert/Geom2dConvert.cxx +++ b/src/Geom2dConvert/Geom2dConvert.cxx @@ -515,7 +515,6 @@ static Handle(Geom2d_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCu Handle(TColStd_HArray1OfReal) resKnots; Handle(TColStd_HArray1OfInteger) resMults; Standard_Real start_value,end_value; - Standard_Real tolerance=Precision::Confusion(); Standard_Integer resNbPoles,degree, ii,jj, aStatus; @@ -527,6 +526,7 @@ static Handle(Geom2d_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCu BS->KnotSequence(BSFlatKnots); start_value = BSKnots(1); end_value = BSKnots(BS->NbKnots()); + Standard_Real tolerance = 10.*Epsilon(Abs(end_value)); a->Knots(aKnots); a->Poles(aPoles); @@ -565,22 +565,6 @@ static Handle(Geom2d_BSplineCurve) MultNumandDenom(const Handle(Geom2d_BSplineCu degree, resDenPoles, aStatus); -// BSplCLib::FunctionMultiply(law_evaluator, -// BS->Degree(), -// BSFlatKnots, -// BSPoles, -// resFlatKnots, -// degree, -// resNumPoles, -// aStatus); -// BSplCLib::FunctionMultiply(law_evaluator, -// BS->Degree(), -// BSFlatKnots, -// BSWeights, -// resFlatKnots, -// degree, -// resDenPoles, -// aStatus); for (ii=1;ii<=resNbPoles;ii++) for(jj=1;jj<=2;jj++) resPoles(ii).SetCoord(jj,resNumPoles(ii).Coord(jj)/resDenPoles(ii)); @@ -1339,24 +1323,22 @@ void Geom2dConvert::ConcatC1(TColGeom2d_Array1OfBSplineCurve& ArrayOf Curve1Poles(ii).SetCoord(jj,Curve1Poles(ii).Coord(jj)*Curve1Weights(ii)); //POP pour NT Geom2dConvert_reparameterise_evaluator ev (aPolynomialCoefficient); -// BSplCLib::FunctionReparameterise(reparameterise_evaluator, BSplCLib::FunctionReparameterise(ev, Curve1->Degree(), Curve1FlatKnots, Curve1Poles, FlatKnots, - aNewCurveDegree, + aNewCurveDegree, NewPoles, aStatus ); - TColStd_Array1OfReal NewWeights(1, FlatKnots.Length() - (aNewCurveDegree + 1)); -// BSplCLib::FunctionReparameterise(reparameterise_evaluator, + TColStd_Array1OfReal NewWeights(1, FlatKnots.Length() - (aNewCurveDegree + 1)); BSplCLib::FunctionReparameterise(ev, Curve1->Degree(), Curve1FlatKnots, Curve1Weights, FlatKnots, - aNewCurveDegree, + aNewCurveDegree, NewWeights, aStatus ); diff --git a/src/GeomAdaptor/GeomAdaptor_Curve.cxx b/src/GeomAdaptor/GeomAdaptor_Curve.cxx index 24aacacb77..a68075eeb0 100644 --- a/src/GeomAdaptor/GeomAdaptor_Curve.cxx +++ b/src/GeomAdaptor/GeomAdaptor_Curve.cxx @@ -58,65 +58,6 @@ static const Standard_Real PosTol = Precision::PConfusion() / 2; IMPLEMENT_STANDARD_RTTIEXT(GeomAdaptor_Curve, Adaptor3d_Curve) -static void DefinFPeriod(const Standard_Real theLower, - const Standard_Real theUpper, - const Standard_Real theEps, - const Standard_Real thePeriod, - Standard_Real &theCurFirst, - Standard_Integer &theFPer); - -static void DefinLPeriod(const Standard_Real theLower, - const Standard_Real theUpper, - const Standard_Real theEps, - const Standard_Real thePeriod, - Standard_Real &theCurLast, - Standard_Integer &theLPer); - -static Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK, - const TColStd_Array1OfInteger& theTM, - const TColStd_Array1OfInteger& theInter, - const Standard_Integer theCurDegree, - const Standard_Integer theNb, - const Standard_Integer theNbInt, - const Standard_Real theFirst, - const Standard_Real theLast, - const Standard_Real theEps, - const Standard_Boolean thePeriodicCur, - Standard_Integer theNbIntervals, - Standard_Real theLower = 0, - Standard_Real thePeriod = 0, - Standard_Integer theIndex1 = 0, - Standard_Integer theIndex2 = 0); - -static void WriteIntervals(const TColStd_Array1OfReal &theTK, - const TColStd_Array1OfInteger &theInter, - const Standard_Integer theNbInt, - const Standard_Integer theIndex1, - const Standard_Integer theIndex2, - const Standard_Real theCurPeriod, - const Standard_Boolean theFlagForFirst, - TColStd_Array1OfReal &theT, - TColStd_Array1OfInteger &theFinalIntervals, - Standard_Integer &theNbIntervals, - Standard_Integer &theCurInt); - -static void SpreadInt(const TColStd_Array1OfReal &theTK, - const TColStd_Array1OfInteger &theTM, - const TColStd_Array1OfInteger &theInter, - const Standard_Integer theCurDegree, - const Standard_Integer theNb, - const Standard_Integer theFPer, - const Standard_Integer theLPer, - const Standard_Integer theNbInt, - const Standard_Real theLower, - const Standard_Real theFirst, - const Standard_Real theLast, - const Standard_Real thePeriod, - const Standard_Real theLastParam, - const Standard_Real theEps, - TColStd_Array1OfReal &theT, - Standard_Integer &theNbIntervals); - //======================================================================= //function : ShallowCopy //purpose : @@ -310,159 +251,6 @@ GeomAbs_Shape GeomAdaptor_Curve::Continuity() const return GeomAbs_CN; } -//======================================================================= -//function : DefinFPeriod -//purpose : -//======================================================================= - -void DefinFPeriod(const Standard_Real theLower, - const Standard_Real theUpper, - const Standard_Real theEps, - const Standard_Real thePeriod, - Standard_Real &theCurFirst, - Standard_Integer &theFPer) -{ - if (theCurFirst >= theLower) - { - while (theCurFirst >= theUpper) - { - theCurFirst = theCurFirst - thePeriod; - theFPer++; - } - if (Abs(theUpper - theCurFirst) <= theEps) - { - theFPer++; - theCurFirst = theLower; - } - } - else - { - while (theCurFirst < theLower) - { - theCurFirst = theCurFirst + thePeriod; - if ((Abs(theLower - theCurFirst)) > theEps) - { - theFPer--; - } - } - - if (Abs(theUpper - theCurFirst) <= theEps) - { - theCurFirst = theLower; - } - } -} - -//======================================================================= -//function : DefinLPeriod -//purpose : -//======================================================================= - -void DefinLPeriod(const Standard_Real theLower, - const Standard_Real theUpper, - const Standard_Real theEps, - const Standard_Real thePeriod, - Standard_Real &theCurLast, - Standard_Integer &theLPer) -{ - if (theCurLast >= theLower) - { - if ((theCurLast >= theUpper) && (Abs(theCurLast - theUpper) <= theEps)) - { - theCurLast = theUpper; - } - else - { - while (theCurLast >= theUpper) - { - theCurLast = theCurLast - thePeriod; - theLPer++; - } - if (Abs(theUpper - theCurLast) <= theEps) - { - theCurLast = theLower; - } - } - } - else - { - while (theCurLast < theLower) - { - theCurLast = theCurLast + thePeriod; - if (Abs(theLower - theCurLast) > theEps) - { - theLPer--; - } - } - if ((theUpper - theCurLast) <= theEps) - { - theCurLast = theLower; - } - } -} - -//======================================================================= -//function : LocalNbIntervals -//purpose : -//======================================================================= - -Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK, - const TColStd_Array1OfInteger& theTM, - const TColStd_Array1OfInteger& theInter, - const Standard_Integer theCurDegree, - const Standard_Integer theNb, - const Standard_Integer theNbInt, - const Standard_Real theFirst, - const Standard_Real theLast, - const Standard_Real theEps, - const Standard_Boolean thePeriodicCur, - Standard_Integer theNbIntervals, - Standard_Real theLower, - Standard_Real thePeriod, - Standard_Integer theIndex1, - Standard_Integer theIndex2) -{ - Standard_Real aNewFirst = theFirst; - Standard_Real aNewLast = theLast; - if (theIndex1 == 0) - { - BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theFirst, - thePeriodicCur, 1, theNb, theIndex1, aNewFirst); - } - if (theIndex2 == 0) - { - BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theLast, - thePeriodicCur, 1, theNb, theIndex2, aNewLast); - } - // Protection against theFirst = UFirst - eps, which located as ULast - eps - if (thePeriodicCur && ((aNewLast - aNewFirst) < Precision::PConfusion())) - { - if (Abs(aNewLast - theLower) < Precision::PConfusion()) - { - aNewLast += thePeriod; - } - else - { - aNewFirst -= thePeriod; - } - } - - if (Abs(aNewFirst - theTK(theIndex1 + 1)) < theEps) - { - theIndex1++; - } - if ((aNewLast - theTK(theIndex2)) > theEps) - { - theIndex2++; - } - for (Standard_Integer i = 1; i <= theNbInt; i++) - { - if (theInter(i) > theIndex1 && theInter(i) < theIndex2) theNbIntervals++; - } - return theNbIntervals; -} - - //======================================================================= //function : NbIntervals //purpose : @@ -470,207 +258,61 @@ Standard_Integer LocalNbIntervals(const TColStd_Array1OfReal& theTK, Standard_Integer GeomAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const { - Standard_Integer myNbIntervals = 1; - Standard_Integer NbSplit; - if (myTypeCurve == GeomAbs_BSplineCurve) { - Standard_Integer FirstIndex = myBSplineCurve->FirstUKnotIndex(); - Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex(); - TColStd_Array1OfInteger Inter(1, LastIndex - FirstIndex + 1); - Standard_Boolean aContPer = (S >= Continuity()) && myBSplineCurve->IsPeriodic(); - Standard_Boolean aContNotPer = (S > Continuity()) && !myBSplineCurve->IsPeriodic(); - - if(aContPer || aContNotPer) { - Standard_Integer Cont; - switch (S) { - case GeomAbs_G1: - case GeomAbs_G2: - throw Standard_DomainError("GeomAdaptor_Curve::NbIntervals"); - break; - case GeomAbs_C0: - myNbIntervals = 1; - break; - case GeomAbs_C1: - case GeomAbs_C2: - case GeomAbs_C3: - case GeomAbs_CN: - { - if (S == GeomAbs_C1) Cont = 1; - else if (S == GeomAbs_C2) Cont = 2; - else if (S == GeomAbs_C3) Cont = 3; - else Cont = myBSplineCurve->Degree(); - Standard_Integer Degree = myBSplineCurve->Degree(); - Standard_Integer NbKnots = myBSplineCurve->NbKnots(); - TColStd_Array1OfInteger Mults(1, NbKnots); - myBSplineCurve->Multiplicities(Mults); - NbSplit = 1; - Standard_Integer Index = FirstIndex; - Inter(NbSplit) = Index; - Index++; - NbSplit++; - while (Index < LastIndex) - { - if (Degree - Mults(Index) < Cont) - { - Inter(NbSplit) = Index; - NbSplit++; - } - Index++; - } - Inter(NbSplit) = Index; - - Standard_Integer NbInt = NbSplit - 1; - - Standard_Integer Nb = myBSplineCurve->NbKnots(); - Standard_Integer Index1 = 0; - Standard_Integer Index2 = 0; - const TColStd_Array1OfReal& TK = myBSplineCurve->Knots(); - const TColStd_Array1OfInteger& TM = myBSplineCurve->Multiplicities(); - Standard_Real Eps = Min(Resolution(Precision::Confusion()), - Precision::PConfusion()); - - myNbIntervals = 1; - - if (!myBSplineCurve->IsPeriodic()) - { - myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - myFirst, myLast, Eps, Standard_False, myNbIntervals); - } - else - { - Standard_Real aCurFirst = myFirst; - Standard_Real aCurLast = myLast; - Standard_Real aLower = myBSplineCurve->FirstParameter(); - Standard_Real anUpper = myBSplineCurve->LastParameter(); - - if ((Abs(aCurFirst - aLower) < Eps) && (aCurFirst < aLower)) - { - aCurFirst = aLower; - } - if ((Abs(aCurLast - anUpper) < Eps) && (aCurLast < anUpper)) - { - aCurLast = anUpper; - } - - Standard_Real aPeriod = myBSplineCurve->Period(); - Standard_Integer aLPer = 1; Standard_Integer aFPer = 1; - if ((Abs(aLower - myFirst) < Eps) && (aCurFirst < aLower)) - { - aCurFirst = aLower; - } - else - { - DefinFPeriod(aLower, anUpper, - Eps, aPeriod, aCurFirst, aFPer); - } - DefinLPeriod(aLower, anUpper, - Eps, aPeriod, aCurLast, aLPer); - - Standard_Real aNewFirst; - Standard_Real aNewLast; - BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myFirst, - Standard_True, 1, Nb, Index1, aNewFirst); - BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myLast, - Standard_True, 1, Nb, Index2, aNewLast); - if ((aNewFirst == myFirst && aNewLast == myLast) && (aFPer != aLPer)) - { - myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod); - } - else - { - Standard_Integer aSumPer = Abs(aLPer - aFPer); - - Standard_Real aFirst = 0; - if (aLower < 0 && anUpper == 0) - { - if (Abs(aCurLast) < Eps) - { - aCurLast = 0; - } - aFirst = aLower; - } - - if (aSumPer <= 1) - { - if ((Abs(myFirst - TK(Nb) - aPeriod * (aFPer - 1)) <= Eps) && (myLast < (TK(Nb) + aPeriod * (aLPer - 1)))) - { - myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod); - return myNbIntervals; - } - if ((Abs(myFirst - aLower) < Eps) && (Abs(myLast - anUpper) < Eps)) - { - myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - myFirst, myLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod); - return myNbIntervals; - } - } - - if (aSumPer != 0) - { - Standard_Integer aFInt = 0; - Standard_Integer aLInt = 0; - Standard_Integer aPInt = NbInt; - - if ((aCurFirst != aPeriod) || ((aCurFirst != anUpper) && (Abs(myFirst) < Eps))) - { - aFInt = 1; - } - if ((aCurLast != aLower) && (aCurLast != anUpper)) - { - aLInt = 1; - } - - aFInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - aCurFirst, anUpper, Eps, Standard_True, aFInt, aLower, aPeriod); - - if (aCurLast == anUpper) - { - aLInt = NbInt; - } - else - { - if (Abs(aCurLast - aFirst) > Eps) - { - aLInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - aFirst, aCurLast, Eps, Standard_True, aLInt, aLower, aPeriod, 1); - } - else - { - aLInt = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - aFirst, aCurLast, Eps, Standard_True, aLInt, aLower, aPeriod); - } - } - - myNbIntervals = aFInt + aLInt + aPInt * (aSumPer - 1); - } - else - { - myNbIntervals = LocalNbIntervals(TK, TM, Inter, Degree, Nb, NbInt, - aCurFirst, aCurLast, Eps, Standard_True, myNbIntervals, aLower, aPeriod); - } - } - } - } - break; - } + if (myTypeCurve == GeomAbs_BSplineCurve) + { + if ((!myBSplineCurve->IsPeriodic() && S <= Continuity()) || S == GeomAbs_C0) + { + return 1; } + + Standard_Integer aDegree = myBSplineCurve->Degree(); + Standard_Integer aCont; + + switch (S) + { + case GeomAbs_C1: + aCont = 1; + break; + case GeomAbs_C2: + aCont = 2; + break; + case GeomAbs_C3: + aCont = 3; + break; + case GeomAbs_CN: + aCont = aDegree; + break; + default: + throw Standard_DomainError ("GeomAdaptor_Curve::NbIntervals()"); + } + + Standard_Real anEps = Min(Resolution(Precision::Confusion()), Precision::PConfusion()); + + return BSplCLib::Intervals(myBSplineCurve->Knots(), + myBSplineCurve->Multiplicities(), + aDegree, + myBSplineCurve->IsPeriodic(), + aCont, + myFirst, + myLast, + anEps, + nullptr); } else if (myTypeCurve == GeomAbs_OffsetCurve) { + Standard_Integer myNbIntervals = 1; GeomAbs_Shape BaseS=GeomAbs_C0; switch(S){ - case GeomAbs_G1: - case GeomAbs_G2: - throw Standard_DomainError("GeomAdaptor_Curve::NbIntervals"); - break; - case GeomAbs_C0: BaseS = GeomAbs_C1; break; - case GeomAbs_C1: BaseS = GeomAbs_C2; break; - case GeomAbs_C2: BaseS = GeomAbs_C3; break; - default: BaseS = GeomAbs_CN; + case GeomAbs_G1: + case GeomAbs_G2: + throw Standard_DomainError("GeomAdaptor_Curve::NbIntervals"); + break; + case GeomAbs_C0: BaseS = GeomAbs_C1; break; + case GeomAbs_C1: BaseS = GeomAbs_C2; break; + case GeomAbs_C2: BaseS = GeomAbs_C3; break; + default: BaseS = GeomAbs_CN; } - GeomAdaptor_Curve C - (Handle(Geom_OffsetCurve)::DownCast (myCurve)->BasisCurve()); + GeomAdaptor_Curve C (Handle(Geom_OffsetCurve)::DownCast (myCurve)->BasisCurve(), myFirst, myLast); // akm 05/04/02 (OCC278) If our curve is trimmed we must recalculate // the number of intervals obtained from the basis to // vvv reflect parameter bounds @@ -680,211 +322,16 @@ Standard_Integer GeomAdaptor_Curve::NbIntervals(const GeomAbs_Shape S) const TColStd_Array1OfReal rdfInter(1,1+iNbBasisInt); C.Intervals(rdfInter,BaseS); for (iInt=1; iInt<=iNbBasisInt; iInt++) - if (rdfInter(iInt)>myFirst && rdfInter(iInt)myFirst && rdfInter(iInt) theIndex1 && theInter(anId) <= theIndex2) - { - theNbIntervals++; - theFinalIntervals(theNbIntervals) = theInter(anId); - } - } - } else { - for (Standard_Integer anId = 1; anId <= theNbInt; anId++) - { - if (theInter(anId) > theIndex1 && theInter(anId) < theIndex2) - { - theNbIntervals++; - theFinalIntervals(theNbIntervals) = theInter(anId); - } - } - } - - theFinalIntervals(theNbIntervals + 1) = theIndex2; - - for (Standard_Integer anId = theCurInt; anId <= theNbIntervals + 1; anId++) - { - theT(anId) = theTK(theFinalIntervals(anId)) + theCurPeriod; - theCurInt++; - } -} - -//======================================================================= -//function : SpreadInt -//purpose : -//======================================================================= - -void SpreadInt(const TColStd_Array1OfReal &theTK, - const TColStd_Array1OfInteger &theTM, - const TColStd_Array1OfInteger &theInter, - const Standard_Integer theCurDegree, - const Standard_Integer theNb, - const Standard_Integer theFPer, - const Standard_Integer theLPer, - const Standard_Integer theNbInt, - const Standard_Real theLower, - const Standard_Real theFirst, - const Standard_Real theLast, - const Standard_Real thePeriod, - const Standard_Real theLastParam, - const Standard_Real theEps, - TColStd_Array1OfReal &theT, - Standard_Integer &theNbIntervals) -{ - Standard_Integer anIndex1 = 0; - Standard_Integer anIndex2 = 0; - Standard_Real aNewFirst, aNewLast; - Standard_Integer anUpper; - BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theFirst, - Standard_True, 1, theNb, anIndex1, aNewFirst); - BSplCLib::LocateParameter(theCurDegree, theTK, theTM, theLastParam, - Standard_True, 1, theNb, anIndex2, aNewLast); - - if (Abs(aNewFirst - theTK(anIndex1 + 1)) < theEps) - { - anIndex1++; - } - if ((aNewLast - theTK(anIndex2)) > theEps) - { - anIndex2++; - } - theNbIntervals = 1; - - if (anIndex1 == theNb) - { - anIndex1 = 1; - } - - // Count the max number of boundaries of intervals - if (Abs(theLPer - theFPer) > 1) - { - anUpper = theNb - anIndex1 + anIndex2 + (theLPer - theFPer - 1) * theNb + 1; - } - else - { - anUpper = theNb - anIndex1 + anIndex2 + 1; - } - - if (theLPer == theFPer) - { - anUpper = theInter.Upper(); - } - TColStd_Array1OfInteger aFinalIntervals(1, anUpper); - aFinalIntervals(1) = anIndex1; - - // If first and last are in the same period - if ((Abs(theLPer - theFPer) == 0)) - { - Standard_Integer aCurInt = 1; - Standard_Real aCurPeriod = theFPer * thePeriod; - - if (theFirst == aNewFirst && theLast == aNewLast) - { - aCurPeriod = 0; - } - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - anIndex2, aCurPeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt); - return; - } - - // If the first and the last are in neighboring periods - if (Abs(theLPer - theFPer) == 1) - { - Standard_Integer aCurInt = 1; - - if (Abs(theLastParam - theLower) < theEps) - { - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - return; - } - else - { - // For period with first - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - // For period with last - theNbIntervals++; - WriteIntervals(theTK, theInter, theNbInt, 1, - anIndex2, theLPer * thePeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt); - return; - } - } - // If the first and the last are far apart - if (Abs(theLPer - theFPer) > 1) - { - Standard_Integer aCurInt = 1; - - if (Abs(theLastParam - theLower) < theEps) - { - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - - Standard_Integer aNbPer = Abs(theLPer - theFPer); - Standard_Integer aCurPer = theFPer + 1; - - while (aNbPer > 1) - { - theNbIntervals++; - WriteIntervals(theTK, theInter, theNbInt, 1, - theNb, aCurPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - - aNbPer--; - aCurPer++; - } - return; - } - else - { - // For period with first - WriteIntervals(theTK, theInter, theNbInt, anIndex1, - theNb, theFPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - - Standard_Integer aNbPer = Abs(theLPer - theFPer); - Standard_Integer aCurPer = theFPer + 1; - while (aNbPer > 1) - { - theNbIntervals++; - WriteIntervals(theTK, theInter, theNbInt, 1, - theNb, aCurPer * thePeriod, Standard_True, theT, aFinalIntervals, theNbIntervals, aCurInt); - - aNbPer--; - aCurPer++; - } - // For period with last - theNbIntervals++; - WriteIntervals(theTK, theInter, theNbInt, 1, - anIndex2, theLPer * thePeriod, Standard_False, theT, aFinalIntervals, theNbIntervals, aCurInt); - return; - } + return 1; } } @@ -893,175 +340,53 @@ void SpreadInt(const TColStd_Array1OfReal &theTK, //purpose : //======================================================================= -void GeomAdaptor_Curve::Intervals(TColStd_Array1OfReal& T, - const GeomAbs_Shape S ) const +void GeomAdaptor_Curve::Intervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const { - Standard_Integer myNbIntervals = 1; - Standard_Integer NbSplit; - Standard_Real FirstParam = myFirst, LastParam = myLast; - if (myTypeCurve == GeomAbs_BSplineCurve) { - Standard_Integer FirstIndex = myBSplineCurve->FirstUKnotIndex(); - Standard_Integer LastIndex = myBSplineCurve->LastUKnotIndex(); - TColStd_Array1OfInteger Inter(1, LastIndex - FirstIndex + 1); - Standard_Boolean aContPer = (S >= Continuity()) && myBSplineCurve->IsPeriodic(); - Standard_Boolean aContNotPer = (S > Continuity()) && !myBSplineCurve->IsPeriodic(); - - if (aContPer || aContNotPer) { - Standard_Integer Cont; - switch (S) { - case GeomAbs_G1: - case GeomAbs_G2: - throw Standard_DomainError("Geom2dAdaptor_Curve::NbIntervals"); - break; - case GeomAbs_C0: - myNbIntervals = 1; - break; - case GeomAbs_C1: - case GeomAbs_C2: - case GeomAbs_C3: - case GeomAbs_CN: - { - if (S == GeomAbs_C1) Cont = 1; - else if (S == GeomAbs_C2) Cont = 2; - else if (S == GeomAbs_C3) Cont = 3; - else Cont = myBSplineCurve->Degree(); - Standard_Integer Degree = myBSplineCurve->Degree(); - Standard_Integer NbKnots = myBSplineCurve->NbKnots(); - TColStd_Array1OfInteger Mults(1, NbKnots); - myBSplineCurve->Multiplicities(Mults); - NbSplit = 1; - Standard_Integer Index = FirstIndex; - Inter(NbSplit) = Index; - Index++; - NbSplit++; - while (Index < LastIndex) - { - if (Degree - Mults(Index) < Cont) - { - Inter(NbSplit) = Index; - NbSplit++; - } - Index++; - } - Inter(NbSplit) = Index; - Standard_Integer NbInt = NbSplit - 1; - // GeomConvert_BSplineCurveKnotSplitting Convector(myBspl, Cont); - // Standard_Integer NbInt = Convector.NbSplits()-1; - // TColStd_Array1OfInteger Inter(1,NbInt+1); - // Convector.Splitting( Inter); - - Standard_Integer Nb = myBSplineCurve->NbKnots(); - Standard_Integer Index1 = 0; - Standard_Integer Index2 = 0; - Standard_Real newFirst, newLast; - const TColStd_Array1OfReal& TK = myBSplineCurve->Knots(); - const TColStd_Array1OfInteger& TM = myBSplineCurve->Multiplicities(); - Standard_Real Eps = Min(Resolution(Precision::Confusion()), - Precision::PConfusion()); - - if (!myBSplineCurve->IsPeriodic() || ((Abs(myFirst - myBSplineCurve->FirstParameter()) < Eps) && - (Abs(myLast - myBSplineCurve->LastParameter()) < Eps))) - { - BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myFirst, - myBSplineCurve->IsPeriodic(), - 1, Nb, Index1, newFirst); - BSplCLib::LocateParameter(myBSplineCurve->Degree(), TK, TM, myLast, - myBSplineCurve->IsPeriodic(), - 1, Nb, Index2, newLast); - FirstParam = newFirst; - LastParam = newLast; - // Protection against myFirst = UFirst - eps, which located as ULast - eps - if (myBSplineCurve->IsPeriodic() && (LastParam - FirstParam) < Precision::PConfusion()) - { - if (Abs(LastParam - myBSplineCurve->FirstParameter()) < Precision::PConfusion()) - LastParam += myBSplineCurve->Period(); - else - FirstParam -= myBSplineCurve->Period(); - } - // On decale eventuellement les indices - // On utilise une "petite" tolerance, la resolution ne doit - // servir que pour les tres longue courbes....(PRO9248) - - if (Abs(FirstParam - TK(Index1 + 1)) < Eps) Index1++; - if (LastParam - TK(Index2) > Eps) Index2++; - - myNbIntervals = 1; - - TColStd_Array1OfInteger aFinalIntervals(1, Inter.Upper()); - aFinalIntervals(1) = Index1; - for (Standard_Integer i = 1; i <= NbInt; i++) { - if (Inter(i) > Index1 && Inter(i) < Index2) { - myNbIntervals++; - aFinalIntervals(myNbIntervals) = Inter(i); - } - } - aFinalIntervals(myNbIntervals + 1) = Index2; - - for (Standard_Integer I = 1; I <= myNbIntervals + 1; I++) { - T(I) = TK(aFinalIntervals(I)); - } - } - else - { - Standard_Real aFirst = myFirst; - Standard_Real aLast = myLast; - - Standard_Real aCurFirst = aFirst; - Standard_Real aCurLast = aLast; - - Standard_Real aPeriod = myBSplineCurve->Period(); - Standard_Real aLower = myBSplineCurve->FirstParameter(); - Standard_Real anUpper = myBSplineCurve->LastParameter(); - - Standard_Integer aLPer = 0; Standard_Integer aFPer = 0; - - if (Abs(myFirst - aLower) <= Eps) - { - aCurFirst = aLower; - aFirst = aCurFirst; - } - - if (Abs(myLast - anUpper) <= Eps) - { - aCurLast = anUpper; - aLast = aCurLast; - } - - if ((Abs(aLower - myFirst) < Eps) && (aCurFirst < aLower)) - { - aCurFirst = aLower; - } - else - { - DefinFPeriod(aLower, anUpper, - Eps, aPeriod, aCurFirst, aFPer); - } - DefinLPeriod(aLower, anUpper, - Eps, aPeriod, aCurLast, aLPer); - - if (myFirst == aLower) - { - aFPer = 0; - } - - SpreadInt(TK, TM, Inter, myBSplineCurve->Degree(), Nb, aFPer, aLPer, NbInt, aLower, myFirst, myLast, aPeriod, - aCurLast, Eps, T, myNbIntervals); - - T(T.Lower()) = aFirst; - T(T.Lower() + myNbIntervals) = aLast; - return; - } - } - T(T.Lower()) = myFirst; - T(T.Lower() + myNbIntervals) = myLast; + if ((!myBSplineCurve->IsPeriodic() && S <= Continuity()) || S == GeomAbs_C0) + { + T( T.Lower() ) = myFirst; + T( T.Lower() + 1 ) = myLast; return; - } } + + Standard_Integer aDegree = myBSplineCurve->Degree(); + Standard_Integer aCont; + + switch (S) + { + case GeomAbs_C1: + aCont = 1; + break; + case GeomAbs_C2: + aCont = 2; + break; + case GeomAbs_C3: + aCont = 3; + break; + case GeomAbs_CN: + aCont = aDegree; + break; + default: + throw Standard_DomainError ("GeomAdaptor_Curve::Intervals()"); + } + + Standard_Real anEps = Min(Resolution(Precision::Confusion()), Precision::PConfusion()); + + BSplCLib::Intervals(myBSplineCurve->Knots(), + myBSplineCurve->Multiplicities(), + aDegree, + myBSplineCurve->IsPeriodic(), + aCont, + myFirst, + myLast, + anEps, + &T); } else if (myTypeCurve == GeomAbs_OffsetCurve){ + Standard_Integer myNbIntervals = 1; GeomAbs_Shape BaseS=GeomAbs_C0; switch(S){ case GeomAbs_G1: @@ -1073,8 +398,7 @@ void GeomAdaptor_Curve::Intervals(TColStd_Array1OfReal& T, case GeomAbs_C2: BaseS = GeomAbs_C3; break; default: BaseS = GeomAbs_CN; } - GeomAdaptor_Curve C - (Handle(Geom_OffsetCurve)::DownCast (myCurve)->BasisCurve()); + GeomAdaptor_Curve C (Handle(Geom_OffsetCurve)::DownCast (myCurve)->BasisCurve(), myFirst, myLast); // akm 05/04/02 (OCC278) If our curve is trimmed we must recalculate // the array of intervals obtained from the basis to // vvv reflect parameter bounds @@ -1090,10 +414,15 @@ void GeomAdaptor_Curve::Intervals(TColStd_Array1OfReal& T, // old - myNbIntervals = C.NbIntervals(BaseS); // old - C.Intervals(T, BaseS); // akm 05/04/02 ^^^ + T( T.Lower() ) = myFirst; + T( T.Lower() + myNbIntervals ) = myLast; } - T( T.Lower() ) = FirstParam; - T( T.Lower() + myNbIntervals ) = LastParam; + else + { + T( T.Lower() ) = myFirst; + T( T.Lower() + 1 ) = myLast; + } } //======================================================================= diff --git a/src/GeomFill/GeomFill_SectionPlacement.cxx b/src/GeomFill/GeomFill_SectionPlacement.cxx index a2616b4b1d..8d39b1c3cd 100644 --- a/src/GeomFill/GeomFill_SectionPlacement.cxx +++ b/src/GeomFill/GeomFill_SectionPlacement.cxx @@ -276,6 +276,8 @@ GeomFill_SectionPlacement(const Handle(GeomFill_LocationLaw)& L, Standard_Integer NbLocalPnts = 10; Standard_Integer NbPnts = (NbKnots-1) * NbLocalPnts; + if (NbPnts < 0) + NbPnts = 0; if (I1 != I2) NbPnts += NbLocalPnts; if (I3 != I4 && first < BC->Knot(I3)) diff --git a/src/GeomLib/GeomLib_IsPlanarSurface.cxx b/src/GeomLib/GeomLib_IsPlanarSurface.cxx index b0c04de57c..16ec51a963 100644 --- a/src/GeomLib/GeomLib_IsPlanarSurface.cxx +++ b/src/GeomLib/GeomLib_IsPlanarSurface.cxx @@ -30,18 +30,6 @@ #include #include -static Standard_Boolean Controle(const TColgp_Array1OfPnt& P, - const gp_Pln& Plan, - const Standard_Real Tol) -{ - Standard_Integer ii; - Standard_Boolean B=Standard_True; - - for (ii=1; ii<=P.Length() && B; ii++) - B = (Plan.Distance(P(ii)) < Tol); - - return B; -} static Standard_Boolean Controle(const TColgp_Array1OfPnt& Poles, const Standard_Real Tol, @@ -49,51 +37,36 @@ static Standard_Boolean Controle(const TColgp_Array1OfPnt& Poles, gp_Pln& Plan) { Standard_Boolean IsPlan = Standard_False; - Standard_Boolean Essai = Standard_True; Standard_Real gx,gy,gz; - Standard_Integer Nb = Poles.Length(); - gp_Pnt Bary; + gp_Pnt Bary; gp_Dir DX, DY; + Standard_Real aTolSingular = Precision::Confusion(); - - if (Nb > 10) { - // Test allege (pour une rejection rapide) - TColgp_Array1OfPnt Aux(1,5); - Aux(1) = Poles(1); - Aux(2) = Poles(Nb/3); - Aux(3) = Poles(Nb/2); - Aux(4) = Poles(Nb/2+Nb/3); - Aux(5) = Poles(Nb); - GeomLib::Inertia(Aux, Bary, DX, DY, gx, gy, gz); - Essai = (gzTol) { - gp_Pnt P; - gp_Vec DU, DV; - Standard_Real umin, umax, vmin, vmax; - S->Bounds(umin, umax, vmin, vmax); - S->D1( (umin+umax)/2, (vmin+vmax)/2, P, DU, DV); - // On prend DX le plus proche possible de DU - gp_Dir du(DU); - Standard_Real Angle1 = du.Angle(DX); - Standard_Real Angle2 = du.Angle(DY); - if (Angle1 > M_PI/2) Angle1 = M_PI-Angle1; - if (Angle2 > M_PI/2) Angle2 = M_PI-Angle2; - if (Angle2 < Angle1) { - du = DY; DY = DX; DX = du; - } - if (DX.Angle(DU) > M_PI/2) DX.Reverse(); - if (DY.Angle(DV) > M_PI/2) DY.Reverse(); - - gp_Ax3 axe(Bary, DX^DY, DX); - Plan.SetPosition(axe); - Plan.SetLocation(Bary); - IsPlan = Standard_True; + + GeomLib::Inertia(Poles, Bary, DX, DY, gx, gy, gz); + if (gz < Tol && gy > aTolSingular) { + gp_Pnt P; + gp_Vec DU, DV; + Standard_Real umin, umax, vmin, vmax; + S->Bounds(umin, umax, vmin, vmax); + S->D1((umin + umax) / 2, (vmin + vmax) / 2, P, DU, DV); + // On prend DX le plus proche possible de DU + gp_Dir du(DU); + Standard_Real Angle1 = du.Angle(DX); + Standard_Real Angle2 = du.Angle(DY); + if (Angle1 > M_PI / 2) Angle1 = M_PI - Angle1; + if (Angle2 > M_PI / 2) Angle2 = M_PI - Angle2; + if (Angle2 < Angle1) { + du = DY; DY = DX; DX = du; } - } + if (DX.Angle(DU) > M_PI / 2) DX.Reverse(); + if (DY.Angle(DV) > M_PI / 2) DY.Reverse(); + + gp_Ax3 axe(Bary, DX^DY, DX); + Plan.SetPosition(axe); + Plan.SetLocation(Bary); + IsPlan = Standard_True; + } return IsPlan; } @@ -106,8 +79,6 @@ static Standard_Boolean Controle(const Handle(Geom_Curve)& C, GeomAbs_CurveType Type; GeomAdaptor_Curve AC(C); Type = AC.GetType(); - Handle(TColgp_HArray1OfPnt) TabP; - TabP.Nullify(); switch (Type) { case GeomAbs_Line : @@ -131,40 +102,27 @@ static Standard_Boolean Controle(const Handle(Geom_Curve)& C, case GeomAbs_BezierCurve: { Nb = AC.NbPoles(); - Handle (Geom_BezierCurve) BZ = AC.Bezier(); - TabP = new (TColgp_HArray1OfPnt) (1, AC.NbPoles()); - for (ii=1; ii<=Nb; ii++) - TabP->SetValue(ii, BZ->Pole(ii)); break; } case GeomAbs_BSplineCurve: { Nb = AC.NbPoles(); - Handle (Geom_BSplineCurve) BZ = AC.BSpline(); - TabP = new (TColgp_HArray1OfPnt) (1, AC.NbPoles()); - for (ii=1; ii<=Nb; ii++) - TabP->SetValue(ii, BZ->Pole(ii)); break; } - default : - { - Nb = 8 + 3*AC.NbIntervals(GeomAbs_CN); - } - } - - if (TabP.IsNull()) { - Standard_Real u, du, f, l, d; - f = AC.FirstParameter(); - l = AC.LastParameter(); - du = (l-f)/(Nb-1); - for (ii=1; ii<=Nb && B ; ii++) { - u = (ii-1)*du + f; - d = Plan.Distance(C->Value(u)); - B = (d < Tol); + default : + { + Nb = 8 + 3*AC.NbIntervals(GeomAbs_CN); } } - else { - B = Controle(TabP->Array1(), Plan, Tol); + + Standard_Real u, du, f, l, d; + f = AC.FirstParameter(); + l = AC.LastParameter(); + du = (l - f) / (Nb - 1); + for (ii = 1; ii <= Nb && B; ii++) { + u = (ii - 1)*du + f; + d = Plan.Distance(C->Value(u)); + B = d < Tol; } return B; @@ -196,30 +154,6 @@ GeomLib_IsPlanarSurface::GeomLib_IsPlanarSurface(const Handle(Geom_Surface)& S, IsPlan = Standard_False; break; } - case GeomAbs_BezierSurface : - case GeomAbs_BSplineSurface : - { - Standard_Integer ii, jj, kk, - NbU = AS.NbUPoles(), NbV = AS.NbVPoles(); - TColgp_Array1OfPnt Poles(1, NbU*NbV); - if (Type == GeomAbs_BezierSurface) { - Handle(Geom_BezierSurface) BZ; - BZ = AS.Bezier(); - for(ii=1, kk=1; ii<=NbU; ii++) - for(jj=1; jj<=NbV; jj++,kk++) - Poles(kk) = BZ->Pole(ii,jj); - } - else { - Handle(Geom_BSplineSurface) BS; - BS = AS.BSpline(); - for(ii=1, kk=1; ii<=NbU; ii++) - for(jj=1; jj<=NbV; jj++,kk++) - Poles(kk) = BS->Pole(ii,jj); - } - - IsPlan = Controle(Poles, Tol, S, myPlan); - break; - } case GeomAbs_SurfaceOfRevolution : { @@ -299,7 +233,7 @@ GeomLib_IsPlanarSurface::GeomLib_IsPlanarSurface(const Handle(Geom_Surface)& S, break; } - default : + default : { Standard_Integer NbU,NbV, ii, jj, kk; NbU = 8 + 3*AS.NbUIntervals(GeomAbs_CN); diff --git a/src/QABugs/QABugs_20.cxx b/src/QABugs/QABugs_20.cxx index 8a5443f139..b055b1a57d 100644 --- a/src/QABugs/QABugs_20.cxx +++ b/src/QABugs/QABugs_20.cxx @@ -4359,6 +4359,120 @@ static Standard_Integer QACheckBends(Draw_Interpretor& theDI, return 0; } +static Standard_Integer OCC26441(Draw_Interpretor& theDi, Standard_Integer theNbArgs, const char** theArgVec) +{ + if (theNbArgs < 3) + { + theDi << "Syntax error: wrong number of arguments!\n"; + return 1; + } + + const TopoDS_Shape& aShape = DBRep::Get(theArgVec[1]); + if (aShape.IsNull()) + { + theDi << " Null Shape is not allowed here\n"; + return 1; + } + const TopoDS_Shape& aRefShape = DBRep::Get(theArgVec[2]); + if (aRefShape.IsNull()) + { + theDi << " Null Shape is not allowed here\n"; + return 1; + } + if(aShape.ShapeType() != aRefShape.ShapeType()) + { + theDi << " Shape types are not the same\n"; + return 1; + } + + Standard_Real anEps = Precision::Confusion(); + if (theNbArgs > 3) + { + anEps = Draw::Atof(theArgVec[3]); + } + + Standard_Boolean isAllDiff = Standard_False; + if (theNbArgs > 4) + { + Standard_Integer Inc = Draw::Atoi(theArgVec[4]); + if (Inc > 0) + isAllDiff = Standard_True; + } + + BRep_Builder aBB; + TopExp_Explorer anExp, anExpRef; + Standard_Real aMaxE = 0., aMaxV = 0.; + TopTools_MapOfShape aChecked; + TopoDS_Vertex aV[2], aRefV[2]; + + //Checking edge and vertex tolerances + TopoDS_Compound aBadEdges; + aBB.MakeCompound(aBadEdges); + TopoDS_Compound aBadVerts; + aBB.MakeCompound(aBadVerts); + anExp.Init(aShape, TopAbs_EDGE); + anExpRef.Init(aRefShape, TopAbs_EDGE); + for (; anExpRef.More(); anExpRef.Next()) + { + const TopoDS_Edge& aRefE = TopoDS::Edge(anExpRef.Current()); + if (!anExp.More()) + { + theDi << " Different number of edges\n"; + return 1; + } + const TopoDS_Edge& anE = TopoDS::Edge(anExp.Current()); + if (!aChecked.Add(anE)) + continue; + Standard_Real aTolRef = BRep_Tool::Tolerance(aRefE); + Standard_Real aTol = BRep_Tool::Tolerance(anE); + Standard_Real aDiff = aTol - aTolRef; + if (isAllDiff && aDiff < 0) + aDiff = -aDiff; + if (aDiff > anEps) + { + if (aDiff > aMaxE) + aMaxE = aDiff; + + aBB.Add(aBadEdges, anE); + } + TopExp::Vertices(aRefE, aRefV[0], aRefV[1]); + TopExp::Vertices(anE, aV[0], aV[1]); + + for (int i = 0; i < 2; ++i) + { + if (aRefV[i].IsNull()) + continue; + if (!aChecked.Add(aV[i])) + continue; + aTolRef = BRep_Tool::Tolerance(aRefV[i]); + aTol = BRep_Tool::Tolerance(aV[i]); + aDiff = aTol - aTolRef; + if (aDiff > anEps) + { + if (aDiff > aMaxV) + aMaxV = aDiff; + + aBB.Add(aBadVerts, aV[i]); + } + } + + anExp.Next(); + + } + + if (aMaxE > anEps) + { + theDi << " Maximal difference for edges : " << aMaxE << "\n"; + DBRep::Set("BadEdges", aBadEdges); + } + if (aMaxV > anEps) + { + theDi << " Maximal difference for vertices : " << aMaxV << "\n"; + DBRep::Set("BadVerts", aBadVerts); + } + + return 0; +} void QABugs::Commands_20(Draw_Interpretor& theCommands) { @@ -4466,6 +4580,10 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) { "QACheckBends curve [CosMaxAngle [theNbPoints]]", __FILE__, QACheckBends, group); + theCommands.Add("OCC26441", + "OCC26441 shape ref_shape [tol [all_diff 0/1]] \nif all_diff = 0, only icreasing tolerances is considered" , + __FILE__, + OCC26441, group); return; } diff --git a/src/STEPCAFControl/STEPCAFControl_Reader.cxx b/src/STEPCAFControl/STEPCAFControl_Reader.cxx index 6c2ccfa8b4..a211ebbb94 100644 --- a/src/STEPCAFControl/STEPCAFControl_Reader.cxx +++ b/src/STEPCAFControl/STEPCAFControl_Reader.cxx @@ -221,6 +221,10 @@ #include #include #include +#include +#include +#include +#include #include #include @@ -937,6 +941,306 @@ static void propagateColorToParts(const Handle(XCAFDoc_ShapeTool)& theSTool, propagateColorToParts(theSTool, theCTool, anOriginalL); } } + +//======================================================================= +//function : SetAssemblyComponentStyle +//purpose : auxiliary: set override style for assembly components +//======================================================================= + +static void SetAssemblyComponentStyle(const Handle(Transfer_TransientProcess) &theTP, + const Handle(XCAFDoc_ColorTool)& theCTool, + const STEPConstruct_Styles& theStyles, + const Handle(StepVisual_ContextDependentOverRidingStyledItem)& theStyle) +{ + if (theStyle.IsNull()) return; + + Handle(StepVisual_Colour) aSurfCol, aBoundCol, aCurveCol, aRenderCol; + Standard_Real aRenderTransp; + // check if it is component style + Standard_Boolean anIsComponent = Standard_False; + if (!theStyles.GetColors(theStyle, aSurfCol, aBoundCol, aCurveCol, aRenderCol, aRenderTransp, anIsComponent)) + return; + + const Interface_Graph& aGraph = theTP->Graph(); + TopLoc_Location aLoc; // init; + // find shape + TopoDS_Shape aShape; + Handle(Transfer_Binder) aBinder; + Handle(StepShape_ShapeRepresentation) aRepr = Handle(StepShape_ShapeRepresentation)::DownCast(theStyle->ItemAP242 ().Value ()); + if (aRepr.IsNull()) + return; + Handle(StepRepr_ShapeRepresentationRelationship) aSRR; + Interface_EntityIterator aSubs = theTP->Graph().Sharings(aRepr); + for (aSubs.Start(); aSubs.More(); aSubs.Next()) { + const Handle(Standard_Transient)& aSubsVal = aSubs.Value(); + if (aSubsVal->IsKind (STANDARD_TYPE(StepRepr_ShapeRepresentationRelationship))) + { + // NB: C cast is used instead of DownCast() to improve performance on some cases. + // This saves ~10% of elapsed time on "testgrid perf de bug29* -parallel 0". + aSRR = (StepRepr_ShapeRepresentationRelationship*)(aSubsVal.get()); + } + } + + aBinder = theTP->Find(aSRR); + if (!aBinder.IsNull() ) { + aShape = TransferBRep::ShapeResult (aBinder); + } + if (aShape.IsNull()) + return; + + //get transformation + aSubs = aGraph.Shareds (theStyle); + aSubs.Start(); + for(; aSubs.More(); aSubs.Next()) + { + Handle(StepRepr_ShapeRepresentationRelationshipWithTransformation) aRelation = Handle(StepRepr_ShapeRepresentationRelationshipWithTransformation)::DownCast (aSubs.Value ()); + if(aRelation.IsNull()) continue; + + auto aTransf = aRelation->TransformationOperator (); + if(auto anItemTransf = aTransf.ItemDefinedTransformation ()) + { + Handle(StepGeom_Axis2Placement3d) anAxp1 = Handle(StepGeom_Axis2Placement3d)::DownCast(anItemTransf->TransformItem1 ()); + Handle(StepGeom_Axis2Placement3d) anAxp2 = Handle(StepGeom_Axis2Placement3d)::DownCast(anItemTransf->TransformItem2 ()); + + if(!anAxp1.IsNull() && !anAxp2.IsNull()) + { + Handle(Geom_Axis2Placement) anOrig = StepToGeom::MakeAxis2Placement (anAxp1); + Handle(Geom_Axis2Placement) aTarg = StepToGeom::MakeAxis2Placement (anAxp2); + gp_Ax3 anAx3Orig(anOrig->Ax2()); + gp_Ax3 anAx3Targ(aTarg->Ax2()); + + gp_Trsf aTr1; + aTr1.SetTransformation(anAx3Targ, anAx3Orig); + TopLoc_Location aLoc1 (aTr1); + aLoc = aLoc.Multiplied(aLoc1); + } + } + } + + aShape.Location( aLoc, Standard_False ); + + if(!aSurfCol.IsNull() || !aBoundCol.IsNull() || !aCurveCol.IsNull() || !aRenderCol.IsNull()) + { + Quantity_Color aSCol,aBCol,aCCol,aRCol; + Quantity_ColorRGBA aFullSCol; + if(!aSurfCol.IsNull()) { + theStyles.DecodeColor(aSurfCol,aSCol); + aFullSCol = Quantity_ColorRGBA(aSCol); + } + if(!aBoundCol.IsNull()) + theStyles.DecodeColor(aBoundCol,aBCol); + if(!aCurveCol.IsNull()) + theStyles.DecodeColor(aCurveCol,aCCol); + if(!aRenderCol.IsNull()) { + theStyles.DecodeColor(aRenderCol,aRCol); + aFullSCol = Quantity_ColorRGBA(aRCol,static_cast(1.0f - aRenderTransp)); + } + + if(!aSurfCol.IsNull() || !aRenderCol.IsNull()) + theCTool->SetInstanceColor(aShape,XCAFDoc_ColorSurf,aFullSCol); + if(!aBoundCol.IsNull()) + theCTool->SetInstanceColor(aShape,XCAFDoc_ColorCurv,aBCol); + if(!aCurveCol.IsNull()) + theCTool->SetInstanceColor(aShape,XCAFDoc_ColorCurv,aCCol); + } +} + +//======================================================================= +//function : SetStyle +//purpose : auxiliary: set style for parts and instances +//======================================================================= + +static void SetStyle(const Handle(XSControl_WorkSession) &theWS, + const XCAFDoc_DataMapOfShapeLabel& theMap, + const Handle(XCAFDoc_ColorTool)& theCTool, + const Handle(XCAFDoc_ShapeTool)& theSTool, + const STEPConstruct_Styles& theStyles, + const Handle(TColStd_HSequenceOfTransient)& theHSeqOfInvisStyle, + const Handle(StepVisual_StyledItem)& theStyle) +{ + if (theStyle.IsNull()) return; + + const Handle(Transfer_TransientProcess) &aTP = theWS->TransferReader()->TransientProcess(); + if (Handle(StepVisual_OverRidingStyledItem) anOverridingStyle = Handle(StepVisual_OverRidingStyledItem)::DownCast (theStyle)) + { + SetStyle (theWS, theMap, theCTool, theSTool, theStyles, theHSeqOfInvisStyle, anOverridingStyle->OverRiddenStyle ()); + if (Handle(StepVisual_ContextDependentOverRidingStyledItem) anAssemblyComponentStyle = Handle(StepVisual_ContextDependentOverRidingStyledItem)::DownCast (theStyle)) + { + SetAssemblyComponentStyle (aTP, theCTool, theStyles,anAssemblyComponentStyle); + return; + } + } + + Standard_Boolean anIsVisible = Standard_True; + // check the visibility of styled item. + for (Standard_Integer si = 1; si <= theHSeqOfInvisStyle->Length(); si++) { + if (theStyle != theHSeqOfInvisStyle->Value(si)) + continue; + // found that current style is invisible. + anIsVisible = Standard_False; + break; + } + Handle(StepVisual_Colour) aSurfCol, aBoundCol, aCurveCol, aRenderCol; + Standard_Real aRenderTransp; + // check if it is component style + Standard_Boolean anIsComponent = Standard_False; + if (!theStyles.GetColors(theStyle, aSurfCol, aBoundCol, aCurveCol, aRenderCol, aRenderTransp, anIsComponent) && anIsVisible) + return; + + // collect styled items + NCollection_Vector anItems; + if (!theStyle->ItemAP242().IsNull()) { + anItems.Append(theStyle->ItemAP242()); + } + + for (Standard_Integer itemIt = 0; itemIt < anItems.Length(); itemIt++) { + Standard_Integer anIndex = aTP->MapIndex(anItems.Value(itemIt).Value()); + TopoDS_Shape aS; + if (anIndex > 0) { + Handle(Transfer_Binder) aBinder = aTP->MapItem(anIndex); + aS = TransferBRep::ShapeResult(aBinder); + } + Standard_Boolean isSkipSHUOstyle = Standard_False; + // take shape with real location. + while (anIsComponent) { + // take SR of NAUO + Handle(StepShape_ShapeRepresentation) aSR; + findStyledSR(theStyle, aSR); + // search for SR along model + if (aSR.IsNull()) + break; + Interface_EntityIterator aSubs = theWS->HGraph()->Graph().Sharings(aSR); + Handle(StepShape_ShapeDefinitionRepresentation) aSDR; + for (aSubs.Start(); aSubs.More(); aSubs.Next()) { + aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(aSubs.Value()); + if (aSDR.IsNull()) + continue; + StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition(); + Handle(StepRepr_ProductDefinitionShape) PDS = + Handle(StepRepr_ProductDefinitionShape)::DownCast(aPDSselect.PropertyDefinition()); + if (PDS.IsNull()) + continue; + StepRepr_CharacterizedDefinition aCharDef = PDS->Definition(); + + Handle(StepRepr_AssemblyComponentUsage) ACU = + Handle(StepRepr_AssemblyComponentUsage)::DownCast(aCharDef.ProductDefinitionRelationship()); + if (ACU.IsNull()) + continue; + // PTV 10.02.2003 skip styled item that refer to SHUO + if (ACU->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) { + isSkipSHUOstyle = Standard_True; + break; + } + Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO = + Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(ACU); + if (NAUO.IsNull()) + continue; + + TopoDS_Shape aSh; + // PTV 10.02.2003 to find component of assembly CORRECTLY + STEPConstruct_Tool aTool(theWS); + TDF_Label aShLab = STEPCAFControl_Reader::FindInstance(NAUO, theCTool->ShapeTool(), aTool, theMap); + aSh = theCTool->ShapeTool()->GetShape(aShLab); + if (!aSh.IsNull()) { + aS = aSh; + break; + } + } + break; + } + if (isSkipSHUOstyle) + continue; // skip styled item which refer to SHUO + + if (aS.IsNull()) + continue; + + if (!aSurfCol.IsNull() || !aBoundCol.IsNull() || !aCurveCol.IsNull() || !aRenderCol.IsNull() || !anIsVisible) + { + TDF_Label aL; + Standard_Boolean isFound = theSTool->SearchUsingMap(aS, aL, Standard_False, Standard_True); + if (!aSurfCol.IsNull() || !aBoundCol.IsNull() || !aCurveCol.IsNull() || !aRenderCol.IsNull()) + { + Quantity_Color aSCol, aBCol, aCCol, aRCol; + Quantity_ColorRGBA aFullSCol; + if (!aSurfCol.IsNull()) { + theStyles.DecodeColor(aSurfCol, aSCol); + aFullSCol = Quantity_ColorRGBA(aSCol); + } + if (!aBoundCol.IsNull()) + theStyles.DecodeColor(aBoundCol, aBCol); + if (!aCurveCol.IsNull()) + theStyles.DecodeColor(aCurveCol, aCCol); + if (!aRenderCol.IsNull()) { + theStyles.DecodeColor(aRenderCol, aRCol); + aFullSCol = Quantity_ColorRGBA(aRCol, static_cast(1.0f - aRenderTransp)); + } + if (isFound) + { + if (!aSurfCol.IsNull() || !aRenderCol.IsNull()) + theCTool->SetColor(aL, aFullSCol, XCAFDoc_ColorSurf); + if (!aBoundCol.IsNull()) + theCTool->SetColor(aL, aBCol, XCAFDoc_ColorCurv); + if (!aCurveCol.IsNull()) + theCTool->SetColor(aL, aCCol, XCAFDoc_ColorCurv); + } + else + { + for (TopoDS_Iterator it(aS); it.More(); it.Next()) + { + TDF_Label aL1; + if (theSTool->SearchUsingMap(it.Value(), aL1, Standard_False, Standard_True)) + { + if (!aSurfCol.IsNull() || !aRenderCol.IsNull()) + theCTool->SetColor(aL1, aFullSCol, XCAFDoc_ColorSurf); + if (!aBoundCol.IsNull()) + theCTool->SetColor(aL1, aBCol, XCAFDoc_ColorCurv); + if (!aCurveCol.IsNull()) + theCTool->SetColor(aL1, aCCol, XCAFDoc_ColorCurv); + } + } + } + } + if (!anIsVisible) + { + // sets the invisibility for shape. + if (isFound) + theCTool->SetVisibility(aL, Standard_False); + } + } + } +} + +//======================================================================= +//function : IsOverriden +//purpose : auxiliary: check that style is overridden +//======================================================================= + +static Standard_Boolean IsOverriden(const Interface_Graph& theGraph, + const Handle(StepVisual_StyledItem)& theStyle, + Standard_Boolean theIsRoot) +{ + Interface_EntityIterator aSubs = theGraph.Sharings (theStyle); + aSubs.Start(); + for(; aSubs.More(); aSubs.Next()) + { + Handle(StepVisual_OverRidingStyledItem) anOverRidingStyle = Handle(StepVisual_OverRidingStyledItem)::DownCast (aSubs.Value ()); + if(!anOverRidingStyle.IsNull()) + { + if(!theIsRoot) + { + return Standard_True; + } + // for root style returns true only if it is overridden by other root style + auto anItem = anOverRidingStyle->ItemAP242 ().Value (); + if(!anItem.IsNull() && anItem->IsKind(STANDARD_TYPE(StepShape_ShapeRepresentation))) + { + return Standard_True; + } + } + } + return Standard_False; +} + //======================================================================= //function : ReadColors //purpose : @@ -961,152 +1265,36 @@ Standard_Boolean STEPCAFControl_Reader::ReadColors(const Handle(XSControl_WorkSe Handle(XCAFDoc_ShapeTool) STool = XCAFDoc_DocumentTool::ShapeTool(Doc->Main()); if (STool.IsNull()) return Standard_False; + const Interface_Graph& aGraph = Styles.Graph (); + // parse and search for color attributes - Standard_Integer nb = Styles.NbStyles(); - for (Standard_Integer i = 1; i <= nb; i++) { - Handle(StepVisual_StyledItem) style = Styles.Style(i); - if (style.IsNull()) continue; - - Standard_Boolean IsVisible = Standard_True; - // check the visibility of styled item. - for (Standard_Integer si = 1; si <= aHSeqOfInvisStyle->Length(); si++) { - if (style != aHSeqOfInvisStyle->Value(si)) - continue; - // found that current style is invisible. - IsVisible = Standard_False; - break; - } - - Handle(StepVisual_Colour) SurfCol, BoundCol, CurveCol, RenderCol; - Standard_Real RenderTransp; - // check if it is component style - Standard_Boolean IsComponent = Standard_False; - if (!Styles.GetColors(style, SurfCol, BoundCol, CurveCol, RenderCol, RenderTransp, IsComponent) && IsVisible) - continue; - - // collect styled items - NCollection_Vector anItems; - if (!style->ItemAP242().IsNull()) { - anItems.Append(style->ItemAP242()); - } - - const Handle(Transfer_TransientProcess) &TP = WS->TransferReader()->TransientProcess(); - for (Standard_Integer itemIt = 0; itemIt < anItems.Length(); itemIt++) { - Standard_Integer index = TP->MapIndex(anItems.Value(itemIt).Value()); - TopoDS_Shape S; - if (index > 0) { - Handle(Transfer_Binder) binder = TP->MapItem(index); - S = TransferBRep::ShapeResult(binder); - } - Standard_Boolean isSkipSHUOstyle = Standard_False; - // take shape with real location. - while (IsComponent) { - // take SR of NAUO - Handle(StepShape_ShapeRepresentation) aSR; - findStyledSR(style, aSR); - // search for SR along model - if (aSR.IsNull()) - break; - Interface_EntityIterator subs = WS->HGraph()->Graph().Sharings(aSR); - Handle(StepShape_ShapeDefinitionRepresentation) aSDR; - for (subs.Start(); subs.More(); subs.Next()) { - aSDR = Handle(StepShape_ShapeDefinitionRepresentation)::DownCast(subs.Value()); - if (aSDR.IsNull()) - continue; - StepRepr_RepresentedDefinition aPDSselect = aSDR->Definition(); - Handle(StepRepr_ProductDefinitionShape) PDS = - Handle(StepRepr_ProductDefinitionShape)::DownCast(aPDSselect.PropertyDefinition()); - if (PDS.IsNull()) - continue; - StepRepr_CharacterizedDefinition aCharDef = PDS->Definition(); - - Handle(StepRepr_AssemblyComponentUsage) ACU = - Handle(StepRepr_AssemblyComponentUsage)::DownCast(aCharDef.ProductDefinitionRelationship()); - if (ACU.IsNull()) - continue; - // PTV 10.02.2003 skip styled item that refer to SHUO - if (ACU->IsKind(STANDARD_TYPE(StepRepr_SpecifiedHigherUsageOccurrence))) { - isSkipSHUOstyle = Standard_True; - break; - } - Handle(StepRepr_NextAssemblyUsageOccurrence) NAUO = - Handle(StepRepr_NextAssemblyUsageOccurrence)::DownCast(ACU); - if (NAUO.IsNull()) - continue; - - TopoDS_Shape aSh; - // PTV 10.02.2003 to find component of assembly CORRECTLY - STEPConstruct_Tool Tool(WS); - TDF_Label aShLab = FindInstance(NAUO, CTool->ShapeTool(), Tool, myMap); - aSh = CTool->ShapeTool()->GetShape(aShLab); - if (!aSh.IsNull()) { - S = aSh; - break; - } - } - break; - } - if (isSkipSHUOstyle) - continue; // skip styled item which refer to SHUO - - if (S.IsNull()) - continue; - - if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull() || !RenderCol.IsNull() || !IsVisible) - { - TDF_Label aL; - Standard_Boolean isFound = STool->SearchUsingMap(S, aL, Standard_False, Standard_True); - if (!SurfCol.IsNull() || !BoundCol.IsNull() || !CurveCol.IsNull() || !RenderCol.IsNull()) - { - Quantity_Color aSCol, aBCol, aCCol, aRCol; - Quantity_ColorRGBA aFullSCol; - if (!SurfCol.IsNull()) { - Styles.DecodeColor(SurfCol, aSCol); - aFullSCol = Quantity_ColorRGBA(aSCol); - } - if (!BoundCol.IsNull()) - Styles.DecodeColor(BoundCol, aBCol); - if (!CurveCol.IsNull()) - Styles.DecodeColor(CurveCol, aCCol); - if (!RenderCol.IsNull()) { - Styles.DecodeColor(RenderCol, aRCol); - aFullSCol = Quantity_ColorRGBA(aRCol, static_cast(1.0f - RenderTransp)); - } - if (isFound) - { - if (!SurfCol.IsNull() || !RenderCol.IsNull()) - CTool->SetColor(aL, aFullSCol, XCAFDoc_ColorSurf); - if (!BoundCol.IsNull()) - CTool->SetColor(aL, aBCol, XCAFDoc_ColorCurv); - if (!CurveCol.IsNull()) - CTool->SetColor(aL, aCCol, XCAFDoc_ColorCurv); - } - else - { - for (TopoDS_Iterator it(S); it.More(); it.Next()) - { - TDF_Label aL1; - if (STool->SearchUsingMap(it.Value(), aL1, Standard_False, Standard_True)) - { - if (!SurfCol.IsNull() || !RenderCol.IsNull()) - CTool->SetColor(aL1, aFullSCol, XCAFDoc_ColorSurf); - if (!BoundCol.IsNull()) - CTool->SetColor(aL1, aBCol, XCAFDoc_ColorCurv); - if (!CurveCol.IsNull()) - CTool->SetColor(aL1, aCCol, XCAFDoc_ColorCurv); - } - } - } - } - if (!IsVisible) - { - // sets the invisibility for shape. - if (isFound) - CTool->SetVisibility(aL, Standard_False); - } - } + Standard_Integer nb = Styles.NbRootStyles(); + // apply root styles earlier, as they can be overridden + // function IsOverriden for root style returns true only if it is overridden by other root style + Standard_Boolean anIsRootStyle = Standard_True; + for(Standard_Integer i = 1; i <= nb; i++) + { + Handle(StepVisual_StyledItem) Style = Styles.RootStyle(i); + // check that style is overridden by other root style + if (!IsOverriden (aGraph, Style, anIsRootStyle)) + { + SetStyle (WS, myMap, CTool, STool, Styles, aHSeqOfInvisStyle, Style); } } + + nb = Styles.NbStyles(); + // apply leaf styles, they can override root styles + anIsRootStyle = Standard_False; + for(Standard_Integer i = 1; i <= nb; i++) + { + Handle(StepVisual_StyledItem) Style = Styles.Style(i); + // check that style is overridden + if (!IsOverriden (aGraph, Style, anIsRootStyle)) + { + SetStyle (WS, myMap, CTool, STool, Styles, aHSeqOfInvisStyle, Style); + } + } + CTool->ReverseChainsOfTreeNodes(); // some colors can be attached to assemblies, propagate them to components diff --git a/src/STEPConstruct/STEPConstruct_Styles.cxx b/src/STEPConstruct/STEPConstruct_Styles.cxx index 71caf4ca0c..09c0efcabb 100644 --- a/src/STEPConstruct/STEPConstruct_Styles.cxx +++ b/src/STEPConstruct/STEPConstruct_Styles.cxx @@ -68,6 +68,8 @@ #include #include #include +#include +#include //======================================================================= //function : STEPConstruct_Styles @@ -124,6 +126,26 @@ Handle(StepVisual_StyledItem) STEPConstruct_Styles::Style (const Standard_Intege return Handle(StepVisual_StyledItem)::DownCast ( myStyles.FindKey(i) ); } +//======================================================================= +//function : NbRootStyles +//purpose : +//======================================================================= + +Standard_Integer STEPConstruct_Styles::NbRootStyles () const +{ + return myRootStyles.Extent(); +} + +//======================================================================= +//function : RootStyle +//purpose : +//======================================================================= + +Handle(StepVisual_StyledItem) STEPConstruct_Styles::RootStyle (const Standard_Integer i) const +{ + return Handle(StepVisual_StyledItem)::DownCast ( myRootStyles.FindKey(i) ); +} + //======================================================================= //function : ClearStyles @@ -134,6 +156,7 @@ void STEPConstruct_Styles::ClearStyles () { myStyles.Clear(); myPSA.Clear(); + myRootStyles.Clear(); } @@ -344,13 +367,15 @@ Standard_Boolean STEPConstruct_Styles::LoadStyles () { myStyles.Clear(); myPSA.Clear(); - + myRootStyles.Clear(); + // find all MDGPRs and DMs and collect all defined styles in myStyles Handle(Interface_InterfaceModel) model = Model(); Standard_Integer nb = model->NbEntities(); Handle(Standard_Type) tMDGPR = STANDARD_TYPE(StepVisual_MechanicalDesignGeometricPresentationRepresentation); Handle(Standard_Type) tDM = STANDARD_TYPE(StepVisual_DraughtingModel); Handle(Standard_Type) tSI = STANDARD_TYPE(StepVisual_StyledItem); + Handle(Standard_Type) tSR = STANDARD_TYPE(StepShape_ShapeRepresentation); for (Standard_Integer i = 1; i <= nb; i ++) { Handle(Standard_Transient) enti = model->Value(i); @@ -364,13 +389,26 @@ Standard_Boolean STEPConstruct_Styles::LoadStyles () Handle(StepVisual_StyledItem) style = Handle(StepVisual_StyledItem)::DownCast ( container->ItemsValue(j) ); if ( style.IsNull() ) continue; - myStyles.Add ( style ); + auto anItem = style->ItemAP242 ().Value (); + if (!anItem.IsNull() && anItem->IsKind(tSR)) + { + myRootStyles.Add (style); + } + else + { + myStyles.Add (style); + } } } - else if (enti->DynamicType() == tSI) + else if (enti->IsKind (STANDARD_TYPE(StepVisual_StyledItem))) { Handle(StepVisual_StyledItem) aStyledItem = Handle(StepVisual_StyledItem)::DownCast (enti); - if (!myStyles.Contains (aStyledItem)) + auto anItem = aStyledItem->ItemAP242 ().Value (); + if (!anItem.IsNull() && anItem->IsKind(tSR) && !myRootStyles.Contains (aStyledItem)) + { + myRootStyles.Add (aStyledItem); + } + else if (!myStyles.Contains (aStyledItem)) { myStyles.Add (aStyledItem); } diff --git a/src/STEPConstruct/STEPConstruct_Styles.hxx b/src/STEPConstruct/STEPConstruct_Styles.hxx index 722561d51f..5fc2cd6c86 100644 --- a/src/STEPConstruct/STEPConstruct_Styles.hxx +++ b/src/STEPConstruct/STEPConstruct_Styles.hxx @@ -69,6 +69,12 @@ public: //! Returns style with given index Standard_EXPORT Handle(StepVisual_StyledItem) Style (const Standard_Integer i) const; + + //! Returns number of override styles + Standard_EXPORT Standard_Integer NbRootStyles() const; + + //! Returns override style with given index + Standard_EXPORT Handle(StepVisual_StyledItem) RootStyle (const Standard_Integer i) const; //! Clears all defined styles and PSA sequence Standard_EXPORT void ClearStyles(); @@ -159,6 +165,7 @@ private: TColStd_IndexedDataMapOfTransientTransient myMapOfStyles; TColStd_IndexedMapOfTransient myStyles; + TColStd_IndexedMapOfTransient myRootStyles; TColStd_SequenceOfTransient myPSA; diff --git a/src/STEPControl/STEPControl_Controller.cxx b/src/STEPControl/STEPControl_Controller.cxx index 1970fff87a..bdb17f8f88 100644 --- a/src/STEPControl/STEPControl_Controller.cxx +++ b/src/STEPControl/STEPControl_Controller.cxx @@ -239,6 +239,7 @@ STEPControl_Controller::STEPControl_Controller () Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixNonAdjacentIntersectingEdgesMode", 't', "-1"); Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixVertexPositionMode", 't', "0"); Interface_Static::Init ("XSTEP", "FromSTEP.FixShape.FixVertexToleranceMode", 't', "-1"); + Interface_Static::Init ("XSTEP", "FromSTEP.FixFaceSize.Tolerance", 't', "1.e-7"); // ika 28.07.16: Parameter to read all top level solids and shells, // should be used only in case of invalid shape_representation without links to shapes. diff --git a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx index fe63901416..7d603b2dae 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx +++ b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.cxx @@ -753,7 +753,25 @@ static void ReconstructMissedSeam(const TopTools_SequenceOfShape& theRemovedEdge if ((theUperiod != 0. && aUdiff > theUperiod/2) || (theVperiod != 0. && aVdiff > theVperiod/2)) { - anEdge.Reverse(); + if (aLastVertex.IsSame(theCurVertex) || (theUperiod != 0. && theVperiod != 0.)) + { + anEdge.Reverse(); + } + else + { + TopAbs_Orientation anOri = anEdge.Orientation(); + anEdge.Orientation(TopAbs_FORWARD); + Handle(Geom2d_Curve) aPC1 = BRep_Tool::CurveOnSurface(anEdge, theFrefFace, Param1, Param2); + anEdge.Reverse(); + Handle(Geom2d_Curve) aPC2 = BRep_Tool::CurveOnSurface(anEdge, theFrefFace, Param1, Param2); + anEdge.Reverse(); // again FORWARD + TopLoc_Location aLoc; + BRep_Builder aBB; + Standard_Real aTol = BRep_Tool::Tolerance(anEdge); + const Handle(Geom_Surface)& aSurf = BRep_Tool::Surface(theFrefFace, aLoc); + aBB.UpdateEdge(anEdge, aPC2, aPC1, aSurf, aLoc, aTol); + anEdge.Orientation(anOri); + } aPC = BRep_Tool::CurveOnSurface(anEdge, theFrefFace, Param1, Param2); aParam = (anEdge.Orientation() == TopAbs_FORWARD)? Param1 : Param2; aPoint = aPC->Value(aParam); @@ -2745,6 +2763,26 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() for (Standard_Integer i = 1; i <= aFaceMap.Extent(); i++) TopExp::MapShapesAndAncestors (aFaceMap(i), TopAbs_EDGE, TopAbs_FACE, aGMapEdgeFaces); + // creating map of face shells for the whole shape to avoid + // unification of faces belonging to the different shells + DataMapOfShapeMapOfShape aGMapFaceShells; + for (TopExp_Explorer anExp (myShape, TopAbs_SHELL); anExp.More(); anExp.Next()) + { + const TopoDS_Shape& aShell = anExp.Current(); + for (TopoDS_Iterator anItF (aShell); anItF.More(); anItF.Next()) + { + const TopoDS_Shape& aF = anItF.Value(); + if (TopTools_MapOfShape* pShells = aGMapFaceShells.ChangeSeek (aF)) + { + pShells->Add (aShell); + } + else + { + (aGMapFaceShells.Bound (aF, TopTools_MapOfShape()))->Add (aShell); + } + } + } + // creating map of free boundaries TopTools_MapOfShape aFreeBoundMap; // look at only shells not belonging to solids @@ -2766,7 +2804,7 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() // unify faces in each shell separately TopExp_Explorer exps; for (exps.Init(myShape, TopAbs_SHELL); exps.More(); exps.Next()) - IntUnifyFaces(exps.Current(), aGMapEdgeFaces, aFreeBoundMap); + IntUnifyFaces(exps.Current(), aGMapEdgeFaces, aGMapFaceShells, aFreeBoundMap); // gather all faces out of shells in one compound and unify them at once BRep_Builder aBB; @@ -2777,7 +2815,10 @@ void ShapeUpgrade_UnifySameDomain::UnifyFaces() aBB.Add(aCmp, exps.Current()); if (nbf > 0) - IntUnifyFaces(aCmp, aGMapEdgeFaces, aFreeBoundMap); + { + // No connection to shells, thus no need to pass the face-shell map + IntUnifyFaces(aCmp, aGMapEdgeFaces, DataMapOfShapeMapOfShape(), aFreeBoundMap); + } myShape = myContext->Apply(myShape); } @@ -2800,13 +2841,52 @@ static void SetFixWireModes(ShapeFix_Face& theSff) aFixWire->FixSmallMode() = 0; } +//======================================================================= +//function : isSameSets +//purpose : Compares two sets of shapes. Returns true if they are the same, +// false otherwise. +//======================================================================= + +template +static Standard_Boolean isSameSets(const Container* theFShells1, + const Container* theFShells2) +{ + // If both are null - no problem + if (theFShells1 == nullptr && theFShells2 == nullptr) + { + return Standard_True; + } + // If only one is null - not the same + if (theFShells1 == nullptr || theFShells2 == nullptr) + { + return Standard_False; + } + // Both not null + if (theFShells1->Extent() != theFShells2->Extent()) + { + return Standard_False; + } + // number of shells in each set should be very small in normal cases - max 2. + // thus just check if all objects of one are contained in the other and vice versa. + for (typename Container::Iterator it1(*theFShells1), it2(*theFShells2); + it1.More() && it2.More(); it1.Next(), it2.Next()) + { + if (!theFShells1->Contains(it2.Value()) || !theFShells2->Contains(it1.Value())) + { + return Standard_False; + } + } + return Standard_True; +} + //======================================================================= //function : IntUnifyFaces //purpose : //======================================================================= void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape, - TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces, + const TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces, + const DataMapOfShapeMapOfShape& theGMapFaceShells, const TopTools_MapOfShape& theFreeBoundMap) { // creating map of edge faces for the shape @@ -2855,6 +2935,9 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape Standard_Real Uperiod = (aBaseSurface->IsUPeriodic())? aBaseSurface->UPeriod() : 0.; Standard_Real Vperiod = (aBaseSurface->IsVPeriodic())? aBaseSurface->VPeriod() : 0.; + // Get shells connected to the face (in normal cases should not be more than 2) + const TopTools_MapOfShape* pFShells1 = theGMapFaceShells.Seek (aFace); + // find adjacent faces to union Standard_Integer i; for (i = 1; i <= edges.Length(); i++) { @@ -2903,6 +2986,15 @@ void ShapeUpgrade_UnifySameDomain::IntUnifyFaces(const TopoDS_Shape& theInpShape if (aProcessed.Contains(aCheckedFace)) continue; + // Get shells connected to the checked face + const TopTools_MapOfShape* pFShells2 = theGMapFaceShells.Seek (aCheckedFace); + // Faces can be unified only if the shells of faces connected to + // these faces are the same. Otherwise, topology would be broken. + if (!isSameSets (pFShells1, pFShells2)) + { + continue; + } + if (bCheckNormals) { // get normal of checked face using the same parameter on edge gp_Dir aDN2; diff --git a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.hxx b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.hxx index a068959276..b2567e7d3c 100644 --- a/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.hxx +++ b/src/ShapeUpgrade/ShapeUpgrade_UnifySameDomain.hxx @@ -70,6 +70,7 @@ class ShapeUpgrade_UnifySameDomain : public Standard_Transient public: typedef NCollection_DataMap DataMapOfFacePlane; + typedef NCollection_DataMap DataMapOfShapeMapOfShape; //! Empty constructor Standard_EXPORT ShapeUpgrade_UnifySameDomain(); @@ -168,7 +169,8 @@ protected: Standard_EXPORT void UnifyEdges(); void IntUnifyFaces(const TopoDS_Shape& theInpShape, - TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces, + const TopTools_IndexedDataMapOfShapeListOfShape& theGMapEdgeFaces, + const DataMapOfShapeMapOfShape& theGMapFaceShells, const TopTools_MapOfShape& theFreeBoundMap); //! Splits the sequence of edges into the sequence of chains diff --git a/src/XCAFDoc/XCAFDoc_ShapeTool.cxx b/src/XCAFDoc/XCAFDoc_ShapeTool.cxx index b226c6f133..85e3ecc0e3 100644 --- a/src/XCAFDoc/XCAFDoc_ShapeTool.cxx +++ b/src/XCAFDoc/XCAFDoc_ShapeTool.cxx @@ -48,6 +48,7 @@ #include #include #include +#include IMPLEMENT_DERIVED_ATTRIBUTE_WITH_TYPE(XCAFDoc_ShapeTool,TDataStd_GenericEmpty,"xcaf","ShapeTool") @@ -1602,6 +1603,33 @@ Standard_Boolean XCAFDoc_ShapeTool::RemoveSHUO (const TDF_Label& L) const //purpose : auxiliary //======================================================================= +static Standard_Boolean IsEqual (const TopLoc_Location& theLoc1, const TopLoc_Location& theLoc2) +{ + if (theLoc1.IsEqual (theLoc2)) {return Standard_True; } + if (theLoc1.IsIdentity() || theLoc2.IsIdentity()) {return Standard_False; } + const Handle(TopLoc_Datum3D)& aDatum1 = theLoc1.FirstDatum(); + const Handle(TopLoc_Datum3D)& aDatum2 = theLoc2.FirstDatum(); + if (aDatum1 && aDatum2) + { + NCollection_Mat4 aMat41; + NCollection_Mat4 aMat42; + theLoc1.FirstDatum()->Transformation().GetMat4(aMat41); + theLoc2.FirstDatum()->Transformation().GetMat4(aMat42); + if ( !aMat41.IsEqual (aMat42)) {return Standard_False; } + } + else if (aDatum1 || aDatum2) {return Standard_False; } + if (theLoc1.FirstPower() != theLoc2.FirstPower() ) {return Standard_False; } + else { return IsEqual (theLoc1.NextLocation(), theLoc2.NextLocation());} +} + +static Standard_Boolean IsSame (const TopoDS_Shape& theShape1, const TopoDS_Shape& theShape2) +{ + + return theShape1.TShape() == theShape2.TShape() + && theShape1.Orientation() == theShape2.Orientation() + && IsEqual (theShape1.Location(), theShape2.Location()); +} + static Standard_Boolean checkForShape (const TopoDS_Shape& theShape, const TopoDS_Shape& theCurSh, const TDF_Label& theUserL, @@ -1616,7 +1644,7 @@ static Standard_Boolean checkForShape (const TopoDS_Shape& theShape, aCompLoc = aCompLoc.Multiplied( theCurSh.Location() ); aSupLoc = aSupLoc.Multiplied( aCompLoc ); aCopySh.Location( aSupLoc, Standard_False ); - if ( aCopySh.IsSame( theShape ) ) { + if ( IsSame ( theShape, aCopySh ) ) { theLabels.Prepend( theUserL ); return Standard_True; } diff --git a/tests/boolean/bopfuse_simple/ZP6 b/tests/boolean/bopfuse_simple/ZP6 index f8b2fb8f4e..00cb1a188d 100755 --- a/tests/boolean/bopfuse_simple/ZP6 +++ b/tests/boolean/bopfuse_simple/ZP6 @@ -3,6 +3,8 @@ # #Create 3 torus +puts "TODO CR33225 Linux: Error : The area of result shape is 138625, expected 197700" + ptorus a0 100 20 tcopy a0 a1 tcopy a0 a2 diff --git a/tests/bugs/caf/bug114 b/tests/bugs/caf/bug114 deleted file mode 100755 index fafb52003c..0000000000 --- a/tests/bugs/caf/bug114 +++ /dev/null @@ -1,24 +0,0 @@ -puts "===========" -puts "OCC114" -puts "===========" - -# Max number of iterations for computing memory leackage -set i_max 10 -puts "Amount of iterations is $i_max" - -NewDocument D BinOcaf -UndoLimit D 10 - -restore [locate_data_file OCC294.brep] s - -set listmem {} -for {set i 1} {${i} <= ${i_max}} {incr i} { - - OpenCommand D - SetShape D 0:1 s - AbortCommand D - - # check memory usage (with tolerance equal to half page size) - lappend listmem [meminfo h] - checktrend $listmem 50 50 "Memory leak detected" -} diff --git a/tests/bugs/caf/bug26293_2 b/tests/bugs/caf/bug26293_2 deleted file mode 100644 index d8b8d9d23d..0000000000 --- a/tests/bugs/caf/bug26293_2 +++ /dev/null @@ -1,17 +0,0 @@ -puts "===========" -puts "OCC26293" -puts "===========" -puts "" -################################# -# Error opening the document -################################# - -Open [locate_data_file bug26293_all_geom.sgd] D -vinit -for {set i 1} {$i < 1065} {incr i} { - if { ![catch {GetShape D 0:1:$i:1:1:2 res$i}] } { - vdisplay res$i - } -} -vfit -checkview -screenshot -3d -path ${imagedir}/${test_image}.png \ No newline at end of file diff --git a/tests/bugs/fclasses/bug24831 b/tests/bugs/fclasses/bug24831 index 90d6d8de65..c1269d10b8 100644 --- a/tests/bugs/fclasses/bug24831 +++ b/tests/bugs/fclasses/bug24831 @@ -1,3 +1,5 @@ +puts "TODO ?CR33225 Windows: Failed class " + pload QAcommands QANTestStlIterators diff --git a/tests/bugs/fclasses/bug7287_1 b/tests/bugs/fclasses/bug7287_1 index 9c87d5ee3d..d6f8107bf0 100755 --- a/tests/bugs/fclasses/bug7287_1 +++ b/tests/bugs/fclasses/bug7287_1 @@ -1,3 +1,4 @@ +puts "TODO ?СК33225 Linux: Checking trend failed " puts "TODO ?OCC7287 Linux: Tcl Exception: Memory leak detected" puts "TODO ?OCC7287 Linux: TEST INCOMPLETE" puts "TODO ?OCC7287 MacOS: Tcl Exception: Memory leak detected" diff --git a/tests/bugs/fclasses/bug7287_5 b/tests/bugs/fclasses/bug7287_5 index 929094e2da..7142cffe71 100755 --- a/tests/bugs/fclasses/bug7287_5 +++ b/tests/bugs/fclasses/bug7287_5 @@ -1,3 +1,4 @@ +puts "TODO ?CR332257287 Linux: Checking trend failed: mean delta per step = 9432.0, sigma = 4220.013270121316, expected delta = 0" puts "TODO ?OCC7287 Linux: Tcl Exception: Memory leak detected" puts "TODO ?OCC7287 Linux: TEST INCOMPLETE" puts "TODO ?OCC7287 MacOS: Tcl Exception: Memory leak detected" diff --git a/tests/bugs/fclasses/bug7287_6 b/tests/bugs/fclasses/bug7287_6 index e40799f71e..25588729d3 100755 --- a/tests/bugs/fclasses/bug7287_6 +++ b/tests/bugs/fclasses/bug7287_6 @@ -1,3 +1,4 @@ +puts "TODO ?CR33225 Linux: Checking trend failed: mean delta per step = 7408.0, sigma = 2737.917456754312, expected delta = 0" puts "TODO ?OCC7287 Linux: Tcl Exception: Memory leak detected" puts "TODO ?OCC7287 Linux: TEST INCOMPLETE" puts "TODO ?OCC7287 MacOS: Tcl Exception: Memory leak detected" diff --git a/tests/bugs/heal/bug33171_1 b/tests/bugs/heal/bug33171_1 new file mode 100644 index 0000000000..600d69de96 --- /dev/null +++ b/tests/bugs/heal/bug33171_1 @@ -0,0 +1,71 @@ +puts "========================" +puts " 0033171: Modeling Algorithms - Invalid result of faces unification" +puts "========================" +puts "" + +# make outer prism +polyline p 0 0 0 10 0 0 10 10 0 0 10 0 0 0 0 +mkplane f p +prism s f 0 0 5 + +# make section shells +polyline p1 3 10 0 3 7 0 6 7 0 6 3 0 10 3 0 +polyline p2 6 7 0 10 7 0 +polyline p3 8 7 0 8 10 0 +polyline p4 0 5 0 10 5 0 + +prism sh1 p1 0 0 5 +prism sh2 p2 0 0 5 +prism sh3 p3 0 0 5 +prism sh4 p4 0 0 5 + +# split the prism +bclearobjects +bcleartools +baddobjects s +baddtools sh1 sh2 sh3 sh4 +bfillds +bsplit r + +checkshape r +if {![regexp "This shape seems to be OK" [bopcheck r]]} { + puts "Error: invalid shape after split" +} + +# try to unify faces in the result compound +unifysamedom ru1 r +unifysamedom ru2 r +i + +checkshape ru1 +checkshape ru2 + +checknbshapes ru1 -ref [nbshapes r -t] -t +checknbshapes ru2 -ref [nbshapes r -t] -t + +if {![regexp "This shape seems to be OK" [bopcheck ru1]]} { + puts "Error: invalid shape after faces unification" +} +if {![regexp "This shape seems to be OK" [bopcheck ru2]]} { + puts "Error: invalid shape after faces unification" +} + +# make compound of shells +eval compound [explode r] shs + +unifysamedom shsu1 r +unifysamedom shsu2 r +i + +checkshape shsu1 +checkshape shsu2 + +checknbshapes shsu1 -ref [nbshapes shs -t] -t +checknbshapes shsu2 -ref [nbshapes shs -t] -t + +if {![regexp "This shape seems to be OK" [bopcheck shsu1]]} { + puts "Error: invalid shape after faces unification" +} +if {![regexp "This shape seems to be OK" [bopcheck shsu2]]} { + puts "Error: invalid shape after faces unification" +} + +checkview -display ru2 -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/heal/bug33171_2 b/tests/bugs/heal/bug33171_2 new file mode 100644 index 0000000000..d80bcabdb5 --- /dev/null +++ b/tests/bugs/heal/bug33171_2 @@ -0,0 +1,57 @@ +puts "========================" +puts " 0033171: Modeling Algorithms - Invalid result of faces unification" +puts "========================" +puts "" + +# make two solids +box b1 10 10 5 +box b2 10 0 0 5 5 5 +# make shared +bclearobjects +bcleartools +baddobjects b1 b2 +bfillds +bbuild r + +checkshape r +if {![regexp "This shape seems to be OK" [bopcheck r]]} { + puts "Error: invalid shape after fuse" +} + +# try to unify faces in the result compound +unifysamedom ru1 r +unifysamedom ru2 r +i + +checkshape ru1 +checkshape ru2 + +checknbshapes ru1 -ref [nbshapes r -t] -t +checknbshapes ru2 -ref [nbshapes r -t] -t + +if {![regexp "This shape seems to be OK" [bopcheck ru1]]} { + puts "Error: invalid shape after faces unification" +} +if {![regexp "This shape seems to be OK" [bopcheck ru2]]} { + puts "Error: invalid shape after faces unification" +} + +# make compound of shells +eval compound [explode r] shs + +unifysamedom shsu1 r +unifysamedom shsu2 r +i + +checkshape shsu1 +checkshape shsu2 + +checknbshapes shsu1 -ref [nbshapes shs -t] -t +checknbshapes shsu2 -ref [nbshapes shs -t] -t + +if {![regexp "This shape seems to be OK" [bopcheck shsu1]]} { + puts "Error: invalid shape after faces unification" +} +if {![regexp "This shape seems to be OK" [bopcheck shsu2]]} { + puts "Error: invalid shape after faces unification" +} + +checkview -display ru2 -2d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/heal/bug33193 b/tests/bugs/heal/bug33193 new file mode 100644 index 0000000000..5726245a59 --- /dev/null +++ b/tests/bugs/heal/bug33193 @@ -0,0 +1,19 @@ +puts "=========================================" +puts "0033193: Modeling Algorithms - Regression: UnifySameDomain raises SIGSEGV" +puts "=========================================" +puts "" + +restore [locate_data_file bug33193.brep] a + +unifysamedom result a + +checkshape result + +checknbshapes result -t -solid 1 -shell 1 -face 152 -wire 202 -edge 411 -vertex 273 + +set tolres [checkmaxtol result] + +if { ${tolres} > 1.26e-7} { + puts "Error: bad tolerance of result" +} + diff --git a/tests/bugs/mesh/bug32424 b/tests/bugs/mesh/bug32424 deleted file mode 100644 index deb41d8bfa..0000000000 --- a/tests/bugs/mesh/bug32424 +++ /dev/null @@ -1,18 +0,0 @@ -puts "=======" -puts "0032424: Mesh - Slow triangulation of a simple shape." -puts "=======" -puts "" -cpulimit 3 - -restore [locate_data_file bug32424.brep] result - -incmesh result 0.17 -a 20 - -checktrinfo result -tri 2360 -nod 1302 - -vinit -vdefaults -autoTriang 0 -vsetdispmode 1 -vdisplay result -vfit -checkview -screenshot -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/modalg_1/bug19071 b/tests/bugs/modalg_1/bug19071 index 5bec0ef2b0..8144c621b4 100755 --- a/tests/bugs/modalg_1/bug19071 +++ b/tests/bugs/modalg_1/bug19071 @@ -1,7 +1,12 @@ +puts "TODO CR33225 Linux: Error : The command is not valid. The area is 0." +puts "TODO CR33225 Linux: Error : The area of result shape is 0, expected 177462" +puts "TODO CR33225 Linux: is WRONG because number of " + puts "============" puts "OCC19071" puts "============" puts "" + ####################################################################### # The MakeFuse or the MakePartition function crash together on 2 torus ####################################################################### diff --git a/tests/bugs/modalg_5/bug25199 b/tests/bugs/modalg_5/bug25199 index 47d968a223..410c4600ef 100755 --- a/tests/bugs/modalg_5/bug25199 +++ b/tests/bugs/modalg_5/bug25199 @@ -1,4 +1,5 @@ puts "TODO CR30351 Windows: Faulty OCC25199: Bad tolerance edge generated by blend algorithm" +puts "TODO CR33225 Linux: Faulty OCC25199: Bad tolerance edge generated by blend algorithm" puts "============" puts "OCC25199" diff --git a/tests/bugs/modalg_6/bug26616 b/tests/bugs/modalg_6/bug26616 deleted file mode 100644 index 75391f0a0d..0000000000 --- a/tests/bugs/modalg_6/bug26616 +++ /dev/null @@ -1,20 +0,0 @@ -puts "========" -puts "OCC26616" -puts "========" -puts "" -############################################ -# Memory leak in IntTools_Context::Hatcher -############################################ - -restore [locate_data_file OCC26635_t0.brep] t0 -restore [locate_data_file OCC26635_t1.brep] t1 - -bfuse res t0 t1 - -set listmem {} -for {set i 1} {$i < 10} {incr i} { - bfuse res t0 t1 - - lappend listmem [meminfo h] - checktrend $listmem 0 64 "Memory leak detected" -} diff --git a/tests/bugs/modalg_6/bug27884 b/tests/bugs/modalg_6/bug27884 index e8bf7ec226..74509b211b 100644 --- a/tests/bugs/modalg_6/bug27884 +++ b/tests/bugs/modalg_6/bug27884 @@ -3,6 +3,8 @@ puts "OCC27884: Modeling Algorithms - Possible improvement for 2d classifier" puts "=================================================================" puts "" +puts "TODO ?CR33225 Windows: Error: algorithm slowed down" + pload ALL pload QAcommands diff --git a/tests/bugs/modalg_7/bug29293_1 b/tests/bugs/modalg_7/bug29293_1 index 9ff06449e0..5d4015de14 100644 --- a/tests/bugs/modalg_7/bug29293_1 +++ b/tests/bugs/modalg_7/bug29293_1 @@ -1,3 +1,5 @@ +puts "TODO ?CR33225 Windows: extra characters after close-quote " + puts "========" puts "OCC29293" puts "========" diff --git a/tests/bugs/modalg_7/bug29843_1 b/tests/bugs/modalg_7/bug29843_1 deleted file mode 100644 index 24e35fe3fb..0000000000 --- a/tests/bugs/modalg_7/bug29843_1 +++ /dev/null @@ -1,48 +0,0 @@ -puts "========" -puts "0029843: Modeling Algorithms - Boolean FUSE produces incorrect result" -puts "========" -puts "" - -restore [locate_data_file bug29843.brep] s - -explode s -bclearobjects -bcleartools -baddobjects s_1 -baddtools s_2 -bfillds - -bbop r_0 0 -bbop r_1 1 -bbop r_2 2 -bbop r_3 3 -bbop r_4 4 -bbuild r_5 - -foreach i { 0 1 2 3 4 5} { - checkshape r_$i - if {![regexp "OK" [bopcheck r_$i]]} { - puts "Error: r_$i is self-intersecting shape" - } -} - -checkprops r_0 -s 9.84429 -v 0.639311 -checknbshapes r_0 -wire 7 -face 5 -shell 1 -solid 1 -t - -checkprops r_1 -s 2121.39 -v 612.41 -checknbshapes r_1 -wire 38 -face 32 -shell 2 -solid 1 -t - -checkprops r_2 -s 2113.85 -v 611.569 -checknbshapes r_2 -wire 32 -face 26 -shell 2 -solid 1 -t - -checkprops r_3 -s 15.9893 -v 0.215264 -checknbshapes r_3 -wire 11 -face 9 -shell 2 -solid 2 -t - -checkprops r_4 -l 24.9725 -checksection r_4 -r 2 - -checkprops r_5 -s 2139.68 -v 612.402 -checknbshapes r_5 -wire 44 -face 36 -shell 5 -solid 4 -t - -checkview -display r_0 -2d -path ${imagedir}/${test_image}.png - diff --git a/tests/bugs/modalg_7/bug30054 b/tests/bugs/modalg_7/bug30054 index b187154b5a..9b16118a62 100644 --- a/tests/bugs/modalg_7/bug30054 +++ b/tests/bugs/modalg_7/bug30054 @@ -2,7 +2,7 @@ puts "=================================================" puts "0030054: BRepOffset_MakeOffset fails to build joints in intersection mode" puts "=================================================" puts "" - +puts "TODO OCC33166 ALL: Faulty shapes" restore [locate_data_file bug30054.brep] a thickshell result a 1 i diff --git a/tests/bugs/modalg_8/bug26441 b/tests/bugs/modalg_8/bug26441 new file mode 100644 index 0000000000..55071ba692 --- /dev/null +++ b/tests/bugs/modalg_8/bug26441 @@ -0,0 +1,40 @@ +puts "============" +puts "0026441: Modeling Algorithms - BRepOffset_MakeOffset affects original shape" +puts "============" +puts "" + +pload QAcommands +restore [locate_data_file bug26440_plate.brep] sh + +tcopy sh sh_ref +thickshell result sh 160 + +checkprops result -s 2.40831e+07 +checkshape result + +set nbshapes_expected " +Number of shapes in shape + VERTEX : 196 + EDGE : 308 + WIRE : 110 + FACE : 110 + SHELL : 1 + SOLID : 1 + COMPSOLID : 0 + COMPOUND : 0 + SHAPE : 726 +" +checknbshapes result -ref ${nbshapes_expected} -t -m "solid construction" +if { [info exist BadEdges] } { + unset BadEdges +} +if { [info exist BadVerts] } { + unset BadVerts +} + +OCC26441 sh sh_ref 1.e-7 1 + +if { [isdraw BadEdges] || [isdraw BadVerts]} { + puts "Error: tolerances of some subshapes of initial shape are changed" +} + diff --git a/tests/bugs/modalg_8/bug33173 b/tests/bugs/modalg_8/bug33173 new file mode 100644 index 0000000000..beb793d69b --- /dev/null +++ b/tests/bugs/modalg_8/bug33173 @@ -0,0 +1,15 @@ +puts "========" +puts "0033173: Modeling Algorithms - Regression in BRepExtrema_DistShapeShape causing Standard_OutOfRange" +puts "========" +puts "" + +set MinDistExpected 7.049107166484117e-07 +restore [locate_data_file bug33173.brep] s +explode s +distmini dm s_1 s_2 +if {[isdraw dm]} { + checkreal MinDist $MinDistExpected [dval dm_val] 1.e-7 .01 +} else { + puts "Error: distmini failed" +} + diff --git a/tests/bugs/modalg_8/bug33179 b/tests/bugs/modalg_8/bug33179 new file mode 100644 index 0000000000..3ed700aca4 --- /dev/null +++ b/tests/bugs/modalg_8/bug33179 @@ -0,0 +1,9 @@ +puts "================================" +puts "0033179: Modeling Algorithms - Crash in in ShapeFix_Shape with the attached object, when healing for fixing SameParameterFlag" +puts "================================" + +restore [locate_data_file bug33179.brep] s + +fsameparameter s +checkshape s + diff --git a/tests/bugs/modalg_8/bug33187 b/tests/bugs/modalg_8/bug33187 new file mode 100644 index 0000000000..34b14961e3 --- /dev/null +++ b/tests/bugs/modalg_8/bug33187 @@ -0,0 +1,9 @@ +puts "================================" +puts "0033187: Modeling Algorithms - Crash in postprocessing of imported shape" +puts "================================" + +restore [locate_data_file bug33187.brep] s + +if [catch { fixshape r s } catch_result] { + puts "${BugNumber}: Faulty" +} diff --git a/tests/bugs/moddata_3/bug162 b/tests/bugs/moddata_3/bug162 index eff2020590..8638698c34 100644 --- a/tests/bugs/moddata_3/bug162 +++ b/tests/bugs/moddata_3/bug162 @@ -2,6 +2,9 @@ puts "========" puts "OCC162" puts "========" +puts "TODO ?CR33225 Linux: Checking trend failed " +puts "TODO ?CR33225 Linux: Tcl Exception: Memory leak detected" + pload QAcommands pload XDE diff --git a/tests/bugs/step/bug27122 b/tests/bugs/step/bug27122 new file mode 100644 index 0000000000..b4c4f6ae0b --- /dev/null +++ b/tests/bugs/step/bug27122 @@ -0,0 +1,27 @@ +puts "================" +puts "OCC27122" +puts "================" +puts "" +##################################################################### +# STEP import regression: invalid shapes are produced during model translation due to huge face tolerance +##################################################################### + +pload XDE + +# Empty resource file name to take params from InterfaceStatic +param "read.step.resource.name" "\"\"" +# Add FixFaceSize operator +param "FromSTEP.exec.op" FixShape,FixFaceSize +# Set a tolerance exceeding the size of the problem face to FixFaceSize operator +param "FromSTEP.FixFaceSize.Tolerance" 0.0508 + +stepread [locate_data_file bug27122_280696.stp] a * + +# restore old params +param "read.step.resource.name" STEP +param "FromSTEP.exec.op" FixShape +param "FromSTEP.FixFaceSize.Tolerance" 1.e-7 + +checknbshapes a_1 -t -face 10 + +checkview -display a_1 -3d -path ${imagedir}/${test_image}.png diff --git a/tests/bugs/step/bug32977 b/tests/bugs/step/bug32977 new file mode 100644 index 0000000000..3948aeb0cf --- /dev/null +++ b/tests/bugs/step/bug32977 @@ -0,0 +1,58 @@ +puts "====================================" +puts "0032977: OCC V7.5, V7.6 cannot read STEP color correctly for the root label, but v6.8 can" +puts "====================================" +puts "" + +pload ALL + +# Read files +# Check colors number + +ReadStep D1 [locate_data_file bug32977_1.stp] +set info1 [XStat D1] +regexp {Number +of +colors += +([-0-9.+eE]+)} $info1 full nbcolor +regexp {Number +of +colors += +[-0-9.+eE]+\n([^\n]*)} $info1 full colors +if {[string compare ${colors} "RED BLACK GRAY74 GRAY26 "] != 0} { + puts "Error: not expected colors ${colors}" + } +if {$nbcolor != 4} { + puts "Error: not expected number of colors" + } + +ReadStep D2 [locate_data_file bug32977_2.step] +set info2 [XStat D2] +regexp {Number +of +colors += +([-0-9.+eE]+)} $info2 full nbcolor +regexp {Number +of +colors += +[-0-9.+eE]+\n([^\n]*)} $info2 full colors +if {[string compare ${colors} "LIGHTSTEELBLUE2 WHITE VIOLETRED3 GRAY25 "] != 0} { + puts "Error: not expected colors ${colors}" + } +if {$nbcolor != 4} { + puts "Error: not expected number of colors" + } + +ReadStep D3 [locate_data_file trj10_pm8-id-214.stp] +set info3 [XStat D3] +regexp {Number +of +colors += +([-0-9.+eE]+)} $info3 full nbcolor +regexp {Number +of +colors += +[-0-9.+eE]+\n([^\n]*)} $info3 full colors +if {[string compare ${colors} "MAGENTA RED ORANGERED ORANGE DEEPSKYBLUE2 GREEN "] != 0} { + puts "Error: not expected colors ${colors}" + } +if {$nbcolor != 6} { + puts "Error: not expected number of colors" + } + +vinit View1 +XDisplay D1 -dispmode 1 +vfit +checkview -screenshot -3d -path ${imagedir}/${test_image}1.png + +vclear +XDisplay D2 -dispmode 1 +vfit +checkview -screenshot -3d -path ${imagedir}/${test_image}2.png + +vclear +XDisplay D3 -dispmode 1 +vfit +checkview -screenshot -3d -path ${imagedir}/${test_image}3.png + diff --git a/tests/bugs/xde/bug22898 b/tests/bugs/xde/bug22898 index a86dbb8a89..39e9697788 100644 --- a/tests/bugs/xde/bug22898 +++ b/tests/bugs/xde/bug22898 @@ -1,4 +1,5 @@ puts "TODO OCC24156 MacOS: Error: unsupported locale specification" +puts "TODO CR33225 Linux: Error: unsupported locale specification" # Test for issue #22898 and other functionality that can be affected by locale. # Just run multiple conversions of the shape to and from different formats and diff --git a/tests/cr/bugs/bug33170 b/tests/cr/bugs/bug33170 new file mode 100644 index 0000000000..9313e54b76 --- /dev/null +++ b/tests/cr/bugs/bug33170 @@ -0,0 +1,30 @@ +puts "============" +puts "0033170: Modeling Algorithms - Checking for canonical geometry: plane detection problems" +puts "============" +puts "" + +set ExpectGap 0.0051495320504590563 +brestore [locate_data_file bug33170.brep] f +set log1 [getanasurf asurf1 f pln 0.006] +regexp {Gap = +([-0-9.+eE]+)} $log1 full gap1 +if {[isdraw asurf1]} { + set log [dump asurf1] + if { [regexp {Plane} $log ] != 1 } { + puts "Error: surface is not a plane" + } +} else { + puts "Error: required surface is not got" +} +checkreal FoundGap1 $gap1 $ExpectGap 1.0e-9 0.0 +# +set log2 [getanasurf asurf2 f pln 1.] +regexp {Gap = +([-0-9.+eE]+)} $log1 full gap2 +if {[isdraw asurf2]} { + set log [dump asurf2] + if { [regexp {Plane} $log ] != 1 } { + puts "Error: surface is not a plane" + } +} else { + puts "Error: required surface is not got" +} +checkreal FoundGap2 $gap2 $ExpectGap 1.0e-9 0.0 diff --git a/tests/cr/grids.list b/tests/cr/grids.list index 8eb5c913e5..809bfa6f44 100644 --- a/tests/cr/grids.list +++ b/tests/cr/grids.list @@ -1,2 +1,3 @@ 001 base 002 approx +003 bugs diff --git a/tests/de/step_2/K4 b/tests/de/step_2/K4 index 50f99b358e..8671a0efe7 100644 --- a/tests/de/step_2/K4 +++ b/tests/de/step_2/K4 @@ -8,10 +8,10 @@ CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) So NBSHAPES : Solid = 3 ( 3 ) Shell = 3 ( 3 ) Face = 492 ( 492 ) STATSHAPE : Solid = 57 ( 57 ) Shell = 57 ( 57 ) Face = 1894 ( 1894 ) FreeWire = 0 ( 0 ) TOLERANCE : MaxTol = 1e-007 ( 1e-007 ) AvgTol = 1e-007 ( 1e-007 ) -LABELS : N0Labels = 5 ( 5 ) N1Labels = 31 ( 31 ) N2Labels = 0 ( 0 ) TotalLabels = 36 ( 36 ) NameLabels = 36 ( 36 ) ColorLabels = 3 ( 3 ) LayerLabels = 0 ( 0 ) +LABELS : N0Labels = 5 ( 5 ) N1Labels = 32 ( 32 ) N2Labels = 0 ( 0 ) TotalLabels = 37 ( 37 ) NameLabels = 36 ( 36 ) ColorLabels = 4 ( 4 ) LayerLabels = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) -NCOLORS : NColors = 3 ( 3 ) -COLORS : Colors = CYAN GREEN YELLOW ( CYAN GREEN YELLOW ) +NCOLORS : NColors = 4 ( 4 ) +COLORS : Colors = CYAN GREEN RED YELLOW ( CYAN GREEN RED YELLOW ) NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) diff --git a/tests/de/step_2/K5 b/tests/de/step_2/K5 index a09559240c..62dfab9afa 100644 --- a/tests/de/step_2/K5 +++ b/tests/de/step_2/K5 @@ -8,10 +8,10 @@ CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) So NBSHAPES : Solid = 3 ( 3 ) Shell = 3 ( 3 ) Face = 492 ( 492 ) STATSHAPE : Solid = 57 ( 57 ) Shell = 57 ( 57 ) Face = 1894 ( 1894 ) FreeWire = 0 ( 0 ) TOLERANCE : MaxTol = 1e-007 ( 1e-007 ) AvgTol = 1e-007 ( 1e-007 ) -LABELS : N0Labels = 5 ( 5 ) N1Labels = 31 ( 31 ) N2Labels = 0 ( 0 ) TotalLabels = 36 ( 36 ) NameLabels = 36 ( 36 ) ColorLabels = 3 ( 3 ) LayerLabels = 0 ( 0 ) +LABELS : N0Labels = 5 ( 5 ) N1Labels = 32 ( 32 ) N2Labels = 0 ( 0 ) TotalLabels = 37 ( 37 ) NameLabels = 36 ( 36 ) ColorLabels = 4 ( 4 ) LayerLabels = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) -NCOLORS : NColors = 3 ( 3 ) -COLORS : Colors = CYAN GREEN YELLOW ( CYAN GREEN YELLOW ) +NCOLORS : NColors = 4 ( 4 ) +COLORS : Colors = CYAN GREEN RED YELLOW ( CYAN GREEN RED YELLOW ) NLAYERS : NLayers = 0 ( 0 ) LAYERS : Layers = ( ) diff --git a/tests/de_mesh/gltf_write/010 b/tests/de_mesh/gltf_write/010 deleted file mode 100644 index b9b5d1be71..0000000000 --- a/tests/de_mesh/gltf_write/010 +++ /dev/null @@ -1,16 +0,0 @@ -puts "========" -puts "0032867: Data Exchange - Implement Draco compression for writing glTF" -puts "Test case exporting model into glb (binary glTF) file." -puts "========" - -Close D0 -silent -ReadGltf D0 [locate_data_file bug32867_010.glb] - -set aGltfFile1 "${imagedir}/${casename}_tmp1.glb" -set aGltfFile2 "${imagedir}/${casename}_tmp2.glb" - -WriteGltf D0 "$aGltfFile1" -draco on -mergefaces -WriteGltf D0 "$aGltfFile2" -draco on - -ReadGltf D1 "$aGltfFile1" -ReadGltf D "$aGltfFile2" diff --git a/tests/de_mesh/gltf_write/Diamond b/tests/de_mesh/gltf_write/Diamond deleted file mode 100644 index f020c335eb..0000000000 --- a/tests/de_mesh/gltf_write/Diamond +++ /dev/null @@ -1,16 +0,0 @@ -puts "========" -puts "0032867: Data Exchange - Implement Draco compression for writing glTF" -puts "Test case exporting model into glb (binary glTF) file." -puts "========" - -Close D0 -silent -ReadGltf D0 [locate_data_file bug32867_Diamond.glb] - -set aGltfFile1 "${imagedir}/${casename}_tmp1.glb" -set aGltfFile2 "${imagedir}/${casename}_tmp2.glb" - -WriteGltf D0 "$aGltfFile1" -draco on -WriteGltf D0 "$aGltfFile2" -draco on -mergefaces - -ReadGltf D1 "$aGltfFile1" -ReadGltf D "$aGltfFile2" diff --git a/tests/de_mesh/gltf_write/as1draco b/tests/de_mesh/gltf_write/as1draco deleted file mode 100644 index f07a25a3c9..0000000000 --- a/tests/de_mesh/gltf_write/as1draco +++ /dev/null @@ -1,18 +0,0 @@ -puts "========" -puts "0032867: Data Exchange - Implement Draco compression for writing glTF" -puts "Test case exporting model into glb (binary glTF) file." -puts "========" - -Close D0 -silent -ReadStep D0 [locate_data_file as1-oc-214-mat.stp] -XGetOneShape ss D0 -incmesh ss 1.0 - -set aGltfFile1 "${imagedir}/${casename}_tmp1.glb" -set aGltfFile2 "${imagedir}/${casename}_tmp2.glb" - -WriteGltf D0 "$aGltfFile1" -draco on -WriteGltf D0 "$aGltfFile2" -draco on -mergefaces - -ReadGltf D1 "$aGltfFile1" -ReadGltf D "$aGltfFile2" diff --git a/tests/de_mesh/gltf_write/bearing b/tests/de_mesh/gltf_write/bearing deleted file mode 100644 index 46d8ae6d15..0000000000 --- a/tests/de_mesh/gltf_write/bearing +++ /dev/null @@ -1,16 +0,0 @@ -puts "========" -puts "0032867: Data Exchange - Implement Draco compression for writing glTF" -puts "Test case exporting model into glb (binary glTF) file." -puts "========" - -restore [locate_data_file bearing.brep] b -incmesh b 0.1 - -set aGltfFile1 "${imagedir}/${casename}_tmp1.glb" -set aGltfFile2 "${imagedir}/${casename}_tmp2.glb" - -WriteGltf b "$aGltfFile1" -draco on -WriteGltf b "$aGltfFile2" -draco on -mergefaces - -ReadGltf D0 "$aGltfFile1" -ReadGltf D "$aGltfFile2" diff --git a/tests/de_mesh/gltf_write/bull b/tests/de_mesh/gltf_write/bull deleted file mode 100644 index 5d7de77f3c..0000000000 --- a/tests/de_mesh/gltf_write/bull +++ /dev/null @@ -1,16 +0,0 @@ -puts "========" -puts "0032867: Data Exchange - Implement Draco compression for writing glTF" -puts "Test case exporting model into glb (binary glTF) file." -puts "========" - -Close D0 -silent -ReadGltf D0 [locate_data_file bug32867_bull.glb] - -set aGltfFile1 "${imagedir}/${casename}_tmp1.glb" -set aGltfFile2 "${imagedir}/${casename}_tmp2.glb" - -WriteGltf D0 "$aGltfFile1" -draco on -WriteGltf D0 "$aGltfFile2" -draco on -mergefaces - -ReadGltf D1 "$aGltfFile1" -ReadGltf D "$aGltfFile2" diff --git a/tests/de_mesh/gltf_write/bull_parallel b/tests/de_mesh/gltf_write/bull_parallel deleted file mode 100644 index 5e3967bd4d..0000000000 --- a/tests/de_mesh/gltf_write/bull_parallel +++ /dev/null @@ -1,13 +0,0 @@ -puts "========" -puts "0032867: Data Exchange - Implement Draco compression for writing glTF" -puts "Test case exporting model into glb (binary glTF) file." -puts "========" - -Close D0 -silent -ReadGltf D0 [locate_data_file bug32867_bull.glb] - -set aGltfFile1 "${imagedir}/${casename}_tmp1.glb" - -WriteGltf D0 "$aGltfFile1" -draco on -parallel - -ReadGltf D "$aGltfFile1" diff --git a/tests/de_mesh/gltf_write/screw b/tests/de_mesh/gltf_write/screw deleted file mode 100644 index fa7bee51c8..0000000000 --- a/tests/de_mesh/gltf_write/screw +++ /dev/null @@ -1,18 +0,0 @@ -puts "========" -puts "0032867: Data Exchange - Implement Draco compression for writing glTF" -puts "Test case exporting model into glb (binary glTF) file." -puts "========" - -Close D0 -silent -ReadStep D0 [locate_data_file screw.step] -XGetOneShape ss D0 -incmesh ss 1.0 - -set aGltfFile1 "${imagedir}/${casename}_tmp1.glb" -set aGltfFile2 "${imagedir}/${casename}_tmp2.glb" - -WriteGltf D0 "$aGltfFile1" -draco on -mergefaces -WriteGltf D0 "$aGltfFile2" -draco on - -ReadGltf D1 "$aGltfFile1" -ReadGltf D "$aGltfFile2" \ No newline at end of file diff --git a/tests/de_mesh/gltf_write/soapbox b/tests/de_mesh/gltf_write/soapbox deleted file mode 100644 index 2ec1901886..0000000000 --- a/tests/de_mesh/gltf_write/soapbox +++ /dev/null @@ -1,17 +0,0 @@ -puts "========" -puts "0032867: Data Exchange - Implement Draco compression for writing glTF" -puts "Test case exporting model into glb (binary glTF) file." -puts "========" - -ReadStep D0 [locate_data_file ec_soapbox-A.stp] -XGetOneShape ss D0 -incmesh ss 1.0 - -set aGltfFile1 "${imagedir}/${casename}_tmp1.glb" -set aGltfFile2 "${imagedir}/${casename}_tmp2.glb" - -WriteGltf D0 "$aGltfFile1" -draco on -WriteGltf D0 "$aGltfFile2" -draco on -mergefaces - -ReadGltf D1 "$aGltfFile1" -ReadGltf D "$aGltfFile2" \ No newline at end of file diff --git a/tests/de_mesh/gltf_write/test b/tests/de_mesh/gltf_write/test deleted file mode 100644 index 708cfe088e..0000000000 --- a/tests/de_mesh/gltf_write/test +++ /dev/null @@ -1,20 +0,0 @@ -puts "========" -puts "0032867: Data Exchange - Implement Draco compression for writing glTF" -puts "Test case exporting model into glb (binary glTF) file." -puts "========" - -Close D0 -silent -ReadGltf D0 [locate_data_file bug32867_test.glb] - -set aGltfFile1 "${imagedir}/${casename}_tmp1.glb" -set aGltfFile2 "${imagedir}/${casename}_tmp2.glb" - -WriteGltf D0 "$aGltfFile1" -draco on -WriteGltf D0 "$aGltfFile2" -draco on -mergefaces - -ReadGltf D1 "$aGltfFile1" -XGetOneShape s1 D1 -checktrinfo s1 -tri 9366 -ReadGltf D "$aGltfFile2" -XGetOneShape s2 D -checktrinfo s2 -tri 9366 diff --git a/tests/heal/checkshape/bug32448_10 b/tests/heal/checkshape/bug32448_10 deleted file mode 100644 index 0984113b23..0000000000 --- a/tests/heal/checkshape/bug32448_10 +++ /dev/null @@ -1,8 +0,0 @@ -puts "REQUIRED All: Faulty shapes in variables faulty_1 to faulty_6101" -puts "==========" -puts "0032448: Provide exact validating (as option) using GeomLib_CheckCurveOnSurface" -puts "==========" -puts "" - -restore [locate_data_file OCC54.brep] b -checkshape b -exact -parallel diff --git a/tests/hlr/poly_hlr/A1 b/tests/hlr/poly_hlr/A1 index 1b6e75a3cc..4a5e0ad98f 100644 --- a/tests/hlr/poly_hlr/A1 +++ b/tests/hlr/poly_hlr/A1 @@ -4,7 +4,7 @@ puts "=====================================" puts "" set viewname "" -set length 6.30238 +set length 6.30139 restore [locate_data_file bug27341_hlrsave.brep] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/A2 b/tests/hlr/poly_hlr/A2 index c116d9dec9..39098da4e6 100644 --- a/tests/hlr/poly_hlr/A2 +++ b/tests/hlr/poly_hlr/A2 @@ -1,4 +1,4 @@ -puts "TODO OCC30286 ALL: Error : The length of result shape is 8.06872, expected 8.05281" +puts "TODO OCC30286 ALL: Error : The length of result shape is 7.9487, expected 8.05281" puts "=====================================" puts "OCC27341: Incorrect exact HLR results" diff --git a/tests/hlr/poly_hlr/A3 b/tests/hlr/poly_hlr/A3 index 3e71edfe30..804241eb90 100644 --- a/tests/hlr/poly_hlr/A3 +++ b/tests/hlr/poly_hlr/A3 @@ -4,7 +4,7 @@ puts "=====================================" puts "" set viewname "vbottom" -set length 8.39744 +set length 8.40196 restore [locate_data_file bug27341_hlrsave.brep] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/A4 b/tests/hlr/poly_hlr/A4 index 72303a8910..980d50d0bf 100644 --- a/tests/hlr/poly_hlr/A4 +++ b/tests/hlr/poly_hlr/A4 @@ -1,4 +1,4 @@ -puts "TODO OCC30286 ALL: Error : The length of result shape is 7.44464, expected 7.39488" +puts "TODO OCC30286 ALL: Error : The length of result shape is 7.4452, expected 7.39488" puts "=====================================" puts "OCC27341: Incorrect exact HLR results" diff --git a/tests/hlr/poly_hlr/A5 b/tests/hlr/poly_hlr/A5 index f276fd4c4d..3423f470fa 100644 --- a/tests/hlr/poly_hlr/A5 +++ b/tests/hlr/poly_hlr/A5 @@ -1,4 +1,4 @@ -puts "TODO OCC30286 ALL: Error : The length of result shape is 9.10542, expected 9.47163" +puts "TODO OCC30286 ALL: Error : The length of result shape is 9.08401, expected 9.47163" puts "=====================================" puts "OCC27341: Incorrect exact HLR results" diff --git a/tests/hlr/poly_hlr/A6 b/tests/hlr/poly_hlr/A6 index f85f2d0066..f80e6dda04 100644 --- a/tests/hlr/poly_hlr/A6 +++ b/tests/hlr/poly_hlr/A6 @@ -4,7 +4,7 @@ puts "=====================================" puts "" set viewname "vleft" -set length 7.64599 +set length 7.64618 restore [locate_data_file bug27341_hlrsave.brep] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/A7 b/tests/hlr/poly_hlr/A7 index dc38a1c33e..c9f00b1c14 100644 --- a/tests/hlr/poly_hlr/A7 +++ b/tests/hlr/poly_hlr/A7 @@ -4,7 +4,7 @@ puts "=====================================" puts "" set viewname "vright" -set length 9.30381 +set length 9.30402 restore [locate_data_file bug27341_hlrsave.brep] a COMPUTE_HLR $viewname $algotype diff --git a/tests/hlr/poly_hlr/Plate b/tests/hlr/poly_hlr/Plate index 536d8018d5..54e63d22ea 100644 --- a/tests/hlr/poly_hlr/Plate +++ b/tests/hlr/poly_hlr/Plate @@ -1,5 +1,5 @@ puts "TODO OCC30286 Windows: Error : The length of result shape is 404.004, expected 404.386" -puts "TODO OCC30286 Linux: Error : The length of result shape is 404.492, expected 404.386" +puts "TODO CR33225 Linux: Error : The length of result shape is 404.004, expected 404.386" polyline f1 0 0 0 0 -10 0 100 -10 0 100 0 0 0 0 0 polyline f2 100 0 0 110 0 0 110 100 0 100 100 0 100 0 0 diff --git a/tests/lowalgos/proximity/D4 b/tests/lowalgos/proximity/D4 new file mode 100644 index 0000000000..c463310b87 --- /dev/null +++ b/tests/lowalgos/proximity/D4 @@ -0,0 +1,29 @@ +puts "============" +puts "0033144: Modeling Algorithms - Wrong result of Shape Proximity" +puts "===========" +puts "" + +sphere s1 0 1 0 0 0 1 1 +trimu s1 s1 0 pi +mkface fs1 s1 +incmesh fs1 1e-3 + +plane p1 0 0 0 0 1 0 +trim p1 p1 -1 1 -1 1 +mkface f2 p1 +incmesh f2 1e-3 + +set log [proximity fs1 f2 -value -profile] + +regexp {Proximity value: ([0-9+-.eE]*)} $log full val; + +set tol 1.e-2 +set expected 2.0 + +regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 +set status1 ${val2} +set expected_status1 Middle + +regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 +set status2 ${val2} +set expected_status2 Middle \ No newline at end of file diff --git a/tests/lowalgos/proximity/B6 b/tests/lowalgos/proximity/E3 similarity index 55% rename from tests/lowalgos/proximity/B6 rename to tests/lowalgos/proximity/E3 index 860919a914..a7e5858183 100644 --- a/tests/lowalgos/proximity/B6 +++ b/tests/lowalgos/proximity/E3 @@ -1,26 +1,23 @@ puts "============" -puts "0033017: Implement an algorithm to find a proximity between a pair of shapes" +puts "0033144: Modeling Algorithms - Wrong result of Shape Proximity" puts "===========" puts "" -plane p1 0 0 0 0 0 1 -trim p1 p1 -1 1 -1 1 -mkface f1 p1 -incmesh f1 1.e-3 +restore [locate_data_file bug33144_e1.brep] e1 +restore [locate_data_file bug33144_e2.brep] e2 -circle c 0 0 1 1 -mkedge e1 c -incmesh e1 1.e-3 +incmesh e1 1e-3 +incmesh e2 1e-3 -set log [proximity f1 e1 -value -profile] +set log [proximity e1 e2 -value -profile] regexp {Proximity value: ([0-9+-.eE]*)} $log full val; set tol 1.e-3 -set expected 1.0 +set expected 0.6996 regexp {Status of ProxPnt1 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 set status1 ${val2} -set expected_status1 Border +set expected_status1 Middle regexp {Status of ProxPnt2 on ([A-Za-z0-9._-]*) : ([A-Za-z]*)} $log full val1 val2 set status2 ${val2} diff --git a/tests/offset/faces_type_i/B3 b/tests/offset/faces_type_i/B3 index 429bc1596e..3e45add693 100644 --- a/tests/offset/faces_type_i/B3 +++ b/tests/offset/faces_type_i/B3 @@ -1,6 +1,6 @@ -puts "TODO OCC23748 ALL: ERROR. offsetperform operation not done." -puts "TODO OCC23748 ALL: Error: The command cannot be built" -puts "TODO OCC26556 ALL: Error : The offset cannot be built." +puts "TODO OCC26556 ALL: Error : The volume" +puts "TODO OCC26556 ALL: Faulty shapes" +puts "TODO OCC26556 ALL: Error : The area" pcone s 5 0 12 270 diff --git a/tests/offset/faces_type_i/C8 b/tests/offset/faces_type_i/C8 index 35d6dc4903..0a00d26119 100644 --- a/tests/offset/faces_type_i/C8 +++ b/tests/offset/faces_type_i/C8 @@ -1,5 +1,6 @@ puts "TODO OCC25406 ALL: Error : The volume of result shape is" puts "TODO OCC25406 ALL: Error: bsection of the result and s is not equal to zero" +puts "TODO OCC25406 ALL: Faulty shapes" ellipse w1 0 0 0 15 10 mkedge w1 w1 0 pi/2 diff --git a/tests/offset/shape_type_i/A7 b/tests/offset/shape_type_i/A7 index d3f9f7a6f4..e43caa9efb 100644 --- a/tests/offset/shape_type_i/A7 +++ b/tests/offset/shape_type_i/A7 @@ -1,5 +1,4 @@ puts "TODO OCC23068 ALL: Error : The volume of result shape " -puts "TODO OCC25406 ALL: Error: bsection of the result and s is not equal to zero" pcone s 5 0 12 270 diff --git a/tests/offset/shape_type_i/C8 b/tests/offset/shape_type_i/C8 index c9bd158b10..b57fd6e696 100644 --- a/tests/offset/shape_type_i/C8 +++ b/tests/offset/shape_type_i/C8 @@ -1,5 +1,6 @@ puts "TODO OCC23068 ALL: Error : The volume of result shape is" puts "TODO OCC23068 ALL: Error: bsection of the result and s is not equal to zero" +puts "TODO OCC23068 ALL: Faulty shapes" ellipse w1 0 0 0 15 10 mkedge w1 w1 0 pi/2 diff --git a/tests/opengl/data/background/skydome b/tests/opengl/data/background/skydome deleted file mode 100644 index 281bad22b6..0000000000 --- a/tests/opengl/data/background/skydome +++ /dev/null @@ -1,43 +0,0 @@ -puts "============" -puts "0032606: Visualization - add a shader for sky" -puts "============" -puts "" - -set THE_DIM 256 - -pload MODELING VISUALIZATION -psphere s 1 - -vinit View1 -width 768 -height 512 -vcamera -persp -fovy 120 - -chrono t restart -vbackground -skydome -size $THE_DIM -cloud 0.3 -sunDir 1.0 0.5 0.0 -time 10 -fog 0.3 -chrono t show -vaxo -vdump $imagedir/${casename}_day.png - -chrono t restart -vbackground -skydome -size $THE_DIM -cloud 0.3 -sunDir 1.0 -0.5 0.0 -time -10 -fog 0.05 -chrono t show -vaxo -vdump $imagedir/${casename}_night.png - -chrono t restart -vbackground -skydome -size $THE_DIM -cloud 0.15 -sunDir 1.0 0.15 0.0 -time 10 -chrono t show -vaxo -vdump $imagedir/${casename}_sunset.png - -chrono t restart -vbackground -skydome -size $THE_DIM -chrono t show -vaxo -vdump $imagedir/${casename}_defaults.png - -vdisplay -dispMode 1 s -vfit -vaspects s -material SILVER -vrenderparams -shadingModel pbr -vlight headlight -enabled 0 -vdump $imagedir/${casename}_pbr.png diff --git a/tests/opengl/data/general/bug25679 b/tests/opengl/data/general/bug25679 deleted file mode 100644 index 6a267ae414..0000000000 --- a/tests/opengl/data/general/bug25679 +++ /dev/null @@ -1,33 +0,0 @@ -puts "========" -puts "OCC25679: Visualization, TKOpenGl - View frustum culling clips wrong objects" -puts "========" -puts "" - -pload MODELING VISUALIZATION - -set LINES_IN_ROW 50 - -set aNoCulling $imagedir/${casename}_without.png -set aWithCulling $imagedir/${casename}_with.png -set aDiff $imagedir/${casename}_diff.png - -vinit View1 - -for {set i 0} {$i < $LINES_IN_ROW} {incr i} { - for {set j 0} {$j < $LINES_IN_ROW} {incr j} { - set aLineName "line" - append aLineName [expr $i * $LINES_IN_ROW + $j] - vline $aLineName 0 0 0 1 0 0 - vsetlocation $aLineName [expr $i * 3] [expr $j * 3] 0 - } -} - -vfit - -vrenderparams -frustumculling on -vdump $aWithCulling -vrenderparams -frustumculling off -vdump $aNoCulling - -set aDiffRes [diffimage $aWithCulling $aNoCulling 0.1 0 0 $aDiff] -if {$aDiffRes != 0} { puts "ERROR : Test failed: there is a difference between images rendered with and without frustum culling" } diff --git a/tests/opengl/data/raytrace/bug25201 b/tests/opengl/data/raytrace/bug25201 deleted file mode 100644 index 9896f29319..0000000000 --- a/tests/opengl/data/raytrace/bug25201 +++ /dev/null @@ -1,53 +0,0 @@ -puts "========" -puts "OCC25201: Visualization - Implementing soft shadows and ambient occlusion in OCCT ray-tracing core" -puts "========" - -pload MODELING VISUALIZATION - -# custom shapes -set aShape1 [locate_data_file occ/Top.brep] -set aShape2 [locate_data_file occ/Bottom.brep] - -# setup 3D viewer content -vinit name=View1 w=512 h=512 -vglinfo - -vvbo 0 -vsetdispmode 1 -vbackground -gradient B4C8FF B4B4B4 -gradientMode VERTICAL -vtextureenv on 4 -restore $aShape1 s1 -restore $aShape2 s2 -vdisplay s1 s2 -vsetmaterial s1 Gold -vsetmaterial s2 Silver -vsetlocation s1 0.0 0.1 0.0 -vlight -change 0 -dir 0.667 -0.667 -0.333 -smoothAngle 6 -intensity 100 -vturnview 3.0 -1.2 -0.1 -vfit - -# activate path tracing -vrenderparams -raytrace -vrenderparams -gi -vrenderparams -rayDepth 12 - -set aModeNum 0 - -vbsdf s1 roughness 6400 - -vfps 200 -vdump $imagedir/${casename}_${aModeNum}.png -incr aModeNum - -vsetmaterial s1 glass -vbsdf s1 absorpcoeff 1.0 - -vfps 200 -vdump $imagedir/${casename}_${aModeNum}.png -incr aModeNum - -vsetmaterial s2 plaster - -vfps 200 -vdump $imagedir/${casename}_${aModeNum}.png -incr aModeNum diff --git a/tests/opengl/data/raytrace/dof_mono b/tests/opengl/data/raytrace/dof_mono deleted file mode 100644 index b5ea196a06..0000000000 --- a/tests/opengl/data/raytrace/dof_mono +++ /dev/null @@ -1,10 +0,0 @@ -puts "========" -puts "Ray Tracing - check depth-of-field" -puts "========" - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_cube.tcl - -vrenderparams -ray -gi -rayDepth 10 -iss -vrenderparams -aperture 0.1 -focal 2.0 -vfps 200 -vdump ${imagedir}/${casename}.png diff --git a/tests/opengl/data/raytrace/dof_stereo b/tests/opengl/data/raytrace/dof_stereo deleted file mode 100644 index 9e8d46260b..0000000000 --- a/tests/opengl/data/raytrace/dof_stereo +++ /dev/null @@ -1,16 +0,0 @@ -puts "========" -puts "Ray Tracing - check depth-of-field" -puts "========" - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_cube.tcl - -vrenderparams -ray -gi -rayDepth 10 -iss -vrenderparams -aperture 0.1 -focal 2.0 - -# activate stereo -vstereo on -vstereo -mode anaglyph -vcamera -iod 0.1 -vfit -vfps 200 -vdump ${imagedir}/${casename}.png -stereo blend diff --git a/tests/opengl/data/raytrace/normal_map b/tests/opengl/data/raytrace/normal_map deleted file mode 100644 index f9e244866b..0000000000 --- a/tests/opengl/data/raytrace/normal_map +++ /dev/null @@ -1,34 +0,0 @@ -puts "========" -puts "0031275: Visualization, TKOpenGl - handle normal-map texture with Path-Tracing" -puts "========" - -pload XDE OCAF MODELING VISUALIZATION -Close D -silent -ReadGltf D [locate_data_file bug31275_SphereWithNormalMap.glb] - -vclear -vinit v -w 1024 -h 1024 -vbackground -cubemap [locate_data_file Circus_CubeMap_V.png] -vcamera -persp -vlight -clear -vlight -add ambient -XDisplay -dispmode 1 D -vback -vfit - -vrenderparams -ignoreNormalMap on -vrenderparams -ray -gi -rayDepth 10 -vfps 200 -vdump ${imagedir}/${casename}_without_normal_map.png - -vrenderparams -ignoreNormalMap off -vfps 200 -vdump ${imagedir}/${casename}_with_normal_map_back.png - -vfront -vfps 200 -vdump ${imagedir}/${casename}_with_normal_map_front.png - -vlight -add positional -pos 0 0 0 -head 1 -intensity 10 -vfps 200 -vdump ${imagedir}/${casename}_point_light.png diff --git a/tests/opengl/data/raytrace/pbr_spheres b/tests/opengl/data/raytrace/pbr_spheres deleted file mode 100644 index e2fbf0f72a..0000000000 --- a/tests/opengl/data/raytrace/pbr_spheres +++ /dev/null @@ -1,43 +0,0 @@ -puts "========" -puts "0031225: Visualization, TKOpenGl - support cubemap for environment texture within Ray-Tracing" -puts "Spheres grid with different roughness values" -puts "========" - -cpulimit 600 - -pload MODELING VISUALIZATION -vclear -vclose ALL -source $env(CSF_OCCTSamplesPath)/tcl/vis_pbr_spheres.tcl - -vrenderparams -ray -gi -rayDepth 10 -vcamera -ortho -vfit -vlight -change 1 -intensity 0.0001 -vfps 200 -vdump $::imagedir/${::casename}_ortho0.png - -vlight -change 1 -intensity 0.3 -vfps 200 -vdump $::imagedir/${::casename}_ortho30.png - -vcamera -persp -vfit -vlight -change 1 -intensity 0.0001 -vfps 200 -vdump $::imagedir/${::casename}_persp0.png - -vlight -change 1 -intensity 0.3 -vfps 200 -vdump $::imagedir/${::casename}_persp30.png - -set aCubeMap [locate_data_file Circus_CubeMap_V.png] -vlight -change 1 -intensity 1 -vbackground -cubemap $aCubeMap -vcamera -ortho -vfps 200 -vdump $::imagedir/${::casename}_orthoenv.png - -vcamera -persp -vfps 200 -vdump $::imagedir/${::casename}_perspenv.png diff --git a/tests/opengl/data/raytrace/sample_ball_alpha b/tests/opengl/data/raytrace/sample_ball_alpha deleted file mode 100644 index dfd7d58b71..0000000000 --- a/tests/opengl/data/raytrace/sample_ball_alpha +++ /dev/null @@ -1,13 +0,0 @@ -puts "============" -puts "Visualization - Path Tracing, Ball sample" -puts "============" -puts "" - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_ball.tcl - -vtexture ball 21 -scale 0.1 0.1 -vsetmaterial ball plaster -vbsdf ball -coatFresnel Constant 0.0 - -vfps 100 -vdump $imagedir/${casename}_zoom.png diff --git a/tests/opengl/data/raytrace/sample_ball_iss b/tests/opengl/data/raytrace/sample_ball_iss deleted file mode 100644 index 32b9d31f1c..0000000000 --- a/tests/opengl/data/raytrace/sample_ball_iss +++ /dev/null @@ -1,20 +0,0 @@ -puts "============" -puts "Visualization - Path Tracing, Ball sample (ISS mode)" -puts "============" -puts "" - -cpulimit 1000 - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_ball.tcl - -vrenderparams -iss -nbtiles 64 -vfps 1024 -vdump $imagedir/${casename}_iss_64.png - -vrenderparams -iss -nbtiles 256 -vfps 256 -vdump $imagedir/${casename}_iss_256.png - -vrenderparams -iss -nbtiles 1024 -vfps 64 -vdump $imagedir/${casename}_iss_1024.png diff --git a/tests/opengl/data/raytrace/sample_ball_wood b/tests/opengl/data/raytrace/sample_ball_wood deleted file mode 100644 index 3fd116873d..0000000000 --- a/tests/opengl/data/raytrace/sample_ball_wood +++ /dev/null @@ -1,13 +0,0 @@ -puts "============" -puts "0031135: Visualization, TKOpenGl - texture sRGB -> linear conversion is applied twice by Path Tracer" -puts "============" -puts "" - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_ball.tcl - -vtexture ball 11 -scale 0.1 0.1 -vsetmaterial ball plaster -vbsdf ball -coatFresnel Constant 0.0 - -vfps 100 -vdump $imagedir/${casename}_zoom.png diff --git a/tests/opengl/data/raytrace/sample_cube b/tests/opengl/data/raytrace/sample_cube deleted file mode 100644 index 44c965afa9..0000000000 --- a/tests/opengl/data/raytrace/sample_cube +++ /dev/null @@ -1,8 +0,0 @@ -puts "============" -puts "Visualization - Path Tracing, Cube sample" -puts "============" -puts "" - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_cube.tcl -vfps 200 -vdump ${imagedir}/${casename}.png diff --git a/tests/opengl/data/raytrace/sample_cube_clamp b/tests/opengl/data/raytrace/sample_cube_clamp deleted file mode 100644 index 338c7358b0..0000000000 --- a/tests/opengl/data/raytrace/sample_cube_clamp +++ /dev/null @@ -1,22 +0,0 @@ -puts "============" -puts "Visualization - Path Tracing, Cube sample with radiance clamping" -puts "============" -puts "" - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_cube.tcl - -vrenderparams -maxrad 1.0 -vfps 100 -vdump $imagedir/${casename}_1.png - -vrenderparams -maxrad 2.0 -vfps 100 -vdump $imagedir/${casename}_2.png - -vrenderparams -maxrad 10.0 -vfps 100 -vdump $imagedir/${casename}_10.png - -vrenderparams -maxrad 100.0 -vfps 100 -vdump $imagedir/${casename}_100.png diff --git a/tests/opengl/data/raytrace/sample_cube_twosided b/tests/opengl/data/raytrace/sample_cube_twosided deleted file mode 100644 index ac872ad495..0000000000 --- a/tests/opengl/data/raytrace/sample_cube_twosided +++ /dev/null @@ -1,19 +0,0 @@ -puts "============" -puts "Visualization - Path Tracing, Cube sample" -puts "============" -puts "" - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_cube.tcl - -vaxo -vfit -vfps 100 - -# Dump image produced with one-sided BSDFs -vdump $imagedir/${casename}_onesided.png - -vrenderparams -twoside -vfps 100 - -# Dump image produced with two-sided BSDFs -vdump $imagedir/${casename}_twosided.png diff --git a/tests/opengl/data/raytrace/sample_materials b/tests/opengl/data/raytrace/sample_materials deleted file mode 100644 index 95e25ea36c..0000000000 --- a/tests/opengl/data/raytrace/sample_materials +++ /dev/null @@ -1,7 +0,0 @@ -puts "============" -puts "Visualization - Path Tracing, Materials sample" -puts "============" -puts "" - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_materials.tcl -vdump $imagedir/${casename}_materials.png diff --git a/tests/opengl/data/raytrace/tone_mapping b/tests/opengl/data/raytrace/tone_mapping deleted file mode 100644 index 90bd049577..0000000000 --- a/tests/opengl/data/raytrace/tone_mapping +++ /dev/null @@ -1,14 +0,0 @@ -puts "========" -puts "Ray Tracing - check tone mapping" -puts "========" - -source $env(CSF_OCCTSamplesPath)/tcl/pathtrace_cube.tcl - -vrenderparams -ray -gi -rayDepth 10 -iss - -vrenderparams -tonemapping filmic -vrenderparams -exposure -1.0 -vrenderparams -whitepoint 7.0 -vfit -vfps 200 -vdump ${imagedir}/${casename}.png diff --git a/tests/opengl/data/shading/pbr_spheres b/tests/opengl/data/shading/pbr_spheres deleted file mode 100644 index e3f3628304..0000000000 --- a/tests/opengl/data/shading/pbr_spheres +++ /dev/null @@ -1,34 +0,0 @@ -puts "========" -puts "0030700: Visualization, TKOpenGl - support PBR Metallic-Roughness shading model" -puts "Spheres grid with different roughness values" -puts "========" - -pload MODELING VISUALIZATION - -# PBR doesn't work with Compatible Profile on macOS -if { $::tcl_platform(os) == "Darwin" } { vcaps -core } - -vclear -vclose ALL -source $env(CSF_OCCTSamplesPath)/tcl/vis_pbr_spheres.tcl - -vcamera -ortho -vfit -vlight -change 1 -intensity 0.0001 -vdump $::imagedir/${::casename}_ortho0.png -vlight -change 1 -intensity 0.3 -vdump $::imagedir/${::casename}_ortho30.png -vcamera -persp -vfit -vlight -change 1 -intensity 0.0001 -vdump $::imagedir/${::casename}_persp0.png -vlight -change 1 -intensity 0.3 -vdump $::imagedir/${::casename}_persp30.png - -set aCubeMap [locate_data_file Circus_CubeMap_V.png] -vlight -change 1 -intensity 1 -vbackground -cubemap $aCubeMap -vcamera -ortho -vdump $::imagedir/${::casename}_orthoenv.png -vcamera -persp -vdump $::imagedir/${::casename}_perspenv.png diff --git a/tests/opengl/data/shading/shading_models b/tests/opengl/data/shading/shading_models deleted file mode 100644 index 76306ae990..0000000000 --- a/tests/opengl/data/shading/shading_models +++ /dev/null @@ -1,68 +0,0 @@ -puts "========" -puts "Test various Shading Models assigned per-object" -puts "========" - -pload MODELING VISUALIZATION - -# PBR doesn't work with Compatible Profile on macOS -#if { $::tcl_platform(os) == "Darwin" } { vcaps -core } - -# setup viewer -vclear -vclose ALL -vinit View1 -width 912 -height 912 - -# define spheres with a rough triangulation to easily distinguish Shading Models -psphere p0 10 -copytranslate p11 p0 0 0 0 -copytranslate p12 p0 40 0 0 -copytranslate p21 p0 0 20 0 -copytranslate p22 p0 40 20 0 -copytranslate p31 p0 0 40 0 -copytranslate p32 p0 40 40 0 -compound p11 p12 p21 p22 p31 p32 ss -incmesh ss 1 -vdefaults -autoTriang 0 - -# display objects -vdisplay -dispMode 1 p11 p12 p21 p22 p31 p32 -vdrawparray p41 triangles v 0 55 0 v 0 75 0 v 20 55 0 v 0 55 0 v 0 75 0 v 0 55 20 v 0 55 0 v 0 55 20 v 20 55 0 v 0 75 0 v 0 55 20 v 20 55 0 -vdrawparray p42 triangles v 40 55 0 v 40 75 0 v 60 55 0 v 40 55 0 v 40 75 0 v 40 55 20 v 40 55 0 v 40 55 20 v 60 55 0 v 40 75 0 v 40 55 20 v 60 55 0 -vtop -vrotate -0.9 0.1 0 -vfit - -vcaps -ffp 1 -vdump $::imagedir/${::casename}_defaults_ffp.png - -vcaps -ffp 0 -vdump $::imagedir/${::casename}_defaults.png - -# customize shading models -vaspects p11 -setShadingModel VERTEX -vdrawtext t11 Graphic3d_TOSM_VERTEX -pos 10 5 10 -color RED -aspect BOLD -vaspects p12 -setShadingModel FRAGMENT -vdrawtext t12 Graphic3d_TOSM_FRAGMENT -pos 50 5 10 -color RED -aspect BOLD - -vaspects p21 -setShadingModel PBR -vdrawtext t21 Graphic3d_TOSM_PBR -pos 10 25 10 -color RED -aspect BOLD -vaspects p22 -setShadingModel PBR_FACET -vdrawtext t22 Graphic3d_TOSM_PBR_FACET -pos 50 25 10 -color RED -aspect BOLD - -vaspects p31 -setShadingModel UNLIT -vdrawtext t31 Graphic3d_TOSM_UNLIT -pos 10 45 10 -color RED -aspect BOLD -vaspects p32 -setShadingModel FACET -vdrawtext t32 Graphic3d_TOSM_FACET -pos 50 45 10 -color RED -aspect BOLD -vaspects p41 -setShadingModel VERTEX -vdrawtext t41 Graphic3d_TOSM_VERTEX -pos 10 65 10 -color RED -aspect BOLD -vaspects p42 -setShadingModel FACET -vdrawtext t42 Graphic3d_TOSM_FACET -pos 50 65 10 -color RED -aspect BOLD -vdisplay -topmost t11 t12 t21 t22 t31 t32 t41 t42 - -vcaps -ffp 1 -vdump $::imagedir/${::casename}_ffp.png - -vcaps -ffp 0 -vlight -change 1 -intensity 0.1 -vrenderparams -shadingModel pbr -vdump $::imagedir/${::casename}.png diff --git a/tests/opengl/data/textures/cubemap_dds b/tests/opengl/data/textures/cubemap_dds deleted file mode 100644 index 60c727298e..0000000000 --- a/tests/opengl/data/textures/cubemap_dds +++ /dev/null @@ -1,36 +0,0 @@ -puts "============" -puts "0031478: Visualization, TKOpenGl - allow uploading Cubemap in compressed DDS format when supported by GPU" -puts "============" -puts "" - -pload MODELING VISUALIZATION - -if { $::tcl_platform(os) == "Darwin" } { - # PBR doesn't work with Compatible Profile on macOS - vcaps -core -} -if { [vdriver -default] == "TKOpenGles" } { - puts "Skipping test case 'DDS texture': OpenGL ES does not support sRGB S3TC_DXT1 texture format" - return -} - -set aCubeMapPNG [locate_data_file cubemap_labels.png] -set aCubeMapDDS [locate_data_file cubemap_labels.dds] - -box b 1 2 3 -psphere s 1 - -vclear -vinit View1 -w 512 -h 512 -vcamera -fovy 100 -vzbufftrihedron -#vdisplay -dispMode 1 b -vdisplay -dispMode 1 s -vfit - -vrenderparams -shadingModel pbr -vbackground -cubemap $aCubeMapPNG -invertedz -vdump $imagedir/${casename}_png.png - -vbackground -cubemap $aCubeMapDDS -invertedz -vdump $imagedir/${casename}_dds.png diff --git a/tests/opengl/data/textures/cubemap_ibl b/tests/opengl/data/textures/cubemap_ibl deleted file mode 100644 index 0f283af232..0000000000 --- a/tests/opengl/data/textures/cubemap_ibl +++ /dev/null @@ -1,25 +0,0 @@ -puts "============" -puts "0032590: Visualization, V3d_View - improve API for setting Image Based Lighting" -puts "============" -puts "" - -set aCubeMapLabs [locate_data_file cubemap_labels.png] - -pload MODELING VISUALIZATION - -# PBR doesn't work with Compatible Profile on macOS -if { $::tcl_platform(os) == "Darwin" } { vcaps -core } - -vclear -vclose ALL -source $env(CSF_OCCTSamplesPath)/tcl/vis_pbr_spheres.tcl -vcamera -fovy 100 - -vbackground -cubemap $aCubeMapLabs -pbrEnv noIBL -vdump $imagedir/${casename}_1.png - -vbackground -pbrEnv IBL -vdump $imagedir/${casename}_2.png - -vbackground BLACK -pbrEnv KEEP -vdump $imagedir/${casename}_3.png diff --git a/tests/opengl/data/textures/pbr_tangent_normal b/tests/opengl/data/textures/pbr_tangent_normal deleted file mode 100644 index e371c6cc30..0000000000 --- a/tests/opengl/data/textures/pbr_tangent_normal +++ /dev/null @@ -1,31 +0,0 @@ -puts "========" -puts "0031302: Visualization, TKOpenGl - wrong tangent space calculation for normal maps" -puts "Test for tangent space orientation." -puts "========" - -pload XDE OCAF MODELING VISUALIZATION - -# PBR doesn't work with Compatible Profile on macOS -if { $::tcl_platform(os) == "Darwin" } { vcaps -core } - -vclear -vclose ALL - -vinit v -w 1024 -h 1024 -vcamera -persp -vbackground -cubemap [locate_data_file Circus_CubeMap_V.png] -vrenderparams -shadingModel PBR - -vlight -clear -vlight -add ambient - -Close D -silent -ReadGltf D [locate_data_file bug31302_NormalTangentTest.gltf] -XDisplay -dispmode 1 D - -vfront -vfit -vdump $imagedir/${casename}_front.png - -vback -vdump $imagedir/${casename}_back.png diff --git a/tests/opengl/data/transparency/ior b/tests/opengl/data/transparency/ior deleted file mode 100644 index 1dd6f66da8..0000000000 --- a/tests/opengl/data/transparency/ior +++ /dev/null @@ -1,51 +0,0 @@ -puts "========" -puts "0031284: Visualization - XCAFDoc_VisMaterialPBR lacks Index of Refraction" -puts "========" - -pload MODELING XDE OCAF VISUALIZATION -if { $::tcl_platform(os) == "Darwin" } { vcaps -core } - -box b 0.5 1.0 -0.5 3 1 1 -psphere s1 0.5 -psphere s2 0.5 -psphere s3 0.5 -ttranslate s1 1 0 0 -ttranslate s2 2 0 0 -ttranslate s3 3 0 0 -Close D -silent -XNewDoc D -set l0 [XAddShape D b 0] -set l1 [XAddShape D s1 0] -set l2 [XAddShape D s2 0] -set l3 [XAddShape D s3 0] -XAddVisMaterial D m1 -baseColor GREEN -refractionIndex 1.0 -transparency 0.5 -metallic 0 -roughness 0 -XAddVisMaterial D m2 -baseColor GREEN -refractionIndex 1.3 -transparency 0.5 -metallic 0 -roughness 0 -XAddVisMaterial D m3 -baseColor GREEN -refractionIndex 2.5 -transparency 0.5 -metallic 0 -roughness 0 -XSetVisMaterial D $l1 m1 -XSetVisMaterial D $l2 m2 -XSetVisMaterial D $l3 m3 - -vclear -vinit View1 -vcamera -persp -vfront -XDisplay -dispMode 1 D -vfit -vviewparams -scale 245 -proj -0 -0.75 -0.66 -up 0 -0.66 0.75 -at 2.0 0.84 0.04 -vlight -change 0 -intensity 2.5 -vlight -change 1 -intensity 1.0 -set aCubeMap [locate_data_file Circus_CubeMap_V.png] -vbackground -cubemap $aCubeMap - -vrenderparams -shadingModel PBR -raster -vdump $imagedir/${casename}_pbr.png - -if { ![string match "OpenGL ES 2.0*" [vglinfo VERSION]] && ![string match "OpenGL ES 3.0*" [vglinfo VERSION]] } { - vrenderparams -raytrace -gi 0 -reflections 1 -rayDepth 10 - vfps 200 - vdump $imagedir/${casename}_rt.png - - vrenderparams -raytrace -gi 1 - vfps 200 - vdump $imagedir/${casename}_pt.png -} diff --git a/tests/perf/fclasses/strtod b/tests/perf/fclasses/strtod index 50a7369a71..71f52cb4cc 100644 --- a/tests/perf/fclasses/strtod +++ b/tests/perf/fclasses/strtod @@ -3,6 +3,8 @@ puts "Testing performance of Strtod() vs. standard strtod()" puts "=================================================================" puts "" +puts "TODO ?CR33225 Linux: is expected to be at least " + pload QAcommands # Check that performance of Strtod() and Atof() is at least twice better diff --git a/tests/pipe/bugs/bug32818 b/tests/pipe/bugs/bug32818 new file mode 100644 index 0000000000..46011451ba --- /dev/null +++ b/tests/pipe/bugs/bug32818 @@ -0,0 +1,18 @@ +puts "========" +puts "0032818: Modeling Algorithms - Result of sweep operation is invalid" +puts "========" +puts "" + +restore [locate_data_file bug32818.brep] +explode bug32818 +renamevar bug32818_1 p +renamevar bug32818_2 pr + +mksweep p +setsweep -CF +addsweep pr + +buildsweep result -R -S + +checkshape result +checknbshapes result -vertex 80 -edge 160 -wire 80 -face 80 -shell 1 -solid 1 \ No newline at end of file diff --git a/tests/tools/begin b/tests/tools/begin deleted file mode 100644 index 562c9109d9..0000000000 --- a/tests/tools/begin +++ /dev/null @@ -1,3 +0,0 @@ -if { [array get Draw_Groups "TOOLS Check commands"] == "" } { - pload TOOLS -} diff --git a/tests/tools/dfbrowser/A1 b/tests/tools/dfbrowser/A1 deleted file mode 100644 index 0c636d3e33..0000000000 --- a/tests/tools/dfbrowser/A1 +++ /dev/null @@ -1,12 +0,0 @@ -pload DCAF -pload INSPECTOR - -NewDocument Doc BinOcaf - -set aSetAttr1 100 -set aLabel 0:2 -SetInteger Doc ${aLabel} ${aSetAttr1} - -tinspector -plugins dfbrowser -tinspector -update - diff --git a/tests/tools/dfbrowser/A2 b/tests/tools/dfbrowser/A2 deleted file mode 100644 index e138425ac3..0000000000 --- a/tests/tools/dfbrowser/A2 +++ /dev/null @@ -1,23 +0,0 @@ -pload DCAF VISUALIZATION INSPECTOR - -NewDocument D BinOcaf -tinspector -plugins dfbrowser - -cpulimit 300 -UndoLimit D 100 - -NewCommand D - -NewCommand D - -set B2 [AddObject D] -set F2 [AddFunction D $B2 Box] -BoxDX D $B2 190 -BoxDY D $B2 290 -BoxDZ D $B2 390 - -InitLogBook D -AddDriver D Box Attach Cyl -ComputeFun D $F2 - -tinspector -update diff --git a/tests/tools/dfbrowser/A3 b/tests/tools/dfbrowser/A3 deleted file mode 100644 index 8e83cd5b23..0000000000 --- a/tests/tools/dfbrowser/A3 +++ /dev/null @@ -1,2 +0,0 @@ -pload INSPECTOR -tinspector -plugins dfbrowser -open $env(CSF_OCCTDataPath)/step/screw.step -select 0:1:1:1 diff --git a/tests/tools/dfbrowser/A4 b/tests/tools/dfbrowser/A4 deleted file mode 100644 index a761268241..0000000000 --- a/tests/tools/dfbrowser/A4 +++ /dev/null @@ -1,150 +0,0 @@ -pload DCAF INSPECTOR TOPTEST - -# Create the first document and set UndoLimit -NewDocument Doc1 BinOcaf -UndoLimit Doc1 100 - -# Add an attribute to a data framework -set aSetAttr1 100 -set aLabel 0:2 -SetInteger Doc1 ${aLabel} ${aSetAttr1} - - -# Create the second document -set test_name "OCC26961" -set test_int 123 -set test_real 123.456e-7 -set test_int_arr {10 20} -set test_real_arr {1.1 3.14 5.4e18} -set test_extstr_arr {"sample string 1" "string 2"} -set test_bool_arr {0 1} -set test_ref_arr {"0:1:2:3:2" "0:1:2:3:1"} -set test_byte_arr {15 25} -set test_map {1 5 2 10} -set test_map_sorted {1 2 5 10} -set test_named_ints {i1 1 i2 2} -set test_named_reals {r1 1.1 r2 2.2} -set test_named_strings {s1 string1 s2 string2 s3 string3_string_extended s4 string4_double_extended s5 string5} -set test_named_bytes {b1 65 b2 66} -set test_ref "0:1:1" -set test_guid "00000000-0000-0000-2222-000000000000" -set test_comment "Sample document containing various attributes" -set test_string "Sample string" -set test_expr "2*pi*r" -set test_var1 "0:1:2:3:2" -set test_var2 "0:1:2:3:1" -set test_point "111 222 333" -set test_axisPos "10 10 30" -set test_axisDir "11 22 33" -set test_plane "15 25 35" -set test_boxXYZ "10 20 30" -set test_boxDX 100 -set test_boxDY 200 -set test_boxDZ 300 -set test_geom_t "cir" -set test_failure 1 -set test_driver "G" -set test_driver_id "2a96b604-ec8b-11d0-bee7-080009dc3333" -set test_transp 0.5 -set test_color AQUAMARINE4 -set test_material 22 -set test_positionX 100 -set test_positionY 200 -set test_positionZ 300 - -puts "Creating document" -NewDocument D BinOcaf - -# Simple values -SetInteger D 0:1:1 $test_int -SetReal D 0:1:1 $test_real -SetName D 0:1:1 $test_name -SetComment D 0:1:1 $test_comment -SetAsciiString D 0:1:1 $test_string - -# TagSource -SetTagger D 0:1:2 - -# Reference -SetReference D 0:1:3 $test_ref - -# Directory -#NewDirectory D 0:1:2:1 - -# UAttribute -#SetUAttribute D 0:1:2:2 $test_guid - -# Variable -SetVariable D $test_var2 0 mm -SetVariable D $test_var1 1 "" - -# Relation -SetRelation D 0:1:2:3 "2*pi*r" $test_var1 $test_var2 - -# TreeNode -SetNode D 0:1:2:4 - -# Arrays -eval SetIntArray D 0:1:1 1 1 2 $test_int_arr -eval SetRealArray D 0:1:1 1 1 3 $test_real_arr -eval SetExtStringArray D 0:1:1 1 1 2 $test_extstr_arr -eval SetRefArray D 0:1:1 1 2 $test_ref_arr -eval SetByteArray D 0:1:1 1 1 2 $test_byte_arr - -# Lists -eval SetIntegerList D 0:1:1 $test_int_arr -eval SetRealList D 0:1:1 $test_real_arr -eval SetExtStringList D 0:1:1 $test_extstr_arr -eval SetBooleanList D 0:1:1 $test_bool_arr -eval SetReferenceList D 0:1:1 $test_ref_arr - -# IntPackedMap -eval SetIntPackedMap D 0:1:1 1 $test_map - -# NamedData -eval SetNDataIntegers D 0:1:4 2 $test_named_ints -eval SetNDataReals D 0:1:4 2 $test_named_reals -eval SetNDataStrings D 0:1:4 5 $test_named_strings -eval SetNDataBytes D 0:1:4 2 $test_named_bytes -eval SetNDataIntArrays D 0:1:4 ia 2 $test_int_arr -eval SetNDataRealArrays D 0:1:4 ra 3 $test_real_arr - -# NamedShape -eval box Box $test_boxXYZ $test_boxDX $test_boxDY $test_boxDZ -SetShape D 0:1:6 Box - -# Point -eval point Point $test_point -SetPoint D 0:1:5:1 Point - -# Axis -eval line Axis $test_axisPos $test_axisDir -SetAxis D 0:1:5:2 Axis - -# Plane -eval plane Plane $test_plane -SetPlane D 0:1:5:3 Plane - -# Geometry -SetGeometry D 0:1:6 $test_geom_t - -# Constraint -SetConstraint D 0:1:1 equal 0:1:6 - -# PatternStd -SetPattern D 0:1:1 5 0:1:6 - -# Function -SetFunction D 0:1:1 $test_guid $test_failure - -# AISPresentation -AISInitViewer D -AISSet D 0:1:1 $test_driver -AISTransparency D 0:1:1 $test_transp -AISColor D 0:1:1 $test_color -AISMaterial D 0:1:1 $test_material - -# Position -SetPosition D 0:1:1 $test_positionX $test_positionY $test_positionZ - -tinspector -plugins dfbrowser diff --git a/tests/tools/dfbrowser/A5 b/tests/tools/dfbrowser/A5 deleted file mode 100644 index 6fdadd115b..0000000000 --- a/tests/tools/dfbrowser/A5 +++ /dev/null @@ -1,78 +0,0 @@ -pload TOPTEST -pload VISUALIZATION -pload XDE -pload QAcommands -pload DCAF - -set Test "TNaming_Builder test" -set IsDone 1 -set TestError "" - -puts "Creating document" -NewDocument D MDTV-Standard -set TestLab 0:1 - -#################### PRIMITIVE EVOLUTION #################### -box b 100 200 300 - -explode b E -if {[catch {BuildNamedShape D $TestLab:1 PRIMITIVE b}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build solid as primitive" -} -if {[catch {BuildNamedShape D [set TestLab]:1:1 PRIMITIVE b_1}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build edge as alone primitive" -} -if {[catch {BuildNamedShape D [set TestLab]:1:1 PRIMITIVE b_1 b_2 b_3}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build several edges as primitive over the old one" -} -if {[catch {BuildNamedShape D [set TestLab]:1:2 PRIMITIVE b_4 b_5 b_6}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build several edges as primitive" -} - - -#################### GENERATED EVOLUTION #################### -box b2 200 300 400 -explode b2 F -if {[catch {BuildNamedShape D $TestLab:2 GENERATED b b2}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build solid as generation" -} -if {[catch {BuildNamedShape D [set TestLab]:2:1 GENERATED b_1 b2_1}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as alone generation" -} -if {[catch {BuildNamedShape D [set TestLab]:2:2 GENERATED b_2 b2_2 b_2 b2_3 b_3 b2_4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as generation n:m" -} -if {[catch {BuildNamedShape D [set TestLab]:2:1 GENERATED b_3 b2_1 b_3 b2_3 b_4 b2_4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as generation n:m to the exists named shape" -} - -#################### MODIFY EVOLUTION #################### -box b3 300 400 500 -explode b3 F -if {[catch {BuildNamedShape D $TestLab:3 MODIFY b2 b3}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build solid as modification" -} -if {[catch {BuildNamedShape D [set TestLab]:3:1 MODIFY b2_1 b3_1}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as alone modification" -} -if {[catch {BuildNamedShape D [set TestLab]:3:2 MODIFY b2_5 b3_2 b2_2 b3_3 b2_3 b3_4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as modification n:m" -} -if {[catch {BuildNamedShape D [set TestLab]:3:1 MODIFY b2_3 b3_1 b_3 b3_3 b2_4 b3_4}] == 1} { - set IsDone 0 - set TestError "$TestError # Can't build face as modification n:m to the exists named shape" -} - -pload INSPECTOR -tinspector -select 0:1:3:2 TNaming_NamedShape diff --git a/tests/tools/dfbrowser/A6 b/tests/tools/dfbrowser/A6 deleted file mode 100644 index 7395f50e98..0000000000 --- a/tests/tools/dfbrowser/A6 +++ /dev/null @@ -1,76 +0,0 @@ -pload DCAF - -chrono qat start -# Create a new document and set UndoLimit -NewDocument D BinOcaf - -#NewDocument D -cpulimit 300 -UndoLimit D 100 - -# Open a transaction -NewCommand D - -puts "caf005-I3" -set QA_DUP 0 - -# Add an attribute to a data framework -set aLabel_Root 0:2 -set aName_Root Label_1 -Label D ${aLabel_Root} -SetName D ${aLabel_Root} ${aName_Root} - -set aName1 Label_1_1 -###set aChild1 [NewChild D ${aLabel_Root}] -set aChild1 0:2:1 -Label D ${aChild1} -SetName D ${aChild1} ${aName1} - -set aName2 Label_1_2 -###set aChild2 [NewChild D ${aLabel_Root}] -set aChild2 0:2:2 -Label D ${aChild2} -SetName D ${aChild2} ${aName2} - -set aName3 Label_1_1_1 -###set aChild3 [NewChild D ${aLabel_Root}] -set aChild3 0:2:3 -Label D ${aChild3} -SetName D ${aChild3} ${aName3} - -set aName4 Label_1_1_2 -###set aChild4 [NewChild D ${aLabel_Root}] -set aChild4 0:2:4 -Label D ${aChild4} -SetName D ${aChild4} ${aName4} - -set aName5 Label_1_1_3 -###set aChild5 [NewChild D ${aLabel_Root}] -set aChild5 0:2:5 -Label D ${aChild5} -SetName D ${aChild5} ${aName5} - -set aName6 Label_1_2_1 -###set aChild6 [NewChild D ${aLabel_Root}] -set aChild6 0:2:6 -Label D ${aChild6} -SetName D ${aChild6} ${aName6} - -set aName7 Label_1_2_2 -###set aChild7 [NewChild D ${aLabel_Root}] -set aChild7 0:2:7 -Label D ${aChild7} -SetName D ${aChild7} ${aName7} - -SetNode D ${aLabel_Root} -AppendNode D ${aLabel_Root} ${aChild1} -AppendNode D ${aLabel_Root} ${aChild2} -AppendNode D ${aChild1} ${aChild3} -AppendNode D ${aChild1} ${aChild4} -AppendNode D ${aChild1} ${aChild5} -AppendNode D ${aChild2} ${aChild6} -AppendNode D ${aChild2} ${aChild7} - -pload INSPECTOR - -tinspector -plugins dfbrowser -select 0:2:6 TDataStd_TreeNode diff --git a/tests/tools/dfbrowser/A7 b/tests/tools/dfbrowser/A7 deleted file mode 100644 index 1e835f2e63..0000000000 --- a/tests/tools/dfbrowser/A7 +++ /dev/null @@ -1,6 +0,0 @@ -puts "========" -puts "0029743: Samples - Inspector tool - crash by selecting TNaming_UsedShapes tree item" -puts "========" - -pload INSPECTOR -tinspector -plugins dfbrowser -open [locate_data_file bug29743.cbf] -select 0 TNaming_UsedShapes diff --git a/tests/tools/dfbrowser/A8 b/tests/tools/dfbrowser/A8 deleted file mode 100644 index c6c2e6d93f..0000000000 --- a/tests/tools/dfbrowser/A8 +++ /dev/null @@ -1,7 +0,0 @@ -puts "========" -puts "0029733: TInspector can't open several cbf files" -puts "========" - -pload INSPECTOR -tinspector -plugins dfbrowser -open [locate_data_file bug29743.cbf] -tinspector -open [locate_data_file bug29733.cbf] diff --git a/tests/tools/dfbrowser/A9 b/tests/tools/dfbrowser/A9 deleted file mode 100644 index 701be36d29..0000000000 --- a/tests/tools/dfbrowser/A9 +++ /dev/null @@ -1,12 +0,0 @@ -puts "========" -puts "0029841: Test cases from tools/dfbrowser periodically hang on Windows platform" -puts "========" - -pload INSPECTOR - -tinspector -plugins dfbrowser - -for { set i 1 } { ${i} <= 10 } { incr i } { - tinspector -open [locate_data_file bug29743.cbf] -select 0 TNaming_UsedShapes - tinspector -open [locate_data_file bug29733.cbf] -select 0 TNaming_UsedShapes -} diff --git a/tests/tools/end b/tests/tools/end deleted file mode 100644 index 57901e2abe..0000000000 --- a/tests/tools/end +++ /dev/null @@ -1,2 +0,0 @@ -# to end a test script -puts "TEST COMPLETED" diff --git a/tests/tools/grids.list b/tests/tools/grids.list deleted file mode 100644 index c8ade14958..0000000000 --- a/tests/tools/grids.list +++ /dev/null @@ -1,3 +0,0 @@ -001 dfbrowser -001 shapeview -001 vinspector diff --git a/tests/tools/parse.rules b/tests/tools/parse.rules deleted file mode 100644 index 396c2d9c2e..0000000000 --- a/tests/tools/parse.rules +++ /dev/null @@ -1,3 +0,0 @@ -SKIPPED /Draw_Failure: Could not open: TKToolsDraw/ OCCT built without Qt tools -FAILED /\bFaulty\b/ bad shape -OK /Relative error of mass computation/ message from vprops \ No newline at end of file diff --git a/tests/tools/shapeview/A1 b/tests/tools/shapeview/A1 deleted file mode 100644 index 5093256077..0000000000 --- a/tests/tools/shapeview/A1 +++ /dev/null @@ -1,11 +0,0 @@ -pload ALL INSPECTOR - -tinspector -plugins shapeview - -box b1 200 100 120 -tinspector -shape b1 - -box b2 100 200 220 100 120 100 -tinspector -shape b2 - -tinspector -activate shapeview -select b1 diff --git a/tests/tools/shapeview/A2 b/tests/tools/shapeview/A2 deleted file mode 100644 index 0e78f445b9..0000000000 --- a/tests/tools/shapeview/A2 +++ /dev/null @@ -1,5 +0,0 @@ -pload ALL INSPECTOR - -tinspector -plugins shapeview - -tinspector -open $env(CSF_OCCTDataPath)/occ/solid.brep shapeview diff --git a/tests/tools/vinspector/A1 b/tests/tools/vinspector/A1 deleted file mode 100644 index abc11f94f7..0000000000 --- a/tests/tools/vinspector/A1 +++ /dev/null @@ -1,18 +0,0 @@ -pload ALL INSPECTOR - -tinspector -plugins vinspector - -vinit - -box box_1 0 0 200 100 100 100 -vdisplay box_1 -vselmode box_1 1 1 -vselmode box_1 3 1 - -box box_2 180 120 200 150 150 150 -vdisplay box_2 - -vfit - -tinspector -update -select box_1 - diff --git a/tests/tools/vinspector/A2 b/tests/tools/vinspector/A2 deleted file mode 100644 index 54c60660ff..0000000000 --- a/tests/tools/vinspector/A2 +++ /dev/null @@ -1,9 +0,0 @@ -pload ALL INSPECTOR - -tinspector -plugins vinspector - -vinit - -tinspector -open $env(CSF_OCCTDataPath)/occ/solid.brep -vfit - diff --git a/tests/v3d/bugs/bug25760_2 b/tests/v3d/bugs/bug25760_2 deleted file mode 100644 index 39f34661fe..0000000000 --- a/tests/v3d/bugs/bug25760_2 +++ /dev/null @@ -1,118 +0,0 @@ -puts "============" -puts "CR25760: Visualization - precision factor added to ZNear, ZFar in method ZFitAll() of Graphic3d_Camera is not enough" -puts "============" -puts "" - -pload MODELING VISUALIZATION -vinit View1 w=409 h=409 -vclear - -vclear -vautozfit 0 - -proc test3d {dstart} { - - set proj1 { 0.47243081629544409 -0.39335870920278265 -0.78871924644244684} - set proj2 {-0.31828216872577886 0.17649241059446089 -0.93142197208020105} - - for {set i 1} {$i <= 3} {incr i} { - for {set r 1} {$r <= 3} {incr r} { - - set x [expr pow(100, $i)] - set y [expr pow( 70, $i)] - set z [expr pow( 50, $i)] - set dist [expr pow(100, $r)] - - vclear - vertex v0 $x $y $z - vertex v1 [expr "$x + ($dist * [lindex $proj1 0])"] [expr "$y + ($dist * [lindex $proj1 1])"] [expr "$z + ($dist * [lindex $proj1 2])"] - vertex v2 [expr "$x + ($dist * [lindex $proj2 0])"] [expr "$y + ($dist * [lindex $proj2 1])"] [expr "$z + ($dist * [lindex $proj2 2])"] - - for {set d [expr $dstart * {max ($x,$y,$z,$dist)}]} {$d <= 1e7} {set d [expr "abs ($d) * 1.2E5"]} { - for {set p 1} {$p <= 2} {incr p} { - set proj [set proj$p] - - vremove -all - vdisplay v0 - vdisplay v$p - vviewparams -eye [expr "$x - ($d * [lindex $proj 0])"] [expr "$y - ($d * [lindex $proj 1])"] [expr "$z - ($d * [lindex $proj 2])"] -at $x $y $z - vzfit - - vremove -all - vdisplay v0 - if { [checkcolor 204 204 1 1 0] != 1 } { - puts "Error: 3D projection test failed with the following parameters:" - vviewparams - vzrange - puts "" - puts "v1 x: $x" - puts "v1 y: $y" - puts "v1 z: $z" - puts "v2 x: [expr $x + ($dist * [lindex $proj 0])]" - puts "v2 y: [expr $y + ($dist * [lindex $proj 1])]" - puts "v2 z: [expr $z + ($dist * [lindex $proj 2])]" - puts "" - return 0 - } - - vremove -all - vdisplay v$p - if { [checkcolor 204 204 1 1 0] != 1 } { - puts "Error: 3D projection test failed with the following parameters:" - vviewparams - vzrange - puts "" - puts "v1 x: $x" - puts "v1 y: $y" - puts "v1 z: $z" - puts "v2 x: [expr $x + ($dist * [lindex $proj 0])]" - puts "v2 y: [expr $y + ($dist * [lindex $proj 1])]" - puts "v2 z: [expr $z + ($dist * [lindex $proj 2])]" - puts "" - return 0 - } - } - } - } - } - return 1 -} - -set tcl_precision 16 - -#################################################################### -# Test orthographic camera without frustum culling. # -# Test camera with scale 1E-8 to avoid jittering. # -#################################################################### -vcamera -ortho -vviewparams -scale 1e-8 -vrenderparams -frustumculling off -if { [test3d 1e-7] != 1 } { puts "Error: 3D projection test failed: camera is orthographic, view frustum culling is OFF" } - -#################################################################### -# Test orthographic camera with frustum culling. # -# Test camera with scale 1E-8 to avoid jittering. # -#################################################################### -vcamera -ortho -vviewparams -scale 1e-8 -vrenderparams -frustumculling on - -if { [test3d 1e-7] != 1 } { - puts "Error: 3D projection test failed: camera is orthographic, view frustum culling is ON" -} - -#################################################################### -# Test perspective camera without frustum culling. # -# Test camera with less starting distance 1.0 to avoid jittering. # -#################################################################### -vcamera -persp -vrenderparams -frustumculling off -if { [test3d 1.0] != 1 } { puts "Error: 3D projection test failed: camera is perspective, view frustum culling is OFF" } - -#################################################################### -# Test perspective camera with frustum culling. # -# Test camera with less starting distance 1.0 to avoid jittering. # -#################################################################### -vcamera -persp -vrenderparams -frustumculling on -if { [test3d 1.0] != 1 } { puts "Error: 3D projection test failed: camera is perspective, view frustum culling is ON" } diff --git a/tests/v3d/bugs/bug25853 b/tests/v3d/bugs/bug25853 deleted file mode 100644 index ad187c10ef..0000000000 --- a/tests/v3d/bugs/bug25853 +++ /dev/null @@ -1,50 +0,0 @@ -puts "==========" -puts "OCC25853: Edges disappear or reappear when displaying new edges" -puts "==========" -puts "" - -pload MODELING VISUALIZATION -vinit View1 w=1024 h=1024 -vsetdispmode View1 1 -vclear - -#vtop -set scale 0.086865724500890112 -set vpprojx 0.0 -set vpprojy 0.0 -set vpprojz 1.0 -set vpupx 0.0 -set vpupy 1.0 -set vpupz 0.0 -set vpatx 4995 -set vpaty 500 -set vpatz 0 -set vpeyex 4995 -set vpeyey 500 -set vpeyez 0.0001 -vviewparams -scale $scale -eye $vpeyex $vpeyey $vpeyez -at $vpatx $vpaty $vpatz -up $vpupx $vpupy $vpupz -proj $vpprojx $vpprojy $vpprojz - -set NB 1000 - -proc draw_lines {{distance 10.0}} { - # set colors to corner spheres - for {set i 0} {$i < $::NB} {incr i} { - set x [expr $i * $distance] - set ya 0.0 - set yb 1000.0 - set z 0.0 - vertex v1 $x $ya $z - vertex v2 $x $yb $z - edge e$i v1 v2 - vdisplay -update e$i - puts "$i: $x $ya $yb $z" - } -} - -puts "Start test lines" -draw_lines 10.0 - -checkcolor 804 483 1 0 0 -checkcolor 860 500 1 0 0 - -vdump $imagedir/${casename}.png diff --git a/tests/v3d/bugs/bug30434 b/tests/v3d/bugs/bug30434 deleted file mode 100644 index e1ebfa8441..0000000000 --- a/tests/v3d/bugs/bug30434 +++ /dev/null @@ -1,43 +0,0 @@ -puts "=============" -puts "0030434: Visualization, TKV3d - add 'NoUpdate' state of frustum culling optimization" -puts "=============" - -pload VISUALIZATION -vclear -vinit View1 - -set THE_NB_POINTS 10 -puts "Creating [expr $THE_NB_POINTS * $THE_NB_POINTS * $THE_NB_POINTS] points..." -for {set i 0} {$i < $THE_NB_POINTS} {incr i} { - for {set j 0} {$j < $THE_NB_POINTS} {incr j} { - for {set k 0} {$k < $THE_NB_POINTS} {incr k} { - vpoint p$i$j$k 3.*$i 3.*$j 3.*$k - } - } -} - -vcamera -ortho -vfront -vfit -vzoom 2 -vrenderparams -frustumculling on -vrenderparams -frustumculling noupdate -vfit -if { [vreadpixel 92 92 rgb name] == "YELLOW" } { puts "Error: point should be clipped earlier" } -vdump $::imagedir/${::casename}_ortho_culled.png -vrenderparams -frustumculling off -if { [vreadpixel 92 92 rgb name] != "YELLOW" } { puts "Error: point should NOT be clipped" } -vdump $::imagedir/${::casename}_ortho_all.png - -vcamera -persp -vaxo -vfit -vzoom 3 -vrenderparams -frustumculling on -vrenderparams -frustumculling noupdate -vfit -if { [vreadpixel 114 92 rgb name] == "YELLOW" } { puts "Error: point should be clipped earlier" } -vdump $::imagedir/${::casename}_persp_culled.png -vrenderparams -frustumculling off -if { [vreadpixel 114 92 rgb name] != "YELLOW" } { puts "Error: point should NOT be clipped" } -vdump $::imagedir/${::casename}_persp_all.png diff --git a/tests/v3d/bugs/bug30437_1 b/tests/v3d/bugs/bug30437_1 deleted file mode 100644 index 39e8aab967..0000000000 --- a/tests/v3d/bugs/bug30437_1 +++ /dev/null @@ -1,32 +0,0 @@ -puts "=============" -puts "0030437: Visualization, TKV3d - add Draw command to print rendering statistics" -puts "=============" - -pload MODELING VISUALIZATION -vclear -vinit View1 - -set THE_NB_POINTS 10 -puts "Creating [expr $THE_NB_POINTS * $THE_NB_POINTS * $THE_NB_POINTS] points..." -for {set i 0} {$i < $THE_NB_POINTS} {incr i} { - for {set j 0} {$j < $THE_NB_POINTS} {incr j} { - for {set k 0} {$k < $THE_NB_POINTS} {incr k} { - vpoint p$i$j$k 3.*$i 3.*$j 3.*$k - } - } -} - -vcamera -ortho -vfront -vfit -vzoom 2 -set aPointsNb_1 [vstatprofiler points] -if [expr $aPointsNb_1 != 160] { puts "Error: unexpected number of not culled points 1" } - -vcamera -persp -vaxo -vfit -vzoom 3 -set aPointsNb_2 [vstatprofiler points] -if [expr $aPointsNb_2 != 307] { puts "Error: unexpected number of not culled points 2" } -vdump $imagedir/${casename}.png diff --git a/tests/v3d/materials/pbr1 b/tests/v3d/materials/pbr1 deleted file mode 100644 index 384f1bead5..0000000000 --- a/tests/v3d/materials/pbr1 +++ /dev/null @@ -1,16 +0,0 @@ -# PBR requires OpenGL 3.0+ on macOS -pload VISUALIZATION -pload OPENGL -if { $::tcl_platform(os) == "Darwin" } { vcaps -core } - -source $env(CSF_OCCTSamplesPath)/tcl/materials.tcl -vlight -change 0 -intensity 5 -vrenderparams -shadingModel PBR -msaa 0 -vdump $imagedir/${casename}_default.png - -set aCubeMap [locate_data_file Circus_CubeMap_V.png] -vbackground -cubemap $aCubeMap -vdump $imagedir/${casename}_env.png - -vbackground -cubemap $aCubeMap -invertedz -vdump $imagedir/${casename}_env_iz.png diff --git a/tests/v3d/memory/bug172 b/tests/v3d/memory/bug172 deleted file mode 100644 index dacd99c8de..0000000000 --- a/tests/v3d/memory/bug172 +++ /dev/null @@ -1,25 +0,0 @@ -puts "========" -puts "OCC172" -puts "========" - -pload XDE VISUALIZATION QAcommands - -# disable VBO to avoid false memory leaks reported on NVIDIA graphics, see issue #29996 -pload OPENGL -vcaps -vbo 0 - -vinit View1 -restore [locate_data_file OCC162.brep] s -vdisplay s - -set listmem {} -set i_max 10 -for {set i 1} {${i} <= ${i_max}} {incr i} { - # select shape - OCC172 - # deselect shape - OCC172 - - lappend listmem [meminfo h] - checktrend $listmem 0 1 "Memory leak detected" -} diff --git a/tests/v3d/memory/bug26538 b/tests/v3d/memory/bug26538 deleted file mode 100644 index ea409df48f..0000000000 --- a/tests/v3d/memory/bug26538 +++ /dev/null @@ -1,26 +0,0 @@ -puts "============" -puts "OCC26538: Visualization - Infinite growth of maxtrix stack in OpenGl_Structure::Render" -puts "============" -puts "" - -pload MODELING VISUALIZATION -box b1 1 1 1 -box b2 1 1 1 - -vclear -vinit View1 -vdisplay b1 b2 -vsetlocation b2 10 10 10 -vfit - -set listmem {} -set aNbChecks 50 -for {set anIter 1} {$anIter <= $aNbChecks} {incr anIter} { - vfps 100 - lappend listmem [meminfo h] - #checktrend $listmem 0 1 "Memory leak detected" -} -puts $listmem - -checktrend $listmem 0 1 "Memory leak detected" -vdump ${imagedir}/${casename}.png diff --git a/tests/v3d/memory/bug29412 b/tests/v3d/memory/bug29412 deleted file mode 100644 index b82d855ab7..0000000000 --- a/tests/v3d/memory/bug29412 +++ /dev/null @@ -1,28 +0,0 @@ -puts "# ===================================================================" -puts "# 0029412: Huge Memory leak since I upgraded to OC 6.9.0" -puts "# ===================================================================" -puts "" - -pload VISUALIZATION QAcommands -pload OPENGL -vcaps -vsync 0 -vinit View1 -vglinfo - -OCC29412 100 ;# just to initialize - -meminfo -vmemgpu - -set heap_before [meminfo heap] -OCC29412 -set heap_after [meminfo heap] - -meminfo -vmemgpu - -# check that memory increase is moderate: can be up to 75 KiB on Debian; -# note that the leak in OCCT 6.9.0 - 7.0.0 was ~ 19 MiB -if { $heap_after - $heap_before > 100 * 1024 } { - puts "Error: memory leak of [expr ($heap_after - $heap_before) / 1024] KiB" -} diff --git a/tests/v3d/trsf/bug24623_3 b/tests/v3d/trsf/bug24623_3 deleted file mode 100644 index 46dd910329..0000000000 --- a/tests/v3d/trsf/bug24623_3 +++ /dev/null @@ -1,44 +0,0 @@ -puts "============" -puts "OCC24623_3: Visualization - improve selection mechanism" -puts "Tests memory leaks in creation of selection primitives for connected interactive objects:" -puts "checks that there is no 'dead links' in removing Select3D_BVHPrimitiveContent" -puts "============" -puts "" - -pload MODELING VISUALIZATION -psphere s 0.5 -tclean s -incmesh s 0.001 -trinfo s - -set aMemInit [meminfo h] -set aNb 1000 - -# display as copies -eval compound [lrepeat $aNb s] ss -explode ss -for {set i 1} {$i <= $aNb} {incr i} { vloadselection ss_${i}; vsetlocation -noupdate ss_${i} ${i} 0 0 } -vfit -set aMemSel1 [meminfo h] -vclear -set aMemClear1 [meminfo h] - -# display as connected instances of single presentation -vconnectto i_1 0 0 0 s -nodisplay -vloadselection i_1 -for {set i 2} {$i < $aNb} {incr i} { vconnectto i_${i} ${i} 0 0 i_1 -nodisplay; vloadselection i_${i} } -set aMemSel2 [meminfo h] -vclear -set aMemClear2 [meminfo h] - -puts "Initial memory : [expr $aMemInit / (1024 * 1024)] MiB" -puts "Compute selection (simple) : [expr $aMemSel1 / (1024 * 1024)] MiB" -puts "Clearing (simple) : [expr $aMemClear1 / (1024 * 1024)] MiB" -puts "Compute selection (connected): [expr $aMemSel2 / (1024 * 1024)] MiB" -puts "Clearing (connected) : [expr $aMemClear2 / (1024 * 1024)] MiB" - -set aRatio [expr $aMemClear2 / double($aMemClear1)] - -# check if the memory difference is greater than 10% -if {[expr $aRatio > 1.1]} { puts "Error : TEST FAILED" } -vdump $imagedir/${casename}.png diff --git a/tests/v3d/trsf/bug24623_4 b/tests/v3d/trsf/bug24623_4 deleted file mode 100644 index 997603f3ce..0000000000 --- a/tests/v3d/trsf/bug24623_4 +++ /dev/null @@ -1,37 +0,0 @@ -puts "============" -puts "OCC24623_4: Visualization - improve selection mechanism" -puts "Tests memory leaks in creation of selection primitives for connected interactive objects:" -puts "checks that there is no 'dead links' to reference interactives after its clearing" -puts "============" -puts "" - -pload MODELING VISUALIZATION -psphere s 0.5 -tclean s -incmesh s 0.001 -trinfo s -vinit -vclear - -set aMemInit [meminfo h] -set anIterNb 100 - -for {set anIterCount 0} {$anIterCount < $anIterNb} {incr anIterCount} { - set aNb 11 - - vconnectto i_1 0 0 0 s -nodisplay - vloadselection i_1 - for {set i 2} {$i < $aNb} {incr i} { vconnectto i_${i} ${i} 0 0 i_1 -nodisplay; vloadselection i_${i} } - vclear -} - -set aMemClear [meminfo h] - -puts "Initial memory : [expr $aMemInit / (1024 * 1024)] MiB" -puts "Clearing : [expr $aMemClear / (1024 * 1024)] MiB" - -set aRatio [expr $aMemClear / double($aMemInit)] - -# check if the memory difference is greater than 20% -if {[expr $aRatio > 1.2]} { puts "Error : TEST FAILED" } -vdump $imagedir/${casename}.png diff --git a/tests/v3d/trsf/bug25532 b/tests/v3d/trsf/bug25532 deleted file mode 100644 index 4f24614136..0000000000 --- a/tests/v3d/trsf/bug25532 +++ /dev/null @@ -1,50 +0,0 @@ -puts "============" -puts "OCC25532: Visualization - fix cross-references between AIS_ConnectedInteractive and connected presentation" -puts "============" -puts "" - -pload MODELING VISUALIZATION -pload OPENGL -psphere s 0.5 -tclean s -incmesh s 0.001 -trinfo s - -vclear -vinit View1 -vaxo -vcaps -vbo 0 -vsetdispmode 1 -vdefaults -absDefl 1.0 -vselprops -autoactivate 0 - -set aMemInit [meminfo h] -set aNb 1000 - -# display as copies -eval compound [lrepeat $aNb s] ss -explode ss -for {set i 1} {$i <= $aNb} {incr i} { vdisplay -noupdate ss_${i}; vsetlocation -noupdate ss_${i} ${i} 0 0 } -vfit -set aMemDisp1 [meminfo h] -vclear -set aMemClear1 [meminfo h] - -# display as connected instances of single presentation -vconnectto i_1 0 0 0 s -for {set i 2} {$i < $aNb} {incr i} { vconnectto i_${i} ${i} 0 0 i_1 } -set aMemDisp2 [meminfo h] -vclear -set aMemClear2 [meminfo h] - -puts "Initial memory: [expr $aMemInit / (1024 * 1024)] MiB" -puts "Displaying (simple): [expr $aMemDisp1 / (1024 * 1024)] MiB" -puts "Clearing (simple): [expr $aMemClear1 / (1024 * 1024)] MiB" -puts "Displaying (connected): [expr $aMemDisp2 / (1024 * 1024)] MiB" -puts "Clearing (connected): [expr $aMemClear2 / (1024 * 1024)] MiB" - -set aRatio [expr $aMemClear2 / double($aMemClear1)] - -# check if the memory difference is greater than 20% -if [expr $aRatio > 1.2] { puts "Error : TEST FAILED" } -vdump ${imagedir}/${casename}.png diff --git a/tests/vselect/bugs/bug27318 b/tests/vselect/bugs/bug27318 deleted file mode 100644 index ec682f0958..0000000000 --- a/tests/vselect/bugs/bug27318 +++ /dev/null @@ -1,34 +0,0 @@ -puts "TODO OCC27318 MacOS: Error : TEST FAILED" - -puts "========" -puts "OCC27318: Memory is not released in Select3D_SensitiveSet when destroying AIS_InteractiveContext without removing objects" -puts "========" -puts "" - -pload VISUALIZATION QAcommands - -# to measure initial memory correctly, open and close interactive context -# to load FreeImage -vinit -vclose -set aMemInit [meminfo h] -puts "Initial mem: [expr $aMemInit / (1024 * 1024)] MiB ([expr $aMemInit])" - -# create a box and display it in each interactive context. The context is -# the only instance that references to the box. Therefore, the box must be -# removed completely after each context's closing -for {set anIter 0} {$anIter < 300} {incr anIter} { - vinit - OCC27318 - vclose -} - -set aMemAfter [meminfo h] -puts "Memory after closing interactive context several times: [expr $aMemAfter / (1024 * 1024)] MiB ([expr $aMemAfter])" - -set aRatio [expr $aMemAfter / double($aMemInit)] - -# check if the memory difference is greater than 5% -if [expr $aRatio > 1.05] { - puts "Error : TEST FAILED" -}