ebabe23e22653639e7d33685e8b2c4f6b804ca59
[occt.git] / src / IntPolyh / IntPolyh_StartPoint.cxx
1 // Created on: 1999-04-06
2 // Created by: Fabrice SERVANT
3 // Copyright (c) 1999-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 <IntPolyh_StartPoint.hxx>
19 #include <IntPolyh_Triangle.hxx>
20
21 #include <stdio.h>
22 //#include <Precision.hxx>
23 #define MyConfusionPrecision 10.0e-12
24
25 IntPolyh_StartPoint::IntPolyh_StartPoint() : x(0),y(0),z(0),u1(0),v1(0),u2(0),v2(0),
26 lambda1(-1.0),lambda2(-1.0),angle(-2.0),t1(-1),e1(-2),t2(-1),e2(-2),
27 chainlist(-1) {
28 }
29
30 IntPolyh_StartPoint::IntPolyh_StartPoint(const Standard_Real _x,
31                                          const Standard_Real _y,
32                                          const Standard_Real _z,
33                                          const Standard_Real _u1,
34                                          const Standard_Real _v1,
35                                          const Standard_Real _u2,
36                                          const Standard_Real _v2,
37                                          const Standard_Integer _t1,
38                                          const Standard_Integer _e1,
39                                          const Standard_Real _lambda1,
40                                          const Standard_Integer _t2,
41                                          const Standard_Integer _e2,
42                                          const Standard_Real _lambda2,
43                                          const Standard_Integer _chainlist):angle(-2.0) { 
44   x=_x; y=_y; z=_z; 
45   u1=_u1; v1=_v1; 
46   u2=_u2; v2=_v2; 
47   t1=_t1; e1=_e1; lambda1=_lambda1; 
48   t2=_t2; e2=_e2; lambda2=_lambda2; 
49   chainlist=_chainlist;
50 }
51
52 Standard_Real IntPolyh_StartPoint::X() const { return(x); } 
53 Standard_Real IntPolyh_StartPoint::Y() const { return(y); }  
54 Standard_Real IntPolyh_StartPoint::Z() const { return(z); } 
55 Standard_Real IntPolyh_StartPoint::U1() const { return(u1); } 
56 Standard_Real IntPolyh_StartPoint::V1() const { return(v1); }
57 Standard_Real IntPolyh_StartPoint::U2() const { return(u2); } 
58 Standard_Real IntPolyh_StartPoint::V2() const { return(v2); }
59 Standard_Integer IntPolyh_StartPoint::T1() const { return(t1); }
60 Standard_Integer IntPolyh_StartPoint::E1() const { return(e1); }
61 Standard_Real IntPolyh_StartPoint::Lambda1() const { return(lambda1); }
62 Standard_Integer IntPolyh_StartPoint::T2() const { return(t2); }
63 Standard_Integer IntPolyh_StartPoint::E2() const { return(e2); }
64 Standard_Real IntPolyh_StartPoint::Lambda2() const { return(lambda2); }
65 Standard_Integer IntPolyh_StartPoint::ChainList() const { return(chainlist); }
66 Standard_Real IntPolyh_StartPoint::GetAngle() const { return(angle); }
67
68 Standard_Integer IntPolyh_StartPoint::GetEdgePoints(const IntPolyh_Triangle &Triangle,
69                                                     Standard_Integer &FirstEdgePoint, 
70                                                     Standard_Integer &SecondEdgePoint,
71                                                     Standard_Integer &LastPoint) const {
72  Standard_Integer SurfID;
73  if(e1!=-1) {
74    if(e1==1)      { FirstEdgePoint = Triangle.FirstPoint();  SecondEdgePoint = Triangle.SecondPoint(); 
75                     LastPoint = Triangle.ThirdPoint();  }
76    else if(e1==2) { FirstEdgePoint = Triangle.SecondPoint(); SecondEdgePoint = Triangle.ThirdPoint();  
77                     LastPoint = Triangle.FirstPoint();  }
78    else if(e1==3) { FirstEdgePoint = Triangle.ThirdPoint();  SecondEdgePoint = Triangle.FirstPoint();
79                     LastPoint = Triangle.SecondPoint();}
80    SurfID=1;
81  }
82  else if(e2!=-1) {
83    if(e2==1)      { FirstEdgePoint = Triangle.FirstPoint();  SecondEdgePoint = Triangle.SecondPoint();
84                     LastPoint = Triangle.ThirdPoint();}
85    else if(e2==2) { FirstEdgePoint = Triangle.SecondPoint(); SecondEdgePoint = Triangle.ThirdPoint();
86                     LastPoint = Triangle.FirstPoint();}
87    else if(e2==3) { FirstEdgePoint = Triangle.ThirdPoint();  SecondEdgePoint = Triangle.FirstPoint();
88                     LastPoint = Triangle.SecondPoint();}
89    SurfID=2;
90  }
91  else SurfID=0;
92  return(SurfID) ;
93 }
94
95 void IntPolyh_StartPoint::Equal(const IntPolyh_StartPoint &StPt) {
96   x         = StPt.x;
97   y         = StPt.y;
98   z         = StPt.z;
99   u1        = StPt.u1;
100   v1        = StPt.v1;
101   u2        = StPt.u2;
102   v2        = StPt.v2;
103   t1        = StPt.t1;
104   e1        = StPt.e1;
105   lambda1   = StPt.lambda1;
106   t2        = StPt.t2;
107   e2        = StPt.e2;
108   lambda2   = StPt.lambda2;
109   angle     = StPt.angle;
110   chainlist = StPt.chainlist;
111 }
112
113 void IntPolyh_StartPoint::SetXYZ(const Standard_Real XX,
114                                  const Standard_Real YY,
115                                  const Standard_Real ZZ) {
116   x=XX; y=YY; z=ZZ;
117 }
118
119 void IntPolyh_StartPoint::SetUV1(const Standard_Real UU1,
120                                  const Standard_Real VV1) {
121   u1=UU1; v1=VV1;
122 }
123
124 void IntPolyh_StartPoint::SetUV2(const Standard_Real UU2,
125                                  const Standard_Real VV2) {
126   u2=UU2; v2=VV2;
127 }
128
129 void IntPolyh_StartPoint::SetEdge1(const Standard_Integer IE1) {
130   e1=IE1;
131 }
132
133 void IntPolyh_StartPoint::SetLambda1(const Standard_Real LAM1) {
134   lambda1=LAM1;
135 }
136
137 void IntPolyh_StartPoint::SetEdge2(const Standard_Integer IE2) {
138   e2=IE2;
139 }
140
141 void IntPolyh_StartPoint::SetLambda2(const Standard_Real LAM2) {
142   lambda2=LAM2;
143 }
144
145 void IntPolyh_StartPoint::SetCoupleValue(const Standard_Integer IT1,
146                                           const Standard_Integer IT2) {
147   t1=IT1;
148   t2=IT2;
149 }
150
151 void IntPolyh_StartPoint::SetAngle(const Standard_Real Ang) {
152   angle=Ang;
153 }
154
155 void IntPolyh_StartPoint::SetChainList(const Standard_Integer ChList) {
156   chainlist=ChList;
157 }
158
159 Standard_Integer IntPolyh_StartPoint::CheckSameSP(const IntPolyh_StartPoint & SP) const {
160 ///Renvoit 1 si monSP==SP
161   Standard_Integer Test=0;
162   if( ( (e1>=-1)&&(e1==SP.e1))||((e2>=-1)&&(e2==SP.e2)) ) {
163     ///Les edges sont definis
164
165       if( ( (lambda1>-MyConfusionPrecision)&&(Abs(lambda1-SP.lambda1)<MyConfusionPrecision) ) //lambda1!=-1 && lambda1==SP.lambda2
166         ||( (lambda2>-MyConfusionPrecision)&&(Abs(lambda2-SP.lambda2)<MyConfusionPrecision) ) )
167         Test=1;
168       //if( (Abs(u1-SP.u1)<MyConfusionPrecision)&&(Abs(v1-SP.v1)<MyConfusionPrecision) )
169         //Test=1;
170
171     }
172   if( (Test==0) && ((e1==-1)||(e2==-1)) ) {
173     ///monSP est un sommet
174       if( (Abs(SP.u1-u1)<MyConfusionPrecision)&&(Abs(SP.v1-v1)<MyConfusionPrecision) )
175         Test=1;
176     }
177   else if( (e1==-2)&&(e2==-2) ) {
178     Dump(00200);
179     SP.Dump(00201);
180     printf("e1==-2 & e2==-2 Can't Check\n");
181   }
182   /*  if( (Abs(u1-SP.u1)<MyConfusionPrecision)&&(Abs(v1-SP.v1)<MyConfusionPrecision) )
183       Test=1;*/
184   return(Test);
185 }
186
187 void IntPolyh_StartPoint::Dump() const{ 
188   printf("\nPoint : x=%+8.3eg y=%+8.3eg z=%+8.3eg u1=%+8.3eg v1=%+8.3eg u2=%+8.3eg v2=%+8.3eg\n",
189          x,y,z,u1,v1,u2,v2);
190   printf("Triangle S1:%d Edge S1:%d Lambda1:%f Triangle S2:%d Edge S2:%d Lambda2:%f\n",t1,e1,lambda1,t2,e2,lambda2);
191   printf("Angle: %f List Number: %d\n",angle,chainlist);
192 }
193
194 void IntPolyh_StartPoint::Dump(const Standard_Integer i) const{
195   printf("\nPoint(%d) : x=%+8.3eg y=%+8.3eg z=%+8.3eg u1=%+8.3eg v1=%+8.3eg u2=%+8.3eg v2=%+8.3eg\n",
196          i,x,y,z,u1,v1,u2,v2);
197   printf("Triangle S1:%d Edge S1:%d Lambda1:%f Triangle S2:%d Edge S2:%d Lambda2:%f\n",t1,e1,lambda1,t2,e2,lambda2);
198   printf("Angle: %f List Number: %d\n",angle,chainlist);
199 }
200
201