const Standard_Real Tol,
const Standard_Boolean Approx,
const Standard_Boolean ApproxS1,
- const Standard_Boolean ApproxS2,
- const Standard_Boolean theIsReqToPostWLProc)
+ const Standard_Boolean ApproxS2)
{
myHS1 = new GeomAdaptor_HSurface(S1);
if (S1==S2)
myHS2 = myHS1;
else
myHS2 = new GeomAdaptor_HSurface(S2);
- InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.,theIsReqToPostWLProc);
+ InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.);
}
//=======================================================================
const Standard_Real U2, const Standard_Real V2,
const Standard_Boolean Approx,
const Standard_Boolean ApproxS1,
- const Standard_Boolean ApproxS2,
- const Standard_Boolean theIsReqToPostWLProc)
+ const Standard_Boolean ApproxS2)
{
myHS1 = new GeomAdaptor_HSurface(S1);
if (S1==S2)
myHS2 = myHS1;
else
myHS2 = new GeomAdaptor_HSurface(S2);
- InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2,theIsReqToPostWLProc);
+ InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2);
}
//=======================================================================
const Standard_Real U1,
const Standard_Real V1,
const Standard_Real U2,
- const Standard_Real V2,
- const Standard_Boolean theIsReqToPostWLProc)
+ const Standard_Real V2)
{
myTolReached2d = myTolReached3d = 0.0;
myNbrestr = 0;
myIntersector.Perform(myHS1,dom1,TolArc,TolTang);
}
else if (!useStart) {
- myIntersector.Perform(myHS1,dom1,myHS2,dom2,TolArc,TolTang,Standard_True, Standard_False, theIsReqToPostWLProc);
+ myIntersector.Perform(myHS1, dom1, myHS2, dom2,
+ TolArc,TolTang,Standard_True, Standard_False);
}
else {
myIntersector.Perform(myHS1,dom1,myHS2,dom2,U1,V1,U2,V2,TolArc,TolTang);
GeomInt_IntSS(const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
//! general intersection of two surfaces
- Standard_EXPORT void Perform (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
+ Standard_EXPORT void Perform (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
//! intersection of adapted surfaces
- void Perform (const Handle(GeomAdaptor_HSurface)& HS1, const Handle(GeomAdaptor_HSurface)& HS2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
+ void Perform (const Handle(GeomAdaptor_HSurface)& HS1, const Handle(GeomAdaptor_HSurface)& HS2, const Standard_Real Tol, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
//! general intersection using a starting point
- Standard_EXPORT void Perform (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
+ Standard_EXPORT void Perform (const Handle(Geom_Surface)& S1, const Handle(Geom_Surface)& S2, const Standard_Real Tol, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
//! intersection of adapted surfaces using a starting point
- void Perform (const Handle(GeomAdaptor_HSurface)& HS1, const Handle(GeomAdaptor_HSurface)& HS2, const Standard_Real Tol, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
+ void Perform (const Handle(GeomAdaptor_HSurface)& HS1, const Handle(GeomAdaptor_HSurface)& HS2, const Standard_Real Tol, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean Approx = Standard_True, const Standard_Boolean ApproxS1 = Standard_False, const Standard_Boolean ApproxS2 = Standard_False);
Standard_Boolean IsDone() const;
protected:
- Standard_EXPORT void InternalPerform (const Standard_Real Tol, const Standard_Boolean Approx, const Standard_Boolean ApproxS1, const Standard_Boolean ApproxS2, const Standard_Boolean useStart, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Boolean theIsReqToPostWLProc);
+ Standard_EXPORT void InternalPerform (const Standard_Real Tol, const Standard_Boolean Approx, const Standard_Boolean ApproxS1, const Standard_Boolean ApproxS2, const Standard_Boolean useStart, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2);
Standard_EXPORT void MakeCurve (const Standard_Integer Ind, const Handle(Adaptor3d_TopolTool)& D1, const Handle(Adaptor3d_TopolTool)& D2, const Standard_Real Tol, const Standard_Boolean Approx, const Standard_Boolean Approx1, const Standard_Boolean Approx2);
const Standard_Real Tol,
const Standard_Boolean Approx,
const Standard_Boolean ApproxS1,
- const Standard_Boolean ApproxS2,
- const Standard_Boolean theIsReqToPostWLProc)
+ const Standard_Boolean ApproxS2)
{
myHS1 = HS1;
myHS2 = HS2;
- InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.,theIsReqToPostWLProc);
+ InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_False,0.,0.,0.,0.);
}
//=======================================================================
const Standard_Real U2, const Standard_Real V2,
const Standard_Boolean Approx,
const Standard_Boolean ApproxS1,
- const Standard_Boolean ApproxS2,
- const Standard_Boolean theIsReqToPostWLProc)
+ const Standard_Boolean ApproxS2)
{
myHS1 = HS1;
myHS2 = HS2;
- InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2,theIsReqToPostWLProc);
+ InternalPerform(Tol,Approx,ApproxS1,ApproxS2,Standard_True,U1,V1,U2,V2);
}
//=======================================================================
Handle(GeomAdaptor_HSurface) AS1,AS2;
Standard_Real tol = Precision::Confusion();
Standard_Real UVsta[4];
- Standard_Boolean useStart = Standard_False, useBnd = Standard_False, isPostProcessingReq = Standard_True;
+ Standard_Boolean useStart = Standard_False, useBnd = Standard_False;
for(Standard_Integer i = 4; i < n; i++)
{
{
tol = Draw::Atof(a[++i]);
}
-
- if(!strcmp(a[i], "-npp"))
- {
- isPostProcessingReq = Standard_False;
- }
}
//
Handle(Geom_Curve) Result;
if(!useStart && !useBnd)
{
// General case
- Inters.Perform(GS1,GS2,tol,Standard_True, Standard_False, Standard_False, isPostProcessingReq);
+ Inters.Perform(GS1,GS2,tol,Standard_True, Standard_False, Standard_False);
}
else if (useStart && !useBnd)
{
- Inters.Perform(GS1,GS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3], Standard_True, Standard_False, Standard_False, Standard_True);
+ Inters.Perform(GS1,GS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3], Standard_True, Standard_False, Standard_False);
}
else if (!useStart && useBnd)
{
- Inters.Perform(AS1,AS2,tol,Standard_True, Standard_False, Standard_False, Standard_True);
+ Inters.Perform(AS1,AS2,tol,Standard_True, Standard_False, Standard_False);
}
else
{
- Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3], Standard_True, Standard_False, Standard_False, Standard_True);
+ Inters.Perform(AS1,AS2,tol,UVsta[0],UVsta[1],UVsta[2],UVsta[3], Standard_True, Standard_False, Standard_False);
}
//
if (!Inters.IsDone())
theCommands.Add("intersect",
"intersect result surf1 surf2 [-sp u1 v1 u2 v2] [-b U1F U1L V1F V1L U2F U2L V2F V2L] [-t tolerance] [-npp] : "
"Use:\n -sp option for setting start point;\n -b option for setting bounds;\n "
- "-t option for setting tolerance;\n -npp option for switching off post-processing intersection line (e.g. avoid purger)",
+ "-t option for setting tolerance;\n",
__FILE__,
intersection,g);
aWLine->ComputeVertexParameters(myTol3D);
- aWLine->EnablePurging(Standard_False);
theLines.Append(aWLine);
}//while(aParameter < theLPar)
}
const Standard_Real TolArc,
const Standard_Real TolTang,
const Standard_Boolean isGeomInt,
- const Standard_Boolean theIsReqToKeepRLine,
- const Standard_Boolean theIsReqToPostWLProc)
+ const Standard_Boolean theIsReqToKeepRLine)
{
myTolArc = TolArc;
myTolTang = TolTang;
ParamParamPerfom(theS1, theD1, theS2, theD2, TolArc,
TolTang, ListOfPnts, RestrictLine, typs1, typs2);
}
-
- if(!theIsReqToPostWLProc)
- return;
-
- for(Standard_Integer i = slin.Lower(); i <= slin.Upper(); i++)
- {
- Handle(IntPatch_WLine) aWL = Handle(IntPatch_WLine)::DownCast(slin.Value(i));
-
- if(aWL.IsNull())
- continue;
-
- if (!aWL->IsPurgingAllowed())
- continue;
-
- Handle(IntPatch_WLine) aRW =
- IntPatch_WLineTool::ComputePurgedWLine(aWL, theS1, theS2, theD1, theD2, RestrictLine);
-
- if(aRW.IsNull())
- continue;
-
- slin.InsertAfter(i, aRW);
- slin.Remove(i);
- }
}
//=======================================================================
IntSurf_ListOfPntOn2S& ListOfPnts,
const Standard_Boolean RestrictLine,
const Standard_Boolean isGeomInt,
- const Standard_Boolean theIsReqToKeepRLine,
- const Standard_Boolean theIsReqToPostWLProc)
+ const Standard_Boolean theIsReqToKeepRLine)
{
myTolArc = TolArc;
myTolTang = TolTang;
GeomGeomPerfom(theS1, theD1, theS2, theD2, TolArc,
TolTang, ListOfPnts, RestrictLine, typs1, typs2, theIsReqToKeepRLine);
}
-
- if(!theIsReqToPostWLProc)
- return;
-
- for(Standard_Integer i = slin.Lower(); i <= slin.Upper(); i++)
- {
- Handle(IntPatch_WLine) aWL = Handle(IntPatch_WLine)::DownCast(slin.Value(i));
-
- if(aWL.IsNull())
- continue;
-
- if(!aWL->IsPurgingAllowed())
- continue;
-
- Handle(IntPatch_WLine) aRW =
- IntPatch_WLineTool::ComputePurgedWLine(aWL, theS1, theS2, theD1, theD2, RestrictLine);
-
- if(aRW.IsNull())
- continue;
-
- slin.InsertAfter(i, aRW);
- slin.Remove(i);
- }
}
//=======================================================================
}
else
{
- if (line->ArcType() == IntPatch_Walking)
- {
- Handle(IntPatch_WLine)::DownCast(line)->EnablePurging(Standard_False);
- }
-
if((line->ArcType() != IntPatch_Restriction) || theIsReqToKeepRLine)
slin.Append(line);
}
for (; i<=nblm; i++) slin.Append(interpp.Line(i));
}
}
-
- for(Standard_Integer i = slin.Lower(); i <= slin.Upper(); i++)
- {
- Handle(IntPatch_WLine) aWL = Handle(IntPatch_WLine)::DownCast(slin.Value(i));
-
- if(aWL.IsNull())
- continue;
-
- if (!aWL->IsPurgingAllowed())
- continue;
-
- Handle(IntPatch_WLine) aRW =
- IntPatch_WLineTool::ComputePurgedWLine(aWL, S1, S2, D1, D2, Standard_True);
-
- if(aRW.IsNull())
- continue;
-
- slin.InsertAfter(i, aRW);
- slin.Remove(i);
- }
}
#ifdef DUMPOFIntPatch_Intersection
//! after deleting TopOpeBRep.
//! If theIsReqToPostWLProc == FALSE, then we will work with Walking-line
//! obtained after intersection algorithm directly (wothout any post-processing).
- Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& S1, const Handle(Adaptor3d_TopolTool)& D1, const Handle(Adaptor3d_HSurface)& S2, const Handle(Adaptor3d_TopolTool)& D2, const Standard_Real TolArc, const Standard_Real TolTang, const Standard_Boolean isGeomInt = Standard_True, const Standard_Boolean theIsReqToKeepRLine = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
+ Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& S1, const Handle(Adaptor3d_TopolTool)& D1, const Handle(Adaptor3d_HSurface)& S2, const Handle(Adaptor3d_TopolTool)& D2, const Standard_Real TolArc, const Standard_Real TolTang, const Standard_Boolean isGeomInt = Standard_True, const Standard_Boolean theIsReqToKeepRLine = Standard_False);
//! If isGeomInt == Standard_False, then method
//! Param-Param intersection will be used.
//! after deleting TopOpeBRep.
//! If theIsReqToPostWLProc == FALSE, then we will work with Walking-line
//! obtained after intersection algorithm directly (wothout any post-processing).
- Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& S1, const Handle(Adaptor3d_TopolTool)& D1, const Handle(Adaptor3d_HSurface)& S2, const Handle(Adaptor3d_TopolTool)& D2, const Standard_Real TolArc, const Standard_Real TolTang, IntSurf_ListOfPntOn2S& LOfPnts, const Standard_Boolean RestrictLine = Standard_True, const Standard_Boolean isGeomInt = Standard_True, const Standard_Boolean theIsReqToKeepRLine = Standard_False, const Standard_Boolean theIsReqToPostWLProc = Standard_True);
+ Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& S1, const Handle(Adaptor3d_TopolTool)& D1, const Handle(Adaptor3d_HSurface)& S2, const Handle(Adaptor3d_TopolTool)& D2, const Standard_Real TolArc, const Standard_Real TolTang, IntSurf_ListOfPntOn2S& LOfPnts, const Standard_Boolean RestrictLine = Standard_True, const Standard_Boolean isGeomInt = Standard_True, const Standard_Boolean theIsReqToKeepRLine = Standard_False);
//! Perform with start point
Standard_EXPORT void Perform (const Handle(Adaptor3d_HSurface)& S1, const Handle(Adaptor3d_TopolTool)& D1, const Handle(Adaptor3d_HSurface)& S2, const Handle(Adaptor3d_TopolTool)& D2, const Standard_Real U1, const Standard_Real V1, const Standard_Real U2, const Standard_Real V2, const Standard_Real TolArc, const Standard_Real TolTang);
if(bPWIsDone)
{
- Standard_Boolean hasBeenAdded = Standard_False;
if(PW.NbPoints() > 2 )
{
//Try to extend the intersection line to the boundary,
const Standard_Integer aMinNbPoints = 40;
//if(PW.NbPoints() < aMinNbPoints)
//{
- // hasBeenAdded = PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints);
+ // PW.SeekAdditionalPoints(Surf1, Surf2, aMinNbPoints);
//}
Standard_Integer iPWNbPoints = PW.NbPoints(), aNbPointsVer = 0;
Standard_Real TolTang = TolTangency;
Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
- wline->EnablePurging(!hasBeenAdded);
IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
if(wline->NbVertex() == 0)
if(PW.IsDone())
{
- Standard_Boolean hasBeenAdded = Standard_False;
if(PW.NbPoints()>2)
{
//const Standard_Integer aMinNbPoints = 40;
Standard_Real TolTang = TolTangency;
Handle(IntPatch_WLine) wline = new IntPatch_WLine(PW.Line(),Standard_False,trans1,trans2);
- wline->EnablePurging(!hasBeenAdded);
IntPatch_RstInt::PutVertexOnLine(wline,Surf1,D1,Surf2,Standard_True,TolTang);
IntPatch_RstInt::PutVertexOnLine(wline,Surf2,D2,Surf1,Standard_False,TolTang);
const IntSurf_TypeTrans Trans1,
const IntSurf_TypeTrans Trans2) :
IntPatch_PointLine(Tang,Trans1,Trans2),fipt(Standard_False),lapt(Standard_False),
- hasArcOnS1(Standard_False),hasArcOnS2(Standard_False),
- myIsPurgerAllowed(Standard_True)
+ hasArcOnS1(Standard_False),hasArcOnS2(Standard_False)
{
typ = IntPatch_Walking;
curv = Line;
const IntSurf_Situation Situ1,
const IntSurf_Situation Situ2) :
IntPatch_PointLine(Tang,Situ1,Situ2),fipt(Standard_False),lapt(Standard_False),
- hasArcOnS1(Standard_False),hasArcOnS2(Standard_False),
- myIsPurgerAllowed(Standard_True)
+ hasArcOnS1(Standard_False),hasArcOnS2(Standard_False)
{
typ = IntPatch_Walking;
curv = Line;
IntPatch_WLine::IntPatch_WLine (const Handle(IntSurf_LineOn2S)& Line,
const Standard_Boolean Tang) :
IntPatch_PointLine(Tang),fipt(Standard_False),lapt(Standard_False),
- hasArcOnS1(Standard_False),hasArcOnS2(Standard_False),
- myIsPurgerAllowed(Standard_True)
+ hasArcOnS1(Standard_False),hasArcOnS2(Standard_False)
{
typ = IntPatch_Walking;
curv = Line;
//! Otherwise, prints list of 2d-points on the 2nd surface
Standard_EXPORT void Dump(const Standard_Integer theMode) const;
- //! Allows or forbides purging of existing WLine
- void EnablePurging(const Standard_Boolean theIsEnabled)
- {
- myIsPurgerAllowed = theIsEnabled;
- }
-
- //! Returns TRUE if purging is allowed or forbiden for existing WLine
- Standard_Boolean IsPurgingAllowed()
- {
- return myIsPurgerAllowed;
- }
-
-
DEFINE_STANDARD_RTTIEXT(IntPatch_WLine,IntPatch_PointLine)
protected:
private:
-
-
Handle(IntSurf_LineOn2S) curv;
Standard_Boolean fipt;
Standard_Boolean lapt;
Handle(Adaptor2d_HCurve2d) theArcOnS1;
Standard_Boolean hasArcOnS2;
Handle(Adaptor2d_HCurve2d) theArcOnS2;
- Standard_Boolean myIsPurgerAllowed;
-
-
};
}
}
-//=========================================================================
-// function : FillPointsHash
-// purpose : Fill points hash by input data.
-// Static subfunction in ComputePurgedWLine.
-//=========================================================================
-static void FillPointsHash(const Handle(IntPatch_WLine) &theWLine,
- NCollection_Array1<Standard_Integer> &thePointsHash)
-{
- // 1 - Delete point.
- // 0 - Store point.
- // -1 - Vertex point (not delete).
- Standard_Integer i, v;
-
- for(i = 1; i <= theWLine->NbPnts(); i++)
- thePointsHash.SetValue(i, 0);
-
- for(v = 1; v <= theWLine->NbVertex(); v++)
- {
- IntPatch_Point aVertex = theWLine->Vertex(v);
- Standard_Integer avertexindex = (Standard_Integer)aVertex.ParameterOnLine();
- thePointsHash.SetValue(avertexindex, -1);
- }
-}
-
-//=========================================================================
-// function : MakeNewWLine
-// purpose : Makes new walking line according to the points hash
-// Static subfunction in ComputePurgedWLine and DeleteOuter.
-//=========================================================================
-static Handle(IntPatch_WLine) MakeNewWLine(const Handle(IntPatch_WLine) &theWLine,
- const NCollection_Array1<Standard_Integer> &thePointsHash)
-{
- Standard_Integer i;
-
- Handle(IntSurf_LineOn2S) aPurgedLineOn2S = new IntSurf_LineOn2S();
- Handle(IntPatch_WLine) aLocalWLine = new IntPatch_WLine(aPurgedLineOn2S, Standard_False);
- Standard_Integer anOldLineIdx = 1, aVertexIdx = 1;
- for(i = 1; i <= thePointsHash.Upper(); i++)
- {
- if (thePointsHash(i) == 0)
- {
- // Store this point.
- aPurgedLineOn2S->Add(theWLine->Point(i));
- anOldLineIdx++;
- }
- else if (thePointsHash(i) == -1)
- {
- // Add vertex.
- IntPatch_Point aVertex = theWLine->Vertex(aVertexIdx++);
- aVertex.SetParameter(anOldLineIdx++);
- aLocalWLine->AddVertex(aVertex);
- aPurgedLineOn2S->Add(theWLine->Point(i));
- }
- }
-
- return aLocalWLine;
-}
-
-//=========================================================================
-// function : MovePoint
-// purpose : Move point into surface param space. No interpolation used
-// because walking algorithm should care for closeness to the param space.
-// Static subfunction in ComputePurgedWLine.
-//=========================================================================
-static void MovePoint(const Handle(Adaptor3d_HSurface) &theS1,
- Standard_Real &U1, Standard_Real &V1)
-{
- if (U1 < theS1->FirstUParameter())
- U1 = theS1->FirstUParameter();
-
- if (U1 > theS1->LastUParameter())
- U1 = theS1->LastUParameter();
-
- if (V1 < theS1->FirstVParameter())
- V1 = theS1->FirstVParameter();
-
- if (V1 > theS1->LastVParameter())
- V1 = theS1->LastVParameter();
-}
-
-//=========================================================================
-// function : DeleteOuterPoints
-// purpose : Check and delete out of bounds points on walking line.
-// Static subfunction in ComputePurgedWLine.
-//=========================================================================
-static Handle(IntPatch_WLine)
- DeleteOuterPoints(const Handle(IntPatch_WLine) &theWLine,
- const Handle(Adaptor3d_HSurface) &theS1,
- const Handle(Adaptor3d_HSurface) &theS2,
- const Handle(Adaptor3d_TopolTool) &theDom1,
- const Handle(Adaptor3d_TopolTool) &theDom2)
-{
- Standard_Integer i;
-
- NCollection_Array1<Standard_Integer> aDelOuterPointsHash(1, theWLine->NbPnts());
- FillPointsHash(theWLine, aDelOuterPointsHash);
-
- if (theS1->IsUPeriodic() || theS1->IsVPeriodic() ||
- theS2->IsUPeriodic() || theS2->IsVPeriodic() )
- return theWLine;
-
- gp_Pnt2d aPntOnF1, aPntOnF2;
- Standard_Real aX1, aY1, aX2, aY2;
-
- // Iterate over points in walking line and delete which are out of bounds.
- // Forward.
- Standard_Boolean isAllDeleted = Standard_True;
- Standard_Boolean aChangedFirst = Standard_False;
- Standard_Integer aFirstGeomIdx = 1;
- for(i = 1; i <= theWLine->NbPnts(); i++)
- {
- theWLine->Point(i).Parameters(aX1, aY1, aX2, aY2);
- aPntOnF1.SetCoord(aX1, aY1);
- aPntOnF2.SetCoord(aX2, aY2);
-
- TopAbs_State aState1 = theDom1->Classify(aPntOnF1, Precision::Confusion());
- TopAbs_State aState2 = theDom2->Classify(aPntOnF2, Precision::Confusion());
-
- if (aState1 == TopAbs_OUT ||
- aState2 == TopAbs_OUT )
- {
- aDelOuterPointsHash(i) = 1;
- aChangedFirst = Standard_True;
- }
- else
- {
- isAllDeleted = Standard_False;
-
- aFirstGeomIdx = Max (i - 1, 1);
- if (aDelOuterPointsHash(i) == -1)
- aFirstGeomIdx = i; // Use data what lies in (i) point / vertex.
-
- aDelOuterPointsHash(i) = -1;
- break;
- }
- }
-
- if (isAllDeleted)
- {
- // ALL points are out of bounds:
- // case boolean bcut_complex F5 and similar.
- return theWLine;
- }
-
- // Backward.
- Standard_Boolean aChangedLast = Standard_False;
- Standard_Integer aLastGeomIdx = theWLine->NbPnts();
- for(i = theWLine->NbPnts(); i >= 1; i--)
- {
- theWLine->Point(i).Parameters(aX1, aY1, aX2, aY2);
- aPntOnF1.SetCoord(aX1, aY1);
- aPntOnF2.SetCoord(aX2, aY2);
-
- TopAbs_State aState1 = theDom1->Classify(aPntOnF1, Precision::Confusion());
- TopAbs_State aState2 = theDom2->Classify(aPntOnF2, Precision::Confusion());
-
- if (aState1 == TopAbs_OUT ||
- aState2 == TopAbs_OUT )
- {
- aDelOuterPointsHash(i) = 1;
- aChangedLast = Standard_True; // Move vertex to first good point
- }
- else
- {
- aLastGeomIdx = Min (i + 1, theWLine->NbPnts());
- if (aDelOuterPointsHash(i) == -1)
- aLastGeomIdx = i; // Use data what lies in (i) point / vertex.
-
- aDelOuterPointsHash(i) = -1;
- break;
- }
- }
-
- if (!aChangedFirst && !aChangedLast)
- {
- // Nothing is done, return input.
- return theWLine;
- }
-
- // Build new line and modify geometry of necessary vertexes.
- Handle(IntPatch_WLine) aLocalWLine = MakeNewWLine(theWLine, aDelOuterPointsHash);
-
- if (aChangedFirst)
- {
- // Vertex geometry.
- IntPatch_Point aVertex = aLocalWLine->Vertex(1);
- aVertex.SetValue(theWLine->Point(aFirstGeomIdx).Value());
- Standard_Real aU1, aU2, aV1, aV2;
- theWLine->Point(aFirstGeomIdx).Parameters(aU1, aV1, aU2, aV2);
- MovePoint(theS1, aU1, aV1);
- MovePoint(theS2, aU2, aV2);
- aVertex.SetParameters(aU1, aV1, aU2, aV2);
- aLocalWLine->Replace(1, aVertex);
- // Change point in walking line.
- aLocalWLine->SetPoint(1, aVertex);
- }
-
- if (aChangedLast)
- {
- // Vertex geometry.
- IntPatch_Point aVertex = aLocalWLine->Vertex(aLocalWLine->NbVertex());
- aVertex.SetValue(theWLine->Point(aLastGeomIdx).Value());
- Standard_Real aU1, aU2, aV1, aV2;
- theWLine->Point(aLastGeomIdx).Parameters(aU1, aV1, aU2, aV2);
- MovePoint(theS1, aU1, aV1);
- MovePoint(theS2, aU2, aV2);
- aVertex.SetParameters(aU1, aV1, aU2, aV2);
- aLocalWLine->Replace(aLocalWLine->NbVertex(), aVertex);
- // Change point in walking line.
- aLocalWLine->SetPoint(aLocalWLine->NbPnts(), aVertex);
- }
-
-
- return aLocalWLine;
-}
-
-//=========================================================================
-// function : IsInsideIn2d
-// purpose : Check if aNextPnt lies inside of tube build on aBasePnt and aBaseVec.
-// In 2d space. Static subfunction in DeleteByTube.
-//=========================================================================
-static Standard_Boolean IsInsideIn2d(const gp_Pnt2d& aBasePnt,
- const gp_Vec2d& aBaseVec,
- const gp_Pnt2d& aNextPnt,
- const Standard_Real aSquareMaxDist)
-{
- gp_Vec2d aVec2d(aBasePnt, aNextPnt);
-
- //d*d = (basevec^(nextpnt-basepnt))**2 / basevec**2
- Standard_Real aCross = aVec2d.Crossed(aBaseVec);
- Standard_Real aSquareDist = aCross * aCross
- / aBaseVec.SquareMagnitude();
-
- return (aSquareDist <= aSquareMaxDist);
-}
-
-//=========================================================================
-// function : IsInsideIn3d
-// purpose : Check if aNextPnt lies inside of tube build on aBasePnt and aBaseVec.
-// In 3d space. Static subfunction in DeleteByTube.
-//=========================================================================
-static Standard_Boolean IsInsideIn3d(const gp_Pnt& aBasePnt,
- const gp_Vec& aBaseVec,
- const gp_Pnt& aNextPnt,
- const Standard_Real aSquareMaxDist)
-{
- gp_Vec aVec(aBasePnt, aNextPnt);
-
- //d*d = (basevec^(nextpnt-basepnt))**2 / basevec**2
- Standard_Real aSquareDist = aVec.CrossSquareMagnitude(aBaseVec)
- / aBaseVec.SquareMagnitude();
-
- return (aSquareDist <= aSquareMaxDist);
-}
-
-static const Standard_Integer aMinNbBadDistr = 15;
-static const Standard_Integer aNbSingleBezier = 30;
-
-//=========================================================================
-// function : DeleteByTube
-// purpose : Check and delete points using tube criteria.
-// Static subfunction in ComputePurgedWLine.
-//=========================================================================
-static Handle(IntPatch_WLine)
- DeleteByTube(const Handle(IntPatch_WLine) &theWLine,
- const Handle(Adaptor3d_HSurface) &theS1,
- const Handle(Adaptor3d_HSurface) &theS2)
-{
- // III: Check points for tube criteria:
- // Workaround to handle case of small amount points after purge.
- // Test "boolean boptuc_complex B5" and similar.
- Standard_Integer aNbPnt = 0 , i;
-
- if (theWLine->NbPnts() <= 2)
- return theWLine;
-
- NCollection_Array1<Standard_Integer> aNewPointsHash(1, theWLine->NbPnts());
- FillPointsHash(theWLine, aNewPointsHash);
-
- // Inital computations.
- Standard_Real UonS1[3], VonS1[3], UonS2[3], VonS2[3];
- theWLine->Point(1).ParametersOnS1(UonS1[0], VonS1[0]);
- theWLine->Point(2).ParametersOnS1(UonS1[1], VonS1[1]);
- theWLine->Point(1).ParametersOnS2(UonS2[0], VonS2[0]);
- theWLine->Point(2).ParametersOnS2(UonS2[1], VonS2[1]);
-
- gp_Pnt2d aBase2dPnt1(UonS1[0], VonS1[0]);
- gp_Pnt2d aBase2dPnt2(UonS2[0], VonS2[0]);
- gp_Vec2d aBase2dVec1(UonS1[1] - UonS1[0], VonS1[1] - VonS1[0]);
- gp_Vec2d aBase2dVec2(UonS2[1] - UonS2[0], VonS2[1] - VonS2[0]);
- gp_Pnt aBase3dPnt = theWLine->Point(1).Value();
- gp_Vec aBase3dVec(theWLine->Point(1).Value(), theWLine->Point(2).Value());
-
- // Choose base tolerance and scale it to pipe algorithm.
- const Standard_Real aBaseTolerance = Precision::Approximation();
- Standard_Real aResS1Tol = Min(theS1->UResolution(aBaseTolerance),
- theS1->VResolution(aBaseTolerance));
- Standard_Real aResS2Tol = Min(theS2->UResolution(aBaseTolerance),
- theS2->VResolution(aBaseTolerance));
- Standard_Real aTol1 = aResS1Tol * aResS1Tol;
- Standard_Real aTol2 = aResS2Tol * aResS2Tol;
- Standard_Real aTol3d = aBaseTolerance * aBaseTolerance;
-
- const Standard_Real aLimitCoeff = 0.99 * 0.99;
- for(i = 3; i <= theWLine->NbPnts(); i++)
- {
- Standard_Boolean isDeleteState = Standard_False;
-
- theWLine->Point(i).ParametersOnS1(UonS1[2], VonS1[2]);
- theWLine->Point(i).ParametersOnS2(UonS2[2], VonS2[2]);
- gp_Pnt2d aPnt2dOnS1(UonS1[2], VonS1[2]);
- gp_Pnt2d aPnt2dOnS2(UonS2[2], VonS2[2]);
- const gp_Pnt& aPnt3d = theWLine->Point(i).Value();
-
- if (aNewPointsHash(i - 1) != - 1 &&
- IsInsideIn2d(aBase2dPnt1, aBase2dVec1, aPnt2dOnS1, aTol1) &&
- IsInsideIn2d(aBase2dPnt2, aBase2dVec2, aPnt2dOnS2, aTol2) &&
- IsInsideIn3d(aBase3dPnt, aBase3dVec, aPnt3d, aTol3d) )
- {
- // Handle possible uneven parametrization on one of 2d subspaces.
- // Delete point only when expected lengths are close to each other (aLimitCoeff).
- // Example:
- // c2d1 - line
- // c3d - line
- // c2d2 - geometrically line, but have uneven parametrization -> c2d2 is bspline.
- gp_XY aPntOnS1[2]= { gp_XY(UonS1[1] - UonS1[0], VonS1[1] - VonS1[0])
- , gp_XY(UonS1[2] - UonS1[1], VonS1[2] - VonS1[1])};
- gp_XY aPntOnS2[2]= { gp_XY(UonS2[1] - UonS2[0], VonS2[1] - VonS2[0])
- , gp_XY(UonS2[2] - UonS2[1], VonS2[2] - VonS2[1])};
-
- Standard_Real aStepOnS1 = aPntOnS1[0].SquareModulus() / aPntOnS1[1].SquareModulus();
- Standard_Real aStepOnS2 = aPntOnS2[0].SquareModulus() / aPntOnS2[1].SquareModulus();
-
- // Check very rare case when wline fluctuates nearly one point and some of them may be equal.
- // Middle point will be deleted when such situation occurs.
- // bugs moddata_2 bug469.
- if (Min(aStepOnS1, aStepOnS2) >= aLimitCoeff * Max(aStepOnS1, aStepOnS2))
- {
- // Set hash flag to "Delete" state.
- isDeleteState = Standard_True;
- aNewPointsHash.SetValue(i - 1, 1);
-
- // Change middle point.
- UonS1[1] = UonS1[2];
- UonS2[1] = UonS2[2];
- VonS1[1] = VonS1[2];
- VonS2[1] = VonS2[2];
- }
- }
-
- if (!isDeleteState)
- {
- // Compute new pipe parameters.
- UonS1[0] = UonS1[1];
- VonS1[0] = VonS1[1];
- UonS2[0] = UonS2[1];
- VonS2[0] = VonS2[1];
-
- UonS1[1] = UonS1[2];
- VonS1[1] = VonS1[2];
- UonS2[1] = UonS2[2];
- VonS2[1] = VonS2[2];
-
- aBase2dPnt1.SetCoord(UonS1[0], VonS1[0]);
- aBase2dPnt2.SetCoord(UonS2[0], VonS2[0]);
- aBase2dVec1.SetCoord(UonS1[1] - UonS1[0], VonS1[1] - VonS1[0]);
- aBase2dVec2.SetCoord(UonS2[1] - UonS2[0], VonS2[1] - VonS2[0]);
- aBase3dPnt = theWLine->Point(i - 1).Value();
- aBase3dVec = gp_Vec(theWLine->Point(i - 1).Value(), theWLine->Point(i).Value());
-
- aNbPnt++;
- }
- }
-
- // Workaround to handle case of small amount of points after purge.
- // Test "boolean boptuc_complex B5" and similar.
- // This is possible since there are at least two points.
- if (aNewPointsHash(1) == -1 &&
- aNewPointsHash(2) == -1 &&
- aNbPnt <= 3)
- {
- // Delete first.
- aNewPointsHash(1) = 1;
- }
- if (aNewPointsHash(theWLine->NbPnts() - 1) == -1 &&
- aNewPointsHash(theWLine->NbPnts() ) == -1 &&
- aNbPnt <= 3)
- {
- // Delete last.
- aNewPointsHash(theWLine->NbPnts()) = 1;
- }
-
- // Purgre when too small amount of points left.
- if (aNbPnt <= 2)
- {
- for(i = aNewPointsHash.Lower(); i <= aNewPointsHash.Upper(); i++)
- {
- if (aNewPointsHash(i) != -1)
- {
- aNewPointsHash(i) = 1;
- }
- }
- }
-
- // Handle possible bad distribution of points,
- // which are will converted into one single bezier curve (less than 30 points).
- // Make distribution more even:
- // max step will be nearly to 0.1 of param distance.
- if (aNbPnt + 2 > aMinNbBadDistr &&
- aNbPnt + 2 < aNbSingleBezier )
- {
- for(Standard_Integer anIdx = 1; anIdx <= 8; anIdx++)
- {
- Standard_Integer aHashIdx =
- Standard_Integer(anIdx * theWLine->NbPnts() / 9);
-
- //Vertex must be stored as VERTEX (HASH = -1)
- if (aNewPointsHash(aHashIdx) != -1)
- aNewPointsHash(aHashIdx) = 0;
- }
- }
-
- return MakeNewWLine(theWLine, aNewPointsHash);
-}
-
//=======================================================================
//function : IsOnPeriod
//purpose : Checks, if [theU1, theU2] intersects the period-value
theHasBeenJoined = Standard_True;
}
-//=========================================================================
-// function : ComputePurgedWLine
-// purpose :
-//=========================================================================
-Handle(IntPatch_WLine) IntPatch_WLineTool::
- ComputePurgedWLine(const Handle(IntPatch_WLine) &theWLine,
- const Handle(Adaptor3d_HSurface) &theS1,
- const Handle(Adaptor3d_HSurface) &theS2,
- const Handle(Adaptor3d_TopolTool) &theDom1,
- const Handle(Adaptor3d_TopolTool) &theDom2,
- const Standard_Boolean theRestrictLine)
-{
- Standard_Integer i, k, v, nb, nbvtx;
- Handle(IntPatch_WLine) aResult;
- nbvtx = theWLine->NbVertex();
- nb = theWLine->NbPnts();
- if (nb==2)
- {
- const IntSurf_PntOn2S& p1 = theWLine->Point(1);
- const IntSurf_PntOn2S& p2 = theWLine->Point(2);
- if(p1.Value().IsEqual(p2.Value(), gp::Resolution()))
- return aResult;
- }
-
- Handle(IntPatch_WLine) aLocalWLine;
- Handle(IntPatch_WLine) aTmpWLine = theWLine;
- Handle(IntSurf_LineOn2S) aLineOn2S = new IntSurf_LineOn2S();
- aLocalWLine = new IntPatch_WLine(aLineOn2S, Standard_False);
- for(i = 1; i <= nb; i++)
- aLineOn2S->Add(theWLine->Point(i));
-
- for(v = 1; v <= nbvtx; v++)
- aLocalWLine->AddVertex(theWLine->Vertex(v));
-
- // I: Delete equal points
- for(i = 1; i <= aLineOn2S->NbPoints(); i++)
- {
- Standard_Integer aStartIndex = i + 1;
- Standard_Integer anEndIndex = i + 5;
- nb = aLineOn2S->NbPoints();
- anEndIndex = (anEndIndex > nb) ? nb : anEndIndex;
-
- if((aStartIndex > nb) || (anEndIndex <= 1))
- continue;
-
- k = aStartIndex;
-
- while(k <= anEndIndex)
- {
- if(i != k)
- {
- IntSurf_PntOn2S p1 = aLineOn2S->Value(i);
- IntSurf_PntOn2S p2 = aLineOn2S->Value(k);
-
- Standard_Real UV[8];
- p1.Parameters(UV[0], UV[1], UV[2], UV[3]);
- p2.Parameters(UV[4], UV[5], UV[6], UV[7]);
-
- Standard_Real aMax = Abs(UV[0]);
- for(Standard_Integer anIdx = 1; anIdx < 8; anIdx++)
- {
- if (aMax < Abs(UV[anIdx]))
- aMax = Abs(UV[anIdx]);
- }
-
- if(p1.Value().IsEqual(p2.Value(), gp::Resolution()) ||
- Abs(UV[0] - UV[4]) + Abs(UV[1] - UV[5]) < 1.0e-16 * aMax ||
- Abs(UV[2] - UV[6]) + Abs(UV[3] - UV[7]) < 1.0e-16 * aMax )
- {
- aTmpWLine = aLocalWLine;
- aLocalWLine = new IntPatch_WLine(aLineOn2S, Standard_False);
-
- for(v = 1; v <= aTmpWLine->NbVertex(); v++)
- {
- IntPatch_Point aVertex = aTmpWLine->Vertex(v);
- Standard_Integer avertexindex = (Standard_Integer)aVertex.ParameterOnLine();
-
- if(avertexindex >= k)
- {
- aVertex.SetParameter(aVertex.ParameterOnLine() - 1.);
- }
- aLocalWLine->AddVertex(aVertex);
- }
- aLineOn2S->RemovePoint(k);
- anEndIndex--;
- continue;
- }
- }
- k++;
- }
- }
-
- if (aLineOn2S->NbPoints() <= 2)
- {
- if (aLineOn2S->NbPoints() == 2)
- return aLocalWLine;
- else
- return aResult;
- }
-
- // Avoid purge in case of C0 continuity:
- // Intersection approximator may produce invalid curve after purge, example:
- // bugs modalg_5 bug24731.
- // Do not run purger when base number of points is too small.
- if (theS1->UContinuity() == GeomAbs_C0 ||
- theS1->VContinuity() == GeomAbs_C0 ||
- theS2->UContinuity() == GeomAbs_C0 ||
- theS2->VContinuity() == GeomAbs_C0 ||
- nb < aNbSingleBezier)
- {
- return aLocalWLine;
- }
-
- if (theRestrictLine)
- {
- // II: Delete out of borders points.
- aLocalWLine = DeleteOuterPoints(aLocalWLine, theS1, theS2, theDom1, theDom2);
- }
-
- // III: Delete points by tube criteria.
- Handle(IntPatch_WLine) aLocalWLineTube =
- DeleteByTube(aLocalWLine, theS1, theS2);
-
- if(aLocalWLineTube->NbPnts() > 1)
- {
- aResult = aLocalWLineTube;
- }
- return aResult;
-}
-
-
//=======================================================================
//function : JoinWLines
//purpose :
DEFINE_STANDARD_ALLOC
- //! I
- //! Removes equal points (leave one of equal points) from theWLine
- //! and recompute vertex parameters.
- //!
- //! II
- //! Removes point out of borders in case of non periodic surfaces.
- //! This step is done only if theRestrictLine is true.
- //!
- //! III
- //! Removes exceed points using tube criteria:
- //! delete 7D point if it lies near to expected lines in 2d and 3d.
- //! Each task (2d, 2d, 3d) have its own tolerance and checked separately.
- //!
- //! Returns new WLine or null WLine if the number
- //! of the points is less than 2.
- Standard_EXPORT static
- Handle(IntPatch_WLine) ComputePurgedWLine(const Handle(IntPatch_WLine) &theWLine,
- const Handle(Adaptor3d_HSurface) &theS1,
- const Handle(Adaptor3d_HSurface) &theS2,
- const Handle(Adaptor3d_TopolTool) &theDom1,
- const Handle(Adaptor3d_TopolTool) &theDom2,
- const Standard_Boolean theRestrictLine);
-
//! Joins all WLines from theSlin to one if it is possible and records
//! the result into theSlin again. Lines will be kept to be splitted if:
//! a) they are separated (has no common points);
myIntersector.SetTolerances(myTol1,myTol2,Deflection);
myIntersector.Perform(mySurface1,myDomain1,mySurface2,myDomain2,
- myTol1,myTol2,Standard_True,Standard_True,
- Standard_False);
+ myTol1,myTol2,Standard_True,Standard_True);
#ifdef OCCT_DEBUG
if (TopOpeBRepTool_GettraceKRO()) KRO_DSFILLER_INTFF.Stop();