// Created on: 1996-02-23 // Created by: Jacques GOUSSARD // Copyright (c) 1996-1999 Matra Datavision // Copyright (c) 1999-2012 OPEN CASCADE SAS // // The content of this file is subject to the Open CASCADE Technology Public // License Version 6.5 (the "License"). You may not use the content of this file // except in compliance with the License. Please obtain a copy of the License // at http://www.opencascade.org and read it completely before using this file. // // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. // // The Original Code and all software distributed under the License is // distributed on an "AS IS" basis, without warranty of any kind, and the // Initial Developer hereby disclaims all such warranties, including without // limitation, any warranties of merchantability, fitness for a particular // purpose or non-infringement. Please see the License for the specific terms // and conditions governing the rights and limitations under the License. // modified by mps (dec 96) ajout des commandes pour l'analyse de continuite #include #ifdef HAVE_CONFIG_H # include #endif #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 //#ifdef WNT #include #ifdef WNT //#define strcasecmp strcmp Already defined #endif #ifdef HAVE_STRINGS_H # include #endif 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, const 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 = 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) { 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) { const char* pName; if (!FindNamed(sub,pName)) { nbfaulty++; char aName[256]; Sprintf(aName,"%.80s%d",checkfaultyname,nbfaulty); DBRep::Set(aName,sub); pName = aName; lfaulty.Append(Draw::Get(pName)); OS << "Shape " << pName << " "; if (!FindNamed(S,pName)) { nbfaulty++; Sprintf(aName,"%.80s%d",checkfaultyname,nbfaulty); DBRep::Set(aName,S); pName = aName; lfaulty.Append(Draw::Get(pName)); } OS << " on shape " << pName << " :\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()); } 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) { const char* pName; char aName[256]; if (!FindNamed(S,pName)) { nbfaulty++; Sprintf(aName,"%.80s%d",checkfaultyname,nbfaulty); DBRep::Set(aName,S); pName = aName; lfaulty.Append(Draw::Get(pName)); } OS << "On Shape " << pName << " :\n"; for (;itl.More(); itl.Next()) { 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_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]); 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]); 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"<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); NbProblems->ChangeValue(itl.Value())++; } for(ii=1; ii<=sl->Length(); ii++) if(sl->Value(ii).IsSame(Shape)) break; if(ii>sl->Length()) { sl->Append(Shape); NbProblems->ChangeValue(itl.Value())++; } } 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); NbProblems->ChangeValue(itl.Value())++; } } 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; theCommands << " -- The Shape " << ShName << " has problems :"<<"\n"; theCommands<<" Check Count"<<"\n"; theCommands<<" ------------------------------------------------"<<"\n"; Handle(TColStd_HArray1OfInteger) NbProblems = new TColStd_HArray1OfInteger(1,33); for (i=1; i<=33; i++) NbProblems->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(); NCollection_Array1 aProblems (1,33); aProblems.SetValue( BRepCheck_InvalidPointOnCurve, " Invalid Point on Curve ................... "); aProblems.SetValue(BRepCheck_InvalidPointOnCurveOnSurface, " Invalid Point on CurveOnSurface .......... "); aProblems.SetValue(BRepCheck_InvalidPointOnSurface, " Invalid Point on Surface ................. "); aProblems.SetValue(BRepCheck_No3DCurve, " No 3D Curve .............................. "); aProblems.SetValue(BRepCheck_Multiple3DCurve, " Multiple 3D Curve ........................ "); aProblems.SetValue(BRepCheck_Invalid3DCurve, " Invalid 3D Curve ......................... "); aProblems.SetValue(BRepCheck_NoCurveOnSurface, " No Curve on Surface ...................... "); aProblems.SetValue(BRepCheck_InvalidCurveOnSurface, " Invalid Curve on Surface ................. "); aProblems.SetValue(BRepCheck_InvalidCurveOnClosedSurface, " Invalid Curve on Closed Surface ................. "); aProblems.SetValue(BRepCheck_InvalidSameRangeFlag, " Invalid SameRange Flag ................... "); aProblems.SetValue(BRepCheck_InvalidSameParameterFlag, " Invalid SameParameter Flag ............... "); aProblems.SetValue(BRepCheck_InvalidDegeneratedFlag, " Invalid Degenerated Flag ................. "); aProblems.SetValue(BRepCheck_FreeEdge, " Free Edge ................................ "); aProblems.SetValue(BRepCheck_InvalidMultiConnexity, " Invalid Multi Connexity ................... "); aProblems.SetValue(BRepCheck_InvalidRange, " Invalid Range ................... "); aProblems.SetValue(BRepCheck_EmptyWire, " Empty Wire ................... "); aProblems.SetValue(BRepCheck_RedundantEdge, " BRepCheck_RedundantEdge ................... "); aProblems.SetValue(BRepCheck_SelfIntersectingWire, " Self Intersecting Wire ................... "); aProblems.SetValue(BRepCheck_NoSurface, " No Surface ................... "); aProblems.SetValue(BRepCheck_InvalidWire, " Invalid Wire ................... "); aProblems.SetValue(BRepCheck_RedundantWire, " Redundant Wire ................... "); aProblems.SetValue(BRepCheck_IntersectingWires, " Intersecting Wires ................... "); aProblems.SetValue(BRepCheck_InvalidImbricationOfWires, " Invalid Imbrication Of Wires .................. "); aProblems.SetValue(BRepCheck_EmptyShell, " Empty Shell ................... "); aProblems.SetValue(BRepCheck_RedundantFace, " Redundant Face ................... "); aProblems.SetValue(BRepCheck_UnorientableShape, " Unorientable Shape ................... "); aProblems.SetValue(BRepCheck_NotClosed, " Not Closed ................... "); aProblems.SetValue(BRepCheck_NotConnected, " Not Connected ................... "); aProblems.SetValue(BRepCheck_SubshapeNotInShape, " Subshape Not In Shape ................... "); aProblems.SetValue(BRepCheck_BadOrientation, " Bad Orientation ................... "); aProblems.SetValue(BRepCheck_BadOrientationOfSubshape, " Bad Orientation of Subshape .............. "); aProblems.SetValue(BRepCheck_InvalidToleranceValue, " Invalid tolerance value................... "); aProblems.SetValue(BRepCheck_CheckFail, " Checkshape failure....................... "); for (Standard_Integer i = (Standard_Integer)BRepCheck_InvalidPointOnCurve; i <= (Standard_Integer)BRepCheck_CheckFail; ++i) { if (NbProblems->Value (i) > 0) theCommands << i << aProblems.Value (i) << "\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) { theCommands<<"checkshape exception : "; theCommands << Standard_Failure::Caught()->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<