#include <IntSurf_PntOn2S.hxx>
#include <IntSurf_LineOn2S.hxx>
#include <IntSurf.hxx>
+#include <IntSurf_InteriorPoint.hxx>
#include <Adaptor2d_HCurve2d.hxx>
#include <IntSurf_PathPoint.hxx>
#include <IntPatch_WLine.hxx>
#include <IntPatch_ArcFunction.hxx>
#include <IntPatch_RstInt.hxx>
-#ifndef DEB
+#ifndef OCCT_DEBUG
#define No_Standard_RangeError
#define No_Standard_OutOfRange
#endif
-
#include <math_Vector.hxx>
#include <math_Matrix.hxx>
#include <TopTrans_CurveTransition.hxx>
#include <IntSurf_SequenceOfInteriorPoint.hxx>
#include <IntSurf_QuadricTool.hxx>
#include <GeomAbs_SurfaceType.hxx>
+#include <IntAna2d_AnaIntersection.hxx>
+#include <gp_Lin2d.hxx>
+#include <ElCLib.hxx>
+
+#include <Bnd_Box2d.hxx>
+#include <IntPatch_PointLine.hxx>
static Standard_Boolean DecomposeResult(const Handle(IntPatch_Line)& Line,
const Standard_Boolean IsReversed,
Standard_Real U2,
Standard_Real V2);
+static Standard_Boolean IsIn2DBox(const Bnd_Box2d& theBox,
+ const Handle(IntPatch_PointLine)& theLine,
+ const Standard_Real theUPeriod,
+ const Standard_Real theVPeriod,
+ const Standard_Boolean isTheSurface1Using);
+
//=======================================================================
//function : IntPatch_ImpPrmIntersection
//purpose :
const Standard_Real Pas)
{
Standard_Boolean reversed, procf, procl, dofirst, dolast;
- Standard_Integer indfirst = 0, indlast = 0, ind2, i,j,k, NbSegm;
+ Standard_Integer indfirst = 0, indlast = 0, ind2, NbSegm;
Standard_Integer NbPointIns, NbPointRst, Nblines, Nbpts, NbPointDep;
Standard_Real U1,V1,U2,V2,paramf,paraml,currentparam;
}
}
//
- // Recherche des points interieurs
- if (!reversed) {
- if (myIsStartPnt)
- solins.Perform(Func,Surf2,myUStart,myVStart);
+ Standard_Boolean SearchIns = Standard_True;
+ if(Quad.TypeQuadric() == GeomAbs_Plane && solrst.NbSegments() > 0)
+ {
+ //For such kind of cases it is possible that whole surface is on one side of plane,
+ //plane only touches surface and does not cross it,
+ //so no inner points exist.
+ SearchIns = Standard_False;
+ Handle(Adaptor3d_TopolTool) T;
+ if(reversed)
+ {
+ T = D1;
+ }
else
- solins.Perform(Func,Surf2,D2,TolTang);
+ {
+ T = D2;
+ }
+ Standard_Integer aNbSamples = 0;
+ aNbSamples = T->NbSamples();
+ gp_Pnt2d s2d;
+ gp_Pnt s3d;
+ Standard_Real aValf[1], aUVap[2];
+ math_Vector Valf(aValf,1,1), UVap(aUVap,1,2);
+ T->SamplePoint(1,s2d, s3d);
+ UVap(1)=s2d.X();
+ UVap(2)=s2d.Y();
+ Func.Value(UVap,Valf);
+ Standard_Real rvalf = Sign(1.,Valf(1));
+ for(Standard_Integer i = 2; i <= aNbSamples; ++i)
+ {
+ T->SamplePoint(i,s2d, s3d);
+ UVap(1)=s2d.X();
+ UVap(2)=s2d.Y();
+ Func.Value(UVap,Valf);
+ if(rvalf * Valf(1) < 0.)
+ {
+ SearchIns = Standard_True;
+ break;
+ }
+ }
}
- else {
- if (myIsStartPnt)
- solins.Perform(Func,Surf1,myUStart,myVStart);
- else
- solins.Perform(Func,Surf1,D1,TolTang);
+ // Recherche des points interieurs
+ NbPointIns = 0;
+ if(SearchIns) {
+ 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 (Standard_Integer 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) {
}
//
Nblines = iwalk.NbLines();
- for (j=1; j<=Nblines; j++) {
+ for (Standard_Integer 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) {
-
+ Standard_Integer k = 0;
tgline = iwline->TangentVector(k);
if(k>=1 && k<=Nbpts) { } else { k=Nbpts>>1; }
valpt = thelin->Value(k).Value();
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;
+ && iwline->IsTangentAtBegining() == Standard_False)
+ {
+ indfirst = iwline->FirstPointIndex();
+ PPoint = seqpdep(indfirst);
+ tgline = PPoint.Direction3d();
+ Standard_Integer themult = PPoint.Multiplicity();
+ for (Standard_Integer 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);
- PPoint.Parameters(themult,U1,V1);
- Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@
- }
+ if((V2 < Vmin) && (Vmin-V2 < TolV)) V2 = Vmin;
+ if((V2 > Vmax) && (V2-Vmax < TolV)) V2 = Vmax;
- 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.);
+ PPoint.Parameters(themult,U1,V1);
+ Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@
+ }
- Recadre(reversed,typeS1,typeS2,ptdeb,iwline,1,U1,V1,U2,V2);
+ 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.);
- currentarc = solrst.Point(i).Arc();
- currentparam = solrst.Point(i).Parameter();
- currentarc->D1(currentparam,p2d,d2d);
- tgrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+ Recadre(reversed,typeS1,typeS2,ptdeb,iwline,1,U1,V1,U2,V2);
- 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);
- }
+ currentarc = solrst.Point(i).Arc();
+ currentparam = solrst.Point(i).Parameter();
+ currentarc->D1(currentparam,p2d,d2d);
+ tgrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
- 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());
- }
+ 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);
+ }
- themult--;
+ 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()) {
+ else if (iwline->IsTangentAtBegining())
+ {
gp_Pnt psol = thelin->Value(1).Value();
thelin->Value(1).ParametersOnS1(U1,V1);
thelin->Value(1).ParametersOnS2(U2,V2);
wline->AddVertex(ptdeb);
wline->SetFirstPoint(wline->NbVertex());
}
- else {
+ else
+ {
gp_Pnt psol = thelin->Value(1).Value();
thelin->Value(1).ParametersOnS1(U1,V1);
thelin->Value(1).ParametersOnS2(U2,V2);
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;
+ && iwline->IsTangentAtEnd() == Standard_False)
+ {
+ indlast = iwline->LastPointIndex();
+ PPoint = seqpdep(indlast);
+ tgline = PPoint.Direction3d().Reversed();
+ Standard_Integer themult = PPoint.Multiplicity();
+ for (Standard_Integer 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);
- PPoint.Parameters(themult,U1,V1);
- Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@
- VecNormale = d1u.Crossed(d1v); //-- @@@@
- }
+ if((V2 < Vmin) && (Vmin-V2 < TolV)) V2 = Vmin;
+ if((V2 > Vmax) && (V2-Vmax < TolV)) V2 = Vmax;
- ptfin.SetValue(PPoint.Value(),TolArc,Standard_False);
- ptfin.SetParameters(U1,V1,U2,V2);
- ptfin.SetParameter(Nbpts);
+ PPoint.Parameters(themult,U1,V1);
+ Surf1->D1(U1,V1,ptbid,d1u,d1v); //-- @@@@
+ VecNormale = d1u.Crossed(d1v); //-- @@@@
+ }
- Recadre(reversed,typeS1,typeS2,ptfin,iwline,Nbpts-1,U1,V1,U2,V2);
+ ptfin.SetValue(PPoint.Value(),TolArc,Standard_False);
+ ptfin.SetParameters(U1,V1,U2,V2);
+ ptfin.SetParameter(Nbpts);
- currentarc = solrst.Point(i).Arc();
- currentparam = solrst.Point(i).Parameter();
- currentarc->D1(currentparam,p2d,d2d);
- tgrst.SetLinearForm(d2d.X(),d1u,d2d.Y(),d1v);
+ 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);
- }
+ 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--;
+ 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()) {
+ else if (iwline->IsTangentAtEnd())
+ {
gp_Pnt psol = thelin->Value(Nbpts).Value();
thelin->Value(Nbpts).ParametersOnS1(U1,V1);
thelin->Value(Nbpts).ParametersOnS2(U2,V2);
wline->AddVertex(ptfin);
wline->SetLastPoint(wline->NbVertex());
}
- else {
+ else
+ {
gp_Pnt psol = thelin->Value(Nbpts).Value();
thelin->Value(Nbpts).ParametersOnS1(U1,V1);
thelin->Value(Nbpts).ParametersOnS2(U2,V2);
Nblines = slin.Length();
- for (j=1; j<=Nblines-1; j++) {
+ for (Standard_Integer j=1; j<=Nblines-1; j++) {
dofirst = dolast = Standard_False;
const Handle(IntPatch_Line)& slinj = slin(j);
- const Handle(IntPatch_WLine)& wlin1 = *((Handle(IntPatch_WLine)*)&slinj);
+ Handle(IntPatch_WLine) wlin1 (Handle(IntPatch_WLine)::DownCast (slinj));
if (wlin1->HasFirstPoint()) {
ptdeb = wlin1->FirstPoint(indfirst);
if (ptdeb.IsTangencyPoint()) {
}
if (dofirst || dolast) {
- for (k=j+1; k<=Nblines;k++) {
+ for (Standard_Integer k=j+1; k<=Nblines;k++) {
const Handle(IntPatch_Line)& slink = slin(k);
- const Handle(IntPatch_WLine)& wlin2 = *((Handle(IntPatch_WLine)*)&slink);
+ Handle(IntPatch_WLine) wlin2 (Handle(IntPatch_WLine)::DownCast (slink));
if (wlin2->HasFirstPoint()) {
ptbis = wlin2->FirstPoint(ind2);
if (ptbis.IsTangencyPoint()) {
// Treatment the segments
NbSegm = solrst.NbSegments();
if (NbSegm) {
- for(i=1; i<=NbSegm; i++) {
+ for(Standard_Integer i=1; i<=NbSegm; i++) {
thesegm = solrst.Segment(i);
+ //Check if segment is degenerated
+ if(thesegm.HasFirstPoint() && thesegm.HasLastPoint())
+ {
+ Standard_Real tol2 = Precision::Confusion();
+ tol2 *= tol2;
+ const gp_Pnt& aPf = thesegm.FirstPoint().Value();
+ const gp_Pnt& aPl = thesegm.LastPoint().Value();
+ if(aPf.SquareDistance(aPl) <= tol2)
+ {
+ //segment can be degenerated - check inner point
+ paramf = thesegm.FirstPoint().Parameter();
+ paraml = thesegm.LastPoint().Parameter();
+ gp_Pnt2d _p2d =
+ thesegm.Curve()->Value(.57735 * paramf + 0.42265 * paraml);
+ gp_Pnt aPm;
+ if(reversed)
+ {
+ Surf1->D0(_p2d.X(), _p2d.Y(), aPm);
+ }
+ else
+ {
+ Surf2->D0(_p2d.X(), _p2d.Y(), aPm);
+ }
+ if(aPm.SquareDistance(aPf) <= tol2)
+ {
+ //Degenerated
+ continue;
+ }
+ }
+ }
+
+
//----------------------------------------------------------------------
// on cree une ligne d intersection contenant uniquement le segment.
// VOIR POUR LA TRANSITION DE LA LIGNE
Standard_Integer nbsample = 100;
if (!reversed) {
- for (j=1; j<=nbsample; j++) {
+ for (Standard_Integer j=1; j<=nbsample; j++) {
prm = paramf + (j-1)*(paraml-paramf)/(nbsample-1);
arcsegm->D0(prm,p2d);
Surf2->D0(p2d.X(),p2d.Y(),ptpoly);
}
}
else {
- for (j=1; j<=nbsample; j++) {
+ for (Standard_Integer j=1; j<=nbsample; j++) {
prm = paramf + (j-1)*(paraml-paramf)/(nbsample-1);
arcsegm->D0(prm,p2d);
Surf1->D0(p2d.X(),p2d.Y(),ptpoly);
if (dofirst || dolast) {
Nblines = slin.Length();
- for (j=1; j<=Nblines; j++) {
+ for (Standard_Integer 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();
+ Nbpts = Handle(IntPatch_WLine)::DownCast (slinj)->NbVertex();
}
else {
- Nbpts = (*((Handle(IntPatch_RLine)*)&slinj))->NbVertex();
+ Nbpts = Handle(IntPatch_RLine)::DownCast (slinj)->NbVertex();
}
- for (k=1; k<=Nbpts;k++) {
+ for (Standard_Integer k=1; k<=Nbpts;k++) {
if (typ == IntPatch_Walking) {
- ptdeb = (*((Handle(IntPatch_WLine)*)&slinj))->Vertex(k);
+ ptdeb = Handle(IntPatch_WLine)::DownCast (slinj)->Vertex(k);
}
else {
- ptdeb = (*((Handle(IntPatch_RLine)*)&slinj))->Vertex(k);
+ ptdeb = Handle(IntPatch_RLine)::DownCast (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);
+ Handle(IntPatch_WLine)::DownCast (slinj)->Replace(k,ptdeb);
}
else {
- (*((Handle(IntPatch_RLine)*)&slinj))->Replace(k,ptdeb);
+ Handle(IntPatch_RLine)::DownCast (slinj)->Replace(k,ptdeb);
}
ptdeb.SetParameter(paramf);
rline->AddVertex(ptdeb);
if (dolast) {
if(dofirst) { //-- on recharge le ptdeb
if (typ == IntPatch_Walking) {
- ptdeb = (*((Handle(IntPatch_WLine)*)&slinj))->Vertex(k);
+ ptdeb = Handle(IntPatch_WLine)::DownCast (slinj)->Vertex(k);
}
else {
- ptdeb = (*((Handle(IntPatch_RLine)*)&slinj))->Vertex(k);
+ ptdeb = Handle(IntPatch_RLine)::DownCast (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);
+ Handle(IntPatch_WLine)::DownCast (slinj)->Replace(k,ptdeb);
}
else {
- (*((Handle(IntPatch_RLine)*)&slinj))->Replace(k,ptdeb);
+ Handle(IntPatch_RLine)::DownCast (slinj)->Replace(k,ptdeb);
}
ptdeb.SetParameter(paraml);
rline->AddVertex(ptdeb);
}// if (NbSegm)
//
// on traite les restrictions de la surface implicite
- for (i=1; i<=slin.Length(); i++)
+ for (Standard_Integer i=1; i<=slin.Length(); i++)
{
+ Handle(IntPatch_Line)& aL = slin(i);
+
if (!reversed)
- IntPatch_RstInt::PutVertexOnLine(slin(i),Surf1,D1,Surf2,Standard_True,TolTang);
+ IntPatch_RstInt::PutVertexOnLine(aL,Surf1,D1,Surf2,Standard_True,TolTang);
else
- IntPatch_RstInt::PutVertexOnLine(slin(i),Surf2,D2,Surf1,Standard_False,TolTang);
+ IntPatch_RstInt::PutVertexOnLine(aL,Surf2,D2,Surf1,Standard_False,TolTang);
+ }
+
+ const Standard_Real aUPeriodOfSurf1 = Surf1->IsUPeriodic() ? Surf1->UPeriod() : 0.0,
+ aUPeriodOfSurf2 = Surf2->IsUPeriodic() ? Surf2->UPeriod() : 0.0,
+ aVPeriodOfSurf1 = Surf1->IsVPeriodic() ? Surf1->VPeriod() : 0.0,
+ aVPeriodOfSurf2 = Surf2->IsVPeriodic() ? Surf2->VPeriod() : 0.0;
+
+ for (Standard_Integer i = 1; i <= slin.Length(); i++)
+ {
+ //BndBox of the points in Restriction line
+ Bnd_Box2d aBRL;
+ for(Standard_Integer j = i + 1; j <= slin.Length(); j++)
+ {
+ Handle(IntPatch_PointLine) aL1 = Handle(IntPatch_PointLine)::DownCast(slin(i));
+ Handle(IntPatch_PointLine) aL2 = Handle(IntPatch_PointLine)::DownCast(slin(j));
+
+ Handle(IntPatch_RLine) aRL1 = Handle(IntPatch_RLine)::DownCast(aL1);
+ Handle(IntPatch_RLine) aRL2 = Handle(IntPatch_RLine)::DownCast(aL2);
+
+ if(aRL1.IsNull() && aRL2.IsNull())
+ {//If Walking-Walking
+ continue;
+ }
+ else if(aRL1.IsNull())
+ {// i-th line is not restriction,
+ // but j-th is restriction
+ slin.Append(aL1);
+ slin.SetValue(i, aL2);
+ slin.Remove(j);
+ j--;
+ continue;
+ }
+
+ //Here aL1 (i-th line) is Restriction-line and aL2 (j-th line) is not Restriction
+
+ if(aBRL.IsVoid())
+ {//Fill aBRL
+ for(Standard_Integer aPRID = 1; aPRID <= aRL1->NbPnts(); aPRID++)
+ {
+ Standard_Real u = 0.0, v = 0.0;
+ if(reversed)
+ aRL1->Point(aPRID).ParametersOnS1(u, v);
+ else
+ aRL1->Point(aPRID).ParametersOnS2(u, v);
+
+ aBRL.Add(gp_Pnt2d(u, v));
+ }
+
+ Standard_Real aXmin = 0.0, aYmin = 0.0, aXMax = 0.0, aYMax = 0.0;
+ aBRL.Get(aXmin, aYmin, aXMax, aYMax);
+ const Standard_Real aDX = aXMax - aXmin,
+ aDY = aYMax - aYmin;
+
+ const Standard_Real aTolU = reversed? Surf1->UResolution(TolArc) : Surf2->UResolution(TolArc);
+ const Standard_Real aTolV = reversed? Surf1->VResolution(TolArc) : Surf2->VResolution(TolArc);
+
+ if((aDX > aTolU) && (aDY > aTolV))
+ {//Delete restriction line because it is not isoline.
+ slin.Remove(i);
+ i--;
+ break;
+ }
+
+ aXmin -= aTolU;
+ aXMax += aTolU;
+ aYmin -= aTolV;
+ aYMax += aTolV;
+ aBRL.SetVoid();
+ aBRL.Update(aXmin, aYmin, aXMax, aYMax);
+ }
+
+ const Standard_Boolean isCoincide = IsIn2DBox(aBRL, aL2,
+ (reversed? aUPeriodOfSurf1 : aUPeriodOfSurf2),
+ (reversed? aVPeriodOfSurf1 : aVPeriodOfSurf2), reversed);
+
+ if(isCoincide)
+ {//Delete Walking-line
+ slin.Remove(j);
+ j--;
+ }
+ }
}
+
empt = (slin.Length() == 0 && spnt.Length() == 0);
done = Standard_True;
-
-
- // post processing for cones and spheres
+
if(slin.Length() == 0)
return;
if(!isDecomposeRequired)
return;
+ // post processing for cones and spheres
+
const Handle(Adaptor3d_TopolTool)& PDomain = (reversed) ? D1 : D2;
const Handle(Adaptor3d_HSurface)& aQSurf = (reversed) ? Surf2 : Surf1;
IntPatch_SequenceOfLine dslin;
Standard_Boolean isDecompose = Standard_False;
- for(i = 1; i <= slin.Length(); i++ )
+ for(Standard_Integer i = 1; i <= slin.Length(); i++ )
{
if(DecomposeResult(slin(i),reversed,Quad,PDomain,aQSurf,TolArc,dslin))
{
return;
slin.Clear();
- for(i = 1; i <= dslin.Length(); i++ )
+ for(Standard_Integer i = 1; i <= dslin.Length(); i++ )
slin.Append(dslin(i));
}
}
static void ForcedPurgePoints(const Handle(IntSurf_LineOn2S)& Result,
- const Standard_Boolean IsReversed,
- const IntSurf_Quadric& Quad)
+ const Standard_Boolean IsReversed,
+ const IntSurf_Quadric& Quad)
{
if(Result->NbPoints() <= 30) return;
Standard_Integer Index = 0, IndexLimF = 8, IndexLimL = 8;
}
static void ToSmooth( const Handle(IntSurf_LineOn2S)& Line,
- const Standard_Boolean IsReversed,
- const IntSurf_Quadric& Quad,
- const Standard_Boolean IsFirst,
- Standard_Real& D3D)
+ const Standard_Boolean IsReversed,
+ const IntSurf_Quadric& Quad,
+ const Standard_Boolean IsFirst,
+ Standard_Real& D3D)
{
if(Line->NbPoints() <= 10)
return;
}
static Standard_Boolean TestMiddleOnPrm(const IntSurf_PntOn2S& aP,
- const IntSurf_PntOn2S& aV,
- const Standard_Boolean IsReversed,
- const Standard_Real ArcTol,
- const Handle(Adaptor3d_TopolTool)& PDomain)
+ const IntSurf_PntOn2S& aV,
+ const Standard_Boolean IsReversed,
+ const Standard_Real ArcTol,
+ const Handle(Adaptor3d_TopolTool)& PDomain)
{
Standard_Boolean result = Standard_False;
}
static void VerifyVertices( const Handle(IntSurf_LineOn2S)& Line,
- const Standard_Boolean IsReversed,
- const Handle(IntSurf_LineOn2S)& Vertices,
- const Standard_Real TOL2D,
- const Standard_Real ArcTol,
- const Handle(Adaptor3d_TopolTool)& PDomain,
- IntSurf_PntOn2S& VrtF,
- Standard_Boolean& AddFirst,
- IntSurf_PntOn2S& VrtL,
- Standard_Boolean& AddLast)
+ const Standard_Boolean IsReversed,
+ const Handle(IntSurf_LineOn2S)& Vertices,
+ const Standard_Real TOL2D,
+ const Standard_Real ArcTol,
+ const Handle(Adaptor3d_TopolTool)& PDomain,
+ 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(nbp < 3)
return;
- Handle(IntPatch_WLine)& WLine = (*((Handle(IntPatch_WLine)*)&Line));
+ Handle(IntPatch_WLine)& WLine = Handle(IntPatch_WLine)::DownCast (Line);
Standard_Integer ip = 0, iv = 0;
gp_Pnt aPnt;
IntPatch_Point thePnt;
return Standard_False;
}
- const Handle(IntPatch_WLine)& aWLine = (*((Handle(IntPatch_WLine)*)&theLine));
+ Handle(IntPatch_WLine) aWLine (Handle(IntPatch_WLine)::DownCast (theLine));
const Handle(IntSurf_LineOn2S)& aSLine = aWLine->Curve();
if(aSLine->NbPoints() <= 2)
// build WLine parts (if any)
Standard_Boolean flNextLine = Standard_True;
Standard_Boolean hasBeenDecomposed = Standard_False;
+ Standard_Boolean PrePointExist = Standard_False;
+ IntSurf_PntOn2S PrePoint;
while(flNextLine)
{
// reset variables
//if((Lindex-Findex+1) <= 2 )
if(aLindex <= aFindex)
return hasBeenDecomposed;
+
+ if (PrePointExist)
+ {
+ sline->Add(PrePoint);
+ PrePointExist = Standard_False;
+ }
// analyze other points
for(Standard_Integer k = aFindex; k <= aLindex; k++)
}
sline->Add(aSSLine->Value(k));
+ PrePoint = aSSLine->Value(k);
continue;
}
{
aBindex = k;
isDecomposited = Standard_True;
+ ////
+ if (Abs(U1) <= Precision::PConfusion() ||
+ Abs(U1 - 2*M_PI) <= Precision::PConfusion())
+ {
+ IntSurf_PntOn2S NewPoint;
+ IntSurf_PntOn2S CurPoint = aSSLine->Value(k);
+ gp_Pnt thePnt = CurPoint.Value();
+ Standard_Real theU1, theV1, theU2, theV2;
+ theU1 = (Abs(U1) <= Precision::PConfusion())? 2*M_PI : 0.;
+ theV1 = V1;
+ NewPoint.SetValue(thePnt);
+ if (!IsReversed)
+ {
+ CurPoint.ParametersOnS2(theU2, theV2);
+ NewPoint.SetValue(theU1, theV1, theU2, theV2);
+ }
+ else
+ {
+ CurPoint.ParametersOnS1(theU2, theV2);
+ NewPoint.SetValue(theU2, theV2, theU1, theV1);
+ }
+ sline->Add(NewPoint);
+ }
+ else if (Abs(AnU1) <= Precision::PConfusion() ||
+ Abs(AnU1 - 2*M_PI) <= Precision::PConfusion())
+ {
+ //Modify <PrePoint>
+ PrePointExist = Standard_True;
+ Standard_Real theU1, theV1;
+ if (!IsReversed)
+ {
+ PrePoint.ParametersOnS1(theU1, theV1);
+ theU1 = (Abs(AnU1) <= Precision::PConfusion())? 2*M_PI : 0.;
+ PrePoint.SetValue(Standard_True, //on first
+ theU1, theV1);
+ }
+ else
+ {
+ PrePoint.ParametersOnS2(theU1, theV1);
+ theU1 = (Abs(AnU1) <= Precision::PConfusion())? 2*M_PI : 0.;
+ PrePoint.SetValue(Standard_False, //on second
+ theU1, theV1);
+ }
+ }
+ ////
break;
}
sline->Add(aSSLine->Value(k));
+ PrePoint = aSSLine->Value(k);
AnU1=U1;
}
return hasBeenDecomposed;
}
-/*
-// <-A
+
+static Standard_Boolean IsIn2DBox(const Bnd_Box2d& theBox,
+ const Handle(IntPatch_PointLine)& theLine,
+ const Standard_Real theUPeriod,
+ const Standard_Real theVPeriod,
+ const Standard_Boolean isTheSurface1Using)
{
-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);
-}
+ const Standard_Integer aNbPnts = theLine->NbPnts();
+
+ const Standard_Real aDeltaUPeriod[] = {0.0, -theUPeriod, 2.0*theUPeriod};
+ const Standard_Real aDeltaVPeriod[] = {0.0, -theVPeriod, 2.0*theVPeriod};
+
+ const Standard_Integer aSzOfUPArr = sizeof(aDeltaUPeriod)/sizeof(aDeltaUPeriod[0]);
+ const Standard_Integer aSzOfVPArr = sizeof(aDeltaVPeriod)/sizeof(aDeltaVPeriod[0]);
+
+ for(Standard_Integer aPtID = 1; aPtID <= aNbPnts; aPtID++)
+ {
+ Standard_Real aU = 0.0, aV = 0.0;
+ if(isTheSurface1Using)
+ theLine->Point(aPtID).ParametersOnS1(aU, aV);
+ else
+ theLine->Point(aPtID).ParametersOnS2(aU, aV);
+
+ if(!theBox.IsOut(gp_Pnt2d(aU, aV)))
+ continue;
+
+ Standard_Boolean isInscribe = Standard_False;
+
+ for(Standard_Integer aUind = 0; !isInscribe && (aUind < aSzOfUPArr); aUind++)
+ {
+ if((aUind > 0) && (aDeltaUPeriod[aUind] == 0.0))
+ {
+ break;
+ }
+
+ aU += aDeltaUPeriod[aUind];
+
+ for(Standard_Integer aVind = 0; !isInscribe && (aVind < aSzOfVPArr); aVind++)
+ {
+ if((aVind > 0) && (aDeltaVPeriod[aVind] == 0.0))
+ {
+ break;
+ }
+
+ aV += aDeltaVPeriod[aVind];
+
+ isInscribe = !theBox.IsOut(gp_Pnt2d(aU, aV));
+ }
+ }
+
+ if(!isInscribe)
+ return Standard_False;
+ }
+ return Standard_True;
}
-*/