1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

0024470: Wrong result done by General Fuse algorithm.

Modifications:
1. The validity of the intersection point between edge and face is checked with sum of the tolerance values of the edge and face.
2. The intersection between toroidal surface and one of the following surfaces: Plane, Cylinder, Sphere, Cone or Torus
   is treated as analytical in the following cases:
   1) Torus and Plane: a. Axes of the surfaces are parallel;
                       b. Axes of the surfaces are perpendicular and location of the torus is lying on the plane;
   2) Torus and Sphere: The location of the sphere is lying on the line made from toruses axis;
   3) Torus and Cone, Cylinder or Torus: The axis of the surfaces are collinear.
   In all cases the intersection line(s) is(are) circle(s).

Added test cases bugs/modalg_5/bug24470

The intersection between torus with minor radius more than (or equal to) the major radius and any other surface is considered as parametric.
This commit is contained in:
emv
2014-01-09 12:01:01 +04:00
committed by bugmaster
parent 547702a15d
commit 7eed5d29a9
21 changed files with 2489 additions and 1360 deletions

View File

@@ -4,3 +4,4 @@ IntPatch_ImpImpIntersection_2.gxx
IntPatch_ImpImpIntersection_3.gxx
IntPatch_ImpImpIntersection_4.gxx
IntPatch_ImpImpIntersection_5.gxx
IntPatch_ImpImpIntersection_6.gxx

View File

@@ -856,6 +856,9 @@ static
case GeomAbs_Sphere:
pu1=M_PI+M_PI;
break;
case GeomAbs_Torus:
pu1=pv1=M_PI+M_PI;
break;
default:
break;
}
@@ -865,6 +868,9 @@ static
case GeomAbs_Sphere:
pu2=M_PI+M_PI;
break;
case GeomAbs_Torus:
pu2=pv2=M_PI+M_PI;
break;
default:
break;
}

View File

@@ -52,3 +52,4 @@
#include <IntPatch_ImpImpIntersection_3.gxx>
#include <IntPatch_ImpImpIntersection_4.gxx>
#include <IntPatch_ImpImpIntersection_5.gxx>
#include <IntPatch_ImpImpIntersection_6.gxx>

View File

@@ -120,3 +120,39 @@ static Standard_Boolean IntCoCo(const IntSurf_Quadric&,
Standard_Boolean&,
IntPatch_SequenceOfLine&,
IntPatch_SequenceOfPoint&);
//torus
static Standard_Boolean IntPTo(const IntSurf_Quadric&,
const IntSurf_Quadric&,
const Standard_Real,
const Standard_Boolean,
Standard_Boolean&,
IntPatch_SequenceOfLine&);
static Standard_Boolean IntCyTo(const IntSurf_Quadric&,
const IntSurf_Quadric&,
const Standard_Real,
const Standard_Boolean,
Standard_Boolean&,
IntPatch_SequenceOfLine&);
static Standard_Boolean IntCoTo(const IntSurf_Quadric&,
const IntSurf_Quadric&,
const Standard_Real,
const Standard_Boolean,
Standard_Boolean&,
IntPatch_SequenceOfLine&);
static Standard_Boolean IntSpTo(const IntSurf_Quadric&,
const IntSurf_Quadric&,
const Standard_Real,
const Standard_Boolean,
Standard_Boolean&,
IntPatch_SequenceOfLine&);
static Standard_Boolean IntToTo(const IntSurf_Quadric&,
const IntSurf_Quadric&,
const Standard_Real,
Standard_Boolean&,
Standard_Boolean&,
IntPatch_SequenceOfLine&);

View File

@@ -14,6 +14,11 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
static
Standard_Integer SetQuad(const Handle(Adaptor3d_HSurface)& theS,
GeomAbs_SurfaceType& theTS,
IntSurf_Quadric& theQuad);
//=======================================================================
//function : IntPatch_ImpImpIntersection
//purpose :
@@ -28,11 +33,11 @@ IntPatch_ImpImpIntersection::IntPatch_ImpImpIntersection ():
//=======================================================================
IntPatch_ImpImpIntersection::IntPatch_ImpImpIntersection
(const Handle(Adaptor3d_HSurface)& S1,
const Handle(Adaptor3d_TopolTool)& D1,
const Handle(Adaptor3d_TopolTool)& D1,
const Handle(Adaptor3d_HSurface)& S2,
const Handle(Adaptor3d_TopolTool)& D2,
const Standard_Real TolArc,
const Standard_Real TolTang)
const Handle(Adaptor3d_TopolTool)& D2,
const Standard_Real TolArc,
const Standard_Real TolTang)
{
Perform(S1,D1,S2,D2,TolArc,TolTang);
}
@@ -41,11 +46,11 @@ IntPatch_ImpImpIntersection::IntPatch_ImpImpIntersection
//purpose :
//=======================================================================
void IntPatch_ImpImpIntersection::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 Handle(Adaptor3d_TopolTool)& D1,
const Handle(Adaptor3d_HSurface)& S2,
const Handle(Adaptor3d_TopolTool)& D2,
const Standard_Real TolArc,
const Standard_Real TolTang) {
done = Standard_False;
spnt.Clear();
slin.Clear();
@@ -68,312 +73,170 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
IntPatch_SequenceOfPathPointOfTheSOnBounds pnt1,pnt2;
//
// On commence par intersecter les supports des surfaces
IntSurf_Quadric quad1;
IntSurf_Quadric quad2;
IntSurf_Quadric quad1, quad2;
IntPatch_ArcFunction AFunc;
const Standard_Real Tolang = 1.e-8;
GeomAbs_SurfaceType typs1 = S1->GetType();
GeomAbs_SurfaceType typs2 = S2->GetType();
GeomAbs_SurfaceType typs1, typs2;
Standard_Boolean bEmpty = Standard_False;
//
switch (typs1) {
case GeomAbs_Plane :
{
quad1.SetValue(S1->Plane());
switch (typs2) {
case GeomAbs_Plane:
{
quad2.SetValue(S2->Plane());
if (!IntPP(quad1,quad2,Tolang,TolTang,SameSurf,slin)) {
return;
}
}
break;
case GeomAbs_Cylinder:
{
quad2.SetValue(S2->Cylinder());
Standard_Real VMin, VMax, H;
//
VMin = S1->FirstVParameter();
VMax = S1->LastVParameter();
H = (Precision::IsNegativeInfinite(VMin) ||
Precision::IsPositiveInfinite(VMax)) ? 0 : (VMax - VMin);
if (!IntPCy(quad1,quad2,Tolang,TolTang,Standard_False,empt,slin,H)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Sphere:
{
quad2.SetValue(S2->Sphere());
//modified by NIZNHY-PKV Tue Sep 20 09:03:06 2011f
if (!IntPSp(quad1,quad2,Tolang,TolTang,Standard_False,empt,slin,spnt)) {
//if (!IntPSp(quad1,quad2,TolTang,Standard_False,empt,slin,spnt)) {
//modified by NIZNHY-PKV Tue Sep 20 09:03:10 2011t
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Cone:
{
quad2.SetValue(S2->Cone());
if (!IntPCo(quad1,quad2,Tolang,TolTang,Standard_False,
empt,multpoint,slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
default:
{
Standard_ConstructionError::Raise();
break;
}
const Standard_Integer iT1 = SetQuad(S1, typs1, quad1);
const Standard_Integer iT2 = SetQuad(S2, typs2, quad2);
//
if (!iT1 || !iT2) {
Standard_ConstructionError::Raise();
return;
}
//
const Standard_Boolean bReverse = iT1 > iT2;
const Standard_Integer iTT = iT1*10 + iT2;
//
switch (iTT) {
case 11: { // Plane/Plane
if (!IntPP(quad1, quad2, Tolang, TolTang, SameSurf, slin)) {
return;
}
break;
}
break;
case GeomAbs_Cylinder:
{
quad1.SetValue(S1->Cylinder());
switch (typs2){
case GeomAbs_Plane:
{
quad2.SetValue(S2->Plane());
Standard_Real VMin, VMax, H;
//
VMin = S1->FirstVParameter();
VMax = S1->LastVParameter();
H = (Precision::IsNegativeInfinite(VMin) ||
Precision::IsPositiveInfinite(VMax)) ? 0 : (VMax - VMin);
if (!IntPCy(quad1,quad2,Tolang,TolTang,Standard_True,empt,slin,H)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Cylinder:
{
quad2.SetValue(S2->Cylinder());
if (!IntCyCy(quad1,quad2,TolTang,empt,SameSurf,multpoint,slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Sphere:
{
quad2.SetValue(S2->Sphere());
if (!IntCySp(quad1,quad2,TolTang,Standard_False,empt,multpoint,
slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Cone:
{
quad2.SetValue(S2->Cone());
if (!IntCyCo(quad1,quad2,TolTang,Standard_False,empt,multpoint,
slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
default:
{
Standard_ConstructionError::Raise();
break;
}
//
case 12:
case 21: { // Plane/Cylinder
Standard_Real VMin, VMax, H;
//
const Handle(Adaptor3d_HSurface)& aSCyl = bReverse ? S2 : S1;
VMin = aSCyl->FirstVParameter();
VMax = aSCyl->LastVParameter();
H = (Precision::IsNegativeInfinite(VMin) ||
Precision::IsPositiveInfinite(VMax)) ? 0 : (VMax - VMin);
//
if (!IntPCy(quad1, quad2, Tolang, TolTang, bReverse, empt, slin, H)) {
return;
}
bEmpty = empt;
break;
}
break;
case GeomAbs_Sphere:
{
quad1.SetValue(S1->Sphere());
switch (typs2){
case GeomAbs_Plane:
{
quad2.SetValue(S2->Plane());
//modified by NIZNHY-PKV Tue Sep 20 09:03:35 2011f
if (!IntPSp(quad1,quad2,Tolang,TolTang,Standard_True,empt,slin,spnt)) {
//if (!IntPSp(quad1,quad2,TolTang,Standard_True,empt,slin,spnt)) {
//modified by NIZNHY-PKV Tue Sep 20 09:03:38 2011t
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Cylinder:
{
quad2.SetValue(S2->Cylinder());
if (!IntCySp(quad1,quad2,TolTang,Standard_True,empt,multpoint,
slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Sphere:
{
quad2.SetValue(S2->Sphere());
if (!IntSpSp(quad1,quad2,TolTang,empt,SameSurf,slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Cone:
{
quad2.SetValue(S2->Cone());
if (!IntCoSp(quad1,quad2,TolTang,Standard_True,empt,multpoint,
slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
default:
{
Standard_ConstructionError::Raise();
break;
}
//
case 13:
case 31: { // Plane/Cone
if (!IntPCo(quad1, quad2, Tolang, TolTang, bReverse, empt, multpoint, slin, spnt)) {
return;
}
bEmpty = empt;
break;
}
break;
case GeomAbs_Cone:
{
quad1.SetValue(S1->Cone());
switch (typs2){
case GeomAbs_Plane:
{
quad2.SetValue(S2->Plane());
if (!IntPCo(quad1,quad2,Tolang,TolTang,Standard_True,
empt,multpoint,slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Cylinder:
{
quad2.SetValue(S2->Cylinder());
if (!IntCyCo(quad1,quad2,TolTang,Standard_True,empt,multpoint,
slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Sphere:
{
quad2.SetValue(S2->Sphere());
if (!IntCoSp(quad1,quad2,TolTang,Standard_False,empt,multpoint,
slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
case GeomAbs_Cone:
{
quad2.SetValue(S2->Cone());
if (!IntCoCo(quad1,quad2,TolTang,empt,SameSurf,multpoint,
slin,spnt)) {
return;
}
if (empt) {
done = Standard_True;
return;
}
}
break;
default:
{
Standard_ConstructionError::Raise();
break;
}
//
case 14:
case 41: { // Plane/Sphere
if (!IntPSp(quad1, quad2, Tolang, TolTang, bReverse, empt, slin, spnt)) {
return;
}
bEmpty = empt;
break;
}
break;
default:
{
//
case 15:
case 51: { // Plane/Torus
if (!IntPTo(quad1, quad2, TolTang, bReverse, empt, slin)) {
return;
}
bEmpty = empt;
break;
}
//
case 22: { // Cylinder/Cylinder
if (!IntCyCy(quad1, quad2, TolTang, empt, SameSurf, multpoint, slin, spnt)) {
return;
}
bEmpty = empt;
break;
}
//
case 23:
case 32: { // Cylinder/Cone
if (!IntCyCo(quad1, quad2, TolTang, bReverse, empt, multpoint, slin, spnt)) {
return;
}
bEmpty = empt;
break;
}
//
case 24:
case 42: { // Cylinder/Sphere
if (!IntCySp(quad1, quad2, TolTang, bReverse, empt, multpoint, slin, spnt)) {
return;
}
bEmpty = empt;
break;
}
//
case 25:
case 52: { // Cylinder/Torus
if (!IntCyTo(quad1, quad2, TolTang, bReverse, empt, slin)) {
return;
}
bEmpty = empt;
break;
}
//
case 33: { // Cone/Cone
if (!IntCoCo(quad1, quad2, TolTang, empt, SameSurf, multpoint, slin, spnt)) {
return;
}
bEmpty = empt;
break;
}
//
case 34:
case 43: { // Cone/Sphere
if (!IntCoSp(quad1, quad2, TolTang, bReverse, empt, multpoint, slin, spnt)) {
return;
}
bEmpty = empt;
break;
}
//
case 35:
case 53: { // Cone/Torus
if (!IntCoTo(quad1, quad2, TolTang, bReverse, empt, slin)) {
return;
}
break;
}
//
case 44: { // Sphere/Sphere
if (!IntSpSp(quad1, quad2, TolTang, empt, SameSurf, slin, spnt)) {
return;
}
bEmpty = empt;
break;
}
//
case 45:
case 54: { // Sphere/Torus
if (!IntSpTo(quad1, quad2, TolTang, bReverse, empt, slin)) {
return;
}
bEmpty = empt;
break;
}
//
case 55: { // Torus/Torus
if (!IntToTo(quad1, quad2, TolTang, SameSurf, empt, slin)) {
return;
}
bEmpty = empt;
break;
}
//
default: {
Standard_ConstructionError::Raise();
break;
}
} //switch (typs1) {
}
//
if (bEmpty) {
done = Standard_True;
return;
}
//
if (!SameSurf) {
AFunc.SetQuadric(quad2);
@@ -462,6 +325,10 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
Ptreference = ElSLib::Value(0.,10.,S1->Cone());
}
break;
case GeomAbs_Torus: {
Ptreference = ElSLib::Value(0.,0.,S1->Torus());
}
break;
default:
break;
}
@@ -475,10 +342,10 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
empt = Standard_False;
// C est la qu il faut commencer a bosser...
PutPointsOnLine(S1,S2,pnt1, slin, Standard_True, D1, quad1,quad2,
multpoint,TolArc);
multpoint,TolArc);
PutPointsOnLine(S1,S2,pnt2, slin, Standard_False,D2, quad2,quad1,
multpoint,TolArc);
multpoint,TolArc);
if (edg1.Length() != 0) {
ProcessSegments(edg1,slin,quad1,quad2,Standard_True,TolArc);
@@ -519,7 +386,7 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
aState2=D2->Classify(aP2D, TolArc);
//
if(aState1!=TopAbs_OUT && aState2!=TopAbs_OUT) {
aSIP.Append(aIP);
aSIP.Append(aIP);
}
}
//
@@ -567,22 +434,22 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
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);
quad1.Parameters(P,u1,v1);
quad2.Parameters(P,u2,v2);
point.SetValue(P,TolArc,Standard_False);
point.SetParameters(u1,v1,u2,v2);
point.SetParameter(0.0);
glin->AddVertex(point);
gp_Circ Circ = glin->Circle();
P=ElCLib::Value(0.0,Circ);
quad1.Parameters(P,u1,v1);
quad2.Parameters(P,u2,v2);
point.SetValue(P,TolArc,Standard_False);
point.SetParameters(u1,v1,u2,v2);
point.SetParameter(0.0);
glin->AddVertex(point);
P=ElCLib::Value(0.0,Circ);
quad1.Parameters(P,u1,v1);
quad2.Parameters(P,u2,v2);
point.SetValue(P,TolArc,Standard_False);
point.SetParameters(u1,v1,u2,v2);
point.SetParameter(M_PI+M_PI);
glin->AddVertex(point);
P=ElCLib::Value(0.0,Circ);
quad1.Parameters(P,u1,v1);
quad2.Parameters(P,u2,v2);
point.SetValue(P,TolArc,Standard_False);
point.SetParameters(u1,v1,u2,v2);
point.SetParameter(M_PI+M_PI);
glin->AddVertex(point);
}
}
@@ -590,25 +457,63 @@ void IntPatch_ImpImpIntersection::Perform(const Handle(Adaptor3d_HSurface)& S1,
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);
quad1.Parameters(P,u1,v1);
quad2.Parameters(P,u2,v2);
point.SetValue(P,TolArc,Standard_False);
point.SetParameters(u1,v1,u2,v2);
point.SetParameter(0.0);
glin->AddVertex(point);
gp_Elips Elips = glin->Ellipse();
P=ElCLib::Value(0.0,Elips);
quad1.Parameters(P,u1,v1);
quad2.Parameters(P,u2,v2);
point.SetValue(P,TolArc,Standard_False);
point.SetParameters(u1,v1,u2,v2);
point.SetParameter(0.0);
glin->AddVertex(point);
P=ElCLib::Value(0.0,Elips);
quad1.Parameters(P,u1,v1);
quad2.Parameters(P,u2,v2);
point.SetValue(P,TolArc,Standard_False);
point.SetParameters(u1,v1,u2,v2);
point.SetParameter(M_PI+M_PI);
glin->AddVertex(point);
P=ElCLib::Value(0.0,Elips);
quad1.Parameters(P,u1,v1);
quad2.Parameters(P,u2,v2);
point.SetValue(P,TolArc,Standard_False);
point.SetParameters(u1,v1,u2,v2);
point.SetParameter(M_PI+M_PI);
glin->AddVertex(point);
}
}
}
done = Standard_True;
}
//=======================================================================
//function : SetQuad
//purpose :
//=======================================================================
Standard_Integer SetQuad(const Handle(Adaptor3d_HSurface)& theS,
GeomAbs_SurfaceType& theTS,
IntSurf_Quadric& theQuad)
{
theTS = theS->GetType();
Standard_Integer iRet = 0;
switch (theTS) {
case GeomAbs_Plane:
theQuad.SetValue(theS->Plane());
iRet = 1;
break;
case GeomAbs_Cylinder:
theQuad.SetValue(theS->Cylinder());
iRet = 2;
break;
case GeomAbs_Cone:
theQuad.SetValue(theS->Cone());
iRet = 3;
break;
case GeomAbs_Sphere:
theQuad.SetValue(theS->Sphere());
iRet = 4;
break;
case GeomAbs_Torus:
theQuad.SetValue(theS->Torus());
iRet = 5;
break;
default:
break;
}
//
return iRet;
}

View File

@@ -17,18 +17,21 @@
//modified by NIZNHY-PKV Thu Sep 15 11:09:12 2011
static
void SeamPosition(const gp_Pnt& aPLoc,
const gp_Ax3& aPos,
gp_Ax2& aSeamPos);
const gp_Ax3& aPos,
gp_Ax2& aSeamPos);
static
void AdjustToSeam (const gp_Cylinder& aQuad,
gp_Circ& aCirc);
gp_Circ& aCirc);
static
void AdjustToSeam (const gp_Sphere& aQuad,
gp_Circ& aCirc,
const Standard_Real aTolAng);
gp_Circ& aCirc,
const Standard_Real aTolAng);
static
void AdjustToSeam (const gp_Cone& aQuad,
gp_Circ& aCirc);
gp_Circ& aCirc);
static
void AdjustToSeam (const gp_Torus& aQuad,
gp_Circ& aCirc);
//modified by NIZNHY-PKV Thu Sep 15 11:09:13 2011
//=======================================================================
@@ -37,11 +40,11 @@ static
// Traitement du cas Plan/Plan
//=======================================================================
Standard_Boolean IntPP (const IntSurf_Quadric& Quad1,
const IntSurf_Quadric& Quad2,
const Standard_Real Tolang,
const Standard_Real TolTang,
Standard_Boolean& Same,
IntPatch_SequenceOfLine& slin)
const IntSurf_Quadric& Quad2,
const Standard_Real Tolang,
const Standard_Real TolTang,
Standard_Boolean& Same,
IntPatch_SequenceOfLine& slin)
{
IntSurf_TypeTrans trans1,trans2;
@@ -82,12 +85,12 @@ Standard_Boolean IntPP (const IntSurf_Quadric& Quad1,
// Traitement du cas Plan/Cylindre et reciproquement
//=======================================================================
Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
const IntSurf_Quadric& Quad2,
const Standard_Real Tolang,
const Standard_Real TolTang,
const Standard_Boolean Reversed,
Standard_Boolean& Empty,
IntPatch_SequenceOfLine& slin,
const IntSurf_Quadric& Quad2,
const Standard_Real Tolang,
const Standard_Real TolTang,
const Standard_Boolean Reversed,
Standard_Boolean& Empty,
IntPatch_SequenceOfLine& slin,
const Standard_Real H)
{
@@ -113,7 +116,7 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
Empty = Standard_False;
switch (typint) {
case IntAna_Empty : {
Empty = Standard_True;
}
@@ -123,78 +126,78 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
gp_Lin linsol = inter.Line(1);
gp_Pnt orig(linsol.Location());
if (NbSol == 1) { // ligne de tangence
gp_Vec TestCurvature(orig,Cy.Location());
gp_Vec Normp,Normcyl;
if (!Reversed) {
Normp = Quad1.Normale(orig);
Normcyl = Quad2.Normale(orig);
}
else {
Normp = Quad2.Normale(orig);
Normcyl = Quad1.Normale(orig);
}
IntSurf_Situation situcyl;
IntSurf_Situation situp;
gp_Vec TestCurvature(orig,Cy.Location());
gp_Vec Normp,Normcyl;
if (!Reversed) {
Normp = Quad1.Normale(orig);
Normcyl = Quad2.Normale(orig);
}
else {
Normp = Quad2.Normale(orig);
Normcyl = Quad1.Normale(orig);
}
IntSurf_Situation situcyl;
IntSurf_Situation situp;
if (Normp.Dot(TestCurvature) > 0.) {
situcyl = IntSurf_Outside;
if (Normp.Dot(Normcyl) > 0.) {
situp = IntSurf_Inside;
}
else {
situp = IntSurf_Outside;
}
}
else {
situcyl = IntSurf_Inside;
if (Normp.Dot(Normcyl) > 0.) {
situp = IntSurf_Outside;
}
else {
situp = IntSurf_Inside;
}
}
Handle(IntPatch_GLine) glig;
if (!Reversed) {
glig = new IntPatch_GLine(linsol, Standard_True, situp, situcyl);
}
else {
glig = new IntPatch_GLine(linsol, Standard_True, situcyl, situp);
}
slin.Append(glig);
if (Normp.Dot(TestCurvature) > 0.) {
situcyl = IntSurf_Outside;
if (Normp.Dot(Normcyl) > 0.) {
situp = IntSurf_Inside;
}
else {
situp = IntSurf_Outside;
}
}
else {
situcyl = IntSurf_Inside;
if (Normp.Dot(Normcyl) > 0.) {
situp = IntSurf_Outside;
}
else {
situp = IntSurf_Inside;
}
}
Handle(IntPatch_GLine) glig;
if (!Reversed) {
glig = new IntPatch_GLine(linsol, Standard_True, situp, situcyl);
}
else {
glig = new IntPatch_GLine(linsol, Standard_True, situcyl, situp);
}
slin.Append(glig);
}
else {
// on a 2 droites. Il faut determiner les transitions
// de chacune.
if (linsol.Direction().DotCross(Quad2.Normale(orig),
Quad1.Normale(orig)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
Handle(IntPatch_GLine) glig =
new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
slin.Append(glig);
linsol = inter.Line(2);
orig = linsol.Location();
// on a 2 droites. Il faut determiner les transitions
// de chacune.
if (linsol.Direction().DotCross(Quad2.Normale(orig),
Quad1.Normale(orig)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
Handle(IntPatch_GLine) glig =
new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
slin.Append(glig);
linsol = inter.Line(2);
orig = linsol.Location();
if (linsol.Direction().DotCross(Quad2.Normale(orig),
Quad1.Normale(orig)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
slin.Append(glig);
if (linsol.Direction().DotCross(Quad2.Normale(orig),
Quad1.Normale(orig)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
slin.Append(glig);
}
}
break;
@@ -211,12 +214,12 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
ElCLib::D1(0.,cirsol,ptref,Tgt);
if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
slin.Append(glig);
@@ -230,12 +233,12 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
ElCLib::D1(0.,elipsol,ptref,Tgt);
if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
slin.Append(glig);
@@ -254,15 +257,15 @@ Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
// Traitement du cas Plan/Sphere et reciproquement
//=======================================================================
Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
const IntSurf_Quadric& Quad2,
//modified by NIZNHY-PKV Tue Sep 20 08:59:36 2011f
const Standard_Real Tolang,
//modified by NIZNHY-PKV Tue Sep 20 08:59:39 2011t
const Standard_Real TolTang,
const Standard_Boolean Reversed,
Standard_Boolean& Empty,
IntPatch_SequenceOfLine& slin,
IntPatch_SequenceOfPoint& spnt)
const IntSurf_Quadric& Quad2,
//modified by NIZNHY-PKV Tue Sep 20 08:59:36 2011f
const Standard_Real Tolang,
//modified by NIZNHY-PKV Tue Sep 20 08:59:39 2011t
const Standard_Real TolTang,
const Standard_Boolean Reversed,
Standard_Boolean& Empty,
IntPatch_SequenceOfLine& slin,
IntPatch_SequenceOfPoint& spnt)
{
@@ -316,12 +319,12 @@ Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
ElCLib::D1(0.,cirsol,ptref,Tgt);
if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
slin.Append(glig);
@@ -340,14 +343,14 @@ Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
// Traitement du cas Plan/Cone et reciproquement
//=======================================================================
Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
const IntSurf_Quadric& Quad2,
const Standard_Real Tolang,
const Standard_Real TolTang,
const Standard_Boolean Reversed,
Standard_Boolean& Empty,
Standard_Boolean& Multpoint,
IntPatch_SequenceOfLine& slin,
IntPatch_SequenceOfPoint& spnt)
const IntSurf_Quadric& Quad2,
const Standard_Real Tolang,
const Standard_Real TolTang,
const Standard_Boolean Reversed,
Standard_Boolean& Empty,
Standard_Boolean& Multpoint,
IntPatch_SequenceOfLine& slin,
IntPatch_SequenceOfPoint& spnt)
{
@@ -396,7 +399,7 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
case IntAna_Line: {
gp_Lin linsol = inter.Line(1);
if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
linsol.SetDirection(linsol.Direction().Reversed());
linsol.SetDirection(linsol.Direction().Reversed());
}
Standard_Real para = ElCLib::Parameter(linsol, apex);
gp_Pnt ptbid (ElCLib::Value(para+5.,linsol));
@@ -405,149 +408,149 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
Quad2.Parameters(apex,U2,V2);
if (NbSol == 1) { // ligne de tangence
IntPatch_Point ptsol;
ptsol.SetValue(apex,TolTang,Standard_False);
ptsol.SetParameters(U1,V1,U2,V2);
ptsol.SetParameter(para);
gp_Pnt ptbid2(apex.XYZ() + 5.*Co.Axis().Direction().XYZ());
gp_Vec TestCurvature(ptbid,ptbid2);
gp_Vec Normp,Normco;
if (!Reversed) {
Normp = Quad1.Normale(ptbid);
Normco = Quad2.Normale(ptbid);
}
else {
Normp = Quad2.Normale(ptbid);
Normco = Quad1.Normale(ptbid);
}
IntSurf_Situation situco,situco_otherside;
IntSurf_Situation situp,situp_otherside;
if (Normp.Dot(TestCurvature) > 0.) {
situco = IntSurf_Outside;
situco_otherside = IntSurf_Inside;
if (Normp.Dot(Normco) > 0.) {
situp = IntSurf_Inside;
situp_otherside = IntSurf_Outside;
}
else {
situp = IntSurf_Outside;
situp_otherside = IntSurf_Inside;
}
}
else {
situco = IntSurf_Inside;
situco_otherside = IntSurf_Outside;
if (Normp.Dot(Normco) > 0.) {
situp = IntSurf_Outside;
situp_otherside = IntSurf_Inside;
}
else {
situp = IntSurf_Inside;
situp_otherside = IntSurf_Outside;
}
}
//----------------------------------------------------------
//-- Apex ---> Cone.Direction
//--
Handle(IntPatch_GLine) glig;
if (!Reversed) {
glig = new IntPatch_GLine(linsol, Standard_True, situp, situco);
}
else {
glig = new IntPatch_GLine(linsol, Standard_True, situco, situp);
}
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
//----------------------------------------------------------
//-- -Cone.Direction <------- Apex
//--
linsol.SetDirection(linsol.Direction().Reversed());
if (!Reversed) {
glig = new IntPatch_GLine(linsol, Standard_True, situp_otherside, situco_otherside);
}
else {
glig = new IntPatch_GLine(linsol, Standard_True, situco_otherside, situp_otherside);
}
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
IntPatch_Point ptsol;
ptsol.SetValue(apex,TolTang,Standard_False);
ptsol.SetParameters(U1,V1,U2,V2);
ptsol.SetParameter(para);
gp_Pnt ptbid2(apex.XYZ() + 5.*Co.Axis().Direction().XYZ());
gp_Vec TestCurvature(ptbid,ptbid2);
gp_Vec Normp,Normco;
if (!Reversed) {
Normp = Quad1.Normale(ptbid);
Normco = Quad2.Normale(ptbid);
}
else {
Normp = Quad2.Normale(ptbid);
Normco = Quad1.Normale(ptbid);
}
IntSurf_Situation situco,situco_otherside;
IntSurf_Situation situp,situp_otherside;
if (Normp.Dot(TestCurvature) > 0.) {
situco = IntSurf_Outside;
situco_otherside = IntSurf_Inside;
if (Normp.Dot(Normco) > 0.) {
situp = IntSurf_Inside;
situp_otherside = IntSurf_Outside;
}
else {
situp = IntSurf_Outside;
situp_otherside = IntSurf_Inside;
}
}
else {
situco = IntSurf_Inside;
situco_otherside = IntSurf_Outside;
if (Normp.Dot(Normco) > 0.) {
situp = IntSurf_Outside;
situp_otherside = IntSurf_Inside;
}
else {
situp = IntSurf_Inside;
situp_otherside = IntSurf_Outside;
}
}
//----------------------------------------------------------
//-- Apex ---> Cone.Direction
//--
Handle(IntPatch_GLine) glig;
if (!Reversed) {
glig = new IntPatch_GLine(linsol, Standard_True, situp, situco);
}
else {
glig = new IntPatch_GLine(linsol, Standard_True, situco, situp);
}
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
//----------------------------------------------------------
//-- -Cone.Direction <------- Apex
//--
linsol.SetDirection(linsol.Direction().Reversed());
if (!Reversed) {
glig = new IntPatch_GLine(linsol, Standard_True, situp_otherside, situco_otherside);
}
else {
glig = new IntPatch_GLine(linsol, Standard_True, situco_otherside, situp_otherside);
}
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
}
else {
// on a 2 droites. Il faut determiner les transitions
// de chacune. On oriente chaque ligne dans le sens
// de l axe du cone. Les transitions de chaque ligne seront
// inverses l une de l autre => on ne fait le calcul que sur
// la premiere.
if (linsol.Direction().DotCross
(Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
// on a 2 droites. Il faut determiner les transitions
// de chacune. On oriente chaque ligne dans le sens
// de l axe du cone. Les transitions de chaque ligne seront
// inverses l une de l autre => on ne fait le calcul que sur
// la premiere.
if (linsol.Direction().DotCross
(Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
Multpoint = Standard_True;
//------------------------------------------- Ligne 1 -------
IntPatch_Point ptsol;
ptsol.SetValue(apex,TolTang,Standard_False);
ptsol.SetParameters(U1,V1,U2,V2);
ptsol.SetParameter(para);
ptsol.SetMultiple(Standard_True);
Handle(IntPatch_GLine) glig;
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
//-----------------------------------------------------------
//-- Other Side : Les transitions restent les memes
//-- linsol -> -linsol et Quad1(2).N -> -Quad1(2).N
//--
linsol.SetDirection(linsol.Direction().Reversed());
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
para = ElCLib::Parameter(linsol, apex);
ptsol.SetParameter(para);
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
//------------------------------------------- Ligne 2 -------
linsol = inter.Line(2);
if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
linsol.SetDirection(linsol.Direction().Reversed());
}
para = ElCLib::Parameter(linsol, apex);
ptbid = ElCLib::Value(para+5.,linsol);
if (linsol.Direction().DotCross
(Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
ptsol.SetParameter(para);
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
para = ElCLib::Parameter(linsol, apex);
ptsol.SetParameter(para);
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
//-----------------------------------------------------------
//-- Other Side : Les transitions restent les memes
//-- linsol -> -linsol et Quad1(2).N -> -Quad1(2).N
//--
linsol.SetDirection(linsol.Direction().Reversed());
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
para = ElCLib::Parameter(linsol, apex);
ptsol.SetParameter(para);
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
Multpoint = Standard_True;
//------------------------------------------- Ligne 1 -------
IntPatch_Point ptsol;
ptsol.SetValue(apex,TolTang,Standard_False);
ptsol.SetParameters(U1,V1,U2,V2);
ptsol.SetParameter(para);
ptsol.SetMultiple(Standard_True);
Handle(IntPatch_GLine) glig;
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
//-----------------------------------------------------------
//-- Other Side : Les transitions restent les memes
//-- linsol -> -linsol et Quad1(2).N -> -Quad1(2).N
//--
linsol.SetDirection(linsol.Direction().Reversed());
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
para = ElCLib::Parameter(linsol, apex);
ptsol.SetParameter(para);
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
//------------------------------------------- Ligne 2 -------
linsol = inter.Line(2);
if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
linsol.SetDirection(linsol.Direction().Reversed());
}
para = ElCLib::Parameter(linsol, apex);
ptbid = ElCLib::Value(para+5.,linsol);
if (linsol.Direction().DotCross
(Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
ptsol.SetParameter(para);
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
para = ElCLib::Parameter(linsol, apex);
ptsol.SetParameter(para);
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
//-----------------------------------------------------------
//-- Other Side : Les transitions restent les memes
//-- linsol -> -linsol et Quad1(2).N -> -Quad1(2).N
//--
linsol.SetDirection(linsol.Direction().Reversed());
glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
para = ElCLib::Parameter(linsol, apex);
ptsol.SetParameter(para);
glig->AddVertex(ptsol);
glig->SetFirstPoint(1);
slin.Append(glig);
}
}
break;
@@ -562,12 +565,12 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
ElCLib::D1(0.,cirsol,ptref,Tgt);
if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
slin.Append(glig);
@@ -581,12 +584,12 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
ElCLib::D1(0.,elipsol,ptref,Tgt);
if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
slin.Append(glig);
@@ -598,17 +601,17 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
gp_Vec Tgtorig(parabsol.YAxis().Direction());
Standard_Real ptran = Tgtorig.DotCross(Quad2.Normale(parabsol.Location()),
Quad1.Normale(parabsol.Location()));
Quad1.Normale(parabsol.Location()));
if (ptran >0.00000001) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else if (ptran <-0.00000001) {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
else {
trans1=trans2=IntSurf_Undecided;
trans1=trans2=IntSurf_Undecided;
}
Handle(IntPatch_GLine) glig = new IntPatch_GLine(parabsol,Standard_False,trans1,trans2);
slin.Append(glig);
@@ -620,26 +623,26 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
gp_Vec Tgttop;
for(Standard_Integer i=1; i<=2; i++) {
gp_Hypr hyprsol = inter.Hyperbola(i);
tophypr = ElCLib::Value(hyprsol.MajorRadius(),
hyprsol.XAxis());
Tgttop = hyprsol.YAxis().Direction();
Standard_Real qwe = Tgttop.DotCross(Quad2.Normale(tophypr),
Quad1.Normale(tophypr));
if (qwe>0.00000001) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else if (qwe<-0.00000001){
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
else {
trans1=trans2=IntSurf_Undecided;
}
Handle(IntPatch_GLine) glig = new IntPatch_GLine(hyprsol,Standard_False,trans1,trans2);
slin.Append(glig);
gp_Hypr hyprsol = inter.Hyperbola(i);
tophypr = ElCLib::Value(hyprsol.MajorRadius(),
hyprsol.XAxis());
Tgttop = hyprsol.YAxis().Direction();
Standard_Real qwe = Tgttop.DotCross(Quad2.Normale(tophypr),
Quad1.Normale(tophypr));
if (qwe>0.00000001) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else if (qwe<-0.00000001){
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
else {
trans1=trans2=IntSurf_Undecided;
}
Handle(IntPatch_GLine) glig = new IntPatch_GLine(hyprsol,Standard_False,trans1,trans2);
slin.Append(glig);
}
}
break;
@@ -650,6 +653,73 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
}
return Standard_True;
}
//=======================================================================
//function : IntPTo
//purpose :
//=======================================================================
Standard_Boolean IntPTo(const IntSurf_Quadric& theQuad1,
const IntSurf_Quadric& theQuad2,
const Standard_Real theTolTang,
const Standard_Boolean bReversed,
Standard_Boolean& bEmpty,
IntPatch_SequenceOfLine& theSeqLin)
{
const gp_Pln aPln = bReversed ? theQuad2.Plane() : theQuad1.Plane();
const gp_Torus aTorus = bReversed ? theQuad1.Torus() : theQuad2.Torus();
//
IntAna_QuadQuadGeo inter(aPln, aTorus, theTolTang);
Standard_Boolean bRet = inter.IsDone();
//
if (!bRet) {
return bRet;
}
//
IntAna_ResultType typint = inter.TypeInter();
Standard_Integer NbSol = inter.NbSolutions();
bEmpty = Standard_False;
//
switch (typint) {
case IntAna_Empty :
bEmpty = Standard_True;
break;
//
case IntAna_Circle : {
Standard_Integer i;
IntSurf_TypeTrans trans1, trans2;
gp_Pnt ptref;
gp_Vec Tgt;
//
for (i = 1; i <= NbSol; ++i) {
gp_Circ aC = inter.Circle(i);
if (!aPln.Axis().IsNormal(aTorus.Axis(), Precision::Angular())) {
AdjustToSeam(aTorus, aC);
}
ElCLib::D1(0., aC, ptref, Tgt);
//
if (Tgt.DotCross(theQuad2.Normale(ptref),theQuad1.Normale(ptref)) > 0.0) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
//
Handle(IntPatch_GLine) glig =
new IntPatch_GLine(aC, Standard_False, trans1, trans2);
theSeqLin.Append(glig);
}
}
break;
//
case IntAna_NoGeometricSolution:
default:
bRet = Standard_False;
break;
}
//
return bRet;
}
//
//modified by NIZNHY-PKV Thu Sep 15 10:53:39 2011f
//=======================================================================
@@ -657,7 +727,7 @@ Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
//purpose :
//=======================================================================
void AdjustToSeam (const gp_Cone& aQuad,
gp_Circ& aCirc)
gp_Circ& aCirc)
{
gp_Ax2 aAx2;
//
@@ -671,8 +741,8 @@ void AdjustToSeam (const gp_Cone& aQuad,
//purpose :
//=======================================================================
void AdjustToSeam (const gp_Sphere& aQuad,
gp_Circ& aCirc,
const Standard_Real aTolAng)
gp_Circ& aCirc,
const Standard_Real aTolAng)
{
gp_Ax2 aAx2;
//
@@ -693,7 +763,7 @@ void AdjustToSeam (const gp_Sphere& aQuad,
//purpose :
//=======================================================================
void AdjustToSeam (const gp_Cylinder& aQuad,
gp_Circ& aCirc)
gp_Circ& aCirc)
{
gp_Ax2 aAx2;
//
@@ -703,17 +773,31 @@ void AdjustToSeam (const gp_Cylinder& aQuad,
aCirc.SetPosition(aAx2);
}
//=======================================================================
//function : AdjustToSeam
//purpose :
//=======================================================================
void AdjustToSeam (const gp_Torus& aQuad,
gp_Circ& aCirc)
{
gp_Ax2 aAx2;
//
const gp_Pnt& aPLoc=aCirc.Location();
const gp_Ax3& aAx3=aQuad.Position();
SeamPosition(aPLoc, aAx3, aAx2);
aCirc.SetPosition(aAx2);
}
//=======================================================================
//function : SeamPosition
//purpose :
//=======================================================================
void SeamPosition(const gp_Pnt& aPLoc,
const gp_Ax3& aPos,
gp_Ax2& aSeamPos)
const gp_Ax3& aPos,
gp_Ax2& aSeamPos)
{
const gp_Dir& aDZ=aPos.Direction();
const gp_Dir& aDX=aPos.XDirection();
gp_Ax2 aAx2(aPLoc, aDZ, aDX);
aSeamPos=aAx2;
}
//modified by NIZNHY-PKV Thu Sep 15 10:53:41 2011t

View File

@@ -0,0 +1,181 @@
// Created on: 1992-05-07
// Created by: Jacques GOUSSARD
// Copyright (c) 1992-1999 Matra Datavision
// Copyright (c) 1999-2012 OPEN CASCADE SAS
//
// 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
// 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.
static
Standard_Boolean TreatResultTorus(const IntSurf_Quadric& theQuad1,
const IntSurf_Quadric& theQuad2,
const IntAna_QuadQuadGeo& anInt,
Standard_Boolean& bEmpty,
IntPatch_SequenceOfLine& theSeqLin);
//=======================================================================
//function : IntCyTo
//purpose :
//=======================================================================
Standard_Boolean IntCyTo(const IntSurf_Quadric& theQuad1,
const IntSurf_Quadric& theQuad2,
const Standard_Real theTolTang,
const Standard_Boolean bReversed,
Standard_Boolean& bEmpty,
IntPatch_SequenceOfLine& theSeqLin)
{
const gp_Cylinder aCyl = bReversed ? theQuad2.Cylinder() : theQuad1.Cylinder();
const gp_Torus aTorus = bReversed ? theQuad1.Torus() : theQuad2.Torus();
//
IntAna_QuadQuadGeo anInt(aCyl, aTorus, theTolTang);
Standard_Boolean bRet =
TreatResultTorus(theQuad1, theQuad2, anInt, bEmpty, theSeqLin);
//
return bRet;
}
//=======================================================================
//function : IntCoTo
//purpose :
//=======================================================================
Standard_Boolean IntCoTo(const IntSurf_Quadric& theQuad1,
const IntSurf_Quadric& theQuad2,
const Standard_Real theTolTang,
const Standard_Boolean bReversed,
Standard_Boolean& bEmpty,
IntPatch_SequenceOfLine& theSeqLin)
{
const gp_Cone aCone = bReversed ? theQuad2.Cone() : theQuad1.Cone();
const gp_Torus aTorus = bReversed ? theQuad1.Torus() : theQuad2.Torus();
//
IntAna_QuadQuadGeo anInt(aCone, aTorus, theTolTang);
Standard_Boolean bRet =
TreatResultTorus(theQuad1, theQuad2, anInt, bEmpty, theSeqLin);
//
return bRet;
}
//=======================================================================
//function : IntSpTo
//purpose :
//=======================================================================
Standard_Boolean IntSpTo(const IntSurf_Quadric& theQuad1,
const IntSurf_Quadric& theQuad2,
const Standard_Real theTolTang,
const Standard_Boolean bReversed,
Standard_Boolean& bEmpty,
IntPatch_SequenceOfLine& theSeqLin)
{
const gp_Sphere aSphere = bReversed ? theQuad2.Sphere() : theQuad1.Sphere();
const gp_Torus aTorus = bReversed ? theQuad1.Torus() : theQuad2.Torus();
//
IntAna_QuadQuadGeo anInt(aSphere, aTorus, theTolTang);
Standard_Boolean bRet =
TreatResultTorus(theQuad1, theQuad2, anInt, bEmpty, theSeqLin);
//
return bRet;
}
//=======================================================================
//function : IntToTo
//purpose :
//=======================================================================
Standard_Boolean IntToTo(const IntSurf_Quadric& theQuad1,
const IntSurf_Quadric& theQuad2,
const Standard_Real theTolTang,
Standard_Boolean& bSameSurf,
Standard_Boolean& bEmpty,
IntPatch_SequenceOfLine& theSeqLin)
{
const gp_Torus aTorus1 = theQuad1.Torus();
const gp_Torus aTorus2 = theQuad2.Torus();
//
IntAna_QuadQuadGeo anInt(aTorus1, aTorus2, theTolTang);
Standard_Boolean bRet = anInt.IsDone();
if (bRet) {
if (anInt.TypeInter() == IntAna_Same) {
bEmpty = Standard_False;
bSameSurf = Standard_True;
} else {
bRet = TreatResultTorus(theQuad1, theQuad2, anInt, bEmpty, theSeqLin);
}
}
//
return bRet;
}
//=======================================================================
//function : TreatResultTorus
//purpose :
//=======================================================================
static Standard_Boolean TreatResultTorus(const IntSurf_Quadric& theQuad1,
const IntSurf_Quadric& theQuad2,
const IntAna_QuadQuadGeo& anInt,
Standard_Boolean& bEmpty,
IntPatch_SequenceOfLine& theSeqLin)
{
Standard_Boolean bRet = anInt.IsDone();
//
if (!bRet) {
return bRet;
}
//
IntAna_ResultType typint = anInt.TypeInter();
Standard_Integer NbSol = anInt.NbSolutions();
bEmpty = Standard_False;
//
switch (typint) {
case IntAna_Empty :
bEmpty = Standard_True;
break;
//
case IntAna_Circle : {
Standard_Integer i;
IntSurf_TypeTrans trans1, trans2;
gp_Vec Tgt;
gp_Pnt ptref;
//
for (i = 1; i <= NbSol; ++i) {
gp_Circ aC = anInt.Circle(i);
if (theQuad1.TypeQuadric() == theQuad2.TypeQuadric()) {
AdjustToSeam(theQuad1.Torus(), aC);
}
ElCLib::D1(0., aC, ptref, Tgt);
Standard_Real qwe = Tgt.DotCross(theQuad2.Normale(ptref),
theQuad1.Normale(ptref));
if(qwe> 0.00000001) {
trans1 = IntSurf_Out;
trans2 = IntSurf_In;
}
else if(qwe< -0.00000001) {
trans1 = IntSurf_In;
trans2 = IntSurf_Out;
}
else {
trans1=trans2=IntSurf_Undecided;
}
//
Handle(IntPatch_GLine) glig =
new IntPatch_GLine(aC, Standard_False, trans1, trans2);
theSeqLin.Append(glig);
}
}
break;
//
case IntAna_NoGeometricSolution:
default:
bRet = Standard_False;
break;
}
//
return bRet;
}

View File

@@ -849,7 +849,79 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1,
case GeomAbs_Cone: ts2 = 1; break;
default: break;
}
//
// treatment of the cases with torus and any other geom surface
if ((typs1 == GeomAbs_Torus && ts2) ||
(typs2 == GeomAbs_Torus && ts1) ||
(typs1 == GeomAbs_Torus && typs2 == GeomAbs_Torus)) {
// check if axes collinear
//
const Handle(Adaptor3d_HSurface)& aTorSurf =
(typs1 == GeomAbs_Torus) ? theS1 : theS2;
const Handle(Adaptor3d_HSurface)& aGeomSurf =
(typs1 == GeomAbs_Torus) ? theS2 : theS1;
//
Standard_Boolean bValid =
aTorSurf->Torus().MajorRadius() > aTorSurf->Torus().MinorRadius();
if (bValid && (typs1 == typs2)) {
bValid = aGeomSurf->Torus().MajorRadius() > aGeomSurf->Torus().MinorRadius();
}
//
if (bValid) {
Standard_Boolean bCheck, bImpImp;
const gp_Ax1 aTorAx = aTorSurf->Torus().Axis();
const gp_Lin aL1(aTorAx);
//
bCheck = Standard_True;
bImpImp = Standard_False;
//
gp_Ax1 aGeomAx;
switch (aGeomSurf->GetType()) {
case GeomAbs_Plane: {
aGeomAx = aGeomSurf->Plane().Axis();
if (aTorAx.IsParallel(aGeomAx, Precision::Angular()) ||
(aTorAx.IsNormal(aGeomAx, Precision::Angular()) &&
(aGeomSurf->Plane().Distance(aTorAx.Location()) < Precision::Confusion()))) {
bImpImp = Standard_True;
}
bCheck = Standard_False;
break;
}
case GeomAbs_Sphere: {
if (aL1.Distance(aGeomSurf->Sphere().Location()) < Precision::Confusion()) {
bImpImp = Standard_True;
}
bCheck = Standard_False;
break;
}
case GeomAbs_Cylinder:
aGeomAx = aGeomSurf->Cylinder().Axis();
break;
case GeomAbs_Cone:
aGeomAx = aGeomSurf->Cone().Axis();
break;
case GeomAbs_Torus:
aGeomAx = aGeomSurf->Torus().Axis();
break;
default:
bCheck = Standard_False;
break;
}
//
if (bCheck) {
if (aTorAx.IsParallel(aGeomAx, Precision::Angular()) &&
(aL1.Distance(aGeomAx.Location()) <= Precision::Confusion())) {
bImpImp = Standard_True;
}
}
//
if (bImpImp) {
ts1 = 1;
ts2 = 1;
}
}
}
//
// Possible intersection types: 1. ts1 == ts2 == 1 <Geom-Geom>
// 2. ts1 != ts2 <Geom-Param>
// 3. ts1 == ts2 == 0 <Param-Param>
@@ -1028,7 +1100,79 @@ void IntPatch_Intersection::Perform(const Handle(Adaptor3d_HSurface)& theS1,
case GeomAbs_Cone: ts2 = 1; break;
default: break;
}
//
// treatment of the cases with torus and any other geom surface
if ((typs1 == GeomAbs_Torus && ts2) ||
(typs2 == GeomAbs_Torus && ts1) ||
(typs1 == GeomAbs_Torus && typs2 == GeomAbs_Torus)) {
// check if axes collinear
//
const Handle(Adaptor3d_HSurface)& aTorSurf =
(typs1 == GeomAbs_Torus) ? theS1 : theS2;
const Handle(Adaptor3d_HSurface)& aGeomSurf =
(typs1 == GeomAbs_Torus) ? theS2 : theS1;
//
Standard_Boolean bValid =
aTorSurf->Torus().MajorRadius() > aTorSurf->Torus().MinorRadius();
if (bValid && (typs1 == typs2)) {
bValid = aGeomSurf->Torus().MajorRadius() > aGeomSurf->Torus().MinorRadius();
}
//
if (bValid) {
Standard_Boolean bCheck, bImpImp;
const gp_Ax1 aTorAx = aTorSurf->Torus().Axis();
const gp_Lin aL1(aTorAx);
//
bCheck = Standard_True;
bImpImp = Standard_False;
//
gp_Ax1 aGeomAx;
switch (aGeomSurf->GetType()) {
case GeomAbs_Plane: {
aGeomAx = aGeomSurf->Plane().Axis();
if (aTorAx.IsParallel(aGeomAx, Precision::Angular()) ||
(aTorAx.IsNormal(aGeomAx, Precision::Angular()) &&
(aGeomSurf->Plane().Distance(aTorAx.Location()) < Precision::Confusion()))) {
bImpImp = Standard_True;
}
bCheck = Standard_False;
break;
}
case GeomAbs_Sphere: {
if (aL1.Distance(aGeomSurf->Sphere().Location()) < Precision::Confusion()) {
bImpImp = Standard_True;
}
bCheck = Standard_False;
break;
}
case GeomAbs_Cylinder:
aGeomAx = aGeomSurf->Cylinder().Axis();
break;
case GeomAbs_Cone:
aGeomAx = aGeomSurf->Cone().Axis();
break;
case GeomAbs_Torus:
aGeomAx = aGeomSurf->Torus().Axis();
break;
default:
bCheck = Standard_False;
break;
}
//
if (bCheck) {
if (aTorAx.IsParallel(aGeomAx, Precision::Angular()) &&
(aL1.Distance(aGeomAx.Location()) <= Precision::Confusion())) {
bImpImp = Standard_True;
}
}
//
if (bImpImp) {
ts1 = 1;
ts2 = 1;
}
}
}
//
// Possible intersection types: 1. ts1 == ts2 == 1 <Geom-Geom>
// 2. ts1 != ts2 <Geom-Param>
// 3. ts1 == ts2 == 0 <Param-Param>
@@ -1215,6 +1359,10 @@ void IntPatch_Intersection::GeomGeomPerfom(const Handle(Adaptor3d_HSurface)& the
Quad1.SetValue(theS1->Cone());
break;
case GeomAbs_Torus:
Quad1.SetValue(theS1->Torus());
break;
default:
break;
}
@@ -1236,6 +1384,10 @@ void IntPatch_Intersection::GeomGeomPerfom(const Handle(Adaptor3d_HSurface)& the
Quad2.SetValue(theS2->Cone());
break;
case GeomAbs_Torus:
Quad2.SetValue(theS2->Torus());
break;
default:
break;
}

View File

@@ -134,12 +134,12 @@ static void Recadre(const Handle(Adaptor3d_HSurface)& myHS1,
//=======================================================================
static void Parameters(const Handle(Adaptor3d_HSurface)& myHS1,
const Handle(Adaptor3d_HSurface)& myHS2,
const gp_Pnt& Ptref,
Standard_Real& U1,
Standard_Real& V1,
Standard_Real& U2,
Standard_Real& V2)
const Handle(Adaptor3d_HSurface)& myHS2,
const gp_Pnt& Ptref,
Standard_Real& U1,
Standard_Real& V1,
Standard_Real& U2,
Standard_Real& V2)
{
IntSurf_Quadric quad1,quad2;
GeomAbs_SurfaceType typs = myHS1->Surface().GetType();
@@ -156,6 +156,9 @@ static void Parameters(const Handle(Adaptor3d_HSurface)& myHS1,
case GeomAbs_Sphere:
quad1.SetValue(myHS1->Surface().Sphere());
break;
case GeomAbs_Torus:
quad1.SetValue(myHS1->Surface().Torus());
break;
default:
Standard_ConstructionError::Raise("IntPatch_IntSS::MakeCurve");
}
@@ -174,6 +177,9 @@ static void Parameters(const Handle(Adaptor3d_HSurface)& myHS1,
case GeomAbs_Sphere:
quad2.SetValue(myHS2->Surface().Sphere());
break;
case GeomAbs_Torus:
quad2.SetValue(myHS2->Surface().Torus());
break;
default:
Standard_ConstructionError::Raise("IntPatch_IntSS::MakeCurve");
}