Warning, /include/opencascade/IntPatch_ImpImpIntersection_3.gxx is written in an unsupported language. File is not indexed.
0001 // Created on: 1992-05-07
0002 // Created by: Jacques GOUSSARD
0003 // Copyright (c) 1992-1999 Matra Datavision
0004 // Copyright (c) 1999-2014 OPEN CASCADE SAS
0005 //
0006 // This file is part of Open CASCADE Technology software library.
0007 //
0008 // This library is free software; you can redistribute it and/or modify it under
0009 // the terms of the GNU Lesser General Public License version 2.1 as published
0010 // by the Free Software Foundation, with special exception defined in the file
0011 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
0012 // distribution for complete text of the license and disclaimer of any warranty.
0013 //
0014 // Alternatively, this file may be used under the terms of Open CASCADE
0015 // commercial license or contractual agreement.
0016
0017 //modified by NIZNHY-PKV Thu Sep 15 11:09:12 2011
0018 static
0019 void SeamPosition(const gp_Pnt& aPLoc,
0020 const gp_Ax3& aPos,
0021 gp_Ax2& aSeamPos);
0022 static
0023 void AdjustToSeam (const gp_Cylinder& aQuad,
0024 gp_Circ& aCirc);
0025 static
0026 void AdjustToSeam (const gp_Sphere& aQuad,
0027 gp_Circ& aCirc,
0028 const Standard_Real aTolAng);
0029 static
0030 void AdjustToSeam (const gp_Cone& aQuad,
0031 gp_Circ& aCirc);
0032 static
0033 void AdjustToSeam (const gp_Torus& aQuad,
0034 gp_Circ& aCirc);
0035 //modified by NIZNHY-PKV Thu Sep 15 11:09:13 2011
0036
0037 //=======================================================================
0038 //function : IntPP
0039 //purpose :
0040 // Traitement du cas Plan/Plan
0041 //=======================================================================
0042 Standard_Boolean IntPP (const IntSurf_Quadric& Quad1,
0043 const IntSurf_Quadric& Quad2,
0044 const Standard_Real Tolang,
0045 const Standard_Real TolTang,
0046 Standard_Boolean& Same,
0047 IntPatch_SequenceOfLine& slin)
0048
0049 {
0050 IntSurf_TypeTrans trans1,trans2;
0051 IntAna_ResultType typint;
0052 gp_Pln pl1(Quad1.Plane());
0053 gp_Pln pl2(Quad2.Plane());
0054
0055 IntAna_QuadQuadGeo inter(pl1,pl2,Tolang,TolTang);
0056 if (!inter.IsDone()) {return Standard_False;}
0057 Same = Standard_False;
0058 typint = inter.TypeInter();
0059 if (typint == IntAna_Same) { // cas faces confondues
0060 Same = Standard_True;
0061 }
0062 else if (typint != IntAna_Empty) { // on a une ligne
0063 gp_Lin linsol = inter.Line(1);
0064 Standard_Real discri = linsol.Direction().DotCross
0065 (Quad2.Normale(linsol.Location()),
0066 Quad1.Normale(linsol.Location()));
0067
0068 if (discri>0.0) {
0069 trans1 = IntSurf_Out;
0070 trans2 = IntSurf_In;
0071 }
0072 else {
0073 trans1 = IntSurf_In;
0074 trans2 = IntSurf_Out;
0075 }
0076 Handle(IntPatch_GLine) glig =
0077 new IntPatch_GLine (linsol,Standard_False,trans1,trans2);
0078 slin.Append(glig);
0079 }
0080 return Standard_True;
0081 }
0082 //=======================================================================
0083 //function : IntPCy
0084 //purpose :
0085 // Traitement du cas Plan/Cylindre et reciproquement
0086 //=======================================================================
0087 Standard_Boolean IntPCy (const IntSurf_Quadric& Quad1,
0088 const IntSurf_Quadric& Quad2,
0089 const Standard_Real Tolang,
0090 const Standard_Real TolTang,
0091 const Standard_Boolean Reversed,
0092 Standard_Boolean& Empty,
0093 IntPatch_SequenceOfLine& slin,
0094 const Standard_Real H)
0095
0096 {
0097 gp_Pln Pl;
0098 gp_Cylinder Cy;
0099
0100 IntSurf_TypeTrans trans1,trans2;
0101 IntAna_ResultType typint;
0102
0103 IntAna_QuadQuadGeo inter;
0104 if (!Reversed) {
0105 Pl = Quad1.Plane();
0106 Cy = Quad2.Cylinder();
0107 }
0108 else {
0109 Pl = Quad2.Plane();
0110 Cy = Quad1.Cylinder();
0111 }
0112 inter.Perform(Pl,Cy,Tolang,TolTang,H);
0113 if (!inter.IsDone()) {return Standard_False;}
0114 typint = inter.TypeInter();
0115 Standard_Integer NbSol = inter.NbSolutions();
0116 Empty = Standard_False;
0117
0118 switch (typint) {
0119
0120 case IntAna_Empty : {
0121 Empty = Standard_True;
0122 }
0123 break;
0124
0125 case IntAna_Line: {
0126 gp_Lin linsol = inter.Line(1);
0127 gp_Pnt orig(linsol.Location());
0128 if (NbSol == 1) { // ligne de tangence
0129 gp_Vec TestCurvature(orig,Cy.Location());
0130 gp_Vec Normp,Normcyl;
0131 if (!Reversed) {
0132 Normp = Quad1.Normale(orig);
0133 Normcyl = Quad2.Normale(orig);
0134 }
0135 else {
0136 Normp = Quad2.Normale(orig);
0137 Normcyl = Quad1.Normale(orig);
0138 }
0139
0140 IntSurf_Situation situcyl;
0141 IntSurf_Situation situp;
0142
0143 if (Normp.Dot(TestCurvature) > 0.) {
0144 situcyl = IntSurf_Outside;
0145 if (Normp.Dot(Normcyl) > 0.) {
0146 situp = IntSurf_Inside;
0147 }
0148 else {
0149 situp = IntSurf_Outside;
0150 }
0151 }
0152 else {
0153 situcyl = IntSurf_Inside;
0154 if (Normp.Dot(Normcyl) > 0.) {
0155 situp = IntSurf_Outside;
0156 }
0157 else {
0158 situp = IntSurf_Inside;
0159 }
0160 }
0161 Handle(IntPatch_GLine) glig;
0162 if (!Reversed) {
0163 glig = new IntPatch_GLine(linsol, Standard_True, situp, situcyl);
0164 }
0165 else {
0166 glig = new IntPatch_GLine(linsol, Standard_True, situcyl, situp);
0167 }
0168 slin.Append(glig);
0169 }
0170 else {
0171 // on a 2 droites. Il faut determiner les transitions
0172 // de chacune.
0173
0174 if (linsol.Direction().DotCross(Quad2.Normale(orig),
0175 Quad1.Normale(orig)) >0.) {
0176 trans1 = IntSurf_Out;
0177 trans2 = IntSurf_In;
0178 }
0179 else {
0180 trans1 = IntSurf_In;
0181 trans2 = IntSurf_Out;
0182 }
0183 Handle(IntPatch_GLine) glig =
0184 new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
0185 slin.Append(glig);
0186
0187 linsol = inter.Line(2);
0188 orig = linsol.Location();
0189
0190 if (linsol.Direction().DotCross(Quad2.Normale(orig),
0191 Quad1.Normale(orig)) >0.) {
0192 trans1 = IntSurf_Out;
0193 trans2 = IntSurf_In;
0194 }
0195 else {
0196 trans1 = IntSurf_In;
0197 trans2 = IntSurf_Out;
0198 }
0199 glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
0200 slin.Append(glig);
0201 }
0202 }
0203 break;
0204 //
0205 case IntAna_Circle: {
0206 gp_Circ cirsol;
0207 gp_Pnt ptref;
0208 gp_Vec Tgt;
0209 //
0210 cirsol = inter.Circle(1);
0211 //modified by NIZNHY-PKV Thu Sep 15 11:30:03 2011f
0212 AdjustToSeam(Cy, cirsol);
0213 //modified by NIZNHY-PKV Thu Sep 15 11:30:15 2011t
0214 ElCLib::D1(0.,cirsol,ptref,Tgt);
0215
0216 if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
0217 trans1 = IntSurf_Out;
0218 trans2 = IntSurf_In;
0219 }
0220 else {
0221 trans1 = IntSurf_In;
0222 trans2 = IntSurf_Out;
0223 }
0224 Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
0225 slin.Append(glig);
0226 }
0227 break;
0228 //
0229 case IntAna_Ellipse: {
0230 gp_Elips elipsol = inter.Ellipse(1);
0231 gp_Pnt ptref;
0232 gp_Vec Tgt;
0233 ElCLib::D1(0.,elipsol,ptref,Tgt);
0234
0235 if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) > 0.0) {
0236 trans1 = IntSurf_Out;
0237 trans2 = IntSurf_In;
0238 }
0239 else {
0240 trans1 = IntSurf_In;
0241 trans2 = IntSurf_Out;
0242 }
0243 Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
0244 slin.Append(glig);
0245 }
0246 break;
0247 //
0248 default: {
0249 return Standard_False; // on ne doit pas passer ici
0250 }
0251 }
0252 return Standard_True;
0253 }
0254 //=======================================================================
0255 //function : IntPSp
0256 //purpose :
0257 // Traitement du cas Plan/Sphere et reciproquement
0258 //=======================================================================
0259 Standard_Boolean IntPSp (const IntSurf_Quadric& Quad1,
0260 const IntSurf_Quadric& Quad2,
0261 //modified by NIZNHY-PKV Tue Sep 20 08:59:36 2011f
0262 const Standard_Real Tolang,
0263 //modified by NIZNHY-PKV Tue Sep 20 08:59:39 2011t
0264 const Standard_Real TolTang,
0265 const Standard_Boolean Reversed,
0266 Standard_Boolean& Empty,
0267 IntPatch_SequenceOfLine& slin,
0268 IntPatch_SequenceOfPoint& spnt)
0269
0270
0271 {
0272 gp_Circ cirsol;
0273 gp_Pln Pl;
0274 gp_Sphere Sp;
0275 IntSurf_TypeTrans trans1,trans2;
0276 IntAna_ResultType typint;
0277
0278 IntAna_QuadQuadGeo inter;
0279 if (!Reversed) {
0280 Pl = Quad1.Plane();
0281 Sp = Quad2.Sphere();
0282 }
0283 else {
0284 Pl = Quad2.Plane();
0285 Sp = Quad1.Sphere();
0286 }
0287 inter.Perform(Pl,Sp);
0288
0289 if (!inter.IsDone()) {return Standard_False;}
0290
0291 typint = inter.TypeInter();
0292 Empty = Standard_False;
0293
0294 switch (typint) {
0295 case IntAna_Empty : {
0296 Empty = Standard_True;
0297 }
0298 break;
0299 //
0300 case IntAna_Point: {
0301 gp_Pnt psol = inter.Point(1);
0302 Standard_Real U1,V1,U2,V2;
0303 Quad1.Parameters(psol,U1,V1);
0304 Quad2.Parameters(psol,U2,V2);
0305 IntPatch_Point ptsol;
0306 ptsol.SetValue(psol,TolTang,Standard_True);
0307 ptsol.SetParameters(U1,V1,U2,V2);
0308 spnt.Append(ptsol);
0309 }
0310 break;
0311 //
0312 case IntAna_Circle: {
0313 cirsol = inter.Circle(1);
0314 //modified by NIZNHY-PKV Thu Sep 15 11:30:03 2011f
0315 AdjustToSeam(Sp, cirsol, Tolang);
0316 //modified by NIZNHY-PKV Thu Sep 15 11:30:15 2011t
0317 gp_Pnt ptref;
0318 gp_Vec Tgt;
0319 ElCLib::D1(0.,cirsol,ptref,Tgt);
0320
0321 if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
0322 trans1 = IntSurf_Out;
0323 trans2 = IntSurf_In;
0324 }
0325 else {
0326 trans1 = IntSurf_In;
0327 trans2 = IntSurf_Out;
0328 }
0329 Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
0330 slin.Append(glig);
0331 }
0332 break;
0333
0334 default: {
0335 return Standard_False; // on ne doit pas passer ici
0336 }
0337 }
0338 return Standard_True;
0339 }
0340 //=======================================================================
0341 //function : IntPCo
0342 //purpose :
0343 // Traitement du cas Plan/Cone et reciproquement
0344 //=======================================================================
0345 Standard_Boolean IntPCo (const IntSurf_Quadric& Quad1,
0346 const IntSurf_Quadric& Quad2,
0347 const Standard_Real Tolang,
0348 const Standard_Real TolTang,
0349 const Standard_Boolean Reversed,
0350 Standard_Boolean& Empty,
0351 Standard_Boolean& Multpoint,
0352 IntPatch_SequenceOfLine& slin,
0353 IntPatch_SequenceOfPoint& spnt)
0354
0355
0356 {
0357 gp_Pnt apex;
0358
0359 gp_Pln Pl;
0360 gp_Cone Co;
0361
0362 IntSurf_TypeTrans trans1,trans2;
0363 IntAna_ResultType typint;
0364
0365 IntAna_QuadQuadGeo inter;
0366 if (!Reversed) {
0367 Pl = Quad1.Plane();
0368 Co = Quad2.Cone();
0369 apex = Co.Apex();
0370 }
0371 else {
0372 Pl = Quad2.Plane();
0373 Co = Quad1.Cone();
0374 apex = Co.Apex();
0375 }
0376
0377 inter.Perform(Pl,Co,Tolang,TolTang);
0378 if (!inter.IsDone()) {
0379 return Standard_False;
0380 }
0381 //
0382 typint = inter.TypeInter();
0383 Standard_Integer NbSol = inter.NbSolutions();
0384 Empty = Standard_False;
0385
0386 switch (typint) {
0387 case IntAna_Point: {
0388 gp_Pnt psol = inter.Point(1);
0389 Standard_Real U1,V1,U2,V2;
0390 Quad1.Parameters(psol,U1,V1);
0391 Quad2.Parameters(psol,U2,V2);
0392 IntPatch_Point ptsol;
0393 ptsol.SetValue(psol,TolTang,Standard_False);
0394 ptsol.SetParameters(U1,V1,U2,V2);
0395 spnt.Append(ptsol);
0396 }
0397 break;
0398
0399 case IntAna_Line: {
0400 gp_Lin linsol = inter.Line(1);
0401 if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
0402 linsol.SetDirection(linsol.Direction().Reversed());
0403 }
0404 Standard_Real para = ElCLib::Parameter(linsol, apex);
0405 gp_Pnt ptbid (ElCLib::Value(para+5.,linsol));
0406 Standard_Real U1,V1,U2,V2;
0407 Quad1.Parameters(apex,U1,V1);
0408 Quad2.Parameters(apex,U2,V2);
0409
0410 if (NbSol == 1) { // ligne de tangence
0411 IntPatch_Point ptsol;
0412 ptsol.SetValue(apex,TolTang,Standard_False);
0413 ptsol.SetParameters(U1,V1,U2,V2);
0414 ptsol.SetParameter(para);
0415 gp_Pnt ptbid2(apex.XYZ() + 5.*Co.Axis().Direction().XYZ());
0416 gp_Vec TestCurvature(ptbid,ptbid2);
0417 gp_Vec Normp,Normco;
0418 if (!Reversed) {
0419 Normp = Quad1.Normale(ptbid);
0420 Normco = Quad2.Normale(ptbid);
0421 }
0422 else {
0423 Normp = Quad2.Normale(ptbid);
0424 Normco = Quad1.Normale(ptbid);
0425 }
0426 IntSurf_Situation situco,situco_otherside;
0427 IntSurf_Situation situp,situp_otherside;
0428
0429 if (Normp.Dot(TestCurvature) > 0.) {
0430 situco = IntSurf_Outside;
0431 situco_otherside = IntSurf_Inside;
0432 if (Normp.Dot(Normco) > 0.) {
0433 situp = IntSurf_Inside;
0434 situp_otherside = IntSurf_Outside;
0435 }
0436 else {
0437 situp = IntSurf_Outside;
0438 situp_otherside = IntSurf_Inside;
0439 }
0440 }
0441 else {
0442 situco = IntSurf_Inside;
0443 situco_otherside = IntSurf_Outside;
0444 if (Normp.Dot(Normco) > 0.) {
0445 situp = IntSurf_Outside;
0446 situp_otherside = IntSurf_Inside;
0447 }
0448 else {
0449 situp = IntSurf_Inside;
0450 situp_otherside = IntSurf_Outside;
0451 }
0452 }
0453 //----------------------------------------------------------
0454 //-- Apex ---> Cone.Direction
0455 //--
0456 Handle(IntPatch_GLine) glig;
0457 if (!Reversed) {
0458 glig = new IntPatch_GLine(linsol, Standard_True, situp, situco);
0459 }
0460 else {
0461 glig = new IntPatch_GLine(linsol, Standard_True, situco, situp);
0462 }
0463 glig->AddVertex(ptsol);
0464 glig->SetFirstPoint(1);
0465 slin.Append(glig);
0466 //----------------------------------------------------------
0467 //-- -Cone.Direction <------- Apex
0468 //--
0469 linsol.SetDirection(linsol.Direction().Reversed());
0470 if (!Reversed) {
0471 glig = new IntPatch_GLine(linsol, Standard_True, situp_otherside, situco_otherside);
0472 }
0473 else {
0474 glig = new IntPatch_GLine(linsol, Standard_True, situco_otherside, situp_otherside);
0475 }
0476 glig->AddVertex(ptsol);
0477 glig->SetFirstPoint(1);
0478 slin.Append(glig);
0479 }
0480 else {
0481 // on a 2 droites. Il faut determiner les transitions
0482 // de chacune. On oriente chaque ligne dans le sens
0483 // de l axe du cone. Les transitions de chaque ligne seront
0484 // inverses l une de l autre => on ne fait le calcul que sur
0485 // la premiere.
0486 if (linsol.Direction().DotCross
0487 (Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
0488 trans1 = IntSurf_Out;
0489 trans2 = IntSurf_In;
0490 }
0491 else {
0492 trans1 = IntSurf_In;
0493 trans2 = IntSurf_Out;
0494 }
0495
0496 Multpoint = Standard_True;
0497 //------------------------------------------- Ligne 1 -------
0498 IntPatch_Point ptsol;
0499 ptsol.SetValue(apex,TolTang,Standard_False);
0500 ptsol.SetParameters(U1,V1,U2,V2);
0501 ptsol.SetParameter(para);
0502 ptsol.SetMultiple(Standard_True);
0503 Handle(IntPatch_GLine) glig;
0504 glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
0505 glig->AddVertex(ptsol);
0506 glig->SetFirstPoint(1);
0507 slin.Append(glig);
0508 //-----------------------------------------------------------
0509 //-- Other Side : Les transitions restent les memes
0510 //-- linsol -> -linsol et Quad1(2).N -> -Quad1(2).N
0511 //--
0512 linsol.SetDirection(linsol.Direction().Reversed());
0513 glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
0514 para = ElCLib::Parameter(linsol, apex);
0515 ptsol.SetParameter(para);
0516 glig->AddVertex(ptsol);
0517 glig->SetFirstPoint(1);
0518 slin.Append(glig);
0519
0520 //------------------------------------------- Ligne 2 -------
0521 linsol = inter.Line(2);
0522 if (linsol.Direction().Dot(Co.Axis().Direction()) <0.) {
0523 linsol.SetDirection(linsol.Direction().Reversed());
0524 }
0525 para = ElCLib::Parameter(linsol, apex);
0526 ptbid = ElCLib::Value(para+5.,linsol);
0527 if (linsol.Direction().DotCross
0528 (Quad2.Normale(ptbid),Quad1.Normale(ptbid)) >0.) {
0529 trans1 = IntSurf_Out;
0530 trans2 = IntSurf_In;
0531 }
0532 else {
0533 trans1 = IntSurf_In;
0534 trans2 = IntSurf_Out;
0535 }
0536 ptsol.SetParameter(para);
0537 glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
0538 para = ElCLib::Parameter(linsol, apex);
0539 ptsol.SetParameter(para);
0540 glig->AddVertex(ptsol);
0541 glig->SetFirstPoint(1);
0542 slin.Append(glig);
0543 //-----------------------------------------------------------
0544 //-- Other Side : Les transitions restent les memes
0545 //-- linsol -> -linsol et Quad1(2).N -> -Quad1(2).N
0546 //--
0547 linsol.SetDirection(linsol.Direction().Reversed());
0548 glig = new IntPatch_GLine(linsol, Standard_False,trans1,trans2);
0549 para = ElCLib::Parameter(linsol, apex);
0550 ptsol.SetParameter(para);
0551 glig->AddVertex(ptsol);
0552 glig->SetFirstPoint(1);
0553 slin.Append(glig);
0554 }
0555 }
0556 break;
0557
0558 case IntAna_Circle: {
0559 gp_Circ cirsol = inter.Circle(1);
0560 //modified by NIZNHY-PKV Thu Sep 15 11:34:04 2011f
0561 AdjustToSeam(Co, cirsol);
0562 //modified by NIZNHY-PKV Thu Sep 15 11:36:08 2011t
0563 gp_Pnt ptref;
0564 gp_Vec Tgt;
0565 ElCLib::D1(0.,cirsol,ptref,Tgt);
0566
0567 if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
0568 trans1 = IntSurf_Out;
0569 trans2 = IntSurf_In;
0570 }
0571 else {
0572 trans1 = IntSurf_In;
0573 trans2 = IntSurf_Out;
0574 }
0575 Handle(IntPatch_GLine) glig = new IntPatch_GLine(cirsol,Standard_False,trans1,trans2);
0576 slin.Append(glig);
0577 }
0578 break;
0579
0580 case IntAna_Ellipse: {
0581 gp_Elips elipsol = inter.Ellipse(1);
0582 gp_Pnt ptref;
0583 gp_Vec Tgt;
0584 ElCLib::D1(0.,elipsol,ptref,Tgt);
0585
0586 if (Tgt.DotCross(Quad2.Normale(ptref),Quad1.Normale(ptref)) >0.) {
0587 trans1 = IntSurf_Out;
0588 trans2 = IntSurf_In;
0589 }
0590 else {
0591 trans1 = IntSurf_In;
0592 trans2 = IntSurf_Out;
0593 }
0594 Handle(IntPatch_GLine) glig = new IntPatch_GLine(elipsol,Standard_False,trans1,trans2);
0595 slin.Append(glig);
0596 }
0597 break;
0598
0599 case IntAna_Parabola: {
0600 gp_Parab parabsol = inter.Parabola(1);
0601
0602 gp_Vec Tgtorig(parabsol.YAxis().Direction());
0603 Standard_Real ptran = Tgtorig.DotCross(Quad2.Normale(parabsol.Location()),
0604 Quad1.Normale(parabsol.Location()));
0605 if (ptran >0.00000001) {
0606 trans1 = IntSurf_Out;
0607 trans2 = IntSurf_In;
0608 }
0609 else if (ptran <-0.00000001) {
0610 trans1 = IntSurf_In;
0611 trans2 = IntSurf_Out;
0612 }
0613 else {
0614 trans1=trans2=IntSurf_Undecided;
0615 }
0616 Handle(IntPatch_GLine) glig = new IntPatch_GLine(parabsol,Standard_False,trans1,trans2);
0617 slin.Append(glig);
0618 }
0619 break;
0620
0621 case IntAna_Hyperbola: {
0622 gp_Pnt tophypr;
0623 gp_Vec Tgttop;
0624
0625 for(Standard_Integer i=1; i<=2; i++) {
0626 gp_Hypr hyprsol = inter.Hyperbola(i);
0627 tophypr = ElCLib::Value(hyprsol.MajorRadius(),
0628 hyprsol.XAxis());
0629 Tgttop = hyprsol.YAxis().Direction();
0630 Standard_Real qwe = Tgttop.DotCross(Quad2.Normale(tophypr),
0631 Quad1.Normale(tophypr));
0632
0633 if (qwe>0.00000001) {
0634 trans1 = IntSurf_Out;
0635 trans2 = IntSurf_In;
0636 }
0637 else if (qwe<-0.00000001){
0638 trans1 = IntSurf_In;
0639 trans2 = IntSurf_Out;
0640 }
0641 else {
0642 trans1=trans2=IntSurf_Undecided;
0643 }
0644 Handle(IntPatch_GLine) glig = new IntPatch_GLine(hyprsol,Standard_False,trans1,trans2);
0645 slin.Append(glig);
0646 }
0647 }
0648 break;
0649
0650 default: {
0651 return Standard_False;
0652 }
0653 }
0654 return Standard_True;
0655 }
0656 //=======================================================================
0657 //function : IntPTo
0658 //purpose :
0659 //=======================================================================
0660 Standard_Boolean IntPTo(const IntSurf_Quadric& theQuad1,
0661 const IntSurf_Quadric& theQuad2,
0662 const Standard_Real theTolTang,
0663 const Standard_Boolean bReversed,
0664 Standard_Boolean& bEmpty,
0665 IntPatch_SequenceOfLine& theSeqLin)
0666 {
0667 const gp_Pln aPln = bReversed ? theQuad2.Plane() : theQuad1.Plane();
0668 const gp_Torus aTorus = bReversed ? theQuad1.Torus() : theQuad2.Torus();
0669 //
0670 IntAna_QuadQuadGeo inter(aPln, aTorus, theTolTang);
0671 Standard_Boolean bRet = inter.IsDone();
0672 //
0673 if (!bRet) {
0674 return bRet;
0675 }
0676 //
0677 IntAna_ResultType typint = inter.TypeInter();
0678 Standard_Integer NbSol = inter.NbSolutions();
0679 bEmpty = Standard_False;
0680 //
0681 switch (typint) {
0682 case IntAna_Empty :
0683 bEmpty = Standard_True;
0684 break;
0685 //
0686 case IntAna_Circle : {
0687 Standard_Integer i;
0688 IntSurf_TypeTrans trans1, trans2;
0689 gp_Pnt ptref;
0690 gp_Vec Tgt;
0691 //
0692 for (i = 1; i <= NbSol; ++i) {
0693 gp_Circ aC = inter.Circle(i);
0694 if (!aPln.Axis().IsNormal(aTorus.Axis(), Precision::Angular())) {
0695 AdjustToSeam(aTorus, aC);
0696 }
0697 ElCLib::D1(0., aC, ptref, Tgt);
0698 //
0699 if (Tgt.DotCross(theQuad2.Normale(ptref),theQuad1.Normale(ptref)) > 0.0) {
0700 trans1 = IntSurf_Out;
0701 trans2 = IntSurf_In;
0702 }
0703 else {
0704 trans1 = IntSurf_In;
0705 trans2 = IntSurf_Out;
0706 }
0707 //
0708 Handle(IntPatch_GLine) glig =
0709 new IntPatch_GLine(aC, Standard_False, trans1, trans2);
0710 theSeqLin.Append(glig);
0711 }
0712 }
0713 break;
0714 //
0715 case IntAna_NoGeometricSolution:
0716 default:
0717 bRet = Standard_False;
0718 break;
0719 }
0720 //
0721 return bRet;
0722 }
0723 //
0724 //modified by NIZNHY-PKV Thu Sep 15 10:53:39 2011f
0725 //=======================================================================
0726 //function : AdjustToSeam
0727 //purpose :
0728 //=======================================================================
0729 void AdjustToSeam (const gp_Cone& aQuad,
0730 gp_Circ& aCirc)
0731 {
0732 gp_Ax2 aAx2;
0733 //
0734 const gp_Pnt& aPLoc=aCirc.Location();
0735 const gp_Ax3& aAx3=aQuad.Position();
0736 SeamPosition(aPLoc, aAx3, aAx2);
0737 aCirc.SetPosition(aAx2);
0738 }
0739 //=======================================================================
0740 //function : AdjustToSeam
0741 //purpose :
0742 //=======================================================================
0743 void AdjustToSeam (const gp_Sphere& aQuad,
0744 gp_Circ& aCirc,
0745 const Standard_Real aTolAng)
0746 {
0747 gp_Ax2 aAx2;
0748 //
0749 const gp_Ax1& aAx1C=aCirc.Axis();
0750 const gp_Ax3& aAx3=aQuad.Position();
0751 const gp_Ax1& aAx1Q=aAx3.Axis();
0752 //
0753 const gp_Dir& aDirC=aAx1C.Direction();
0754 const gp_Dir& aDirQ=aAx1Q.Direction();
0755 if (aDirC.IsParallel(aDirQ, aTolAng)) {
0756 const gp_Pnt& aPLoc=aCirc.Location();
0757 SeamPosition(aPLoc, aAx3, aAx2);
0758 aCirc.SetPosition(aAx2);
0759 }
0760 }
0761 //=======================================================================
0762 //function : AdjustToSeam
0763 //purpose :
0764 //=======================================================================
0765 void AdjustToSeam (const gp_Cylinder& aQuad,
0766 gp_Circ& aCirc)
0767 {
0768 gp_Ax2 aAx2;
0769 //
0770 const gp_Pnt& aPLoc=aCirc.Location();
0771 const gp_Ax3& aAx3=aQuad.Position();
0772 SeamPosition(aPLoc, aAx3, aAx2);
0773 aCirc.SetPosition(aAx2);
0774 }
0775 //=======================================================================
0776 //function : AdjustToSeam
0777 //purpose :
0778 //=======================================================================
0779 void AdjustToSeam (const gp_Torus& aQuad,
0780 gp_Circ& aCirc)
0781 {
0782 gp_Ax2 aAx2;
0783 //
0784 const gp_Pnt& aPLoc=aCirc.Location();
0785 const gp_Ax3& aAx3=aQuad.Position();
0786 SeamPosition(aPLoc, aAx3, aAx2);
0787 aCirc.SetPosition(aAx2);
0788 }
0789 //=======================================================================
0790 //function : SeamPosition
0791 //purpose :
0792 //=======================================================================
0793 void SeamPosition(const gp_Pnt& aPLoc,
0794 const gp_Ax3& aPos,
0795 gp_Ax2& aSeamPos)
0796 {
0797 const gp_Dir& aDZ=aPos.Direction();
0798 const gp_Dir& aDX=aPos.XDirection();
0799 gp_Ax2 aAx2(aPLoc, aDZ, aDX);
0800 aSeamPos=aAx2;
0801 }
0802
0803 //modified by NIZNHY-PKV Thu Sep 15 10:53:41 2011t