0022922: Clean up warnings on uninitialized / unused variables
[occt.git] / src / GeomPlate / GeomPlate_PlateG1Criterion.cxx
CommitLineData
7fd59977 1// File: GeomPlate_PlateG1Criterion.cxx
2// Created: Wed Mar 5 10:04:41 1997
3// Author: Joelle CHAUVET
4// <jct@sgi38>
5
6
7#include <GeomPlate_PlateG1Criterion.ixx>
8#include <AdvApp2Var_Criterion.hxx>
9#include <TColgp_SequenceOfXY.hxx>
10#include <TColgp_SequenceOfXYZ.hxx>
11#include <gp_Vec.hxx>
12#include <gp_XY.hxx>
13#include <gp_Pnt.hxx>
14#include <TColStd_HArray1OfReal.hxx>
15#include <PLib.hxx>
16
17
18// static Standard_Boolean first = Standard_True;
19
20
21//============================================================================
22//function : GeomPlate_PlateG1Criterion
23//purpose :
24//============================================================================
25
26
27 GeomPlate_PlateG1Criterion::
28GeomPlate_PlateG1Criterion(const TColgp_SequenceOfXY& Data,
29 const TColgp_SequenceOfXYZ& G1Data,
30 const Standard_Real Maximum,
31 const AdvApp2Var_CriterionType Type,
32 const AdvApp2Var_CriterionRepartition Repart)
33{
34 myData=Data;
35 myXYZ=G1Data;
36 myMaxValue = Maximum;
37 myType = Type;
38 myRepartition = Repart;
39}
40
41
42//============================================================================
43//function : Value
44//purpose :
45//============================================================================
46
47void GeomPlate_PlateG1Criterion::Value(AdvApp2Var_Patch& P,
48 const AdvApp2Var_Context& C) const
49{
50 Standard_Real UInt[2],VInt[2];
51 Standard_Integer MaxNbCoeff[2], NbCoeff[2];
52 Standard_Real * adrCoeff = NULL ;
53 adrCoeff = (Standard_Real *) &P.Coefficients(1,C) ->ChangeArray1()(P.Coefficients(1,C)->Lower());
54
55 MaxNbCoeff[0] = C.ULimit();
56 MaxNbCoeff[1] = C.VLimit();
57 NbCoeff[0] = P.NbCoeffInU();
58 NbCoeff[1] = P.NbCoeffInV();
59 UInt[0] = P.U0();
60 UInt[1] = P.U1();
61 VInt[0] = P.V0();
62 VInt[1] = P.V1();
63
64 Standard_Real up,vp, ang = 0.;
65
66 Standard_Integer dimension = 3 * NbCoeff[1];
67 TColStd_Array1OfReal Patch(1, NbCoeff[0] * dimension);
68 TColStd_Array1OfReal Curve(1, 2*dimension);
69 TColStd_Array1OfReal Point(1, 3);
70 Standard_Real * Coeffs = (Standard_Real *) &Patch.ChangeValue(1);
7fd59977 71 Standard_Real * Digit = (Standard_Real *) &Point.ChangeValue(1);
72
73 Standard_Integer k1, k2, pos, ll=1;
74 for (k1 = 1; k1 <= NbCoeff[0]; k1++) {
75// JAG 99.04.29 pos = 3*(MaxNbCoeff[0])*(k1-1);
76 pos = 3*(MaxNbCoeff[1])*(k1-1);
77 for (k2 = 1; k2 <= NbCoeff[1]; k2++, pos+=3 ) {
78 Patch(ll) = adrCoeff[pos];
79 Patch(ll+1) = adrCoeff[pos+1];
80 Patch(ll+2) = adrCoeff[pos+2];
81 ll += 3;
82 }
83 }
84
85 Standard_Integer i, NbCtr = myData.Length();
86 for(i=1; i<=NbCtr; i++) {
87 gp_Vec v1s,v2s,v3s;
88 gp_Vec v3h(myXYZ.Value(i).X(),myXYZ.Value(i).Y(),myXYZ.Value(i).Z());
89 gp_XY P2d = myData.Value(i);
90 if ( UInt[0]<P2d.X() && P2d.X()<UInt[1]
91 && VInt[0]<P2d.Y() && P2d.Y()<VInt[1] ) {
92// u,v recadres sur (-1,1)
93 up = (2*P2d.X()-UInt[0]-UInt[1])
94 / (UInt[1]-UInt[0]) ;
95 vp = (2*P2d.Y()-VInt[0]-VInt[1])
96 / (VInt[1]-VInt[0]) ;
97 PLib::EvalPoly2Var(up,vp,
98 1,0,
99 NbCoeff[0]-1,NbCoeff[1]-1,3,
100 Coeffs[0],
101 Digit[0]);
102
103 v1s.SetCoord(1,Digit[0]);
104 v1s.SetCoord(2,Digit[1]);
105 v1s.SetCoord(3,Digit[2]);
106
107 PLib::EvalPoly2Var(up,vp,
108 0,1,
109 NbCoeff[0]-1,NbCoeff[1]-1,3,
110 Coeffs[0],
111 Digit[0]);
112
113 v2s.SetCoord(1,Digit[0]);
114 v2s.SetCoord(2,Digit[1]);
115 v2s.SetCoord(3,Digit[2]);
116
117 v3s=v1s^v2s;
c6541a0c
D
118 if( v3s.Angle(v3h)>(M_PI/2)) {
119 if ((M_PI-v3s.Angle(v3h))>ang) {
120 ang=(M_PI-v3s.Angle(v3h));
7fd59977 121 }
122 }
123 else {
124 if(v3s.Angle(v3h)>ang) {
125 ang=v3s.Angle(v3h);
126 }
127 }
128 }
129 }
130 P.SetCritValue(ang);
131}
132
133
134//============================================================================
135//function : IsSatisfied
136//purpose :
137//============================================================================
138
139Standard_Boolean GeomPlate_PlateG1Criterion::IsSatisfied(const AdvApp2Var_Patch& P) const
140{
141 return (P.CritValue() < myMaxValue);
142}
143