1 // Created on: 1992-04-06
2 // Created by: Jacques GOUSSARD
3 // Copyright (c) 1992-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
9 // under the terms of the GNU Lesser General Public 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 #include <IntPatch_RLine.ixx>
19 #include <IntSurf_PntOn2S.hxx>
20 #include <Precision.hxx>
22 IntPatch_RLine::IntPatch_RLine (const Standard_Boolean Tang,
23 const IntSurf_TypeTrans Trans1,
24 const IntSurf_TypeTrans Trans2) :
25 IntPatch_Line(Tang,Trans1,Trans2),
26 fipt(Standard_False),lapt(Standard_False)
29 typ = IntPatch_Restriction;
35 IntPatch_RLine::IntPatch_RLine (const Standard_Boolean Tang,
36 const IntSurf_Situation Situ1,
37 const IntSurf_Situation Situ2) :
38 IntPatch_Line(Tang,Situ1,Situ2),
39 fipt(Standard_False),lapt(Standard_False)
41 typ = IntPatch_Restriction;
47 IntPatch_RLine::IntPatch_RLine (const Standard_Boolean Tang) :
49 fipt(Standard_False),lapt(Standard_False)
52 typ = IntPatch_Restriction;
57 void IntPatch_RLine::ParamOnS1(Standard_Real& a,Standard_Real& b) const {
60 for(Standard_Integer i=svtx.Length();i>=1;i--) {
61 Standard_Real p=svtx(i).ParameterOnLine();
71 void IntPatch_RLine::ParamOnS2(Standard_Real& a,Standard_Real& b) const {
74 for(Standard_Integer i=svtx.Length();i>=1;i--) {
75 Standard_Real p=svtx(i).ParameterOnLine();
86 void IntPatch_RLine::SetArcOnS1(const Handle(Adaptor2d_HCurve2d)& A) {
91 void IntPatch_RLine::SetArcOnS2(const Handle(Adaptor2d_HCurve2d)& A) {
97 void IntPatch_RLine::SetPoint(const Standard_Integer Index,
98 const IntPatch_Point& thepoint) {
99 curv->Value(Index,thepoint.PntOn2S());
102 //void IntPatch_RLine::ComputeVertexParameters(const Standard_Real Tol)
103 void IntPatch_RLine::ComputeVertexParameters(const Standard_Real )
105 Standard_Integer i,j,nbvtx;//k;
107 Standard_Real ParamMinOnLine,ParamMaxOnLine;
108 if(fipt) { ParamMinOnLine = Vertex(indf).ParameterOnLine(); } else { ParamMinOnLine = -100000.0; }
109 if(lapt) { ParamMaxOnLine = Vertex(indl).ParameterOnLine(); } else { ParamMaxOnLine = 100000.0; }
110 Standard_Boolean APointDeleted = Standard_False;
111 //----------------------------------------------------------
112 //-- F i l t r e s u r r e s t r i c t i o n s --
113 //----------------------------------------------------------
114 //-- deux vertex sur la meme restriction et seulement
115 //-- sur celle ci ne doivent pas avoir le meme parametre
119 APointDeleted = Standard_False;
120 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
121 const IntPatch_Point& VTXi = svtx.Value(i);
122 if((VTXi.IsOnDomS1()==Standard_True) && (VTXi.IsOnDomS2()==Standard_False)) {
123 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
125 const IntPatch_Point& VTXj = svtx.Value(j);
126 if((VTXj.IsOnDomS1()==Standard_True) && (VTXj.IsOnDomS2()==Standard_False)) {
127 if(VTXi.ParameterOnLine() == VTXj.ParameterOnLine()) {
128 if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) {
129 if(VTXi.ParameterOnArc1() == VTXj.ParameterOnArc1()) {
132 if(lapt) { if(indl>=j) indl--; }
133 if(fipt) { if(indf>=j) indf--; }
134 APointDeleted = Standard_True;
144 while(APointDeleted == Standard_True);
147 APointDeleted = Standard_False;
148 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
149 const IntPatch_Point& VTXi = svtx.Value(i);
150 if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_False)) {
151 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
153 const IntPatch_Point& VTXj = svtx.Value(j);
154 if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_False)) {
155 if(VTXi.ParameterOnLine() == VTXj.ParameterOnLine()) {
156 if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) {
157 if(VTXi.ParameterOnArc2() == VTXj.ParameterOnArc2()) {
160 if(lapt) { if(indl>=j) indl--; }
161 if(fipt) { if(indf>=j) indf--; }
162 APointDeleted = Standard_True;
172 while(APointDeleted == Standard_True);
176 //----------------------------------------------------
177 //-- On trie les Vertex
178 Standard_Boolean SortIsOK;
180 SortIsOK = Standard_True;
181 for(i=2; i<=nbvtx; i++) {
182 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
183 SortIsOK = Standard_False;
184 svtx.Exchange(i-1,i);
191 APointDeleted = Standard_False;
192 Standard_Boolean restrdiff;
193 for(i=1; i<=nbvtx && (APointDeleted == Standard_False); i++) {
194 const IntPatch_Point& VTX = svtx.Value(i);
195 for(j=1; j<=nbvtx && (APointDeleted == Standard_False) ; j++) {
197 const IntPatch_Point& VTXM1 = svtx.Value(j);
199 Standard_Boolean kill = Standard_False;
200 Standard_Boolean killm1 = Standard_False;
202 if(VTXM1.ParameterOnLine() == VTX.ParameterOnLine()) {
203 restrdiff=Standard_False;
204 if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()) { //-- OnS1 OnS1
205 if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS1 == OnS1
206 if(VTX.ParameterOnArc1() == VTXM1.ParameterOnArc1()) {
207 if(VTXM1.IsOnDomS2()) { //-- OnS1 == OnS1 OnS2
208 if(VTX.IsOnDomS2()==Standard_False) { //-- OnS1 == OnS1 OnS2 PasOnS2
212 if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS1 == OnS1 OnS2 == OnS2
213 if(VTX.ParameterOnArc2() == VTXM1.ParameterOnArc2()) {
219 else { //-- OnS1 == OnS1 PasOnS2
220 if(VTX.IsOnDomS2()) { //-- OnS1 == OnS1 PasOnS2 OnS2
221 killm1=Standard_True;
227 restrdiff=Standard_True;
231 if((restrdiff==Standard_False) && (!(kill || killm1))) {
232 if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()) { //-- OnS2 OnS2
233 if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS2 == OnS2
234 if(VTX.ParameterOnArc2() == VTXM1.ParameterOnArc2()) {
235 if(VTXM1.IsOnDomS1()) { //-- OnS2 == OnS2 OnS1
236 if(VTX.IsOnDomS1()==Standard_False) { //-- OnS2 == OnS2 OnS1 PasOnS1
240 if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS2 == OnS2 OnS1 == OnS1
241 if(VTX.ParameterOnArc1() == VTXM1.ParameterOnArc1()) {
247 else { //-- OnS2 == OnS2 PasOnS1
248 if(VTX.IsOnDomS1()) { //-- OnS2 == OnS2 PasOnS1 OnS1
249 killm1=Standard_True;
255 restrdiff=Standard_True;
259 if(restrdiff==Standard_False) {
261 APointDeleted = Standard_True;
266 APointDeleted = Standard_True;
276 while(APointDeleted == Standard_True);
279 SortIsOK = Standard_True;
280 for(i=2; i<=nbvtx && SortIsOK; i++) {
281 const IntPatch_Point& Pim1=svtx.Value(i-1);
282 const IntPatch_Point& Pii =svtx.Value(i);
283 if(Pim1.ParameterOnLine()==Pii.ParameterOnLine()) {
284 if( (Pii.IsOnDomS1() == Standard_False)
285 && (Pii.IsOnDomS2() == Standard_False)) {
286 SortIsOK = Standard_False;
291 if( (Pim1.IsOnDomS1() == Standard_False)
292 && (Pim1.IsOnDomS2() == Standard_False)) {
293 SortIsOK = Standard_False;
303 //----------------------------------------------------
304 //-- On trie les Vertex ( Cas Bizarre )
307 SortIsOK = Standard_True;
308 for(i=2; i<=nbvtx; i++) {
309 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
310 SortIsOK = Standard_False;
311 svtx.Exchange(i-1,i);
323 Standard_Boolean SortIsOK;
324 Standard_Integer nbvtx = NbVertex();
326 SortIsOK = Standard_True;
327 for(Standard_Integer i=2; i<=nbvtx; i++) {
328 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
329 SortIsOK = Standard_False;
330 svtx.Exchange(i,i-1);
332 if(indf == i) indf = i-1;
333 else if(indf == (i-1)) indf = i;
336 if(indl == i) indl = i-1;
337 else if(indl == (i-1)) indl = i;