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>
68 #include <Geom_Curve.hxx>
70 //modified by NIZNHY-PKV Thu May 05 09:01:57 2011f
72 Standard_Boolean Validate(const Adaptor3d_Curve&,
73 const Adaptor3d_CurveOnSurface&,
75 const Standard_Boolean);
77 void PrintProblematicPoint(const gp_Pnt&,
82 Standard_Real Prec(const Adaptor3d_Curve& aAC3D,
83 const Adaptor3d_CurveOnSurface& aACS);
85 Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D);
87 Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS);
89 //static Standard_Boolean Validate(const Adaptor3d_Curve&,
90 // const Adaptor3d_Curve&,
91 // const Standard_Real,
92 // const Standard_Boolean);
93 //modified by NIZNHY-PKV Thu May 05 09:02:01 2011t
95 static const Standard_Integer NCONTROL=23;
97 //=======================================================================
98 //function : BRepCheck_Edge
100 //=======================================================================
102 BRepCheck_Edge::BRepCheck_Edge(const TopoDS_Edge& E)
105 myGctrl = Standard_True;
108 //=======================================================================
111 //=======================================================================
113 void BRepCheck_Edge::Minimum()
117 BRepCheck_ListOfStatus thelist;
118 myMap.Bind(myShape, thelist);
119 BRepCheck_ListOfStatus& lst = myMap(myShape);
122 // Existence et unicite d`une representation 3D
123 Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
124 BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
125 Standard_Boolean exist = Standard_False;
126 Standard_Boolean unique = Standard_True;
127 // Search for a 3D reference. If no existent one, creates it with the
128 // first encountered CurveOnSurf; if multiple, chooses the first one...
130 Standard_Boolean Degenerated = TE->Degenerated();
131 Standard_Boolean SameParameter = TE->SameParameter();
132 Standard_Boolean SameRange = TE->SameRange();
133 if (!SameRange && SameParameter) {
134 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
136 // Handle(Geom_Curve) C3d;
138 while (itcr.More()) {
139 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
140 if (cr->IsCurve3D()) {
142 exist = Standard_True;
145 unique = Standard_False;
147 if (myCref.IsNull() && !cr->Curve3D().IsNull()) {
155 BRepCheck::Add(lst,BRepCheck_No3DCurve);
159 BRepCheck::Add(lst,BRepCheck_Multiple3DCurve);
162 if (myCref.IsNull() && !Degenerated) {
163 itcr.Initialize(TE->Curves());
164 while (itcr.More()) {
165 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
166 if (cr->IsCurveOnSurface()) {
173 else if (!myCref.IsNull() && Degenerated){
174 BRepCheck::Add(lst,BRepCheck_InvalidDegeneratedFlag);
177 if (!myCref.IsNull()) {
178 Handle(BRep_GCurve) GCref (Handle(BRep_GCurve)::DownCast (myCref));
179 Standard_Real First,Last;
180 GCref->Range(First,Last);
183 BRepCheck::Add(lst,BRepCheck_InvalidRange);
186 if (myCref->IsCurve3D()) {
187 // eap 6 Jun 2002 occ332
188 // better transform C3d instead of transforming Surf upto C3d initial location,
189 // on transformed BSpline surface 'same parameter' may seem wrong
190 TopLoc_Location L = myShape.Location() * myCref->Location();
191 Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
192 (myCref->Curve3D()->Transformed
193 (/*myCref->Location()*/L.Transformation()));
194 GeomAdaptor_Curve GAC3d(C3d, C3d->TransformedParameter(First, L.Transformation()),
195 C3d->TransformedParameter(Last, L.Transformation()));
196 myHCurve = new GeomAdaptor_HCurve(GAC3d);
198 else { // curve on surface
199 Handle(Geom_Surface) Sref = myCref->Surface();
200 Sref = Handle(Geom_Surface)::DownCast
201 (Sref->Transformed(myCref->Location().Transformation()));
202 const Handle(Geom2d_Curve)& PCref = myCref->PCurve();
203 Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
204 Handle(Geom2dAdaptor_HCurve) GHPCref =
205 new Geom2dAdaptor_HCurve(PCref,First,Last);
206 Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
207 myHCurve = new Adaptor3d_HCurveOnSurface(ACSref);
212 lst.Append(BRepCheck_NoError);
214 myMin = Standard_True;
219 //=======================================================================
220 //function : InContext
222 //=======================================================================
224 void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
226 if (myMap.IsBound(S)) {
229 BRepCheck_ListOfStatus thelist;
230 myMap.Bind(S, thelist);
231 BRepCheck_ListOfStatus& lst = myMap(S);
233 Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
234 Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape));
236 TopAbs_ShapeEnum styp = S.ShapeType();
237 // for (TopExp_Explorer exp(S,TopAbs_EDGE); exp.More(); exp.Next()) {
238 TopExp_Explorer exp(S,TopAbs_EDGE) ;
239 for ( ; exp.More(); exp.Next()) {
240 if (exp.Current().IsSame(myShape)) {
245 BRepCheck::Add(lst,BRepCheck_SubshapeNotInShape);
257 if (!myCref.IsNull()) {
259 Standard_Boolean SameParameter = TE->SameParameter();
260 Standard_Boolean SameRange = TE->SameRange();
261 // Modified by skv - Tue Apr 27 11:48:13 2004 Begin
262 if (!SameParameter || !SameRange) {
264 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
266 BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
270 // Modified by skv - Tue Apr 27 11:48:14 2004 End
271 Standard_Real First = myHCurve->FirstParameter();
272 Standard_Real Last = myHCurve->LastParameter();
274 Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape());
275 const TopLoc_Location& Floc = S.Location();
276 const TopLoc_Location& TFloc = TF->Location();
277 const Handle(Geom_Surface)& Su = TF->Surface();
278 TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location());
279 TopLoc_Location LE = myShape.Location() * myCref->Location();
280 const gp_Trsf& Etrsf = LE.Transformation();
281 Standard_Boolean pcurvefound = Standard_False;
283 BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
284 while (itcr.More()) {
285 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
286 if (cr != myCref && cr->IsCurveOnSurface(Su,L)) {
287 pcurvefound = Standard_True;
288 Handle(BRep_GCurve) GC (Handle(BRep_GCurve)::DownCast (cr));
291 Standard_Real ff = f, ll = l;
292 if(myCref->IsCurve3D())
294 ff = myCref->Curve3D()->TransformedParameter(f, Etrsf);
295 ll = myCref->Curve3D()->TransformedParameter(l, Etrsf);
298 // Modified by skv - Tue Apr 27 11:50:35 2004 Begin
299 if (Abs(ff-First) > Precision::PConfusion() ||
300 Abs(ll-Last) > Precision::PConfusion()) {
301 BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
302 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
304 // Modified by skv - Tue Apr 27 11:50:37 2004 End
306 Handle(Geom_Surface) Sb = cr->Surface();
307 Sb = Handle(Geom_Surface)::DownCast
308 // (Su->Transformed(L.Transformation()));
309 (Su->Transformed(/*L*/(Floc * TFloc).Transformation()));
310 Handle(Geom2d_Curve) PC = cr->PCurve();
311 Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Sb);
312 Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l);
313 Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
314 Standard_Boolean ok =
315 Validate(myHCurve->Curve() ,ACS,Tol,SameParameter);
317 if (cr->IsCurveOnClosedSurface()) {
318 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
321 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
323 // Modified by skv - Tue Apr 27 11:53:00 2004 Begin
324 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
325 // if (SameParameter) {
326 // BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
328 // Modified by skv - Tue Apr 27 11:53:01 2004 End
330 if (cr->IsCurveOnClosedSurface()) {
331 GHPC->ChangeCurve2d().Load(cr->PCurve2(),f,l); // same bounds
332 ACS.Load(GAHS); // sans doute inutile
333 ACS.Load(GHPC); // meme remarque...
334 ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter);
336 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
337 // Modified by skv - Tue Apr 27 11:53:20 2004 Begin
339 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
341 // Modified by skv - Tue Apr 27 11:53:23 2004 End
350 Handle(Geom_Plane) P;
351 Handle(Standard_Type) dtyp = Su->DynamicType();
352 if (dtyp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
353 P = Handle(Geom_Plane)::DownCast
354 (Handle(Geom_RectangularTrimmedSurface)::
355 DownCast(Su)->BasisSurface());
358 P = Handle(Geom_Plane)::DownCast(Su);
360 if (P.IsNull()) { // not a plane
361 BRepCheck::Add(lst,BRepCheck_NoCurveOnSurface);
363 else { // on fait la projection a la volee, comme BRep_Tool
366 P = Handle(Geom_Plane)::
367 DownCast(P->Transformed(/*L*/(Floc * TFloc).Transformation()));// eap occ332
368 //on projette Cref sur ce plan
369 Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(P);
371 // Dub - Normalement myHCurve est une GeomAdaptor_HCurve
372 GeomAdaptor_Curve& Gac =
373 Handle(GeomAdaptor_HCurve)::DownCast(myHCurve)->ChangeCurve();
374 Handle(Geom_Curve) C3d = Gac.Curve();
375 Handle(Geom_Curve) ProjOnPlane =
376 GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,First,Last),
377 P, P->Position().Direction(),
379 Handle(GeomAdaptor_HCurve) aHCurve =
380 new GeomAdaptor_HCurve(ProjOnPlane);
382 ProjLib_ProjectedCurve proj(GAHS,aHCurve);
383 Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj);
384 Handle(Geom2dAdaptor_HCurve) GHPC =
385 new Geom2dAdaptor_HCurve(PC,
386 myHCurve->FirstParameter(),
387 myHCurve->LastParameter());
389 Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
391 Standard_Boolean ok = Validate(myHCurve->Curve(),ACS,
392 Tol,Standard_True); // voir dub...
394 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
403 // on verifie que l`edge est bien connectee 2 fois (pas de bord libre)
404 Standard_Integer nbconnection = 0;
405 //TopExp_Explorer exp;
406 for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) {
407 const TopoDS_Face& fac = TopoDS::Face(exp.Current());
408 TopExp_Explorer exp2;
409 for (exp2.Init(fac,TopAbs_EDGE); exp2.More(); exp2.Next()) {
410 if (exp2.Current().IsSame(myShape)) {
415 if (nbconnection < 2 && !TE->Degenerated()) {
416 BRepCheck::Add(myMap(S),BRepCheck_FreeEdge);
418 else if (nbconnection > 2) {
419 BRepCheck::Add(myMap(S),BRepCheck_InvalidMultiConnexity);
422 BRepCheck::Add(myMap(S),BRepCheck_NoError);
429 if (myMap(S).IsEmpty()) {
430 myMap(S).Append(BRepCheck_NoError);
435 //=======================================================================
438 //=======================================================================
440 void BRepCheck_Edge::Blind()
442 // Modified by skv - Tue Apr 27 11:36:01 2004 Begin
443 // The body of this function is removed because of its useless.
445 myBlind = Standard_True;
447 // Modified by skv - Tue Apr 27 11:36:02 2004 End
451 //=======================================================================
452 //function : GeometricControls
454 //=======================================================================
456 void BRepCheck_Edge::GeometricControls(const Standard_Boolean B)
462 //=======================================================================
463 //function : GeometricControls
465 //=======================================================================
467 Standard_Boolean BRepCheck_Edge::GeometricControls() const
472 //=======================================================================
473 //function : SetStatus
475 //=======================================================================
476 void BRepCheck_Edge::SetStatus(const BRepCheck_Status theStatus)
478 BRepCheck::Add(myMap(myShape),theStatus);
482 //=======================================================================
483 //function : Tolerance
485 //=======================================================================
487 Standard_Real BRepCheck_Edge::Tolerance()
489 Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
490 Standard_Integer it, iRep=1, nbRep=(TE->Curves()).Extent();
492 return Precision::Confusion();
494 TColStd_Array1OfTransient theRep(1, nbRep*2);
495 Standard_Real First, Last;
496 if (!myHCurve.IsNull()) {
497 First = myHCurve->FirstParameter();
498 Last= myHCurve->LastParameter();
501 BRep_Tool::Range(TopoDS::Edge(myShape), First, Last);
504 BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
505 for (; itcr.More(); itcr.Next()) {
506 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
507 if (cr->IsCurve3D() && !TE->Degenerated()) {
508 //// modified by jgv, 20.03.03 ////
509 TopLoc_Location Loc = myShape.Location() * cr->Location();
510 Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
511 (cr->Curve3D()->Transformed( Loc.Transformation() ));
512 ///////////////////////////////////
513 GeomAdaptor_Curve GAC3d(C3d,First,Last);
516 theRep(iRep)=theRep(1);
519 theRep(it) = new GeomAdaptor_HCurve(GAC3d);
522 else if (cr->IsCurveOnSurface()) {
524 Handle(Geom_Surface) Sref = cr->Surface();
525 //// modified by jgv, 20.03.03 ////
526 TopLoc_Location Loc = myShape.Location() * cr->Location();
527 Sref = Handle(Geom_Surface)::DownCast
528 (Sref->Transformed( Loc.Transformation() ));
529 ///////////////////////////////////
530 const Handle(Geom2d_Curve)& PCref = cr->PCurve();
531 Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
532 Handle(Geom2dAdaptor_HCurve) GHPCref =
533 new Geom2dAdaptor_HCurve(PCref,First,Last);
534 Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
535 theRep(iRep) = new Adaptor3d_HCurveOnSurface(ACSref);
538 if (cr->IsCurveOnClosedSurface()) {
539 Handle(Geom_Surface) Sref = cr->Surface();
540 Sref = Handle(Geom_Surface)::DownCast
541 (Sref->Transformed(cr->Location().Transformation()));
542 const Handle(Geom2d_Curve)& PCref = cr->PCurve2();
543 Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
544 Handle(Geom2dAdaptor_HCurve) GHPCref =
545 new Geom2dAdaptor_HCurve(PCref,First,Last);
546 Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
547 theRep(iRep) = new Adaptor3d_HCurveOnSurface(ACSref);
557 Standard_Real dist2, tol2, tolCal=0., prm;
560 for (i= 0; i< NCONTROL; i++) {
561 prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
563 center=(*(Handle(Adaptor3d_HCurve)*)&theRep(1))->Value(prm);
564 for (iRep=2; iRep<=nbRep; iRep++) {
565 othP=(*(Handle(Adaptor3d_HCurve)*)&theRep(iRep))->Value(prm);
566 dist2=center.SquareDistance(othP);
567 if (dist2>tolCal) tolCal=dist2;
573 // On prend 5% de marge car au dessus on crontrole severement
574 return sqrt(tolCal)*1.05;
578 //=======================================================================
579 //function : CheckPolygonOnTriangulation
581 //=======================================================================
582 BRepCheck_Status BRepCheck_Edge::
583 CheckPolygonOnTriangulation(const TopoDS_Edge& theEdge)
585 BRep_ListOfCurveRepresentation& aListOfCR =
586 (*((Handle(BRep_TEdge)*) &theEdge.TShape()))->ChangeCurves();
587 BRep_ListIteratorOfListOfCurveRepresentation anITCR(aListOfCR);
589 BRepAdaptor_Curve aBC;
590 aBC.Initialize(theEdge);
593 return BRepCheck_NoError;
595 while (anITCR.More())
597 if(!anITCR.Value()->IsPolygonOnTriangulation())
603 const Handle(BRep_CurveRepresentation) aCR = anITCR.Value();
604 Handle(BRep_PolygonOnTriangulation) aPT (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&,