+//=======================================================================
+//function : computePeriodicity
+//purpose : Compute period information on adaptor.
+//=======================================================================
+static void computePeriodicity(const Handle(Adaptor3d_HSurface)& theSurf,
+ Standard_Real &theUPeriod,
+ Standard_Real &theVPeriod)
+{
+ theUPeriod = 0.0;
+ theVPeriod = 0.0;
+
+ // Compute once information about periodicity.
+ // Param space may be reduced in case of rectangular trimmed surface,
+ // in this case really trimmed bounds should be set as unperiodic.
+ Standard_Real aTrimF, aTrimL, aBaseF, aBaseL, aDummyF, aDummyL;
+ Handle(Geom_Surface) aS = GeomAdaptor::MakeSurface(theSurf->Surface(), Standard_False); // Not trim.
+ // U param space.
+ if (theSurf->IsUPeriodic())
+ {
+ theUPeriod = theSurf->UPeriod();
+ }
+ else if(theSurf->IsUClosed())
+ {
+ theUPeriod = theSurf->LastUParameter() - theSurf->FirstUParameter();
+ }
+ if (theUPeriod != 0.0)
+ {
+ aTrimF = theSurf->FirstUParameter(); // Trimmed first
+ aTrimL = theSurf->LastUParameter(); // Trimmed last
+ aS->Bounds(aBaseF, aBaseL, aDummyF, aDummyL); // Non-trimmed values.
+ if (Abs (aBaseF - aTrimF) + Abs (aBaseL - aTrimL) > Precision::PConfusion())
+ {
+ // Param space reduced.
+ theUPeriod = 0.0;
+ }
+ }
+
+ // V param space.
+ if (theSurf->IsVPeriodic())
+ {
+ theVPeriod = theSurf->VPeriod();
+ }
+ else if(theSurf->IsVClosed())
+ {
+ theVPeriod = theSurf->LastVParameter() - theSurf->FirstVParameter();
+ }
+ if (theVPeriod != 0.0)
+ {
+ aTrimF = theSurf->FirstVParameter(); // Trimmed first
+ aTrimL = theSurf->LastVParameter(); // Trimmed last
+ aS->Bounds(aDummyF, aDummyL, aBaseF, aBaseL); // Non-trimmed values.
+ if (Abs (aBaseF - aTrimF) + Abs (aBaseL - aTrimL) > Precision::PConfusion())
+ {
+ // Param space reduced.
+ theVPeriod = 0.0;
+ }
+ }
+}
+