1 // Created on: 1995-12-11
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepCheck_Edge.ixx>
18 #include <TColStd_Array1OfTransient.hxx>
19 #include <TColStd_HArray1OfReal.hxx>
21 #include <BRepAdaptor_Curve.hxx>
22 #include <Bnd_Box.hxx>
24 #include <BRepCheck_ListOfStatus.hxx>
25 #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
27 #include <BRep_TEdge.hxx>
28 #include <BRep_TFace.hxx>
30 #include <BRep_CurveRepresentation.hxx>
31 #include <BRep_ListOfCurveRepresentation.hxx>
32 #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
33 #include <BRep_GCurve.hxx>
34 #include <BRep_CurveOnSurface.hxx>
36 #include <BRep_PolygonOnTriangulation.hxx>
38 #include <BRep_Tool.hxx>
40 #include <TopExp_Explorer.hxx>
42 #include <Geom_Surface.hxx>
43 #include <Geom_RectangularTrimmedSurface.hxx>
44 #include <Geom_Plane.hxx>
45 #include <Geom_TrimmedCurve.hxx>
46 #include <Geom2d_Curve.hxx>
48 #include <Geom2dAdaptor_HCurve.hxx>
49 #include <GeomAdaptor_Curve.hxx>
50 #include <GeomAdaptor_HCurve.hxx>
51 #include <GeomAdaptor_HSurface.hxx>
52 #include <Adaptor3d_CurveOnSurface.hxx>
53 #include <Adaptor3d_HCurveOnSurface.hxx>
55 #include <ProjLib_ProjectedCurve.hxx>
56 #include <GeomProjLib.hxx>
57 #include <Extrema_LocateExtPC.hxx>
59 #include <BRepCheck.hxx>
60 #include <Geom2dAdaptor.hxx>
62 #include <TopAbs_ShapeEnum.hxx>
63 #include <TopoDS_Face.hxx>
64 #include <Precision.hxx>
66 #include <Poly_PolygonOnTriangulation.hxx>
67 #include <Poly_Triangulation.hxx>
69 //modified by NIZNHY-PKV Thu May 05 09:01:57 2011f
71 Standard_Boolean Validate(const Adaptor3d_Curve&,
72 const Adaptor3d_CurveOnSurface&,
74 const Standard_Boolean);
76 void PrintProblematicPoint(const gp_Pnt&,
81 Standard_Real Prec(const Adaptor3d_Curve& aAC3D,
82 const Adaptor3d_CurveOnSurface& aACS);
84 Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D);
86 Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS);
88 //static Standard_Boolean Validate(const Adaptor3d_Curve&,
89 // const Adaptor3d_Curve&,
90 // const Standard_Real,
91 // const Standard_Boolean);
92 //modified by NIZNHY-PKV Thu May 05 09:02:01 2011t
94 static const Standard_Integer NCONTROL=23;
96 //=======================================================================
97 //function : BRepCheck_Edge
99 //=======================================================================
101 BRepCheck_Edge::BRepCheck_Edge(const TopoDS_Edge& E)
104 myGctrl = Standard_True;
107 //=======================================================================
110 //=======================================================================
112 void BRepCheck_Edge::Minimum()
116 BRepCheck_ListOfStatus thelist;
117 myMap.Bind(myShape, thelist);
118 BRepCheck_ListOfStatus& lst = myMap(myShape);
121 // Existence et unicite d`une representation 3D
122 Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
123 BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
124 Standard_Boolean exist = Standard_False;
125 Standard_Boolean unique = Standard_True;
126 // Search for a 3D reference. If no existent one, creates it with the
127 // first encountered CurveOnSurf; if multiple, chooses the first one...
129 Standard_Boolean Degenerated = TE->Degenerated();
130 Standard_Boolean SameParameter = TE->SameParameter();
131 Standard_Boolean SameRange = TE->SameRange();
132 if (!SameRange && SameParameter) {
133 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
135 // Handle(Geom_Curve) C3d;
137 while (itcr.More()) {
138 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
139 if (cr->IsCurve3D()) {
141 exist = Standard_True;
144 unique = Standard_False;
146 if (myCref.IsNull() && !cr->Curve3D().IsNull()) {
154 BRepCheck::Add(lst,BRepCheck_No3DCurve);
158 BRepCheck::Add(lst,BRepCheck_Multiple3DCurve);
161 if (myCref.IsNull() && !Degenerated) {
162 itcr.Initialize(TE->Curves());
163 while (itcr.More()) {
164 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
165 if (cr->IsCurveOnSurface()) {
172 else if (!myCref.IsNull() && Degenerated){
173 BRepCheck::Add(lst,BRepCheck_InvalidDegeneratedFlag);
176 if (!myCref.IsNull()) {
177 const Handle(BRep_GCurve)& GCref = *((Handle(BRep_GCurve)*)&myCref);
178 Standard_Real First,Last;
179 GCref->Range(First,Last);
182 BRepCheck::Add(lst,BRepCheck_InvalidRange);
185 if (myCref->IsCurve3D()) {
186 // eap 6 Jun 2002 occ332
187 // better transform C3d instead of transforming Surf upto C3d initial location,
188 // on transformed BSpline surface 'same parameter' may seem wrong
189 TopLoc_Location L = myShape.Location() * myCref->Location();
190 Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
191 (myCref->Curve3D()->Transformed
192 (/*myCref->Location()*/L.Transformation()));
193 GeomAdaptor_Curve GAC3d(C3d, C3d->TransformedParameter(First, L.Transformation()),
194 C3d->TransformedParameter(Last, L.Transformation()));
195 myHCurve = new GeomAdaptor_HCurve(GAC3d);
197 else { // curve on surface
198 Handle(Geom_Surface) Sref = myCref->Surface();
199 Sref = Handle(Geom_Surface)::DownCast
200 (Sref->Transformed(myCref->Location().Transformation()));
201 const Handle(Geom2d_Curve)& PCref = myCref->PCurve();
202 Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
203 Handle(Geom2dAdaptor_HCurve) GHPCref =
204 new Geom2dAdaptor_HCurve(PCref,First,Last);
205 Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
206 myHCurve = new Adaptor3d_HCurveOnSurface(ACSref);
211 lst.Append(BRepCheck_NoError);
213 myMin = Standard_True;
218 //=======================================================================
219 //function : InContext
221 //=======================================================================
223 void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
225 if (myMap.IsBound(S)) {
228 BRepCheck_ListOfStatus thelist;
229 myMap.Bind(S, thelist);
230 BRepCheck_ListOfStatus& lst = myMap(S);
232 Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
233 Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape));
235 TopAbs_ShapeEnum styp = S.ShapeType();
236 // for (TopExp_Explorer exp(S,TopAbs_EDGE); exp.More(); exp.Next()) {
237 TopExp_Explorer exp(S,TopAbs_EDGE) ;
238 for ( ; exp.More(); exp.Next()) {
239 if (exp.Current().IsSame(myShape)) {
244 BRepCheck::Add(lst,BRepCheck_SubshapeNotInShape);
256 if (!myCref.IsNull()) {
258 Standard_Boolean SameParameter = TE->SameParameter();
259 Standard_Boolean SameRange = TE->SameRange();
260 // Modified by skv - Tue Apr 27 11:48:13 2004 Begin
261 if (!SameParameter || !SameRange) {
263 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
265 BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
269 // Modified by skv - Tue Apr 27 11:48:14 2004 End
270 Standard_Real First = myHCurve->FirstParameter();
271 Standard_Real Last = myHCurve->LastParameter();
273 Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape());
274 const TopLoc_Location& Floc = S.Location();
275 const TopLoc_Location& TFloc = TF->Location();
276 const Handle(Geom_Surface)& Su = TF->Surface();
277 TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location());
278 TopLoc_Location LE = myShape.Location() * myCref->Location();
279 const gp_Trsf& Etrsf = LE.Transformation();
280 Standard_Boolean pcurvefound = Standard_False;
282 BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
283 while (itcr.More()) {
284 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
285 if (cr != myCref && cr->IsCurveOnSurface(Su,L)) {
286 pcurvefound = Standard_True;
287 const Handle(BRep_GCurve)& GC = *((Handle(BRep_GCurve)*)&cr);
290 Standard_Real ff = f, ll = l;
291 if(myCref->IsCurve3D())
293 ff = myCref->Curve3D()->TransformedParameter(f, Etrsf);
294 ll = myCref->Curve3D()->TransformedParameter(l, Etrsf);
297 // Modified by skv - Tue Apr 27 11:50:35 2004 Begin
298 if (Abs(ff-First) > Precision::PConfusion() ||
299 Abs(ll-Last) > Precision::PConfusion()) {
300 BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
301 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
303 // Modified by skv - Tue Apr 27 11:50:37 2004 End
305 Handle(Geom_Surface) Sb = cr->Surface();
306 Sb = Handle(Geom_Surface)::DownCast
307 // (Su->Transformed(L.Transformation()));
308 (Su->Transformed(/*L*/(Floc * TFloc).Transformation()));
309 Handle(Geom2d_Curve) PC = cr->PCurve();
310 Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Sb);
311 Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l);
312 Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
313 Standard_Boolean ok =
314 Validate(myHCurve->Curve() ,ACS,Tol,SameParameter);
316 if (cr->IsCurveOnClosedSurface()) {
317 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
320 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
322 // Modified by skv - Tue Apr 27 11:53:00 2004 Begin
323 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
324 // if (SameParameter) {
325 // BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
327 // Modified by skv - Tue Apr 27 11:53:01 2004 End
329 if (cr->IsCurveOnClosedSurface()) {
330 GHPC->ChangeCurve2d().Load(cr->PCurve2(),f,l); // same bounds
331 ACS.Load(GAHS); // sans doute inutile
332 ACS.Load(GHPC); // meme remarque...
333 ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter);
335 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
336 // Modified by skv - Tue Apr 27 11:53:20 2004 Begin
338 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
340 // Modified by skv - Tue Apr 27 11:53:23 2004 End
349 Handle(Geom_Plane) P;
350 Handle(Standard_Type) dtyp = Su->DynamicType();
351 if (dtyp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
352 P = Handle(Geom_Plane)::DownCast
353 (Handle(Geom_RectangularTrimmedSurface)::
354 DownCast(Su)->BasisSurface());
357 P = Handle(Geom_Plane)::DownCast(Su);
359 if (P.IsNull()) { // not a plane
360 BRepCheck::Add(lst,BRepCheck_NoCurveOnSurface);
362 else { // on fait la projection a la volee, comme BRep_Tool
365 P = Handle(Geom_Plane)::
366 DownCast(P->Transformed(/*L*/(Floc * TFloc).Transformation()));// eap occ332
367 //on projette Cref sur ce plan
368 Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(P);
370 // Dub - Normalement myHCurve est une GeomAdaptor_HCurve
371 GeomAdaptor_Curve& Gac =
372 Handle(GeomAdaptor_HCurve)::DownCast(myHCurve)->ChangeCurve();
373 Handle(Geom_Curve) C3d = Gac.Curve();
374 Handle(Geom_Curve) ProjOnPlane =
375 GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,First,Last),
376 P, P->Position().Direction(),
378 Handle(GeomAdaptor_HCurve) aHCurve =
379 new GeomAdaptor_HCurve(ProjOnPlane);
381 ProjLib_ProjectedCurve proj(GAHS,aHCurve);
382 Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj);
383 Handle(Geom2dAdaptor_HCurve) GHPC =
384 new Geom2dAdaptor_HCurve(PC,
385 myHCurve->FirstParameter(),
386 myHCurve->LastParameter());
388 Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
390 Standard_Boolean ok = Validate(myHCurve->Curve(),ACS,
391 Tol,Standard_True); // voir dub...
393 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
402 // on verifie que l`edge est bien connectee 2 fois (pas de bord libre)
403 Standard_Integer nbconnection = 0;
404 //TopExp_Explorer exp;
405 for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) {
406 const TopoDS_Face& fac = TopoDS::Face(exp.Current());
407 TopExp_Explorer exp2;
408 for (exp2.Init(fac,TopAbs_EDGE); exp2.More(); exp2.Next()) {
409 if (exp2.Current().IsSame(myShape)) {
414 if (nbconnection < 2 && !TE->Degenerated()) {
415 BRepCheck::Add(myMap(S),BRepCheck_FreeEdge);
417 else if (nbconnection > 2) {
418 BRepCheck::Add(myMap(S),BRepCheck_InvalidMultiConnexity);
421 BRepCheck::Add(myMap(S),BRepCheck_NoError);
428 if (myMap(S).IsEmpty()) {
429 myMap(S).Append(BRepCheck_NoError);
434 //=======================================================================
437 //=======================================================================
439 void BRepCheck_Edge::Blind()
441 // Modified by skv - Tue Apr 27 11:36:01 2004 Begin
442 // The body of this function is removed because of its useless.
444 myBlind = Standard_True;
446 // Modified by skv - Tue Apr 27 11:36:02 2004 End
450 //=======================================================================
451 //function : GeometricControls
453 //=======================================================================
455 void BRepCheck_Edge::GeometricControls(const Standard_Boolean B)
461 //=======================================================================
462 //function : GeometricControls
464 //=======================================================================
466 Standard_Boolean BRepCheck_Edge::GeometricControls() const
471 //=======================================================================
472 //function : SetStatus
474 //=======================================================================
475 void BRepCheck_Edge::SetStatus(const BRepCheck_Status theStatus)
477 BRepCheck::Add(myMap(myShape),theStatus);
481 //=======================================================================
482 //function : Tolerance
484 //=======================================================================
486 Standard_Real BRepCheck_Edge::Tolerance()
488 Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
489 Standard_Integer it, iRep=1, nbRep=(TE->Curves()).Extent();
491 return Precision::Confusion();
493 TColStd_Array1OfTransient theRep(1, nbRep*2);
494 Standard_Real First, Last;
495 if (!myHCurve.IsNull()) {
496 First = myHCurve->FirstParameter();
497 Last= myHCurve->LastParameter();
500 BRep_Tool::Range(TopoDS::Edge(myShape), First, Last);
503 BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
504 for (; itcr.More(); itcr.Next()) {
505 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
506 if (cr->IsCurve3D() && !TE->Degenerated()) {
507 //// modified by jgv, 20.03.03 ////
508 TopLoc_Location Loc = myShape.Location() * cr->Location();
509 Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
510 (cr->Curve3D()->Transformed( Loc.Transformation() ));
511 ///////////////////////////////////
512 GeomAdaptor_Curve GAC3d(C3d,First,Last);
515 theRep(iRep)=theRep(1);
518 theRep(it) = new GeomAdaptor_HCurve(GAC3d);
521 else if (cr->IsCurveOnSurface()) {
523 Handle(Geom_Surface) Sref = cr->Surface();
524 //// modified by jgv, 20.03.03 ////
525 TopLoc_Location Loc = myShape.Location() * cr->Location();
526 Sref = Handle(Geom_Surface)::DownCast
527 (Sref->Transformed( Loc.Transformation() ));
528 ///////////////////////////////////
529 const Handle(Geom2d_Curve)& PCref = cr->PCurve();
530 Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
531 Handle(Geom2dAdaptor_HCurve) GHPCref =
532 new Geom2dAdaptor_HCurve(PCref,First,Last);
533 Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
534 theRep(iRep) = new Adaptor3d_HCurveOnSurface(ACSref);
537 if (cr->IsCurveOnClosedSurface()) {
538 Handle(Geom_Surface) Sref = cr->Surface();
539 Sref = Handle(Geom_Surface)::DownCast
540 (Sref->Transformed(cr->Location().Transformation()));
541 const Handle(Geom2d_Curve)& PCref = cr->PCurve2();
542 Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
543 Handle(Geom2dAdaptor_HCurve) GHPCref =
544 new Geom2dAdaptor_HCurve(PCref,First,Last);
545 Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
546 theRep(iRep) = new Adaptor3d_HCurveOnSurface(ACSref);
556 Standard_Real dist2, tol2, tolCal=0., prm;
559 for (i= 0; i< NCONTROL; i++) {
560 prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
562 center=(*(Handle(Adaptor3d_HCurve)*)&theRep(1))->Value(prm);
563 for (iRep=2; iRep<=nbRep; iRep++) {
564 othP=(*(Handle(Adaptor3d_HCurve)*)&theRep(iRep))->Value(prm);
565 dist2=center.SquareDistance(othP);
566 if (dist2>tolCal) tolCal=dist2;
572 // On prend 5% de marge car au dessus on crontrole severement
573 return sqrt(tolCal)*1.05;
577 //=======================================================================
578 //function : CheckPolygonOnTriangulation
580 //=======================================================================
581 BRepCheck_Status BRepCheck_Edge::
582 CheckPolygonOnTriangulation(const TopoDS_Edge& theEdge)
584 BRep_ListOfCurveRepresentation& aListOfCR =
585 (*((Handle(BRep_TEdge)*) &theEdge.TShape()))->ChangeCurves();
586 BRep_ListIteratorOfListOfCurveRepresentation anITCR(aListOfCR);
588 BRepAdaptor_Curve aBC;
589 aBC.Initialize(theEdge);
592 return BRepCheck_NoError;
594 while (anITCR.More())
596 if(!anITCR.Value()->IsPolygonOnTriangulation())
602 const Handle(BRep_CurveRepresentation) aCR = anITCR.Value();
603 const Handle(BRep_PolygonOnTriangulation)& aPT =
604 Handle(BRep_PolygonOnTriangulation)::DownCast(aCR);
606 const TopLoc_Location aLL = theEdge.Location() * aPT->Location();
608 const Handle(Poly_Triangulation) aTriang = aCR->Triangulation();
609 const Handle(Poly_PolygonOnTriangulation) aPOnTriag =
610 aCR->IsPolygonOnClosedTriangulation() ?
611 aCR->PolygonOnTriangulation2() :
612 aCR->PolygonOnTriangulation();
613 const TColStd_Array1OfInteger& anIndices = aPOnTriag->Nodes();
614 const TColgp_Array1OfPnt& Nodes = aTriang->Nodes();
615 const Standard_Integer aNbNodes = anIndices.Length();
617 const Standard_Real aTol = aPOnTriag->Deflection() +
618 BRep_Tool::Tolerance(theEdge);
620 if(aPOnTriag->HasParameters())
622 for(Standard_Integer i = aPOnTriag->Parameters()->Lower();
623 i <= aPOnTriag->Parameters()->Upper(); i++)
625 const Standard_Real aParam = aPOnTriag->Parameters()->Value(i);
626 const gp_Pnt aPE(aBC.Value(aParam)),
627 aPT(Nodes(anIndices(i)).Transformed(aLL));
629 const Standard_Real aSQDist = aPE.SquareDistance(aPT);
630 if(aSQDist > aTol*aTol)
632 return BRepCheck_InvalidPolygonOnTriangulation;
638 //If aPOnTriag does not have any parameters we will check if it
639 //inscribes into Bounding box, which is built on the edge triangulation.
643 for (Standard_Integer i = 1; i <= aNbNodes; i++)
645 if (aLL.IsIdentity())
646 aB.Add(Nodes(anIndices(i)));
648 aB.Add(Nodes(anIndices(i)).Transformed(aLL));
653 Standard_Real aFP = aBC.FirstParameter();
654 Standard_Real aLP = aBC.LastParameter();
656 const Standard_Real aStep = (aLP - aFP)/IntToReal(NCONTROL);
658 Standard_Real aPar = aFP;
660 for(Standard_Integer i = 1; i < NCONTROL; i ++)
665 return BRepCheck_InvalidPolygonOnTriangulation;
674 return BRepCheck_InvalidPolygonOnTriangulation;
681 return BRepCheck_NoError;
684 //=======================================================================
685 //function : Validate
687 //=======================================================================
688 Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
689 const Adaptor3d_CurveOnSurface& Other,
690 const Standard_Real Tol,
691 const Standard_Boolean SameParameter)
693 Standard_Boolean Status, proj;
694 Standard_Real aPC, First, Last, Error;
695 gp_Pnt problematic_point ;
697 Status = Standard_True;
699 First = CRef.FirstParameter();
700 Last = CRef.LastParameter();
702 aPC=Precision::PConfusion();
703 proj = (!SameParameter ||
704 Abs(Other.FirstParameter()-First) > aPC ||
705 Abs( Other.LastParameter()-Last) > aPC);
709 Standard_Real Tol2, prm, dD;
711 //modified by NIZNHY-PKV Thu May 05 09:06:41 2011f
713 dD=Prec(CRef, Other);//3.e-15;
717 //modified by NIZNHY-PKV Thu May 05 09:06:47 2011t
719 for (i = 0; i < NCONTROL; ++i) {
720 prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
721 pref = CRef.Value(prm);
722 pother = Other.Value(prm);
723 if (pref.SquareDistance(pother) > Tol2) {
724 problematic_point = pref ;
725 Status = Standard_False;
726 Error = pref.Distance(pother);
727 PrintProblematicPoint(problematic_point, Error, Tol);
734 Extrema_LocateExtPC refd,otherd;
735 Standard_Real OFirst = Other.FirstParameter();
736 Standard_Real OLast = Other.LastParameter();
737 gp_Pnt pd = CRef.Value(First);
738 gp_Pnt pdo = Other.Value(OFirst);
739 Standard_Real distt = pd.SquareDistance(pdo);
740 if (distt > Tol*Tol) {
741 problematic_point = pd ;
742 Status = Standard_False ;
744 PrintProblematicPoint(problematic_point, Error, Tol);
748 pd = CRef.Value(Last);
749 pdo = Other.Value(OLast);
750 distt = pd.SquareDistance(pdo);
751 if (distt > Tol*Tol) {
752 problematic_point = pd ;
753 Status = Standard_False ;
755 PrintProblematicPoint(problematic_point, Error, Tol);
760 refd.Initialize(CRef,First,Last,CRef.Resolution(Tol));
761 otherd.Initialize(Other,OFirst,OLast,Other.Resolution(Tol));
762 for (Standard_Integer i = 2; i< NCONTROL-1; i++) {
763 Standard_Real rprm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
764 gp_Pnt pref = CRef.Value(rprm);
765 Standard_Real oprm = ((NCONTROL-1-i)*OFirst + i*OLast)/(NCONTROL-1);
766 gp_Pnt pother = Other.Value(oprm);
767 refd.Perform(pother,rprm);
768 if (!refd.IsDone() || refd.SquareDistance() > Tol * Tol) {
769 problematic_point = pref ;
770 Status = Standard_False ;
772 Error = sqrt (refd.SquareDistance());
777 PrintProblematicPoint(problematic_point, Error, Tol);
781 otherd.Perform(pref,oprm);
782 if (!otherd.IsDone() || otherd.SquareDistance() > Tol * Tol) {
783 problematic_point = pref ;
784 Status = Standard_False ;
785 if (otherd.IsDone()) {
786 Error = sqrt (otherd.SquareDistance());
791 PrintProblematicPoint(problematic_point, Error, Tol);
801 //=======================================================================
804 //=======================================================================
805 Standard_Real Prec(const Adaptor3d_Curve& aAC3D,
806 const Adaptor3d_CurveOnSurface& aACS)
808 Standard_Real aXEmax, aXC, aXS;
810 aXC=PrecCurve(aAC3D);
811 aXS=PrecSurface(aACS);
812 aXEmax=(aXC>aXS) ? aXC: aXS;
815 //=======================================================================
816 //function : PrecCurve
818 //=======================================================================
819 Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D)
821 Standard_Real aXEmax;
822 GeomAbs_CurveType aCT;
824 aXEmax=RealEpsilon();
827 if (aCT==GeomAbs_Ellipse) {
829 Standard_Real aX[5], aXE;
831 gp_Elips aEL3D=aAC3D.Ellipse();
832 aEL3D.Location().Coord(aX[0], aX[1], aX[2]);
833 aX[3]=aEL3D.MajorRadius();
834 aX[4]=aEL3D.MinorRadius();
836 for (i=0; i<5; ++i) {
845 }//if (aCT=GeomAbs_Ellipse) {
849 //=======================================================================
850 //function : PrecSurface
852 //=======================================================================
853 Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS)
855 Standard_Real aXEmax;
856 GeomAbs_SurfaceType aST;
858 aXEmax=RealEpsilon();
860 const Handle(Adaptor3d_HSurface)& aAHS=aACS.GetSurface();
862 if (aST==GeomAbs_Cone) {
863 gp_Cone aCone=aAHS->Cone();
865 Standard_Real aX[4], aXE;
867 aCone.Location().Coord(aX[0], aX[1], aX[2]);
868 aX[3]=aCone.RefRadius();
870 for (i=0; i<4; ++i) {
879 }//if (aST==GeomAbs_Cone) {
882 //=======================================================================
883 //function : PrintProblematicPoint
885 //=======================================================================
887 void PrintProblematicPoint(const gp_Pnt& problematic_point,
888 const Standard_Real Error,
889 const Standard_Real Tol)
891 cout << " **** probleme de SameParameter au point :" << endl;
892 cout << " " << problematic_point.Coord(1) << " "
893 << problematic_point.Coord(2) << " " << problematic_point.Coord(3) << endl ;
894 cout << " Erreur detectee :" << Error << " Tolerance :" << Tol << endl;
897 void PrintProblematicPoint(const gp_Pnt&,