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 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.
18 #include <Adaptor2d_HCurve2d.hxx>
19 #include <IntPatch_Point.hxx>
20 #include <IntPatch_RLine.hxx>
21 #include <IntSurf_LineOn2S.hxx>
22 #include <IntSurf_PntOn2S.hxx>
23 #include <Precision.hxx>
24 #include <Standard_DomainError.hxx>
25 #include <Standard_OutOfRange.hxx>
26 #include <Standard_Type.hxx>
28 IMPLEMENT_STANDARD_RTTIEXT(IntPatch_RLine,IntPatch_PointLine)
30 IntPatch_RLine::IntPatch_RLine (const Standard_Boolean Tang,
31 const IntSurf_TypeTrans Trans1,
32 const IntSurf_TypeTrans Trans2) :
33 IntPatch_PointLine(Tang,Trans1,Trans2), fipt(Standard_False),lapt(Standard_False)
36 typ = IntPatch_Restriction;
42 IntPatch_RLine::IntPatch_RLine (const Standard_Boolean Tang,
43 const IntSurf_Situation Situ1,
44 const IntSurf_Situation Situ2) :
45 IntPatch_PointLine(Tang,Situ1,Situ2), fipt(Standard_False),lapt(Standard_False)
47 typ = IntPatch_Restriction;
53 IntPatch_RLine::IntPatch_RLine (const Standard_Boolean Tang) :
54 IntPatch_PointLine(Tang), fipt(Standard_False),lapt(Standard_False)
57 typ = IntPatch_Restriction;
62 void IntPatch_RLine::ParamOnS1(Standard_Real& a,Standard_Real& b) const {
65 for(Standard_Integer i=svtx.Length();i>=1;i--) {
66 Standard_Real p=svtx(i).ParameterOnLine();
76 void IntPatch_RLine::ParamOnS2(Standard_Real& a,Standard_Real& b) const {
79 for(Standard_Integer i=svtx.Length();i>=1;i--) {
80 Standard_Real p=svtx(i).ParameterOnLine();
91 void IntPatch_RLine::SetArcOnS1(const Handle(Adaptor2d_HCurve2d)& A) {
96 void IntPatch_RLine::SetArcOnS2(const Handle(Adaptor2d_HCurve2d)& A) {
102 void IntPatch_RLine::SetPoint(const Standard_Integer Index,
103 const IntPatch_Point& thepoint) {
104 curv->Value(Index,thepoint.PntOn2S());
107 //void IntPatch_RLine::ComputeVertexParameters(const Standard_Real Tol)
108 void IntPatch_RLine::ComputeVertexParameters(const Standard_Real )
110 Standard_Integer i,j,nbvtx;//k;
112 Standard_Boolean APointDeleted = Standard_False;
113 //----------------------------------------------------------
114 //-- F i l t r e s u r r e s t r i c t i o n s --
115 //----------------------------------------------------------
116 //-- deux vertex sur la meme restriction et seulement
117 //-- sur celle ci ne doivent pas avoir le meme parametre
121 APointDeleted = Standard_False;
122 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
123 const IntPatch_Point& VTXi = svtx.Value(i);
124 if((VTXi.IsOnDomS1()==Standard_True) && (VTXi.IsOnDomS2()==Standard_False)) {
125 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
127 const IntPatch_Point& VTXj = svtx.Value(j);
128 if((VTXj.IsOnDomS1()==Standard_True) && (VTXj.IsOnDomS2()==Standard_False)) {
129 if(VTXi.ParameterOnLine() == VTXj.ParameterOnLine()) {
130 if(VTXi.ArcOnS1() == VTXj.ArcOnS1()) {
131 if(VTXi.ParameterOnArc1() == VTXj.ParameterOnArc1()) {
134 if(lapt) { if(indl>=j) indl--; }
135 if(fipt) { if(indf>=j) indf--; }
136 APointDeleted = Standard_True;
146 while(APointDeleted == Standard_True);
149 APointDeleted = Standard_False;
150 for(i=1; (i<=nbvtx) && (APointDeleted==Standard_False) ;i++) {
151 const IntPatch_Point& VTXi = svtx.Value(i);
152 if((VTXi.IsOnDomS2()==Standard_True) && (VTXi.IsOnDomS1()==Standard_False)) {
153 for(j=1; (j<=nbvtx) && (APointDeleted==Standard_False) ;j++) {
155 const IntPatch_Point& VTXj = svtx.Value(j);
156 if((VTXj.IsOnDomS2()==Standard_True) && (VTXj.IsOnDomS1()==Standard_False)) {
157 if(VTXi.ParameterOnLine() == VTXj.ParameterOnLine()) {
158 if(VTXi.ArcOnS2() == VTXj.ArcOnS2()) {
159 if(VTXi.ParameterOnArc2() == VTXj.ParameterOnArc2()) {
162 if(lapt) { if(indl>=j) indl--; }
163 if(fipt) { if(indf>=j) indf--; }
164 APointDeleted = Standard_True;
174 while(APointDeleted == Standard_True);
178 //----------------------------------------------------
179 //-- On trie les Vertex
180 Standard_Boolean SortIsOK;
182 SortIsOK = Standard_True;
183 for(i=2; i<=nbvtx; i++) {
184 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
185 SortIsOK = Standard_False;
186 svtx.Exchange(i-1,i);
193 APointDeleted = Standard_False;
194 Standard_Boolean restrdiff;
195 for(i=1; i<=nbvtx && (APointDeleted == Standard_False); i++) {
196 const IntPatch_Point& VTX = svtx.Value(i);
197 for(j=1; j<=nbvtx && (APointDeleted == Standard_False) ; j++) {
199 const IntPatch_Point& VTXM1 = svtx.Value(j);
201 Standard_Boolean kill = Standard_False;
202 Standard_Boolean killm1 = Standard_False;
204 if(VTXM1.ParameterOnLine() == VTX.ParameterOnLine()) {
205 restrdiff=Standard_False;
206 if(VTXM1.IsOnDomS1() && VTX.IsOnDomS1()) { //-- OnS1 OnS1
207 if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS1 == OnS1
208 if(VTX.ParameterOnArc1() == VTXM1.ParameterOnArc1()) {
209 if(VTXM1.IsOnDomS2()) { //-- OnS1 == OnS1 OnS2
210 if(VTX.IsOnDomS2()==Standard_False) { //-- OnS1 == OnS1 OnS2 PasOnS2
214 if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS1 == OnS1 OnS2 == OnS2
215 if(VTX.ParameterOnArc2() == VTXM1.ParameterOnArc2()) {
221 else { //-- OnS1 == OnS1 PasOnS2
222 if(VTX.IsOnDomS2()) { //-- OnS1 == OnS1 PasOnS2 OnS2
223 killm1=Standard_True;
229 restrdiff=Standard_True;
233 if((restrdiff==Standard_False) && (!(kill || killm1))) {
234 if(VTXM1.IsOnDomS2() && VTX.IsOnDomS2()) { //-- OnS2 OnS2
235 if(VTXM1.ArcOnS2() == VTX.ArcOnS2()) { //-- OnS2 == OnS2
236 if(VTX.ParameterOnArc2() == VTXM1.ParameterOnArc2()) {
237 if(VTXM1.IsOnDomS1()) { //-- OnS2 == OnS2 OnS1
238 if(VTX.IsOnDomS1()==Standard_False) { //-- OnS2 == OnS2 OnS1 PasOnS1
242 if(VTXM1.ArcOnS1() == VTX.ArcOnS1()) { //-- OnS2 == OnS2 OnS1 == OnS1
243 if(VTX.ParameterOnArc1() == VTXM1.ParameterOnArc1()) {
249 else { //-- OnS2 == OnS2 PasOnS1
250 if(VTX.IsOnDomS1()) { //-- OnS2 == OnS2 PasOnS1 OnS1
251 killm1=Standard_True;
257 restrdiff=Standard_True;
261 if(restrdiff==Standard_False) {
263 APointDeleted = Standard_True;
268 APointDeleted = Standard_True;
278 while(APointDeleted == Standard_True);
281 SortIsOK = Standard_True;
282 for(i=2; i<=nbvtx && SortIsOK; i++) {
283 const IntPatch_Point& Pim1=svtx.Value(i-1);
284 const IntPatch_Point& Pii =svtx.Value(i);
285 if(Pim1.ParameterOnLine()==Pii.ParameterOnLine()) {
286 if( (Pii.IsOnDomS1() == Standard_False)
287 && (Pii.IsOnDomS2() == Standard_False)) {
288 SortIsOK = Standard_False;
293 if( (Pim1.IsOnDomS1() == Standard_False)
294 && (Pim1.IsOnDomS2() == Standard_False)) {
295 SortIsOK = Standard_False;
305 //----------------------------------------------------
306 //-- On trie les Vertex ( Cas Bizarre )
309 SortIsOK = Standard_True;
310 for(i=2; i<=nbvtx; i++) {
311 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
312 SortIsOK = Standard_False;
313 svtx.Exchange(i-1,i);
325 Standard_Boolean SortIsOK;
326 Standard_Integer nbvtx = NbVertex();
328 SortIsOK = Standard_True;
329 for(Standard_Integer i=2; i<=nbvtx; i++) {
330 if(svtx.Value(i-1).ParameterOnLine() > svtx.Value(i).ParameterOnLine()) {
331 SortIsOK = Standard_False;
332 svtx.Exchange(i,i-1);
334 if(indf == i) indf = i-1;
335 else if(indf == (i-1)) indf = i;
338 if(indl == i) indl = i-1;
339 else if(indl == (i-1)) indl = i;
348 void IntPatch_RLine::Dump(const Standard_Integer theMode) const
350 cout<<" ----------- D u m p I n t P a t c h _ R L i n e -(begin)------"<<endl;
351 const Standard_Integer aNbPoints = NbPnts();
352 const Standard_Integer aNbVertex = NbVertex();
357 printf("Num [X Y Z] [U1 V1] [U2 V2]\n");
358 for(Standard_Integer i=1; i<=aNbPoints; i++)
360 Standard_Real u1,v1,u2,v2;
361 Point(i).Parameters(u1,v1,u2,v2);
362 printf("%4d [%+10.20f %+10.20f %+10.20f] [%+10.20f %+10.20f] [%+10.20f %+10.20f]\n",
363 i,Point(i).Value().X(),Point(i).Value().Y(),Point(i).Value().Z(),
367 for(Standard_Integer i=1;i<=aNbVertex;i++)
370 Standard_Real polr = Vertex(i).ParameterOnLine();
371 Standard_Integer pol = static_cast<Standard_Integer>(polr);
373 if(pol>=1 && pol<=aNbVertex)
375 cout<<"----> IntSurf_PntOn2S : "<<
376 polr <<", Pnt (" << Vertex(pol).Value().X() << "," <<
377 Vertex(pol).Value().Y() << "," <<
378 Vertex(pol).Value().Z() <<")" <<endl;
384 for(Standard_Integer i = 1; i <= aNbPoints; i++)
386 Standard_Real u1,v1,u2,v2;
387 Point(i).Parameters(u1,v1,u2,v2);
388 printf("point p%d %+10.20f %+10.20f %+10.20f\n",
389 i,Point(i).Value().X(),Point(i).Value().Y(),Point(i).Value().Z());
394 for(Standard_Integer i = 1; i <= aNbPoints; i++)
396 Standard_Real u1,v1,u2,v2;
397 Point(i).Parameters(u1,v1,u2,v2);
398 printf("point p%d %+10.20f %+10.20f\n", i, u1, v1);
403 for(Standard_Integer i = 1; i <= aNbPoints; i++)
405 Standard_Real u1,v1,u2,v2;
406 Point(i).Parameters(u1,v1,u2,v2);
407 printf("point p%d %+10.20f %+10.20f\n", i, u2, v2);
412 cout<<"\n--------------------------------------------------- (end) -------"<<endl;