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.
18 #include <Adaptor3d_CurveOnSurface.hxx>
19 #include <Adaptor3d_HCurve.hxx>
20 #include <Adaptor3d_HCurveOnSurface.hxx>
21 #include <Bnd_Box.hxx>
22 #include <BRep_CurveOnSurface.hxx>
23 #include <BRep_CurveRepresentation.hxx>
24 #include <BRep_GCurve.hxx>
25 #include <BRep_ListIteratorOfListOfCurveRepresentation.hxx>
26 #include <BRep_ListOfCurveRepresentation.hxx>
27 #include <BRep_PolygonOnTriangulation.hxx>
28 #include <BRep_TEdge.hxx>
29 #include <BRep_TFace.hxx>
30 #include <BRep_Tool.hxx>
31 #include <BRepAdaptor_Curve.hxx>
32 #include <BRepCheck.hxx>
33 #include <BRepCheck_Edge.hxx>
34 #include <BRepCheck_ListIteratorOfListOfStatus.hxx>
35 #include <BRepCheck_ListOfStatus.hxx>
36 #include <Extrema_LocateExtPC.hxx>
37 #include <Geom2d_Curve.hxx>
38 #include <Geom2dAdaptor.hxx>
39 #include <Geom2dAdaptor_HCurve.hxx>
40 #include <Geom_Curve.hxx>
41 #include <Geom_Plane.hxx>
42 #include <Geom_RectangularTrimmedSurface.hxx>
43 #include <Geom_Surface.hxx>
44 #include <Geom_TrimmedCurve.hxx>
45 #include <GeomAdaptor_Curve.hxx>
46 #include <GeomAdaptor_HCurve.hxx>
47 #include <GeomAdaptor_HSurface.hxx>
48 #include <GeomProjLib.hxx>
49 #include <Poly_PolygonOnTriangulation.hxx>
50 #include <Poly_Triangulation.hxx>
51 #include <Precision.hxx>
52 #include <ProjLib_ProjectedCurve.hxx>
53 #include <Standard_Type.hxx>
54 #include <TColStd_Array1OfTransient.hxx>
55 #include <TColStd_HArray1OfReal.hxx>
56 #include <TopAbs_ShapeEnum.hxx>
57 #include <TopExp_Explorer.hxx>
59 #include <TopoDS_Edge.hxx>
60 #include <TopoDS_Face.hxx>
61 #include <TopoDS_Shape.hxx>
63 //modified by NIZNHY-PKV Thu May 05 09:01:57 2011f
65 Standard_Boolean Validate(const Adaptor3d_Curve&,
66 const Adaptor3d_CurveOnSurface&,
68 const Standard_Boolean);
70 void PrintProblematicPoint(const gp_Pnt&,
75 Standard_Real Prec(const Adaptor3d_Curve& aAC3D,
76 const Adaptor3d_CurveOnSurface& aACS);
78 Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D);
80 Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS);
82 //static Standard_Boolean Validate(const Adaptor3d_Curve&,
83 // const Adaptor3d_Curve&,
84 // const Standard_Real,
85 // const Standard_Boolean);
86 //modified by NIZNHY-PKV Thu May 05 09:02:01 2011t
88 static const Standard_Integer NCONTROL=23;
90 //=======================================================================
91 //function : BRepCheck_Edge
93 //=======================================================================
95 BRepCheck_Edge::BRepCheck_Edge(const TopoDS_Edge& E)
98 myGctrl = Standard_True;
101 //=======================================================================
104 //=======================================================================
106 void BRepCheck_Edge::Minimum()
110 BRepCheck_ListOfStatus thelist;
111 myMap.Bind(myShape, thelist);
112 BRepCheck_ListOfStatus& lst = myMap(myShape);
115 // Existence et unicite d`une representation 3D
116 Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
117 BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
118 Standard_Boolean exist = Standard_False;
119 Standard_Boolean unique = Standard_True;
120 // Search for a 3D reference. If no existent one, creates it with the
121 // first encountered CurveOnSurf; if multiple, chooses the first one...
123 Standard_Boolean Degenerated = TE->Degenerated();
124 Standard_Boolean SameParameter = TE->SameParameter();
125 Standard_Boolean SameRange = TE->SameRange();
126 if (!SameRange && SameParameter) {
127 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
129 // Handle(Geom_Curve) C3d;
131 while (itcr.More()) {
132 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
133 if (cr->IsCurve3D()) {
135 exist = Standard_True;
138 unique = Standard_False;
140 if (myCref.IsNull() && !cr->Curve3D().IsNull()) {
148 BRepCheck::Add(lst,BRepCheck_No3DCurve);
152 BRepCheck::Add(lst,BRepCheck_Multiple3DCurve);
155 if (myCref.IsNull() && !Degenerated) {
156 itcr.Initialize(TE->Curves());
157 while (itcr.More()) {
158 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
159 if (cr->IsCurveOnSurface()) {
166 else if (!myCref.IsNull() && Degenerated){
167 BRepCheck::Add(lst,BRepCheck_InvalidDegeneratedFlag);
170 if (!myCref.IsNull()) {
171 Handle(BRep_GCurve) GCref (Handle(BRep_GCurve)::DownCast (myCref));
172 Standard_Real First,Last;
173 GCref->Range(First,Last);
176 BRepCheck::Add(lst,BRepCheck_InvalidRange);
179 if (myCref->IsCurve3D()) {
180 // eap 6 Jun 2002 occ332
181 // better transform C3d instead of transforming Surf upto C3d initial location,
182 // on transformed BSpline surface 'same parameter' may seem wrong
183 TopLoc_Location L = myShape.Location() * myCref->Location();
184 Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
185 (myCref->Curve3D()->Transformed
186 (/*myCref->Location()*/L.Transformation()));
187 GeomAdaptor_Curve GAC3d(C3d, C3d->TransformedParameter(First, L.Transformation()),
188 C3d->TransformedParameter(Last, L.Transformation()));
189 myHCurve = new GeomAdaptor_HCurve(GAC3d);
191 else { // curve on surface
192 Handle(Geom_Surface) Sref = myCref->Surface();
193 Sref = Handle(Geom_Surface)::DownCast
194 (Sref->Transformed(myCref->Location().Transformation()));
195 const Handle(Geom2d_Curve)& PCref = myCref->PCurve();
196 Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
197 Handle(Geom2dAdaptor_HCurve) GHPCref =
198 new Geom2dAdaptor_HCurve(PCref,First,Last);
199 Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
200 myHCurve = new Adaptor3d_HCurveOnSurface(ACSref);
205 lst.Append(BRepCheck_NoError);
207 myMin = Standard_True;
212 //=======================================================================
213 //function : InContext
215 //=======================================================================
217 void BRepCheck_Edge::InContext(const TopoDS_Shape& S)
219 if (myMap.IsBound(S)) {
222 BRepCheck_ListOfStatus thelist;
223 myMap.Bind(S, thelist);
224 BRepCheck_ListOfStatus& lst = myMap(S);
226 Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
227 Standard_Real Tol = BRep_Tool::Tolerance(TopoDS::Edge(myShape));
229 TopAbs_ShapeEnum styp = S.ShapeType();
230 // for (TopExp_Explorer exp(S,TopAbs_EDGE); exp.More(); exp.Next()) {
231 TopExp_Explorer exp(S,TopAbs_EDGE) ;
232 for ( ; exp.More(); exp.Next()) {
233 if (exp.Current().IsSame(myShape)) {
238 BRepCheck::Add(lst,BRepCheck_SubshapeNotInShape);
250 if (!myCref.IsNull()) {
252 Standard_Boolean SameParameter = TE->SameParameter();
253 Standard_Boolean SameRange = TE->SameRange();
254 // Modified by skv - Tue Apr 27 11:48:13 2004 Begin
255 if (!SameParameter || !SameRange) {
257 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
259 BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
263 // Modified by skv - Tue Apr 27 11:48:14 2004 End
264 Standard_Real First = myHCurve->FirstParameter();
265 Standard_Real Last = myHCurve->LastParameter();
267 Handle(BRep_TFace)& TF = *((Handle(BRep_TFace)*) &S.TShape());
268 const TopLoc_Location& Floc = S.Location();
269 const TopLoc_Location& TFloc = TF->Location();
270 const Handle(Geom_Surface)& Su = TF->Surface();
271 TopLoc_Location L = (Floc * TFloc).Predivided(myShape.Location());
272 TopLoc_Location LE = myShape.Location() * myCref->Location();
273 const gp_Trsf& Etrsf = LE.Transformation();
274 Standard_Boolean pcurvefound = Standard_False;
276 BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
277 while (itcr.More()) {
278 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
279 if (cr != myCref && cr->IsCurveOnSurface(Su,L)) {
280 pcurvefound = Standard_True;
281 Handle(BRep_GCurve) GC (Handle(BRep_GCurve)::DownCast (cr));
284 Standard_Real ff = f, ll = l;
285 if(myCref->IsCurve3D())
287 ff = myCref->Curve3D()->TransformedParameter(f, Etrsf);
288 ll = myCref->Curve3D()->TransformedParameter(l, Etrsf);
291 // Modified by skv - Tue Apr 27 11:50:35 2004 Begin
292 if (Abs(ff-First) > Precision::PConfusion() ||
293 Abs(ll-Last) > Precision::PConfusion()) {
294 BRepCheck::Add(lst,BRepCheck_InvalidSameRangeFlag);
295 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
297 // Modified by skv - Tue Apr 27 11:50:37 2004 End
299 Handle(Geom_Surface) Sb = cr->Surface();
300 Sb = Handle(Geom_Surface)::DownCast
301 // (Su->Transformed(L.Transformation()));
302 (Su->Transformed(/*L*/(Floc * TFloc).Transformation()));
303 Handle(Geom2d_Curve) PC = cr->PCurve();
304 Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(Sb);
305 Handle(Geom2dAdaptor_HCurve) GHPC = new Geom2dAdaptor_HCurve(PC,f,l);
306 Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
307 Standard_Boolean ok =
308 Validate(myHCurve->Curve() ,ACS,Tol,SameParameter);
310 if (cr->IsCurveOnClosedSurface()) {
311 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
314 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
316 // Modified by skv - Tue Apr 27 11:53:00 2004 Begin
317 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
318 // if (SameParameter) {
319 // BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
321 // Modified by skv - Tue Apr 27 11:53:01 2004 End
323 if (cr->IsCurveOnClosedSurface()) {
324 GHPC->ChangeCurve2d().Load(cr->PCurve2(),f,l); // same bounds
325 ACS.Load(GHPC, GAHS); // sans doute inutile
326 ok = Validate(myHCurve->Curve(),ACS,Tol,SameParameter);
328 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnClosedSurface);
329 // Modified by skv - Tue Apr 27 11:53:20 2004 Begin
331 BRepCheck::Add(lst,BRepCheck_InvalidSameParameterFlag);
333 // Modified by skv - Tue Apr 27 11:53:23 2004 End
342 Handle(Geom_Plane) P;
343 Handle(Standard_Type) dtyp = Su->DynamicType();
344 if (dtyp == STANDARD_TYPE(Geom_RectangularTrimmedSurface)) {
345 P = Handle(Geom_Plane)::DownCast
346 (Handle(Geom_RectangularTrimmedSurface)::
347 DownCast(Su)->BasisSurface());
350 P = Handle(Geom_Plane)::DownCast(Su);
352 if (P.IsNull()) { // not a plane
353 BRepCheck::Add(lst,BRepCheck_NoCurveOnSurface);
355 else { // on fait la projection a la volee, comme BRep_Tool
358 P = Handle(Geom_Plane)::
359 DownCast(P->Transformed(/*L*/(Floc * TFloc).Transformation()));// eap occ332
360 //on projette Cref sur ce plan
361 Handle(GeomAdaptor_HSurface) GAHS = new GeomAdaptor_HSurface(P);
363 // Dub - Normalement myHCurve est une GeomAdaptor_HCurve
364 GeomAdaptor_Curve& Gac =
365 Handle(GeomAdaptor_HCurve)::DownCast(myHCurve)->ChangeCurve();
366 Handle(Geom_Curve) C3d = Gac.Curve();
367 Handle(Geom_Curve) ProjOnPlane =
368 GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,First,Last),
369 P, P->Position().Direction(),
371 Handle(GeomAdaptor_HCurve) aHCurve =
372 new GeomAdaptor_HCurve(ProjOnPlane);
374 ProjLib_ProjectedCurve proj(GAHS,aHCurve);
375 Handle(Geom2d_Curve) PC = Geom2dAdaptor::MakeCurve(proj);
376 Handle(Geom2dAdaptor_HCurve) GHPC =
377 new Geom2dAdaptor_HCurve(PC,
378 myHCurve->FirstParameter(),
379 myHCurve->LastParameter());
381 Adaptor3d_CurveOnSurface ACS(GHPC,GAHS);
383 Standard_Boolean ok = Validate(myHCurve->Curve(),ACS,
384 Tol,Standard_True); // voir dub...
386 BRepCheck::Add(lst,BRepCheck_InvalidCurveOnSurface);
395 // on verifie que l`edge est bien connectee 2 fois (pas de bord libre)
396 Standard_Integer nbconnection = 0;
397 //TopExp_Explorer exp;
398 for (exp.Init(S,TopAbs_FACE); exp.More(); exp.Next()) {
399 const TopoDS_Face& fac = TopoDS::Face(exp.Current());
400 TopExp_Explorer exp2;
401 for (exp2.Init(fac,TopAbs_EDGE); exp2.More(); exp2.Next()) {
402 if (exp2.Current().IsSame(myShape)) {
407 if (nbconnection < 2 && !TE->Degenerated()) {
408 BRepCheck::Add(myMap(S),BRepCheck_FreeEdge);
410 else if (nbconnection > 2) {
411 BRepCheck::Add(myMap(S),BRepCheck_InvalidMultiConnexity);
414 BRepCheck::Add(myMap(S),BRepCheck_NoError);
421 if (myMap(S).IsEmpty()) {
422 myMap(S).Append(BRepCheck_NoError);
427 //=======================================================================
430 //=======================================================================
432 void BRepCheck_Edge::Blind()
434 // Modified by skv - Tue Apr 27 11:36:01 2004 Begin
435 // The body of this function is removed because of its useless.
437 myBlind = Standard_True;
439 // Modified by skv - Tue Apr 27 11:36:02 2004 End
443 //=======================================================================
444 //function : GeometricControls
446 //=======================================================================
448 void BRepCheck_Edge::GeometricControls(const Standard_Boolean B)
454 //=======================================================================
455 //function : GeometricControls
457 //=======================================================================
459 Standard_Boolean BRepCheck_Edge::GeometricControls() const
464 //=======================================================================
465 //function : SetStatus
467 //=======================================================================
468 void BRepCheck_Edge::SetStatus(const BRepCheck_Status theStatus)
470 BRepCheck::Add(myMap(myShape),theStatus);
474 //=======================================================================
475 //function : Tolerance
477 //=======================================================================
479 Standard_Real BRepCheck_Edge::Tolerance()
481 Handle(BRep_TEdge)& TE = *((Handle(BRep_TEdge)*)&myShape.TShape());
482 Standard_Integer it, iRep=1, nbRep=(TE->Curves()).Extent();
484 return Precision::Confusion();
486 TColStd_Array1OfTransient theRep(1, nbRep*2);
487 Standard_Real First, Last;
488 if (!myHCurve.IsNull()) {
489 First = myHCurve->FirstParameter();
490 Last= myHCurve->LastParameter();
493 BRep_Tool::Range(TopoDS::Edge(myShape), First, Last);
496 BRep_ListIteratorOfListOfCurveRepresentation itcr(TE->Curves());
497 for (; itcr.More(); itcr.Next()) {
498 const Handle(BRep_CurveRepresentation)& cr = itcr.Value();
499 if (cr->IsCurve3D() && !TE->Degenerated()) {
500 //// modified by jgv, 20.03.03 ////
501 TopLoc_Location Loc = myShape.Location() * cr->Location();
502 Handle(Geom_Curve) C3d = Handle(Geom_Curve)::DownCast
503 (cr->Curve3D()->Transformed( Loc.Transformation() ));
504 ///////////////////////////////////
505 GeomAdaptor_Curve GAC3d(C3d,First,Last);
508 theRep(iRep)=theRep(1);
511 theRep(it) = new GeomAdaptor_HCurve(GAC3d);
514 else if (cr->IsCurveOnSurface()) {
516 Handle(Geom_Surface) Sref = cr->Surface();
517 //// modified by jgv, 20.03.03 ////
518 TopLoc_Location Loc = myShape.Location() * cr->Location();
519 Sref = Handle(Geom_Surface)::DownCast
520 (Sref->Transformed( Loc.Transformation() ));
521 ///////////////////////////////////
522 const Handle(Geom2d_Curve)& PCref = cr->PCurve();
523 Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
524 Handle(Geom2dAdaptor_HCurve) GHPCref =
525 new Geom2dAdaptor_HCurve(PCref,First,Last);
526 Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
527 theRep(iRep) = new Adaptor3d_HCurveOnSurface(ACSref);
530 if (cr->IsCurveOnClosedSurface()) {
531 Handle(Geom_Surface) Sref = cr->Surface();
532 Sref = Handle(Geom_Surface)::DownCast
533 (Sref->Transformed(cr->Location().Transformation()));
534 const Handle(Geom2d_Curve)& PCref = cr->PCurve2();
535 Handle(GeomAdaptor_HSurface) GAHSref = new GeomAdaptor_HSurface(Sref);
536 Handle(Geom2dAdaptor_HCurve) GHPCref =
537 new Geom2dAdaptor_HCurve(PCref,First,Last);
538 Adaptor3d_CurveOnSurface ACSref(GHPCref,GAHSref);
539 theRep(iRep) = new Adaptor3d_HCurveOnSurface(ACSref);
549 Standard_Real dist2, tol2, tolCal=0., prm;
552 for (i= 0; i< NCONTROL; i++) {
553 prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
555 center=(*(Handle(Adaptor3d_HCurve)*)&theRep(1))->Value(prm);
556 for (iRep=2; iRep<=nbRep; iRep++) {
557 othP=(*(Handle(Adaptor3d_HCurve)*)&theRep(iRep))->Value(prm);
558 dist2=center.SquareDistance(othP);
559 if (dist2>tolCal) tolCal=dist2;
565 // On prend 5% de marge car au dessus on crontrole severement
566 return sqrt(tolCal)*1.05;
570 //=======================================================================
571 //function : CheckPolygonOnTriangulation
573 //=======================================================================
574 BRepCheck_Status BRepCheck_Edge::
575 CheckPolygonOnTriangulation(const TopoDS_Edge& theEdge)
577 BRep_ListOfCurveRepresentation& aListOfCR =
578 (*((Handle(BRep_TEdge)*) &theEdge.TShape()))->ChangeCurves();
579 BRep_ListIteratorOfListOfCurveRepresentation anITCR(aListOfCR);
581 BRepAdaptor_Curve aBC;
582 aBC.Initialize(theEdge);
585 return BRepCheck_NoError;
587 while (anITCR.More())
589 if(!anITCR.Value()->IsPolygonOnTriangulation())
595 const Handle(BRep_CurveRepresentation) aCR = anITCR.Value();
596 Handle(BRep_PolygonOnTriangulation) aPT (Handle(BRep_PolygonOnTriangulation)::DownCast(aCR));
598 const TopLoc_Location aLL = theEdge.Location() * aPT->Location();
600 const Handle(Poly_Triangulation) aTriang = aCR->Triangulation();
601 const Handle(Poly_PolygonOnTriangulation) aPOnTriag =
602 aCR->IsPolygonOnClosedTriangulation() ?
603 aCR->PolygonOnTriangulation2() :
604 aCR->PolygonOnTriangulation();
605 const TColStd_Array1OfInteger& anIndices = aPOnTriag->Nodes();
606 const TColgp_Array1OfPnt& Nodes = aTriang->Nodes();
607 const Standard_Integer aNbNodes = anIndices.Length();
609 const Standard_Real aTol = aPOnTriag->Deflection() +
610 BRep_Tool::Tolerance(theEdge);
612 if(aPOnTriag->HasParameters())
614 for(Standard_Integer i = aPOnTriag->Parameters()->Lower();
615 i <= aPOnTriag->Parameters()->Upper(); i++)
617 const Standard_Real aParam = aPOnTriag->Parameters()->Value(i);
618 const gp_Pnt aPE(aBC.Value(aParam)),
619 aPnt(Nodes(anIndices(i)).Transformed(aLL));
621 const Standard_Real aSQDist = aPE.SquareDistance(aPnt);
622 if(aSQDist > aTol*aTol)
624 return BRepCheck_InvalidPolygonOnTriangulation;
630 //If aPOnTriag does not have any parameters we will check if it
631 //inscribes into Bounding box, which is built on the edge triangulation.
635 for (Standard_Integer i = 1; i <= aNbNodes; i++)
637 if (aLL.IsIdentity())
638 aB.Add(Nodes(anIndices(i)));
640 aB.Add(Nodes(anIndices(i)).Transformed(aLL));
645 Standard_Real aFP = aBC.FirstParameter();
646 Standard_Real aLP = aBC.LastParameter();
648 const Standard_Real aStep = (aLP - aFP)/IntToReal(NCONTROL);
650 Standard_Real aPar = aFP;
652 for(Standard_Integer i = 1; i < NCONTROL; i ++)
657 return BRepCheck_InvalidPolygonOnTriangulation;
666 return BRepCheck_InvalidPolygonOnTriangulation;
673 return BRepCheck_NoError;
676 //=======================================================================
677 //function : Validate
679 //=======================================================================
680 Standard_Boolean Validate(const Adaptor3d_Curve& CRef,
681 const Adaptor3d_CurveOnSurface& Other,
682 const Standard_Real Tol,
683 const Standard_Boolean SameParameter)
685 Standard_Boolean Status, proj;
686 Standard_Real aPC, First, Last, Error;
687 gp_Pnt problematic_point ;
689 Status = Standard_True;
691 First = CRef.FirstParameter();
692 Last = CRef.LastParameter();
694 aPC=Precision::PConfusion();
695 proj = (!SameParameter ||
696 Abs(Other.FirstParameter()-First) > aPC ||
697 Abs( Other.LastParameter()-Last) > aPC);
701 Standard_Real Tol2, prm, dD;
703 //modified by NIZNHY-PKV Thu May 05 09:06:41 2011f
705 dD=Prec(CRef, Other);//3.e-15;
709 //modified by NIZNHY-PKV Thu May 05 09:06:47 2011t
711 for (i = 0; i < NCONTROL; ++i) {
712 prm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
713 pref = CRef.Value(prm);
714 pother = Other.Value(prm);
715 if (pref.SquareDistance(pother) > Tol2) {
716 problematic_point = pref ;
717 Status = Standard_False;
718 Error = pref.Distance(pother);
719 PrintProblematicPoint(problematic_point, Error, Tol);
726 Extrema_LocateExtPC refd,otherd;
727 Standard_Real OFirst = Other.FirstParameter();
728 Standard_Real OLast = Other.LastParameter();
729 gp_Pnt pd = CRef.Value(First);
730 gp_Pnt pdo = Other.Value(OFirst);
731 Standard_Real distt = pd.SquareDistance(pdo);
732 if (distt > Tol*Tol) {
733 problematic_point = pd ;
734 Status = Standard_False ;
736 PrintProblematicPoint(problematic_point, Error, Tol);
740 pd = CRef.Value(Last);
741 pdo = Other.Value(OLast);
742 distt = pd.SquareDistance(pdo);
743 if (distt > Tol*Tol) {
744 problematic_point = pd ;
745 Status = Standard_False ;
747 PrintProblematicPoint(problematic_point, Error, Tol);
752 refd.Initialize(CRef,First,Last,CRef.Resolution(Tol));
753 otherd.Initialize(Other,OFirst,OLast,Other.Resolution(Tol));
754 for (Standard_Integer i = 2; i< NCONTROL-1; i++) {
755 Standard_Real rprm = ((NCONTROL-1-i)*First + i*Last)/(NCONTROL-1);
756 gp_Pnt pref = CRef.Value(rprm);
757 Standard_Real oprm = ((NCONTROL-1-i)*OFirst + i*OLast)/(NCONTROL-1);
758 gp_Pnt pother = Other.Value(oprm);
759 refd.Perform(pother,rprm);
760 if (!refd.IsDone() || refd.SquareDistance() > Tol * Tol) {
761 problematic_point = pref ;
762 Status = Standard_False ;
764 Error = sqrt (refd.SquareDistance());
769 PrintProblematicPoint(problematic_point, Error, Tol);
773 otherd.Perform(pref,oprm);
774 if (!otherd.IsDone() || otherd.SquareDistance() > Tol * Tol) {
775 problematic_point = pref ;
776 Status = Standard_False ;
777 if (otherd.IsDone()) {
778 Error = sqrt (otherd.SquareDistance());
783 PrintProblematicPoint(problematic_point, Error, Tol);
793 //=======================================================================
796 //=======================================================================
797 Standard_Real Prec(const Adaptor3d_Curve& aAC3D,
798 const Adaptor3d_CurveOnSurface& aACS)
800 Standard_Real aXEmax, aXC, aXS;
802 aXC=PrecCurve(aAC3D);
803 aXS=PrecSurface(aACS);
804 aXEmax=(aXC>aXS) ? aXC: aXS;
807 //=======================================================================
808 //function : PrecCurve
810 //=======================================================================
811 Standard_Real PrecCurve(const Adaptor3d_Curve& aAC3D)
813 Standard_Real aXEmax;
814 GeomAbs_CurveType aCT;
816 aXEmax=RealEpsilon();
819 if (aCT==GeomAbs_Ellipse) {
821 Standard_Real aX[5], aXE;
823 gp_Elips aEL3D=aAC3D.Ellipse();
824 aEL3D.Location().Coord(aX[0], aX[1], aX[2]);
825 aX[3]=aEL3D.MajorRadius();
826 aX[4]=aEL3D.MinorRadius();
828 for (i=0; i<5; ++i) {
837 }//if (aCT=GeomAbs_Ellipse) {
841 //=======================================================================
842 //function : PrecSurface
844 //=======================================================================
845 Standard_Real PrecSurface(const Adaptor3d_CurveOnSurface& aACS)
847 Standard_Real aXEmax;
848 GeomAbs_SurfaceType aST;
850 aXEmax=RealEpsilon();
852 const Handle(Adaptor3d_HSurface)& aAHS=aACS.GetSurface();
854 if (aST==GeomAbs_Cone) {
855 gp_Cone aCone=aAHS->Cone();
857 Standard_Real aX[4], aXE;
859 aCone.Location().Coord(aX[0], aX[1], aX[2]);
860 aX[3]=aCone.RefRadius();
862 for (i=0; i<4; ++i) {
871 }//if (aST==GeomAbs_Cone) {
874 //=======================================================================
875 //function : PrintProblematicPoint
877 //=======================================================================
879 void PrintProblematicPoint(const gp_Pnt& problematic_point,
880 const Standard_Real Error,
881 const Standard_Real Tol)
883 cout << " **** probleme de SameParameter au point :" << endl;
884 cout << " " << problematic_point.Coord(1) << " "
885 << problematic_point.Coord(2) << " " << problematic_point.Coord(3) << endl ;
886 cout << " Erreur detectee :" << Error << " Tolerance :" << Tol << endl;
889 void PrintProblematicPoint(const gp_Pnt&,