Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1997-03-05 |
2 | // Created by: Joelle CHAUVET | |
3 | // Copyright (c) 1997-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
42cf5bc1 | 17 | |
18 | #include <AdvApp2Var_Context.hxx> | |
7fd59977 | 19 | #include <AdvApp2Var_Criterion.hxx> |
42cf5bc1 | 20 | #include <AdvApp2Var_Patch.hxx> |
21 | #include <GeomPlate_PlateG1Criterion.hxx> | |
22 | #include <gp_Pnt.hxx> | |
7fd59977 | 23 | #include <gp_Vec.hxx> |
24 | #include <gp_XY.hxx> | |
7fd59977 | 25 | #include <PLib.hxx> |
42cf5bc1 | 26 | #include <TColgp_SequenceOfXY.hxx> |
27 | #include <TColgp_SequenceOfXYZ.hxx> | |
28 | #include <TColStd_HArray1OfReal.hxx> | |
7fd59977 | 29 | |
30 | // static Standard_Boolean first = Standard_True; | |
7fd59977 | 31 | //============================================================================ |
32 | //function : GeomPlate_PlateG1Criterion | |
33 | //purpose : | |
34 | //============================================================================ | |
b311480e | 35 | GeomPlate_PlateG1Criterion:: |
7fd59977 | 36 | GeomPlate_PlateG1Criterion(const TColgp_SequenceOfXY& Data, |
37 | const TColgp_SequenceOfXYZ& G1Data, | |
38 | const Standard_Real Maximum, | |
39 | const AdvApp2Var_CriterionType Type, | |
40 | const AdvApp2Var_CriterionRepartition Repart) | |
41 | { | |
42 | myData=Data; | |
43 | myXYZ=G1Data; | |
44 | myMaxValue = Maximum; | |
45 | myType = Type; | |
46 | myRepartition = Repart; | |
47 | } | |
48 | ||
49 | ||
50 | //============================================================================ | |
51 | //function : Value | |
52 | //purpose : | |
53 | //============================================================================ | |
54 | ||
55 | void GeomPlate_PlateG1Criterion::Value(AdvApp2Var_Patch& P, | |
56 | const AdvApp2Var_Context& C) const | |
57 | { | |
58 | Standard_Real UInt[2],VInt[2]; | |
59 | Standard_Integer MaxNbCoeff[2], NbCoeff[2]; | |
60 | Standard_Real * adrCoeff = NULL ; | |
61 | adrCoeff = (Standard_Real *) &P.Coefficients(1,C) ->ChangeArray1()(P.Coefficients(1,C)->Lower()); | |
62 | ||
63 | MaxNbCoeff[0] = C.ULimit(); | |
64 | MaxNbCoeff[1] = C.VLimit(); | |
65 | NbCoeff[0] = P.NbCoeffInU(); | |
66 | NbCoeff[1] = P.NbCoeffInV(); | |
67 | UInt[0] = P.U0(); | |
68 | UInt[1] = P.U1(); | |
69 | VInt[0] = P.V0(); | |
70 | VInt[1] = P.V1(); | |
71 | ||
72 | Standard_Real up,vp, ang = 0.; | |
73 | ||
74 | Standard_Integer dimension = 3 * NbCoeff[1]; | |
75 | TColStd_Array1OfReal Patch(1, NbCoeff[0] * dimension); | |
76 | TColStd_Array1OfReal Curve(1, 2*dimension); | |
77 | TColStd_Array1OfReal Point(1, 3); | |
78 | Standard_Real * Coeffs = (Standard_Real *) &Patch.ChangeValue(1); | |
7fd59977 | 79 | Standard_Real * Digit = (Standard_Real *) &Point.ChangeValue(1); |
80 | ||
81 | Standard_Integer k1, k2, pos, ll=1; | |
82 | for (k1 = 1; k1 <= NbCoeff[0]; k1++) { | |
83 | // JAG 99.04.29 pos = 3*(MaxNbCoeff[0])*(k1-1); | |
84 | pos = 3*(MaxNbCoeff[1])*(k1-1); | |
85 | for (k2 = 1; k2 <= NbCoeff[1]; k2++, pos+=3 ) { | |
86 | Patch(ll) = adrCoeff[pos]; | |
87 | Patch(ll+1) = adrCoeff[pos+1]; | |
88 | Patch(ll+2) = adrCoeff[pos+2]; | |
89 | ll += 3; | |
90 | } | |
91 | } | |
92 | ||
93 | Standard_Integer i, NbCtr = myData.Length(); | |
94 | for(i=1; i<=NbCtr; i++) { | |
95 | gp_Vec v1s,v2s,v3s; | |
96 | gp_Vec v3h(myXYZ.Value(i).X(),myXYZ.Value(i).Y(),myXYZ.Value(i).Z()); | |
97 | gp_XY P2d = myData.Value(i); | |
98 | if ( UInt[0]<P2d.X() && P2d.X()<UInt[1] | |
99 | && VInt[0]<P2d.Y() && P2d.Y()<VInt[1] ) { | |
100 | // u,v recadres sur (-1,1) | |
101 | up = (2*P2d.X()-UInt[0]-UInt[1]) | |
102 | / (UInt[1]-UInt[0]) ; | |
103 | vp = (2*P2d.Y()-VInt[0]-VInt[1]) | |
104 | / (VInt[1]-VInt[0]) ; | |
105 | PLib::EvalPoly2Var(up,vp, | |
106 | 1,0, | |
107 | NbCoeff[0]-1,NbCoeff[1]-1,3, | |
108 | Coeffs[0], | |
109 | Digit[0]); | |
110 | ||
111 | v1s.SetCoord(1,Digit[0]); | |
112 | v1s.SetCoord(2,Digit[1]); | |
113 | v1s.SetCoord(3,Digit[2]); | |
114 | ||
115 | PLib::EvalPoly2Var(up,vp, | |
116 | 0,1, | |
117 | NbCoeff[0]-1,NbCoeff[1]-1,3, | |
118 | Coeffs[0], | |
119 | Digit[0]); | |
120 | ||
121 | v2s.SetCoord(1,Digit[0]); | |
122 | v2s.SetCoord(2,Digit[1]); | |
123 | v2s.SetCoord(3,Digit[2]); | |
124 | ||
125 | v3s=v1s^v2s; | |
c6541a0c D |
126 | if( v3s.Angle(v3h)>(M_PI/2)) { |
127 | if ((M_PI-v3s.Angle(v3h))>ang) { | |
128 | ang=(M_PI-v3s.Angle(v3h)); | |
7fd59977 | 129 | } |
130 | } | |
131 | else { | |
132 | if(v3s.Angle(v3h)>ang) { | |
133 | ang=v3s.Angle(v3h); | |
134 | } | |
135 | } | |
136 | } | |
137 | } | |
138 | P.SetCritValue(ang); | |
139 | } | |
140 | ||
141 | ||
142 | //============================================================================ | |
143 | //function : IsSatisfied | |
144 | //purpose : | |
145 | //============================================================================ | |
146 | ||
147 | Standard_Boolean GeomPlate_PlateG1Criterion::IsSatisfied(const AdvApp2Var_Patch& P) const | |
148 | { | |
149 | return (P.CritValue() < myMaxValue); | |
150 | } | |
151 |