// Created on: 1997-04-10 // Created by: Prestataire Mary FABIEN // Copyright (c) 1997-1999 Matra Datavision // Copyright (c) 1999-2014 OPEN CASCADE SAS // // This file is part of Open CASCADE Technology software library. // // This library is free software; you can redistribute it and/or modify it under // the terms of the GNU Lesser General Public License version 2.1 as published // by the Free Software Foundation, with special exception defined in the file // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT // distribution for complete text of the license and disclaimer of any warranty. // // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //======================================================================= //function : Create //purpose : //======================================================================= TopOpeBRepDS_Check::TopOpeBRepDS_Check(const Handle(TopOpeBRepDS_HDataStructure)& HDS) { myHDS = HDS; myMapSurfaceStatus.Clear(); myMapCurveStatus.Clear(); myMapPointStatus.Clear(); myMapShapeStatus.Clear(); } //======================================================================= //function : Create //purpose : //======================================================================= TopOpeBRepDS_Check::TopOpeBRepDS_Check() { myMapSurfaceStatus.Clear(); myMapCurveStatus.Clear(); myMapPointStatus.Clear(); myMapShapeStatus.Clear(); } //======================================================================= //function : ChkIntg //purpose : Check Integrity //======================================================================= Standard_Boolean CheckEdgeParameter(const Handle(TopOpeBRepDS_HDataStructure)& myHDS); Standard_Boolean TopOpeBRepDS_Check::ChkIntg() { const TopOpeBRepDS_DataStructure& DS = myHDS->DS(); Standard_Boolean bI=Standard_False; // Check the integrity of the DS Standard_Integer i,nshape = DS.NbShapes(); for (i = 1; i <= nshape; i++) { // Integrity of Interferences : Check support and geometry const TopOpeBRepDS_ListOfInterference& LI = DS.ShapeInterferences(i); bI = ChkIntgInterf(LI); } Standard_Integer nsurface = DS.NbSurfaces(); for (i = 1; i <= nsurface; i++) { // Integrity of Interferences : Check support and geometry const TopOpeBRepDS_ListOfInterference& LI = DS.SurfaceInterferences(i); bI = bI && ChkIntgInterf(LI); } Standard_Integer ncurve = DS.NbCurves(); for (i = 1; i <= ncurve; i++) { // Integrity of Interferences : Check support and geometry const TopOpeBRepDS_ListOfInterference& LI = DS.CurveInterferences(i); bI = bI && ChkIntgInterf(LI); } Standard_Integer npoint = DS.NbPoints(); for (i = 1; i <= npoint; i++) { // Integrity of Interferences : Check support and geometry const TopOpeBRepDS_ListOfInterference& LI = DS.PointInterferences(i); bI = bI && ChkIntgInterf(LI); } #ifdef DEB PrintIntg(cout); #endif // CheckEdgeParameter(); CheckEdgeParameter(myHDS); return bI; } //======================================================================= //function : ChkIntgInterf //purpose : //======================================================================= Standard_Boolean TopOpeBRepDS_Check::ChkIntgInterf (const TopOpeBRepDS_ListOfInterference& LI) { TopOpeBRepDS_ListIteratorOfListOfInterference it1; it1.Initialize(LI); Standard_Boolean IsOK = Standard_True; while (it1.More() ) { Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); IsOK = IsOK && CheckDS(I1->Support(), I1->SupportType()); IsOK = IsOK && CheckDS(I1->Geometry(), I1->GeometryType()); it1.Next(); } return IsOK; } //======================================================================= //function : CheckDS //purpose : //======================================================================= Standard_Boolean TopOpeBRepDS_Check::CheckDS(const Standard_Integer I, const TopOpeBRepDS_Kind K) { // geometry switch(K) { case TopOpeBRepDS_SURFACE : { if(myHDS->NbSurfaces() < I) { #ifdef DEB cout<<"Surpassed index of TopOpeBRepDS_SURFACE. actual index : "<NbSurfaces(); #endif if(myMapSurfaceStatus.IsBound(I)) myMapSurfaceStatus.UnBind(I); myMapSurfaceStatus.Bind(I, TopOpeBRepDS_NOK); return Standard_False; } if(!myMapSurfaceStatus.IsBound(I)) myMapSurfaceStatus.Bind(I,TopOpeBRepDS_OK); return Standard_True; } case TopOpeBRepDS_CURVE : { if(myHDS->NbCurves() < I) { #ifdef DEB cout<<"Surpassed index of TopOpeBRepDS_CURVE. actual index : "<NbCurves(); #endif if(myMapCurveStatus.IsBound(I)) myMapCurveStatus.UnBind(I); myMapCurveStatus.Bind(I, TopOpeBRepDS_NOK); return Standard_False; } if(!myMapCurveStatus.IsBound(I)) myMapCurveStatus.Bind(I,TopOpeBRepDS_OK); return Standard_True; } case TopOpeBRepDS_POINT : { if(myHDS->NbPoints() < I) { #ifdef DEB cout<<"Surpassed index of TopOpeBRepDS_POINT : actual index : "<NbPoints()<NbShapes() < I) { #ifdef DEB cout<<"Surpassed index of TopOpeBRepDS_Shape_. actual index : "<NbShapes(); #endif if(myMapShapeStatus.IsBound(I)) myMapShapeStatus.UnBind(I); myMapShapeStatus.Bind(I,TopOpeBRepDS_NOK); return Standard_False; } const TopoDS_Shape& S =myHDS->Shape(I); TopAbs_ShapeEnum se=TopAbs_COMPOUND; switch (K) { case TopOpeBRepDS_SOLID : se = TopAbs_SOLID; break; case TopOpeBRepDS_SHELL : se = TopAbs_SHELL; break; case TopOpeBRepDS_FACE : se = TopAbs_FACE; break; case TopOpeBRepDS_WIRE : se = TopAbs_WIRE; break; case TopOpeBRepDS_EDGE : se = TopAbs_EDGE; break; case TopOpeBRepDS_VERTEX : se = TopAbs_VERTEX;break; default: break ; } if(S.ShapeType() != se) { #ifdef DEB cout<<"Error : Shape "<ChangeDS(); Standard_Integer NbSh = myHDS->NbShapes(), i, Curr, Loc; for(i = 1;i <= NbSh; i++) { // Verifie que les Shapes de mySameDomaine existe bien dans la DS const TopoDS_Shape& Sind = myHDS->Shape(i); const TopTools_ListOfShape& losi = BDS.ShapeSameDomain(Sind); if(!CheckShapes(losi)) { #ifdef DEB cout<<"Shape of ShapeSameDomain (n*n "<Shape(itS); if (!index) return Standard_False; it.Next(); } return Standard_True; } //======================================================================= //function : OneVertexOnPnt //purpose : //======================================================================= Standard_Boolean TopOpeBRepDS_Check::OneVertexOnPnt(){ Standard_Boolean b = Standard_True; // Standard_Integer i, j, k; Standard_Integer i, j; Standard_Integer Curr1, Curr2, sdr1, sdr2; Standard_Integer NbVe = 0, NbPo = myHDS->NbPoints(); // Standard_Real tol, tol1, tol2, Dist; Standard_Real tol1, tol2, Dist; TColStd_IndexedMapOfInteger vert; vert.Clear(); for(i = 1;i <= myHDS->NbShapes();i++) { const TopoDS_Shape& S = myHDS->Shape(i); if((S.ShapeType() == TopAbs_VERTEX) && myHDS->HasShape(S)) vert.Add(i); } NbVe = vert.Extent(); for(i = 1;i <= NbVe; i++) { Curr1 = vert.FindKey(i); const TopoDS_Shape& S1 = myHDS->Shape(Curr1); sdr1 = myHDS->SameDomainReference(S1); for(j = i+1;j <= NbVe; j++) { Curr2 = vert.FindKey(j); const TopoDS_Shape& S2 = myHDS->Shape(Curr2); sdr2 = myHDS->SameDomainReference(S2); tol1 = TopOpeBRepTool_ShapeTool::Tolerance(S1); tol2 = TopOpeBRepTool_ShapeTool::Tolerance(S2); const gp_Pnt& P1 = TopOpeBRepTool_ShapeTool::Pnt(S1); const gp_Pnt& P2 = TopOpeBRepTool_ShapeTool::Pnt(S2); Dist = P1.Distance(P2); if(Dist <= tol1 + tol2) { if(sdr1 != sdr2) { #ifdef DEB cout<<"Pb Vertex n+n"< 1.e50"); IsOK = Standard_False; } } it1.Next(); } } Standard_Integer ncurve = DS.NbCurves(); for (i = 1; i <= ncurve; i++) { // Integrity of Interferences : Check parameter of CurvesInterferences const TopOpeBRepDS_ListOfInterference& LI = DS.CurveInterferences(i); it1.Initialize(LI); while (it1.More() ) { const Handle(TopOpeBRepDS_Interference)& I1 = it1.Value(); const Handle(TopOpeBRepDS_CurvePointInterference)& CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(I1); if(!CPI.IsNull()) { Standard_Integer Param = //#ifdef DEB // TopOpeBRepDS_InterferenceTool::Parameter(CPI); //#else (Standard_Integer ) TopOpeBRepDS_InterferenceTool::Parameter(CPI); //#endif if(Param > 1.e50) { I1->Dump(cout,"!!**!!** WARNING : sur l'interference : \n", "parameter > 1.e50"); IsOK = Standard_False; } } it1.Next(); } } return IsOK; } //======================================================================= //function : PrintIntg //purpose : //======================================================================= Standard_OStream& TopOpeBRepDS_Check::PrintIntg(Standard_OStream& OS) { OS<Shape(i); switch(S.ShapeType()) { case TopAbs_VERTEX: MapVertex.Bind(i, DMI.Value()); break; case TopAbs_EDGE: MapEdge.Bind(i, DMI.Value()); break; case TopAbs_WIRE: MapWire.Bind(i, DMI.Value()); break; case TopAbs_FACE: MapFace.Bind(i, DMI.Value()); break; case TopAbs_SOLID: MapSolid.Bind(i, DMI.Value()); break; default: break ; } } PrintMap(MapVertex, "Vertex", OS); PrintMap(MapEdge, "Edge", OS); PrintMap(MapWire, "Wire", OS); PrintMap(MapFace, "Face", OS); PrintMap(MapSolid, "Solid", OS); OS<NbShapes() < index) { OS<<"**PB**IN**TopOpeBRepDS_Check::PrintShape** "; return OS; } if(!myMapShapeStatus.IsBound(index)) { OS<<"NO CHECK HAS PROCESSING"<Shape(index); #ifdef DEB PrintShape(S.ShapeType(),cout); OS<<" "<