1 // Created on: 1999-04-27
2 // Created by: Pavel DURANDIN
3 // Copyright (c) 1999-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 <ShapeExtend_CompositeSurface.ixx>
18 #include <Precision.hxx>
19 #include <Geom_Surface.hxx>
21 //=======================================================================
22 //function : ShapeExtend_CompositeSurface
24 //=======================================================================
26 ShapeExtend_CompositeSurface::ShapeExtend_CompositeSurface()
30 //=======================================================================
31 //function : Constructor
33 //=======================================================================
35 ShapeExtend_CompositeSurface::ShapeExtend_CompositeSurface(const Handle(TColGeom_HArray2OfSurface)& GridSurf,
36 const ShapeExtend_Parametrisation param)
38 Init ( GridSurf, param );
41 //=======================================================================
42 //function : Constructor
44 //=======================================================================
46 ShapeExtend_CompositeSurface::ShapeExtend_CompositeSurface(const Handle(TColGeom_HArray2OfSurface)& GridSurf,
47 const TColStd_Array1OfReal &UJoints,
48 const TColStd_Array1OfReal &VJoints)
50 Init ( GridSurf, UJoints, VJoints );
53 //=======================================================================
56 //=======================================================================
58 Standard_Boolean ShapeExtend_CompositeSurface::Init (const Handle(TColGeom_HArray2OfSurface)& GridSurf,
59 const ShapeExtend_Parametrisation param)
61 if ( GridSurf.IsNull() ) return Standard_False;
63 ComputeJointValues ( param );
64 return CheckConnectivity ( Precision::Confusion() );
67 //=======================================================================
70 //=======================================================================
72 Standard_Boolean ShapeExtend_CompositeSurface::Init (const Handle(TColGeom_HArray2OfSurface)& GridSurf,
73 const TColStd_Array1OfReal &UJoints,
74 const TColStd_Array1OfReal &VJoints)
76 if ( GridSurf.IsNull() ) return Standard_False;
79 Standard_Boolean ok = Standard_True;
80 if ( ! SetUJointValues ( UJoints ) || ! SetVJointValues ( VJoints ) ) {
82 ComputeJointValues ( ShapeExtend_Natural );
84 cout << "Warning: ShapeExtend_CompositeSurface::Init: bad joint values" << endl;
88 return ( CheckConnectivity ( Precision::Confusion() ) ? ok : Standard_False );
91 //=======================================================================
92 //function : NbUPatches
94 //=======================================================================
96 Standard_Integer ShapeExtend_CompositeSurface::NbUPatches() const
98 return myPatches->ColLength();
101 //=======================================================================
102 //function : NbVPatches
104 //=======================================================================
106 Standard_Integer ShapeExtend_CompositeSurface::NbVPatches() const
108 return myPatches->RowLength();
111 //=======================================================================
114 //=======================================================================
116 const Handle(Geom_Surface)& ShapeExtend_CompositeSurface::Patch(const Standard_Integer i,
117 const Standard_Integer j) const
119 return myPatches->Value(i,j);
122 //=======================================================================
125 //=======================================================================
127 const Handle(TColGeom_HArray2OfSurface)& ShapeExtend_CompositeSurface::Patches() const
132 //=======================================================================
133 //function : UJointValues
135 //=======================================================================
137 Handle(TColStd_HArray1OfReal) ShapeExtend_CompositeSurface::UJointValues() const
139 return myUJointValues;
142 //=======================================================================
143 //function : VJointValues
145 //=======================================================================
147 Handle(TColStd_HArray1OfReal) ShapeExtend_CompositeSurface::VJointValues() const
149 return myVJointValues;
152 //=======================================================================
153 //function : UJointValue
155 //=======================================================================
157 Standard_Real ShapeExtend_CompositeSurface::UJointValue(const Standard_Integer i) const
159 return myUJointValues->Value(i);
162 //=======================================================================
163 //function : VJointValue
165 //=======================================================================
167 Standard_Real ShapeExtend_CompositeSurface::VJointValue(const Standard_Integer i) const
169 return myVJointValues->Value(i);
172 //=======================================================================
173 //function : SetUJointValues
175 //=======================================================================
177 Standard_Boolean ShapeExtend_CompositeSurface::SetUJointValues (const TColStd_Array1OfReal &UJoints)
179 Standard_Integer NbU = NbUPatches();
180 if ( UJoints.Length() != NbU+1 ) return Standard_False;
182 Handle(TColStd_HArray1OfReal) UJointValues = new TColStd_HArray1OfReal(1,NbU+1);
183 for ( Standard_Integer i=1, j=UJoints.Lower(); i <= NbU+1; i++, j++ ) {
184 UJointValues->SetValue ( i, UJoints(j) );
185 if ( i >1 && UJoints(j) - UJoints(j-1) < Precision::PConfusion() )
186 return Standard_False;
188 myUJointValues = UJointValues;
189 return Standard_True;
192 //=======================================================================
193 //function : SetVJointValues
195 //=======================================================================
197 Standard_Boolean ShapeExtend_CompositeSurface::SetVJointValues (const TColStd_Array1OfReal &VJoints)
199 Standard_Integer NbV = NbVPatches();
200 if ( VJoints.Length() != NbV+1 ) return Standard_False;
202 Handle(TColStd_HArray1OfReal) VJointValues = new TColStd_HArray1OfReal(1,NbV+1);
203 for ( Standard_Integer i=1, j=VJoints.Lower(); i <= NbV+1; i++, j++ ) {
204 VJointValues->SetValue ( i, VJoints(j) );
205 if ( i >1 && VJoints(j) - VJoints(j-1) < Precision::PConfusion() )
206 return Standard_False;
208 myVJointValues = VJointValues;
209 return Standard_True;
212 //=======================================================================
213 //function : SetUFirstValue
215 //=======================================================================
217 void ShapeExtend_CompositeSurface::SetUFirstValue (const Standard_Real UFirst)
219 if ( myUJointValues.IsNull() ) return;
221 Standard_Real shift = UFirst - myUJointValues->Value(1);
222 Standard_Integer NbU = myUJointValues->Length();
223 for ( Standard_Integer i=1; i <= NbU; i++ ) {
224 myUJointValues->SetValue ( i, myUJointValues->Value(i) + shift );
228 //=======================================================================
229 //function : SetVFirstValue
231 //=======================================================================
233 void ShapeExtend_CompositeSurface::SetVFirstValue (const Standard_Real VFirst)
235 if ( myVJointValues.IsNull() ) return;
237 Standard_Real shift = VFirst - myVJointValues->Value(1);
238 Standard_Integer NbV = myVJointValues->Length();
239 for ( Standard_Integer i=1; i <= NbV; i++ ) {
240 myVJointValues->SetValue ( i, myVJointValues->Value(i) + shift );
244 //=======================================================================
245 //function : LocateUParameter
247 //=======================================================================
249 Standard_Integer ShapeExtend_CompositeSurface::LocateUParameter(const Standard_Real U) const
251 Standard_Integer nbPatch = NbUPatches();
252 for(Standard_Integer i = 2; i <= nbPatch; i++)
253 if (U < myUJointValues->Value(i)) return i-1;
257 //=======================================================================
258 //function : LocateVParameter
260 //=======================================================================
262 Standard_Integer ShapeExtend_CompositeSurface::LocateVParameter(const Standard_Real V) const
264 Standard_Integer nbPatch = NbVPatches();
265 for(Standard_Integer i = 2; i <= nbPatch; i++)
266 if (V < myVJointValues->Value(i)) return i-1;
270 //=======================================================================
271 //function : LocateUVPoint
273 //=======================================================================
275 void ShapeExtend_CompositeSurface::LocateUVPoint(const gp_Pnt2d& pnt,
277 Standard_Integer& j) const
279 i = LocateUParameter(pnt.X());
280 j = LocateVParameter(pnt.Y());
283 //=======================================================================
286 //=======================================================================
288 const Handle(Geom_Surface)& ShapeExtend_CompositeSurface::Patch(const Standard_Real U,
289 const Standard_Real V) const
291 return myPatches->Value ( LocateUParameter(U), LocateVParameter(V) );
294 //=======================================================================
297 //=======================================================================
299 const Handle(Geom_Surface)& ShapeExtend_CompositeSurface::Patch(const gp_Pnt2d& pnt) const
301 return myPatches->Value ( LocateUParameter(pnt.X()), LocateVParameter(pnt.Y()) );
304 //=======================================================================
305 //function : ULocalToGlobal
307 //=======================================================================
309 Standard_Real ShapeExtend_CompositeSurface::ULocalToGlobal (const Standard_Integer i,
310 const Standard_Integer j,
311 const Standard_Real u) const
313 Standard_Real u1, u2, v1, v2;
314 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
315 Standard_Real scale = ( myUJointValues->Value(i+1) - myUJointValues->Value(i) ) / ( u2 - u1 );
316 return u * scale + ( myUJointValues->Value(i) - u1 * scale ); // ! this formula is stable if u1 is infinite
319 //=======================================================================
320 //function : VLocalToGlobal
322 //=======================================================================
324 Standard_Real ShapeExtend_CompositeSurface::VLocalToGlobal (const Standard_Integer i,
325 const Standard_Integer j,
326 const Standard_Real v) const
328 Standard_Real u1, u2, v1, v2;
329 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
330 Standard_Real scale = ( myVJointValues->Value(j+1) - myVJointValues->Value(j) ) / ( v2 - v1 );
331 return v * scale + ( myVJointValues->Value(j) - v1 * scale ); // ! this formula is stable if v1 is infinite
334 //=======================================================================
335 //function : LocalToGlobal
337 //=======================================================================
339 gp_Pnt2d ShapeExtend_CompositeSurface::LocalToGlobal (const Standard_Integer i,
340 const Standard_Integer j,
341 const gp_Pnt2d &uv) const
343 Standard_Real u1, u2, v1, v2;
344 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
345 Standard_Real scaleu = ( myUJointValues->Value(i+1) - myUJointValues->Value(i) ) / ( u2 - u1 );
346 Standard_Real scalev = ( myVJointValues->Value(j+1) - myVJointValues->Value(j) ) / ( v2 - v1 );
347 return gp_Pnt2d ( uv.X() * scaleu + ( myUJointValues->Value(i) - u1 * scaleu ), // ! this formula is stable if u1 or v1 is infinite
348 uv.Y() * scalev + ( myVJointValues->Value(j) - v1 * scalev ) );
351 //=======================================================================
352 //function : UGlobalToLocal
354 //=======================================================================
356 Standard_Real ShapeExtend_CompositeSurface::UGlobalToLocal (const Standard_Integer i,
357 const Standard_Integer j,
358 const Standard_Real U) const
360 Standard_Real u1, u2, v1, v2;
361 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
362 Standard_Real scale = ( u2 - u1 ) / ( myUJointValues->Value(i+1) - myUJointValues->Value(i) );
363 return U * scale + ( u1 - myUJointValues->Value(i) * scale ); // ! this formula is stable if u1 is infinite
366 //=======================================================================
367 //function : VGlobalToLocal
369 //=======================================================================
371 Standard_Real ShapeExtend_CompositeSurface::VGlobalToLocal (const Standard_Integer i,
372 const Standard_Integer j,
373 const Standard_Real V) const
375 Standard_Real u1, u2, v1, v2;
376 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
377 Standard_Real scale = ( v2 - v1 ) / ( myVJointValues->Value(j+1) - myVJointValues->Value(j) );
378 return V * scale + ( v1 - myVJointValues->Value(j) * scale ); // ! this formula is stable if v1 is infinite
381 //=======================================================================
382 //function : GlobalToLocal
384 //=======================================================================
386 gp_Pnt2d ShapeExtend_CompositeSurface::GlobalToLocal (const Standard_Integer i,
387 const Standard_Integer j,
388 const gp_Pnt2d &UV) const
390 Standard_Real u1, u2, v1, v2;
391 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
392 Standard_Real scaleu = ( u2 - u1 ) / ( myUJointValues->Value(i+1) - myUJointValues->Value(i) );
393 Standard_Real scalev = ( v2 - v1 ) / ( myVJointValues->Value(j+1) - myVJointValues->Value(j) );
394 return gp_Pnt2d ( UV.X() * scaleu + ( u1 - myUJointValues->Value(i) * scaleu ), // ! this formula is stable if u1 or v1 is infinite
395 UV.Y() * scalev + ( v1 - myVJointValues->Value(j) * scalev ) );
398 //=======================================================================
399 //function : GlobalToLocalTransformation
401 //=======================================================================
403 Standard_Boolean ShapeExtend_CompositeSurface::GlobalToLocalTransformation (const Standard_Integer i,
404 const Standard_Integer j,
405 Standard_Real &uFact,
406 gp_Trsf2d &Trsf) const
408 Standard_Real u1, u2, v1, v2;
409 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
411 Standard_Real scaleu = ( u2 - u1 ) / ( myUJointValues->Value(i+1) - myUJointValues->Value(i) );
412 Standard_Real scalev = ( v2 - v1 ) / ( myVJointValues->Value(j+1) - myVJointValues->Value(j) );
413 gp_Vec2d shift ( u1 / scaleu - myUJointValues->Value(i),
414 v1 / scalev - myVJointValues->Value(j) );
416 uFact = scaleu / scalev;
417 gp_Trsf2d Shift, Scale;
418 if ( shift.X() != 0. || shift.Y() != 0. ) Shift.SetTranslation ( shift );
419 if ( scalev != 1. ) Scale.SetScale ( gp_Pnt2d(0,0), scalev );
420 Trsf = Scale * Shift;
421 return uFact != 1. || Trsf.Form() != gp_Identity;
424 //=======================================================================
425 // Inherited methods (from Geom_Geometry and Geom_Surface)
426 //=======================================================================
428 //=======================================================================
429 //function : Transform
431 //=======================================================================
433 void ShapeExtend_CompositeSurface::Transform (const gp_Trsf &T)
435 if ( myPatches.IsNull() ) return;
436 for ( Standard_Integer i=1; i <= NbUPatches(); i++ )
437 for ( Standard_Integer j=1; j <= NbVPatches(); j++ )
438 Patch(i,j)->Transform ( T );
441 //=======================================================================
444 //=======================================================================
446 Handle(Geom_Geometry) ShapeExtend_CompositeSurface::Copy () const
448 Handle(ShapeExtend_CompositeSurface) surf = new ShapeExtend_CompositeSurface;
449 if ( myPatches.IsNull() ) return surf;
451 Handle(TColGeom_HArray2OfSurface) patches =
452 new TColGeom_HArray2OfSurface ( 1, NbUPatches(), 1, NbVPatches() );
453 for ( Standard_Integer i=1; i <= NbUPatches(); i++ )
454 for ( Standard_Integer j=1; j <= NbVPatches(); j++ )
455 patches->SetValue ( i, j, Handle(Geom_Surface)::DownCast ( Patch(i,j)->Copy() ) );
456 surf->Init ( patches );
460 //=======================================================================
461 //function : UReverse
463 //=======================================================================
465 void ShapeExtend_CompositeSurface::UReverse ()
469 //=======================================================================
470 //function : UReversedParameter
472 //=======================================================================
474 Standard_Real ShapeExtend_CompositeSurface::UReversedParameter (const Standard_Real U) const
479 //=======================================================================
480 //function : VReverse
482 //=======================================================================
484 void ShapeExtend_CompositeSurface::VReverse ()
488 //=======================================================================
489 //function : VReversedParameter
491 //=======================================================================
493 Standard_Real ShapeExtend_CompositeSurface::VReversedParameter (const Standard_Real V) const
498 //=======================================================================
501 //=======================================================================
503 void ShapeExtend_CompositeSurface::Bounds(Standard_Real& U1,
506 Standard_Real& V2) const
510 U2 = UJointValue(NbUPatches()+1);
511 V2 = VJointValue(NbVPatches()+1);
514 //=======================================================================
515 //function : IsUPeriodic
517 //=======================================================================
519 Standard_Boolean ShapeExtend_CompositeSurface::IsUPeriodic () const
521 return Standard_False;
524 //=======================================================================
525 //function : IsVPeriodic
527 //=======================================================================
529 Standard_Boolean ShapeExtend_CompositeSurface::IsVPeriodic () const
531 return Standard_False;
534 //=======================================================================
537 //=======================================================================
539 Handle(Geom_Curve) ShapeExtend_CompositeSurface::UIso (const Standard_Real ) const
541 Handle(Geom_Curve) dummy;
545 //=======================================================================
548 //=======================================================================
550 Handle(Geom_Curve) ShapeExtend_CompositeSurface::VIso (const Standard_Real ) const
552 Handle(Geom_Curve) dummy;
556 //=======================================================================
557 //function : Continuity
559 //=======================================================================
561 GeomAbs_Shape ShapeExtend_CompositeSurface::Continuity () const
566 //=======================================================================
569 //=======================================================================
571 Standard_Boolean ShapeExtend_CompositeSurface::IsCNu (const Standard_Integer N) const
576 //=======================================================================
579 //=======================================================================
581 Standard_Boolean ShapeExtend_CompositeSurface::IsCNv (const Standard_Integer N) const
586 //=======================================================================
587 //function : IsUClosed
589 //=======================================================================
591 Standard_Boolean ShapeExtend_CompositeSurface::IsUClosed () const
596 //=======================================================================
597 //function : IsVClosed
599 //=======================================================================
601 Standard_Boolean ShapeExtend_CompositeSurface::IsVClosed () const
606 //=======================================================================
609 //=======================================================================
611 void ShapeExtend_CompositeSurface::D0 (const Standard_Real U,
612 const Standard_Real V,
615 Standard_Integer i = LocateUParameter ( U );
616 Standard_Integer j = LocateVParameter ( V );
617 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
618 myPatches->Value(i,j)->D0 ( uv.X(), uv.Y(), P );
621 //=======================================================================
624 //=======================================================================
626 void ShapeExtend_CompositeSurface::D1 (const Standard_Real U,
627 const Standard_Real V,
632 Standard_Integer i = LocateUParameter ( U );
633 Standard_Integer j = LocateVParameter ( V );
634 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
635 myPatches->Value(i,j)->D1 ( uv.X(), uv.Y(), P, D1U, D1V );
638 //=======================================================================
641 //=======================================================================
643 void ShapeExtend_CompositeSurface::D2 (const Standard_Real U,
644 const Standard_Real V,
652 Standard_Integer i = LocateUParameter ( U );
653 Standard_Integer j = LocateVParameter ( V );
654 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
655 myPatches->Value(i,j)->D2 ( uv.X(), uv.Y(), P, D1U, D1V, D2U, D2V, D2UV );
658 //=======================================================================
661 //=======================================================================
663 void ShapeExtend_CompositeSurface::D3 (const Standard_Real U,
664 const Standard_Real V,
676 Standard_Integer i = LocateUParameter ( U );
677 Standard_Integer j = LocateVParameter ( V );
678 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
679 myPatches->Value(i,j)->D3 ( uv.X(), uv.Y(), P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV );
682 //=======================================================================
685 //=======================================================================
687 gp_Vec ShapeExtend_CompositeSurface::DN (const Standard_Real U,
688 const Standard_Real V,
689 const Standard_Integer Nu,
690 const Standard_Integer Nv) const
692 Standard_Integer i = LocateUParameter ( U );
693 Standard_Integer j = LocateVParameter ( V );
694 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
695 return myPatches->Value(i,j)->DN ( uv.X(), uv.Y(), Nu, Nv );
698 //=======================================================================
701 //=======================================================================
703 gp_Pnt ShapeExtend_CompositeSurface::Value (const gp_Pnt2d& pnt) const
705 Standard_Integer i = LocateUParameter ( pnt.X() );
706 Standard_Integer j = LocateVParameter ( pnt.Y() );
707 gp_Pnt2d uv = GlobalToLocal ( i, j, pnt );
709 myPatches->Value(i,j)->D0 ( uv.X(), uv.Y(), point );
713 //=======================================================================
714 //function : ComputeJointValues
716 //=======================================================================
718 void ShapeExtend_CompositeSurface::ComputeJointValues (const ShapeExtend_Parametrisation param)
720 Standard_Integer NbU = NbUPatches();
721 Standard_Integer NbV = NbVPatches();
722 myUJointValues = new TColStd_HArray1OfReal(1,NbU+1);
723 myVJointValues = new TColStd_HArray1OfReal(1,NbV+1);
725 if ( param == ShapeExtend_Natural ) {
726 Standard_Real U1, U2, V1, V2, U=0, V=0;
727 Standard_Integer i; // svv Jan 10 2000 : porting on DEC
728 for ( i = 1; i <= NbU; i++ ) {
729 myPatches->Value(i,1)->Bounds(U1,U2,V1,V2);
730 if ( i ==1 ) myUJointValues->SetValue ( 1, U = U1 );
732 myUJointValues->SetValue ( i+1, U );
734 for ( i = 1; i <= NbV; i++ ) {
735 myPatches->Value(1,i)->Bounds(U1,U2,V1,V2);
736 if ( i ==1 ) myVJointValues->SetValue ( 1, V = V1 );
738 myVJointValues->SetValue ( i+1, V );
742 Standard_Real stepu = 1., stepv = 1.; // suppose param == ShapeExtend_Uniform
743 if ( param == ShapeExtend_Unitary ) {
747 Standard_Integer i; // svv Jan 10 2000 : porting on DEC
748 for ( i=0; i <= NbU; i++ )
749 myUJointValues->SetValue ( i+1, i * stepu );
750 for ( i=0; i <= NbV; i++ )
751 myVJointValues->SetValue ( i+1, i * stepv );
755 //=======================================================================
756 //function : CheckConnectivity
758 //=======================================================================
760 static inline Standard_Real LimitValue (const Standard_Real &par)
762 return Precision::IsInfinite(par) ? ( par <0 ? -10000. : 10000. ) : par;
765 static void GetLimitedBounds (const Handle(Geom_Surface) &surf,
766 Standard_Real &U1, Standard_Real &U2,
767 Standard_Real &V1, Standard_Real &V2)
769 surf->Bounds ( U1, U2, V1, V2 );
770 U1 = LimitValue ( U1 );
771 U2 = LimitValue ( U2 );
772 V1 = LimitValue ( V1 );
773 V2 = LimitValue ( V2 );
776 Standard_Boolean ShapeExtend_CompositeSurface::CheckConnectivity (const Standard_Real Prec)
778 const Standard_Integer NPOINTS = 23;
779 Standard_Boolean ok = Standard_True;
780 Standard_Integer NbU = NbUPatches();
781 Standard_Integer NbV = NbVPatches();
783 // check in u direction
784 Standard_Integer i,j; // svv Jan 10 2000 : porting on DEC
785 for ( i=1, j = NbU; i <= NbU; j = i++ ) {
786 Standard_Real maxdist2 = 0.;
787 for ( Standard_Integer k=1; k <= NbV; k++ ) {
788 Handle(Geom_Surface) sj = myPatches->Value(j,k);
789 Handle(Geom_Surface) si = myPatches->Value(i,k);
790 Standard_Real Uj1, Uj2, Vj1, Vj2;
791 GetLimitedBounds ( sj, Uj1, Uj2, Vj1, Vj2 );
792 Standard_Real Ui1, Ui2, Vi1, Vi2;
793 GetLimitedBounds ( si, Ui1, Ui2, Vi1, Vi2 );
794 Standard_Real stepj = ( Vj2 - Vj1 ) / ( NPOINTS - 1 );
795 Standard_Real stepi = ( Vi2 - Vi1 ) / ( NPOINTS - 1 );
796 for ( Standard_Integer isample=0; isample < NPOINTS; isample++ ) {
797 Standard_Real parj = Vj1 + stepj * isample;
798 Standard_Real pari = Vi1 + stepi * isample;
799 Standard_Real dist2 = sj->Value ( Uj2, parj ).SquareDistance ( si->Value ( Ui1, pari ) );
800 if ( maxdist2 < dist2 ) maxdist2 = dist2;
803 if ( i==1 ) myUClosed = ( maxdist2 <= Prec*Prec );
804 else if ( maxdist2 > Prec*Prec ) ok = Standard_False;
807 // check in v direction
808 for ( i=1, j = NbV; i <= NbV; j = i++ ) {
809 Standard_Real maxdist2 = 0.;
810 for ( Standard_Integer k=1; k <= NbU; k++ ) {
811 Handle(Geom_Surface) sj = myPatches->Value(k,j);
812 Handle(Geom_Surface) si = myPatches->Value(k,i);
813 Standard_Real Uj1, Uj2, Vj1, Vj2;
814 GetLimitedBounds ( sj, Uj1, Uj2, Vj1, Vj2 );
815 Standard_Real Ui1, Ui2, Vi1, Vi2;
816 GetLimitedBounds ( si, Ui1, Ui2, Vi1, Vi2 );
817 Standard_Real stepj = ( Uj2 - Uj1 ) / ( NPOINTS - 1 );
818 Standard_Real stepi = ( Ui2 - Ui1 ) / ( NPOINTS - 1 );
819 for ( Standard_Integer isample=0; isample < NPOINTS; isample++ ) {
820 Standard_Real parj = Uj1 + stepj * isample;
821 Standard_Real pari = Ui1 + stepi * isample;
822 Standard_Real dist2 = sj->Value ( parj, Vj2 ).SquareDistance ( si->Value ( pari, Vi1 ) );
823 if ( maxdist2 < dist2 ) maxdist2 = dist2;
826 if ( i==1 ) myVClosed = ( maxdist2 <= Prec*Prec );
827 else if ( maxdist2 > Prec*Prec ) ok = Standard_False;
831 if ( ! ok ) cout << "Warning: ShapeExtend_CompositeSurface: not connected in 3d" << endl;