Test for 0022778: Bug in BRepMesh
[occt.git] / src / GeomPlate / GeomPlate_PointConstraint.cxx
1 // Created on: 1997-05-05
2 // Created by: Jerome LEMONIER
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
5 //
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
10 //
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
13 //
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
20
21
22
23 #include <GeomPlate_PointConstraint.ixx>
24 #include <GeomAPI_ProjectPointOnSurf.hxx>
25 #include <gp_Ax3.hxx>
26 #include <GeomAPI_ProjectPointOnSurf.hxx>
27 #include <gp_Trsf.hxx>
28 #include <Geom_Plane.hxx>
29 #include <Extrema_POnSurf.hxx>
30 #include <Extrema_ExtPS.hxx>
31 #include <GeomAdaptor_Surface.hxx>
32
33 //---------------------------------------------------------
34 //         Constructeurs avec un point 
35 //---------------------------------------------------------
36 GeomPlate_PointConstraint::GeomPlate_PointConstraint(const gp_Pnt& Pt, 
37                                              const Standard_Integer Order, 
38                                              const Standard_Real TolDist)
39 :
40 myOrder(Order),
41 myLProp(2,TolDist),
42 myPoint(Pt),
43 myTolDist(TolDist),
44 hasPnt2dOnSurf(Standard_False)
45 { if ((myOrder>1)||(myOrder<-1))
46     Standard_Failure::Raise("GeomPlate_PointConstraint : the constraint must 0 or -1 with a point"); 
47 }
48
49 //---------------------------------------------------------
50 //         Constructeurs avec un point sur surface
51 //---------------------------------------------------------
52 GeomPlate_PointConstraint::GeomPlate_PointConstraint
53 (const Standard_Real U,
54  const Standard_Real V,
55  const Handle(Geom_Surface)& Surf,
56  const Standard_Integer Order,
57  const Standard_Real TolDist,
58  const Standard_Real TolAng,
59  const Standard_Real TolCurv)
60 :myOrder(Order),
61  myLProp(2,TolDist),
62  mySurf(Surf),
63  myU(U),
64  myV(V),
65  myTolDist(TolDist),
66  myTolAng(TolAng),
67  myTolCurv(TolCurv),
68  hasPnt2dOnSurf(Standard_False)
69
70
71   Surf->D2(myU,myV,myPoint,myD11,myD12,myD21,myD22,myD23);
72   myLProp.SetSurface(Surf);
73 }
74
75 //---------------------------------------------------------
76 // Fonction : D0
77 //---------------------------------------------------------
78 void GeomPlate_PointConstraint::D0(gp_Pnt& P) const
79 { P=myPoint;
80 }
81
82 //---------------------------------------------------------
83 // Fonction : D1
84 //---------------------------------------------------------
85 void GeomPlate_PointConstraint::D1(gp_Pnt& P,gp_Vec& V1,gp_Vec& V2) const
86 { P=myPoint;
87   V1=myD11;
88   V2=myD12;
89 }
90
91 //---------------------------------------------------------
92 // Fonction : D2
93 //---------------------------------------------------------
94 void GeomPlate_PointConstraint::D2(gp_Pnt& P,gp_Vec& V1,gp_Vec& V2,gp_Vec& V3,gp_Vec& V4,gp_Vec& V5) const
95 { P=myPoint;
96   V1=myD11;
97   V2=myD12;
98   V3=myD21;
99   V4=myD22;
100   V5=myD23;
101 }
102
103 //---------------------------------------------------------
104 // Fonction : SetG0Criterion
105 //---------------------------------------------------------
106 void GeomPlate_PointConstraint :: SetG0Criterion( const Standard_Real TolDist )
107 {
108   myTolDist = TolDist;
109 }
110 //---------------------------------------------------------
111 // Fonction : SetG1Criterion
112 //---------------------------------------------------------
113 void GeomPlate_PointConstraint :: SetG1Criterion( const Standard_Real TolAng )
114 {
115   myTolAng = TolAng;
116 }
117 //---------------------------------------------------------
118 // Fonction : SetG2Criterion
119 //---------------------------------------------------------
120 void GeomPlate_PointConstraint :: SetG2Criterion( const Standard_Real TolCurv )
121 {
122   myTolCurv = TolCurv;
123 }
124
125 //---------------------------------------------------------
126 // Fonction : G0Criterion
127 //---------------------------------------------------------
128 Standard_Real GeomPlate_PointConstraint::G0Criterion() const
129 { return myTolDist;
130 }
131
132 //---------------------------------------------------------
133 // Fonction : G1Criterion 
134 //---------------------------------------------------------
135 Standard_Real GeomPlate_PointConstraint::G1Criterion() const
136 { return myTolAng;
137 }
138
139 //---------------------------------------------------------
140 // Fonction : G2Criterion 
141 //---------------------------------------------------------
142 Standard_Real GeomPlate_PointConstraint::G2Criterion() const
143 { return myTolCurv;
144 }
145
146 //---------------------------------------------------------
147 // Fonction : Surface 
148 //---------------------------------------------------------
149 //Handle(Geom_Surface) GeomPlate_PointConstraint::Surface() const
150 //{  Standard_Failure::Raise("GeomPlate_PointConstraint.cxx : The surface does not exist"); 
151 //}
152 //------------------------------------------------------------
153 //Fonction : LPropSurf
154 //------------------------------------------------------------
155 GeomLProp_SLProps &GeomPlate_PointConstraint::LPropSurf()
156 { // if (myFrontiere.IsNull())
157   //  Standard_Failure::Raise("GeomPlate_CurveConstraint.cxx : Curve must be on a Surface"); 
158  // gp_Pnt2d P2d= myFrontiere->ChangeCurve().GetCurve()->Value(U);
159 myLProp.SetParameters(myU,myV);
160 return myLProp;
161 }
162
163
164 //------------------------------------------------------------
165 //Fonction : Order
166 //------------------------------------------------------------
167 Standard_Integer GeomPlate_PointConstraint::Order() const
168 {
169 return myOrder;
170 }
171 //------------------------------------------------------------
172 //Fonction : SetOrder
173 //------------------------------------------------------------
174 void GeomPlate_PointConstraint::SetOrder(const Standard_Integer Order) 
175 { myOrder=Order;
176 }
177
178 //------------------------------------------------------------
179 //Fonction : HasPnt2dOnSurf
180 //------------------------------------------------------------
181 Standard_Boolean GeomPlate_PointConstraint::HasPnt2dOnSurf() const
182
183   return hasPnt2dOnSurf;
184 }
185 //------------------------------------------------------------
186 //Fonction : SetPnt2dOnSurf
187 //------------------------------------------------------------
188 void GeomPlate_PointConstraint::SetPnt2dOnSurf(const gp_Pnt2d& Pnt2d) 
189
190   myPt2d=Pnt2d;
191   hasPnt2dOnSurf = Standard_True;
192 }
193 //------------------------------------------------------------
194 //Fonction : Pnt2dOnSurf
195 //------------------------------------------------------------
196 gp_Pnt2d GeomPlate_PointConstraint::Pnt2dOnSurf() const
197 { return myPt2d;
198 }
199