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.
18 #include <Geom_Curve.hxx>
19 #include <Geom_Geometry.hxx>
20 #include <Geom_Surface.hxx>
22 #include <gp_Pnt2d.hxx>
23 #include <gp_Trsf.hxx>
24 #include <gp_Trsf2d.hxx>
26 #include <Precision.hxx>
27 #include <ShapeExtend_CompositeSurface.hxx>
28 #include <Standard_Type.hxx>
30 IMPLEMENT_STANDARD_RTTIEXT(ShapeExtend_CompositeSurface,Geom_Surface)
32 //=======================================================================
33 //function : ShapeExtend_CompositeSurface
35 //=======================================================================
36 ShapeExtend_CompositeSurface::ShapeExtend_CompositeSurface()
40 //=======================================================================
41 //function : Constructor
43 //=======================================================================
45 ShapeExtend_CompositeSurface::ShapeExtend_CompositeSurface(const Handle(TColGeom_HArray2OfSurface)& GridSurf,
46 const ShapeExtend_Parametrisation param)
48 Init ( GridSurf, param );
51 //=======================================================================
52 //function : Constructor
54 //=======================================================================
56 ShapeExtend_CompositeSurface::ShapeExtend_CompositeSurface(const Handle(TColGeom_HArray2OfSurface)& GridSurf,
57 const TColStd_Array1OfReal &UJoints,
58 const TColStd_Array1OfReal &VJoints)
60 Init ( GridSurf, UJoints, VJoints );
63 //=======================================================================
66 //=======================================================================
68 Standard_Boolean ShapeExtend_CompositeSurface::Init (const Handle(TColGeom_HArray2OfSurface)& GridSurf,
69 const ShapeExtend_Parametrisation param)
71 if ( GridSurf.IsNull() ) return Standard_False;
73 ComputeJointValues ( param );
74 return CheckConnectivity ( Precision::Confusion() );
77 //=======================================================================
80 //=======================================================================
82 Standard_Boolean ShapeExtend_CompositeSurface::Init (const Handle(TColGeom_HArray2OfSurface)& GridSurf,
83 const TColStd_Array1OfReal &UJoints,
84 const TColStd_Array1OfReal &VJoints)
86 if ( GridSurf.IsNull() ) return Standard_False;
89 Standard_Boolean ok = Standard_True;
90 if ( ! SetUJointValues ( UJoints ) || ! SetVJointValues ( VJoints ) ) {
92 ComputeJointValues ( ShapeExtend_Natural );
94 cout << "Warning: ShapeExtend_CompositeSurface::Init: bad joint values" << endl;
98 return ( CheckConnectivity ( Precision::Confusion() ) ? ok : Standard_False );
101 //=======================================================================
102 //function : NbUPatches
104 //=======================================================================
106 Standard_Integer ShapeExtend_CompositeSurface::NbUPatches() const
108 return myPatches->ColLength();
111 //=======================================================================
112 //function : NbVPatches
114 //=======================================================================
116 Standard_Integer ShapeExtend_CompositeSurface::NbVPatches() const
118 return myPatches->RowLength();
121 //=======================================================================
124 //=======================================================================
126 const Handle(Geom_Surface)& ShapeExtend_CompositeSurface::Patch(const Standard_Integer i,
127 const Standard_Integer j) const
129 return myPatches->Value(i,j);
132 //=======================================================================
135 //=======================================================================
137 const Handle(TColGeom_HArray2OfSurface)& ShapeExtend_CompositeSurface::Patches() const
142 //=======================================================================
143 //function : UJointValues
145 //=======================================================================
147 Handle(TColStd_HArray1OfReal) ShapeExtend_CompositeSurface::UJointValues() const
149 return myUJointValues;
152 //=======================================================================
153 //function : VJointValues
155 //=======================================================================
157 Handle(TColStd_HArray1OfReal) ShapeExtend_CompositeSurface::VJointValues() const
159 return myVJointValues;
162 //=======================================================================
163 //function : UJointValue
165 //=======================================================================
167 Standard_Real ShapeExtend_CompositeSurface::UJointValue(const Standard_Integer i) const
169 return myUJointValues->Value(i);
172 //=======================================================================
173 //function : VJointValue
175 //=======================================================================
177 Standard_Real ShapeExtend_CompositeSurface::VJointValue(const Standard_Integer i) const
179 return myVJointValues->Value(i);
182 //=======================================================================
183 //function : SetUJointValues
185 //=======================================================================
187 Standard_Boolean ShapeExtend_CompositeSurface::SetUJointValues (const TColStd_Array1OfReal &UJoints)
189 Standard_Integer NbU = NbUPatches();
190 if ( UJoints.Length() != NbU+1 ) return Standard_False;
192 Handle(TColStd_HArray1OfReal) UJointValues = new TColStd_HArray1OfReal(1,NbU+1);
193 for ( Standard_Integer i=1, j=UJoints.Lower(); i <= NbU+1; i++, j++ ) {
194 UJointValues->SetValue ( i, UJoints(j) );
195 if ( i >1 && UJoints(j) - UJoints(j-1) < Precision::PConfusion() )
196 return Standard_False;
198 myUJointValues = UJointValues;
199 return Standard_True;
202 //=======================================================================
203 //function : SetVJointValues
205 //=======================================================================
207 Standard_Boolean ShapeExtend_CompositeSurface::SetVJointValues (const TColStd_Array1OfReal &VJoints)
209 Standard_Integer NbV = NbVPatches();
210 if ( VJoints.Length() != NbV+1 ) return Standard_False;
212 Handle(TColStd_HArray1OfReal) VJointValues = new TColStd_HArray1OfReal(1,NbV+1);
213 for ( Standard_Integer i=1, j=VJoints.Lower(); i <= NbV+1; i++, j++ ) {
214 VJointValues->SetValue ( i, VJoints(j) );
215 if ( i >1 && VJoints(j) - VJoints(j-1) < Precision::PConfusion() )
216 return Standard_False;
218 myVJointValues = VJointValues;
219 return Standard_True;
222 //=======================================================================
223 //function : SetUFirstValue
225 //=======================================================================
227 void ShapeExtend_CompositeSurface::SetUFirstValue (const Standard_Real UFirst)
229 if ( myUJointValues.IsNull() ) return;
231 Standard_Real shift = UFirst - myUJointValues->Value(1);
232 Standard_Integer NbU = myUJointValues->Length();
233 for ( Standard_Integer i=1; i <= NbU; i++ ) {
234 myUJointValues->SetValue ( i, myUJointValues->Value(i) + shift );
238 //=======================================================================
239 //function : SetVFirstValue
241 //=======================================================================
243 void ShapeExtend_CompositeSurface::SetVFirstValue (const Standard_Real VFirst)
245 if ( myVJointValues.IsNull() ) return;
247 Standard_Real shift = VFirst - myVJointValues->Value(1);
248 Standard_Integer NbV = myVJointValues->Length();
249 for ( Standard_Integer i=1; i <= NbV; i++ ) {
250 myVJointValues->SetValue ( i, myVJointValues->Value(i) + shift );
254 //=======================================================================
255 //function : LocateUParameter
257 //=======================================================================
259 Standard_Integer ShapeExtend_CompositeSurface::LocateUParameter(const Standard_Real U) const
261 Standard_Integer nbPatch = NbUPatches();
262 for(Standard_Integer i = 2; i <= nbPatch; i++)
263 if (U < myUJointValues->Value(i)) return i-1;
267 //=======================================================================
268 //function : LocateVParameter
270 //=======================================================================
272 Standard_Integer ShapeExtend_CompositeSurface::LocateVParameter(const Standard_Real V) const
274 Standard_Integer nbPatch = NbVPatches();
275 for(Standard_Integer i = 2; i <= nbPatch; i++)
276 if (V < myVJointValues->Value(i)) return i-1;
280 //=======================================================================
281 //function : LocateUVPoint
283 //=======================================================================
285 void ShapeExtend_CompositeSurface::LocateUVPoint(const gp_Pnt2d& pnt,
287 Standard_Integer& j) const
289 i = LocateUParameter(pnt.X());
290 j = LocateVParameter(pnt.Y());
293 //=======================================================================
296 //=======================================================================
298 const Handle(Geom_Surface)& ShapeExtend_CompositeSurface::Patch(const Standard_Real U,
299 const Standard_Real V) const
301 return myPatches->Value ( LocateUParameter(U), LocateVParameter(V) );
304 //=======================================================================
307 //=======================================================================
309 const Handle(Geom_Surface)& ShapeExtend_CompositeSurface::Patch(const gp_Pnt2d& pnt) const
311 return myPatches->Value ( LocateUParameter(pnt.X()), LocateVParameter(pnt.Y()) );
314 //=======================================================================
315 //function : ULocalToGlobal
317 //=======================================================================
319 Standard_Real ShapeExtend_CompositeSurface::ULocalToGlobal (const Standard_Integer i,
320 const Standard_Integer j,
321 const Standard_Real u) const
323 Standard_Real u1, u2, v1, v2;
324 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
325 Standard_Real scale = ( myUJointValues->Value(i+1) - myUJointValues->Value(i) ) / ( u2 - u1 );
326 return u * scale + ( myUJointValues->Value(i) - u1 * scale ); // ! this formula is stable if u1 is infinite
329 //=======================================================================
330 //function : VLocalToGlobal
332 //=======================================================================
334 Standard_Real ShapeExtend_CompositeSurface::VLocalToGlobal (const Standard_Integer i,
335 const Standard_Integer j,
336 const Standard_Real v) const
338 Standard_Real u1, u2, v1, v2;
339 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
340 Standard_Real scale = ( myVJointValues->Value(j+1) - myVJointValues->Value(j) ) / ( v2 - v1 );
341 return v * scale + ( myVJointValues->Value(j) - v1 * scale ); // ! this formula is stable if v1 is infinite
344 //=======================================================================
345 //function : LocalToGlobal
347 //=======================================================================
349 gp_Pnt2d ShapeExtend_CompositeSurface::LocalToGlobal (const Standard_Integer i,
350 const Standard_Integer j,
351 const gp_Pnt2d &uv) const
353 Standard_Real u1, u2, v1, v2;
354 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
355 Standard_Real scaleu = ( myUJointValues->Value(i+1) - myUJointValues->Value(i) ) / ( u2 - u1 );
356 Standard_Real scalev = ( myVJointValues->Value(j+1) - myVJointValues->Value(j) ) / ( v2 - v1 );
357 return gp_Pnt2d ( uv.X() * scaleu + ( myUJointValues->Value(i) - u1 * scaleu ), // ! this formula is stable if u1 or v1 is infinite
358 uv.Y() * scalev + ( myVJointValues->Value(j) - v1 * scalev ) );
361 //=======================================================================
362 //function : UGlobalToLocal
364 //=======================================================================
366 Standard_Real ShapeExtend_CompositeSurface::UGlobalToLocal (const Standard_Integer i,
367 const Standard_Integer j,
368 const Standard_Real U) const
370 Standard_Real u1, u2, v1, v2;
371 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
372 Standard_Real scale = ( u2 - u1 ) / ( myUJointValues->Value(i+1) - myUJointValues->Value(i) );
373 return U * scale + ( u1 - myUJointValues->Value(i) * scale ); // ! this formula is stable if u1 is infinite
376 //=======================================================================
377 //function : VGlobalToLocal
379 //=======================================================================
381 Standard_Real ShapeExtend_CompositeSurface::VGlobalToLocal (const Standard_Integer i,
382 const Standard_Integer j,
383 const Standard_Real V) const
385 Standard_Real u1, u2, v1, v2;
386 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
387 Standard_Real scale = ( v2 - v1 ) / ( myVJointValues->Value(j+1) - myVJointValues->Value(j) );
388 return V * scale + ( v1 - myVJointValues->Value(j) * scale ); // ! this formula is stable if v1 is infinite
391 //=======================================================================
392 //function : GlobalToLocal
394 //=======================================================================
396 gp_Pnt2d ShapeExtend_CompositeSurface::GlobalToLocal (const Standard_Integer i,
397 const Standard_Integer j,
398 const gp_Pnt2d &UV) const
400 Standard_Real u1, u2, v1, v2;
401 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
402 Standard_Real scaleu = ( u2 - u1 ) / ( myUJointValues->Value(i+1) - myUJointValues->Value(i) );
403 Standard_Real scalev = ( v2 - v1 ) / ( myVJointValues->Value(j+1) - myVJointValues->Value(j) );
404 return gp_Pnt2d ( UV.X() * scaleu + ( u1 - myUJointValues->Value(i) * scaleu ), // ! this formula is stable if u1 or v1 is infinite
405 UV.Y() * scalev + ( v1 - myVJointValues->Value(j) * scalev ) );
408 //=======================================================================
409 //function : GlobalToLocalTransformation
411 //=======================================================================
413 Standard_Boolean ShapeExtend_CompositeSurface::GlobalToLocalTransformation (const Standard_Integer i,
414 const Standard_Integer j,
415 Standard_Real &uFact,
416 gp_Trsf2d &Trsf) const
418 Standard_Real u1, u2, v1, v2;
419 myPatches->Value(i,j)->Bounds ( u1, u2, v1, v2 );
421 Standard_Real scaleu = ( u2 - u1 ) / ( myUJointValues->Value(i+1) - myUJointValues->Value(i) );
422 Standard_Real scalev = ( v2 - v1 ) / ( myVJointValues->Value(j+1) - myVJointValues->Value(j) );
423 gp_Vec2d shift ( u1 / scaleu - myUJointValues->Value(i),
424 v1 / scalev - myVJointValues->Value(j) );
426 uFact = scaleu / scalev;
427 gp_Trsf2d Shift, Scale;
428 if ( shift.X() != 0. || shift.Y() != 0. ) Shift.SetTranslation ( shift );
429 if ( scalev != 1. ) Scale.SetScale ( gp_Pnt2d(0,0), scalev );
430 Trsf = Scale * Shift;
431 return uFact != 1. || Trsf.Form() != gp_Identity;
434 //=======================================================================
435 // Inherited methods (from Geom_Geometry and Geom_Surface)
436 //=======================================================================
438 //=======================================================================
439 //function : Transform
441 //=======================================================================
443 void ShapeExtend_CompositeSurface::Transform (const gp_Trsf &T)
445 if ( myPatches.IsNull() ) return;
446 for ( Standard_Integer i=1; i <= NbUPatches(); i++ )
447 for ( Standard_Integer j=1; j <= NbVPatches(); j++ )
448 Patch(i,j)->Transform ( T );
451 //=======================================================================
454 //=======================================================================
456 Handle(Geom_Geometry) ShapeExtend_CompositeSurface::Copy () const
458 Handle(ShapeExtend_CompositeSurface) surf = new ShapeExtend_CompositeSurface;
459 if ( myPatches.IsNull() ) return surf;
461 Handle(TColGeom_HArray2OfSurface) patches =
462 new TColGeom_HArray2OfSurface ( 1, NbUPatches(), 1, NbVPatches() );
463 for ( Standard_Integer i=1; i <= NbUPatches(); i++ )
464 for ( Standard_Integer j=1; j <= NbVPatches(); j++ )
465 patches->SetValue ( i, j, Handle(Geom_Surface)::DownCast ( Patch(i,j)->Copy() ) );
466 surf->Init ( patches );
470 //=======================================================================
471 //function : UReverse
473 //=======================================================================
475 void ShapeExtend_CompositeSurface::UReverse ()
479 //=======================================================================
480 //function : UReversedParameter
482 //=======================================================================
484 Standard_Real ShapeExtend_CompositeSurface::UReversedParameter (const Standard_Real U) const
489 //=======================================================================
490 //function : VReverse
492 //=======================================================================
494 void ShapeExtend_CompositeSurface::VReverse ()
498 //=======================================================================
499 //function : VReversedParameter
501 //=======================================================================
503 Standard_Real ShapeExtend_CompositeSurface::VReversedParameter (const Standard_Real V) const
508 //=======================================================================
511 //=======================================================================
513 void ShapeExtend_CompositeSurface::Bounds(Standard_Real& U1,
516 Standard_Real& V2) const
520 U2 = UJointValue(NbUPatches()+1);
521 V2 = VJointValue(NbVPatches()+1);
524 //=======================================================================
525 //function : IsUPeriodic
527 //=======================================================================
529 Standard_Boolean ShapeExtend_CompositeSurface::IsUPeriodic () const
531 return Standard_False;
534 //=======================================================================
535 //function : IsVPeriodic
537 //=======================================================================
539 Standard_Boolean ShapeExtend_CompositeSurface::IsVPeriodic () const
541 return Standard_False;
544 //=======================================================================
547 //=======================================================================
549 Handle(Geom_Curve) ShapeExtend_CompositeSurface::UIso (const Standard_Real ) const
551 Handle(Geom_Curve) dummy;
555 //=======================================================================
558 //=======================================================================
560 Handle(Geom_Curve) ShapeExtend_CompositeSurface::VIso (const Standard_Real ) const
562 Handle(Geom_Curve) dummy;
566 //=======================================================================
567 //function : Continuity
569 //=======================================================================
571 GeomAbs_Shape ShapeExtend_CompositeSurface::Continuity () const
576 //=======================================================================
579 //=======================================================================
581 Standard_Boolean ShapeExtend_CompositeSurface::IsCNu (const Standard_Integer N) const
586 //=======================================================================
589 //=======================================================================
591 Standard_Boolean ShapeExtend_CompositeSurface::IsCNv (const Standard_Integer N) const
596 //=======================================================================
597 //function : IsUClosed
599 //=======================================================================
601 Standard_Boolean ShapeExtend_CompositeSurface::IsUClosed () const
606 //=======================================================================
607 //function : IsVClosed
609 //=======================================================================
611 Standard_Boolean ShapeExtend_CompositeSurface::IsVClosed () const
616 //=======================================================================
619 //=======================================================================
621 void ShapeExtend_CompositeSurface::D0 (const Standard_Real U,
622 const Standard_Real V,
625 Standard_Integer i = LocateUParameter ( U );
626 Standard_Integer j = LocateVParameter ( V );
627 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
628 myPatches->Value(i,j)->D0 ( uv.X(), uv.Y(), P );
631 //=======================================================================
634 //=======================================================================
636 void ShapeExtend_CompositeSurface::D1 (const Standard_Real U,
637 const Standard_Real V,
642 Standard_Integer i = LocateUParameter ( U );
643 Standard_Integer j = LocateVParameter ( V );
644 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
645 myPatches->Value(i,j)->D1 ( uv.X(), uv.Y(), P, D1U, D1V );
648 //=======================================================================
651 //=======================================================================
653 void ShapeExtend_CompositeSurface::D2 (const Standard_Real U,
654 const Standard_Real V,
662 Standard_Integer i = LocateUParameter ( U );
663 Standard_Integer j = LocateVParameter ( V );
664 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
665 myPatches->Value(i,j)->D2 ( uv.X(), uv.Y(), P, D1U, D1V, D2U, D2V, D2UV );
668 //=======================================================================
671 //=======================================================================
673 void ShapeExtend_CompositeSurface::D3 (const Standard_Real U,
674 const Standard_Real V,
686 Standard_Integer i = LocateUParameter ( U );
687 Standard_Integer j = LocateVParameter ( V );
688 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
689 myPatches->Value(i,j)->D3 ( uv.X(), uv.Y(), P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV );
692 //=======================================================================
695 //=======================================================================
697 gp_Vec ShapeExtend_CompositeSurface::DN (const Standard_Real U,
698 const Standard_Real V,
699 const Standard_Integer Nu,
700 const Standard_Integer Nv) const
702 Standard_Integer i = LocateUParameter ( U );
703 Standard_Integer j = LocateVParameter ( V );
704 gp_Pnt2d uv = GlobalToLocal ( i, j, gp_Pnt2d ( U, V ) );
705 return myPatches->Value(i,j)->DN ( uv.X(), uv.Y(), Nu, Nv );
708 //=======================================================================
711 //=======================================================================
713 gp_Pnt ShapeExtend_CompositeSurface::Value (const gp_Pnt2d& pnt) const
715 Standard_Integer i = LocateUParameter ( pnt.X() );
716 Standard_Integer j = LocateVParameter ( pnt.Y() );
717 gp_Pnt2d uv = GlobalToLocal ( i, j, pnt );
719 myPatches->Value(i,j)->D0 ( uv.X(), uv.Y(), point );
723 //=======================================================================
724 //function : ComputeJointValues
726 //=======================================================================
728 void ShapeExtend_CompositeSurface::ComputeJointValues (const ShapeExtend_Parametrisation param)
730 Standard_Integer NbU = NbUPatches();
731 Standard_Integer NbV = NbVPatches();
732 myUJointValues = new TColStd_HArray1OfReal(1,NbU+1);
733 myVJointValues = new TColStd_HArray1OfReal(1,NbV+1);
735 if ( param == ShapeExtend_Natural ) {
736 Standard_Real U1, U2, V1, V2, U=0, V=0;
737 Standard_Integer i; // svv Jan 10 2000 : porting on DEC
738 for ( i = 1; i <= NbU; i++ ) {
739 myPatches->Value(i,1)->Bounds(U1,U2,V1,V2);
740 if ( i ==1 ) myUJointValues->SetValue ( 1, U = U1 );
742 myUJointValues->SetValue ( i+1, U );
744 for ( i = 1; i <= NbV; i++ ) {
745 myPatches->Value(1,i)->Bounds(U1,U2,V1,V2);
746 if ( i ==1 ) myVJointValues->SetValue ( 1, V = V1 );
748 myVJointValues->SetValue ( i+1, V );
752 Standard_Real stepu = 1., stepv = 1.; // suppose param == ShapeExtend_Uniform
753 if ( param == ShapeExtend_Unitary ) {
757 Standard_Integer i; // svv Jan 10 2000 : porting on DEC
758 for ( i=0; i <= NbU; i++ )
759 myUJointValues->SetValue ( i+1, i * stepu );
760 for ( i=0; i <= NbV; i++ )
761 myVJointValues->SetValue ( i+1, i * stepv );
765 //=======================================================================
766 //function : CheckConnectivity
768 //=======================================================================
770 static inline Standard_Real LimitValue (const Standard_Real &par)
772 return Precision::IsInfinite(par) ? ( par <0 ? -10000. : 10000. ) : par;
775 static void GetLimitedBounds (const Handle(Geom_Surface) &surf,
776 Standard_Real &U1, Standard_Real &U2,
777 Standard_Real &V1, Standard_Real &V2)
779 surf->Bounds ( U1, U2, V1, V2 );
780 U1 = LimitValue ( U1 );
781 U2 = LimitValue ( U2 );
782 V1 = LimitValue ( V1 );
783 V2 = LimitValue ( V2 );
786 Standard_Boolean ShapeExtend_CompositeSurface::CheckConnectivity (const Standard_Real Prec)
788 const Standard_Integer NPOINTS = 23;
789 Standard_Boolean ok = Standard_True;
790 Standard_Integer NbU = NbUPatches();
791 Standard_Integer NbV = NbVPatches();
793 // check in u direction
794 Standard_Integer i,j; // svv Jan 10 2000 : porting on DEC
795 for ( i=1, j = NbU; i <= NbU; j = i++ ) {
796 Standard_Real maxdist2 = 0.;
797 for ( Standard_Integer k=1; k <= NbV; k++ ) {
798 Handle(Geom_Surface) sj = myPatches->Value(j,k);
799 Handle(Geom_Surface) si = myPatches->Value(i,k);
800 Standard_Real Uj1, Uj2, Vj1, Vj2;
801 GetLimitedBounds ( sj, Uj1, Uj2, Vj1, Vj2 );
802 Standard_Real Ui1, Ui2, Vi1, Vi2;
803 GetLimitedBounds ( si, Ui1, Ui2, Vi1, Vi2 );
804 Standard_Real stepj = ( Vj2 - Vj1 ) / ( NPOINTS - 1 );
805 Standard_Real stepi = ( Vi2 - Vi1 ) / ( NPOINTS - 1 );
806 for ( Standard_Integer isample=0; isample < NPOINTS; isample++ ) {
807 Standard_Real parj = Vj1 + stepj * isample;
808 Standard_Real pari = Vi1 + stepi * isample;
809 Standard_Real dist2 = sj->Value ( Uj2, parj ).SquareDistance ( si->Value ( Ui1, pari ) );
810 if ( maxdist2 < dist2 ) maxdist2 = dist2;
813 if ( i==1 ) myUClosed = ( maxdist2 <= Prec*Prec );
814 else if ( maxdist2 > Prec*Prec ) ok = Standard_False;
817 // check in v direction
818 for ( i=1, j = NbV; i <= NbV; j = i++ ) {
819 Standard_Real maxdist2 = 0.;
820 for ( Standard_Integer k=1; k <= NbU; k++ ) {
821 Handle(Geom_Surface) sj = myPatches->Value(k,j);
822 Handle(Geom_Surface) si = myPatches->Value(k,i);
823 Standard_Real Uj1, Uj2, Vj1, Vj2;
824 GetLimitedBounds ( sj, Uj1, Uj2, Vj1, Vj2 );
825 Standard_Real Ui1, Ui2, Vi1, Vi2;
826 GetLimitedBounds ( si, Ui1, Ui2, Vi1, Vi2 );
827 Standard_Real stepj = ( Uj2 - Uj1 ) / ( NPOINTS - 1 );
828 Standard_Real stepi = ( Ui2 - Ui1 ) / ( NPOINTS - 1 );
829 for ( Standard_Integer isample=0; isample < NPOINTS; isample++ ) {
830 Standard_Real parj = Uj1 + stepj * isample;
831 Standard_Real pari = Ui1 + stepi * isample;
832 Standard_Real dist2 = sj->Value ( parj, Vj2 ).SquareDistance ( si->Value ( pari, Vi1 ) );
833 if ( maxdist2 < dist2 ) maxdist2 = dist2;
836 if ( i==1 ) myVClosed = ( maxdist2 <= Prec*Prec );
837 else if ( maxdist2 > Prec*Prec ) ok = Standard_False;
841 if ( ! ok ) cout << "Warning: ShapeExtend_CompositeSurface: not connected in 3d" << endl;