0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[occt.git] / src / IntSurf / IntSurf.cxx
1 // Copyright (c) 1995-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
3 //
4 // This file is part of Open CASCADE Technology software library.
5 //
6 // This library is free software; you can redistribute it and/or modify it under
7 // the terms of the GNU Lesser General Public License version 2.1 as published
8 // by the Free Software Foundation, with special exception defined in the file
9 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
10 // distribution for complete text of the license and disclaimer of any warranty.
11 //
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
14
15 #include <IntSurf.hxx>
16
17 #include <Adaptor3d_HSurface.hxx>
18 #include <IntSurf_Transition.hxx>
19 #include <Precision.hxx>
20 #include <gp_Vec.hxx>
21
22 //--------------------------------------------------------------
23 //-- IntSurf::MakeTransition(Vtgint,Vtgrst,Normale,Transline,Transarc);
24 //-- 
25 //-- tgFirst   = Tangente Ligne Intersection
26 //-- tgSecond  = Tangenet Restriction
27 //-- Normale   = Normale a la surface
28 void IntSurf::MakeTransition (const gp_Vec& TgFirst,
29                               const gp_Vec& TgSecond,
30                               const gp_Dir& Normale,
31                               IntSurf_Transition& TFirst,
32                               IntSurf_Transition& TSecond)
33
34 {
35   
36       
37   // Effectuer le produit mixte normale, tangente 1, tangente 2
38   // pour avoir le type de la transition.
39       
40   gp_Vec pvect(TgSecond.Crossed(TgFirst));
41       
42   Standard_Real NTgSecond = TgSecond.Magnitude();
43   Standard_Real NTgFirst  = TgFirst.Magnitude();
44   Standard_Real NTgSecondNTgFirstAngular = NTgSecond*NTgFirst*Precision::Angular();
45
46   if(NTgFirst <= Precision::Confusion()) { 
47     TFirst.SetValue(Standard_True,IntSurf_Undecided);
48     TSecond.SetValue(Standard_True,IntSurf_Undecided);
49   }
50   else if (   (NTgSecond <= Precision::Confusion()) 
51            || (pvect.Magnitude()<= NTgSecondNTgFirstAngular)) {
52     TFirst.SetValue(Standard_True,IntSurf_Unknown,TgFirst.Dot(TgSecond)<0.0);
53     TSecond.SetValue(Standard_True,IntSurf_Unknown,TgFirst.Dot(TgSecond)<0.0);
54   }
55   else { 
56     Standard_Real yu = pvect.Dot(Normale);
57     yu/=NTgSecond*NTgFirst;
58     if (yu>0.0001) {
59       TFirst.SetValue(Standard_False,IntSurf_In);
60       TSecond.SetValue(Standard_False,IntSurf_Out);
61     }
62     else if(yu<-0.0001) {
63       TFirst.SetValue(Standard_False,IntSurf_Out);
64       TSecond.SetValue(Standard_False,IntSurf_In);
65     }
66     else {
67 #if 0 
68       //-- MODIF XAB
69       gp_Vec V1(TgSecond.X() / NTgSecond,TgSecond.Y() / NTgSecond, TgSecond.Z() / NTgSecond);
70       gp_Vec V2(TgFirst.X() / NTgFirst,TgFirst.Y() / NTgFirst, TgFirst.Z() / NTgFirst);
71       
72       pvect = V1.Crossed(V2);
73       yu = pvect.Dot(Normale);
74
75       if (yu>0.0000001) {
76         TFirst.SetValue(Standard_False,IntSurf_In);
77         TSecond.SetValue(Standard_False,IntSurf_Out);
78       }
79       else if(yu<-0.0000001) {
80         TFirst.SetValue(Standard_False,IntSurf_Out);
81         TSecond.SetValue(Standard_False,IntSurf_In);
82       }
83       else { 
84         TFirst.SetValue(Standard_True,IntSurf_Undecided);
85         TSecond.SetValue(Standard_True,IntSurf_Undecided);
86       }
87       
88 #else 
89       TFirst.SetValue(Standard_True,IntSurf_Undecided);
90       TSecond.SetValue(Standard_True,IntSurf_Undecided);
91       
92 #endif
93       
94
95
96     }
97   }
98 }
99
100 //=======================================================================
101 //function : SetPeriod
102 //purpose  : 
103 //=======================================================================
104 void IntSurf::SetPeriod(const Handle(Adaptor3d_HSurface)& theFirstSurf,
105                         const Handle(Adaptor3d_HSurface)& theSecondSurf,
106                         Standard_Real theArrOfPeriod[4])
107 {
108   theArrOfPeriod[0] = theFirstSurf->IsUPeriodic()? theFirstSurf->UPeriod() : 0.0;
109   theArrOfPeriod[1] = theFirstSurf->IsVPeriodic()? theFirstSurf->VPeriod() : 0.0;
110   theArrOfPeriod[2] = theSecondSurf->IsUPeriodic()? theSecondSurf->UPeriod() : 0.0;
111   theArrOfPeriod[3] = theSecondSurf->IsVPeriodic()? theSecondSurf->VPeriod() : 0.0;
112 }
113
114