// Modified by skv - Wed Jun 2 11:49:59 2004 OCC5898
-#include <Approx_SameParameter.ixx>
-#include <TColStd_Array1OfReal.hxx>
-#include <BSplCLib.hxx>
+#include <Adaptor2d_HCurve2d.hxx>
#include <Adaptor3d_CurveOnSurface.hxx>
+#include <Adaptor3d_HCurve.hxx>
+#include <Adaptor3d_HSurface.hxx>
+#include <AdvApprox_ApproxAFunction.hxx>
+#include <Approx_SameParameter.hxx>
+#include <BSplCLib.hxx>
+#include <Extrema_ExtPC.hxx>
+#include <Extrema_LocateExtPC.hxx>
+#include <GCPnts_QuasiUniformDeflection.hxx>
+#include <Geom2d_BSplineCurve.hxx>
+#include <Geom2d_Curve.hxx>
#include <Geom2dAdaptor_Curve.hxx>
#include <Geom2dAdaptor_HCurve.hxx>
+#include <Geom_Curve.hxx>
+#include <Geom_Surface.hxx>
#include <GeomAdaptor_Curve.hxx>
#include <GeomAdaptor_HCurve.hxx>
-#include <GeomAdaptor_Surface.hxx>
#include <GeomAdaptor_HSurface.hxx>
-#include <GCPnts_QuasiUniformDeflection.hxx>
-#include <Extrema_LocateExtPC.hxx>
-#include <AdvApprox_ApproxAFunction.hxx>
+#include <GeomAdaptor_Surface.hxx>
#include <GeomLib_MakeCurvefromApprox.hxx>
#include <Precision.hxx>
-#include <Extrema_ExtPC.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <Standard_OutOfRange.hxx>
+#include <TColStd_Array1OfReal.hxx>
-#ifdef DEB
+#ifdef OCCT_DEBUG
#ifdef DRAW
#include <DrawTrSurf.hxx>
#endif
Standard_Integer extrap_mode[2] ;
extrap_mode[0] = extrap_mode[1] = 3;
Standard_Integer i;
-#ifdef DEB
+#ifdef OCCT_DEBUG
if (Voir) {
cout<<endl;
cout<<"Control the change of variable : "<<endl;
if(temp >= glis) glis = temp;
}
dglis = sqrt(dglis);
-#ifdef DEB
+#ifdef OCCT_DEBUG
if ( Voir) {
cout<<"shift of parameter to the imposed points : "<<glis<<endl;
cout<<"shift distance at the imposed points : "<<dglis<<endl;
if(temp >= dglis) dglis = temp;
}
dglis = sqrt(dglis);
-#ifdef DEB
+#ifdef OCCT_DEBUG
if (Voir)
cout<<"distance de glissement en milieu d intervals : "<<dglis<<endl;
#endif
Standard_Real firstborne= 3.*pc3d(1) - 2.*pc3d(nbp);
Standard_Real lastborne = 3.*pc3d(nbp) - 2.*pc3d(1);
// Modified by skv - Wed Jun 2 11:50:03 2004 OCC5898 End
+ //jgv
+ Standard_Real FirstPar = cons.FirstParameter();
+ Standard_Real LastPar = cons.LastParameter();
+ if (firstborne < FirstPar)
+ firstborne = FirstPar;
+ if (lastborne > LastPar)
+ lastborne = LastPar;
+ /////
for(i = 0; i <= nn; i++){
Standard_Real t = unsurnn*i;
Standard_Real tc3d = pc3d(1)*(1.-t) + pc3d(nbp)*t;
if(temp > d2) d2 = temp;
}
tol = sqrt(d2);
-#ifdef DEB
+#ifdef OCCT_DEBUG
if (Voir)
cout<<"distance max on "<<nn<<" points : "<<tol<<endl<<endl;
#endif
Standard_Real Tol = Tolerance;
Standard_Real Tol2 = Tol * Tol;
- Standard_Real Tolp = myC3d->Resolution(Tol), deltamin = 50*Tolp;
+ Standard_Real deltamin = Precision::PConfusion();//50*Tolp;
Standard_Real besttol2 = Tol2;
Standard_Boolean extrok = 0;
else extrok = 0;
- if(dmax2 > besttol2) besttol2 = dmax2;
+ //if(dmax2 > besttol2) besttol2 = dmax2;
//Take a multiple of the sample pof CheckShape,
//at least the control points will be correct. No comment!!!
-#ifdef DEB
+#ifdef OCCT_DEBUG
Standard_Integer nbcoups = 0;
#endif
ii =1;
new_par.Append(fcons);
- while(Param_de_decoupeC1(inter) <= fcons + deltamin) inter++;
- while(Param_de_decoupeC1(NbInt) >= lcons - deltamin) NbInt--;
+ while(inter <= NbInt && Param_de_decoupeC1(inter) <= fcons + deltamin) inter++;
+ while(NbInt > 0 && Param_de_decoupeC1(NbInt) >= lcons - deltamin) NbInt--;
- while(inter <= NbInt || ii < NCONTROL) {
+ while(inter <= NbInt || (ii < NCONTROL && inter <= Param_de_decoupeC1.Length()) ) {
if(Param_de_decoupeC1(inter) < pcons[ii]) {
new_par.Append(Param_de_decoupeC1(inter));
if((pcons[ii] - Param_de_decoupeC1(inter)) <= deltamin) {
new_par.Append(lcons);
New_NCONTROL = new_par.Length() - 1;
- //simple protection if New_NCONTROL > allocated elements in array
- if (New_NCONTROL > aMaxArraySize) {
+ // Simple protection if New_NCONTROL > allocated elements in array but one
+ // aMaxArraySize - 1 index may be filled after projection.
+ if (New_NCONTROL > aMaxArraySize - 1) {
mySameParameter = Standard_False;
return;
}
myC3d->D0(pc3d[ii],Pc3d);
dist2 = Pcons.SquareDistance(Pc3d);
use_parameter = (dist2 <= Tol2 && (pc3d[ii] > pc3d[count-1] + deltamin)) ;
+ Standard_Real aDistMin = RealLast();;
if(use_parameter) {
if(dist2 > dmax2) dmax2 = dist2;
initp = previousp = pc3d[count] = pc3d[ii];
pcons[count] = pcons[ii];
count++;
+
}
else {
if(!projok) initp = pc3d[ii];
if (Projector.IsDone()) {
curp = Projector.Point().Parameter();
Standard_Real dist_2 = Projector.SquareDistance();
- if(dist_2 > besttol2) besttol2 = dist_2;
- projok = 1;
+ projok = Standard_True;
+ aDistMin = dist_2;
}
else
{
ProjectPointOnCurve(initp,Pcons,Tol,30,myC3d->Curve(),projok,curp);
+ if(projok)
+ {
+ const gp_Pnt& ap1 =myC3d->Value(curp);
+ aDistMin = Pcons.SquareDistance(ap1);
+ }
}
-
+ projok = (projok && (curp > previousp + deltamin && curp < bornesup));
if(projok)
{
- if(curp > previousp + deltamin && curp < bornesup){
- initp = previousp = pc3d[count] = curp;
- pcons[count] = pcons[ii];
- count++;
- }
+ initp = previousp = pc3d[count] = curp;
+ pcons[count] = pcons[ii];
+ count++;
+
}
else
{
if(aNbExt > 0)
{
Standard_Integer anIndMin = 0;
- Standard_Real aDistMin = RealLast();
+ Standard_Real aCurDistMin = RealLast();
for(Standard_Integer i = 1; i <= aNbExt; i++)
{
const gp_Pnt &aP = PR.Point(i).Value();
Standard_Real aDist2 = aP.SquareDistance(Pcons);
- if(aDist2 < aDistMin)
+ if(aDist2 < aCurDistMin)
{
- aDistMin = aDist2;
+ aCurDistMin = aDist2;
anIndMin = i;
}
}
- curp = PR.Point(anIndMin).Parameter();
- if(curp > previousp + deltamin && curp < bornesup)
+ if(anIndMin)
{
- initp = previousp = pc3d[count] = curp;
- pcons[count] = pcons[ii];
- count++;
- projok = Standard_True;
+ curp = PR.Point(anIndMin).Parameter();
+ if( curp > previousp + deltamin && curp < bornesup)
+ {
+ aDistMin = aCurDistMin;
+ initp = previousp = pc3d[count] = curp;
+ pcons[count] = pcons[ii];
+ count++;
+ projok = Standard_True;
+
+ }
}
+
}
}
}
-
- if(!projok)
+ if(projok && besttol2 < aDistMin)
+ besttol2 = aDistMin;
+
+ else if(!projok)
{
//Projector
-#ifdef DEB
+#ifdef OCCT_DEBUG
// JAG
cout << "Projection not done" << endl;
#endif
if(!extrok) { // If not already SameP and tangent to mill, abandon.
mySameParameter = Standard_False;
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout<<"SameParameter problem : zero tangent to extremities"<<endl;
#endif
return;
pcons[count] = lcons;
pc3d[count] = lc3d;
-#ifdef DEB
+#ifdef OCCT_DEBUG
if (AffichFw) {
char Name[17];
Name[0]='\0';
}
//-------------------------------------------
-#ifdef DEB
+#ifdef OCCT_DEBUG
if (AffichFw) {
nbcoups ++;
char Name[17];
}
}
else {
-#ifdef DEB
+#ifdef OCCT_DEBUG
// JAG
cout << "Projection not done" << endl;
#endif
if (Precision::IsInfinite(algtol)) {
mySameParameter = Standard_False;
-#ifdef DEB
+#ifdef OCCT_DEBUG
cout<<"SameParameter problem : function of interpolation of parametration at mills !!"<<endl;
#endif
return;
if(interpolok) {
Standard_Real besttol = sqrt(besttol2);
-#ifdef DEB
+#ifdef OCCT_DEBUG
if (Voir) {
if(algtol > besttol){
cout<<"SameParameter : Tol can't be reached before approx"<<endl;
if(!interpolok)
{
-#ifdef DEB
+#ifdef OCCT_DEBUG
if (Voir)
cout<<"SameParameter : Not enough points, enrich"<<endl;
#endif
}
}
else {
-#ifdef DEB
+#ifdef OCCT_DEBUG
// JAG
cout << "Projection not done" << endl;
#endif