0031642: Visualization - crash in Graphic3d_Structure::SetVisual() on redisplaying...
[occt.git] / src / IntPatch / IntPatch_Point.cxx
1 // Created on: 1992-05-06
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17
18 #include <Adaptor2d_HCurve2d.hxx>
19 #include <Adaptor3d_HVertex.hxx>
20 #include <gp_Pnt.hxx>
21 #include <IntPatch_Point.hxx>
22 #include <IntSurf_PntOn2S.hxx>
23 #include <IntSurf_Transition.hxx>
24 #include <Standard_DomainError.hxx>
25
26 #include <stdio.h>
27 void IntPatch_Point::SetValue (const gp_Pnt& Pt,
28                                const Standard_Real Tol,
29                                const Standard_Boolean Tangent)
30 {
31   onS1    = Standard_False;
32   onS2    = Standard_False;
33   vtxonS1 = Standard_False;
34   vtxonS2 = Standard_False;
35   mult    = Standard_False;
36   tgt     = Tangent;
37   pt.SetValue(Pt);
38   tol = Tol;
39 }
40
41 void IntPatch_Point::SetVertex(const Standard_Boolean OnFirst, const Handle(Adaptor3d_HVertex)& V)
42 {
43   if (OnFirst) {
44     onS1    = Standard_True;
45     vtxonS1 = Standard_True;
46     vS1     = V;
47   }
48   else {
49     onS2    = Standard_True;
50     vtxonS2 = Standard_True;
51     vS2   = V;
52   }
53 }
54
55 void IntPatch_Point::SetArc (const Standard_Boolean OnFirst,
56                              const Handle(Adaptor2d_HCurve2d)& A,
57                              const Standard_Real Param,
58                              const IntSurf_Transition& TLine,
59                              const IntSurf_Transition& TArc)
60 {
61   if (OnFirst) {
62     onS1     = Standard_True;
63     arcS1    = A;
64     traline1 = TLine;
65     tra1     = TArc;
66     prm1     = Param;
67   }
68   else {
69     onS2     = Standard_True;
70     arcS2    = A;
71     traline2 = TLine;
72     tra2     = TArc;
73     prm2     = Param;
74   }
75 }
76
77 void IntPatch_Point::ReverseTransition()
78
79   if(onS1)
80   {
81     IntSurf_Transition TLine;
82     switch (traline1.TransitionType())
83     {
84     case IntSurf_In: TLine.SetValue(Standard_False,IntSurf_Out); break;
85     case IntSurf_Out: TLine.SetValue(Standard_False,IntSurf_In); break;
86     default:
87       break;
88     }
89     traline1=TLine;
90     IntSurf_Transition TArc;
91     switch (tra1.TransitionType())
92     {
93     case IntSurf_In: TArc.SetValue(Standard_False,IntSurf_Out); break;
94     case IntSurf_Out: TArc.SetValue(Standard_False,IntSurf_In); break;
95     default:
96       break;
97     }
98     tra1=TArc;
99   }
100   if(onS2)
101   {
102     IntSurf_Transition TLine;
103     switch (traline2.TransitionType())
104     {
105     case IntSurf_In: TLine.SetValue(Standard_False,IntSurf_Out); break;
106     case IntSurf_Out: TLine.SetValue(Standard_False,IntSurf_In); break;
107     default:
108       break;
109     }
110     traline2=TLine;
111     IntSurf_Transition TArc;
112     switch (tra2.TransitionType())
113     {
114     case IntSurf_In: TArc.SetValue(Standard_False,IntSurf_Out); break;
115     case IntSurf_Out: TArc.SetValue(Standard_False,IntSurf_In); break;
116     default:
117       break;
118     }
119     tra2=TArc;
120   }  
121 }
122
123
124 #include <IntSurf_Situation.hxx>
125 #include <IntSurf_Transition.hxx>
126 #include <IntSurf_TypeTrans.hxx>
127
128 static void DumpTransition(const IntSurf_Transition& T)
129 {
130   IntSurf_TypeTrans typetrans = T.TransitionType(); 
131   if(typetrans == IntSurf_In)             std::cout<<" In  ";
132   else if(typetrans == IntSurf_Out)       std::cout<<" Out ";
133   else if(typetrans == IntSurf_Undecided) std::cout<<" Und.";
134   else if(typetrans == IntSurf_Touch) { 
135     std::cout<<" Touch ";
136     if(T.Situation() == IntSurf_Inside)       std::cout<<" Inside ";
137     else if(T.Situation() == IntSurf_Outside) std::cout<<" Outside";
138     else                                      std::cout<<" Unknown";
139     if(T.IsOpposite()) std::cout<<"     Opposite "; 
140     else               std::cout<<" Non_Opposite ";
141   }
142
143   if(typetrans != IntSurf_Undecided) { 
144     if(T.IsTangent()) std::cout<<" Tangent    ";
145     else              std::cout<<" Non_Tangent";
146   }
147 }
148     
149 #include <Standard_Transient.hxx>
150
151 void IntPatch_Point::Dump() const { 
152   std::cout<<"----------- IntPatch_Point : "<<std::endl;
153   Standard_Real u1,v1,u2,v2;
154   pt.Parameters(u1,v1,u2,v2);
155
156   printf("P(%+10.20f,%+10.20f,%+10.20f) UV1(%+10.20f,%+10.20f)  UV2(%+10.20f,%+10.20f) (Para:%+10.20f)\n",
157          (double)(pt.Value().X()),
158          (double)(pt.Value().Y()),
159          (double)(pt.Value().Z()),
160          (double)u1,(double)v1,(double)u2,(double)v2,(double)para);
161   if(onS1)
162     printf("*OnS1*  par=%+10.20f arc1=%10p", (double)prm1, (void*)arcS1.operator->());
163   if(vtxonS1)
164     printf(" *Vtx1*  vtx1=%10p", (void*)vS1.operator->());
165   if(onS1 || vtxonS1) printf("\n");
166   if(onS2)
167     printf("*OnS2*  par=%+10.20f arc2=%10p", (double)prm2, (void*)arcS2.operator->());
168   if(vtxonS2)
169     printf(" *Vtx2*  vtx2=%10p", (void*)vS2.operator->());
170
171   if(onS2 || vtxonS2)
172     printf("\n");
173   fflush(stdout);
174
175   if(onS1 || onS2) { 
176     std::cout<<" tgt:"<<((tgt)? 1 : 0) <<"   mult:"<<((mult)? 1 :0);
177     if(onS1) { 
178       std::cout<<"\n-traline1  : ";   DumpTransition(traline1);
179       std::cout<<"  -tra1  : ";       DumpTransition(tra1);
180     }
181     if(onS2) { 
182       std::cout<<"\n-traline2  : ";   DumpTransition(traline2);
183       std::cout<<"  -tra2  : ";      DumpTransition(tra2);
184     }
185     std::cout<<std::endl;
186   }
187   std::cout << "\nToler = " << Tolerance();
188   std::cout << std::endl;
189 }