1 // Created on: 1992-05-07
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 Standard_Boolean TreatResultTorus(const IntSurf_Quadric& theQuad1,
20 const IntSurf_Quadric& theQuad2,
21 const IntAna_QuadQuadGeo& anInt,
22 Standard_Boolean& bEmpty,
23 IntPatch_SequenceOfLine& theSeqLin);
25 //=======================================================================
28 //=======================================================================
29 Standard_Boolean IntCyTo(const IntSurf_Quadric& theQuad1,
30 const IntSurf_Quadric& theQuad2,
31 const Standard_Real theTolTang,
32 const Standard_Boolean bReversed,
33 Standard_Boolean& bEmpty,
34 IntPatch_SequenceOfLine& theSeqLin)
36 const gp_Cylinder aCyl = bReversed ? theQuad2.Cylinder() : theQuad1.Cylinder();
37 const gp_Torus aTorus = bReversed ? theQuad1.Torus() : theQuad2.Torus();
39 IntAna_QuadQuadGeo anInt(aCyl, aTorus, theTolTang);
40 Standard_Boolean bRet =
41 TreatResultTorus(theQuad1, theQuad2, anInt, bEmpty, theSeqLin);
46 //=======================================================================
49 //=======================================================================
50 Standard_Boolean IntCoTo(const IntSurf_Quadric& theQuad1,
51 const IntSurf_Quadric& theQuad2,
52 const Standard_Real theTolTang,
53 const Standard_Boolean bReversed,
54 Standard_Boolean& bEmpty,
55 IntPatch_SequenceOfLine& theSeqLin)
57 const gp_Cone aCone = bReversed ? theQuad2.Cone() : theQuad1.Cone();
58 const gp_Torus aTorus = bReversed ? theQuad1.Torus() : theQuad2.Torus();
60 IntAna_QuadQuadGeo anInt(aCone, aTorus, theTolTang);
61 Standard_Boolean bRet =
62 TreatResultTorus(theQuad1, theQuad2, anInt, bEmpty, theSeqLin);
67 //=======================================================================
70 //=======================================================================
71 Standard_Boolean IntSpTo(const IntSurf_Quadric& theQuad1,
72 const IntSurf_Quadric& theQuad2,
73 const Standard_Real theTolTang,
74 const Standard_Boolean bReversed,
75 Standard_Boolean& bEmpty,
76 IntPatch_SequenceOfLine& theSeqLin)
78 const gp_Sphere aSphere = bReversed ? theQuad2.Sphere() : theQuad1.Sphere();
79 const gp_Torus aTorus = bReversed ? theQuad1.Torus() : theQuad2.Torus();
81 IntAna_QuadQuadGeo anInt(aSphere, aTorus, theTolTang);
82 Standard_Boolean bRet =
83 TreatResultTorus(theQuad1, theQuad2, anInt, bEmpty, theSeqLin);
88 //=======================================================================
91 //=======================================================================
92 Standard_Boolean IntToTo(const IntSurf_Quadric& theQuad1,
93 const IntSurf_Quadric& theQuad2,
94 const Standard_Real theTolTang,
95 Standard_Boolean& bSameSurf,
96 Standard_Boolean& bEmpty,
97 IntPatch_SequenceOfLine& theSeqLin)
99 const gp_Torus aTorus1 = theQuad1.Torus();
100 const gp_Torus aTorus2 = theQuad2.Torus();
102 IntAna_QuadQuadGeo anInt(aTorus1, aTorus2, theTolTang);
103 Standard_Boolean bRet = anInt.IsDone();
105 if (anInt.TypeInter() == IntAna_Same) {
106 bEmpty = Standard_False;
107 bSameSurf = Standard_True;
109 bRet = TreatResultTorus(theQuad1, theQuad2, anInt, bEmpty, theSeqLin);
116 //=======================================================================
117 //function : TreatResultTorus
119 //=======================================================================
120 static Standard_Boolean TreatResultTorus(const IntSurf_Quadric& theQuad1,
121 const IntSurf_Quadric& theQuad2,
122 const IntAna_QuadQuadGeo& anInt,
123 Standard_Boolean& bEmpty,
124 IntPatch_SequenceOfLine& theSeqLin)
126 Standard_Boolean bRet = anInt.IsDone();
132 IntAna_ResultType typint = anInt.TypeInter();
133 Standard_Integer NbSol = anInt.NbSolutions();
134 bEmpty = Standard_False;
138 bEmpty = Standard_True;
141 case IntAna_Circle : {
143 IntSurf_TypeTrans trans1, trans2;
147 for (i = 1; i <= NbSol; ++i) {
148 gp_Circ aC = anInt.Circle(i);
149 if (theQuad1.TypeQuadric() == theQuad2.TypeQuadric()) {
150 AdjustToSeam(theQuad1.Torus(), aC);
152 ElCLib::D1(0., aC, ptref, Tgt);
153 Standard_Real qwe = Tgt.DotCross(theQuad2.Normale(ptref),
154 theQuad1.Normale(ptref));
155 if(qwe> 0.00000001) {
156 trans1 = IntSurf_Out;
159 else if(qwe< -0.00000001) {
161 trans2 = IntSurf_Out;
164 trans1=trans2=IntSurf_Undecided;
167 Handle(IntPatch_GLine) glig =
168 new IntPatch_GLine(aC, Standard_False, trans1, trans2);
169 theSeqLin.Append(glig);
174 case IntAna_NoGeometricSolution:
176 bRet = Standard_False;