// Created on: 1996-02-23 // Created by: Jacques GOUSSARD // Copyright (c) 1996-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 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //#include #include #include #include #include #include #include #include #include //Number of BRepCheck_Statuses in BRepCheck_Status.hxx file //(BRepCheck_NoError is not considered, i.e. general status //is smaller by one specified in file) static const Standard_Integer NumberOfStatus = 36; static char* checkfaultyname = NULL; Standard_EXPORT void BRepTest_CheckCommands_SetFaultyName(const char* name) { if (checkfaultyname != NULL) { free(checkfaultyname); checkfaultyname = NULL; } if (name == NULL) { checkfaultyname = (char*)malloc(strlen("faulty_")+1); strcpy(checkfaultyname,"faulty_"); } else { checkfaultyname = (char*)malloc(strlen(name)+1); strcpy(checkfaultyname,name); } } static TopTools_DataMapOfShapeListOfShape theMap; static Standard_Integer nbfaulty = 0; static Draw_SequenceOfDrawable3D lfaulty; Standard_IMPORT Standard_Integer BRepCheck_Trace(const Standard_Integer phase); //======================================================================= //function : FindNamed //======================================================================= static Standard_Boolean FindNamed(const TopoDS_Shape& S, char*& Name) { for (Standard_Integer i = 1 ;i <= lfaulty.Length(); i++) { Handle(DBRep_DrawableShape) DS = Handle(DBRep_DrawableShape)::DownCast(lfaulty(i)); if (DS->Shape().IsSame(S)) { Name = (char*)DS->Name(); return Standard_True; } } return Standard_False; } //======================================================================= //function : Contains //======================================================================= static Standard_Boolean Contains(const TopTools_ListOfShape& L, const TopoDS_Shape& S) { TopTools_ListIteratorOfListOfShape it; for (it.Initialize(L); it.More(); it.Next()) { if (it.Value().IsSame(S)) { return Standard_True; } } return Standard_False; } //======================================================================= //function : PrintSub //======================================================================= static void PrintSub(Standard_OStream& OS, const BRepCheck_Analyzer& Ana, const TopoDS_Shape& S, const TopAbs_ShapeEnum Subtype) { char* Name; BRepCheck_ListIteratorOfListOfStatus itl; TopExp_Explorer exp; for (exp.Init(S,Subtype); exp.More(); exp.Next()) { const Handle(BRepCheck_Result)& res = Ana.Result(exp.Current()); const TopoDS_Shape& sub = exp.Current(); for (res->InitContextIterator(); res->MoreShapeInContext(); res->NextShapeInContext()) { if (res->ContextualShape().IsSame(S) && !Contains(theMap(sub),S)) { theMap(sub).Append(S); itl.Initialize(res->StatusOnShape()); if (itl.Value() != BRepCheck_NoError) { if (!FindNamed(sub,Name)) { nbfaulty++; Name = (char*)malloc(18*sizeof(char)); Sprintf(Name,"%s%d",checkfaultyname,nbfaulty); DBRep::Set(Name,sub); lfaulty.Append(Draw::Get((Standard_CString&)Name)); } OS << "Shape " << Name << " "; if (!FindNamed(S,Name)) { nbfaulty++; Name = (char*)malloc(18*sizeof(char)); Sprintf(Name,"%s%d",checkfaultyname,nbfaulty); DBRep::Set(Name,S); lfaulty.Append(Draw::Get((Standard_CString&)Name)); } OS << " on shape " << Name << " :\n"; for (;itl.More(); itl.Next()) { BRepCheck::Print(itl.Value(),OS); } } break; } } } } //======================================================================= //function : Print //======================================================================= static void Print(Standard_OStream& OS, const BRepCheck_Analyzer& Ana, const TopoDS_Shape& S) { for (TopoDS_Iterator iter(S); iter.More(); iter.Next()) { Print(OS,Ana,iter.Value()); } char* Name; TopAbs_ShapeEnum styp = S.ShapeType(); BRepCheck_ListIteratorOfListOfStatus itl; if (!Ana.Result(S).IsNull() && !theMap.IsBound(S)) { itl.Initialize(Ana.Result(S)->Status()); if (itl.Value() != BRepCheck_NoError) { if (!FindNamed(S,Name)) { nbfaulty++; Name = (char*)malloc(18*sizeof(char)); Sprintf(Name,"%s%d",checkfaultyname,nbfaulty); DBRep::Set(Name,S); lfaulty.Append(Draw::Get((Standard_CString&)Name)); } OS << "On Shape " << Name << " :\n"; for (;itl.More(); itl.Next()) { if (itl.Value() != BRepCheck_NoError) BRepCheck::Print(itl.Value(),OS); } } } if (!theMap.IsBound(S)) { TopTools_ListOfShape thelist; theMap.Bind(S, thelist); } switch (styp) { case TopAbs_EDGE: PrintSub(OS,Ana,S,TopAbs_VERTEX); break; case TopAbs_WIRE: PrintSub(OS,Ana,S,TopAbs_EDGE); PrintSub(OS,Ana,S,TopAbs_VERTEX); break; case TopAbs_FACE: PrintSub(OS,Ana,S,TopAbs_WIRE); PrintSub(OS,Ana,S,TopAbs_EDGE); PrintSub(OS,Ana,S,TopAbs_VERTEX); break; case TopAbs_SHELL: // PrintSub(OS,Ana,S,TopAbs_FACE); break; case TopAbs_SOLID: // PrintSub(OS,Ana,S,TopAbs_EDGE); PrintSub(OS,Ana,S,TopAbs_SHELL); break; default: break; } } //======================================================================= //function : computetolerance //purpose : //======================================================================= static Standard_Integer computetolerance(Draw_Interpretor& di, Standard_Integer narg, const char** a) { if (narg < 2) { //cout << "Usage: computetolerance shape" << endl; di << "Usage: computetolerance shape\n"; return 1; } TopoDS_Shape S = DBRep::Get(a[1]); Standard_Real tol; if (S.ShapeType() == TopAbs_EDGE) { BRepCheck_Edge bce(TopoDS::Edge(S)); tol=bce.Tolerance(); //cout<< "Tolerance de " << (void*) &(*S.TShape()) << " : " << tol << endl; Standard_SStream aSStream1; aSStream1<< "Tolerance de " << (void*) &(*S.TShape()) << " : " << tol << "\n"; di << aSStream1; } else { TopTools_MapOfShape theEdges; TopExp_Explorer exp; for (exp.Init(S, TopAbs_EDGE); exp.More(); exp.Next()) { if (theEdges.Add(exp.Current())) { BRepCheck_Edge bce(TopoDS::Edge(exp.Current())); tol=bce.Tolerance(); //cout<< "Tolerance de " << (void*) &(*exp.Current().TShape()) << " : " << tol << "\n"; Standard_SStream aSStream2; aSStream2<< "Tolerance de " << (void*) &(*exp.Current().TShape()) << " : " << tol << "\n"; di << aSStream2; } } //cout << endl; di << "\n"; } return 0; } //======================================================================= //function : checksection //purpose : Checks the closure of a section line //======================================================================= static Standard_Integer checksection(Draw_Interpretor& di, Standard_Integer narg, const char** a) { if (narg < 2) { return 1; } TopoDS_Shape S = DBRep::Get(a[1]); TopTools_MapOfShape theVertices; TopExp_Explorer exp; for (exp.Init(S, TopAbs_VERTEX); exp.More(); exp.Next()) { if (!theVertices.Add(exp.Current())) theVertices.Remove(exp.Current()); } //cout << " nb alone Vertices : " << theVertices.Extent() << endl; di << " nb alone Vertices : " << theVertices.Extent() << "\n"; char Name[32]; Standard_Integer ipp=0; TopTools_MapIteratorOfMapOfShape itvx; for (itvx.Initialize(theVertices); itvx.More(); itvx.Next()) { ipp++; Sprintf(Name,"alone_%d",ipp); DBRep::Set(Name, itvx.Key()); //cout << Name << " " ; di << Name << " " ; } //cout << endl; di << "\n"; return 0; } //======================================================================= //======================================================================= //function : checkdiff //purpose : Checks the differences beetween a result and his arguments //======================================================================= static Standard_Integer checkdiff(Draw_Interpretor& di, Standard_Integer narg, const char** a) { const char* syntaxe = "checkdiff arg1 [arg2..argn] result [closedSolid (0/1)] [geomCtrl (1/0)]"; if (narg < 3) { if (narg==2) { Standard_Integer bcrtrace=Draw::Atoi(a[narg-1]); bcrtrace=BRepCheck_Trace(bcrtrace); //cout << "BRepCheck_Trace : " << bcrtrace << endl; di << "BRepCheck_Trace : " << bcrtrace << "\n"; //cout << syntaxe << endl; di << syntaxe << "\n"; return 0; } //cout << syntaxe << endl; di << syntaxe << "\n"; return 1; } Standard_Integer lastArg=narg-2; Standard_Boolean closedSolid = Standard_False; Standard_Boolean geomCtrl = Standard_True; TopoDS_Shape resu = DBRep::Get(a[narg-1]); if (resu.IsNull()) { if (narg < 4) { //cout << syntaxe << endl; di << syntaxe << "\n"; return 1; } closedSolid = Draw::Atoi(a[narg-1]) != 0; resu = DBRep::Get(a[narg-2]); lastArg=narg-3; if (resu.IsNull()) { if (narg < 5) { //cout << syntaxe << endl; di << syntaxe << "\n"; return 1; } geomCtrl=closedSolid; closedSolid = Draw::Atoi(a[narg-2]) != 0; resu = DBRep::Get(a[narg-3]); lastArg=narg-4; if (resu.IsNull()) { //cout << syntaxe << endl; di << syntaxe << "\n"; return 1; } } } TopTools_ListOfShape lesArgs; for (Standard_Integer id=1; id <=lastArg; id++) { lesArgs.Append(DBRep::Get(a[id])); } if (BRepAlgo::IsValid(lesArgs, resu, closedSolid, geomCtrl)) { //cout << "Difference is Valid." << endl; di << "Difference is Valid.\n"; } else { //cout << "error : Difference is Not Valid !" << endl; di << "error : Difference is Not Valid !\n"; } return 0; } //======================================================================= // Modified by skv - Tue Apr 27 13:38:44 2004 Begin //======================================================================= //function : CHK //purpose : Checks a shape //======================================================================= // static Standard_Integer CHK(Draw_Interpretor& theCommands, // Standard_Integer narg, const char** a) // { // if (narg < 2) { // return 1; // } // Standard_Boolean doprint = Standard_True; // if (narg == 3) { if (!strcmp(a[2],"-short")) doprint = Standard_False; } // TopoDS_Shape S = DBRep::Get(a[1]); // if (S.IsNull()) { // cout<<"not a topological shape"< (stat); if((NbProblems->Upper() < anID) || (NbProblems->Lower() > anID)) return; NbProblems->SetValue(anID, NbProblems->Value(anID)+1); } //======================================================================= //function : GetProblemSub // purpose : auxilary for StructuralDump //======================================================================= static void GetProblemSub(const BRepCheck_Analyzer& Ana, const TopoDS_Shape& Shape, Handle(TopTools_HSequenceOfShape)& sl, Handle(TColStd_HArray1OfInteger)& NbProblems, const TopAbs_ShapeEnum Subtype) { BRepCheck_ListIteratorOfListOfStatus itl; TopExp_Explorer exp; for (exp.Init(Shape,Subtype); exp.More(); exp.Next()) { const Handle(BRepCheck_Result)& res = Ana.Result(exp.Current()); const TopoDS_Shape& sub = exp.Current(); for (res->InitContextIterator(); res->MoreShapeInContext(); res->NextShapeInContext()) { if (res->ContextualShape().IsSame(Shape) && !Contains(theMap(sub),Shape)) { theMap(sub).Append(Shape); itl.Initialize(res->StatusOnShape()); if (itl.Value() != BRepCheck_NoError) { Standard_Integer ii = 0; for(ii=1; ii<=sl->Length(); ii++) if(sl->Value(ii).IsSame(sub)) break; if(ii>sl->Length()) { sl->Append(sub); FillProblems(itl.Value(),NbProblems); } for(ii=1; ii<=sl->Length(); ii++) if(sl->Value(ii).IsSame(Shape)) break; if(ii>sl->Length()) { sl->Append(Shape); FillProblems(itl.Value(),NbProblems); } } break; } } } } //======================================================================= //function : GetProblemShapes // purpose : auxilary for StructuralDump //======================================================================= static void GetProblemShapes(const BRepCheck_Analyzer& Ana, const TopoDS_Shape& Shape, Handle(TopTools_HSequenceOfShape)& sl, Handle(TColStd_HArray1OfInteger)& NbProblems) { for (TopoDS_Iterator iter(Shape); iter.More(); iter.Next()) { GetProblemShapes(Ana,iter.Value(),sl, NbProblems); } TopAbs_ShapeEnum styp = Shape.ShapeType(); BRepCheck_ListIteratorOfListOfStatus itl; if (!Ana.Result(Shape).IsNull() && !theMap.IsBound(Shape)) { itl.Initialize(Ana.Result(Shape)->Status()); if (itl.Value() != BRepCheck_NoError) { sl->Append(Shape); FillProblems(itl.Value(),NbProblems); } } if (!theMap.IsBound(Shape)) { TopTools_ListOfShape thelist; theMap.Bind(Shape, thelist); } switch (styp) { case TopAbs_EDGE: GetProblemSub(Ana, Shape, sl, NbProblems, TopAbs_VERTEX); break; case TopAbs_FACE: GetProblemSub(Ana, Shape, sl, NbProblems, TopAbs_WIRE); GetProblemSub(Ana, Shape, sl, NbProblems, TopAbs_EDGE); GetProblemSub(Ana, Shape, sl, NbProblems, TopAbs_VERTEX); break; case TopAbs_SHELL: break; case TopAbs_SOLID: GetProblemSub(Ana, Shape, sl, NbProblems, TopAbs_SHELL); break; default: break; } } //======================================================================= //function : StructuralDump //purpose : Structural (data exchange) style of output. //======================================================================= //void StructuralDump(const BRepCheck_Analyzer &theAna, // const Standard_CString ShName, // const Standard_CString Pref, // const TopoDS_Shape &theShape) void StructuralDump(Draw_Interpretor& theCommands, const BRepCheck_Analyzer &theAna, const Standard_CString ShName, const Standard_CString Pref, const TopoDS_Shape &theShape) { Standard_Integer i; //cout << "StructuralDump" << endl; //cout << " -- The Shape " << ShName << " has problems :"<SetValue(i,0); Handle(TopTools_HSequenceOfShape) sl,slv,sle,slw,slf,sls,slo; sl = new TopTools_HSequenceOfShape(); theMap.Clear(); GetProblemShapes(theAna, theShape, sl, NbProblems); theMap.Clear(); Standard_Integer aProblemID = static_cast(BRepCheck_InvalidPointOnCurve); if(NbProblems->Value(aProblemID) > 0) theCommands<<" Invalid Point on Curve ................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidPointOnCurveOnSurface); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid Point on CurveOnSurface .......... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidPointOnSurface); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid Point on Surface ................. "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_No3DCurve); if(NbProblems->Value(aProblemID)>0) theCommands<<" No 3D Curve .............................. "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_Multiple3DCurve); if(NbProblems->Value(aProblemID)>0) theCommands<<" Multiple 3D Curve ........................ "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_Invalid3DCurve); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid 3D Curve ......................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_NoCurveOnSurface); if(NbProblems->Value(aProblemID)>0) theCommands<<" No Curve on Surface ...................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidCurveOnSurface); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid Curve on Surface ................. "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidCurveOnClosedSurface); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid Curve on closed Surface .......... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidSameRangeFlag); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid SameRange Flag ................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidSameParameterFlag); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid SameParameter Flag ............... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidDegeneratedFlag); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid Degenerated Flag ................. "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_FreeEdge); if(NbProblems->Value(aProblemID)>0) theCommands<<" Free Edge ................................ "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidMultiConnexity); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid MultiConnexity ................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidRange); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid Range ............................ "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_EmptyWire); if(NbProblems->Value(aProblemID)>0) theCommands<<" Empty Wire ............................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_RedundantEdge); if(NbProblems->Value(aProblemID)>0) theCommands<<" Redundant Edge ........................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_SelfIntersectingWire); if(NbProblems->Value(aProblemID)>0) theCommands<<" Self Intersecting Wire ................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_NoSurface); if(NbProblems->Value(aProblemID)>0) theCommands<<" No Surface ............................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidWire); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid Wire ............................. "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_RedundantWire); if(NbProblems->Value(aProblemID)>0) theCommands<<" Redundant Wire ........................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_IntersectingWires); if(NbProblems->Value(aProblemID)>0) theCommands<<" Intersecting Wires ....................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidImbricationOfWires); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid Imbrication of Wires ............. "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_EmptyShell); if(NbProblems->Value(aProblemID)>0) theCommands<<" Empty Shell .............................. "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_RedundantFace); if(NbProblems->Value(aProblemID)>0) theCommands<<" Redundant Face ........................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_UnorientableShape); if(NbProblems->Value(aProblemID)>0) theCommands<<" Unorientable Shape ....................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_NotClosed); if(NbProblems->Value(aProblemID)>0) theCommands<<" Not Closed ............................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_NotConnected); if(NbProblems->Value(aProblemID)>0) theCommands<<" Not Connected ............................ "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_SubshapeNotInShape); if(NbProblems->Value(aProblemID)>0) theCommands<<" Subshape not in Shape .................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_BadOrientation); if(NbProblems->Value(aProblemID)>0) theCommands<<" Bad Orientation .......................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_BadOrientationOfSubshape); if(NbProblems->Value(aProblemID)>0) theCommands<<" Bad Orientation of Subshape .............. "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidToleranceValue); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid tolerance value................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidPolygonOnTriangulation); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid polygon on triangulation.......... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_InvalidImbricationOfShells); if(NbProblems->Value(aProblemID)>0) theCommands<<" Invalid Imbrication of Shells............. "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_EnclosedRegion); if(NbProblems->Value(aProblemID)>0) theCommands<<" Enclosed Region........................... "<Value(aProblemID)<<"\n"; aProblemID = static_cast(BRepCheck_CheckFail); if(NbProblems->Value(aProblemID)>0) theCommands<<" checkshape failure........................ "<Value(aProblemID)<<"\n"; theCommands<<" ------------------------------------------------\n"; theCommands<<"*** Shapes with problems : "<Length()<<"\n"; slv = new TopTools_HSequenceOfShape(); sle = new TopTools_HSequenceOfShape(); slw = new TopTools_HSequenceOfShape(); slf = new TopTools_HSequenceOfShape(); sls = new TopTools_HSequenceOfShape(); slo = new TopTools_HSequenceOfShape(); for(i=1; i<=sl->Length(); i++) { TopoDS_Shape shi = sl->Value(i); TopAbs_ShapeEnum sti = shi.ShapeType(); switch (sti) { case TopAbs_VERTEX : slv->Append (shi); break; case TopAbs_EDGE : sle->Append (shi); break; case TopAbs_WIRE : slw->Append (shi); break; case TopAbs_FACE : slf->Append (shi); break; case TopAbs_SHELL : sls->Append (shi); break; case TopAbs_SOLID : slo->Append (shi); break; default : break; } } BRep_Builder B; if(slv->Length()>0) { TopoDS_Compound comp; B.MakeCompound(comp); Standard_Integer nb = slv->Length(); for(i=1; i<=nb; i++) B.Add(comp,slv->Value(i)); char aName[20]; Sprintf(aName,"%s_v",Pref); DBRep::Set(aName,comp); //cout<<"VERTEX : "<<(nb > 9 ? "" : " ")< compound named "< 9) theCommands<<"VERTEX : "< compound named "< compound named "<Length()>0) { TopoDS_Compound comp; B.MakeCompound(comp); Standard_Integer nb = sle->Length(); for(i=1; i<=nb; i++) B.Add(comp,sle->Value(i)); char aName[20]; Sprintf(aName,"%s_e",Pref); DBRep::Set(aName,comp); //cout<<"EDGE : "<<(nb > 9 ? "" : " ")< compound named "< 9) theCommands<<"EDGE : "< compound named "< compound named "<Length()>0) { TopoDS_Compound comp; B.MakeCompound(comp); Standard_Integer nb = slw->Length(); for(i=1; i<=nb; i++) B.Add(comp,slw->Value(i)); char aName[20]; Sprintf(aName,"%s_w",Pref); DBRep::Set(aName,comp); //cout<<"WIRE : "<<(nb > 9 ? "" : " ")< compound named "< 9) theCommands<<"WIRE : "< compound named "< compound named "<Length()>0) { TopoDS_Compound comp; B.MakeCompound(comp); Standard_Integer nb = slf->Length(); for(i=1; i<=nb; i++) B.Add(comp,slf->Value(i)); char aName[20]; Sprintf(aName,"%s_f",Pref); DBRep::Set(aName,comp); //cout<<"FACE : "<<(nb > 9 ? "" : " ")< compound named "< 9) theCommands<<"FACE : "< compound named "< compound named "<Length()>0) { TopoDS_Compound comp; B.MakeCompound(comp); Standard_Integer nb = sls->Length(); for(i=1; i<=nb; i++) B.Add(comp,sls->Value(i)); char aName[20]; Sprintf(aName,"%s_s",Pref); DBRep::Set(aName,comp); //cout<<"SHELL : "<<(nb > 9 ? "" : " ")< compound named "< 9) theCommands<<"SHELL : "< compound named "< compound named "<Length()>0) { TopoDS_Compound comp; B.MakeCompound(comp); Standard_Integer nb = slo->Length(); for(i=1; i<=nb; i++) B.Add(comp,slo->Value(i)); char aName[20]; Sprintf(aName,"%s_o",Pref); DBRep::Set(aName,comp); //cout<<"SOLID : "<<(nb > 9 ? "" : " ")< compound named "< 9) theCommands<<"SOLID : "< compound named "< compound named "< 5) { //cout << "Invalid number of args!!!" << endl; //cout << "No args to have help." << endl; theCommands << "Invalid number of args!!!\n"; theCommands << "No args to have help.\n"; return 1; } Standard_Boolean aGeomCtrl = Standard_True; Standard_Integer aCurInd = 1; if (!strcmp(a[1],"-top")) { aGeomCtrl = Standard_False; aCurInd++; } if (aCurInd > narg - 1) { //cout << "Invalid number of args!!!" << endl; //cout << "No args to have help." << endl; theCommands << "Invalid number of args!!!\n"; theCommands << "No args to have help.\n"; return 1; } Standard_CString aShapeName = a[aCurInd]; TopoDS_Shape aShape = DBRep::Get(aShapeName); if (aShape.IsNull()) { //cout << a[aCurInd] << " is not a topological shape!!!" << endl; theCommands << a[aCurInd] << " is not a topological shape!!!\n"; return 1; } Standard_Boolean IsShortDump = Standard_False; Standard_Boolean IsContextDump = Standard_True; Standard_Integer aBackInd = narg - 1; if (aCurInd < aBackInd) { if (!strcmp(a[aBackInd],"-short")) { IsShortDump = Standard_True; aBackInd--; } } if (aCurInd < aBackInd - 1) { //cout << "Invalid number of args!!!" << endl; //cout << "No args to have help." << endl; theCommands << "Invalid number of args!!!\n"; theCommands << "No args to have help.\n"; return 1; } else if (aCurInd < aBackInd) { IsContextDump = Standard_False; } try { OCC_CATCH_SIGNALS BRepCheck_Analyzer anAna(aShape,aGeomCtrl); Standard_Boolean isValid = anAna.IsValid(); if (isValid) { if (IsContextDump) { theCommands << "This shape seems to be valid"; } else { theCommands << " -- The Shape " << aShapeName << " looks OK"; } } else { if (IsShortDump) { theCommands<<"This shape has faulty shapes"; } else { if (IsContextDump) { //ContextualDump(anAna, aShape); ContextualDump(theCommands, anAna, aShape); } else { Standard_CString aPref = a[aCurInd+1]; //StructuralDump(anAna, aShapeName, aPref, aShape); StructuralDump(theCommands, anAna, aShapeName, aPref, aShape); } } } } catch(Standard_Failure const& anException) { theCommands<<"checkshape exception : "; theCommands << anException.GetMessageString(); theCommands<<"\n"; return 1; } return 0; } // Modified by skv - Tue Apr 27 13:38:24 2004 End /***************************************************************/ static void InitEpsSurf(Standard_Real& epsnl,Standard_Real& epsdis, Standard_Real& epsangk1, Standard_Real& epsangk2, Standard_Real& epsangn1, Standard_Real& perce,Standard_Real& maxlen ) { epsnl = 0.001; epsdis = 0.001; epsangk1 = 0.001 ; epsangk2 = 0.001; epsangn1 = 0.001 ; perce = 0.01; maxlen = 10000 ; } static Standard_Integer shapeG1continuity (Draw_Interpretor& di, Standard_Integer n, const char** a) { Standard_Real epsnl,epsC0, epsC1, epsC2, epsG1,percent,maxlen; Standard_Integer nbeval; InitEpsSurf(epsnl,epsC0, epsC1, epsC2, epsG1,percent,maxlen); Standard_Boolean ISG1=Standard_True; if (n<4) return 1; TopoDS_Face face1,face2; Standard_Real f1,f2,l1,l2; TopoDS_Shape shape = DBRep::Get(a[1],TopAbs_SHAPE); if (shape.IsNull()) return 1; TopoDS_Shape edge = DBRep::Get(a[2],TopAbs_EDGE); if (edge.IsNull()) return 1; // calcul des deux faces TopTools_IndexedDataMapOfShapeListOfShape lface; TopExp::MapShapesAndAncestors(shape,TopAbs_EDGE,TopAbs_FACE,lface); const TopTools_ListOfShape& lfac = lface.FindFromKey(edge); Standard_Integer nelem= lfac.Extent(); if(nelem!=2) return 1; TopTools_ListIteratorOfListOfShape It; It.Initialize(lfac); face1=TopoDS::Face(It.Value()); It.Next(); face2=TopoDS::Face(It.Value()); // calcul des deux pcurves const Handle(Geom2d_Curve) c1 = BRep_Tool::CurveOnSurface (TopoDS::Edge(edge),face1,f1,l1); if (c1.IsNull()) return 1; const Handle(Geom2d_Curve) c2 = BRep_Tool::CurveOnSurface (TopoDS::Edge(edge),face2,f2,l2); if (c2.IsNull()) return 1; Handle(Geom2d_Curve) curv1= new Geom2d_TrimmedCurve(c1,f1,l1); Handle(Geom2d_Curve) curv2= new Geom2d_TrimmedCurve(c2,f2,l2); // calcul dees deux surfaces TopLoc_Location L1,L2; TopoDS_Face aLocalFace = face1; const Handle(Geom_Surface)& s1 = BRep_Tool::Surface(aLocalFace,L1); // const Handle(Geom_Surface)& s1 = // BRep_Tool::Surface(TopoDS::Face(face1),L1); if (s1.IsNull()) return 1; aLocalFace = face2; const Handle(Geom_Surface)& s2 = BRep_Tool::Surface(aLocalFace,L2); // const Handle(Geom_Surface)& s2 = // BRep_Tool::Surface(TopoDS::Face(face2),L2); if (s2.IsNull()) return 1; Handle(Geom_Surface) surf1 = Handle(Geom_Surface):: DownCast(s1->Transformed(L1.Transformation())); if (surf1.IsNull()) return 1; Handle(Geom_Surface) surf2 = Handle(Geom_Surface):: DownCast(s2->Transformed(L2.Transformation())); if (surf2.IsNull()) return 1; nbeval = (Standard_Integer ) Draw::Atof( a[3]); switch(n) { case 7 : epsG1 = Draw::Atof(a[6]); case 6 : epsC0 = Draw::Atof(a[5]); case 5 : epsnl = Draw::Atof(a[4]); case 4 : {} break; default : return 1; } Standard_Real pard1, parf1, U, Uf, deltaU, nb = 0; Standard_Boolean isconti = Standard_True; Standard_Boolean isdone = Standard_True; pard1 = curv1->FirstParameter(); parf1 = curv1->LastParameter(); Standard_Real MaxG0Value=0, MaxG1Angle=0; U = Min( pard1,parf1); Uf = Max (pard1,parf1); deltaU = Abs(parf1- pard1)/nbeval; do { if ( nb == nbeval) { LocalAnalysis_SurfaceContinuity res(curv1, curv2, Uf,surf1, surf2, GeomAbs_G1, epsnl,epsC0, epsC1, epsC2, epsG1,percent,maxlen ); isdone = res.IsDone(); if ( isdone) { isconti = res.IsG1(); if (isconti) {if (res.C0Value()>MaxG0Value) MaxG0Value = res.C0Value(); if (res.G1Angle ()>MaxG1Angle) MaxG1Angle = res.G1Angle();}} else isconti = Standard_False;} else {LocalAnalysis_SurfaceContinuity res (curv1, curv2, (U+nb*deltaU ), surf1,surf2, GeomAbs_G1,epsnl,epsC0, epsC1, epsC2, epsG1, percent,maxlen); isdone = res.IsDone(); if ( isdone) { isconti = res.IsG1(); if ( nb == 0) { MaxG0Value = res.C0Value(); MaxG1Angle = res.G1Angle();} if (res.C0Value()> MaxG0Value) MaxG0Value = res.C0Value(); if (res.G1Angle()> MaxG1Angle) MaxG1Angle= res.G1Angle();;} else isconti = Standard_False;} if (!isconti) ISG1=Standard_False; nb++; } while ((nbTransformed(L1.Transformation())); if (surf1.IsNull()) return 1; Handle(Geom_Surface) surf2 = Handle(Geom_Surface):: DownCast(s2->Transformed(L2.Transformation())); if (surf2.IsNull()) return 1; nbeval = (Standard_Integer ) Draw::Atof( a[3]); switch(n) { case 6 : epsC0 = Draw::Atof(a[5]); case 5 : epsnl = Draw::Atof(a[4]); case 4 : {} break; default : return 1; } Standard_Real pard1, parf1, U, Uf, deltaU, nb = 0; Standard_Boolean isconti = Standard_True; Standard_Boolean isdone = Standard_True; pard1 = curv1->FirstParameter(); parf1 = curv1->LastParameter(); Standard_Real MaxG0Value=0; U = Min( pard1,parf1); Uf = Max (pard1,parf1); deltaU = Abs(parf1- pard1)/nbeval; ISG0=Standard_True; do { if ( nb == nbeval) { LocalAnalysis_SurfaceContinuity res (curv1, curv2, Uf,surf1, surf2, GeomAbs_C0,epsnl,epsC0, epsC1, epsC2, epsG1,percent,maxlen ); isdone = res.IsDone(); if ( isdone) { isconti = res.IsC0( ); if (isconti) if (res.C0Value()>MaxG0Value) MaxG0Value= res.C0Value();} else isconti = Standard_False;} else {LocalAnalysis_SurfaceContinuity res (curv1, curv2, (U+nb*deltaU), surf1, surf2, GeomAbs_C0,epsnl,epsC0, epsC1, epsC2, epsG1, percent,maxlen ); isdone = res.IsDone(); if ( isdone) { isconti = res.IsC0() ; if ( nb == 0) { MaxG0Value = res.C0Value();} if (res.C0Value()> MaxG0Value) MaxG0Value = res.C0Value();} else isconti = Standard_False;} nb++; if (!isconti) ISG0=Standard_False; } while ((nbTransformed(L1.Transformation())); if (surf1.IsNull()) return 1; Handle(Geom_Surface) surf2 = Handle(Geom_Surface):: DownCast(s2->Transformed(L2.Transformation())); if (surf2.IsNull()) return 1; nbeval = (Standard_Integer ) Draw::Atof( a[3]); switch(n) { case 9 : maxlen = Draw::Atof(a[8]); case 8 : percent = Draw::Atof(a[7]); case 7 : epsG1 = Draw::Atof(a[6]); case 6 : epsC0 = Draw::Atof(a[5]); case 5 : epsnl = Draw::Atof(a[4]); case 4 : {} break; default : return 1; } Standard_Real pard1, parf1, U, Uf, deltaU, nb = 0; Standard_Boolean isconti = Standard_True; Standard_Boolean isdone = Standard_True; pard1 = curv1->FirstParameter(); parf1 = curv1->LastParameter(); U = Min( pard1,parf1); Uf = Max (pard1,parf1); deltaU = Abs(parf1- pard1)/nbeval; do { if ( nb == nbeval) { LocalAnalysis_SurfaceContinuity res (curv1, curv2, Uf,surf1, surf2, GeomAbs_G2,epsnl,epsC0, epsC1, epsC2, epsG1,percent,maxlen ); isdone = res.IsDone(); if (isdone){isconti = res.IsG2(); if (isconti) {if(res.C0Value()>MaxG0Value) MaxG0Value=res.C0Value(); if(res.G1Angle()>MaxG1Angle) MaxG1Angle=res.G1Angle(); if(res.G2CurvatureGap()>MaxG2Curvature) MaxG2Curvature=res.G2CurvatureGap(); }} else isconti = Standard_False;} else { LocalAnalysis_SurfaceContinuity res (curv1, curv2, (U+nb*deltaU), surf1,surf2, GeomAbs_G2,epsnl,epsC0, epsC1, epsC2, epsG1,percent,maxlen ); isdone = res.IsDone(); if ( isdone) {isconti = res.IsG2(); if (nb==0){MaxG0Value=res.C0Value(); MaxG1Angle=res.G1Angle(); MaxG2Curvature=res.G2CurvatureGap();} if(res.C0Value()>MaxG0Value) MaxG0Value=res.C0Value(); if(res.G1Angle()>MaxG1Angle) MaxG1Angle=res.G1Angle(); if(res.G2CurvatureGap()>MaxG2Curvature) MaxG2Curvature=res.G2CurvatureGap();} else isconti = Standard_False;} nb++; if (!isconti) ISG2=Standard_False; } while ((nb 0) { //cout< 0) { //cout<