// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#include <IntPatch_ImpPrmIntersection.ixx>
+#include <IntPatch_ImpPrmIntersection.hxx>
-#include <Standard_ConstructionError.hxx>
-#include <IntPatch_SequenceOfLine.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-#include <IntSurf_PntOn2S.hxx>
-#include <IntSurf_LineOn2S.hxx>
-#include <IntSurf.hxx>
-#include <IntSurf_InteriorPoint.hxx>
-
-#include <Adaptor2d_HCurve2d.hxx>
-#include <IntSurf_PathPoint.hxx>
-#include <IntSurf_SequenceOfPathPoint.hxx>
-#include <IntPatch_TheIWalking.hxx>
+#include <Adaptor3d_HSurface.hxx>
+#include <Adaptor3d_TopolTool.hxx>
+#include <ElCLib.hxx>
+#include <IntPatch_ArcFunction.hxx>
+#include <IntPatch_PointLine.hxx>
+#include <IntPatch_RLine.hxx>
+#include <IntPatch_RstInt.hxx>
+#include <IntPatch_SpecialPoints.hxx>
#include <IntPatch_TheIWLineOfTheIWalking.hxx>
-#include <IntPatch_ThePathPointOfTheSOnBounds.hxx>
-#include <IntPatch_TheSegmentOfTheSOnBounds.hxx>
+#include <IntPatch_TheIWalking.hxx>
#include <IntPatch_TheSurfFunction.hxx>
-#include <IntPatch_RLine.hxx>
#include <IntPatch_WLine.hxx>
-#include <IntPatch_ArcFunction.hxx>
-#include <IntPatch_RstInt.hxx>
+#include <IntSurf.hxx>
+#include <IntSurf_Quadric.hxx>
+#include <IntSurf_QuadricTool.hxx>
+#include <IntSurf_SequenceOfPathPoint.hxx>
+#include <TopAbs_Orientation.hxx>
+#include <TopTrans_CurveTransition.hxx>
+#include <math_Matrix.hxx>
+#include <math_Vector.hxx>
+
#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 <TopAbs_State.hxx>
-#include <TopAbs_Orientation.hxx>
-#include <TColStd_Array1OfInteger.hxx>
-#include <TColStd_Array1OfReal.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,
- const IntSurf_Quadric& Quad,
- const Handle(Adaptor3d_TopolTool)& PDomain,
- const Handle(Adaptor3d_HSurface)& QSurf,
- const Standard_Real ArcTol,
- IntPatch_SequenceOfLine& Lines);
+static Standard_Boolean DecomposeResult(const Handle(IntPatch_PointLine)& theLine,
+ const Standard_Boolean IsReversed,
+ const IntSurf_Quadric& theQuad,
+ const Handle(Adaptor3d_TopolTool)& thePDomain,
+ const Handle(Adaptor3d_HSurface)& theQSurf,
+ const Handle(Adaptor3d_HSurface)& theOtherSurf,
+ const Standard_Real theArcTol,
+ const Standard_Real theTolTang,
+ IntPatch_SequenceOfLine& theLines);
static
void ComputeTangency (const IntPatch_TheSOnBounds& solrst,
IntSurf_SequenceOfPathPoint& seqpdep,
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);
+static
+ Standard_Boolean IsCoincide(IntPatch_TheSurfFunction& theFunc,
+ const Handle(IntPatch_PointLine)& theLine,
+ const Handle(Adaptor2d_HCurve2d)& theArc,
+ const Standard_Boolean isTheSurface1Using,
+ const Standard_Real theToler3D,
+ const Standard_Real theToler2D,
+ const Standard_Real thePeriod);
+
+//=======================================================================
+//function : IsSeamOrPole
+//purpose :
+//=======================================================================
+static IntPatch_SpecPntType IsSeamOrPole(const Handle(Adaptor3d_HSurface)& theQSurf,
+ const Handle(IntSurf_LineOn2S)& theLine,
+ const Standard_Boolean IsReversed,
+ const Standard_Integer theRefIndex,
+ const Standard_Real theDeltaMax)
+{
+ if((theRefIndex < 1) || (theRefIndex >= theLine->NbPoints()))
+ return IntPatch_SPntNone;
+
+ //Parameters on Quadric and on parametric for reference point
+ Standard_Real aUQRef, aVQRef, aUPRef, aVPRef;
+ Standard_Real aUQNext, aVQNext, aUPNext, aVPNext;
+
+ if(IsReversed)
+ {
+ theLine->Value(theRefIndex).Parameters (aUPRef, aVPRef, aUQRef, aVQRef);
+ theLine->Value(theRefIndex+1).Parameters(aUPNext, aVPNext, aUQNext, aVQNext);
+ }
+ else
+ {
+ theLine->Value(theRefIndex).Parameters (aUQRef, aVQRef, aUPRef, aVPRef);
+ theLine->Value(theRefIndex+1).Parameters(aUQNext, aVQNext, aUPNext, aVPNext);
+ }
+
+ const GeomAbs_SurfaceType aType = theQSurf->GetType();
+
+ const Standard_Real aDeltaU = Abs(aUQRef - aUQNext);
+
+ if((aType != GeomAbs_Torus) && (aDeltaU < theDeltaMax))
+ return IntPatch_SPntNone;
+
+ switch(aType)
+ {
+ case GeomAbs_Cylinder:
+ return IntPatch_SPntSeamU;
+
+ case GeomAbs_Torus:
+ {
+ const Standard_Real aDeltaV = Abs(aVQRef - aVQNext);
+
+ if((aDeltaU >= theDeltaMax) && (aDeltaV >= theDeltaMax))
+ return IntPatch_SPntSeamUV;
+
+ if(aDeltaU >= theDeltaMax)
+ return IntPatch_SPntSeamU;
+
+ if(aDeltaV >= theDeltaMax)
+ return IntPatch_SPntSeamV;
+ }
+
+ break;
+ case GeomAbs_Sphere:
+ case GeomAbs_Cone:
+ return IntPatch_SPntPoleSeamU;
+ default:
+ break;
+ }
+
+ return IntPatch_SPntNone;
+}
//=======================================================================
//function : IntPatch_ImpPrmIntersection
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;
+ Standard_FALLTHROUGH
case GeomAbs_Cylinder:
case GeomAbs_Cone:
case GeomAbs_Sphere:
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;
+ Standard_FALLTHROUGH
case GeomAbs_Cylinder:
case GeomAbs_Cone:
case GeomAbs_Sphere:
break;
default:
{
- Standard_ConstructionError::Raise();
+ throw Standard_ConstructionError();
break;
}
}
// <-A
wline = new IntPatch_WLine(thelin,Standard_False,trans1,trans2);
+#ifdef INTPATCH_IMPPRMINTERSECTION_DEBUG
+ wline->Dump(0);
+#endif
+
if ( iwline->HasFirstPoint()
&& iwline->IsTangentAtBegining() == Standard_False)
{
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 (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()) {
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 (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 (Standard_Integer i=1; i<=slin.Length(); i++)
+
+ for (Standard_Integer i=1, aNbLin = slin.Length(); i<=aNbLin; i++)
{
- Handle(IntPatch_Line)& aL = slin(i);
+ Handle(IntPatch_PointLine) aL = Handle(IntPatch_PointLine)::DownCast(slin(i));
if (!reversed)
IntPatch_RstInt::PutVertexOnLine(aL,Surf1,D1,Surf2,Standard_True,TolTang);
else
IntPatch_RstInt::PutVertexOnLine(aL,Surf2,D2,Surf1,Standard_False,TolTang);
+
+ if (aL->NbPnts() <= 2)
+ {
+ Standard_Boolean aCond = aL->NbPnts() < 2;
+ if (!aCond)
+ aCond = (aL->Point(1).IsSame(aL->Point(2), Precision::Confusion()));
+
+ if (aCond)
+ {
+ slin.Remove(i);
+ i--;
+ aNbLin--;
+ continue;
+ }
+ }
+
+ if(aL->ArcType() == IntPatch_Walking)
+ {
+ const Handle(IntPatch_WLine) aWL = Handle(IntPatch_WLine)::DownCast(aL);
+ slin.Append(aWL);
+ slin.Remove(i);
+ i--;
+ aNbLin--;
+ }
}
- 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;
+ // Now slin is filled as follows: lower indices correspond to Restriction line,
+ // after (higher indices) - only Walking-line.
+
+ const Standard_Real aTol3d = Max(Func.Tolerance(), TolTang);
+ const Handle(Adaptor3d_HSurface)& aQSurf = (reversed) ? Surf2 : Surf1;
+ const Handle(Adaptor3d_HSurface)& anOtherSurf = (reversed) ? Surf1 : Surf2;
for (Standard_Integer i = 1; i <= slin.Length(); i++)
{
- //BndBox of the points in Restriction line
- Bnd_Box2d aBRL;
+ const Handle(IntPatch_PointLine)& aL1 = Handle(IntPatch_PointLine)::DownCast(slin(i));
+ const Handle(IntPatch_RLine)& aRL1 = Handle(IntPatch_RLine)::DownCast(aL1);
+
+ if(aRL1.IsNull())
+ {
+ //Walking-Walking cases are not supported
+ break;
+ }
+
+ const Handle(Adaptor2d_HCurve2d)& anArc = aRL1->IsArcOnS1() ?
+ aRL1->ArcOnS1() :
+ aRL1->ArcOnS2();
+ if(anArc->Curve2d().GetType() != GeomAbs_Line)
+ {
+ //Restriction line must be isoline.
+ //Other cases are not supported by
+ //existing algorithms.
+
+ break;
+ }
+
+ Standard_Boolean isFirstDeleted = Standard_False;
+
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
+ //Here aL1 (i-th line) is Restriction-line and aL2 (j-th line) is
+ //Restriction or Walking
- if(aBRL.IsVoid())
- {//Fill aBRL
- for(Standard_Integer aPRID = 1; aPRID <= aRL1->NbPnts(); aPRID++)
+ if(!aRL2.IsNull())
+ {
+ const Handle(Adaptor2d_HCurve2d)& anArc2 = aRL2->IsArcOnS1() ?
+ aRL2->ArcOnS1() :
+ aRL2->ArcOnS2();
+ if(anArc2->Curve2d().GetType() != GeomAbs_Line)
{
- Standard_Real u = 0.0, v = 0.0;
- if(reversed)
- aRL1->Point(aPRID).ParametersOnS1(u, v);
- else
- aRL1->Point(aPRID).ParametersOnS2(u, v);
+ //Restriction line must be isoline.
+ //Other cases are not supported by
+ //existing algorithms.
- aBRL.Add(gp_Pnt2d(u, v));
+ continue;
}
+ }
- 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);
+ //aDir can be equal to one of following four values only
+ //(because Reastriction line is boundary of rectangular surface):
+ //either {0, 1} or {0, -1} or {1, 0} or {-1, 0}.
+ const gp_Dir2d aDir = anArc->Curve2d().Line().Direction();
- if((aDX > aTolU) && (aDY > aTolV))
- {//Delete restriction line because it is not isoline.
- slin.Remove(i);
- i--;
- break;
- }
+ Standard_Real aTol2d = anOtherSurf->UResolution(aTol3d),
+ aPeriod = anOtherSurf->IsVPeriodic() ? anOtherSurf->VPeriod() : 0.0;
- aXmin -= aTolU;
- aXMax += aTolU;
- aYmin -= aTolV;
- aYMax += aTolV;
- aBRL.SetVoid();
- aBRL.Update(aXmin, aYmin, aXMax, aYMax);
+ if(Abs(aDir.X()) < 0.5)
+ {//Restriction directs along V-direction
+ aTol2d = anOtherSurf->VResolution(aTol3d);
+ aPeriod = anOtherSurf->IsUPeriodic() ? anOtherSurf->UPeriod() : 0.0;
}
- const Standard_Boolean isCoincide = IsIn2DBox(aBRL, aL2,
- (reversed? aUPeriodOfSurf1 : aUPeriodOfSurf2),
- (reversed? aVPeriodOfSurf1 : aVPeriodOfSurf2), reversed);
+ const Standard_Boolean isCoincide = IsCoincide(Func, aL2, anArc, aRL1->IsArcOnS1(),
+ aTol3d, aTol2d, aPeriod);
if(isCoincide)
- {//Delete Walking-line
- slin.Remove(j);
- j--;
+ {
+ if(aRL2.IsNull())
+ {//Delete Walking-line
+ slin.Remove(j);
+ j--;
+ }
+ else
+ {//Restriction-Restriction
+ const Handle(Adaptor2d_HCurve2d)& anArc2 = aRL2->IsArcOnS1() ?
+ aRL2->ArcOnS1() :
+ aRL2->ArcOnS2();
+
+ const Standard_Real aRange2 = anArc2->LastParameter() -
+ anArc2->FirstParameter();
+ const Standard_Real aRange1 = anArc->LastParameter() -
+ anArc->FirstParameter();
+
+ if(aRange2 > aRange1)
+ {
+ isFirstDeleted = Standard_True;
+ break;
+ }
+ else
+ {//Delete j-th line
+ slin.Remove(j);
+ j--;
+ }
+ }
}
+ } //for(Standard_Integer j = i + 1; j <= slin.Length(); j++)
+
+ if(isFirstDeleted)
+ {//Delete i-th line
+ slin.Remove(i--);
}
- }
+ }//for (Standard_Integer i = 1; i <= slin.Length(); i++)
empt = (slin.Length() == 0 && spnt.Length() == 0);
done = Standard_True;
return;
Standard_Boolean isDecomposeRequired = (Quad.TypeQuadric() == GeomAbs_Cone) ||
- (Quad.TypeQuadric() == GeomAbs_Sphere);
+ (Quad.TypeQuadric() == GeomAbs_Sphere) ||
+ (Quad.TypeQuadric() == GeomAbs_Cylinder) ||
+ (Quad.TypeQuadric() == GeomAbs_Torus);
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(Standard_Integer i = 1; i <= slin.Length(); i++ )
{
- if(DecomposeResult(slin(i),reversed,Quad,PDomain,aQSurf,TolArc,dslin))
+ if(DecomposeResult( Handle(IntPatch_PointLine)::DownCast(slin(i)),
+ reversed, Quad, PDomain, aQSurf,
+ anOtherSurf, TolArc, aTol3d, dslin))
{
isDecompose = Standard_True;
}
}
// collect vertices, reject equals
-static Handle(IntSurf_LineOn2S) GetVertices(const Handle(IntPatch_WLine)& WLine,
+static Handle(IntSurf_LineOn2S) GetVertices(const Handle(IntPatch_PointLine)& thePLine,
const Standard_Real TOL3D,
const Standard_Real TOL2D)
{
Standard_Real U1 = 0., U2 = 0., V1 = 0., V2 = 0.;
Standard_Integer i = 0, k = 0;
- Standard_Integer NbVrt = WLine->NbVertex();
+ Standard_Integer NbVrt = thePLine->NbVertex();
TColStd_Array1OfInteger anVrts(1,NbVrt);
anVrts.Init(0);
if( anVrts(i) == -1 ) continue;
- const IntPatch_Point& Pi = WLine->Vertex(i);
+ const IntPatch_Point& Pi = thePLine->Vertex(i);
for(k = (i+1); k <= NbVrt; k++) {
if( anVrts(k) == -1 ) continue;
- const IntPatch_Point& Pk = WLine->Vertex(k);
+ const IntPatch_Point& Pk = thePLine->Vertex(k);
if(Pi.Value().Distance(Pk.Value()) <= TOL3D) {
// suggest the points are equal;
// copy further processed vertices
for(i = 1; i <= NbVrt; i++) {
if( anVrts(i) == -1 ) continue;
- vertices->Add(WLine->Vertex(i).PntOn2S());
+ vertices->Add(thePLine->Vertex(i).PntOn2S());
}
return vertices;
}
-static Standard_Boolean AreSamePoints(const IntSurf_PntOn2S& P1,
- const IntSurf_PntOn2S& P2)
-{
- Standard_Boolean result = Standard_False;
- Standard_Real T2D = 1.e-9, T3D = 1.e-8;
- const gp_Pnt& P3D1 = P1.Value();
- const gp_Pnt& P3D2 = P2.Value();
- if(P3D1.Distance(P3D2) <= T3D) {
- Standard_Real U1 = 0., V1 = 0., U2 = 0., V2 = 0., U3 = 0., V3 = 0., U4 = 0., V4 = 0.;
- P1.ParametersOnS1(U1,V1);
- P1.ParametersOnS2(U2,V2);
- P2.ParametersOnS1(U3,V3);
- P2.ParametersOnS2(U4,V4);
- gp_Pnt2d P2D11(U1,V1);
- gp_Pnt2d P2D12(U2,V2);
- gp_Pnt2d P2D21(U3,V3);
- gp_Pnt2d P2D22(U4,V4);
- Standard_Boolean sameS1 = (P2D11.Distance(P2D21) <= T2D) ? Standard_True : Standard_False;
- Standard_Boolean sameS2 = (P2D12.Distance(P2D22) <= T2D) ? Standard_True : Standard_False;
- if(sameS1 && sameS2)
- result = Standard_True;
- }
- return result;
-}
-
-static void ForcedPurgePoints(const Handle(IntSurf_LineOn2S)& Result,
- const Standard_Boolean IsReversed,
- const IntSurf_Quadric& Quad)
-{
- if(Result->NbPoints() <= 30) return;
- 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(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)
- IndexLimL = 12;
- }
-
- 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)
- IndexLimL = 12;
- }
-
- while(Result->NbPoints() > 2 && Index < IndexLimF) {
- Result->RemovePoint(2);
- Index++;
- }
- Index = 0;
- while(Result->NbPoints() > 2 && Index < IndexLimL) {
- Result->RemovePoint(Result->NbPoints()-1);
- Index++;
- }
-}
-
-// DEBUG FUNCTION !!!
-#if 0
-static void DumpLine(Handle(IntSurf_LineOn2S)& Line,
- Standard_Boolean IsReversed,
- Standard_Integer Number)
-{
- cout << "DUMP LINE" << endl;
- Standard_Integer i;
- Standard_Real U,V;
- for(i = 1; i <= Line->NbPoints(); i++) {
- if(i <= Number || i >= (Line->NbPoints()-Number)) {
- if(IsReversed)
- Line->Value(i).ParametersOnS2(U,V); // S2 - quadric
- else
- Line->Value(i).ParametersOnS1(U,V); // S1 - quadric
- cout << "point p" << i << " " << U << " " << V << endl;
- }
- }
- cout << endl;
-}
-#endif
-// DEBUG FUNCTION !!!
-
static void SearchVertices(const Handle(IntSurf_LineOn2S)& Line,
const Handle(IntSurf_LineOn2S)& Vertices,
TColStd_Array1OfInteger& PTypes)
Standard_Integer type = 0;
for(iv = 1; iv <= nbv; iv++) {
const IntSurf_PntOn2S& aV = Vertices->Value(iv);
- if(AreSamePoints(aP,aV)) {
+ if(aP.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) {
type = iv;
break;
}
for(iv = 1; iv <= nbv; iv++) {
const IntSurf_PntOn2S& aV = Vertices->Value(iv);
- if(AreSamePoints(aPF,aV)) {
+ if(aPF.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) {
FIndexSame = iv;
break;
}
for(iv = 1; iv <= nbv; iv++) {
const IntSurf_PntOn2S& aV = Vertices->Value(iv);
- if(AreSamePoints(aPL,aV)) {
+ if(aPL.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) {
LIndexSame = iv;
break;
}
}
-static void PutIntVertices(Handle(IntPatch_Line)& Line,
+static void PutIntVertices(const Handle(IntPatch_PointLine)& Line,
Handle(IntSurf_LineOn2S)& Result,
- Standard_Boolean ,//IsReversed,
+ Standard_Boolean theIsReversed,
Handle(IntSurf_LineOn2S)& Vertices,
const Standard_Real ArcTol)
{
if(nbp < 3)
return;
- Handle(IntPatch_WLine)& WLine = (*((Handle(IntPatch_WLine)*)&Line));
+ const Handle(IntPatch_RLine) aRLine = Handle(IntPatch_RLine)::DownCast(Line);
+
Standard_Integer ip = 0, iv = 0;
gp_Pnt aPnt;
IntPatch_Point thePnt;
const IntSurf_PntOn2S& aP = Result->Value(ip);
for(iv = 1; iv <= nbv; iv++) {
const IntSurf_PntOn2S& aV = Vertices->Value(iv);
- if(AreSamePoints(aP,aV)) {
+ if(aP.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) {
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);
+
+ Standard_Real aParam = (Standard_Real)ip;
+
+ if(!aRLine.IsNull())
+ {
+ //In fact, aRLine is always on the parametric surface.
+ //If (theIsReversed == TRUE) then (U1, V1) - point on
+ //parametric surface, otherwise - point on quadric.
+ const Handle(Adaptor2d_HCurve2d)& anArc = aRLine->IsArcOnS1() ?
+ aRLine->ArcOnS1() :
+ aRLine->ArcOnS2();
+
+ const gp_Lin2d aLin(anArc->Curve2d().Line());
+ gp_Pnt2d aPSurf;
+
+ if(theIsReversed)
+ {
+ aPSurf.SetCoord(U1, V1);
+ }
+ else
+ {
+ aPSurf.SetCoord(U2, V2);
+ }
+
+ aParam = ElCLib::Parameter(aLin, aPSurf);
+ }
+
+ thePnt.SetParameter(aParam);
+ Line->AddVertex(thePnt);
}
}
}
const IntSurf_PntOn2S& aP = Line->Value(ip);
for(iv = 1; iv <= nbv; iv++) {
const IntSurf_PntOn2S& aV = Vertices->Value(iv);
- if(AreSamePoints(aP,aV)) {
+ if(aP.IsSame(aV, Precision::Confusion(), Precision::PConfusion())) {
result = Standard_True;
break;
}
TPntL.SetParameters(uu1,vv1,uu2,vv2);
TPntL.SetParameter((Standard_Real)sline->NbPoints());
wline->AddVertex(TPntL);
- wline->SetLastPoint(sline->NbPoints());
+ wline->SetLastPoint(wline->NbVertex());
return wline;
}
return result;
}
-static Standard_Boolean DecomposeResult(const Handle(IntPatch_Line)& theLine,
+//=======================================================================
+//function : DecomposeResult
+//purpose : Split <theLine> in the places where it passes through seam edge
+// or singularity (apex of cone or pole of sphere).
+// This passage is detected by jump of U-parameter
+// from point to point.
+//=======================================================================
+static Standard_Boolean DecomposeResult(const Handle(IntPatch_PointLine)& theLine,
const Standard_Boolean IsReversed,
const IntSurf_Quadric& theQuad,
const Handle(Adaptor3d_TopolTool)& thePDomain,
- const Handle(Adaptor3d_HSurface)& theQSurf,
+ const Handle(Adaptor3d_HSurface)& theQSurf, //quadric
+ const Handle(Adaptor3d_HSurface)& thePSurf, //parametric
const Standard_Real theArcTol,
+ const Standard_Real theTolTang,
IntPatch_SequenceOfLine& theLines)
{
- // Split <theLine> in the places where it passes through seam edge or singularity
- // (apex of cone or pole of sphere). This passage is detected by jump of U-parameter
- // from point to point.
+ if(theLine->ArcType() == IntPatch_Restriction)
+ {
+ const Handle(IntPatch_RLine)& aRL = Handle(IntPatch_RLine)::DownCast(theLine);
+ if(!aRL.IsNull())
+ {
+ const Handle(Adaptor2d_HCurve2d)& anArc = aRL->IsArcOnS1() ?
+ aRL->ArcOnS1() :
+ aRL->ArcOnS2();
+ if(anArc->Curve2d().GetType() != GeomAbs_Line)
+ {
+ //Restriction line must be isoline.
+ //Other cases are not supported by
+ //existing algorithms.
+
+ return Standard_False;
+ }
+ }
+ }
- const Standard_Real aDeltaUmax = 0.5*M_PI;
+ const Standard_Real aDeltaUmax = M_PI_2;
const Standard_Real aTOL3D = 1.e-10,
aTOL2D = Precision::PConfusion(),
aTOL2DS = Precision::PConfusion();
- if( theLine->ArcType() != IntPatch_Walking )
- {
- return Standard_False;
- }
-
- const Handle(IntPatch_WLine)& aWLine = (*((Handle(IntPatch_WLine)*)&theLine));
- const Handle(IntSurf_LineOn2S)& aSLine = aWLine->Curve();
+ const Handle(IntSurf_LineOn2S)& aSLine = theLine->Curve();
if(aSLine->NbPoints() <= 2)
{
}
//Deletes repeated vertices
- Handle(IntSurf_LineOn2S) aVLine = GetVertices(aWLine,aTOL3D,aTOL2D);
+ Handle(IntSurf_LineOn2S) aVLine = GetVertices(theLine,aTOL3D,aTOL2D);
Handle(IntSurf_LineOn2S) aSSLine(aSLine);
AdjustLine(aSSLine,IsReversed,theQSurf,aTOL2D);
+ if(theLine->ArcType() == IntPatch_Walking)
{
Standard_Boolean isInserted = Standard_True;
while(isInserted)
const Standard_Integer aLindex = aSSLine->NbPoints();
Standard_Integer aFindex = 1, aBindex = 0;
- IntPatch_Point aTPntF, aTPntL;
-
// build WLine parts (if any)
Standard_Boolean flNextLine = Standard_True;
Standard_Boolean hasBeenDecomposed = Standard_False;
- Standard_Boolean PrePointExist = Standard_False;
+ IntPatch_SpecPntType aPrePointExist = IntPatch_SPntNone;
+
IntSurf_PntOn2S PrePoint;
while(flNextLine)
{
// reset variables
flNextLine = Standard_False;
Standard_Boolean isDecomposited = Standard_False;
- Standard_Real U1 = 0., U2 = 0., V1 = 0., V2 = 0., AnU1 = 0.;
+ Standard_Real U1 = 0., U2 = 0., V1 = 0., V2 = 0.;
Handle(IntSurf_LineOn2S) sline = new IntSurf_LineOn2S();
//if((Lindex-Findex+1) <= 2 )
- if(aLindex <= aFindex)
- return hasBeenDecomposed;
+ if((aLindex <= aFindex) && !aPrePointExist)
+ {
+ //break of "while(flNextLine)" cycle
+ break;
+ }
- if (PrePointExist)
+ if(aPrePointExist)
{
- sline->Add(PrePoint);
- PrePointExist = Standard_False;
+ const IntSurf_PntOn2S& aRefPt = aSSLine->Value(aFindex);
+
+ const Standard_Real aURes = theQSurf->UResolution(theArcTol),
+ aVRes = theQSurf->VResolution(theArcTol);
+
+ const Standard_Real aTol2d = (aPrePointExist == IntPatch_SPntPole) ? -1.0 :
+ (aPrePointExist == IntPatch_SPntSeamV)? aVRes :
+ (aPrePointExist == IntPatch_SPntSeamUV)? Max(aURes, aVRes) : aURes;
+
+ if(IntPatch_SpecialPoints::ContinueAfterSpecialPoint(theQSurf, thePSurf, aRefPt,
+ aPrePointExist, aTol2d,
+ PrePoint, IsReversed))
+ {
+ sline->Add(PrePoint);
+ }
+ else
+ {
+ //break of "while(flNextLine)" cycle
+ break;
+ }
}
-
+
+ aPrePointExist = IntPatch_SPntNone;
+
// analyze other points
for(Standard_Integer k = aFindex; k <= aLindex; k++)
{
if( k == aFindex )
{
- if(IsReversed)
- {
- aSSLine->Value(k).ParametersOnS2(AnU1,V1); // S2 - quadric, set U,V by Pnt3D
- }
- else
- {
- aSSLine->Value(k).ParametersOnS1(AnU1,V1); // S1 - quadric, set U,V by Pnt3D
- }
-
- sline->Add(aSSLine->Value(k));
PrePoint = aSSLine->Value(k);
+ sline->Add(PrePoint);
continue;
}
aSSLine->Value(k).ParametersOnS1(U1,V1); // S1 - quadric, set U,V by Pnt3D
}
- if(Abs(U1-AnU1) > aDeltaUmax)
+ aPrePointExist = IsSeamOrPole(theQSurf, aSSLine, IsReversed, k-1, aDeltaUmax);
+
+ if(aPrePointExist != IntPatch_SPntNone)
{
aBindex = k;
isDecomposited = Standard_True;
////
- if (Abs(U1) <= Precision::PConfusion() ||
- Abs(U1 - 2*M_PI) <= Precision::PConfusion())
+ const IntSurf_PntOn2S& aRefPt = aSSLine->Value(aBindex-1);
+
+ Standard_Real aCompareTol3D = Precision::Confusion();
+ Standard_Real aCompareTol2D = Precision::PConfusion();
+
+ IntSurf_PntOn2S aNewPoint = aRefPt;
+ IntPatch_SpecPntType aLastType = IntPatch_SPntNone;
+
+ if(aPrePointExist == IntPatch_SPntSeamUV)
{
- 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)
+ aPrePointExist = IntPatch_SPntNone;
+ aLastType = IntPatch_SPntSeamUV;
+ IntPatch_SpecialPoints::AddCrossUVIsoPoint(theQSurf, thePSurf,
+ aRefPt, theTolTang,
+ aNewPoint, IsReversed);
+ }
+ else if(aPrePointExist == IntPatch_SPntSeamV)
+ {//WLine goes through seam
+ aPrePointExist = IntPatch_SPntNone;
+ aLastType = IntPatch_SPntSeamV;
+
+ //Not quadric point
+ Standard_Real aU0 = 0.0, aV0 = 0.0;
+ //Quadric point
+ Standard_Real aUQuadRef = 0.0, aVQuadRef = 0.0;
+
+ if(IsReversed)
{
- CurPoint.ParametersOnS2(theU2, theV2);
- NewPoint.SetValue(theU1, theV1, theU2, theV2);
+ aRefPt.Parameters(aU0, aV0, aUQuadRef, aVQuadRef);
}
else
{
- CurPoint.ParametersOnS1(theU2, theV2);
- NewPoint.SetValue(theU2, theV2, theU1, theV1);
+ aRefPt.Parameters(aUQuadRef, aVQuadRef, aU0, aV0);
+ }
+
+ math_Vector aTol(1, 3), aStartPoint(1,3),
+ anInfBound(1, 3), aSupBound(1, 3);
+
+ //Parameters on parametric surface
+ Standard_Real aUp = 0.0, aVp = 0.0;
+ if(IsReversed)
+ {
+ aSSLine->Value(k).ParametersOnS1(aUp, aVp);
}
- sline->Add(NewPoint);
+ else
+ {
+ aSSLine->Value(k).ParametersOnS2(aUp, aVp);
+ }
+
+ aTol(1) = thePSurf->UResolution(theArcTol);
+ aTol(2) = thePSurf->VResolution(theArcTol);
+ aTol(3) = theQSurf->UResolution(theArcTol);
+ aStartPoint(1) = 0.5*(aU0 + aUp);
+ aStartPoint(2) = 0.5*(aV0 + aVp);
+ aStartPoint(3) = 0.5*(aUQuadRef + U1);
+ anInfBound(1) = thePSurf->FirstUParameter();
+ anInfBound(2) = thePSurf->FirstVParameter();
+ anInfBound(3) = theQSurf->FirstUParameter();
+ aSupBound(1) = thePSurf->LastUParameter();
+ aSupBound(2) = thePSurf->LastVParameter();
+ aSupBound(3) = theQSurf->LastUParameter();
+
+ IntPatch_SpecialPoints::
+ AddPointOnUorVIso(theQSurf, thePSurf, aRefPt, Standard_False,
+ aTol, aStartPoint, anInfBound, aSupBound,
+ aNewPoint, IsReversed);
}
- else if (Abs(AnU1) <= Precision::PConfusion() ||
- Abs(AnU1 - 2*M_PI) <= Precision::PConfusion())
+ else if(aPrePointExist == IntPatch_SPntPoleSeamU)
{
- //Modify <PrePoint>
- PrePointExist = Standard_True;
- Standard_Real theU1, theV1;
- if (!IsReversed)
+ aPrePointExist = IntPatch_SPntNone;
+
+ IntPatch_Point aVert;
+ aVert.SetValue(aRefPt);
+
+ if(IntPatch_SpecialPoints::
+ AddSingularPole(theQSurf, thePSurf, aRefPt, theTolTang,
+ aVert, aNewPoint, IsReversed))
{
- PrePoint.ParametersOnS1(theU1, theV1);
- theU1 = (Abs(AnU1) <= Precision::PConfusion())? 2*M_PI : 0.;
- PrePoint.SetValue(Standard_True, //on first
- theU1, theV1);
+ aPrePointExist = IntPatch_SPntPole;
+ aLastType = IntPatch_SPntPole;
+ aCompareTol2D = -1.0;
+ } //if(IntPatch_AddSpecialPoints::AddSingularPole(...))
+ else
+ {//Pole is not an intersection point
+ aPrePointExist = IntPatch_SPntSeamU;
+ }
+ }
+
+ if(aPrePointExist == IntPatch_SPntSeamU)
+ {//WLine goes through seam
+ aPrePointExist = IntPatch_SPntNone;
+ aLastType = IntPatch_SPntSeamU;
+
+ //Not quadric point
+ Standard_Real aU0 = 0.0, aV0 = 0.0;
+ //Quadric point
+ Standard_Real aUQuadRef = 0.0, aVQuadRef = 0.0;
+
+ if(IsReversed)
+ {
+ aRefPt.Parameters(aU0, aV0, aUQuadRef, aVQuadRef);
+ }
+ else
+ {
+ aRefPt.Parameters(aUQuadRef, aVQuadRef, aU0, aV0);
+ }
+
+ math_Vector aTol(1, 3), aStartPoint(1,3),
+ anInfBound(1, 3), aSupBound(1, 3);
+
+ //Parameters on parametric surface
+ Standard_Real aUp = 0.0, aVp = 0.0;
+ if(IsReversed)
+ {
+ aSSLine->Value(k).ParametersOnS1(aUp, aVp);
}
else
{
- PrePoint.ParametersOnS2(theU1, theV1);
- theU1 = (Abs(AnU1) <= Precision::PConfusion())? 2*M_PI : 0.;
- PrePoint.SetValue(Standard_False, //on second
- theU1, theV1);
+ aSSLine->Value(k).ParametersOnS2(aUp, aVp);
}
+
+ aTol(1) = thePSurf->UResolution(theArcTol);
+ aTol(2) = thePSurf->VResolution(theArcTol);
+ aTol(3) = theQSurf->VResolution(theArcTol);
+ aStartPoint(1) = 0.5*(aU0 + aUp);
+ aStartPoint(2) = 0.5*(aV0 + aVp);
+ aStartPoint(3) = 0.5*(aVQuadRef + V1);
+ anInfBound(1) = thePSurf->FirstUParameter();
+ anInfBound(2) = thePSurf->FirstVParameter();
+ anInfBound(3) = theQSurf->FirstVParameter();
+ aSupBound(1) = thePSurf->LastUParameter();
+ aSupBound(2) = thePSurf->LastVParameter();
+ aSupBound(3) = theQSurf->LastVParameter();
+
+ IntPatch_SpecialPoints::
+ AddPointOnUorVIso(theQSurf, thePSurf, aRefPt, Standard_True, aTol,
+ aStartPoint, anInfBound, aSupBound, aNewPoint,
+ IsReversed);
}
+
+ if(!aNewPoint.IsSame(aRefPt, aCompareTol3D, aCompareTol2D))
+ {
+ sline->Add(aNewPoint);
+ aPrePointExist = aLastType;
+ PrePoint = aNewPoint;
+ }
+ else
+ {
+ if(sline->NbPoints() == 1)
+ {
+ //FIRST point of the sline is the pole of the quadric.
+ //Therefore, there is no point in decomposition.
+
+ PrePoint = aRefPt;
+ aPrePointExist = aLastType;
+ }
+ }
+
////
break;
- }
+ } //if(Abs(U1-AnU1) > aDeltaUmax)
sline->Add(aSSLine->Value(k));
PrePoint = aSSLine->Value(k);
- AnU1=U1;
+ } //for(Standard_Integer k = aFindex; k <= aLindex; k++)
+
+ //Creation of new line as part of existing theLine.
+ //This part is defined by sline.
+
+ if(sline->NbPoints() == 1)
+ {
+ flNextLine = Standard_True;
+ aFindex = aBindex;
+
+ //Go to the next part of aSSLine
+ //because we cannot create the line
+ //with single point.
+
+ continue;
}
IntSurf_PntOn2S aVF, aVL;
}
}
- if(!hasInternals)
+ if(theLine->ArcType() == IntPatch_Walking)
{
- ForcedPurgePoints(sline,IsReversed,theQuad);
- }
+ IntPatch_Point aTPntF, aTPntL;
+
+ Handle(IntPatch_WLine) wline =
+ new IntPatch_WLine(sline,Standard_False,
+ theLine->TransitionOnS1(),theLine->TransitionOnS2());
+
+ gp_Pnt aSPnt(sline->Value(1).Value());
+ sline->Value(1).ParametersOnS1(U1,V1);
+ sline->Value(1).ParametersOnS2(U2,V2);
+ aTPntF.SetValue(aSPnt,theArcTol,Standard_False);
+ aTPntF.SetParameters(U1,V1,U2,V2);
+ aTPntF.SetParameter(1.);
+ wline->AddVertex(aTPntF);
+ wline->SetFirstPoint(1);
+
+ if(hasInternals)
+ {
+ PutIntVertices(wline,sline,IsReversed,aVLine,theArcTol);
+ }
- Handle(IntPatch_WLine) wline =
- new IntPatch_WLine(sline,Standard_False,
- theLine->TransitionOnS1(),theLine->TransitionOnS2());
+ aSPnt = sline->Value(sline->NbPoints()).Value();
+ sline->Value(sline->NbPoints()).ParametersOnS1(U1,V1);
+ sline->Value(sline->NbPoints()).ParametersOnS2(U2,V2);
+ aTPntL.SetValue(aSPnt,theArcTol,Standard_False);
+ aTPntL.SetParameters(U1,V1,U2,V2);
+ aTPntL.SetParameter(sline->NbPoints());
+ wline->AddVertex(aTPntL);
+ wline->SetLastPoint(wline->NbVertex());
- gp_Pnt aSPnt(sline->Value(1).Value());
- sline->Value(1).ParametersOnS1(U1,V1);
- sline->Value(1).ParametersOnS2(U2,V2);
- aTPntF.SetValue(aSPnt,theArcTol,Standard_False);
- aTPntF.SetParameters(U1,V1,U2,V2);
- aTPntF.SetParameter(1.);
- wline->AddVertex(aTPntF);
- wline->SetFirstPoint(1);
+ IntPatch_SequenceOfLine segm;
+ Standard_Boolean isSplited = SplitOnSegments(wline,Standard_False,
+ theLine->TransitionOnS1(),theLine->TransitionOnS2(),theArcTol,segm);
- if(hasInternals)
- {
- PutIntVertices(wline,sline,IsReversed,aVLine,theArcTol);
+ if(!isSplited)
+ {
+ theLines.Append(wline);
+ }
+ else
+ {
+ Standard_Integer nbsegms = segm.Length();
+ Standard_Integer iseg = 0;
+ for(iseg = 1; iseg <= nbsegms; iseg++)
+ theLines.Append(segm(iseg));
+ }
}
+ else
+ {//theLine->ArcType() == IntPatch_Restriction
+ if(!isDecomposited && !hasBeenDecomposed)
+ {
+ //The line has not been changed
+ theLines.Append(Handle(IntPatch_RLine)::DownCast(theLine));
+ return hasBeenDecomposed;
+ }
- aSPnt = sline->Value(sline->NbPoints()).Value();
- sline->Value(sline->NbPoints()).ParametersOnS1(U1,V1);
- sline->Value(sline->NbPoints()).ParametersOnS2(U2,V2);
- aTPntL.SetValue(aSPnt,theArcTol,Standard_False);
- aTPntL.SetParameters(U1,V1,U2,V2);
- aTPntL.SetParameter(sline->NbPoints());
- wline->AddVertex(aTPntL);
- wline->SetLastPoint(sline->NbPoints());
+ IntPatch_Point aTPnt;
+ gp_Pnt2d aPSurf;
+ gp_Pnt aSPnt;
- IntPatch_SequenceOfLine segm;
- Standard_Boolean isSplited = SplitOnSegments(wline,Standard_False,
- theLine->TransitionOnS1(),theLine->TransitionOnS2(),theArcTol,segm);
+ Handle(IntPatch_RLine) aRLine = new IntPatch_RLine(*Handle(IntPatch_RLine)::DownCast(theLine));
+
+ aRLine->ClearVertexes();
+ aRLine->SetCurve(sline);
- if(!isSplited)
- {
- theLines.Append(wline);
- }
- else
- {
- Standard_Integer nbsegms = segm.Length();
- Standard_Integer iseg = 0;
- for(iseg = 1; iseg <= nbsegms; iseg++)
- theLines.Append(segm(iseg));
+ if(hasInternals)
+ {
+ PutIntVertices(aRLine,sline,IsReversed,aVLine,theArcTol);
+ }
+
+ const Handle(Adaptor2d_HCurve2d)& anArc = aRLine->IsArcOnS1() ?
+ aRLine->ArcOnS1() :
+ aRLine->ArcOnS2();
+
+ Standard_Real aFPar = anArc->FirstParameter(),
+ aLPar = anArc->LastParameter();
+
+ const IntSurf_PntOn2S &aRFirst = sline->Value(1),
+ &aRLast = sline->Value(sline->NbPoints());
+
+ const gp_Lin2d aLin(anArc->Curve2d().Line());
+
+ for(Standard_Integer aFLIndex = 0; aFLIndex < 2; aFLIndex++)
+ {
+ if(aFLIndex == 0)
+ {
+ aRFirst.Parameters(U1, V1, U2, V2);
+ aSPnt.SetXYZ(aRFirst.Value().XYZ());
+ }
+ else
+ {
+ aRLast.Parameters(U1, V1, U2, V2);
+ aSPnt.SetXYZ(aRLast.Value().XYZ());
+ }
+
+ if(IsReversed)
+ {
+ aPSurf.SetCoord(U1, V1);
+ }
+ else
+ {
+ aPSurf.SetCoord(U2, V2);
+ }
+
+ Standard_Real aPar = ElCLib::Parameter(aLin, aPSurf);
+
+ if(aFLIndex == 0)
+ {
+ aFPar = Max(aFPar, aPar);
+ aPar = aFPar;
+ }
+ else
+ {
+ aLPar = Min(aLPar, aPar);
+ aPar = aLPar;
+ }
+
+ aTPnt.SetParameter(aPar);
+ aTPnt.SetValue(aSPnt,theArcTol,Standard_False);
+ aTPnt.SetParameters(U1, V1, U2, V2);
+
+ aRLine->AddVertex(aTPnt);
+ }
+
+ if(aLPar - aFPar > Precision::PConfusion())
+ {
+ aRLine->SetFirstPoint(1);
+ aRLine->SetLastPoint(aRLine->NbVertex());
+
+ anArc->Trim(aFPar, aLPar, theArcTol);
+
+ theLines.Append(aRLine);
+ }
}
if(isDecomposited)
return hasBeenDecomposed;
}
-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 : CheckSegmSegm
+//purpose : Returns TRUE if the segment [theParF, theParL] is included
+// in the segment [theRefParF, theRefParL] segment.
+//=======================================================================
+static Standard_Boolean CheckSegmSegm(const Standard_Real theRefParF,
+ const Standard_Real theRefParL,
+ const Standard_Real theParF,
+ const Standard_Real theParL)
{
- const Standard_Integer aNbPnts = theLine->NbPnts();
+ if((theParF < theRefParF) || (theParF > theRefParL))
+ {
+ return Standard_False;
+ }
+
+ if((theParL < theRefParF) || (theParL > theRefParL))
+ {
+ return Standard_False;
+ }
+
+ return Standard_True;
+}
- const Standard_Real aDeltaUPeriod[] = {0.0, -theUPeriod, 2.0*theUPeriod};
- const Standard_Real aDeltaVPeriod[] = {0.0, -theVPeriod, 2.0*theVPeriod};
+//=======================================================================
+//function : IsCoincide
+//purpose : Check, if theLine is coincided with theArc (in 2d-space).
+//
+// Attention!!!
+// Cases when theArc is not 2d-line adaptor are suppored by
+// TopOpeBRep classes only (i.e. are archaic).
+//=======================================================================
+Standard_Boolean IsCoincide(IntPatch_TheSurfFunction& theFunc,
+ const Handle(IntPatch_PointLine)& theLine,
+ const Handle(Adaptor2d_HCurve2d)& theArc,
+ const Standard_Boolean isTheSurface1Using, //Surf1 is parametric?
+ const Standard_Real theToler3D,
+ const Standard_Real theToler2D,
+ const Standard_Real thePeriod) // Period of parametric surface in direction which is perpendicular to theArc direction.
+{
+ if(theLine->ArcType() == IntPatch_Restriction)
+ {//Restriction-restriction processing
+ const Handle(IntPatch_RLine)& aRL2 = Handle(IntPatch_RLine)::DownCast(theLine);
+ const Handle(Adaptor2d_HCurve2d)& anArc = aRL2->IsArcOnS1() ? aRL2->ArcOnS1() : aRL2->ArcOnS2();
+
+ if(anArc->Curve2d().GetType() != GeomAbs_Line)
+ {
+ //Restriction line must be isoline.
+ //Other cases are not supported by
+ //existing algorithms.
+
+ return Standard_False;
+ }
+
+ const gp_Lin2d aLin1(theArc->Curve2d().Line()),
+ aLin2(anArc->Curve2d().Line());
+
+ if(!aLin1.Direction().IsParallel(aLin2.Direction(), Precision::Angular()))
+ {
+ return Standard_False;
+ }
+
+ const Standard_Real aDist =
+ theArc->Curve2d().Line().Distance(anArc->Curve2d().Line());
+ if((aDist < theToler2D) || (Abs(aDist - thePeriod) < theToler2D))
+ {
+ const Standard_Real aRf = theArc->FirstParameter(),
+ aRl = theArc->LastParameter();
+ const Standard_Real aParf = anArc->FirstParameter(),
+ aParl = anArc->LastParameter();
+ const gp_Pnt2d aP1(ElCLib::Value(aParf, aLin2)),
+ aP2(ElCLib::Value(aParl, aLin2));
+
+ Standard_Real aParam1 = ElCLib::Parameter(aLin1, aP1),
+ aParam2 = ElCLib::Parameter(aLin1, aP2);
+
+ if(CheckSegmSegm(aRf, aRl, aParam1, aParam2))
+ return Standard_True;
+
+ //Lines are parallel. Therefore, there is no point in
+ //projecting points to another line in order to check
+ //if segment second line is included in segment of first one.
+
+ return CheckSegmSegm(aParam1, aParam2, aRf, aRl);
+ }
+
+ return Standard_False;
+ }
+
+ const Standard_Integer aNbPnts = theLine->NbPnts();
+ const Standard_Real aUAf = theArc->FirstParameter(),
+ aUAl = theArc->LastParameter();
+ const gp_Lin2d anArcLin(theArc->Curve2d().Line());
- const Standard_Integer aSzOfUPArr = sizeof(aDeltaUPeriod)/sizeof(aDeltaUPeriod[0]);
- const Standard_Integer aSzOfVPArr = sizeof(aDeltaVPeriod)/sizeof(aDeltaVPeriod[0]);
+ math_Vector aX(1, 2), aVal(1, 1);
for(Standard_Integer aPtID = 1; aPtID <= aNbPnts; aPtID++)
{
- Standard_Real aU = 0.0, aV = 0.0;
+ Standard_Real aUf = 0.0, aVf = 0.0;
if(isTheSurface1Using)
- theLine->Point(aPtID).ParametersOnS1(aU, aV);
+ theLine->Point(aPtID).ParametersOnS1(aUf, aVf);
else
- theLine->Point(aPtID).ParametersOnS2(aU, aV);
+ theLine->Point(aPtID).ParametersOnS2(aUf, aVf);
+
+ //Take 2d-point in parametric surface (because theArc is
+ //2d-line in parametric surface).
+ const gp_Pnt2d aPloc(aUf, aVf);
+
+ const Standard_Real aRParam = ElCLib::Parameter(anArcLin, aPloc);
+
+ if((aRParam < aUAf) || (aRParam > aUAl))
+ return Standard_False;
- if(!theBox.IsOut(gp_Pnt2d(aU, aV)))
+ const gp_Pnt2d aPmin(ElCLib::Value(aRParam, anArcLin));
+
+ const Standard_Real aDist = aPloc.Distance(aPmin);
+ if((aDist < theToler2D) || (Abs(aDist - thePeriod) < theToler2D))
+ {//Considered point is in Restriction line.
+ //Go to the next point.
continue;
+ }
- Standard_Boolean isInscribe = Standard_False;
+ //Check if intermediate points between aPloc and theArc are
+ //intersection point (i.e. if aPloc is in tangent zone between
+ //two intersected surfaces).
- for(Standard_Integer aUind = 0; !isInscribe && (aUind < aSzOfUPArr); aUind++)
+ const Standard_Real aUl = aPmin.X(), aVl = aPmin.Y();
+
+ const Standard_Integer aNbPoints = 4;
+ const Standard_Real aStepU = (aUl - aUf)/aNbPoints,
+ aStepV = (aVl - aVf)/aNbPoints;
+
+ Standard_Real aU = aUf+aStepU, aV = aVf+aStepV;
+ for(Standard_Integer i = 1; i < aNbPoints; i++)
{
- if((aUind > 0) && (aDeltaUPeriod[aUind] == 0.0))
+ aX.Value(1) = aU;
+ aX.Value(2) = aV;
+
+ if(!theFunc.Value(aX, aVal))
{
- break;
+ return Standard_False;
}
- aU += aDeltaUPeriod[aUind];
-
- for(Standard_Integer aVind = 0; !isInscribe && (aVind < aSzOfVPArr); aVind++)
+ if(Abs(aVal(1)) > theToler3D)
{
- if((aVind > 0) && (aDeltaVPeriod[aVind] == 0.0))
- {
- break;
- }
-
- aV += aDeltaVPeriod[aVind];
-
- isInscribe = !theBox.IsOut(gp_Pnt2d(aU, aV));
+ return Standard_False;
}
+
+ aU += aStepU;
+ aV += aStepV;
}
-
- if(!isInscribe)
- return Standard_False;
}
+
return Standard_True;
-}
+}
\ No newline at end of file