1 // Created on: 1997-03-05
2 // Created by: Joelle CHAUVET
3 // Copyright (c) 1997-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 //Modified by Jerome LEMONIER
18 // Tue Jun 17 10:20:35 1997
19 // Modification de la comparaison dans la methode
20 // Value (Appel a des distances remplace par le calcul
21 // de la distance au carre)
23 #include <AdvApp2Var_Context.hxx>
24 #include <AdvApp2Var_Criterion.hxx>
25 #include <AdvApp2Var_Patch.hxx>
26 #include <GeomPlate_PlateG0Criterion.hxx>
31 #include <TColgp_SequenceOfXY.hxx>
32 #include <TColgp_SequenceOfXYZ.hxx>
33 #include <TColStd_HArray1OfReal.hxx>
35 //============================================================================
36 //function : GeomPlate_PlateG0Criterion
38 //============================================================================
39 GeomPlate_PlateG0Criterion::
40 GeomPlate_PlateG0Criterion(const TColgp_SequenceOfXY& Data,
41 const TColgp_SequenceOfXYZ& G0Data,
42 const Standard_Real Maximum,
43 const AdvApp2Var_CriterionType Type,
44 const AdvApp2Var_CriterionRepartition Repart)
50 myRepartition = Repart;
54 //============================================================================
57 //============================================================================
59 void GeomPlate_PlateG0Criterion::Value(AdvApp2Var_Patch& P,
60 const AdvApp2Var_Context& C) const
62 Standard_Real UInt[2],VInt[2];
63 Standard_Integer MaxNbCoeff[2], NbCoeff[2];
64 Standard_Real * adrCoeff = NULL ;
65 adrCoeff = (Standard_Real *) &P.Coefficients(1,C) ->ChangeArray1()(P.Coefficients(1,C)->Lower());
67 MaxNbCoeff[0] = C.ULimit();
68 MaxNbCoeff[1] = C.VLimit();
69 NbCoeff[0] = P.NbCoeffInU();
70 NbCoeff[1] = P.NbCoeffInV();
76 Standard_Real up,vp, dist = 0.;
78 Standard_Integer dimension = 3 * NbCoeff[1];
79 TColStd_Array1OfReal Patch(1, NbCoeff[0] * dimension);
80 TColStd_Array1OfReal Curve(1, dimension);
81 TColStd_Array1OfReal Point(1, 3);
82 Standard_Real * Coeffs = (Standard_Real *) &Patch.ChangeValue(1);
83 Standard_Real * Digit = (Standard_Real *) &Point.ChangeValue(1);
85 Standard_Integer k1, k2, pos, ll=1;
86 for (k1 = 1; k1 <= NbCoeff[0]; k1++) {
87 // JAG 99.04.29 pos = 3*(MaxNbCoeff[0])*(k1-1);
88 pos = 3*(MaxNbCoeff[1])*(k1-1);
89 for (k2 = 1; k2 <= NbCoeff[1]; k2++, pos+=3 ) {
90 Patch(ll) = adrCoeff[pos];
91 Patch(ll+1) = adrCoeff[pos+1];
92 Patch(ll+2) = adrCoeff[pos+2];
97 Standard_Integer i, NbCtr = myData.Length();
98 for(i=1; i<=NbCtr; i++) {
99 gp_XY P2d = myData.Value(i);
100 // gp_Pnt PP = myXYZ.Value(i);
102 if ( UInt[0]<P2d.X() && P2d.X()<UInt[1]
103 && VInt[0]<P2d.Y() && P2d.Y()<VInt[1] ) {
104 // u,v recadres sur (-1,1)
105 up = (2*P2d.X()-UInt[0]-UInt[1])
106 / (UInt[1]-UInt[0]) ;
107 vp = (2*P2d.Y()-VInt[0]-VInt[1])
108 / (VInt[1]-VInt[0]) ;
109 PLib::EvalPoly2Var(up,vp,
111 NbCoeff[0]-1,NbCoeff[1]-1,3,
115 P3d.SetCoord(1,Digit[0]);
116 P3d.SetCoord(2,Digit[1]);
117 P3d.SetCoord(3,Digit[2]);
118 Standard_Real x=(P3d.Coord(1)-myXYZ.Value(i).Coord(1)),
119 y=(P3d.Coord(2)-myXYZ.Value(i).Coord(2)),
120 z=(P3d.Coord(3)-myXYZ.Value(i).Coord(3)),
121 DistTmp= x*x+y*y+z*z;
127 P.SetCritValue(Sqrt(dist));
131 //============================================================================
132 //function : IsSatisfied
134 //============================================================================
136 Standard_Boolean GeomPlate_PlateG0Criterion::IsSatisfied(const AdvApp2Var_Patch& P) const
138 return (P.CritValue() < myMaxValue);