//
// This file is part of Open CASCADE Technology software library.
//
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
// by the Free Software Foundation, with special exception defined in the file
// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
// distribution for complete text of the license and disclaimer of any warranty.
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
+#include <IntPatch_WLine.hxx>
+
static
Standard_Integer SetQuad(const Handle(Adaptor3d_HSurface)& theS,
GeomAbs_SurfaceType& theTS,
//purpose :
//=======================================================================
IntPatch_ImpImpIntersection::IntPatch_ImpImpIntersection ():
- done(Standard_False)
+myDone(IntStatus_Fail)
{
}
//=======================================================================
const Handle(Adaptor3d_HSurface)& S2,
const Handle(Adaptor3d_TopolTool)& D2,
const Standard_Real TolArc,
- const Standard_Real TolTang)
+ const Standard_Real TolTang,
+ const Standard_Boolean theIsReqToKeepRLine)
{
- Perform(S1,D1,S2,D2,TolArc,TolTang);
+ Perform(S1,D1,S2,D2,TolArc,TolTang, theIsReqToKeepRLine);
}
//=======================================================================
//function : Perform
const Handle(Adaptor3d_HSurface)& S2,
const Handle(Adaptor3d_TopolTool)& D2,
const Standard_Real TolArc,
- const Standard_Real TolTang) {
- done = Standard_False;
+ const Standard_Real TolTang,
+ const Standard_Boolean theIsReqToKeepRLine)
+{
+ myDone = IntStatus_Fail;
spnt.Clear();
slin.Clear();
+ Standard_Boolean isPostProcessingRequired = Standard_True;
+
empt = Standard_True;
tgte = Standard_False;
oppo = Standard_False;
const Standard_Integer iT2 = SetQuad(S2, typs2, quad2);
//
if (!iT1 || !iT2) {
- Standard_ConstructionError::Raise();
+ throw Standard_ConstructionError();
return;
}
//
break;
}
//
- case 22: { // Cylinder/Cylinder
- if (!IntCyCy(quad1, quad2, TolTang, empt, SameSurf, multpoint, slin, spnt)) {
- return;
+ case 22:
+ { // Cylinder/Cylinder
+ Bnd_Box2d aBox1, aBox2;
+
+ const Standard_Real aU1f = S1->FirstUParameter();
+ Standard_Real aU1l = S1->LastUParameter();
+ const Standard_Real aU2f = S2->FirstUParameter();
+ Standard_Real aU2l = S2->LastUParameter();
+
+ const Standard_Real anUperiod = 2.0*M_PI;
+
+ if(aU1l - aU1f > anUperiod)
+ aU1l = aU1f + anUperiod;
+
+ if(aU2l - aU2f > anUperiod)
+ aU2l = aU2f + anUperiod;
+
+ aBox1.Add(gp_Pnt2d(aU1f, S1->FirstVParameter()));
+ aBox1.Add(gp_Pnt2d(aU1l, S1->LastVParameter()));
+ aBox2.Add(gp_Pnt2d(aU2f, S2->FirstVParameter()));
+ aBox2.Add(gp_Pnt2d(aU2l, S2->LastVParameter()));
+
+ // Resolution is too big if the cylinder radius is
+ // too small. Therefore, we shall bind its value above.
+ // Here, we use simple constant.
+ const Standard_Real a2DTol = Min(1.0e-4, Min( S1->UResolution(TolTang),
+ S2->UResolution(TolTang)));
+
+ myDone = IntCyCy(quad1, quad2, TolTang, a2DTol, aBox1, aBox2,
+ empt, SameSurf, multpoint, slin, spnt);
+
+ if (myDone == IntPatch_ImpImpIntersection::IntStatus_Fail)
+ {
+ return;
+ }
+
+ bEmpty = empt;
+ if(!slin.IsEmpty())
+ {
+ const Handle(IntPatch_WLine)& aWLine =
+ Handle(IntPatch_WLine)::DownCast(slin.Value(1));
+
+ if(!aWLine.IsNull())
+ {//No geometric solution
+ isPostProcessingRequired = Standard_False;
+ }
+ }
+
+ break;
}
- bEmpty = empt;
- break;
- }
//
case 23:
case 32: { // Cylinder/Cone
}
//
default: {
- Standard_ConstructionError::Raise();
+ throw Standard_ConstructionError();
break;
}
}
//
if (bEmpty) {
- done = Standard_True;
+ if (myDone == IntStatus_Fail)
+ myDone = IntStatus_OK;
+
return;
}
//
- if (!SameSurf) {
- AFunc.SetQuadric(quad2);
- AFunc.Set(S1);
+
+ if(isPostProcessingRequired)
+ {
+ if (!SameSurf) {
+ AFunc.SetQuadric(quad2);
+ AFunc.Set(S1);
- solrst.Perform(AFunc, D1, TolArc, TolTang);
- if (!solrst.IsDone()) {
- return;
- }
+ solrst.Perform(AFunc, D1, TolArc, TolTang);
+ if (!solrst.IsDone()) {
+ return;
+ }
- if (solrst.AllArcSolution() && typs1 == typs2) {
- all1 = Standard_True;
- }
- nbpt = solrst.NbPoints();
- nbseg= solrst.NbSegments();
- for (i=1; i<= nbpt; i++) {
- pnt1.Append(solrst.Point(i));
- }
- for (i=1; i<= nbseg; i++) {
- edg1.Append(solrst.Segment(i));
- }
- nosolonS1 = (nbpt == 0) && (nbseg == 0);
+ if (solrst.AllArcSolution() && typs1 == typs2) {
+ all1 = Standard_True;
+ }
+ nbpt = solrst.NbPoints();
+ nbseg= solrst.NbSegments();
+ for (i = 1; i <= nbpt; i++)
+ {
+ const IntPatch_ThePathPointOfTheSOnBounds& aPt = solrst.Point(i);
+ pnt1.Append(aPt);
+ }
+ for (i = 1; i <= nbseg; i++)
+ {
+ const IntPatch_TheSegmentOfTheSOnBounds& aSegm = solrst.Segment(i);
+ edg1.Append(aSegm);
+ }
+ nosolonS1 = (nbpt == 0) && (nbseg == 0);
- if (nosolonS1 && all1) { // cas de face sans restrictions
- all1 = Standard_False;
+ if (nosolonS1 && all1) { // cas de face sans restrictions
+ all1 = Standard_False;
+ }
+ }//if (!SameSurf) {
+ else {
+ nosolonS1 = Standard_True;
}
- }//if (!SameSurf) {
- else {
- nosolonS1 = Standard_True;
- }
- if (!SameSurf) {
- AFunc.SetQuadric(quad1);
- AFunc.Set(S2);
+ if (!SameSurf) {
+ AFunc.SetQuadric(quad1);
+ AFunc.Set(S2);
- solrst.Perform(AFunc, D2, TolArc, TolTang);
- if (!solrst.IsDone()) {
- return;
- }
+ solrst.Perform(AFunc, D2, TolArc, TolTang);
+ if (!solrst.IsDone()) {
+ return;
+ }
- if (solrst.AllArcSolution() && typs1 == typs2) {
- all2 = Standard_True;
- }
- nbpt = solrst.NbPoints();
- nbseg= solrst.NbSegments();
- for (i=1; i<= nbpt; i++) {
- pnt2.Append(solrst.Point(i));
- }
+ if (solrst.AllArcSolution() && typs1 == typs2) {
+ all2 = Standard_True;
+ }
+
+ nbpt = solrst.NbPoints();
+ nbseg= solrst.NbSegments();
+ for (i=1; i<= nbpt; i++) {
+ const IntPatch_ThePathPointOfTheSOnBounds& aPt = solrst.Point(i);
+ pnt2.Append(aPt);
+ }
- for (i=1; i<= nbseg; i++) {
- edg2.Append(solrst.Segment(i));
- }
- nosolonS2 = (nbpt == 0) && (nbseg == 0);
+ for (i=1; i<= nbseg; i++) {
+ const IntPatch_TheSegmentOfTheSOnBounds& aSegm = solrst.Segment(i);
+ edg2.Append(aSegm);
+ }
+
+ nosolonS2 = (nbpt == 0) && (nbseg == 0);
- if (nosolonS2 && all2) { // cas de face sans restrictions
- all2 = Standard_False;
+ if (nosolonS2 && all2) { // cas de face sans restrictions
+ all2 = Standard_False;
+ }
+ }// if (!SameSurf) {
+ else {
+ nosolonS2 = Standard_True;
}
- }// if (!SameSurf) {
- else {
- nosolonS2 = Standard_True;
- }
- //
- if (SameSurf || (all1 && all2)) {
- // faces "paralleles" parfaites
- empt = Standard_False;
- tgte = Standard_True;
- slin.Clear();
- spnt.Clear();
+ //
+ if (SameSurf || (all1 && all2)) {
+ // faces "paralleles" parfaites
+ empt = Standard_False;
+ tgte = Standard_True;
+ slin.Clear();
+ spnt.Clear();
- gp_Pnt Ptreference;
+ gp_Pnt Ptreference;
- switch (typs1) {
- case GeomAbs_Plane: {
- Ptreference = (S1->Plane()).Location();
- }
- break;
- case GeomAbs_Cylinder: {
- Ptreference = ElSLib::Value(0.,0.,S1->Cylinder());
- }
- break;
- case GeomAbs_Sphere: {
- Ptreference = ElSLib::Value(M_PI/4.,M_PI/4.,S1->Sphere());
- }
- break;
- case GeomAbs_Cone: {
- Ptreference = ElSLib::Value(0.,10.,S1->Cone());
- }
- break;
- case GeomAbs_Torus: {
- Ptreference = ElSLib::Value(0.,0.,S1->Torus());
- }
- break;
- default:
- break;
- }
- //
- oppo = quad1.Normale(Ptreference).Dot(quad2.Normale(Ptreference)) < 0.0;
- done = Standard_True;
- return;
- }// if (SameSurf || (all1 && all2)) {
+ switch (typs1) {
+ case GeomAbs_Plane: {
+ Ptreference = (S1->Plane()).Location();
+ }
+ break;
+ case GeomAbs_Cylinder: {
+ Ptreference = ElSLib::Value(0.,0.,S1->Cylinder());
+ }
+ break;
+ case GeomAbs_Sphere: {
+ Ptreference = ElSLib::Value(M_PI/4.,M_PI/4.,S1->Sphere());
+ }
+ break;
+ case GeomAbs_Cone: {
+ Ptreference = ElSLib::Value(0.,10.,S1->Cone());
+ }
+ break;
+ case GeomAbs_Torus: {
+ Ptreference = ElSLib::Value(0.,0.,S1->Torus());
+ }
+ break;
+ default:
+ break;
+ }
+ //
+ oppo = quad1.Normale(Ptreference).Dot(quad2.Normale(Ptreference)) < 0.0;
+ myDone = IntStatus_OK;
+ return;
+ }// if (SameSurf || (all1 && all2)) {
- if (!nosolonS1 || !nosolonS2) {
- empt = Standard_False;
- // C est la qu il faut commencer a bosser...
- PutPointsOnLine(S1,S2,pnt1, slin, Standard_True, D1, quad1,quad2,
- multpoint,TolArc);
+ if (!nosolonS1 || !nosolonS2) {
+ empt = Standard_False;
+ // C est la qu il faut commencer a bosser...
+ PutPointsOnLine(S1,S2,pnt1, slin, Standard_True, D1, quad1,quad2,
+ multpoint,TolArc);
- PutPointsOnLine(S1,S2,pnt2, slin, Standard_False,D2, quad2,quad1,
- multpoint,TolArc);
+ PutPointsOnLine(S1,S2,pnt2, slin, Standard_False,D2, quad2,quad1,
+ multpoint,TolArc);
- if (edg1.Length() != 0) {
- ProcessSegments(edg1,slin,quad1,quad2,Standard_True,TolArc);
- }
+ if (edg1.Length() != 0) {
+ ProcessSegments(edg1,slin,quad1,quad2,Standard_True,TolArc);
+ }
- if (edg2.Length() != 0) {
- ProcessSegments(edg2,slin,quad1,quad2,Standard_False,TolArc);
- }
+ if (edg2.Length() != 0) {
+ ProcessSegments(edg2,slin,quad1,quad2,Standard_False,TolArc);
+ }
- if (edg1.Length() !=0 || edg2.Length() !=0) {
- // ProcessRLine(slin,S1,S2,TolArc);
- ProcessRLine(slin,quad1,quad2,TolArc);
+ if (edg1.Length() !=0 || edg2.Length() !=0) {
+ // ProcessRLine(slin,S1,S2,TolArc);
+ ProcessRLine(slin,quad1,quad2,TolArc, theIsReqToKeepRLine);
+ }
+ }//if (!nosolonS1 || !nosolonS2) {
+ else {
+ empt = ((slin.Length()==0) && (spnt.Length()==0));
}
- }//if (!nosolonS1 || !nosolonS2) {
- else {
- empt = ((slin.Length()==0) && (spnt.Length()==0));
}
- //
- Standard_Integer nblin, aNbPnt;
+
+ Standard_Integer nblin = slin.Length(),
+ aNbPnt = spnt.Length();
//
//modified by NIZNHY-PKV Tue Sep 06 10:03:35 2011f
- aNbPnt=spnt.Length();
if (aNbPnt) {
IntPatch_SequenceOfPoint aSIP;
//
}// if (aNbPnt) {
//modified by NIZNHY-PKV Tue Sep 06 10:18:20 2011t
//
- nblin = slin.Length();
for(i=1; i<=nblin; i++) {
IntPatch_IType thetype = slin.Value(i)->ArcType();
if( (thetype == IntPatch_Ellipse)
gp_Pnt P;
IntPatch_Point point;
Standard_Real u1,v1,u2,v2;
- Standard_Integer nbv;
if(slin.Value(i)->ArcType() == IntPatch_Circle) {
const Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine)*)&slin.Value(i));
- nbv = glin->NbVertex();
if(glin->NbVertex() == 0) {
gp_Circ Circ = glin->Circle();
P=ElCLib::Value(0.0,Circ);
else if(slin.Value(i)->ArcType() == IntPatch_Ellipse) {
const Handle(IntPatch_GLine)& glin = *((Handle(IntPatch_GLine)*)&slin.Value(i));
- nbv = glin->NbVertex();
if(glin->NbVertex() == 0) {
gp_Elips Elips = glin->Ellipse();
P=ElCLib::Value(0.0,Elips);
}
}
}
- done = Standard_True;
+ myDone = IntStatus_OK;
}
//=======================================================================