//=======================================================================
IntPatch_ImpPrmIntersection::IntPatch_ImpPrmIntersection ()
- : done(Standard_False),
- empt(Standard_False),
- myIsStartPnt(Standard_False),
- myUStart(0.0),
- myVStart(0.0)
+ : done(Standard_False),
+ empt(Standard_False),
+ myIsStartPnt(Standard_False),
+ myUStart(0.0),
+ myVStart(0.0)
{ }
//=======================================================================
IntPatch_ImpPrmIntersection::IntPatch_ImpPrmIntersection
- (const Handle(Adaptor3d_HSurface)& Surf1,
- const Handle(Adaptor3d_TopolTool)& D1,
- const Handle(Adaptor3d_HSurface)& Surf2,
- const Handle(Adaptor3d_TopolTool)& D2,
- const Standard_Real TolArc,
- const Standard_Real TolTang,
- const Standard_Real Fleche,
- const Standard_Real Pas)
- : done(Standard_False),
- empt(Standard_False),
- myIsStartPnt(Standard_False),
- myUStart(0.0),
- myVStart(0.0)
+ (const Handle(Adaptor3d_HSurface)& Surf1,
+ const Handle(Adaptor3d_TopolTool)& D1,
+ const Handle(Adaptor3d_HSurface)& Surf2,
+ const Handle(Adaptor3d_TopolTool)& D2,
+ const Standard_Real TolArc,
+ const Standard_Real TolTang,
+ const Standard_Real Fleche,
+ const Standard_Real Pas)
+ : done(Standard_False),
+ empt(Standard_False),
+ myIsStartPnt(Standard_False),
+ myUStart(0.0),
+ myVStart(0.0)
{
Perform(Surf1,D1,Surf2,D2,TolArc,TolTang,Fleche,Pas);
}
//=======================================================================
void IntPatch_ImpPrmIntersection::SetStartPoint(const Standard_Real U,
- const Standard_Real V)
+ const Standard_Real V)
{
myIsStartPnt = Standard_True;
myUStart = U; myVStart = V;
//purpose :
//=======================================================================
void ComputeTangency (const IntPatch_TheSOnBounds& solrst,
- IntSurf_SequenceOfPathPoint& seqpdep,
- const Handle(Adaptor3d_TopolTool)& Domain,
- IntPatch_TheSurfFunction& Func,
- const Handle(Adaptor3d_HSurface)& PSurf,
- TColStd_Array1OfInteger& Destination)
+ IntSurf_SequenceOfPathPoint& seqpdep,
+ const Handle(Adaptor3d_TopolTool)& Domain,
+ IntPatch_TheSurfFunction& Func,
+ const Handle(Adaptor3d_HSurface)& PSurf,
+ TColStd_Array1OfInteger& Destination)
{
Standard_Integer i,k, NbPoints, seqlength;
Standard_Real theparam,test;
theparam = PStart.Parameter();
arcorien = Domain->Orientation(thearc);
ispassing = (arcorien == TopAbs_INTERNAL ||
- arcorien == TopAbs_EXTERNAL);
-
+ arcorien == TopAbs_EXTERNAL);
+
thearc->D0(theparam,p2d);
X(1) = p2d.X();
X(2) = p2d.Y();
PPoint.SetValue(PStart.Value(),X(1),X(2));
-
+
Func.Values(X,F,D);
if (Func.IsTangent()) {
- PPoint.SetTangency(Standard_True);
+ PPoint.SetTangency(Standard_True);
Destination(i) = seqlength+1;
- if (!PStart.IsNew()) {
- vtx = PStart.Vertex();
- for (k=i+1; k<=NbPoints; k++) {
- if (Destination(k) ==0) {
- PStart = solrst.Point(k);
- if (!PStart.IsNew()) {
- vtxbis = PStart.Vertex();
- if (Domain->Identical(vtx,vtxbis)) {
- thearc = PStart.Arc();
- theparam = PStart.Parameter();
- arcorien = Domain->Orientation(thearc);
- ispassing = ispassing && (arcorien == TopAbs_INTERNAL ||
- arcorien == TopAbs_EXTERNAL);
-
- thearc->D0(theparam,p2d);
- PPoint.AddUV(p2d.X(),p2d.Y());
- Destination(k) = seqlength+1;
- }
- }
- }
- }
- }
- PPoint.SetPassing(ispassing);
- seqpdep.Append(PPoint);
- seqlength++;
+ if (!PStart.IsNew()) {
+ vtx = PStart.Vertex();
+ for (k=i+1; k<=NbPoints; k++) {
+ if (Destination(k) ==0) {
+ PStart = solrst.Point(k);
+ if (!PStart.IsNew()) {
+ vtxbis = PStart.Vertex();
+ if (Domain->Identical(vtx,vtxbis)) {
+ thearc = PStart.Arc();
+ theparam = PStart.Parameter();
+ arcorien = Domain->Orientation(thearc);
+ ispassing = ispassing && (arcorien == TopAbs_INTERNAL ||
+ arcorien == TopAbs_EXTERNAL);
+
+ thearc->D0(theparam,p2d);
+ PPoint.AddUV(p2d.X(),p2d.Y());
+ Destination(k) = seqlength+1;
+ }
+ }
+ }
+ }
+ }
+ PPoint.SetPassing(ispassing);
+ seqpdep.Append(PPoint);
+ seqlength++;
}
else { // on a un point de depart potentiel
- vectg = Func.Direction3d();
- dirtg = Func.Direction2d();
-
- PSurf->D1(X(1),X(2),ptbid,d1u,d1v);
- thearc->D1(theparam,p2d,d2d);
- v2.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
- v1 = d1u.Crossed(d1v);
-
- test = vectg.Dot(v1.Crossed(v2));
- if (PStart.IsNew()) {
- if ((test < 0. && arcorien == TopAbs_FORWARD) ||
- (test > 0. && arcorien == TopAbs_REVERSED)) {
- vectg.Reverse();
- dirtg.Reverse();
- }
- PPoint.SetDirections(vectg,dirtg);
- PPoint.SetPassing(ispassing);
+ vectg = Func.Direction3d();
+ dirtg = Func.Direction2d();
+
+ PSurf->D1(X(1),X(2),ptbid,d1u,d1v);
+ thearc->D1(theparam,p2d,d2d);
+ v2.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+ v1 = d1u.Crossed(d1v);
+
+ test = vectg.Dot(v1.Crossed(v2));
+ if (PStart.IsNew()) {
+ if ((test < 0. && arcorien == TopAbs_FORWARD) ||
+ (test > 0. && arcorien == TopAbs_REVERSED)) {
+ vectg.Reverse();
+ dirtg.Reverse();
+ }
+ PPoint.SetDirections(vectg,dirtg);
+ PPoint.SetPassing(ispassing);
Destination(i) = seqlength+1;
- seqpdep.Append(PPoint);
- seqlength++;
- }
- else { // traiter la transition complexe
- gp_Dir bidnorm(1.,1.,1.);
- Standard_Real tole = 1.e-8;
- TopAbs_Orientation LocTrans;
- TopTrans_CurveTransition comptrans;
- comptrans.Reset(vectg,bidnorm,0.);
- if (arcorien == TopAbs_FORWARD ||
- arcorien == TopAbs_REVERSED) {
- // pour essai
-
- vtx = PStart.Vertex();
- vtxorien = Domain->Orientation(vtx);
- if (Abs(test) <= tole) {
- LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL
- }
- else {
- if (((test > 0.)&& arcorien == TopAbs_FORWARD) ||
- ((test < 0.)&& arcorien == TopAbs_REVERSED)){
- LocTrans = TopAbs_FORWARD;
- }
- else {
- LocTrans = TopAbs_REVERSED;
- }
- if (arcorien == TopAbs_REVERSED) {v2.Reverse();}
- }
-
- comptrans.Compare(tole,v2,bidnorm,0.,LocTrans,vtxorien);
- }
+ seqpdep.Append(PPoint);
+ seqlength++;
+ }
+ else { // traiter la transition complexe
+ gp_Dir bidnorm(1.,1.,1.);
+ Standard_Real tole = 1.e-8;
+ TopAbs_Orientation LocTrans;
+ TopTrans_CurveTransition comptrans;
+ comptrans.Reset(vectg,bidnorm,0.);
+ if (arcorien == TopAbs_FORWARD ||
+ arcorien == TopAbs_REVERSED) {
+ // pour essai
+
+ vtx = PStart.Vertex();
+ vtxorien = Domain->Orientation(vtx);
+ if (Abs(test) <= tole) {
+ LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL
+ }
+ else {
+ if (((test > 0.)&& arcorien == TopAbs_FORWARD) ||
+ ((test < 0.)&& arcorien == TopAbs_REVERSED)){
+ LocTrans = TopAbs_FORWARD;
+ }
+ else {
+ LocTrans = TopAbs_REVERSED;
+ }
+ if (arcorien == TopAbs_REVERSED) {v2.Reverse();}
+ }
+
+ comptrans.Compare(tole,v2,bidnorm,0.,LocTrans,vtxorien);
+ }
Destination(i) = seqlength+1;
- for (k= i+1; k<=NbPoints; k++) {
- if (Destination(k) == 0) {
- PStart = solrst.Point(k);
- if (!PStart.IsNew()) {
- vtxbis = PStart.Vertex();
- if (Domain->Identical(vtx,vtxbis)) {
- thearc = PStart.Arc();
- theparam = PStart.Parameter();
- arcorien = Domain->Orientation(thearc);
-
- PPoint.AddUV(X(1),X(2));
-
- thearc->D1(theparam,p2d,d2d);
- PPoint.AddUV(p2d.X(),p2d.Y());
-
- if (arcorien == TopAbs_FORWARD ||
- arcorien == TopAbs_REVERSED) {
- ispassing = Standard_False;
- v2.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
-
- test = vectg.Dot(v1.Crossed(v2));
- vtxorien = Domain->Orientation(PStart.Vertex());
- if (Abs(test) <= tole) {
- LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL
- }
- else {
- if (((test > 0.)&& arcorien == TopAbs_FORWARD) ||
- ((test < 0.)&& arcorien == TopAbs_REVERSED)){
- LocTrans = TopAbs_FORWARD;
- }
- else {
- LocTrans = TopAbs_REVERSED;
- }
- if (arcorien == TopAbs_REVERSED) {v2.Reverse();}
- }
-
- comptrans.Compare(tole,v2,bidnorm,0.,LocTrans,vtxorien);
- }
- Destination(k) = seqlength+1;
- }
- }
- }
- }
+ for (k= i+1; k<=NbPoints; k++) {
+ if (Destination(k) == 0) {
+ PStart = solrst.Point(k);
+ if (!PStart.IsNew()) {
+ vtxbis = PStart.Vertex();
+ if (Domain->Identical(vtx,vtxbis)) {
+ thearc = PStart.Arc();
+ theparam = PStart.Parameter();
+ arcorien = Domain->Orientation(thearc);
+
+ PPoint.AddUV(X(1),X(2));
+
+ thearc->D1(theparam,p2d,d2d);
+ PPoint.AddUV(p2d.X(),p2d.Y());
+
+ if (arcorien == TopAbs_FORWARD ||
+ arcorien == TopAbs_REVERSED) {
+ ispassing = Standard_False;
+ v2.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+
+ test = vectg.Dot(v1.Crossed(v2));
+ vtxorien = Domain->Orientation(PStart.Vertex());
+ if (Abs(test) <= tole) {
+ LocTrans = TopAbs_EXTERNAL; // et pourquoi pas INTERNAL
+ }
+ else {
+ if (((test > 0.)&& arcorien == TopAbs_FORWARD) ||
+ ((test < 0.)&& arcorien == TopAbs_REVERSED)){
+ LocTrans = TopAbs_FORWARD;
+ }
+ else {
+ LocTrans = TopAbs_REVERSED;
+ }
+ if (arcorien == TopAbs_REVERSED) {v2.Reverse();}
+ }
+
+ comptrans.Compare(tole,v2,bidnorm,0.,LocTrans,vtxorien);
+ }
+ Destination(k) = seqlength+1;
+ }
+ }
+ }
+ }
fairpt = Standard_True;
- if (!ispassing) {
- TopAbs_State Before = comptrans.StateBefore();
- TopAbs_State After = comptrans.StateAfter();
- if ((Before == TopAbs_UNKNOWN)||(After == TopAbs_UNKNOWN)) {
- fairpt = Standard_False;
- }
- else if (Before == TopAbs_IN) {
- if (After == TopAbs_IN) {
- ispassing = Standard_True;
- }
- else {
- vectg.Reverse();
- dirtg.Reverse();
- }
- }
- else {
- if (After !=TopAbs_IN) {
- fairpt = Standard_False;
- }
- }
- }
- if (fairpt) {
- PPoint.SetDirections(vectg,dirtg);
- PPoint.SetPassing(ispassing);
- seqpdep.Append(PPoint);
- seqlength++;
- }
- else { // il faut remettre en "ordre" si on ne garde pas le point.
- for (k=i; k <=NbPoints ; k++) {
- if (Destination(k)==seqlength + 1) {
- Destination(k) = -Destination(k);
- }
- }
- }
- }
+ if (!ispassing) {
+ TopAbs_State Before = comptrans.StateBefore();
+ TopAbs_State After = comptrans.StateAfter();
+ if ((Before == TopAbs_UNKNOWN)||(After == TopAbs_UNKNOWN)) {
+ fairpt = Standard_False;
+ }
+ else if (Before == TopAbs_IN) {
+ if (After == TopAbs_IN) {
+ ispassing = Standard_True;
+ }
+ else {
+ vectg.Reverse();
+ dirtg.Reverse();
+ }
+ }
+ else {
+ if (After !=TopAbs_IN) {
+ fairpt = Standard_False;
+ }
+ }
+ }
+ if (fairpt) {
+ PPoint.SetDirections(vectg,dirtg);
+ PPoint.SetPassing(ispassing);
+ seqpdep.Append(PPoint);
+ seqlength++;
+ }
+ else { // il faut remettre en "ordre" si on ne garde pas le point.
+ for (k=i; k <=NbPoints ; k++) {
+ if (Destination(k)==seqlength + 1) {
+ Destination(k) = -Destination(k);
+ }
+ }
+ }
+ }
}
}
}
//purpose :
//=======================================================================
void Recadre(const Standard_Boolean ,
- GeomAbs_SurfaceType typeS1,
- GeomAbs_SurfaceType typeS2,
- IntPatch_Point& pt,
- const Handle(IntPatch_TheIWLineOfTheIWalking)& iwline,
- Standard_Integer Param,
- Standard_Real U1,
- Standard_Real V1,
- Standard_Real U2,
- Standard_Real V2)
+ GeomAbs_SurfaceType typeS1,
+ GeomAbs_SurfaceType typeS2,
+ IntPatch_Point& pt,
+ const Handle(IntPatch_TheIWLineOfTheIWalking)& iwline,
+ Standard_Integer Param,
+ Standard_Real U1,
+ Standard_Real V1,
+ Standard_Real U2,
+ Standard_Real V2)
{
Standard_Real U1p,V1p,U2p,V2p;
iwline->Line()->Value(Param).Parameters(U1p,V1p,U2p,V2p);
switch(typeS1)
{
- case GeomAbs_Torus:
- while(V1<(V1p-1.5*M_PI)) V1+=M_PI+M_PI;
- while(V1>(V1p+1.5*M_PI)) V1-=M_PI+M_PI;
- case GeomAbs_Cylinder:
- case GeomAbs_Cone:
- case GeomAbs_Sphere:
- while(U1<(U1p-1.5*M_PI)) U1+=M_PI+M_PI;
- while(U1>(U1p+1.5*M_PI)) U1-=M_PI+M_PI;
- default:
- break;
+ case GeomAbs_Torus:
+ while(V1<(V1p-1.5*M_PI)) V1+=M_PI+M_PI;
+ while(V1>(V1p+1.5*M_PI)) V1-=M_PI+M_PI;
+ case GeomAbs_Cylinder:
+ case GeomAbs_Cone:
+ case GeomAbs_Sphere:
+ while(U1<(U1p-1.5*M_PI)) U1+=M_PI+M_PI;
+ while(U1>(U1p+1.5*M_PI)) U1-=M_PI+M_PI;
+ default:
+ break;
}
switch(typeS2)
{
- case GeomAbs_Torus:
- while(V2<(V2p-1.5*M_PI)) V2+=M_PI+M_PI;
- while(V2>(V2p+1.5*M_PI)) V2-=M_PI+M_PI;
- case GeomAbs_Cylinder:
- case GeomAbs_Cone:
- case GeomAbs_Sphere:
- while(U2<(U2p-1.5*M_PI)) U2+=M_PI+M_PI;
- while(U2>(U2p+1.5*M_PI)) U2-=M_PI+M_PI;
- default:
- break;
+ case GeomAbs_Torus:
+ while(V2<(V2p-1.5*M_PI)) V2+=M_PI+M_PI;
+ while(V2>(V2p+1.5*M_PI)) V2-=M_PI+M_PI;
+ case GeomAbs_Cylinder:
+ case GeomAbs_Cone:
+ case GeomAbs_Sphere:
+ while(U2<(U2p-1.5*M_PI)) U2+=M_PI+M_PI;
+ while(U2>(U2p+1.5*M_PI)) U2-=M_PI+M_PI;
+ default:
+ break;
}
pt.SetParameters(U1,V1,U2,V2);
}
//purpose :
//=======================================================================
void IntPatch_ImpPrmIntersection::Perform (const Handle(Adaptor3d_HSurface)& Surf1,
- const Handle(Adaptor3d_TopolTool)& D1,
- const Handle(Adaptor3d_HSurface)& Surf2,
- const Handle(Adaptor3d_TopolTool)& D2,
- const Standard_Real TolArc,
- const Standard_Real TolTang,
- const Standard_Real Fleche,
- const Standard_Real Pas)
+ const Handle(Adaptor3d_TopolTool)& D1,
+ const Handle(Adaptor3d_HSurface)& Surf2,
+ const Handle(Adaptor3d_TopolTool)& D2,
+ const Standard_Real TolArc,
+ const Standard_Real TolTang,
+ const Standard_Real Fleche,
+ const Standard_Real Pas)
{
Standard_Boolean reversed, procf, procl, dofirst, dolast;
Standard_Integer indfirst = 0, indlast = 0, ind2, i,j,k, NbSegm;
Standard_Integer NbPointIns, NbPointRst, Nblines, Nbpts, NbPointDep;
Standard_Real U1,V1,U2,V2,paramf,paraml,currentparam;
-
+
IntPatch_TheSegmentOfTheSOnBounds thesegm;
IntSurf_PathPoint PPoint;
Handle(IntPatch_WLine) wline;
IntPatch_ThePathPointOfTheSOnBounds PStart,PStartf,PStartl;
IntPatch_Point ptdeb,ptfin,ptbis;
-
+
IntPatch_IType typ;
IntSurf_Transition TLine,TArc;
IntSurf_TypeTrans trans1,trans2;
gp_Vec tgline,tgrst,norm1,norm2,d1u,d1v;
gp_Dir DirNormale;
gp_Vec VecNormale;
-
+
gp_Pnt2d p2d;
gp_Vec2d d2d;
-
+
Handle(Adaptor2d_HCurve2d) currentarc;
GeomAbs_SurfaceType typeS1, typeS2;
IntSurf_Quadric Quad;
//
typeS1 = Surf1->GetType();
typeS2 = Surf2->GetType();
-
+
paramf =0.;
paraml =0.;
trans1 = IntSurf_Undecided;
//
reversed = Standard_False;
switch (typeS1) {
- case GeomAbs_Plane:
- Quad.SetValue(Surf1->Plane());
- break;
+ case GeomAbs_Plane:
+ Quad.SetValue(Surf1->Plane());
+ break;
- case GeomAbs_Cylinder:
- Quad.SetValue(Surf1->Cylinder());
- break;
+ case GeomAbs_Cylinder:
+ Quad.SetValue(Surf1->Cylinder());
+ break;
- case GeomAbs_Sphere:
- Quad.SetValue(Surf1->Sphere());
- break;
+ case GeomAbs_Sphere:
+ Quad.SetValue(Surf1->Sphere());
+ break;
- case GeomAbs_Cone:
- Quad.SetValue(Surf1->Cone());
- break;
+ case GeomAbs_Cone:
+ Quad.SetValue(Surf1->Cone());
+ break;
default: {
reversed = Standard_True;
switch (typeS2) {
- case GeomAbs_Plane:
- Quad.SetValue(Surf2->Plane());
- break;
-
- case GeomAbs_Cylinder:
- Quad.SetValue(Surf2->Cylinder());
- break;
-
- case GeomAbs_Sphere:
- Quad.SetValue(Surf2->Sphere());
- break;
-
- case GeomAbs_Cone:
- Quad.SetValue(Surf2->Cone());
- break;
+ case GeomAbs_Plane:
+ Quad.SetValue(Surf2->Plane());
+ break;
+
+ case GeomAbs_Cylinder:
+ Quad.SetValue(Surf2->Cylinder());
+ break;
+
+ case GeomAbs_Sphere:
+ Quad.SetValue(Surf2->Sphere());
+ break;
+
+ case GeomAbs_Cone:
+ Quad.SetValue(Surf2->Cone());
+ break;
default: {
- Standard_ConstructionError::Raise();
- break;
- }
+ Standard_ConstructionError::Raise();
+ break;
+ }
}
}
break;
}
//
// Recherche des points interieurs
- if (!reversed) {
- if (myIsStartPnt)
- solins.Perform(Func,Surf2,myUStart,myVStart);
- else
- solins.Perform(Func,Surf2,D2,TolTang);
- }
- else {
- if (myIsStartPnt)
- solins.Perform(Func,Surf1,myUStart,myVStart);
- else
- solins.Perform(Func,Surf1,D1,TolTang);
- }
+ if (!reversed) {
+ if (myIsStartPnt)
+ solins.Perform(Func,Surf2,myUStart,myVStart);
+ else
+ solins.Perform(Func,Surf2,D2,TolTang);
+ }
+ else {
+ if (myIsStartPnt)
+ solins.Perform(Func,Surf1,myUStart,myVStart);
+ else
+ solins.Perform(Func,Surf1,D1,TolTang);
+ }
//
- NbPointIns = solins.NbPoints();
- for (i=1; i <= NbPointIns; i++) {
- seqpins.Append(solins.Value(i));
- }
+ NbPointIns = solins.NbPoints();
+ for (i=1; i <= NbPointIns; i++) {
+ seqpins.Append(solins.Value(i));
+ }
NbPointDep=seqpdep.Length();
//
if (NbPointDep || NbPointIns) {
if(!iwalk.IsDone()) {
return;
}
-
+
Standard_Real Vmin, Vmax, TolV = 1.e-14;
if (!reversed) { //Surf1 is quadric
Vmin = Surf1->FirstVParameter();
for (j=1; j<=Nblines; j++) {
const Handle(IntPatch_TheIWLineOfTheIWalking)& iwline = iwalk.Value(j);
const Handle(IntSurf_LineOn2S)& thelin = iwline->Line();
-
+
Nbpts = thelin->NbPoints();
if(Nbpts>=2) {
-
- tgline = iwline->TangentVector(k);
- if(k>=1 && k<=Nbpts) { } else { k=Nbpts>>1; }
- valpt = thelin->Value(k).Value();
-
- if (!reversed) {
- thelin->Value(k).ParametersOnS2(U2,V2);
- norm1 = Quad.Normale(valpt);
- Surf2->D1(U2,V2,ptbid,d1u,d1v);
- norm2 = d1u.Crossed(d1v);
- }
- else {
- thelin->Value(k).ParametersOnS1(U2,V2);
- norm2 = Quad.Normale(valpt);
- Surf1->D1(U2,V2,ptbid,d1u,d1v);
- norm1 = d1u.Crossed(d1v);
- }
- if (tgline.DotCross(norm2,norm1) > 0.) {
- trans1 = IntSurf_Out;
- trans2 = IntSurf_In;
- }
- else {
- trans1 = IntSurf_In;
- trans2 = IntSurf_Out;
- }
-
- //
- Standard_Real AnU1,AnU2,AnV2;
-
- GeomAbs_SurfaceType typQuad = Quad.TypeQuadric();
- Standard_Boolean arecadr=Standard_False;
- valpt = thelin->Value(1).Value();
- Quad.Parameters(valpt,AnU1,V1);
-
- if((V1 < Vmin) && (Vmin-V1 < TolV)) V1 = Vmin;
- if((V1 > Vmax) && (V1-Vmax < TolV)) V1 = Vmax;
-
- if(reversed) {
- thelin->SetUV(1,Standard_False,AnU1,V1); //-- on va lire u2,v2
- thelin->Value(1).ParametersOnS1(AnU2,AnV2);
- }
- else {
- thelin->SetUV(1,Standard_True,AnU1,V1); //-- on va lire u1,v1
- thelin->Value(1).ParametersOnS2(AnU2,AnV2);
- }
-
- if(typQuad==GeomAbs_Cylinder ||
- typQuad==GeomAbs_Cone ||
- typQuad==GeomAbs_Sphere) {
- arecadr=Standard_True;
- }
- //
- for (k=2; k<=Nbpts; ++k) {
- valpt = thelin->Value(k).Value();
- Quad.Parameters(valpt,U1,V1);
- //
- if((V1 < Vmin) && (Vmin-V1 < TolV)) {
- V1 = Vmin;
- }
- if((V1 > Vmax) && (V1-Vmax < TolV)) {
- V1 = Vmax;
- }
- //
- if(arecadr) {
- //modified by NIZNHY-PKV Fri Mar 28 15:06:01 2008f
- Standard_Real aCf, aTwoPI;
- //
- aCf=0.;
- aTwoPI=M_PI+M_PI;
- if ((U1-AnU1) > 1.5*M_PI) {
- while ((U1-AnU1) > (1.5*M_PI+aCf*aTwoPI)) {
- aCf=aCf+1.;
- }
- U1=U1-aCf*aTwoPI;
- }
- //
- else {
- while ((U1-AnU1) < (-1.5*M_PI-aCf*aTwoPI)) {
- aCf=aCf+1.;
- }
- U1=U1+aCf*aTwoPI;
- }
- // was:
- //if ((U1-AnU1) > 1.5*M_PI) {
- // U1-=M_PI+M_PI;
- //}
- //else if ((U1-AnU1) < -1.5*M_PI) {
- // U1+=M_PI+M_PI;
- //}
- //modified by NIZNHY-PKV Fri Mar 28 15:06:11 2008t
- }
- //
- if(reversed) {
- thelin->SetUV(k,Standard_False,U1,V1);
-
- thelin->Value(k).ParametersOnS1(U2,V2);
- switch(typeS1) {
- case GeomAbs_Cylinder:
- case GeomAbs_Cone:
- case GeomAbs_Sphere:
- case GeomAbs_Torus:
- while(U2<(AnU2-1.5*M_PI)) U2+=M_PI+M_PI;
- while(U2>(AnU2+1.5*M_PI)) U2-=M_PI+M_PI;
- break;
- default:
- break;
- }
- if(typeS2==GeomAbs_Torus) {
- while(V2<(AnV2-1.5*M_PI)) V2+=M_PI+M_PI;
- while(V2>(AnV2+1.5*M_PI)) V2-=M_PI+M_PI;
- }
- thelin->SetUV(k,Standard_True,U2,V2);
- }
- else {
- thelin->SetUV(k,Standard_True,U1,V1);
-
- thelin->Value(k).ParametersOnS2(U2,V2);
- switch(typeS2) {
- case GeomAbs_Cylinder:
- case GeomAbs_Cone:
- case GeomAbs_Sphere:
- case GeomAbs_Torus:
- while(U2<(AnU2-1.5*M_PI)) U2+=M_PI+M_PI;
- while(U2>(AnU2+1.5*M_PI)) U2-=M_PI+M_PI;
- break;
- default:
- break;
- }
- if(typeS2==GeomAbs_Torus) {
- while(V2<(AnV2-1.5*M_PI)) V2+=M_PI+M_PI;
- while(V2>(AnV2+1.5*M_PI)) V2-=M_PI+M_PI;
- }
- thelin->SetUV(k,Standard_False,U2,V2);
-
- }
-
- AnU1=U1;
- AnU2=U2;
- AnV2=V2;
- }
- // <-A
- wline = new IntPatch_WLine(thelin,Standard_False,trans1,trans2);
-
- if ( iwline->HasFirstPoint()
+
+ tgline = iwline->TangentVector(k);
+ if(k>=1 && k<=Nbpts) { } else { k=Nbpts>>1; }
+ valpt = thelin->Value(k).Value();
+
+ if (!reversed) {
+ thelin->Value(k).ParametersOnS2(U2,V2);
+ norm1 = Quad.Normale(valpt);
+ Surf2->D1(U2,V2,ptbid,d1u,d1v);
+ norm2 = d1u.Crossed(d1v);
+ }
+ else {
+ thelin->Value(k).ParametersOnS1(U2,V2);
+ norm2 = Quad.Normale(valpt);
+ Surf1->D1(U2,V2,ptbid,d1u,d1v);
+ norm1 = d1u.Crossed(d1v);
+ }
+ if (tgline.DotCross(norm2,norm1) > 0.) {
+ trans1 = IntSurf_Out;
+ trans2 = IntSurf_In;
+ }
+ else {
+ trans1 = IntSurf_In;
+ trans2 = IntSurf_Out;
+ }
+
+ //
+ Standard_Real AnU1,AnU2,AnV2;
+
+ GeomAbs_SurfaceType typQuad = Quad.TypeQuadric();
+ Standard_Boolean arecadr=Standard_False;
+ valpt = thelin->Value(1).Value();
+ Quad.Parameters(valpt,AnU1,V1);
+
+ if((V1 < Vmin) && (Vmin-V1 < TolV)) V1 = Vmin;
+ if((V1 > Vmax) && (V1-Vmax < TolV)) V1 = Vmax;
+
+ if(reversed) {
+ thelin->SetUV(1,Standard_False,AnU1,V1); //-- on va lire u2,v2
+ thelin->Value(1).ParametersOnS1(AnU2,AnV2);
+ }
+ else {
+ thelin->SetUV(1,Standard_True,AnU1,V1); //-- on va lire u1,v1
+ thelin->Value(1).ParametersOnS2(AnU2,AnV2);
+ }
+
+ if(typQuad==GeomAbs_Cylinder ||
+ typQuad==GeomAbs_Cone ||
+ typQuad==GeomAbs_Sphere) {
+ arecadr=Standard_True;
+ }
+ //
+ for (k=2; k<=Nbpts; ++k) {
+ valpt = thelin->Value(k).Value();
+ Quad.Parameters(valpt,U1,V1);
+ //
+ if((V1 < Vmin) && (Vmin-V1 < TolV)) {
+ V1 = Vmin;
+ }
+ if((V1 > Vmax) && (V1-Vmax < TolV)) {
+ V1 = Vmax;
+ }
+ //
+ if(arecadr) {
+ //modified by NIZNHY-PKV Fri Mar 28 15:06:01 2008f
+ Standard_Real aCf, aTwoPI;
+ //
+ aCf=0.;
+ aTwoPI=M_PI+M_PI;
+ if ((U1-AnU1) > 1.5*M_PI) {
+ while ((U1-AnU1) > (1.5*M_PI+aCf*aTwoPI)) {
+ aCf=aCf+1.;
+ }
+ U1=U1-aCf*aTwoPI;
+ }
+ //
+ else {
+ while ((U1-AnU1) < (-1.5*M_PI-aCf*aTwoPI)) {
+ aCf=aCf+1.;
+ }
+ U1=U1+aCf*aTwoPI;
+ }
+ // was:
+ //if ((U1-AnU1) > 1.5*M_PI) {
+ // U1-=M_PI+M_PI;
+ //}
+ //else if ((U1-AnU1) < -1.5*M_PI) {
+ // U1+=M_PI+M_PI;
+ //}
+ //modified by NIZNHY-PKV Fri Mar 28 15:06:11 2008t
+ }
+ //
+ if(reversed) {
+ thelin->SetUV(k,Standard_False,U1,V1);
+
+ thelin->Value(k).ParametersOnS1(U2,V2);
+ switch(typeS1) {
+ case GeomAbs_Cylinder:
+ case GeomAbs_Cone:
+ case GeomAbs_Sphere:
+ case GeomAbs_Torus:
+ while(U2<(AnU2-1.5*M_PI)) U2+=M_PI+M_PI;
+ while(U2>(AnU2+1.5*M_PI)) U2-=M_PI+M_PI;
+ break;
+ default:
+ break;
+ }
+ if(typeS2==GeomAbs_Torus) {
+ while(V2<(AnV2-1.5*M_PI)) V2+=M_PI+M_PI;
+ while(V2>(AnV2+1.5*M_PI)) V2-=M_PI+M_PI;
+ }
+ thelin->SetUV(k,Standard_True,U2,V2);
+ }
+ else {
+ thelin->SetUV(k,Standard_True,U1,V1);
+
+ thelin->Value(k).ParametersOnS2(U2,V2);
+ switch(typeS2) {
+ case GeomAbs_Cylinder:
+ case GeomAbs_Cone:
+ case GeomAbs_Sphere:
+ case GeomAbs_Torus:
+ while(U2<(AnU2-1.5*M_PI)) U2+=M_PI+M_PI;
+ while(U2>(AnU2+1.5*M_PI)) U2-=M_PI+M_PI;
+ break;
+ default:
+ break;
+ }
+ if(typeS2==GeomAbs_Torus) {
+ while(V2<(AnV2-1.5*M_PI)) V2+=M_PI+M_PI;
+ while(V2>(AnV2+1.5*M_PI)) V2-=M_PI+M_PI;
+ }
+ thelin->SetUV(k,Standard_False,U2,V2);
+
+ }
+
+ AnU1=U1;
+ AnU2=U2;
+ AnV2=V2;
+ }
+ // <-A
+ wline = new IntPatch_WLine(thelin,Standard_False,trans1,trans2);
+
+ if ( iwline->HasFirstPoint()
&& iwline->IsTangentAtBegining() == Standard_False) {
- indfirst = iwline->FirstPointIndex();
- PPoint = seqpdep(indfirst);
- tgline = PPoint.Direction3d();
- Standard_Integer themult = PPoint.Multiplicity();
- for (i=NbPointRst; i>=1; i--) {
- if (Destination(i) == indfirst) {
- if (!reversed) { //-- typeS1 = Pln || Cyl || Sph || Cone
- Quad.Parameters(PPoint.Value(),U1,V1);
-
- if((V1 < Vmin) && (Vmin-V1 < TolV)) V1 = Vmin;
- if((V1 > Vmax) && (V1-Vmax < TolV)) V1 = Vmax;
-
- PPoint.Parameters(themult,U2,V2);
- Surf2->D1(U2,V2,ptbid,d1u,d1v); //-- @@@@
- }
- else { //-- typeS1 != Pln && Cyl && Sph && Cone
- Quad.Parameters(PPoint.Value(),U2,V2);
-
- if((V2 < Vmin) && (Vmin-V2 < TolV)) V2 = Vmin;
- if((V2 > Vmax) && (V2-Vmax < TolV)) V2 = Vmax;
-
- PPoint.Parameters(themult,U1,V1);
- Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@
- }
-
- VecNormale = d1u.Crossed(d1v);
- //-- Modif du 27 Septembre 94 (Recadrage des pts U,V)
- ptdeb.SetValue(PPoint.Value(),TolArc,Standard_False);
- ptdeb.SetParameters(U1,V1,U2,V2);
- ptdeb.SetParameter(1.);
-
- Recadre(reversed,typeS1,typeS2,ptdeb,iwline,1,U1,V1,U2,V2);
-
- currentarc = solrst.Point(i).Arc();
- currentparam = solrst.Point(i).Parameter();
- currentarc->D1(currentparam,p2d,d2d);
- tgrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
-
- Standard_Real squaremagnitudeVecNormale = VecNormale.SquareMagnitude();
- if(squaremagnitudeVecNormale > 1e-13) {
- DirNormale=VecNormale;
- IntSurf::MakeTransition(tgline,tgrst,DirNormale,TLine,TArc);
- }
- else {
- TLine.SetValue(Standard_True,IntSurf_Undecided);
- TArc.SetValue(Standard_True,IntSurf_Undecided);
- }
-
- ptdeb.SetArc(reversed,currentarc,currentparam,TLine,TArc);
- if (!solrst.Point(i).IsNew()) {
- ptdeb.SetVertex(reversed,solrst.Point(i).Vertex());
- }
- wline->AddVertex(ptdeb);
- if (themult == 0) {
- wline->SetFirstPoint(wline->NbVertex());
- }
-
- themult--;
- }
- }
- }
+ indfirst = iwline->FirstPointIndex();
+ PPoint = seqpdep(indfirst);
+ tgline = PPoint.Direction3d();
+ Standard_Integer themult = PPoint.Multiplicity();
+ for (i=NbPointRst; i>=1; i--) {
+ if (Destination(i) == indfirst) {
+ if (!reversed) { //-- typeS1 = Pln || Cyl || Sph || Cone
+ Quad.Parameters(PPoint.Value(),U1,V1);
+
+ if((V1 < Vmin) && (Vmin-V1 < TolV)) V1 = Vmin;
+ if((V1 > Vmax) && (V1-Vmax < TolV)) V1 = Vmax;
+
+ PPoint.Parameters(themult,U2,V2);
+ Surf2->D1(U2,V2,ptbid,d1u,d1v); //-- @@@@
+ }
+ else { //-- typeS1 != Pln && Cyl && Sph && Cone
+ Quad.Parameters(PPoint.Value(),U2,V2);
+
+ if((V2 < Vmin) && (Vmin-V2 < TolV)) V2 = Vmin;
+ if((V2 > Vmax) && (V2-Vmax < TolV)) V2 = Vmax;
+
+ PPoint.Parameters(themult,U1,V1);
+ Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@
+ }
+
+ VecNormale = d1u.Crossed(d1v);
+ //-- Modif du 27 Septembre 94 (Recadrage des pts U,V)
+ ptdeb.SetValue(PPoint.Value(),TolArc,Standard_False);
+ ptdeb.SetParameters(U1,V1,U2,V2);
+ ptdeb.SetParameter(1.);
+
+ Recadre(reversed,typeS1,typeS2,ptdeb,iwline,1,U1,V1,U2,V2);
+
+ currentarc = solrst.Point(i).Arc();
+ currentparam = solrst.Point(i).Parameter();
+ currentarc->D1(currentparam,p2d,d2d);
+ tgrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+
+ Standard_Real squaremagnitudeVecNormale = VecNormale.SquareMagnitude();
+ if(squaremagnitudeVecNormale > 1e-13) {
+ DirNormale=VecNormale;
+ IntSurf::MakeTransition(tgline,tgrst,DirNormale,TLine,TArc);
+ }
+ else {
+ TLine.SetValue(Standard_True,IntSurf_Undecided);
+ TArc.SetValue(Standard_True,IntSurf_Undecided);
+ }
+
+ ptdeb.SetArc(reversed,currentarc,currentparam,TLine,TArc);
+ if (!solrst.Point(i).IsNew()) {
+ ptdeb.SetVertex(reversed,solrst.Point(i).Vertex());
+ }
+ wline->AddVertex(ptdeb);
+ if (themult == 0) {
+ wline->SetFirstPoint(wline->NbVertex());
+ }
+
+ themult--;
+ }
+ }
+ }
else if (iwline->IsTangentAtBegining()) {
- gp_Pnt psol = thelin->Value(1).Value();
- thelin->Value(1).ParametersOnS1(U1,V1);
- thelin->Value(1).ParametersOnS2(U2,V2);
- ptdeb.SetValue(psol,TolArc,Standard_True);
- ptdeb.SetParameters(U1,V1,U2,V2);
- ptdeb.SetParameter(1.);
- wline->AddVertex(ptdeb);
- wline->SetFirstPoint(wline->NbVertex());
- }
+ gp_Pnt psol = thelin->Value(1).Value();
+ thelin->Value(1).ParametersOnS1(U1,V1);
+ thelin->Value(1).ParametersOnS2(U2,V2);
+ ptdeb.SetValue(psol,TolArc,Standard_True);
+ ptdeb.SetParameters(U1,V1,U2,V2);
+ ptdeb.SetParameter(1.);
+ wline->AddVertex(ptdeb);
+ wline->SetFirstPoint(wline->NbVertex());
+ }
else {
- gp_Pnt psol = thelin->Value(1).Value();
- thelin->Value(1).ParametersOnS1(U1,V1);
- thelin->Value(1).ParametersOnS2(U2,V2);
- ptdeb.SetValue(psol,TolArc,Standard_False);
- ptdeb.SetParameters(U1,V1,U2,V2);
- ptdeb.SetParameter(1.);
- wline->AddVertex(ptdeb);
- wline->SetFirstPoint(wline->NbVertex());
- }
-
-
- if ( iwline->HasLastPoint()
+ gp_Pnt psol = thelin->Value(1).Value();
+ thelin->Value(1).ParametersOnS1(U1,V1);
+ thelin->Value(1).ParametersOnS2(U2,V2);
+ ptdeb.SetValue(psol,TolArc,Standard_False);
+ ptdeb.SetParameters(U1,V1,U2,V2);
+ ptdeb.SetParameter(1.);
+ wline->AddVertex(ptdeb);
+ wline->SetFirstPoint(wline->NbVertex());
+ }
+
+
+ if ( iwline->HasLastPoint()
&& iwline->IsTangentAtEnd() == Standard_False) {
- indlast = iwline->LastPointIndex();
- PPoint = seqpdep(indlast);
- tgline = PPoint.Direction3d().Reversed();
- Standard_Integer themult = PPoint.Multiplicity();
- for (i=NbPointRst; i >=1; i--) {
- if (Destination(i) == indlast) {
- if (!reversed) {
- Quad.Parameters(PPoint.Value(),U1,V1);
-
- if((V1 < Vmin) && (Vmin-V1 < TolV)) V1 = Vmin;
- if((V1 > Vmax) && (V1-Vmax < TolV)) V1 = Vmax;
-
- PPoint.Parameters(themult,U2,V2);
- Surf2->D1(U2,V2,ptbid,d1u,d1v); //-- @@@@
- VecNormale = d1u.Crossed(d1v); //-- @@@@
- }
- else {
- Quad.Parameters(PPoint.Value(),U2,V2);
-
- if((V2 < Vmin) && (Vmin-V2 < TolV)) V2 = Vmin;
- if((V2 > Vmax) && (V2-Vmax < TolV)) V2 = Vmax;
-
- PPoint.Parameters(themult,U1,V1);
- Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@
- VecNormale = d1u.Crossed(d1v); //-- @@@@
- }
-
- ptfin.SetValue(PPoint.Value(),TolArc,Standard_False);
- ptfin.SetParameters(U1,V1,U2,V2);
- ptfin.SetParameter(Nbpts);
-
- Recadre(reversed,typeS1,typeS2,ptfin,iwline,Nbpts-1,U1,V1,U2,V2);
-
- currentarc = solrst.Point(i).Arc();
- currentparam = solrst.Point(i).Parameter();
- currentarc->D1(currentparam,p2d,d2d);
- tgrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
-
-
- Standard_Real squaremagnitudeVecNormale = VecNormale.SquareMagnitude();
- if(squaremagnitudeVecNormale > 1e-13) {
- DirNormale=VecNormale;
- IntSurf::MakeTransition(tgline,tgrst,DirNormale,TLine,TArc);
- }
- else {
- TLine.SetValue(Standard_True,IntSurf_Undecided);
- TArc.SetValue(Standard_True,IntSurf_Undecided);
- }
-
-
- ptfin.SetArc(reversed,currentarc,currentparam,TLine,TArc);
- if (!solrst.Point(i).IsNew()) {
- ptfin.SetVertex(reversed,solrst.Point(i).Vertex());
- }
- wline->AddVertex(ptfin);
- if (themult == 0) {
- wline->SetLastPoint(wline->NbVertex());
- }
-
- themult--;
- }
- }
- }
+ indlast = iwline->LastPointIndex();
+ PPoint = seqpdep(indlast);
+ tgline = PPoint.Direction3d().Reversed();
+ Standard_Integer themult = PPoint.Multiplicity();
+ for (i=NbPointRst; i >=1; i--) {
+ if (Destination(i) == indlast) {
+ if (!reversed) {
+ Quad.Parameters(PPoint.Value(),U1,V1);
+
+ if((V1 < Vmin) && (Vmin-V1 < TolV)) V1 = Vmin;
+ if((V1 > Vmax) && (V1-Vmax < TolV)) V1 = Vmax;
+
+ PPoint.Parameters(themult,U2,V2);
+ Surf2->D1(U2,V2,ptbid,d1u,d1v); //-- @@@@
+ VecNormale = d1u.Crossed(d1v); //-- @@@@
+ }
+ else {
+ Quad.Parameters(PPoint.Value(),U2,V2);
+
+ if((V2 < Vmin) && (Vmin-V2 < TolV)) V2 = Vmin;
+ if((V2 > Vmax) && (V2-Vmax < TolV)) V2 = Vmax;
+
+ PPoint.Parameters(themult,U1,V1);
+ Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@
+ VecNormale = d1u.Crossed(d1v); //-- @@@@
+ }
+
+ ptfin.SetValue(PPoint.Value(),TolArc,Standard_False);
+ ptfin.SetParameters(U1,V1,U2,V2);
+ ptfin.SetParameter(Nbpts);
+
+ Recadre(reversed,typeS1,typeS2,ptfin,iwline,Nbpts-1,U1,V1,U2,V2);
+
+ currentarc = solrst.Point(i).Arc();
+ currentparam = solrst.Point(i).Parameter();
+ currentarc->D1(currentparam,p2d,d2d);
+ tgrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+
+
+ Standard_Real squaremagnitudeVecNormale = VecNormale.SquareMagnitude();
+ if(squaremagnitudeVecNormale > 1e-13) {
+ DirNormale=VecNormale;
+ IntSurf::MakeTransition(tgline,tgrst,DirNormale,TLine,TArc);
+ }
+ else {
+ TLine.SetValue(Standard_True,IntSurf_Undecided);
+ TArc.SetValue(Standard_True,IntSurf_Undecided);
+ }
+
+
+ ptfin.SetArc(reversed,currentarc,currentparam,TLine,TArc);
+ if (!solrst.Point(i).IsNew()) {
+ ptfin.SetVertex(reversed,solrst.Point(i).Vertex());
+ }
+ wline->AddVertex(ptfin);
+ if (themult == 0) {
+ wline->SetLastPoint(wline->NbVertex());
+ }
+
+ themult--;
+ }
+ }
+ }
else if (iwline->IsTangentAtEnd()) {
- gp_Pnt psol = thelin->Value(Nbpts).Value();
- thelin->Value(Nbpts).ParametersOnS1(U1,V1);
- thelin->Value(Nbpts).ParametersOnS2(U2,V2);
- ptfin.SetValue(psol,TolArc,Standard_True);
- ptfin.SetParameters(U1,V1,U2,V2);
- ptfin.SetParameter(Nbpts);
- wline->AddVertex(ptfin);
- wline->SetLastPoint(wline->NbVertex());
- }
+ gp_Pnt psol = thelin->Value(Nbpts).Value();
+ thelin->Value(Nbpts).ParametersOnS1(U1,V1);
+ thelin->Value(Nbpts).ParametersOnS2(U2,V2);
+ ptfin.SetValue(psol,TolArc,Standard_True);
+ ptfin.SetParameters(U1,V1,U2,V2);
+ ptfin.SetParameter(Nbpts);
+ wline->AddVertex(ptfin);
+ wline->SetLastPoint(wline->NbVertex());
+ }
else {
- gp_Pnt psol = thelin->Value(Nbpts).Value();
- thelin->Value(Nbpts).ParametersOnS1(U1,V1);
- thelin->Value(Nbpts).ParametersOnS2(U2,V2);
- ptfin.SetValue(psol,TolArc,Standard_False);
- ptfin.SetParameters(U1,V1,U2,V2);
- ptfin.SetParameter(Nbpts);
- wline->AddVertex(ptfin);
- wline->SetLastPoint(wline->NbVertex());
- }
- //
- // Il faut traiter les points de passage.
- slin.Append(wline);
+ gp_Pnt psol = thelin->Value(Nbpts).Value();
+ thelin->Value(Nbpts).ParametersOnS1(U1,V1);
+ thelin->Value(Nbpts).ParametersOnS2(U2,V2);
+ ptfin.SetValue(psol,TolArc,Standard_False);
+ ptfin.SetParameters(U1,V1,U2,V2);
+ ptfin.SetParameter(Nbpts);
+ wline->AddVertex(ptfin);
+ wline->SetLastPoint(wline->NbVertex());
+ }
+
+ if(wline->NbPnts() < 40)
+ {
+ Standard_Boolean hasBeenAdded = iwalk.SeekAdditionalPoints(Surf1, Surf2, 40, j);
+
+ if (!reversed)
+ IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang, hasBeenAdded);
+ else
+ IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang, hasBeenAdded);
+
+ if(hasBeenAdded)
+ {
+ const Standard_Real aTol = Precision::Confusion()*Precision::Confusion();
+ Standard_Real aDecrParam = 0.0;
+ Standard_Integer aNbVert = wline->NbVertex();
+ for (Standard_Integer aV = 2; aV <= aNbVert; aV++)
+ {
+ IntPatch_Point aVert = wline->Vertex(aV);
+
+ const gp_Pnt aP(aVert.Value()), aP1(wline->Vertex(aV-1).Value());
+
+ if(aV == aNbVert)
+ {
+ if(aP.SquareDistance(aP1) <= aTol)
+ {
+ wline->RemoveVertex(aV-1);
+ }
+
+ break;
+ }
+ else
+ {
+ aVert.SetParameter(aVert.ParameterOnLine() - aDecrParam);
+ wline->RemoveVertex(aV);
+ wline->InsertVertexBefore(aV, aVert);
+ }
+
+ const gp_Pnt aP2(wline->Vertex(aV+1).Value());
+
+ if(aP.SquareDistance(aP1) <= aTol)
+ {
+ wline->RemoveVertex(aV);
+ }
+ else if(aP.SquareDistance(aP2) <= aTol)
+ {
+ wline->RemoveVertex(aV);
+
+ aDecrParam++;
+ aV--;
+ aNbVert = wline->NbVertex();
+ }
+
+ aNbVert = wline->NbVertex();
+ }
+ }
+
+ if (wline->HasLastPoint())
+ {
+ wline->SetLastPoint(wline->NbVertex());
+ wline->LastPoint(indlast);
+ }
+ }
+ else
+ {
+ if (!reversed)
+ IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
+ else
+ IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
+ }
+
+ //
+ // Il faut traiter les points de passage.
+ slin.Append(wline);
}// if(Nbpts>=2) {
}// for (j=1; j<=Nblines; j++) {
const Handle(IntPatch_Line)& slinj = slin(j);
const Handle(IntPatch_WLine)& wlin1 = *((Handle(IntPatch_WLine)*)&slinj);
if (wlin1->HasFirstPoint()) {
- ptdeb = wlin1->FirstPoint(indfirst);
- if (ptdeb.IsTangencyPoint()) {
- dofirst = Standard_True;
- }
+ ptdeb = wlin1->FirstPoint(indfirst);
+ if (ptdeb.IsTangencyPoint()) {
+ dofirst = Standard_True;
+ }
}
if (wlin1->HasLastPoint()) {
- ptfin = wlin1->LastPoint(indlast);
- if (ptfin.IsTangencyPoint()) {
- dolast = Standard_True;
- }
+ ptfin = wlin1->LastPoint(indlast);
+ if (ptfin.IsTangencyPoint()) {
+ dolast = Standard_True;
+ }
}
-
+
if (dofirst || dolast) {
- for (k=j+1; k<=Nblines;k++) {
- const Handle(IntPatch_Line)& slink = slin(k);
- const Handle(IntPatch_WLine)& wlin2 = *((Handle(IntPatch_WLine)*)&slink);
- if (wlin2->HasFirstPoint()) {
- ptbis = wlin2->FirstPoint(ind2);
- if (ptbis.IsTangencyPoint()) {
- if (dofirst ) {
- if (ptdeb.Value().Distance(ptbis.Value()) <= TolArc) {
- ptdeb.SetMultiple(Standard_True);
- if (!ptbis.IsMultiple()) {
- ptbis.SetMultiple(Standard_True);
- wlin2->Replace(ind2,ptbis);
- }
- }
- }
- if (dolast ) {
- if (ptfin.Value().Distance(ptbis.Value()) <= TolArc) {
- ptfin.SetMultiple(Standard_True);
- if (!ptbis.IsMultiple()) {
- ptbis.SetMultiple(Standard_True);
- wlin2->Replace(ind2,ptbis);
- }
- }
- }
- }
- }
- if (wlin2->HasLastPoint()) {
- ptbis = wlin2->LastPoint(ind2);
- if (ptbis.IsTangencyPoint()) {
- if (dofirst ) {
- if (ptdeb.Value().Distance(ptbis.Value()) <= TolArc) {
- ptdeb.SetMultiple(Standard_True);
- if (!ptbis.IsMultiple()) {
- ptbis.SetMultiple(Standard_True);
- wlin2->Replace(ind2,ptbis);
- }
- }
- }
- if (dolast ) {
- if (ptfin.Value().Distance(ptbis.Value()) <= TolArc) {
- ptfin.SetMultiple(Standard_True);
- if (!ptbis.IsMultiple()) {
- ptbis.SetMultiple(Standard_True);
- wlin2->Replace(ind2,ptbis);
- }
- }
- }
- }
- }
- }
- if(dofirst)
- wlin1->Replace(indfirst,ptdeb);
- if(dolast)
- wlin1->Replace(indlast,ptfin);
+ for (k=j+1; k<=Nblines;k++) {
+ const Handle(IntPatch_Line)& slink = slin(k);
+ const Handle(IntPatch_WLine)& wlin2 = *((Handle(IntPatch_WLine)*)&slink);
+ if (wlin2->HasFirstPoint()) {
+ ptbis = wlin2->FirstPoint(ind2);
+ if (ptbis.IsTangencyPoint()) {
+ if (dofirst ) {
+ if (ptdeb.Value().Distance(ptbis.Value()) <= TolArc) {
+ ptdeb.SetMultiple(Standard_True);
+ if (!ptbis.IsMultiple()) {
+ ptbis.SetMultiple(Standard_True);
+ wlin2->Replace(ind2,ptbis);
+ }
+ }
+ }
+ if (dolast ) {
+ if (ptfin.Value().Distance(ptbis.Value()) <= TolArc) {
+ ptfin.SetMultiple(Standard_True);
+ if (!ptbis.IsMultiple()) {
+ ptbis.SetMultiple(Standard_True);
+ wlin2->Replace(ind2,ptbis);
+ }
+ }
+ }
+ }
+ }
+ if (wlin2->HasLastPoint()) {
+ ptbis = wlin2->LastPoint(ind2);
+ if (ptbis.IsTangencyPoint()) {
+ if (dofirst ) {
+ if (ptdeb.Value().Distance(ptbis.Value()) <= TolArc) {
+ ptdeb.SetMultiple(Standard_True);
+ if (!ptbis.IsMultiple()) {
+ ptbis.SetMultiple(Standard_True);
+ wlin2->Replace(ind2,ptbis);
+ }
+ }
+ }
+ if (dolast ) {
+ if (ptfin.Value().Distance(ptbis.Value()) <= TolArc) {
+ ptfin.SetMultiple(Standard_True);
+ if (!ptbis.IsMultiple()) {
+ ptbis.SetMultiple(Standard_True);
+ wlin2->Replace(ind2,ptbis);
+ }
+ }
+ }
+ }
+ }
+ }
+ if(dofirst)
+ wlin1->Replace(indfirst,ptdeb);
+ if(dolast)
+ wlin1->Replace(indlast,ptfin);
}
}
}// if (seqpdep.Length() != 0 || seqpins.Length() != 0) {
IntPatch_Point _thepointAtBeg;
IntPatch_Point _thepointAtEnd;
-
+
Standard_Boolean TransitionOK=Standard_False;
if(thesegm.HasFirstPoint()) {
- Standard_Real _u1,_v1,_u2,_v2;
-
- dofirst = Standard_True;
- PStartf = thesegm.FirstPoint();
- paramf = PStartf.Parameter();
-
- gp_Pnt2d _p2d = thesegm.Curve()->Value(paramf);
- Handle(Adaptor3d_HVertex) _vtx;
- if(PStartf.IsNew()==Standard_False)
- _vtx= PStartf.Vertex();
- const gp_Pnt& _Pp = PStartf.Value();
- _thepointAtBeg.SetValue(_Pp,PStartf.Tolerance(),Standard_False);
- if (!reversed) { //-- typeS1 = Pln || Cyl || Sph || Cone
- Quad.Parameters(_Pp,_u1,_v1);
- _u2=_p2d.X(); _v2=_p2d.Y();
- }
- else { //-- typeS1 != Pln && Cyl && Sph && Cone
- Quad.Parameters(_Pp,_u2,_v2);
- _u1=_p2d.X(); _v1=_p2d.Y();
- }
- _thepointAtBeg.SetParameters(_u1,_v1,_u2,_v2);
- _thepointAtBeg.SetParameter(paramf);
- if(PStartf.IsNew()==Standard_False)
- _thepointAtBeg.SetVertex(reversed,_vtx);
- _thepointAtBeg.SetArc(reversed,thesegm.Curve(),paramf,TLineUnk,TArcUnk);
-
-
- gp_Vec d1u1,d1v1,d1u2,d1v2; gp_Vec2d _d2d;
- Surf1->D1(_u1,_v1,ptbid,d1u1,d1v1);
- norm1 = d1u1.Crossed(d1v1);
- Surf2->D1(_u2,_v2,ptbid,d1u2,d1v2);
- norm2 = d1u2.Crossed(d1v2);
-
- thesegm.Curve()->D1(paramf,_p2d,_d2d);
- if(reversed) {
- tgline.SetLinearForm(_d2d.X(),d1u1,_d2d.Y(),d1v1);
- }
- else {
- tgline.SetLinearForm(_d2d.X(),d1u2,_d2d.Y(),d1v2);
- }
- _u1=tgline.DotCross(norm2,norm1);
- TransitionOK=Standard_True;
- if (_u1 > 0.00000001) {
- trans1 = IntSurf_Out;
- trans2 = IntSurf_In;
- }
- else if(_u1 < -0.00000001) {
- trans1 = IntSurf_In;
- trans2 = IntSurf_Out;
- }
- else {
- TransitionOK=Standard_False;
- }
+ Standard_Real _u1,_v1,_u2,_v2;
+
+ dofirst = Standard_True;
+ PStartf = thesegm.FirstPoint();
+ paramf = PStartf.Parameter();
+
+ gp_Pnt2d _p2d = thesegm.Curve()->Value(paramf);
+ Handle(Adaptor3d_HVertex) _vtx;
+ if(PStartf.IsNew()==Standard_False)
+ _vtx= PStartf.Vertex();
+ const gp_Pnt& _Pp = PStartf.Value();
+ _thepointAtBeg.SetValue(_Pp,PStartf.Tolerance(),Standard_False);
+ if (!reversed) { //-- typeS1 = Pln || Cyl || Sph || Cone
+ Quad.Parameters(_Pp,_u1,_v1);
+ _u2=_p2d.X(); _v2=_p2d.Y();
+ }
+ else { //-- typeS1 != Pln && Cyl && Sph && Cone
+ Quad.Parameters(_Pp,_u2,_v2);
+ _u1=_p2d.X(); _v1=_p2d.Y();
+ }
+ _thepointAtBeg.SetParameters(_u1,_v1,_u2,_v2);
+ _thepointAtBeg.SetParameter(paramf);
+ if(PStartf.IsNew()==Standard_False)
+ _thepointAtBeg.SetVertex(reversed,_vtx);
+ _thepointAtBeg.SetArc(reversed,thesegm.Curve(),paramf,TLineUnk,TArcUnk);
+
+
+ gp_Vec d1u1,d1v1,d1u2,d1v2; gp_Vec2d _d2d;
+ Surf1->D1(_u1,_v1,ptbid,d1u1,d1v1);
+ norm1 = d1u1.Crossed(d1v1);
+ Surf2->D1(_u2,_v2,ptbid,d1u2,d1v2);
+ norm2 = d1u2.Crossed(d1v2);
+
+ thesegm.Curve()->D1(paramf,_p2d,_d2d);
+ if(reversed) {
+ tgline.SetLinearForm(_d2d.X(),d1u1,_d2d.Y(),d1v1);
+ }
+ else {
+ tgline.SetLinearForm(_d2d.X(),d1u2,_d2d.Y(),d1v2);
+ }
+ _u1=tgline.DotCross(norm2,norm1);
+ TransitionOK=Standard_True;
+ if (_u1 > 0.00000001) {
+ trans1 = IntSurf_Out;
+ trans2 = IntSurf_In;
+ }
+ else if(_u1 < -0.00000001) {
+ trans1 = IntSurf_In;
+ trans2 = IntSurf_Out;
+ }
+ else {
+ TransitionOK=Standard_False;
+ }
}
if(thesegm.HasLastPoint()) {
- Standard_Real _u1,_v1,_u2,_v2;
-
- dolast = Standard_True;
- PStartl = thesegm.LastPoint();
- paraml = PStartl.Parameter();
-
- gp_Pnt2d _p2d = thesegm.Curve()->Value(paraml);
- Handle(Adaptor3d_HVertex) _vtx;
- if(PStartl.IsNew()==Standard_False)
- _vtx = PStartl.Vertex();
- const gp_Pnt& _Pp = PStartl.Value();
- IntPatch_Point _thepoint;
- _thepointAtEnd.SetValue(_Pp,PStartl.Tolerance(),Standard_False);
- if (!reversed) { //-- typeS1 = Pln || Cyl || Sph || Cone
- Quad.Parameters(_Pp,_u1,_v1);
- _u2=_p2d.X(); _v2=_p2d.Y();
- }
- else { //-- typeS1 != Pln && Cyl && Sph && Cone
- Quad.Parameters(_Pp,_u2,_v2);
- _u1=_p2d.X(); _v1=_p2d.Y();
- }
- _thepointAtEnd.SetParameters(_u1,_v1,_u2,_v2);
- _thepointAtEnd.SetParameter(paraml);
- if(PStartl.IsNew()==Standard_False)
- _thepointAtEnd.SetVertex(reversed,_vtx);
- _thepointAtEnd.SetArc(reversed,thesegm.Curve(),paraml,TLineUnk,TArcUnk);
-
-
-
- gp_Vec d1u1,d1v1,d1u2,d1v2; gp_Vec2d _d2d;
- Surf1->D1(_u1,_v1,ptbid,d1u1,d1v1);
- norm1 = d1u1.Crossed(d1v1);
- Surf2->D1(_u2,_v2,ptbid,d1u2,d1v2);
- norm2 = d1u2.Crossed(d1v2);
-
- thesegm.Curve()->D1(paraml,_p2d,_d2d);
- if(reversed) {
- tgline.SetLinearForm(_d2d.X(),d1u1,_d2d.Y(),d1v1);
- }
- else {
- tgline.SetLinearForm(_d2d.X(),d1u2,_d2d.Y(),d1v2);
- }
- _u1=tgline.DotCross(norm2,norm1);
- TransitionOK=Standard_True;
- if (_u1 > 0.00000001) {
- trans1 = IntSurf_Out;
- trans2 = IntSurf_In;
- }
- else if(_u1 < -0.00000001) {
- trans1 = IntSurf_In;
- trans2 = IntSurf_Out;
- }
- else {
- TransitionOK=Standard_False;
- }
+ Standard_Real _u1,_v1,_u2,_v2;
+
+ dolast = Standard_True;
+ PStartl = thesegm.LastPoint();
+ paraml = PStartl.Parameter();
+
+ gp_Pnt2d _p2d = thesegm.Curve()->Value(paraml);
+ Handle(Adaptor3d_HVertex) _vtx;
+ if(PStartl.IsNew()==Standard_False)
+ _vtx = PStartl.Vertex();
+ const gp_Pnt& _Pp = PStartl.Value();
+ IntPatch_Point _thepoint;
+ _thepointAtEnd.SetValue(_Pp,PStartl.Tolerance(),Standard_False);
+ if (!reversed) { //-- typeS1 = Pln || Cyl || Sph || Cone
+ Quad.Parameters(_Pp,_u1,_v1);
+ _u2=_p2d.X(); _v2=_p2d.Y();
+ }
+ else { //-- typeS1 != Pln && Cyl && Sph && Cone
+ Quad.Parameters(_Pp,_u2,_v2);
+ _u1=_p2d.X(); _v1=_p2d.Y();
+ }
+ _thepointAtEnd.SetParameters(_u1,_v1,_u2,_v2);
+ _thepointAtEnd.SetParameter(paraml);
+ if(PStartl.IsNew()==Standard_False)
+ _thepointAtEnd.SetVertex(reversed,_vtx);
+ _thepointAtEnd.SetArc(reversed,thesegm.Curve(),paraml,TLineUnk,TArcUnk);
+
+
+
+ gp_Vec d1u1,d1v1,d1u2,d1v2; gp_Vec2d _d2d;
+ Surf1->D1(_u1,_v1,ptbid,d1u1,d1v1);
+ norm1 = d1u1.Crossed(d1v1);
+ Surf2->D1(_u2,_v2,ptbid,d1u2,d1v2);
+ norm2 = d1u2.Crossed(d1v2);
+
+ thesegm.Curve()->D1(paraml,_p2d,_d2d);
+ if(reversed) {
+ tgline.SetLinearForm(_d2d.X(),d1u1,_d2d.Y(),d1v1);
+ }
+ else {
+ tgline.SetLinearForm(_d2d.X(),d1u2,_d2d.Y(),d1v2);
+ }
+ _u1=tgline.DotCross(norm2,norm1);
+ TransitionOK=Standard_True;
+ if (_u1 > 0.00000001) {
+ trans1 = IntSurf_Out;
+ trans2 = IntSurf_In;
+ }
+ else if(_u1 < -0.00000001) {
+ trans1 = IntSurf_In;
+ trans2 = IntSurf_Out;
+ }
+ else {
+ TransitionOK=Standard_False;
+ }
}
if(TransitionOK==Standard_False) {
- //-- rline = new IntPatch_RLine (thesegm.Curve(),reversed,Standard_False);
- rline = new IntPatch_RLine (Standard_False);
- if(reversed) {
- rline->SetArcOnS1(thesegm.Curve());
- }
- else {
- rline->SetArcOnS2(thesegm.Curve());
- }
+ //-- rline = new IntPatch_RLine (thesegm.Curve(),reversed,Standard_False);
+ rline = new IntPatch_RLine (Standard_False);
+ if(reversed) {
+ rline->SetArcOnS1(thesegm.Curve());
+ }
+ else {
+ rline->SetArcOnS2(thesegm.Curve());
+ }
}
else {
- //-- rline = new IntPatch_RLine (thesegm.Curve(),reversed,Standard_False,trans1,trans2);
- rline = new IntPatch_RLine (Standard_False,trans1,trans2);
- if(reversed) {
- rline->SetArcOnS1(thesegm.Curve());
- }
- else {
- rline->SetArcOnS2(thesegm.Curve());
- }
+ //-- rline = new IntPatch_RLine (thesegm.Curve(),reversed,Standard_False,trans1,trans2);
+ rline = new IntPatch_RLine (Standard_False,trans1,trans2);
+ if(reversed) {
+ rline->SetArcOnS1(thesegm.Curve());
+ }
+ else {
+ rline->SetArcOnS2(thesegm.Curve());
+ }
}
//------------------------------
//-- Ajout des points
//--
if (thesegm.HasFirstPoint()) {
- rline->AddVertex(_thepointAtBeg);
- rline->SetFirstPoint(rline->NbVertex());
+ rline->AddVertex(_thepointAtBeg);
+ rline->SetFirstPoint(rline->NbVertex());
}
-
+
if (thesegm.HasLastPoint()) {
- rline->AddVertex(_thepointAtEnd);
- rline->SetLastPoint(rline->NbVertex());
+ rline->AddVertex(_thepointAtEnd);
+ rline->SetLastPoint(rline->NbVertex());
}
// Polygone sur restriction solution
if (dofirst && dolast) {
- Standard_Real prm;
- gp_Pnt ptpoly;
- IntSurf_PntOn2S p2s;
- Handle(IntSurf_LineOn2S) Thelin = new IntSurf_LineOn2S ();
- Handle(Adaptor2d_HCurve2d) arcsegm = thesegm.Curve();
- Standard_Integer nbsample = 100;
-
- if (!reversed) {
- for (j=1; j<=nbsample; j++) {
- prm = paramf + (j-1)*(paraml-paramf)/(nbsample-1);
- arcsegm->D0(prm,p2d);
- Surf2->D0(p2d.X(),p2d.Y(),ptpoly);
-
- Quad.Parameters(ptpoly,U1,V1);
- p2s.SetValue(ptpoly,U1,V1,p2d.X(),p2d.Y());
- Thelin->Add(p2s);
- }
- }
- else {
- for (j=1; j<=nbsample; j++) {
- prm = paramf + (j-1)*(paraml-paramf)/(nbsample-1);
- arcsegm->D0(prm,p2d);
- Surf1->D0(p2d.X(),p2d.Y(),ptpoly);
-
- Quad.Parameters(ptpoly,U2,V2);
- p2s.SetValue(ptpoly,p2d.X(),p2d.Y(),U2,V2);
- Thelin->Add(p2s);
- }
- }
- rline->Add(Thelin);
+ Standard_Real prm;
+ gp_Pnt ptpoly;
+ IntSurf_PntOn2S p2s;
+ Handle(IntSurf_LineOn2S) Thelin = new IntSurf_LineOn2S ();
+ Handle(Adaptor2d_HCurve2d) arcsegm = thesegm.Curve();
+ Standard_Integer nbsample = 100;
+
+ if (!reversed) {
+ for (j=1; j<=nbsample; j++) {
+ prm = paramf + (j-1)*(paraml-paramf)/(nbsample-1);
+ arcsegm->D0(prm,p2d);
+ Surf2->D0(p2d.X(),p2d.Y(),ptpoly);
+
+ Quad.Parameters(ptpoly,U1,V1);
+ p2s.SetValue(ptpoly,U1,V1,p2d.X(),p2d.Y());
+ Thelin->Add(p2s);
+ }
+ }
+ else {
+ for (j=1; j<=nbsample; j++) {
+ prm = paramf + (j-1)*(paraml-paramf)/(nbsample-1);
+ arcsegm->D0(prm,p2d);
+ Surf1->D0(p2d.X(),p2d.Y(),ptpoly);
+
+ Quad.Parameters(ptpoly,U2,V2);
+ p2s.SetValue(ptpoly,p2d.X(),p2d.Y(),U2,V2);
+ Thelin->Add(p2s);
+ }
+ }
+ rline->Add(Thelin);
}
if (dofirst || dolast) {
- Nblines = slin.Length();
- for (j=1; j<=Nblines; j++) {
- const Handle(IntPatch_Line)& slinj = slin(j);
- typ = slinj->ArcType();
- if (typ == IntPatch_Walking) {
- Nbpts = (*((Handle(IntPatch_WLine)*)&slinj))->NbVertex();
- }
- else {
- Nbpts = (*((Handle(IntPatch_RLine)*)&slinj))->NbVertex();
- }
- for (k=1; k<=Nbpts;k++) {
- if (typ == IntPatch_Walking) {
- ptdeb = (*((Handle(IntPatch_WLine)*)&slinj))->Vertex(k);
- }
- else {
- ptdeb = (*((Handle(IntPatch_RLine)*)&slinj))->Vertex(k);
- }
- if (dofirst) {
-
- if (ptdeb.Value().Distance(PStartf.Value()) <=TolArc) {
- ptdeb.SetMultiple(Standard_True);
- if (typ == IntPatch_Walking) {
- (*((Handle(IntPatch_WLine)*)&slinj))->Replace(k,ptdeb);
- }
- else {
- (*((Handle(IntPatch_RLine)*)&slinj))->Replace(k,ptdeb);
- }
- ptdeb.SetParameter(paramf);
- rline->AddVertex(ptdeb);
- if (!procf){
- procf=Standard_True;
- rline->SetFirstPoint(rline->NbVertex());
- }
- }
- }
- if (dolast) {
- if(dofirst) { //-- on recharge le ptdeb
- if (typ == IntPatch_Walking) {
- ptdeb = (*((Handle(IntPatch_WLine)*)&slinj))->Vertex(k);
- }
- else {
- ptdeb = (*((Handle(IntPatch_RLine)*)&slinj))->Vertex(k);
- }
- }
- if (ptdeb.Value().Distance(PStartl.Value()) <=TolArc) {
- ptdeb.SetMultiple(Standard_True);
- if (typ == IntPatch_Walking) {
- (*((Handle(IntPatch_WLine)*)&slinj))->Replace(k,ptdeb);
- }
- else {
- (*((Handle(IntPatch_RLine)*)&slinj))->Replace(k,ptdeb);
- }
- ptdeb.SetParameter(paraml);
- rline->AddVertex(ptdeb);
- if (!procl){
- procl=Standard_True;
- rline->SetLastPoint(rline->NbVertex());
- }
- }
- }
- }
- }
+ Nblines = slin.Length();
+ for (j=1; j<=Nblines; j++) {
+ const Handle(IntPatch_Line)& slinj = slin(j);
+ typ = slinj->ArcType();
+ if (typ == IntPatch_Walking) {
+ Nbpts = (*((Handle(IntPatch_WLine)*)&slinj))->NbVertex();
+ }
+ else {
+ Nbpts = (*((Handle(IntPatch_RLine)*)&slinj))->NbVertex();
+ }
+ for (k=1; k<=Nbpts;k++) {
+ if (typ == IntPatch_Walking) {
+ ptdeb = (*((Handle(IntPatch_WLine)*)&slinj))->Vertex(k);
+ }
+ else {
+ ptdeb = (*((Handle(IntPatch_RLine)*)&slinj))->Vertex(k);
+ }
+ if (dofirst) {
+
+ if (ptdeb.Value().Distance(PStartf.Value()) <=TolArc) {
+ ptdeb.SetMultiple(Standard_True);
+ if (typ == IntPatch_Walking) {
+ (*((Handle(IntPatch_WLine)*)&slinj))->Replace(k,ptdeb);
+ }
+ else {
+ (*((Handle(IntPatch_RLine)*)&slinj))->Replace(k,ptdeb);
+ }
+ ptdeb.SetParameter(paramf);
+ rline->AddVertex(ptdeb);
+ if (!procf){
+ procf=Standard_True;
+ rline->SetFirstPoint(rline->NbVertex());
+ }
+ }
+ }
+ if (dolast) {
+ if(dofirst) { //-- on recharge le ptdeb
+ if (typ == IntPatch_Walking) {
+ ptdeb = (*((Handle(IntPatch_WLine)*)&slinj))->Vertex(k);
+ }
+ else {
+ ptdeb = (*((Handle(IntPatch_RLine)*)&slinj))->Vertex(k);
+ }
+ }
+ if (ptdeb.Value().Distance(PStartl.Value()) <=TolArc) {
+ ptdeb.SetMultiple(Standard_True);
+ if (typ == IntPatch_Walking) {
+ (*((Handle(IntPatch_WLine)*)&slinj))->Replace(k,ptdeb);
+ }
+ else {
+ (*((Handle(IntPatch_RLine)*)&slinj))->Replace(k,ptdeb);
+ }
+ ptdeb.SetParameter(paraml);
+ rline->AddVertex(ptdeb);
+ if (!procl){
+ procl=Standard_True;
+ rline->SetLastPoint(rline->NbVertex());
+ }
+ }
+ }
+ }
+ }
}
slin.Append(rline);
}
// on traite les restrictions de la surface implicite
for (i=1; i<=slin.Length(); i++)
{
+ Handle(IntPatch_Line)& aL = slin(i);
+ const Handle(IntPatch_WLine)& wline = Handle(IntPatch_WLine)::DownCast(aL);
+
+ if(!wline.IsNull())
+ {//It was processed above
+ continue;
+ }
+
if (!reversed)
- IntPatch_RstInt::PutVertexOnLine(slin(i),Surf1,D1,Surf2,Standard_True,TolTang);
+ IntPatch_RstInt::PutVertexOnLine(aL,Surf1,D1,Surf2,Standard_True,TolTang, 1);
else
- IntPatch_RstInt::PutVertexOnLine(slin(i),Surf2,D2,Surf1,Standard_False,TolTang);
+ IntPatch_RstInt::PutVertexOnLine(aL,Surf2,D2,Surf1,Standard_False,TolTang, 1);
}
empt = (slin.Length() == 0 && spnt.Length() == 0);
done = Standard_True;
Standard_Boolean IsReversed,
Handle(Adaptor3d_HSurface)& QSurf,
Handle(IntSurf_LineOn2S)& Vertices)
-{
+ {
Handle(IntSurf_LineOn2S) line = new IntSurf_LineOn2S();
Standard_Real VF = QSurf->FirstVParameter();
if(VF <= V && V <= VL)
line->Add(aP);
- }
+ }
Standard_Boolean isDeleted = Standard_True;
Standard_Integer k = 0;
else {
k = i;
break;
- }
+ }
}
if(k != 0) {
else {
Standard_Real uu = U2;
if( U2 > (2.*M_PI) )
- while( uu > (2.*M_PI) )
- uu -= (2.*M_PI);
+ while( uu > (2.*M_PI) )
+ uu -= (2.*M_PI);
else
- while( uu < 0.)
- uu += (2.*M_PI);
-
+ while( uu < 0.)
+ uu += (2.*M_PI);
+
u = ( uu < ((2.*M_PI)-uu) ) ? 0. : (2.*M_PI);
}
}
else {
Standard_Real uu = U2;
if( U2 > (2.*M_PI) )
- while( uu > (2.*M_PI) )
- uu -= (2.*M_PI);
+ while( uu > (2.*M_PI) )
+ uu -= (2.*M_PI);
else
- while( uu < 0.)
- uu += (2.*M_PI);
-
+ while( uu < 0.)
+ uu += (2.*M_PI);
+
u = ( uu < ((2.*M_PI)-uu) ) ? 0. : (2.*M_PI);
}
}
else {
if(U1 < 0.)
while(u < 0.)
- u += 2.*M_PI;
+ u += 2.*M_PI;
if(U1 > (2.*M_PI))
while(u > (2.*M_PI))
- u -= (2.*M_PI);
+ u -= (2.*M_PI);
}
return u;
// collect vertices, reject equals
static Handle(IntSurf_LineOn2S) GetVertices(const Handle(IntPatch_WLine)& WLine,
const Standard_Boolean ,//IsReversed,
- const Standard_Real TOL3D,
- const Standard_Real TOL2D)
+ const Standard_Real TOL3D,
+ const Standard_Real TOL2D)
{
-// Standard_Real TOL3D = 1.e-12, TOL2D = 1.e-8;
+ // Standard_Real TOL3D = 1.e-12, TOL2D = 1.e-8;
Handle(IntSurf_LineOn2S) vertices = new IntSurf_LineOn2S();
Standard_Real U1 = 0., U2 = 0., V1 = 0., V2 = 0.;
Standard_Integer i = 0, k = 0;
Standard_Integer NbVrt = WLine->NbVertex();
-
+
TColStd_Array1OfInteger anVrts(1,NbVrt);
anVrts.Init(0);
const IntPatch_Point& Pk = WLine->Vertex(k);
if(Pi.Value().Distance(Pk.Value()) <= TOL3D) {
- // suggest the points are equal;
- // test 2d parameters on surface
- Standard_Boolean sameU1 = Standard_False;
- Standard_Boolean sameV1 = Standard_False;
- Standard_Boolean sameU2 = Standard_False;
- Standard_Boolean sameV2 = Standard_False;
-
- Pi.ParametersOnS1(U1,V1);
- Pk.ParametersOnS1(U2,V2);
- if(fabs(U1-U2) <= TOL2D) sameU1 = Standard_True;
- if(fabs(V1-V2) <= TOL2D) sameV1 = Standard_True;
-
- Pi.ParametersOnS2(U1,V1);
- Pk.ParametersOnS2(U2,V2);
- if(fabs(U1-U2) <= TOL2D) sameU2 = Standard_True;
- if(fabs(V1-V2) <= TOL2D) sameV2 = Standard_True;
-
- if((sameU1 && sameV1) && (sameU2 && sameV2))
- anVrts(k) = -1;
+ // suggest the points are equal;
+ // test 2d parameters on surface
+ Standard_Boolean sameU1 = Standard_False;
+ Standard_Boolean sameV1 = Standard_False;
+ Standard_Boolean sameU2 = Standard_False;
+ Standard_Boolean sameV2 = Standard_False;
+
+ Pi.ParametersOnS1(U1,V1);
+ Pk.ParametersOnS1(U2,V2);
+ if(fabs(U1-U2) <= TOL2D) sameU1 = Standard_True;
+ if(fabs(V1-V2) <= TOL2D) sameV1 = Standard_True;
+
+ Pi.ParametersOnS2(U1,V1);
+ Pk.ParametersOnS2(U2,V2);
+ if(fabs(U1-U2) <= TOL2D) sameU2 = Standard_True;
+ if(fabs(V1-V2) <= TOL2D) sameV2 = Standard_True;
+
+ if((sameU1 && sameV1) && (sameU2 && sameV2))
+ anVrts(k) = -1;
}
}
}
}
static Standard_Boolean AreSamePoints(const IntSurf_PntOn2S& P1,
- const IntSurf_PntOn2S& P2)
+ const IntSurf_PntOn2S& P2)
{
Standard_Boolean result = Standard_False;
Standard_Real T2D = 1.e-9, T3D = 1.e-8;
Standard_Integer Index = 0, IndexLimF = 8, IndexLimL = 8;
Standard_Real U1 = 0., V1 = 0., U2 = 0., V2 = 0.;
- if(IsReversed) {
- Result->Value(1).ParametersOnS2(U1,V1);
- Result->Value(Result->NbPoints()).ParametersOnS2(U2,V2);
- }
- else {
- Result->Value(1).ParametersOnS1(U1,V1);
- Result->Value(Result->NbPoints()).ParametersOnS1(U2,V2);
- }
+ if(IsReversed) {
+ Result->Value(1).ParametersOnS2(U1,V1);
+ Result->Value(Result->NbPoints()).ParametersOnS2(U2,V2);
+ }
+ else {
+ Result->Value(1).ParametersOnS1(U1,V1);
+ Result->Value(Result->NbPoints()).ParametersOnS1(U2,V2);
+ }
if(Quad.TypeQuadric() == GeomAbs_Cone) {
Standard_Real Uapx = 0., Vapx = 0.;
Quad.Parameters(Quad.Cone().Apex(),Uapx,Vapx);
-
+
if(fabs(V1-Vapx) <= 1.e-3)
IndexLimF = 12;
if(fabs(V2-Vapx) <= 1.e-3)
if(Quad.TypeQuadric() == GeomAbs_Sphere) {
Standard_Real Vapx1 = M_PI/2., Vapx2 = -M_PI/2.;
-
+
if(fabs(V1-Vapx1) <= 1.e-3 || fabs(V1-Vapx2) <= 1.e-3)
IndexLimF = 12;
if(fabs(V2-Vapx1) <= 1.e-3 || fabs(V2-Vapx2) <= 1.e-3)
// DEBUG FUNCTION !!!
#if 0
static void DumpLine(Handle(IntSurf_LineOn2S)& Line,
- Standard_Boolean IsReversed,
- Standard_Integer Number)
+ Standard_Boolean IsReversed,
+ Standard_Integer Number)
{
cout << "DUMP LINE" << endl;
Standard_Integer i;
// DEBUG FUNCTION !!!
static void SearchVertices(const Handle(IntSurf_LineOn2S)& Line,
- const Handle(IntSurf_LineOn2S)& Vertices,
- TColStd_Array1OfInteger& PTypes)
+ const Handle(IntSurf_LineOn2S)& Vertices,
+ TColStd_Array1OfInteger& PTypes)
{
Standard_Integer nbp = Line->NbPoints(), nbv = Vertices->NbPoints();
Standard_Integer ip = 0, iv = 0;
for(iv = 1; iv <= nbv; iv++) {
const IntSurf_PntOn2S& aV = Vertices->Value(iv);
if(AreSamePoints(aP,aV)) {
- type = iv;
- break;
+ type = iv;
+ break;
}
}
PTypes(ip) = type;
}
static inline Standard_Boolean IsSeamParameter(const Standard_Real U,
- const Standard_Real TOL2D)
+ const Standard_Real TOL2D)
{
return (fabs(U) <= TOL2D || fabs(2.*M_PI - U) <= TOL2D);
}
if(u < 0. || u > DBLPI) {
if(u < 0.)
while(u < 0.)
- u += DBLPI;
+ u += DBLPI;
else
while(u > DBLPI)
- u -= DBLPI;
+ u -= DBLPI;
}
return u;
}
static inline void Correct2DBounds(const Standard_Real UF,
- const Standard_Real UL,
- const Standard_Real VF,
- const Standard_Real VL,
- const Standard_Real TOL2D,
- Standard_Real& U,
- Standard_Real& V)
+ const Standard_Real UL,
+ const Standard_Real VF,
+ const Standard_Real VL,
+ const Standard_Real TOL2D,
+ Standard_Real& U,
+ Standard_Real& V)
{
Standard_Real Eps = 1.e-16;
Standard_Real dUF = fabs(U - UF);
}
static void AdjustLine(Handle(IntSurf_LineOn2S)& Line,
- const Standard_Boolean IsReversed,
- const Handle(Adaptor3d_HSurface)& QSurf,
- const Standard_Real TOL2D)
+ const Standard_Boolean IsReversed,
+ const Handle(Adaptor3d_HSurface)& QSurf,
+ const Standard_Real TOL2D)
{
Standard_Real VF = QSurf->FirstVParameter();
Standard_Real VL = QSurf->LastVParameter();
}
static Standard_Boolean InsertSeamVertices(Handle(IntSurf_LineOn2S)& Line,
- const Standard_Boolean IsReversed,
- Handle(IntSurf_LineOn2S)& Vertices,
- const TColStd_Array1OfInteger& PTypes,
- const Standard_Real TOL2D)
+ const Standard_Boolean IsReversed,
+ Handle(IntSurf_LineOn2S)& Vertices,
+ const TColStd_Array1OfInteger& PTypes,
+ const Standard_Real TOL2D)
{
Standard_Boolean result = Standard_False;
Standard_Integer ip = 0, nbp = Line->NbPoints();
if(ipt != 0) {
const IntSurf_PntOn2S& aP = Line->Value(ip);
if(IsReversed)
- aP.ParametersOnS2(U,V); // S2 - quadric
+ aP.ParametersOnS2(U,V); // S2 - quadric
else
- aP.ParametersOnS1(U,V); // S1 - quadric
+ aP.ParametersOnS1(U,V); // S1 - quadric
U = AdjustU(U);
if(IsSeamParameter(U,TOL2D)) {
- if(ip == 1 || ip == nbp) {
- Standard_Real U1 = 0., V1 = 0.;
- Standard_Integer ipp = (ip == 1) ? (ip+1) : (ip-1);
- if(IsReversed)
- Line->Value(ipp).ParametersOnS2(U1,V1); // S2 - quadric
- else
- Line->Value(ipp).ParametersOnS1(U1,V1); // S1 - quadric
- Standard_Real u = AdjustUFirst(U,U1);
- if(fabs(u-U) >= 1.5*M_PI) {
- Standard_Real U2 = 0., V2 = 0.;
- if(IsReversed) {
- Line->Value(ip).ParametersOnS1(U2,V2); // prm
- Line->SetUV(ip,Standard_False,u,V);
- Line->SetUV(ip,Standard_True,U2,V2);
- }
- else {
- Line->Value(ip).ParametersOnS2(U2,V2); // prm
- Line->SetUV(ip,Standard_True,u,V);
- Line->SetUV(ip,Standard_False,U2,V2);
- }
- }
- }
- else {
- Standard_Integer ipp = ip - 1;
- Standard_Integer ipn = ip + 1;
- Standard_Real U1 = 0., V1 = 0., U2 = 0., V2 = 0.;
- if(IsReversed) {
- Line->Value(ipp).ParametersOnS2(U1,V1); // quad
- Line->Value(ipn).ParametersOnS2(U2,V2); // quad
- }
- else {
- Line->Value(ipp).ParametersOnS1(U1,V1); // quad
- Line->Value(ipn).ParametersOnS1(U2,V2); // quad
- }
- U1 = AdjustU(U1);
- U2 = AdjustU(U2);
- Standard_Boolean pnearZero = (fabs(U1) < fabs(2.*M_PI-U1)) ? Standard_True : Standard_False;
- Standard_Boolean cnearZero = (fabs(U) < fabs(2.*M_PI-U)) ? Standard_True : Standard_False;
- if(pnearZero == cnearZero) {
- if(!IsSeamParameter(U2,TOL2D) && !IsSeamParameter(U1,TOL2D)) {
- Standard_Real nU = (cnearZero) ? (2.*M_PI) : 0.;
- IntSurf_PntOn2S nP;
- nP.SetValue(aP.Value());
- Standard_Real U3 = 0., V3 = 0.;
- if(IsReversed) {
- Line->Value(ip).ParametersOnS1(U3,V3); // prm
- nP.SetValue(Standard_False,nU,V);
- nP.SetValue(Standard_True,U3,V3);
- }
- else {
- Line->Value(ip).ParametersOnS2(U3,V3); // prm
- nP.SetValue(Standard_True,nU,V);
- nP.SetValue(Standard_False,U3,V3);
- }
- Line->InsertBefore(ipn,nP);
- Vertices->Add(nP);
- result = Standard_True;
- break;
- }
- }
- else {
- if(!IsSeamParameter(U2,TOL2D) && !IsSeamParameter(U1,TOL2D)) {
- Standard_Real nU = (cnearZero) ? (2.*M_PI) : 0.;
- IntSurf_PntOn2S nP;
- nP.SetValue(aP.Value());
- Standard_Real U3 = 0., V3 = 0.;
- if(IsReversed) {
- Line->Value(ip).ParametersOnS1(U3,V3); // prm
- nP.SetValue(Standard_False,nU,V);
- nP.SetValue(Standard_True,U3,V3);
- }
- else {
- Line->Value(ip).ParametersOnS2(U3,V3); // prm
- nP.SetValue(Standard_True,nU,V);
- nP.SetValue(Standard_False,U3,V3);
- }
- Line->InsertBefore(ip,nP);
- Vertices->Add(nP);
- result = Standard_True;
- break;
- }
- else {
-// Line->InsertBefore(ip,Line->Value(ipn));
-// Line->RemovePoint(ip+2);
-// result = Standard_True;
-// cout << "swap vertex " << endl;
-// break;
- }
- }
- }
+ if(ip == 1 || ip == nbp) {
+ Standard_Real U1 = 0., V1 = 0.;
+ Standard_Integer ipp = (ip == 1) ? (ip+1) : (ip-1);
+ if(IsReversed)
+ Line->Value(ipp).ParametersOnS2(U1,V1); // S2 - quadric
+ else
+ Line->Value(ipp).ParametersOnS1(U1,V1); // S1 - quadric
+ Standard_Real u = AdjustUFirst(U,U1);
+ if(fabs(u-U) >= 1.5*M_PI) {
+ Standard_Real U2 = 0., V2 = 0.;
+ if(IsReversed) {
+ Line->Value(ip).ParametersOnS1(U2,V2); // prm
+ Line->SetUV(ip,Standard_False,u,V);
+ Line->SetUV(ip,Standard_True,U2,V2);
+ }
+ else {
+ Line->Value(ip).ParametersOnS2(U2,V2); // prm
+ Line->SetUV(ip,Standard_True,u,V);
+ Line->SetUV(ip,Standard_False,U2,V2);
+ }
+ }
+ }
+ else {
+ Standard_Integer ipp = ip - 1;
+ Standard_Integer ipn = ip + 1;
+ Standard_Real U1 = 0., V1 = 0., U2 = 0., V2 = 0.;
+ if(IsReversed) {
+ Line->Value(ipp).ParametersOnS2(U1,V1); // quad
+ Line->Value(ipn).ParametersOnS2(U2,V2); // quad
+ }
+ else {
+ Line->Value(ipp).ParametersOnS1(U1,V1); // quad
+ Line->Value(ipn).ParametersOnS1(U2,V2); // quad
+ }
+ U1 = AdjustU(U1);
+ U2 = AdjustU(U2);
+ Standard_Boolean pnearZero = (fabs(U1) < fabs(2.*M_PI-U1)) ? Standard_True : Standard_False;
+ Standard_Boolean cnearZero = (fabs(U) < fabs(2.*M_PI-U)) ? Standard_True : Standard_False;
+ if(pnearZero == cnearZero) {
+ if(!IsSeamParameter(U2,TOL2D) && !IsSeamParameter(U1,TOL2D)) {
+ Standard_Real nU = (cnearZero) ? (2.*M_PI) : 0.;
+ IntSurf_PntOn2S nP;
+ nP.SetValue(aP.Value());
+ Standard_Real U3 = 0., V3 = 0.;
+ if(IsReversed) {
+ Line->Value(ip).ParametersOnS1(U3,V3); // prm
+ nP.SetValue(Standard_False,nU,V);
+ nP.SetValue(Standard_True,U3,V3);
+ }
+ else {
+ Line->Value(ip).ParametersOnS2(U3,V3); // prm
+ nP.SetValue(Standard_True,nU,V);
+ nP.SetValue(Standard_False,U3,V3);
+ }
+ Line->InsertBefore(ipn,nP);
+ Vertices->Add(nP);
+ result = Standard_True;
+ break;
+ }
+ }
+ else {
+ if(!IsSeamParameter(U2,TOL2D) && !IsSeamParameter(U1,TOL2D)) {
+ Standard_Real nU = (cnearZero) ? (2.*M_PI) : 0.;
+ IntSurf_PntOn2S nP;
+ nP.SetValue(aP.Value());
+ Standard_Real U3 = 0., V3 = 0.;
+ if(IsReversed) {
+ Line->Value(ip).ParametersOnS1(U3,V3); // prm
+ nP.SetValue(Standard_False,nU,V);
+ nP.SetValue(Standard_True,U3,V3);
+ }
+ else {
+ Line->Value(ip).ParametersOnS2(U3,V3); // prm
+ nP.SetValue(Standard_True,nU,V);
+ nP.SetValue(Standard_False,U3,V3);
+ }
+ Line->InsertBefore(ip,nP);
+ Vertices->Add(nP);
+ result = Standard_True;
+ break;
+ }
+ else {
+ // Line->InsertBefore(ip,Line->Value(ipn));
+ // Line->RemovePoint(ip+2);
+ // result = Standard_True;
+ // cout << "swap vertex " << endl;
+ // break;
+ }
+ }
+ }
}
}
}
Standard_Boolean IsReversed,
IntSurf_Quadric& Quad,
Standard_Boolean IsFirst,
- Standard_Real& D3D)
+ Standard_Real& D3D)
{
if(Line->NbPoints() <= 10)
return;
-
+
D3D = 0.;
Standard_Integer NbTestPnts = Line->NbPoints() / 5;
if(NbTestPnts < 5) NbTestPnts = 5;
}
DDU += fabs(fabs(Uc)-fabs(Un));
DDV += fabs(fabs(Vc)-fabs(Vn));
-
+
if(ip > startp) {
Standard_Real DP = Line->Value(ip).Value().Distance(Line->Value(ip-1).Value());
D3D += DP;
DDU /= (Standard_Real) NbTestPnts + 1;
DDV /= (Standard_Real) NbTestPnts + 1;
-
+
D3D /= (Standard_Real) NbTestPnts + 1;
if(!doU && Quad.TypeQuadric() == GeomAbs_Sphere) {
if(fabs(fabs(U1)-fabs(U2)) > (M_PI/16.)) doU = Standard_True;
-
+
if(doU && (fabs(U1) <= 1.e-9 || fabs(U1-2.*M_PI) <= 1.e-9)) {
if(fabs(V1-M_PI/2.) <= 1.e-9 || fabs(V1+M_PI/2.) <= 1.e-9) {}
else {
- doU = Standard_False;
+ doU = Standard_False;
}
}
}
-
+
if(Quad.TypeQuadric() == GeomAbs_Cone) {
Standard_Real Uapx = 0., Vapx = 0.;
Quad.Parameters(Quad.Cone().Apex(),Uapx,Vapx);
if(doU && (fabs(U1) <= 1.e-9 || fabs(U1-2.*M_PI) <= 1.e-9)) {
if(fabs(V1-Vapx) <= 1.e-9) {}
else {
- doU = Standard_False;
+ doU = Standard_False;
}
}
}
}
static Standard_Boolean TestMiddleOnPrm(const IntSurf_PntOn2S& aP,
- const IntSurf_PntOn2S& aV,
- const Standard_Boolean IsReversed,
- const Standard_Real ArcTol,
+ const IntSurf_PntOn2S& aV,
+ const Standard_Boolean IsReversed,
+ const Standard_Real ArcTol,
Handle(Adaptor3d_TopolTool)& PDomain)
-
+
{
Standard_Boolean result = Standard_False;
Standard_Real Up = 0., Vp = 0., Uv = 0., Vv = 0.;
Standard_Boolean IsReversed,
Handle(IntSurf_LineOn2S)& Vertices,
Standard_Real TOL2D,
- const Standard_Real ArcTol,
+ const Standard_Real ArcTol,
Handle(Adaptor3d_TopolTool)& PDomain,
- IntSurf_PntOn2S& VrtF,
- Standard_Boolean& AddFirst,
- IntSurf_PntOn2S& VrtL,
- Standard_Boolean& AddLast)
+ IntSurf_PntOn2S& VrtF,
+ Standard_Boolean& AddFirst,
+ IntSurf_PntOn2S& VrtL,
+ Standard_Boolean& AddLast)
{
Standard_Integer nbp = Line->NbPoints(), nbv = Vertices->NbPoints();
Standard_Integer FIndexSame = 0, FIndexNear = 0, LIndexSame = 0, LIndexNear = 0;
}
}
}
-
+
if(LIndexSame == 0) {
if(LIndexNear != 0) {
const IntSurf_PntOn2S& aV = Vertices->Value(LIndexNear);
}
static Standard_Boolean AddVertices(Handle(IntSurf_LineOn2S)& Line,
- const IntSurf_PntOn2S& VrtF,
- const Standard_Boolean AddFirst,
- const IntSurf_PntOn2S& VrtL,
- const Standard_Boolean AddLast,
- const Standard_Real D3DF,
- const Standard_Real D3DL)
+ const IntSurf_PntOn2S& VrtF,
+ const Standard_Boolean AddFirst,
+ const IntSurf_PntOn2S& VrtL,
+ const Standard_Boolean AddLast,
+ const Standard_Real D3DF,
+ const Standard_Real D3DL)
{
Standard_Boolean result = Standard_False;
if(AddFirst) {
}
return result;
}
-
+
static void PutIntVertices(Handle(IntPatch_Line)& Line,
- Handle(IntSurf_LineOn2S)& Result,
- Standard_Boolean ,//IsReversed,
- Handle(IntSurf_LineOn2S)& Vertices,
- const Standard_Real ArcTol)
+ Handle(IntSurf_LineOn2S)& Result,
+ Standard_Boolean ,//IsReversed,
+ Handle(IntSurf_LineOn2S)& Vertices,
+ const Standard_Real ArcTol)
{
Standard_Integer nbp = Result->NbPoints(), nbv = Vertices->NbPoints();
gp_Pnt aPnt;
IntPatch_Point thePnt;
Standard_Real U1 = 0., V1 = 0., U2 = 0., V2 = 0.;
-
+
for(ip = 2; ip <= (nbp-1); ip++) {
const IntSurf_PntOn2S& aP = Result->Value(ip);
for(iv = 1; iv <= nbv; iv++) {
const IntSurf_PntOn2S& aV = Vertices->Value(iv);
if(AreSamePoints(aP,aV)) {
aPnt = Result->Value(ip).Value();
- Result->Value(ip).ParametersOnS1(U1,V1);
- Result->Value(ip).ParametersOnS2(U2,V2);
- thePnt.SetValue(aPnt,ArcTol,Standard_False);
- thePnt.SetParameters(U1,V1,U2,V2);
- thePnt.SetParameter((Standard_Real)ip);
- WLine->AddVertex(thePnt);
+ Result->Value(ip).ParametersOnS1(U1,V1);
+ Result->Value(ip).ParametersOnS2(U2,V2);
+ thePnt.SetValue(aPnt,ArcTol,Standard_False);
+ thePnt.SetParameters(U1,V1,U2,V2);
+ thePnt.SetParameter((Standard_Real)ip);
+ WLine->AddVertex(thePnt);
}
}
}
}
static Standard_Boolean HasInternals(Handle(IntSurf_LineOn2S)& Line,
- Handle(IntSurf_LineOn2S)& Vertices)
+ Handle(IntSurf_LineOn2S)& Vertices)
{
Standard_Integer nbp = Line->NbPoints(), nbv = Vertices->NbPoints();
Standard_Integer ip = 0, iv = 0;
Standard_Boolean result = Standard_False;
-
+
if(nbp < 3)
return result;
if(result)
break;
}
-
+
return result;
}
static Handle(IntPatch_WLine) MakeSplitWLine (Handle(IntPatch_WLine)& WLine,
- Standard_Boolean Tang,
- IntSurf_TypeTrans Trans1,
- IntSurf_TypeTrans Trans2,
- Standard_Real ArcTol,
- Standard_Integer ParFirst,
- Standard_Integer ParLast)
+ Standard_Boolean Tang,
+ IntSurf_TypeTrans Trans1,
+ IntSurf_TypeTrans Trans2,
+ Standard_Real ArcTol,
+ Standard_Integer ParFirst,
+ Standard_Integer ParLast)
{
Handle(IntSurf_LineOn2S) SLine = WLine->Curve();
Handle(IntSurf_LineOn2S) sline = new IntSurf_LineOn2S();
-
- Standard_Integer ip = 0;
+
+ Standard_Integer ip = 0;
for(ip = ParFirst; ip <= ParLast; ip++)
sline->Add(SLine->Value(ip));
TPntF.SetParameter(1.);
wline->AddVertex(TPntF);
wline->SetFirstPoint(1);
-
+
aSPnt = sline->Value(sline->NbPoints()).Value();
sline->Value(sline->NbPoints()).ParametersOnS1(uu1,vv1);
sline->Value(sline->NbPoints()).ParametersOnS2(uu2,vv2);
}
static Standard_Boolean SplitOnSegments(Handle(IntPatch_WLine)& WLine,
- Standard_Boolean Tang,
- IntSurf_TypeTrans Trans1,
- IntSurf_TypeTrans Trans2,
- Standard_Real ArcTol,
- IntPatch_SequenceOfLine& Segments)
+ Standard_Boolean Tang,
+ IntSurf_TypeTrans Trans1,
+ IntSurf_TypeTrans Trans2,
+ Standard_Real ArcTol,
+ IntPatch_SequenceOfLine& Segments)
{
Standard_Boolean result = Standard_False;
Segments.Clear();
Lines.Append(Line);
return;
}
-
+
Standard_Real TOL3D = 1.e-10, TOL2D = 1.e-8, TOL2DS = 1.e-5;
-
+
Handle(IntSurf_LineOn2S) vline = GetVertices(WLine,IsReversed,TOL3D,TOL2D);
Handle(IntSurf_LineOn2S) SSLine = VSplitLine(SLine,IsReversed,QSurf,vline);
AdjustLine(SSLine,IsReversed,QSurf,TOL2D);
- Standard_Boolean isInserted = Standard_True;
+ Standard_Boolean isInserted = Standard_True;
while(isInserted) {
Standard_Integer NbPnts = SSLine->NbPoints();
TColStd_Array1OfInteger ptypes(1,NbPnts);
SearchVertices(SSLine,vline,ptypes);
isInserted = InsertSeamVertices(SSLine,IsReversed,vline,ptypes,TOL2D);
- }
+ }
if(SSLine->NbPoints() == 2) {
Standard_Real uu1 = 0., vv1 = 0., uu2 = 0., vv2 = 0.;
if(IsReversed) {
SSLine->Value(1).ParametersOnS2(uu1,vv1);
SSLine->Value(2).ParametersOnS2(uu2,vv2);
- }
+ }
else {
SSLine->Value(1).ParametersOnS1(uu1,vv1);
SSLine->Value(2).ParametersOnS1(uu2,vv2);
Standard_Real BSEAM = 1.5*M_PI; // delta U crossing seam
Standard_Real BAPEX = M_PI/16.; // delta U crossing apex
-
+
Standard_Integer k = 0;
Standard_Real U1 = 0., U2 = 0., V1 = 0., V2 = 0., AnU1 = 0., AnV1 = 0., DU1 = 0., DV1 = 0.;
Standard_Integer Findex = 1, Lindex = NbPnts, Bindex = 0;
gp_Pnt aPnt, aSPnt;
IntPatch_Point TPntF,TPntL,TPntS;
- Handle(IntSurf_LineOn2S) sline = new IntSurf_LineOn2S();
+ Handle(IntSurf_LineOn2S) sline = new IntSurf_LineOn2S();
Handle(IntPatch_WLine) wline;
IntPatch_SequenceOfLine lines;
// build WLine parts (if any)
nextline:;
- //if((Lindex-Findex+1) <= 2 )
+ //if((Lindex-Findex+1) <= 2 )
if((Lindex-Findex+1) <= 1 )
return;
Standard_Boolean isDecomposited = Standard_False;
Standard_Boolean is2PIDecomposed = Standard_False;
U1 = 0.; V1 = 0.; U2 = 0.; V2 = 0.; AnU1 = 0.; AnV1 = 0.; DU1 = 0.; DV1 = 0.;
-
- // analyze other points
+
+ // analyze other points
for(k = Findex; k <= Lindex; k++) {
if( k == Findex ) {
if(IsReversed) {
SSLine->Value(k).ParametersOnS2(AnU1,V1); // S2 - quadric, set U,V by Pnt3D
- }
+ }
else {
SSLine->Value(k).ParametersOnS1(AnU1,V1); // S1 - quadric, set U,V by Pnt3D
- }
+ }
sline->Add(SSLine->Value(k));
AnV1 = V1;
- continue;
- }
+ continue;
+ }
if(IsReversed) {
SSLine->Value(k).ParametersOnS2(U1,V1); // S2 - quadric, set U,V by Pnt3D
- }
+ }
else {
SSLine->Value(k).ParametersOnS1(U1,V1); // S1 - quadric, set U,V by Pnt3D
- }
+ }
Standard_Real DeltaU = fabs(U1-AnU1);
if(DeltaU > BSEAM) {
Bindex = k;
- isDecomposited = Standard_True;
+ isDecomposited = Standard_True;
is2PIDecomposed = Standard_True;
break;
- }
+ }
else if((DeltaU > BAPEX) && (k >= (Findex+10) && k <= (Lindex-10))) {
Bindex = k;
isDecomposited = Standard_True;
- break;
- }
+ break;
+ }
else {}
sline->Add(SSLine->Value(k));
- AnU1=U1;
+ AnU1=U1;
AnV1=V1;
- }
-
- IntSurf_PntOn2S aVF,aVL;
- Standard_Boolean addVF = Standard_False, addVL = Standard_False;
+ }
+
+ IntSurf_PntOn2S aVF, aVL;
+ Standard_Boolean addVF = Standard_False, addVL = Standard_False;
VerifyVertices(sline,IsReversed,vline,TOL2DS,ArcTol,PDomain,aVF,addVF,aVL,addVL);
Standard_Boolean hasInternals = HasInternals(sline,vline);
- Standard_Real D3F = 0., D3L = 0.;
+ Standard_Real D3F = 0., D3L = 0.;
ToSmooth(sline,IsReversed,Quad,Standard_True,D3F);
ToSmooth(sline,IsReversed,Quad,Standard_False,D3L);
}
if(addVF || addVL) {
- Standard_Boolean isAdded = AddVertices(sline,aVF,addVF,aVL,addVL,D3F,D3L);
+ Standard_Boolean isAdded = AddVertices(sline,aVF,addVF,aVL,addVL,D3F,D3L);
if(isAdded) {
ToSmooth(sline,IsReversed,Quad,Standard_True,D3F);
ToSmooth(sline,IsReversed,Quad,Standard_False,D3L);
+ }
}
- }
if(!hasInternals) {
ForcedPurgePoints(sline,IsReversed,Quad);
- }
+ }
wline = new IntPatch_WLine(sline,Standard_False,Line->TransitionOnS1(),Line->TransitionOnS2());
aSPnt = sline->Value(1).Value();
- sline->Value(1).ParametersOnS1(U1,V1);
- sline->Value(1).ParametersOnS2(U2,V2);
+ sline->Value(1).ParametersOnS1(U1,V1);
+ sline->Value(1).ParametersOnS2(U2,V2);
TPntF.SetValue(aSPnt,ArcTol,Standard_False);
TPntF.SetParameters(U1,V1,U2,V2);
TPntF.SetParameter(1.);
wline->AddVertex(TPntF);
- wline->SetFirstPoint(1);
+ wline->SetFirstPoint(1);
if(hasInternals) {
PutIntVertices(wline,sline,IsReversed,vline,ArcTol);
- }
-
- aSPnt = sline->Value(sline->NbPoints()).Value();
- sline->Value(sline->NbPoints()).ParametersOnS1(U1,V1);
- sline->Value(sline->NbPoints()).ParametersOnS2(U2,V2);
+ }
+
+ aSPnt = sline->Value(sline->NbPoints()).Value();
+ sline->Value(sline->NbPoints()).ParametersOnS1(U1,V1);
+ sline->Value(sline->NbPoints()).ParametersOnS2(U2,V2);
TPntL.SetValue(aSPnt,ArcTol,Standard_False);
TPntL.SetParameters(U1,V1,U2,V2);
TPntL.SetParameter(sline->NbPoints());
wline->AddVertex(TPntL);
- wline->SetLastPoint(sline->NbPoints());
+ wline->SetLastPoint(sline->NbPoints());
- IntPatch_SequenceOfLine segm;
+ IntPatch_SequenceOfLine segm;
Standard_Boolean isSplited = SplitOnSegments(wline,Standard_False,Line->TransitionOnS1(),Line->TransitionOnS2(),ArcTol,segm);
- if(!isSplited)
+ if(!isSplited)
Lines.Append(wline);
else {
- Standard_Integer nbsegms = segm.Length();
- Standard_Integer iseg = 0;
- for(iseg = 1; iseg <= nbsegms; iseg++)
+ Standard_Integer nbsegms = segm.Length();
+ Standard_Integer iseg = 0;
+ for(iseg = 1; iseg <= nbsegms; iseg++)
Lines.Append(segm(iseg));
- }
+ }
if(isDecomposited) {
Findex = Bindex;
sline = new IntSurf_LineOn2S();
goto nextline;
+ }
}
-}
/*
// <-A
- {
- Standard_Integer aNbPnts;
- Standard_Real aU1,aV1,aU2,aV2;
- gp_Pnt aPx;
- //
- aNbPnts=thelin->NbPoints();
- printf(" WLine: aNbPnts=%d\n", aNbPnts);
- for(i=1; i <= aNbPnts; ++i) {
- const IntSurf_PntOn2S& aPoint = thelin->Value(i);
- aPx=aPoint.Value();
- aPoint.Parameters(aU1, aV1, aU2, aV2);
- printf(" point %d %lf %lf %lf %lf %lf %lf %lf\n",
- i, aPx.X(), aPx.Y(), aPx.Z(), aU1, aV1, aU2, aV2);
- }
- }
+{
+Standard_Integer aNbPnts;
+Standard_Real aU1,aV1,aU2,aV2;
+gp_Pnt aPx;
+//
+aNbPnts=thelin->NbPoints();
+printf(" WLine: aNbPnts=%d\n", aNbPnts);
+for(i=1; i <= aNbPnts; ++i) {
+const IntSurf_PntOn2S& aPoint = thelin->Value(i);
+aPx=aPoint.Value();
+aPoint.Parameters(aU1, aV1, aU2, aV2);
+printf(" point %d %lf %lf %lf %lf %lf %lf %lf\n",
+i, aPx.X(), aPx.Y(), aPx.Z(), aU1, aV1, aU2, aV2);
+}
+}
*/
#include <NCollection_IncAllocator.hxx>
#include <Precision.hxx>
+#include <Geom_Surface.hxx>
+#include <Geom_Plane.hxx>
+#include <Geom_CylindricalSurface.hxx>
+#include <Geom_ConicalSurface.hxx>
+#include <Geom_SphericalSurface.hxx>
+#include <Geom_ToroidalSurface.hxx>
+enum TypeOfExtending
+{
+ IS_NOT_REQUIRED = 0,
+ EXTEND_Udir_FOR_SURF1 = 1,
+ EXTEND_Vdir_FOR_SURF1 = 2,
+ EXTEND_Udir_FOR_SURF2 = 4,
+ EXTEND_Vdir_FOR_SURF2 = 8
+};
+
+enum TypeOfPoint
+{
+ EXACTLY_INTO = 0,
+ ON_BOUNDARY = 1,
+ OUT_OF_SURFACE = 2,
+};
+
+//=======================================================================
+//function : IsParallel
+//purpose : Checks if theLine is parallel of some boundary of given
+// surface (it is determined by theCheckSurf1 flag).
+// Parallelism assumes small oscillations (swing is less or
+// equal than theToler).
+// Small lines (if first and last parameters in the Surface
+// are almost equal) are classified as parallel (as same as
+// any point can be considered as parallel of any line).
+// ATTENTION!!!!
+// This function is same as in IntWalk_PWalking_1.gxx file.
+// If you change it, you should change and that function too.
+//=======================================================================
+static void IsParallel(const Handle(IntSurf_LineOn2S)& theLine,
+ const Standard_Boolean theCheckSurf1,
+ const Standard_Real theToler,
+ Standard_Boolean& theIsUparallel,
+ Standard_Boolean& theIsVparallel)
+{
+ const Standard_Integer aNbPointsMAX = 23;
+
+ theIsUparallel = theIsVparallel = Standard_True;
+
+ Standard_Integer aNbPoints = theLine->NbPoints();
+ if(aNbPoints > aNbPointsMAX)
+ {
+ aNbPoints = aNbPointsMAX;
+ }
+ else if(aNbPoints < 2)
+ {
+ //Here we cannot estimate of parallelism.
+ //Do all the same as for small lines
+ return;
+ }
+
+ Standard_Real aStep = IntToReal(theLine->NbPoints()) / aNbPoints;
+ Standard_Real aNPoint = 1.0;
+
+ Standard_Real aUmin = RealLast(), aUmax = RealFirst(), aVmin = RealLast(), aVmax = RealFirst();
+ for(Standard_Integer aNum = 1; aNum <= aNbPoints; aNum++, aNPoint += aStep)
+ {
+ if(aNPoint > aNbPoints)
+ {
+ aNPoint = aNbPoints;
+ }
+
+ Standard_Real u, v;
+ if(theCheckSurf1)
+ theLine->Value(RealToInt(aNPoint)).ParametersOnS1(u, v);
+ else
+ theLine->Value(RealToInt(aNPoint)).ParametersOnS2(u, v);
+
+ if(u < aUmin)
+ aUmin = u;
+
+ if(u > aUmax)
+ aUmax = u;
+
+ if(v < aVmin)
+ aVmin = v;
+
+ if(v > aVmax)
+ aVmax = v;
+ }
+
+ theIsVparallel = ((aUmax - aUmin) < theToler);
+ theIsUparallel = ((aVmax - aVmin) < theToler);
+}
+
+//=======================================================================
+//function : Checking
+//purpose : Check, if given point is in surface's boundaries.
+// If "yes" then theFactTol = 0.0, else theFactTol is
+// equal maximal deviation.
+// ATTENTION!!!!
+// This function is same as in IntWalk_IWalking_1.gxx file.
+// If you change it, you should change and that function too.
+//=======================================================================
+static Standard_Integer Checking(const Handle(Adaptor3d_HSurface)& theASurf1,
+ const Handle(Adaptor3d_HSurface)& theASurf2,
+ Standard_Real& theU1,
+ Standard_Real& theV1,
+ Standard_Real& theU2,
+ Standard_Real& theV2,
+ Standard_Real& theFactTolU,
+ Standard_Real& theFactTolV)
+{
+ const Standard_Real aTol = Min(theFactTolU, theFactTolV);
+ const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
+ const Standard_Real aU1bLast = theASurf1->LastUParameter();
+ const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
+ const Standard_Real aU2bLast = theASurf2->LastUParameter();
+ const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
+ const Standard_Real aV1bLast = theASurf1->LastVParameter();
+ const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
+ const Standard_Real aV2bLast = theASurf2->LastVParameter();
+
+ Standard_Integer aResult = EXACTLY_INTO;
+ theFactTolU = 0.0, theFactTolV = 0.0;
+
+ Standard_Real aDelta = aU1bFirst - theU1;
+ if(aDelta >= 0.0)
+ {
+ theU1 = aU1bFirst;
+
+ if(aDelta > aTol)
+ {
+ theFactTolU = Max(theFactTolU, aDelta);
+ aResult |= (Standard_Integer)OUT_OF_SURFACE;
+ }
+ else
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+ }
+ else if(Abs(aDelta) <= aTol)
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+
+ aDelta = theU1 - aU1bLast;
+ if(aDelta >= 0.0)
+ {
+ theU1 = aU1bLast;
+
+ if(aDelta > aTol)
+ {
+ theFactTolU = Max(theFactTolU, aDelta);
+ aResult |= (Standard_Integer)OUT_OF_SURFACE;
+ }
+ else
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+ }
+ else if(Abs(aDelta) <= aTol)
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+
+ aDelta = aV1bFirst - theV1;
+ if(aDelta >= 0.0)
+ {
+ theV1 = aV1bFirst;
+ if(aDelta > aTol)
+ {
+ theFactTolV = Max(theFactTolV, aDelta);
+ aResult |= (Standard_Integer)OUT_OF_SURFACE;
+ }
+ else
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+ }
+ else if(Abs(aDelta) <= aTol)
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+
+ aDelta = theV1 - aV1bLast;
+ if(aDelta >= 0.0)
+ {
+ theV1 = aV1bLast;
+
+ if(aDelta > aTol)
+ {
+ theFactTolV = Max(theFactTolV, aDelta);
+ aResult |= (Standard_Integer)OUT_OF_SURFACE;
+ }
+ else
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+ }
+ else if(Abs(aDelta) <= aTol)
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+
+ aDelta = aU2bFirst - theU2;
+ if(aDelta >= 0.0)
+ {
+ theU2 = aU2bFirst;
+ if(aDelta > aTol)
+ {
+ theFactTolU = Max(theFactTolU, aDelta);
+ aResult |= (Standard_Integer)OUT_OF_SURFACE;
+ }
+ else
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+ }
+ else if(Abs(aDelta) <= aTol)
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+
+ aDelta = theU2 - aU2bLast;
+ if(aDelta >= 0.0)
+ {
+ theU2 = aU2bLast;
+
+ if(aDelta > aTol)
+ {
+ theFactTolU = Max(theFactTolU, aDelta);
+ aResult |= (Standard_Integer)OUT_OF_SURFACE;
+ }
+ else
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+ }
+ else if(Abs(aDelta) <= aTol)
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+
+ aDelta = aV2bFirst - theV2;
+ if(aDelta >= 0.0)
+ {
+ theV2 = aV2bFirst;
+
+ if(aDelta > aTol)
+ {
+ theFactTolV = Max(theFactTolV, aDelta);
+ aResult |= (Standard_Integer)OUT_OF_SURFACE;
+ }
+ else
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+ }
+ else if(Abs(aDelta) <= aTol)
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+
+ aDelta = theV2 - aV2bLast;
+ if(aDelta >= 0.0)
+ {
+ theV2 = aV2bLast;
+
+ if(aDelta > aTol)
+ {
+ theFactTolV = Max(theFactTolV, aDelta);
+ aResult |= (Standard_Integer)OUT_OF_SURFACE;
+ }
+ else
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+ }
+ else if(Abs(aDelta) <= aTol)
+ {
+ aResult |= (Standard_Integer)ON_BOUNDARY;
+ }
+
+ if(aResult & OUT_OF_SURFACE)
+ {
+ aResult = OUT_OF_SURFACE;
+ }
+ else if(aResult & ON_BOUNDARY)
+ {
+ aResult = ON_BOUNDARY;
+ }
+
+ return aResult;
+}
+
+//=======================================================================
+//function : Constructor
+//purpose :
+//=======================================================================
IntWalk_IWalking::IntWalk_IWalking (const Standard_Real Epsilon,
const Standard_Real Deflection,
const Standard_Real Increment ) :
done = Standard_True;
}
+//=======================================================================
+//function : DistanceMinimizeByGradient
+//purpose : This function is same as in IntWalk_PWalking_1.gxx file.
+// If you change it, you should change and that function too.
+//=======================================================================
+Standard_Boolean IntWalk_IWalking::
+ DistanceMinimizeByGradient( const Handle(Adaptor3d_HSurface)& theASurf1,
+ const Handle(Adaptor3d_HSurface)& theASurf2,
+ Standard_Real& theU1,
+ Standard_Real& theV1,
+ Standard_Real& theU2,
+ Standard_Real& theV2,
+ const Bnd_Box2d& theBox1,
+ const Bnd_Box2d& theBox2,
+ const Standard_Real theStep0U1V1,
+ const Standard_Real theStep0U2V2)
+{
+ const Standard_Real aZeroTol = 1.0/Precision::Infinite();
+ const Standard_Integer aNbIterMAX = 60;
+ const Standard_Real aTol = 1.0e-14;
+ const Standard_Boolean hasCheckBounds = !(theBox1.IsVoid() || theBox2.IsVoid());
+ Standard_Boolean aStatus = Standard_False;
+
+ gp_Pnt aP1, aP2;
+ gp_Vec aD1u, aD1v, aD2U, aD2V;
+
+ theASurf1->D1(theU1, theV1, aP1, aD1u, aD1v);
+ theASurf2->D1(theU2, theV2, aP2, aD2U, aD2V);
+
+ Standard_Real aSQDistPrev = aP1.SquareDistance(aP2);
+
+ gp_Vec aP12(aP1, aP2);
+
+ Standard_Real aGradFu(-aP12.Dot(aD1u));
+ Standard_Real aGradFv(-aP12.Dot(aD1v));
+ Standard_Real aGradFU( aP12.Dot(aD2U));
+ Standard_Real aGradFV( aP12.Dot(aD2V));
+
+ if(Abs(aGradFu) <= aZeroTol)
+ aGradFu = 0.0;
+ if(Abs(aGradFv) <= aZeroTol)
+ aGradFv = 0.0;
+ if(Abs(aGradFU) <= aZeroTol)
+ aGradFU = 0.0;
+ if(Abs(aGradFV) <= aZeroTol)
+ aGradFV = 0.0;
+
+ Standard_Real aSTEPuv = theStep0U1V1, aStepUV = theStep0U2V2;
+
+ Standard_Boolean flRepeat = Standard_True;
+ Standard_Integer aNbIter = aNbIterMAX;
+
+ while(flRepeat)
+ {
+ Standard_Real anAdd = aGradFu*aSTEPuv;
+ Standard_Real aPARu = (anAdd >= 0.0)?
+ (theU1 - Max(anAdd, Epsilon(theU1))) :
+ (theU1 + Max(-anAdd, Epsilon(theU1)));
+ anAdd = aGradFv*aSTEPuv;
+ Standard_Real aPARv = (anAdd >= 0.0)?
+ (theV1 - Max(anAdd, Epsilon(theV1))) :
+ (theV1 + Max(-anAdd, Epsilon(theV1)));
+ anAdd = aGradFU*aStepUV;
+ Standard_Real aParU = (anAdd >= 0.0)?
+ (theU2 - Max(anAdd, Epsilon(theU2))) :
+ (theU2 + Max(-anAdd, Epsilon(theU2)));
+ anAdd = aGradFV*aStepUV;
+ Standard_Real aParV = (anAdd >= 0.0)?
+ (theV2 - Max(anAdd, Epsilon(theV2))) :
+ (theV2 + Max(-anAdd, Epsilon(theV2)));
+
+ if(hasCheckBounds)
+ {
+ Standard_Real aU1min = 0.0, aV1min = 0.0, aU1max = 0.0, aV1max = 0.0;
+ Standard_Real aU2min = 0.0, aV2min = 0.0, aU2max = 0.0, aV2max = 0.0;
+
+ theBox1.Get(aU1min, aV1min, aU1max, aV1max);
+ theBox2.Get(aU2min, aV2min, aU2max, aV2max);
+
+ if(aPARu < aU1min)
+ {
+ const Standard_Real aTTol = 100.0*(aU1max - aU1min);
+ if((aU1min - aPARu) < aTTol)
+ aPARu = aU1min;
+ }
+
+ if(aPARu > aU1max)
+ {
+ const Standard_Real aTTol = 100.0*(aU1max - aU1min);
+ if((aPARu - aU1max) < aTTol)
+ aPARu = aU1max;
+ }
+
+ if(aPARv < aV1min)
+ {
+ const Standard_Real aTTol = 100.0*(aV1max - aV1min);
+ if((aV1min - aPARv) < aTTol)
+ aPARv = aV1min;
+ }
+
+ if(aPARv > aV1max)
+ {
+ const Standard_Real aTTol = 100.0*(aV1max - aV1min);
+ if((aPARv - aV1max) < aTTol)
+ aPARv = aV1max;
+ }
+
+ if(aParU < aU2min)
+ {
+ const Standard_Real aTTol = 100.0*(aU2max - aU2min);
+ if((aU2min - aParU) < aTTol)
+ aParU = aU2min;
+ }
+
+ if(aParU > aU2max)
+ {
+ const Standard_Real aTTol = 100.0*(aU2max - aU2min);
+ if((aParU - aU2max) < aTTol)
+ aParU = aU2max;
+ }
+
+ if(aParV < aV2min)
+ {
+ const Standard_Real aTTol = 100.0*(aV2max - aV2min);
+ if((aV2min - aParV) < aTTol)
+ aParV = aV2min;
+ }
+
+ if(aParV > aV2max)
+ {
+ const Standard_Real aTTol = 100.0*(aV2max - aV2min);
+ if((aParV - aV2max) < aTTol)
+ aParV = aV2max;
+ }
+ }
+
+ gp_Pnt aPt1, aPt2;
+
+ theASurf1->D1(aPARu, aPARv, aPt1, aD1u, aD1v);
+ theASurf2->D1(aParU, aParV, aPt2, aD2U, aD2V);
+
+ Standard_Real aSQDist = aPt1.SquareDistance(aPt2);
+
+ if(aSQDist < aSQDistPrev)
+ {
+ aSQDistPrev = aSQDist;
+ theU1 = aPARu;
+ theV1 = aPARv;
+ theU2 = aParU;
+ theV2 = aParV;
+
+ if(Abs(theU1) < aZeroTol)
+ theU1 = 0.0;
+
+ if(Abs(theV1) < aZeroTol)
+ theV1 = 0.0;
+
+ if(Abs(theU2) < aZeroTol)
+ theU2 = 0.0;
+
+ if(Abs(theV2) < aZeroTol)
+ theV2 = 0.0;
+
+ aStatus = aSQDistPrev < aTol;
+ aSTEPuv *= 1.2;
+ aStepUV *= 1.2;
+ }
+ else
+ {
+ if(--aNbIter < 0)
+ {
+ flRepeat = Standard_False;
+ }
+ else
+ {
+ theASurf1->D1(theU1, theV1, aPt1, aD1u, aD1v);
+ theASurf2->D1(theU2, theV2, aPt2, aD2U, aD2V);
+
+ gp_Vec aP12(aPt1, aPt2);
+ aGradFu = -aP12.Dot(aD1u);
+ aGradFv = -aP12.Dot(aD1v);
+ aGradFU = aP12.Dot(aD2U);
+ aGradFV = aP12.Dot(aD2V);
+
+ if(Abs(aGradFu) <= aZeroTol)
+ aGradFu = 0.0;
+ if(Abs(aGradFv) <= aZeroTol)
+ aGradFv = 0.0;
+ if(Abs(aGradFU) <= aZeroTol)
+ aGradFU = 0.0;
+ if(Abs(aGradFV) <= aZeroTol)
+ aGradFV = 0.0;
+
+ aSTEPuv = theStep0U1V1;
+ aStepUV = theStep0U2V2;
+ }
+ }
+ }
+
+ return aStatus;
+}
+
+//=======================================================================
+//function : DistanceMinimizeByExtrema
+//purpose : This function is same as in IntWalk_PWalking_1.gxx file.
+// If you change it, you should change and that function too.
+//=======================================================================
+Standard_Boolean IntWalk_IWalking::
+ DistanceMinimizeByExtrema(const ThePSurface& theASurf,
+ const gp_Pnt& theP0,
+ Standard_Real& theU0,
+ Standard_Real& theV0,
+ const Standard_Real theStep0U,
+ const Standard_Real theStep0V)
+{
+ const Standard_Real aTol = 1.0e-14;
+ gp_Pnt aPS;
+ gp_Vec aD1Su, aD1Sv, aD2Su, aD2Sv, aD2SuvTemp;
+ Standard_Real aSQDistPrev = RealLast();
+ Standard_Real aU = theU0, aV = theV0;
+
+ Standard_Integer aNbIter = 10;
+ do
+ {
+ theASurf->D2(aU, aV, aPS, aD1Su, aD1Sv, aD2Su, aD2Sv, aD2SuvTemp);
+
+ gp_Vec aVec(theP0, aPS);
+
+ Standard_Real aSQDist = aVec.SquareMagnitude();
+
+ if(aSQDist >= aSQDistPrev)
+ break;
+
+ aSQDistPrev = aSQDist;
+ theU0 = aU;
+ theV0 = aV;
+ aNbIter--;
+
+ if(aSQDistPrev < aTol)
+ break;
+
+ //Functions
+ const Standard_Real aF1 = aD1Su.Dot(aVec), aF2 = aD1Sv.Dot(aVec);
+
+ //Derivatives
+ const Standard_Real aDf1u = aD2Su.Dot(aVec) + aD1Su.Dot(aD1Su),
+ aDf1v = aD2Su.Dot(aD1Sv),
+ aDf2u = aDf1v,
+ aDf2v = aD2Sv.Dot(aVec) + aD1Sv.Dot(aD1Sv);
+
+ const Standard_Real aDet = aDf1u*aDf2v - aDf1v*aDf2u;
+ aU -= theStep0U*(aDf2v*aF1 - aDf1v*aF2)/aDet;
+ aV += theStep0V*(aDf2u*aF1 - aDf1u*aF2)/aDet;
+ }
+ while(aNbIter > 0);
+
+ return (aSQDistPrev < aTol);
+}
+
+//=======================================================================
+//function : SeekPointOnBoundary
+//purpose : This function is same as in IntWalk_PWalking_1.gxx file.
+// If you change it, you should change and that function too.
+//=======================================================================
+Standard_Boolean IntWalk_IWalking::
+ SeekPointOnBoundary(const ThePSurface& theASurf1,
+ const ThePSurface& theASurf2,
+ const Standard_Real theU1,
+ const Standard_Real theV1,
+ const Standard_Real theU2,
+ const Standard_Real theV2,
+ const Standard_Boolean isTheFirst,
+ const Standard_Integer theNCurve,
+ const Standard_Integer theExtendingType,
+ const Standard_Real theParamTol)
+{
+ const Handle(IntSurf_LineOn2S)& line = lines.Value(theNCurve)->Line();
+
+ const Standard_Real aTol = 1.0e-14;
+ Standard_Real aRepetitionFactor = 1.0;
+ Standard_Boolean isOK = Standard_False;
+ Standard_Real U1prec = theU1, V1prec = theV1, U2prec = theU2, V2prec = theV2;
+
+ Standard_Real aU1Min = -Precision::Infinite(),
+ aU1Max = Precision::Infinite(),
+ aV1Min = -Precision::Infinite(),
+ aV1Max = Precision::Infinite();
+
+ Standard_Real aU2Min = -Precision::Infinite(),
+ aU2Max = Precision::Infinite(),
+ aV2Min = -Precision::Infinite(),
+ aV2Max = Precision::Infinite();
+ gp_Vec2d aDir1, aDir2;
+
+ if(isTheFirst)
+ {
+ Standard_Real u1prev = 0.0, v1prev = 0.0, u2prev = 0.0, v2prev = 0.0;
+ line->Value(1).Parameters(u1prev, v1prev, u2prev, v2prev);
+ aDir1 = gp_Vec2d(gp_Pnt2d(u1prev, v1prev), gp_Pnt2d(theU1, theV1));
+ aDir2 = gp_Vec2d(gp_Pnt2d(u2prev, v2prev), gp_Pnt2d(theU2, theV2));
+
+ Standard_Real u1 = 0.0, u2 = 0.0, v1 = 0.0, v2 = 0.0;
+ line->Value(2).Parameters(u1, v1, u2, v2);
+
+ if(u1 <= u1prev)
+ aU1Max = u1prev;
+ else
+ aU1Min = u1prev;
+
+ if(v1 <= v1prev)
+ aV1Max = v1prev;
+ else
+ aV1Min = v1prev;
+
+ if(u2 <= u2prev)
+ aU2Max = u2prev;
+ else
+ aU2Min = u2prev;
+
+ if(v2 <= v2prev)
+ aV2Max = v2prev;
+ else
+ aV2Min = v2prev;
+ }
+ else
+ {
+ Standard_Real u1prev = 0.0, v1prev = 0.0, u2prev = 0.0, v2prev = 0.0;
+ const Standard_Integer aNbPnts = line->NbPoints();
+ line->Value(aNbPnts).Parameters(u1prev, v1prev, u2prev, v2prev);
+ aDir1 = gp_Vec2d(gp_Pnt2d(u1prev, v1prev), gp_Pnt2d(theU1, theV1));
+ aDir2 = gp_Vec2d(gp_Pnt2d(u2prev, v2prev), gp_Pnt2d(theU2, theV2));
+
+ Standard_Real u1 = 0.0, u2 = 0.0, v1 = 0.0, v2 = 0.0;
+ line->Value(aNbPnts-1).Parameters(u1, v1, u2, v2);
+
+ if(u1 <= u1prev)
+ aU1Min = u1prev;
+ else
+ aU1Max = u1prev;
+
+ if(v1 <= v1prev)
+ aV1Min = v1prev;
+ else
+ aV1Max = v1prev;
+
+ if(u2 <= u2prev)
+ aU2Min = u2prev;
+ else
+ aU2Max = u2prev;
+
+ if(v2 <= v2prev)
+ aV2Min = v2prev;
+ else
+ aV2Max = v2prev;
+ }
+
+ //Into surface we allow walking in any direction.
+ if(!(theExtendingType & EXTEND_Udir_FOR_SURF1))
+ {
+ aDir1.SetX(0.0);
+ }
+ else
+ {
+ aU1Min = -Precision::Infinite();
+ aU1Max = Precision::Infinite();
+ }
+
+ if(!(theExtendingType & EXTEND_Vdir_FOR_SURF1))
+ {
+ aDir1.SetY(0.0);
+ }
+ else
+ {
+ aV1Min = -Precision::Infinite();
+ aV1Max = Precision::Infinite();
+ }
+
+ if(!(theExtendingType & EXTEND_Udir_FOR_SURF2))
+ {
+ aDir2.SetX(0.0);
+ }
+ else
+ {
+ aU2Min = -Precision::Infinite();
+ aU2Max = Precision::Infinite();
+ }
+
+ if(!(theExtendingType & EXTEND_Vdir_FOR_SURF2))
+ {
+ aDir2.SetY(0.0);
+ }
+ else
+ {
+ aV2Min = -Precision::Infinite();
+ aV2Max = Precision::Infinite();
+ }
+
+ Standard_Integer flFinish = OUT_OF_SURFACE;
+
+ Standard_Integer aNbIter = 20;
+ while(flFinish == OUT_OF_SURFACE)
+ {
+ flFinish = OUT_OF_SURFACE;
+ Standard_Boolean aStatus = Standard_False;
+
+ do
+ {
+ aNbIter--;
+
+ Bnd_Box2d aB1, aB2;
+ aB1.SetVoid();
+ aB2.SetVoid();
+
+ aStatus = DistanceMinimizeByGradient(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec, aB1, aB2);
+ if(aStatus)
+ {
+ break;
+ }
+
+ aStatus = DistanceMinimizeByExtrema(theASurf1, theASurf2->Value(U2prec, V2prec), U1prec, V1prec);
+ if(aStatus)
+ {
+ break;
+ }
+
+ aStatus = DistanceMinimizeByExtrema(theASurf2, theASurf1->Value(U1prec, V1prec), U2prec, V2prec);
+ if(aStatus)
+ {
+ break;
+ }
+ }
+ while(!aStatus && (aNbIter > 0));
+
+ if(aStatus)
+ {
+ const Standard_Real aResTol = 1.0e-4;
+ const Standard_Real aTolMaxU = 1.0e-8;
+ const Standard_Real aTolMaxV = 1.0e-8;
+ const Standard_Real aURes1 = theASurf1->UResolution(aResTol), aVRes1 = theASurf1->VResolution(aResTol);
+ const Standard_Real aURes2 = theASurf2->UResolution(aResTol), aVRes2 = theASurf2->VResolution(aResTol);
+
+ const Standard_Real aResTol1sq = aURes1*aURes1+aVRes1*aVRes1;
+ const Standard_Real aResTol2sq = aURes2*aURes2+aVRes2*aVRes2;
+
+ Standard_Real aTolU = aTolMaxU, aTolV = aTolMaxV;
+
+ Standard_Real u1 = U1prec, v1 = V1prec, u2 = U2prec, v2 = V2prec;
+
+ flFinish = Checking(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec, aTolU, aTolV);
+
+ if((aTolU <= aTolMaxU) && (aTolV <= aTolMaxV))
+ {
+ Standard_Boolean isAdded = Standard_False;
+ gp_Pnt aP1, aP2, aPInt;
+
+ gp_Pnt aPrevPoint;
+ if(isTheFirst)
+ {
+ aPrevPoint = lines.Value(theNCurve)->Value(1).Value();
+ }
+ else
+ {
+ const Standard_Integer aNbPoints = lines.Value(theNCurve)->NbPoints();
+ aPrevPoint = lines.Value(theNCurve)->Value(aNbPoints).Value();
+ }
+
+ if((flFinish == ON_BOUNDARY) || (flFinish == EXACTLY_INTO))
+ {
+ aP1 = theASurf1->Value(U1prec, V1prec);
+ aP2 = theASurf2->Value(U2prec, V2prec);
+ aPInt.SetXYZ(0.5*(aP1.XYZ() + aP2.XYZ()));
+
+ const Standard_Real aSQDist1 = aPInt.SquareDistance(aP1),
+ aSQDist2 = aPInt.SquareDistance(aP2);
+
+ if((aSQDist1 < aTol) && (aSQDist2 < aTol))
+ {
+ IntSurf_PntOn2S anIP;
+ anIP.SetValue(aPInt, U1prec, V1prec, U2prec, V2prec);
+
+ const Standard_Real aSQNeighborDist = aPInt.SquareDistance(aPrevPoint);
+
+ //Adding too remote point is dangerously
+ if((flFinish == ON_BOUNDARY) || (aSQNeighborDist < aResTol*aResTol))
+ {
+ if(isTheFirst)
+ {
+ line->InsertBefore(1,anIP);
+ isOK = Standard_True;
+ }
+ else
+ {
+ line->Add(anIP);
+ isOK = Standard_True;
+ }
+
+ isAdded = Standard_True;
+ }
+ }
+ }
+
+ if(!isAdded)
+ {
+ aP1 = theASurf1->Value(u1, v1);
+ aP2 = theASurf2->Value(u2, v2);
+ aPInt.SetXYZ(0.5*(aP1.XYZ() + aP2.XYZ()));
+
+ const Standard_Real aSQDist1 = aPInt.SquareDistance(aP1),
+ aSQDist2 = aPInt.SquareDistance(aP2);
+ if((aSQDist1 < aTol) && (aSQDist2 < aTol))
+ {
+ IntSurf_PntOn2S anIP;
+ anIP.SetValue(aPInt, u1, v1, u2, v2);
+
+ if(isTheFirst)
+ {
+ Standard_Real u1prev = 0.0, v1prev = 0.0, u2prev = 0.0, v2prev = 0.0;
+ line->Value(1).Parameters(u1prev, v1prev, u2prev, v2prev);
+ gp_Vec2d aVec1(gp_Pnt2d(u1prev, v1prev), gp_Pnt2d(u1, v1));
+ gp_Vec2d aVec2(gp_Pnt2d(u2prev, v2prev), gp_Pnt2d(u2, v2));
+
+ const Standard_Real aDotPr1 = aVec1.Dot(aDir1), aDotPr2 = aVec2.Dot(aDir2);
+
+ if( ((aDotPr1 >= 0.0) || (aVec1.SquareMagnitude() < aResTol1sq)) &&
+ ((aDotPr2 >= 0.0) || (aVec2.SquareMagnitude() < aResTol2sq)))
+ {//Direction is kept
+ line->InsertBefore(1,anIP);
+ isOK = Standard_True;
+ isAdded = Standard_True;
+ }
+ }
+ else
+ {
+ Standard_Real u1prev = 0.0, v1prev = 0.0, u2prev = 0.0, v2prev = 0.0;
+ const Standard_Integer aNbPoints = line->NbPoints();
+ line->Value(aNbPoints).Parameters(u1prev, v1prev, u2prev, v2prev);
+ gp_Vec2d aVec1(gp_Pnt2d(u1prev, v1prev), gp_Pnt2d(u1, v1));
+ gp_Vec2d aVec2(gp_Pnt2d(u2prev, v2prev), gp_Pnt2d(u2, v2));
+
+ const Standard_Real aDotPr1 = aVec1.Dot(aDir1), aDotPr2 = aVec2.Dot(aDir2);
+
+ if( ((aDotPr1 >= 0.0) || (aVec1.SquareMagnitude() < aResTol1sq)) &&
+ ((aDotPr2 >= 0.0) || (aVec2.SquareMagnitude() < aResTol2sq)))
+ {//Direction is kept
+ line->Add(anIP);
+ isOK = Standard_True;
+ isAdded = Standard_True;
+ }
+ }
+ }
+ }
+
+ if(flFinish == ON_BOUNDARY)
+ {
+ aRepetitionFactor = 1.0;
+ }
+ else
+ {
+ aRepetitionFactor *= 2.0;
+ }
+
+ if((flFinish != OUT_OF_SURFACE) && isAdded)
+ {//One more point into surface is found. We should try continue seeking.
+ Standard_Real aDelta = 0.0;
+ if((theU1 - theASurf1->FirstUParameter()) < -RealSmall())
+ {//U1prec were corrected
+ aDelta = Abs(theASurf1->FirstUParameter() - U1prec);
+
+ if(aDelta > aTolMaxU)
+ {
+ U1prec = theASurf1->FirstUParameter() - Min(aRepetitionFactor*aDelta, theParamTol);
+ flFinish = OUT_OF_SURFACE;
+ }
+ }
+
+ aDelta = 0.0;
+ if((theASurf1->LastUParameter() - theU1) < -RealSmall())
+ {//U1prec were corrected
+ aDelta = Abs(theASurf1->LastUParameter() - U1prec);
+
+ if(aDelta > aTolMaxU)
+ {
+ U1prec = theASurf1->LastUParameter() + Min(aRepetitionFactor*aDelta, theParamTol);
+ flFinish = OUT_OF_SURFACE;
+ }
+ }
+
+ aDelta = 0.0;
+ if((theV1 - theASurf1->FirstVParameter()) < -RealSmall())
+ {//V1prec were corrected
+ aDelta = Abs(theASurf1->FirstVParameter() - V1prec);
+
+ if(aDelta > aTolMaxV)
+ {
+ V1prec = theASurf1->FirstVParameter() - Min(aRepetitionFactor*aDelta, theParamTol);
+ flFinish = OUT_OF_SURFACE;
+ }
+ }
+
+ aDelta = 0.0;
+ if((theASurf1->LastVParameter() - theV1) < -RealSmall())
+ {//V1prec were corrected
+ aDelta = Abs(theASurf1->LastVParameter() - V1prec);
+
+ if(aDelta > aTolMaxV)
+ {
+ V1prec = theASurf1->LastVParameter() + Min(aRepetitionFactor*aDelta, theParamTol);
+ flFinish = OUT_OF_SURFACE;
+ }
+ }
+
+ aDelta = 0.0;
+ if((theU2 - theASurf2->FirstUParameter()) < -RealSmall())
+ {//U2prec were corrected
+ aDelta = Abs(theASurf2->FirstUParameter() - U2prec);
+
+ if(aDelta > aTolMaxU)
+ {
+ U2prec = theASurf2->FirstUParameter() - Min(aRepetitionFactor*aDelta, theParamTol);
+ flFinish = OUT_OF_SURFACE;
+ }
+ }
+
+ aDelta = 0.0;
+ if((theASurf2->LastUParameter() - theU2) < -RealSmall())
+ {//U2prec were corrected
+ aDelta = Abs(theASurf2->LastUParameter() - U2prec);
+
+ if(aDelta > aTolMaxU)
+ {
+ U2prec = theASurf2->LastUParameter() + Min(aRepetitionFactor*aDelta, theParamTol);
+ flFinish = OUT_OF_SURFACE;
+ }
+ }
+
+ aDelta = 0.0;
+ if((theV2 - theASurf2->FirstVParameter()) < -RealSmall())
+ {//V2prec were corrected
+ aDelta = Abs(theASurf2->FirstVParameter() - V2prec);
+
+ if(aDelta > aTolMaxV)
+ {
+ V2prec = theASurf2->FirstVParameter() - Min(aRepetitionFactor*aDelta, theParamTol);
+ flFinish = OUT_OF_SURFACE;
+ }
+ }
+
+ aDelta = 0.0;
+ if((theASurf2->LastVParameter() - theV2) < -RealSmall())
+ {//V2prec were corrected
+ aDelta = Abs(theASurf2->LastVParameter() - V2prec);
+
+ if(aDelta > aTolMaxV)
+ {
+ V2prec = theASurf2->LastVParameter() + Min(aRepetitionFactor*aDelta, theParamTol);
+ flFinish = OUT_OF_SURFACE;
+ }
+ }
+ }//if((flFinish != OUT_OF_SURFACE) && isAdded)
+ }
+ }
+ else
+ {
+ break;
+ }
+
+ if(aNbIter < 0)
+ break;
+ }
+
+ return isOK;
+}
+
+//=======================================================================
+//function : PutToBoundary
+//purpose : This function is same as in IntWalk_PWalking_1.gxx file.
+// If you change it, you should change and that function too.
+//=======================================================================
+Standard_Boolean IntWalk_IWalking::
+ PutToBoundary(const ThePSurface& theASurf1,
+ const ThePSurface& theASurf2,
+ const Standard_Integer theNCurve)
+{
+ //For periodic surfaces, point on boundary can have coordinate t and
+ //(t +/- T) in 2D-space (t is U or V-coordinate, in dependence from
+ //periodic direction, T is a period). Therefore, forcefully found
+ //point on boundary can change orientation of 2D-curve, what
+ //can be worse. By this cause, here we will not consider periodic
+ //surfaces. This case requires additional researching.
+
+ if(theASurf1->IsUPeriodic() || theASurf1->IsVPeriodic())
+ {
+ return Standard_False;
+ }
+
+ if(theASurf2->IsUPeriodic() || theASurf2->IsVPeriodic())
+ {
+ return Standard_False;
+ }
+
+ const Standard_Real aTolMin = Precision::Confusion();
+
+ Standard_Boolean hasBeenAdded = Standard_False;
+
+ const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
+ const Standard_Real aU1bLast = theASurf1->LastUParameter();
+ const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
+ const Standard_Real aU2bLast = theASurf2->LastUParameter();
+ const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
+ const Standard_Real aV1bLast = theASurf1->LastVParameter();
+ const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
+ const Standard_Real aV2bLast = theASurf2->LastVParameter();
+
+ Standard_Real aTol = 1.0;
+ aTol = Min(aTol, aU1bLast - aU1bFirst);
+ aTol = Min(aTol, aU2bLast - aU2bFirst);
+ aTol = Min(aTol, aV1bLast - aV1bFirst);
+ aTol = Min(aTol, aV2bLast - aV2bFirst)*0.1;
+
+ if(aTol <= 2.0*aTolMin)
+ return hasBeenAdded;
+
+ const Handle(IntSurf_LineOn2S)& line = lines.Value(theNCurve)->Line();
+
+ TypeOfExtending anExtType = IS_NOT_REQUIRED;
+ Standard_Boolean isU1parallel = Standard_False, isV1parallel = Standard_False;
+ Standard_Boolean isU2parallel = Standard_False, isV2parallel = Standard_False;
+ IsParallel(line, Standard_True, 0.01*aTol, isU1parallel, isV1parallel);
+ IsParallel(line, Standard_False, 0.01*aTol, isU2parallel, isV2parallel);
+
+ const Standard_Integer aNbPnts = line->NbPoints();
+ Standard_Real u1 = 0.0, v1 = 0.0, u2 = 0.0, v2 = 0.0;
+ Standard_Real u1prev = 0.0, v1prev = 0.0, u2prev = 0.0, v2prev = 0.0;
+
+ line->Value(1).Parameters(u1, v1, u2, v2);
+ if(aNbPnts >= 2)
+ {
+ line->Value(2).Parameters(u1prev, v1prev, u2prev, v2prev);
+ }
+ else
+ {
+ u1prev = u1;
+ v1prev = v1;
+ u2prev = u2;
+ v2prev = v2;
+ }
+
+ Standard_Real aDelta = 0.0;
+
+ if(!isV1parallel)
+ {
+ Standard_Boolean isCurveReversed = Standard_False;
+ if((aU1bLast - aU1bFirst) >= 2.0*u1)
+ {//u1 is nearer to aU1bFirst than to aU1bLast
+ aDelta = u1 - aU1bFirst;
+ isCurveReversed = Standard_False;
+ }
+ else
+ {//u1 is nearer to aU1bLast than to aU1bFirst
+ aDelta = aU1bLast - u1;
+ isCurveReversed = Standard_True;
+ }
+
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ Standard_Real u1old = u1;
+ if(isCurveReversed)
+ { // u1 should be extended to aU1bLast
+ u1 = aU1bLast + aDelta;
+ }
+ else
+ { // u1 should be extended to aU1bFirst
+ u1 = aU1bFirst - aDelta;
+ }
+
+ if((u1 - u1old)*(u1prev - u1old) < 0.0)
+ {//do extending
+ anExtType = (TypeOfExtending)((Standard_Integer)anExtType | (Standard_Integer)EXTEND_Udir_FOR_SURF1);
+ }
+ else
+ {//direction is changed. Extending is not required
+ u1 = u1old;
+ }
+ }
+ }
+
+ if(!isV2parallel)
+ {
+ Standard_Boolean isCurveReversed = Standard_False;
+ if((aU2bLast - aU2bFirst) >= 2.0*u2)
+ {//u2 is nearer to aU2bFirst than to aU2bLast
+ aDelta = u2 - aU2bFirst;
+ isCurveReversed = Standard_False;
+ }
+ else
+ {//u2 is nearer to aU2bLast than to aU2bFirst
+ aDelta = aU2bLast - u2;
+ isCurveReversed = Standard_True;
+ }
+
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ Standard_Real u2old = u2;
+ if(isCurveReversed)
+ { // u2 should be extended to aU2bLast
+ u2 = aU2bLast + aDelta;
+ }
+ else
+ { // u2 should be extended to aU2bFirst
+ u2 = aU2bFirst - aDelta;
+ }
+
+ if((u2 - u2old)*(u2prev - u2old) < 0.0)
+ {//do extending
+ anExtType = (TypeOfExtending)((Standard_Integer)anExtType | (Standard_Integer)EXTEND_Udir_FOR_SURF2);
+ }
+ else
+ {//direction is changed. Extending is not required
+ u2 = u2old;
+ }
+ }
+ }
+
+ if(!isU1parallel)
+ {
+ Standard_Boolean isCurveReversed = Standard_False;
+ if((aV1bLast - aV1bFirst) >= 2.0*v1)
+ {//v1 is nearer to aV1bFirst than to aV1bLast
+ aDelta = v1 - aV1bFirst;
+ isCurveReversed = Standard_False;
+ }
+ else
+ {//v1 is nearer to aV1bLast than to aV1bFirst
+ aDelta = aV1bLast - v1;
+ isCurveReversed = Standard_True;
+ }
+
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ Standard_Real v1old = v1;
+ if(isCurveReversed)
+ { // v1 should be extended to aV1bLast
+ v1 = aV1bLast + aDelta;
+ }
+ else
+ { // v1 should be extended to aV1bFirst
+ v1 = aV1bFirst - aDelta;
+ }
+
+ if((v1 - v1old)*(v1prev - v1old) < 0.0)
+ {//do extending
+ anExtType = (TypeOfExtending)((Standard_Integer)anExtType | (Standard_Integer)EXTEND_Vdir_FOR_SURF1);
+ }
+ else
+ {//direction is changed. Extending is not required
+ v1 = v1old;
+ }
+ }
+ }
+
+ if(!isU2parallel)
+ {
+ Standard_Boolean isCurveReversed = Standard_False;
+ if((aV2bLast - aV2bFirst) >= 2.0*v2)
+ {//v2 is nearer to aV2bFirst than to aV2bLast
+ aDelta = v2 - aV2bFirst;
+ isCurveReversed = Standard_False;
+ }
+ else
+ {//v2 is nearer to aV2bLast than to aV2bFirst
+ aDelta = aV2bLast - v2;
+ isCurveReversed = Standard_True;
+ }
+
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ Standard_Real v2old = v2;
+ if(isCurveReversed)
+ { // v2 should be extended to aV2bLast
+ v2 = aV2bLast + aDelta;
+ }
+ else
+ { // v2 should be extended to aV2bFirst
+ v2 = aV2bFirst - aDelta;
+ }
+
+ if((v2 - v2old)*(v2prev - v2old) < 0.0)
+ {//do extending
+ anExtType = (TypeOfExtending)((Standard_Integer)anExtType | (Standard_Integer)EXTEND_Vdir_FOR_SURF2);
+ }
+ else
+ {//direction is changed. Extending is not required
+ v2 = v2old;
+ }
+ }
+ }
+
+ if(anExtType != IS_NOT_REQUIRED)
+ {
+ hasBeenAdded =
+ SeekPointOnBoundary(theASurf1, theASurf2, u1,
+ v1, u2, v2, Standard_True, theNCurve, (Standard_Integer)anExtType,aTol);
+ }
+
+ anExtType = IS_NOT_REQUIRED;
+ line->Value(aNbPnts).Parameters(u1, v1, u2, v2);
+ if(aNbPnts >= 2)
+ {
+ line->Value(aNbPnts-1).Parameters(u1prev, v1prev, u2prev, v2prev);
+ }
+ else
+ {
+ u1prev = u1;
+ v1prev = v1;
+ u2prev = u2;
+ v2prev = v2;
+ }
+
+ if(!isV1parallel)
+ {
+ Standard_Boolean isCurveReversed = Standard_False;
+ if((aU1bLast - aU1bFirst) >= 2.0*u1)
+ {//u1 is nearer to aU1bFirst than to aU1bLast
+ aDelta = u1 - aU1bFirst;
+ isCurveReversed = Standard_False;
+ }
+ else
+ {//u1 is nearer to aU1bLast than to aU1bFirst
+ aDelta = aU1bLast - u1;
+ isCurveReversed = Standard_True;
+ }
+
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ Standard_Real u1old = u1;
+ if(isCurveReversed)
+ { // u1 should be extended to aU1bLast
+ u1 = aU1bLast + aDelta;
+ }
+ else
+ { // u1 should be extended to aU1bFirst
+ u1 = aU1bFirst - aDelta;
+ }
+
+ if((u1 - u1old)*(u1prev - u1old) < 0.0)
+ {//do extending
+ anExtType = (TypeOfExtending)((Standard_Integer)anExtType | (Standard_Integer)EXTEND_Udir_FOR_SURF1);
+ }
+ else
+ {//direction is changed. Extending is not required
+ u1 = u1old;
+ }
+ }
+ }
+
+ if(!isV2parallel)
+ {
+ Standard_Boolean isCurveReversed = Standard_False;
+ if((aU2bLast - aU2bFirst) >= 2.0*u2)
+ {//u2 is nearer to aU2bFirst than to aU2bLast
+ aDelta = u2 - aU2bFirst;
+ isCurveReversed = Standard_False;
+ }
+ else
+ {//u2 is nearer to aU2bLast than to aU2bFirst
+ aDelta = aU2bLast - u2;
+ isCurveReversed = Standard_True;
+ }
+
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ Standard_Real u2old = u2;
+ if(isCurveReversed)
+ { // u2 should be extended to aU2bLast
+ u2 = aU2bLast + aDelta;
+ }
+ else
+ { // u2 should be extended to aU2bFirst
+ u2 = aU2bFirst - aDelta;
+ }
+
+ if((u2 - u2old)*(u2prev - u2old) < 0.0)
+ {//do extending
+ anExtType = (TypeOfExtending)((Standard_Integer)anExtType | (Standard_Integer)EXTEND_Udir_FOR_SURF2);
+ }
+ else
+ {//direction is changed. Extending is not required
+ u2 = u2old;
+ }
+ }
+ }
+
+ if(!isU1parallel)
+ {
+ Standard_Boolean isCurveReversed = Standard_False;
+ if((aV1bLast - aV1bFirst) >= 2.0*v1)
+ {//v1 is nearer to aV1bFirst than to aV1bLast
+ aDelta = v1 - aV1bFirst;
+ isCurveReversed = Standard_False;
+ }
+ else
+ {//v1 is nearer to aV1bLast than to aV1bFirst
+ aDelta = aV1bLast - v1;
+ isCurveReversed = Standard_True;
+ }
+
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ Standard_Real v1old = v1;
+ if(isCurveReversed)
+ { // v1 should be extended to aV1bLast
+ v1 = aV1bLast + aDelta;
+ }
+ else
+ { // v1 should be extended to aV1bFirst
+ v1 = aV1bFirst - aDelta;
+ }
+
+ if((v1 - v1old)*(v1prev - v1old) < 0.0)
+ {//do extending
+ anExtType = (TypeOfExtending)((Standard_Integer)anExtType | (Standard_Integer)EXTEND_Vdir_FOR_SURF1);
+ }
+ else
+ {//direction is changed. Extending is not required
+ v1 = v1old;
+ }
+ }
+ }
+
+ if(!isU2parallel)
+ {
+ Standard_Boolean isCurveReversed = Standard_False;
+ if((aV2bLast - aV2bFirst) >= 2.0*v2)
+ {//v2 is nearer to aV2bFirst than to aV2bLast
+ aDelta = v2 - aV2bFirst;
+ isCurveReversed = Standard_False;
+ }
+ else
+ {//v2 is nearer to aV2bLast than to aV2bFirst
+ aDelta = aV2bLast - v2;
+ isCurveReversed = Standard_True;
+ }
+
+ if((aTolMin < aDelta) && (aDelta < aTol))
+ {
+ Standard_Real v2old = v2;
+ if(isCurveReversed)
+ { // v2 should be extended to aV2bLast
+ v2 = aV2bLast + aDelta;
+ }
+ else
+ { // v2 should be extended to aV2bFirst
+ v2 = aV2bFirst - aDelta;
+ }
+
+ if((v2 - v2old)*(v2prev - v2old) < 0.0)
+ {//do extending
+ anExtType = (TypeOfExtending)((Standard_Integer)anExtType | (Standard_Integer)EXTEND_Vdir_FOR_SURF2);
+ }
+ else
+ {//direction is changed. Extending is not required
+ v2 = v2old;
+ }
+ }
+ }
+
+ if(anExtType != IS_NOT_REQUIRED)
+ {
+ hasBeenAdded =
+ SeekPointOnBoundary(theASurf1, theASurf2, u1,
+ v1, u2, v2, Standard_False, theNCurve, (Standard_Integer)anExtType,aTol);
+ }
+
+ return hasBeenAdded;
+}
+
+//=======================================================================
+//function : SeekAdditionalPoints
+//purpose : This function is same as in IntWalk_PWalking_1.gxx file.
+// If you change it, you should change and that function too.
+//=======================================================================
+Standard_Boolean IntWalk_IWalking::
+ SeekAdditionalPoints( const ThePSurface& theASurf1,
+ const ThePSurface& theASurf2,
+ const Standard_Integer theMinNbPoints,
+ const Standard_Integer theNCurve)
+{
+ const Standard_Real aTol = 1.0e-14;
+ const Handle(IntSurf_LineOn2S)& line = lines.Value(theNCurve)->Line();
+
+ Standard_Integer aNbPoints = line->NbPoints();
+ if(aNbPoints >= theMinNbPoints)
+ return Standard_True;
+
+ const Standard_Real aU1bFirst = theASurf1->FirstUParameter();
+ const Standard_Real aU1bLast = theASurf1->LastUParameter();
+ const Standard_Real aU2bFirst = theASurf2->FirstUParameter();
+ const Standard_Real aU2bLast = theASurf2->LastUParameter();
+ const Standard_Real aV1bFirst = theASurf1->FirstVParameter();
+ const Standard_Real aV1bLast = theASurf1->LastVParameter();
+ const Standard_Real aV2bFirst = theASurf2->FirstVParameter();
+ const Standard_Real aV2bLast = theASurf2->LastVParameter();
+
+
+ Standard_Boolean isPrecise = Standard_False;
+
+ Standard_Real U1prec = 0.0, V1prec = 0.0, U2prec = 0.0, V2prec = 0.0;
+
+ Standard_Integer aNbPointsPrev = 0;
+ while(aNbPoints < theMinNbPoints && (aNbPoints != aNbPointsPrev))
+ {
+ aNbPointsPrev = aNbPoints;
+ for(Standard_Integer fp = 1, lp = 2; fp < aNbPoints; fp = lp + 1)
+ {
+ Standard_Real U1f, V1f, U2f, V2f; //first point in 1st and 2nd surafaces
+ Standard_Real U1l, V1l, U2l, V2l; //last point in 1st and 2nd surafaces
+
+ lp = fp+1;
+ line->Value(fp).Parameters(U1f, V1f, U2f, V2f);
+ line->Value(lp).Parameters(U1l, V1l, U2l, V2l);
+
+ U1prec = 0.5*(U1f+U1l);
+ if(U1prec < aU1bFirst)
+ U1prec = aU1bFirst;
+ if(U1prec > aU1bLast)
+ U1prec = aU1bLast;
+
+ V1prec = 0.5*(V1f+V1l);
+ if(V1prec < aV1bFirst)
+ V1prec = aV1bFirst;
+ if(V1prec > aV1bLast)
+ V1prec = aV1bLast;
+
+ U2prec = 0.5*(U2f+U2l);
+ if(U2prec < aU2bFirst)
+ U2prec = aU2bFirst;
+ if(U2prec > aU2bLast)
+ U2prec = aU2bLast;
+
+ V2prec = 0.5*(V2f+V2l);
+ if(V2prec < aV2bFirst)
+ V2prec = aV2bFirst;
+ if(V2prec > aV2bLast)
+ V2prec = aV2bLast;
+
+ Standard_Boolean aStatus = Standard_False;
+ Standard_Integer aNbIter = 5;
+ do
+ {
+ Bnd_Box2d aB1, aB2;
+ aB1.SetVoid();
+ aB2.SetVoid();
+
+ aB1.Add(gp_Pnt2d(U1f, V1f));
+ aB1.Add(gp_Pnt2d(U1l, V1l));
+ aB2.Add(gp_Pnt2d(U2f, V2f));
+ aB2.Add(gp_Pnt2d(U2l, V2l));
+
+ aStatus = DistanceMinimizeByGradient(theASurf1, theASurf2, U1prec, V1prec, U2prec, V2prec, aB1, aB2);
+ if(aStatus)
+ {
+ break;
+ }
+
+ aStatus = DistanceMinimizeByExtrema(theASurf1, theASurf2->Value(U2prec, V2prec), U1prec, V1prec);
+ if(aStatus)
+ {
+ break;
+ }
+
+ aStatus = DistanceMinimizeByExtrema(theASurf2, theASurf1->Value(U1prec, V1prec), U2prec, V2prec);
+ if(aStatus)
+ {
+ break;
+ }
+ }
+ while(!aStatus && (--aNbIter > 0));
+
+ //if((U1prec-U1f)*(U1l-U1prec) < 0.0)
+ // aStatus = Standard_False;
+
+ //if((U2prec-U2f)*(U2l-U2prec) < 0.0)
+ // aStatus = Standard_False;
+
+ //if((V1prec-V1f)*(V1l-V1prec) < 0.0)
+ // aStatus = Standard_False;
+
+ //if((V2prec-V2f)*(V2l-V2prec) < 0.0)
+ // aStatus = Standard_False;
+
+ if(aStatus)
+ {
+ gp_Pnt aP1 = theASurf1->Value(U1prec, V1prec),
+ aP2 = theASurf2->Value(U2prec, V2prec);
+ gp_Pnt aPInt(0.5*(aP1.XYZ() + aP2.XYZ()));
+
+ const Standard_Real aSQDist1 = aPInt.SquareDistance(aP1),
+ aSQDist2 = aPInt.SquareDistance(aP2);
+
+ if((aSQDist1 < aTol) && (aSQDist2 < aTol))
+ {
+ IntSurf_PntOn2S anIP;
+ anIP.SetValue(aPInt, U1prec, V1prec, U2prec, V2prec);
+ line->InsertBefore(lp, anIP);
+
+ isPrecise = Standard_True;
+
+ aNbPoints = line->NbPoints();
+ if(aNbPoints >= theMinNbPoints)
+ break;
+ }
+ else
+ {
+ lp--;
+ }
+ }
+ }
+ }
+
+ return isPrecise;
+}