1 // Created on: 1997-04-17
2 // Created by: Christophe MARION
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 //#define No_Standard_OutOfRange
19 #include <BRepTopAdaptor_Tool.hxx>
20 #include <BRepTopAdaptor_TopolTool.hxx>
22 #include <Geom2d_Curve.hxx>
23 #include <GeomInt.hxx>
26 #include <gp_Dir2d.hxx>
27 #include <HLRAlgo.hxx>
28 #include <HLRAlgo_Interference.hxx>
29 #include <HLRAlgo_ListIteratorOfInterferenceList.hxx>
30 #include <HLRAlgo_Projector.hxx>
31 #include <HLRBRep_Data.hxx>
32 #include <HLRBRep_EdgeData.hxx>
33 #include <HLRBRep_EdgeFaceTool.hxx>
34 #include <HLRBRep_FaceData.hxx>
35 #include <IntCurveSurface_IntersectionPoint.hxx>
36 #include <IntCurveSurface_TransitionOnCurve.hxx>
37 #include <IntRes2d_IntersectionPoint.hxx>
38 #include <IntRes2d_IntersectionSegment.hxx>
39 #include <Precision.hxx>
40 #include <Standard_Type.hxx>
41 #include <StdFail_UndefinedDerivative.hxx>
42 #include <TColStd_ListIteratorOfListOfInteger.hxx>
45 IMPLEMENT_STANDARD_RTTIEXT(HLRBRep_Data,Standard_Transient)
47 Standard_Integer nbOkIntersection;
48 Standard_Integer nbPtIntersection;
49 Standard_Integer nbSegIntersection;
50 Standard_Integer nbClassification;
51 Standard_Integer nbCal1Intersection; // pairs of unrejected edges
52 Standard_Integer nbCal2Intersection; // true intersections (not vertex)
53 Standard_Integer nbCal3Intersection; // Curve-Surface intersections
55 static const Standard_Real CutLar = 2.e-1;
56 static const Standard_Real CutBig = 1.e-1;
60 static const Standard_Real DERIVEE_PREMIERE_NULLE = 0.000000000001;
62 //-- ======================================================================
65 #include <IntRes2d_TypeTrans.hxx>
66 #include <IntRes2d_Position.hxx>
67 #include <IntRes2d_IntersectionPoint.hxx>
68 #include <IntRes2d_Transition.hxx>
70 static long unsigned Mask32[32] = { 1,2,4,8, 16,32,64,128, 256,512,1024,2048,
71 4096,8192,16384,32768,
72 65536,131072,262144,524288,
73 1048576,2097152,4194304,8388608,
74 16777216,33554432,67108864,134217728,
75 268435456,536870912,1073741824,2147483648U};
77 static const Standard_Integer SIZEUV = 8;
79 class TableauRejection {
81 Standard_Real **UV; //-- UV[i][j] contient le param (U sur Ci) de l intersection de Ci avec C(IndUV[j])
82 Standard_Integer **IndUV; //-- IndUV[i][j] = J0 -> Intersection entre i et J0
83 Standard_Integer *nbUV; //-- nbUV[i][j] nombre de valeurs pour la ligne i
86 long unsigned **TabBit;
87 Standard_Integer nTabBit;
90 Standard_Integer StNbLect,StNbEcr,StNbMax,StNbMoy,StNbMoyNonNul; //-- STAT
94 TableauRejection(const TableauRejection&);
95 TableauRejection& operator=(const TableauRejection&);
98 //-- ============================================================
100 N=0; nTabBit=0; UV=NULL; nbUV=NULL; IndUV=NULL; TabBit=NULL;
102 StNbLect=StNbEcr=StNbMax=StNbMoy=StNbMoyNonNul=0;
105 //-- ============================================================
106 void SetDim(const Standard_Integer n) {
108 cout<<"\n@#@#@#@#@# SetDim "<<n<<endl;
113 StNbLect=StNbEcr=StNbMax=StNbMoy=0;
116 UV = (Standard_Real **) malloc(N*sizeof(Standard_Real *));
117 IndUV = (Standard_Integer **) malloc(N*sizeof(Standard_Integer *));
118 nbUV = (Standard_Integer *) malloc(N*sizeof(Standard_Integer));
119 // for(Standard_Integer i=0;i<N;i++) {
122 UV[i]=(Standard_Real *) malloc(SIZEUV*sizeof(Standard_Real));
125 IndUV[i]=(Standard_Integer *) malloc(SIZEUV*sizeof(Standard_Integer));
126 for(Standard_Integer k=0;k<SIZEUV;k++) {
133 //-- ============================================================
134 ~TableauRejection() {
135 //-- cout<<"\n Destructeur TableauRejection"<<endl;
138 //-- ============================================================
142 Standard_Integer nnn=0;
143 StNbMoy=StNbMoyNonNul=0;
145 for(Standard_Integer i=0; i<N; i++) {
146 Standard_Integer nb=0;
147 for(Standard_Integer j=0; IndUV[i][j]!=-1 && j<nbUV[i]; j++,nb++);
148 if(nb>StNbMax) StNbMax=nb;
150 if(nb) { StNbMoyNonNul+=nb; nnn++; }
153 printf("\n----------------------------------------");
154 printf("\nNbLignes : %10d",N);
155 printf("\nNbLect : %10d",StNbLect);
156 printf("\nNbEcr : %10d",StNbEcr);
157 printf("\nNbMax : %10d",StNbMax);
158 printf("\nNbMoy : %10d / %10d -> %d",StNbMoy,N,StNbMoy/N);
160 printf("\nNbMoy !=0 : %10d / %10d -> %d",StNbMoyNonNul,nnn,StNbMoyNonNul/nnn);
162 printf("\n----------------------------------------\n");
167 // for(Standard_Integer i=0;i<N;i++) {
176 cout<<" IndUV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
185 else { cout<<" UV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; }
189 if(nbUV) { free(nbUV); nbUV=NULL; }
190 if(IndUV) { free(IndUV); IndUV=NULL;}
191 if(UV) { free(UV); UV=NULL; }
195 //-- ============================================================
196 void Set(Standard_Integer i0,Standard_Integer j0,const Standard_Real u) {
201 Standard_Integer k=-1;
202 // for(Standard_Integer i=0; k==-1 && i<nbUV[i0]; i++) {
204 for( i=0; k==-1 && i<nbUV[i0]; i++) {
205 if(IndUV[i0][i]==-1) {
209 if(k==-1) { //-- on agrandit le tableau
211 //-- declaration de la Nv ligne de taille : ancienne taille + SIZEUV
214 //-- cout<<" \n alloc nbUV["<<i0<<"]="<<nbUV[i0];
216 Standard_Real *NvLigneUV = (Standard_Real *) malloc((nbUV[i0]+SIZEUV)*sizeof(Standard_Real));
217 Standard_Integer *NvLigneInd = (Standard_Integer *)malloc((nbUV[i0]+SIZEUV)*sizeof(Standard_Integer));
219 //-- Recopie des anciennes valeurs ds la nouvelle ligne
221 for(i=0;i<nbUV[i0];i++) {
222 NvLigneUV[i]=UV[i0][i];
223 NvLigneInd[i]=IndUV[i0][i];
226 //-- mise a jour de la nouvelle dimension ; free des anciennes lignes et affectation
232 IndUV[i0]=NvLigneInd;
233 for(Standard_Integer kk=k ; kk<nbUV[i0];kk++) {
240 //-- tri par ordre decroissant
241 Standard_Boolean TriOk;
244 Standard_Integer im1=0;
245 for(i=1; IndUV[i0][i]!=-1 && i<nbUV[i0]; i++,im1++) {
246 if(IndUV[i0][i]>IndUV[i0][im1]) {
247 TriOk=Standard_False;
248 k=IndUV[i0][i]; IndUV[i0][i]=IndUV[i0][im1]; IndUV[i0][im1]=k;
249 Standard_Real t=UV[i0][i]; UV[i0][i]=UV[i0][im1]; UV[i0][im1]=t;
253 while(TriOk==Standard_False);
255 //-- ============================================================
256 Standard_Real Get(Standard_Integer i0,Standard_Integer j0) {
262 //-- for(Standard_Integer i=0; IndUV[i0][i]!=-1 && i<nbUV[i0]; i++) {
263 //-- if(IndUV[i0][i]==j0) {
264 //-- return(UV[i0][i]);
267 //-- ordre decroissant
268 Standard_Integer a=0,b=nbUV[i0]-1,ab;
269 if(IndUV[i0][a]==-1) return(RealLast());
270 if(IndUV[i0][a]==j0) return(UV[i0][a]);
271 if(IndUV[i0][b]==j0) return(UV[i0][b]);
272 while((IndUV[i0][a]>j0) && (IndUV[i0][b]<j0)) {
274 if(IndUV[i0][ab] < j0) { if(b==ab) return(RealLast()); else b=ab; }
275 else if(IndUV[i0][ab] > j0) { if(a==ab) return(RealLast()); else a=ab; }
276 else { return(UV[i0][ab]); }
281 //-- ============================================================
282 void ResetTabBit(const Standard_Integer nbedgs) {
283 //-- cout<<"\n ResetTabBit"<<endl;
285 for(Standard_Integer i=0;i<nbedgs;i++) {
296 //-- ============================================================
297 void InitTabBit(const Standard_Integer nbedgs) {
298 //-- cout<<"\n InitTabBit"<<endl;
299 if(TabBit && nTabBit) {
300 ResetTabBit(nTabBit);
302 TabBit = (long unsigned **) malloc((nbedgs)*sizeof(long unsigned *));
304 Standard_Integer n=1+(nbedgs>>5);
306 for(Standard_Integer i=0;i<nbedgs;i++) {
307 TabBit[i]=(long unsigned *) malloc(n*sizeof(long unsigned));
308 for(Standard_Integer j=0;j<n;j++) {
313 //-- ============================================================
314 void SetNoIntersection(Standard_Integer i0,Standard_Integer i1) {
315 // cout<<" SetNoIntersection : "<<i0<<" "<<i1<<endl;
319 Standard_Integer t = i0; i0=i1; i1=t;
321 Standard_Integer c=i1>>5;
322 Standard_Integer o=i1 & 31;
323 TabBit[i0][c] |= Mask32[o];
325 //-- ============================================================
326 Standard_Boolean NoIntersection(Standard_Integer i0,Standard_Integer i1) {
327 // cout<<" ??NoIntersection : "<<i0<<" "<<i1<<" ";
331 Standard_Integer t = i0; i0=i1; i1=t;
333 Standard_Integer c=i1>>5;
334 Standard_Integer o=i1 & 31;
335 if(TabBit[i0][c] & Mask32[o]) {
336 //-- cout<<" TRUE "<<endl;
337 return(Standard_True);
339 //-- cout<<" FALSE "<<endl;
340 return(Standard_False);
342 //-- ============================================================
343 void SetIntersection(Standard_Integer i0,
345 const IntRes2d_IntersectionPoint& IP) {
346 const IntRes2d_Transition& T1=IP.TransitionOfFirst();
347 const IntRes2d_Transition& T2=IP.TransitionOfSecond();
348 if(T1.PositionOnCurve()==IntRes2d_Middle) {
349 if(T2.PositionOnCurve()==IntRes2d_Middle) {
350 if( T1.TransitionType()==IntRes2d_In
351 || T1.TransitionType()==IntRes2d_Out) {
352 Set(i0,i1,IP.ParamOnFirst());
353 Set(i1,i0,IP.ParamOnSecond());
358 //-- ============================================================
359 void GetSingleIntersection(Standard_Integer i0,Standard_Integer i1,
360 Standard_Real& u,Standard_Real& v ) {
371 //-- ================================================================================
374 //=======================================================================
375 //function : AdjustParameter
377 //=======================================================================
379 static void AdjustParameter (HLRBRep_EdgeData* E,
380 const Standard_Boolean h,
382 Standard_ShortReal& t)
385 Standard_ShortReal t1,t2;
387 E->Status().Bounds(p,t,p2,t2);
388 if (E->VerAtSta()) p = p + (p2 - p) * CutBig;
391 E->Status().Bounds(p1,t1,p,t);
392 if (E->VerAtEnd()) p = p - (p - p1) * CutBig;
396 //=======================================================================
399 //=======================================================================
401 HLRBRep_Data::HLRBRep_Data (const Standard_Integer NV,
402 const Standard_Integer NE,
403 const Standard_Integer NF) :
410 myToler((Standard_ShortReal)1e-5),
411 myLLProps(2,Epsilon(1.)),
412 myFLProps(2,Epsilon(1.)),
413 mySLProps(2,Epsilon(1.)),
416 myReject = new TableauRejection();
417 ((TableauRejection *)myReject)->SetDim(myNbEdges);
420 void HLRBRep_Data::Destroy() {
421 //-- cout<<"\n HLRBRep_Data::~HLRBRep_Data()"<<endl;
422 ((TableauRejection *)myReject)->Destroy();
423 delete ((TableauRejection *)myReject);
425 //=======================================================================
428 //=======================================================================
430 void HLRBRep_Data::Write (const Handle(HLRBRep_Data)& DS,
431 const Standard_Integer dv,
432 const Standard_Integer de,
433 const Standard_Integer df)
435 Standard_Integer n1edge = DS->NbEdges();
436 Standard_Integer n1face = DS->NbFaces();
438 HLRBRep_EdgeData* ed = &(myEData .ChangeValue(de));
439 HLRBRep_EdgeData* e1 = &(DS->EDataArray().ChangeValue(0 ));
443 HLRBRep_FaceData* fd = &(myFData .ChangeValue(df));
444 HLRBRep_FaceData* f1 = &(DS->FDataArray().ChangeValue(0 ));
448 for (Standard_Integer iedge = 1; iedge <= n1edge; iedge++) {
452 ed->VSta(ed->VSta() + dv);
453 ed->VEnd(ed->VEnd() + dv);
456 myEMap.Add(DS->EdgeMap().FindKey(iedge));
462 for (Standard_Integer iface = 1; iface <= n1face; iface++) {
466 const Handle(HLRAlgo_WiresBlock)& wb = fd->Wires();
467 Standard_Integer nw = wb->NbWires();
469 for (Standard_Integer iw = 1; iw <= nw; iw++) {
470 const Handle(HLRAlgo_EdgesBlock)& eb = wb->Wire(iw);
471 Standard_Integer ne = eb->NbEdges();
473 for (Standard_Integer ie = 1; ie <= ne; ie++)
474 eb->Edge(ie,eb->Edge(ie) + de);
478 myFMap.Add(DS->FaceMap().FindKey(iface));
485 //=======================================================================
488 //=======================================================================
490 void HLRBRep_Data::Update (const HLRAlgo_Projector& P)
493 const gp_Trsf& T = myProj.Transformation();
495 Standard_Real tolMinMax = 0;
497 HLRAlgo_EdgesBlock::MinMaxIndices FaceMin, FaceMax;
498 HLRAlgo_EdgesBlock::MinMaxIndices MinMaxFace;
499 HLRAlgo_EdgesBlock::MinMaxIndices WireMin, WireMax, MinMaxWire;
500 HLRAlgo_EdgesBlock::MinMaxIndices EdgeMin, EdgeMax;
501 HLRAlgo_EdgesBlock::MinMaxIndices MinMaxEdge;
502 Standard_Real TotMin[16],TotMax[16];
503 HLRAlgo::InitMinMax(Precision::Infinite(), TotMin, TotMax);
505 // compute the global MinMax
506 // *************************
507 // for (Standard_Integer edge = 1; edge <= myNbEdges; edge++) {
508 Standard_Integer edge;
509 for ( edge = 1; edge <= myNbEdges; edge++) {
510 HLRBRep_EdgeData& ed = myEData.ChangeValue(edge);
511 HLRBRep_Curve& EC = ed.ChangeGeometry();
512 EC.Projector(&myProj);
513 Standard_Real enl =EC.Update(TotMin, TotMax);
514 if (enl > tolMinMax) tolMinMax = enl;
516 HLRAlgo::EnlargeMinMax(tolMinMax, TotMin, TotMax);
518 Standard_Real precad = -Precision::Infinite();
520 for (i = 0; i <= 15; i++) {
521 d[i] = TotMax[i] - TotMin[i];
522 if (precad < d[i]) precad = d[i];
525 precad = precad * 0.0005;
527 for (i = 0; i <= 15; i++)
528 mySurD[i] = 0x00007fff / (d[i] + precad);
529 precad = precad * 0.5;
531 for (i = 0; i <= 15; i++)
532 myDeca[i] = - TotMin[i] + precad;
535 Standard_Boolean ver1,ver2;
540 for (edge = 1; edge <= myNbEdges; edge++) {
542 HLRBRep_EdgeData& ed = myEData.ChangeValue(edge);
543 HLRBRep_Curve& EC = ed.ChangeGeometry();
544 HLRAlgo::InitMinMax(Precision::Infinite(), TotMin, TotMax);
545 tolMinMax = EC.UpdateMinMax(TotMin, TotMax);
546 tol = (Standard_Real)(ed.Tolerance());
547 ed.Vertical(TotMax[0] - TotMin[0] < tol &&
548 TotMax[1] - TotMin[1] < tol &&
549 TotMax[2] - TotMin[2] < tol &&
550 TotMax[3] - TotMin[3] < tol &&
551 TotMax[4] - TotMin[4] < tol &&
552 TotMax[5] - TotMin[5] < tol &&
553 TotMax[6] - TotMin[6] < tol );
554 HLRAlgo::EnlargeMinMax(tolMinMax, TotMin, TotMax);
555 // Linux warning : assignment to `int' from `double'. Cast has been added.
556 EdgeMin.Min[0] = (Standard_Integer)( (myDeca[ 0] + TotMin[ 0]) * mySurD[ 0]);
557 EdgeMax.Min[0] = (Standard_Integer)( (myDeca[ 0] + TotMax[ 0]) * mySurD[ 0]);
558 EdgeMin.Min[1] = (Standard_Integer)( (myDeca[ 1] + TotMin[ 1]) * mySurD[ 1]);
559 EdgeMax.Min[1] = (Standard_Integer)( (myDeca[ 1] + TotMax[ 1]) * mySurD[ 1]);
560 EdgeMin.Min[2] = (Standard_Integer)( (myDeca[ 2] + TotMin[ 2]) * mySurD[ 2]);
561 EdgeMax.Min[2] = (Standard_Integer)( (myDeca[ 2] + TotMax[ 2]) * mySurD[ 2]);
562 EdgeMin.Min[3] = (Standard_Integer)( (myDeca[ 3] + TotMin[ 3]) * mySurD[ 3]);
563 EdgeMax.Min[3] = (Standard_Integer)( (myDeca[ 3] + TotMax[ 3]) * mySurD[ 3]);
564 EdgeMin.Min[4] = (Standard_Integer)( (myDeca[ 4] + TotMin[ 4]) * mySurD[ 4]);
565 EdgeMax.Min[4] = (Standard_Integer)( (myDeca[ 4] + TotMax[ 4]) * mySurD[ 4]);
566 EdgeMin.Min[5] = (Standard_Integer)( (myDeca[ 5] + TotMin[ 5]) * mySurD[ 5]);
567 EdgeMax.Min[5] = (Standard_Integer)( (myDeca[ 5] + TotMax[ 5]) * mySurD[ 5]);
568 EdgeMin.Min[6] = (Standard_Integer)( (myDeca[ 6] + TotMin[ 6]) * mySurD[ 6]);
569 EdgeMax.Min[6] = (Standard_Integer)( (myDeca[ 6] + TotMax[ 6]) * mySurD[ 6]);
570 EdgeMin.Min[7] = (Standard_Integer)( (myDeca[ 7] + TotMin[ 7]) * mySurD[ 7]);
571 EdgeMax.Min[7] = (Standard_Integer)( (myDeca[ 7] + TotMax[ 7]) * mySurD[ 7]);
572 EdgeMin.Max[0] = (Standard_Integer)( (myDeca[ 8] + TotMin[ 8]) * mySurD[ 8]);
573 EdgeMax.Max[0] = (Standard_Integer)( (myDeca[ 8] + TotMax[ 8]) * mySurD[ 8]);
574 EdgeMin.Max[1] = (Standard_Integer)( (myDeca[ 9] + TotMin[ 9]) * mySurD[ 9]);
575 EdgeMax.Max[1] = (Standard_Integer)( (myDeca[ 9] + TotMax[ 9]) * mySurD[ 9]);
576 EdgeMin.Max[2] = (Standard_Integer)( (myDeca[10] + TotMin[10]) * mySurD[10]);
577 EdgeMax.Max[2] = (Standard_Integer)( (myDeca[10] + TotMax[10]) * mySurD[10]);
578 EdgeMin.Max[3] = (Standard_Integer)( (myDeca[11] + TotMin[11]) * mySurD[11]);
579 EdgeMax.Max[3] = (Standard_Integer)( (myDeca[11] + TotMax[11]) * mySurD[11]);
580 EdgeMin.Max[4] = (Standard_Integer)( (myDeca[12] + TotMin[12]) * mySurD[12]);
581 EdgeMax.Max[4] = (Standard_Integer)( (myDeca[12] + TotMax[12]) * mySurD[12]);
582 EdgeMin.Max[5] = (Standard_Integer)( (myDeca[13] + TotMin[13]) * mySurD[13]);
583 EdgeMax.Max[5] = (Standard_Integer)( (myDeca[13] + TotMax[13]) * mySurD[13]);
584 EdgeMin.Max[6] = (Standard_Integer)( (myDeca[14] + TotMin[14]) * mySurD[14]);
585 EdgeMax.Max[6] = (Standard_Integer)( (myDeca[14] + TotMax[14]) * mySurD[14]);
586 EdgeMin.Max[7] = (Standard_Integer)( (myDeca[15] + TotMin[15]) * mySurD[15]);
587 EdgeMax.Max[7] = (Standard_Integer)( (myDeca[15] + TotMax[15]) * mySurD[15]);
589 HLRAlgo::EncodeMinMax(EdgeMin, EdgeMax, MinMaxEdge);
590 ed.UpdateMinMax(MinMaxEdge);
592 ver1 = Standard_True;
593 ver2 = Standard_True;
594 Standard_Integer vsta = ed.VSta();
595 Standard_Integer vend = ed.VEnd();
596 Standard_Boolean vout = ed.OutLVSta() || ed.OutLVEnd();
597 Standard_Boolean vcut = ed.CutAtSta() || ed.CutAtEnd();
599 for (Standard_Integer ebis = 1; ebis <= myNbEdges; ebis++) {
600 HLRBRep_EdgeData& eb = myEData.ChangeValue(ebis);
601 if (vsta == eb.VSta()) {
606 else if (vsta == eb.VEnd()) {
616 EC.D1(EC.Parameter3d(EC.FirstParameter()),Pt,Tg1);
617 EC.D1(EC.Parameter3d(EC.LastParameter ()),Pt,Tg2);
620 if (Abs(Tg1.X()) + Abs(Tg1.Y()) < myToler * 10) ver1 = Standard_True;
623 ver1 = Abs(Dir1.X()) + Abs(Dir1.Y()) < myToler * 10;
625 if (Abs(Tg2.X()) + Abs(Tg2.Y()) < myToler * 10) ver2 = Standard_True;
628 ver2 = Abs(Dir2.X()) + Abs(Dir2.Y()) < myToler * 10;
631 ed.VerAtSta(ed.Vertical() || ver1);
632 ed.VerAtEnd(ed.Vertical() || ver2);
633 ed.AutoIntersectionDone(Standard_True);
634 ed.Simple(Standard_True);
640 for (Standard_Integer face = 1; face <= myNbFaces; face++) {
642 HLRBRep_FaceData& fd = myFData.ChangeValue(face);
643 HLRBRep_Surface& FS = fd.Geometry();
644 iFaceGeom = &(fd.Geometry());
645 mySLProps.SetSurface(iFaceGeom);
646 FS.Projector(&myProj);
647 iFaceType = FS.GetType();
649 // Is the face cut by an outline
651 Standard_Boolean cut = Standard_False;
652 Standard_Boolean withOutL = Standard_False;
654 for (myFaceItr1.InitEdge(fd);
655 myFaceItr1.MoreEdge();
656 myFaceItr1.NextEdge()) {
657 if (myFaceItr1.Internal()) {
658 withOutL = Standard_True;
661 else if (myFaceItr1.OutLine()) {
662 withOutL = Standard_True;
663 if (myFaceItr1.Double()) cut = Standard_True;
667 fd.WithOutL(withOutL);
669 // Is the face simple = no auto-hiding
670 // not cut and simple surface
673 (iFaceType == GeomAbs_Plane ||
674 iFaceType == GeomAbs_Cylinder ||
675 iFaceType == GeomAbs_Cone ||
676 iFaceType == GeomAbs_Sphere ||
677 iFaceType == GeomAbs_Torus )) fd.Simple(Standard_True );
678 else fd.Simple(Standard_False);
680 fd.Plane (iFaceType == GeomAbs_Plane );
681 fd.Cylinder(iFaceType == GeomAbs_Cylinder);
682 fd.Cone (iFaceType == GeomAbs_Cone );
683 fd.Sphere (iFaceType == GeomAbs_Sphere );
684 fd.Torus (iFaceType == GeomAbs_Torus );
685 tol = (Standard_Real)(fd.Tolerance());
686 fd.Side(FS.IsSide(tol,myToler*10));
687 Standard_Boolean inverted = Standard_False;
688 if (fd.WithOutL() && !fd.Side()) {
689 inverted = OrientOutLine(face,fd);
690 OrientOthEdge(face,fd);
693 fd.Hiding(Standard_False);
694 fd.Back(Standard_False);
696 else if (!fd.WithOutL()) {
697 Standard_Real p,pu,pv,r;
698 fd.Back(Standard_False);
699 Standard_Boolean found = Standard_False;
701 for (myFaceItr1.InitEdge(fd);
702 myFaceItr1.MoreEdge() && !found;
703 myFaceItr1.NextEdge()) {
704 myFE = myFaceItr1.Edge ();
705 myFEOri = myFaceItr1.Orientation();
706 myFEOutLine = myFaceItr1.OutLine ();
707 myFEInternal = myFaceItr1.Internal ();
708 myFEDouble = myFaceItr1.Double ();
709 HLRBRep_EdgeData& EDataFE1 = myEData(myFE);
711 (myFEOri == TopAbs_FORWARD ||
712 myFEOri == TopAbs_REVERSED)) {
713 myFEGeom = &(EDataFE1.ChangeGeometry());
714 const HLRBRep_Curve& EC = EDataFE1.Geometry();
715 p = EC.Parameter3d((EC.LastParameter () +
716 EC.FirstParameter()) / 2);
717 if (HLRBRep_EdgeFaceTool::UVPoint(p,myFEGeom,iFaceGeom,pu,pv)) {
718 mySLProps.SetParameters(pu,pv);
721 if (mySLProps.IsNormalDefined())
723 gp_Vec Nm = mySLProps.Normal();
726 if (myProj.Perspective()) {
727 r = Nm.Z() * myProj.Focus() -
728 ( Nm.X() * Pt.X() + Nm.Y() * Pt.Y() + Nm.Z() * Pt.Z() );
731 if (Abs(r) > myToler*10) {
733 found = Standard_True;
742 fd.Side(Standard_True);
743 fd.Hiding(Standard_False);
744 fd.Back(Standard_False);
746 else if (fd.Closed()) {
747 switch (fd.Orientation()) {
748 case TopAbs_REVERSED : fd.Hiding( fd.Back() ); break;
749 case TopAbs_FORWARD : fd.Hiding(!fd.Back() ); break;
750 case TopAbs_EXTERNAL : fd.Hiding(Standard_True ); break;
751 case TopAbs_INTERNAL : fd.Hiding(Standard_False); break;
754 else fd.Hiding(Standard_True);
758 fd.Hiding(Standard_False);
759 fd.Back(Standard_True);
762 fd.Hiding(Standard_True);
763 fd.Back(Standard_False);
767 Standard_Boolean FirstTime = Standard_True;
769 for (myFaceItr1.InitEdge(fd);
770 myFaceItr1.MoreEdge();
771 myFaceItr1.NextEdge()) {
772 myFE = myFaceItr1.Edge();
773 HLRBRep_EdgeData& EDataFE2 = myEData(myFE);
774 if (!fd.Simple()) EDataFE2.AutoIntersectionDone(Standard_False);
775 HLRAlgo::DecodeMinMax(EDataFE2.MinMax(), EdgeMin, EdgeMax);
776 if (myFaceItr1.BeginningOfWire())
777 HLRAlgo::CopyMinMax(EdgeMin, EdgeMax, WireMin, WireMax);
779 HLRAlgo::AddMinMax(EdgeMin, EdgeMax, WireMin, WireMax);
780 if (myFaceItr1.EndOfWire()) {
781 HLRAlgo::EncodeMinMax(WireMin, WireMax, MinMaxWire);
782 myFaceItr1.Wire()->UpdateMinMax(MinMaxWire);
784 FirstTime = Standard_False;
785 HLRAlgo::CopyMinMax(WireMin, WireMax, FaceMin, FaceMax);
788 HLRAlgo::AddMinMax(WireMin, WireMax, FaceMin, FaceMax);
791 HLRAlgo::EncodeMinMax(FaceMin, FaceMax, MinMaxFace);
792 fd.Wires()->UpdateMinMax(MinMaxFace);
793 fd.Size(HLRAlgo::SizeBox(FaceMin,FaceMax));
797 //=======================================================================
798 //function : InitBoundSort
800 //=======================================================================
803 HLRBRep_Data::InitBoundSort (const HLRAlgo_EdgesBlock::MinMaxIndices& MinMaxTot,
804 const Standard_Integer e1,
805 const Standard_Integer e2)
808 const HLRAlgo_EdgesBlock::MinMaxIndices& MinMaxShap = MinMaxTot;
810 for (Standard_Integer e = e1; e <= e2; e++) {
811 HLRBRep_EdgeData& ed = myEData(e);
812 if (!ed.Status().AllHidden()) {
813 myLEMinMax = &ed.MinMax();
814 if (((MinMaxShap.Max[0] - myLEMinMax->Min[0]) & 0x80008000) == 0 &&
815 ((myLEMinMax->Max[0] - MinMaxShap.Min[0]) & 0x80008000) == 0 &&
816 ((MinMaxShap.Max[1] - myLEMinMax->Min[1]) & 0x80008000) == 0 &&
817 ((myLEMinMax->Max[1] - MinMaxShap.Min[1]) & 0x80008000) == 0 &&
818 ((MinMaxShap.Max[2] - myLEMinMax->Min[2]) & 0x80008000) == 0 &&
819 ((myLEMinMax->Max[2] - MinMaxShap.Min[2]) & 0x80008000) == 0 &&
820 ((MinMaxShap.Max[3] - myLEMinMax->Min[3]) & 0x80008000) == 0 &&
821 ((myLEMinMax->Max[3] - MinMaxShap.Min[3]) & 0x80008000) == 0 &&
822 ((MinMaxShap.Max[4] - myLEMinMax->Min[4]) & 0x80008000) == 0 &&
823 ((myLEMinMax->Max[4] - MinMaxShap.Min[4]) & 0x80008000) == 0 &&
824 ((MinMaxShap.Max[5] - myLEMinMax->Min[5]) & 0x80008000) == 0 &&
825 ((myLEMinMax->Max[5] - MinMaxShap.Min[5]) & 0x80008000) == 0 &&
826 ((MinMaxShap.Max[6] - myLEMinMax->Min[6]) & 0x80008000) == 0 &&
827 ((myLEMinMax->Max[6] - MinMaxShap.Min[6]) & 0x80008000) == 0 &&
828 ((MinMaxShap.Max[7] - myLEMinMax->Min[7]) & 0x80008000) == 0) { //- rejection en z
830 myEdgeIndices(myNbrSortEd) = e;
836 //=======================================================================
837 //function : InitEdge
839 //=======================================================================
840 void HLRBRep_Data::InitEdge (const Standard_Integer FI,
841 BRepTopAdaptor_MapOfShapeTool& MST)
847 iFaceData = &myFData(iFace);
848 iFaceGeom = &iFaceData->Geometry();
849 iFaceBack = iFaceData->Back();
850 iFaceSimp = iFaceData->Simple();
851 iFaceMinMax = &iFaceData->Wires()->MinMax();
852 iFaceType = ((HLRBRep_Surface*)iFaceGeom)->GetType();
853 iFaceTest = !iFaceSimp;
854 mySLProps.SetSurface(iFaceGeom);
855 myIntersector.Load(iFaceGeom);
858 HLRBRep_Surface *p1 = (HLRBRep_Surface*)iFaceGeom;
859 const BRepAdaptor_Surface& bras=p1->Surface();
862 const TopoDS_Face& topodsface=bras.Face();
867 if(MST.IsBound(topodsface)) {
868 BRepTopAdaptor_Tool& BRT = MST.ChangeFind(topodsface);
869 myClassifier = BRT.GetTopolTool();
872 BRepTopAdaptor_Tool BRT(topodsface,Precision::PConfusion());
873 MST.Bind(topodsface,BRT);
874 myClassifier = BRT.GetTopolTool();
878 iFaceSmpl = !iFaceData->Cut();
879 myFaceItr2.InitEdge(*iFaceData);
883 for (myFaceItr1.InitEdge(*iFaceData);
884 myFaceItr1.MoreEdge();
885 myFaceItr1.NextEdge()) {
886 myFE = myFaceItr1.Edge(); // edges of a simple hiding
887 myEData(myFE).HideCount(myHideCount-1); // face must be jumped.
891 NextEdge(Standard_False);
894 //=======================================================================
895 //function : MoreEdge
897 //=======================================================================
899 Standard_Boolean HLRBRep_Data::MoreEdge ()
904 if (myFaceItr2.MoreEdge()) { // all edges must be tested if
905 myLE = myFaceItr2.Edge (); // the face is not a simple
906 myLEOutLine = myFaceItr2.OutLine (); // one.
907 myLEInternal = myFaceItr2.Internal();
908 myLEDouble = myFaceItr2.Double ();
909 myLEIsoLine = myFaceItr2.IsoLine ();
910 myLEData = &myEData(myLE);
911 myLEGeom = &myLEData->ChangeGeometry();
912 myLEMinMax = &myLEData->MinMax();
913 myLETol = myLEData->Tolerance();
914 myLEType = myLEGeom->GetType();
916 myLEData->HideCount(myHideCount-1);
917 return Standard_True;
920 iFaceTest = Standard_False; // at the end of the test
921 iFaceSimp = iFaceSmpl; // we know if it is a simple face
922 iFaceData->Simple(iFaceSimp);
924 NextEdge(Standard_False);
927 return myCurSortEd <= myNbrSortEd;
929 //=======================================================================
930 //function : NextEdge
932 //=======================================================================
934 void HLRBRep_Data::NextEdge (const Standard_Boolean skip)
938 if (iFaceTest) myFaceItr2.NextEdge();
941 if (!MoreEdge()) return;
943 myLE = myFaceItr2.Edge ();
944 myLEOutLine = myFaceItr2.OutLine ();
945 myLEInternal = myFaceItr2.Internal();
946 myLEDouble = myFaceItr2.Double ();
947 myLEIsoLine = myFaceItr2.IsoLine ();
948 myLEData = &myEData(myLE);
949 myLEGeom = &myLEData->ChangeGeometry();
950 myLEMinMax = &myLEData->MinMax();
951 myLETol = myLEData->Tolerance();
952 myLEType = myLEGeom->GetType();
953 if (((HLRBRep_EdgeData*)myLEData)->Vertical() ||
955 ((HLRBRep_EdgeData*)myLEData)->HideCount() == myHideCount-1))
957 ((HLRBRep_EdgeData*)myLEData)->HideCount(myHideCount-1);
962 myLEOutLine = Standard_False;
963 myLEInternal = Standard_False;
964 myLEDouble = Standard_False;
965 myLEIsoLine = Standard_False;
966 myLEData = &myEData(myLE);
967 myLEGeom = &myLEData->ChangeGeometry();
968 myLEMinMax = &myLEData->MinMax();
969 myLETol = myLEData->Tolerance();
970 myLEType = myLEGeom->GetType();
972 if (((HLRBRep_EdgeData*)myLEData)->Vertical()) {
976 if (((HLRBRep_EdgeData*)myLEData)->HideCount() > myHideCount-2) {
980 if (((HLRBRep_EdgeData*)myLEData)->Status().AllHidden()) {
984 if (((iFaceMinMax->Max[0] - myLEMinMax->Min[0]) & 0x80008000) != 0 ||
985 ((myLEMinMax->Max[0] - iFaceMinMax->Min[0]) & 0x80008000) != 0 ||
986 ((iFaceMinMax->Max[1] - myLEMinMax->Min[1]) & 0x80008000) != 0 ||
987 ((myLEMinMax->Max[1] - iFaceMinMax->Min[1]) & 0x80008000) != 0 ||
988 ((iFaceMinMax->Max[2] - myLEMinMax->Min[2]) & 0x80008000) != 0 ||
989 ((myLEMinMax->Max[2] - iFaceMinMax->Min[2]) & 0x80008000) != 0 ||
990 ((iFaceMinMax->Max[3] - myLEMinMax->Min[3]) & 0x80008000) != 0 ||
991 ((myLEMinMax->Max[3] - iFaceMinMax->Min[3]) & 0x80008000) != 0 ||
992 ((iFaceMinMax->Max[4] - myLEMinMax->Min[4]) & 0x80008000) != 0 ||
993 ((myLEMinMax->Max[4] - iFaceMinMax->Min[4]) & 0x80008000) != 0 ||
994 ((iFaceMinMax->Max[5] - myLEMinMax->Min[5]) & 0x80008000) != 0 ||
995 ((myLEMinMax->Max[5] - iFaceMinMax->Min[5]) & 0x80008000) != 0 ||
996 ((iFaceMinMax->Max[6] - myLEMinMax->Min[6]) & 0x80008000) != 0 ||
997 ((myLEMinMax->Max[6] - iFaceMinMax->Min[6]) & 0x80008000) != 0 ||
998 ((iFaceMinMax->Max[7] - myLEMinMax->Min[7]) & 0x80008000) != 0) { //-- rejection en z
1002 if (((HLRBRep_Surface*)iFaceGeom)->IsAbove
1003 (iFaceBack,myLEGeom,(Standard_Real)myLETol)) {
1007 return; // edge is OK
1010 //=======================================================================
1013 //=======================================================================
1015 Standard_Integer HLRBRep_Data::Edge () const
1017 if (iFaceTest) return myFaceItr2.Edge();
1018 else return myEdgeIndices(myCurSortEd);
1021 //=======================================================================
1022 //function : InitInterference
1024 //=======================================================================
1026 void HLRBRep_Data::InitInterference ()
1028 myLLProps.SetCurve(myLEGeom);
1029 myFaceItr1.InitEdge(*((HLRBRep_FaceData*)iFaceData));
1030 myNbPoints = myNbSegments = iInterf = 0;
1034 //=======================================================================
1035 //function : NextInterference
1037 //=======================================================================
1039 void HLRBRep_Data::NextInterference ()
1041 // are there more intersections on the current edge
1043 // Standard_Integer miniWire1,miniWire2;
1044 // Standard_Integer maxiWire1,maxiWire2,maxiWire3,maxiWire4;
1046 while (!MoreInterference() && myFaceItr1.MoreEdge()) {
1048 // rejection of current wire
1049 if (myFaceItr1.BeginningOfWire()) {
1050 HLRAlgo_EdgesBlock::MinMaxIndices& MinMaxWire = myFaceItr1.Wire()->MinMax();
1051 if (((MinMaxWire.Max[0] - myLEMinMax->Min[0]) & 0x80008000) != 0 ||
1052 ((myLEMinMax->Max[0] - MinMaxWire.Min[0]) & 0x80008000) != 0 ||
1053 ((MinMaxWire.Max[1] - myLEMinMax->Min[1]) & 0x80008000) != 0 ||
1054 ((myLEMinMax->Max[1] - MinMaxWire.Min[1]) & 0x80008000) != 0 ||
1055 ((MinMaxWire.Max[2] - myLEMinMax->Min[2]) & 0x80008000) != 0 ||
1056 ((myLEMinMax->Max[2] - MinMaxWire.Min[2]) & 0x80008000) != 0 ||
1057 ((MinMaxWire.Max[3] - myLEMinMax->Min[3]) & 0x80008000) != 0 ||
1058 ((myLEMinMax->Max[3] - MinMaxWire.Min[3]) & 0x80008000) != 0 ||
1059 ((MinMaxWire.Max[4] - myLEMinMax->Min[4]) & 0x80008000) != 0 ||
1060 ((myLEMinMax->Max[4] - MinMaxWire.Min[4]) & 0x80008000) != 0 ||
1061 ((MinMaxWire.Max[5] - myLEMinMax->Min[5]) & 0x80008000) != 0 ||
1062 ((myLEMinMax->Max[5] - MinMaxWire.Min[5]) & 0x80008000) != 0 ||
1063 ((MinMaxWire.Max[6] - myLEMinMax->Min[6]) & 0x80008000) != 0 ||
1064 ((myLEMinMax->Max[6] - MinMaxWire.Min[6]) & 0x80008000) != 0 ||
1065 ((MinMaxWire.Max[7] - myLEMinMax->Min[7]) & 0x80008000) != 0) { //-- Rejection en Z
1066 myFaceItr1.SkipWire();
1070 myFE = myFaceItr1.Edge();
1071 myFEOri = myFaceItr1.Orientation();
1072 myFEOutLine = myFaceItr1.OutLine ();
1073 myFEInternal = myFaceItr1.Internal ();
1074 myFEDouble = myFaceItr1.Double ();
1075 myFEData = &myEData(myFE);
1076 myFEGeom = &(((HLRBRep_EdgeData*)myFEData)->ChangeGeometry());
1077 myFETol = ((HLRBRep_EdgeData*)myFEData)->Tolerance();
1078 myFEType = ((HLRBRep_Curve *)myFEGeom)->GetType();
1081 if (myFEOri == TopAbs_FORWARD ||
1082 myFEOri == TopAbs_REVERSED) {
1083 // Edge from the boundary
1084 if (!((HLRBRep_EdgeData*)myFEData)->Vertical() && !(myFEDouble && !myFEOutLine)) {
1085 // not a vertical edge and not a double Edge
1086 HLRAlgo_EdgesBlock::MinMaxIndices* MinMaxFEdg = &((HLRBRep_EdgeData*)myFEData)->MinMax();
1087 //-- -----------------------------------------------------------------------
1088 //-- Max - Min doit etre positif pour toutes les directions
1090 //-- Rejection 1 (FEMax-LEMin)& 0x80008000 !=0
1092 //-- FE Min ........... FE Max
1093 //-- LE Min .... LE Max
1095 //-- Rejection 2 (LEMax-FEMin)& 0x80008000 !=0
1096 //-- FE Min ........... FE Max
1097 //-- LE Min .... LE Max
1098 //-- ----------------------------------------------------------------------
1100 if(((TableauRejection *)myReject)->
1101 NoIntersection(myLE,myFE) == Standard_False) {
1104 if (((MinMaxFEdg->Max[0] - myLEMinMax->Min[0]) & 0x80008000) == 0 &&
1105 ((myLEMinMax->Max[0] - MinMaxFEdg->Min[0]) & 0x80008000) == 0 &&
1106 ((MinMaxFEdg->Max[1] - myLEMinMax->Min[1]) & 0x80008000) == 0 &&
1107 ((myLEMinMax->Max[1] - MinMaxFEdg->Min[1]) & 0x80008000) == 0 &&
1108 ((MinMaxFEdg->Max[2] - myLEMinMax->Min[2]) & 0x80008000) == 0 &&
1109 ((myLEMinMax->Max[2] - MinMaxFEdg->Min[2]) & 0x80008000) == 0 &&
1110 ((MinMaxFEdg->Max[3] - myLEMinMax->Min[3]) & 0x80008000) == 0 &&
1111 ((myLEMinMax->Max[3] - MinMaxFEdg->Min[3]) & 0x80008000) == 0 &&
1112 ((MinMaxFEdg->Max[4] - myLEMinMax->Min[4]) & 0x80008000) == 0 &&
1113 ((myLEMinMax->Max[4] - MinMaxFEdg->Min[4]) & 0x80008000) == 0 &&
1114 ((MinMaxFEdg->Max[5] - myLEMinMax->Min[5]) & 0x80008000) == 0 &&
1115 ((myLEMinMax->Max[5] - MinMaxFEdg->Min[5]) & 0x80008000) == 0 &&
1116 ((MinMaxFEdg->Max[6] - myLEMinMax->Min[6]) & 0x80008000) == 0 &&
1117 ((myLEMinMax->Max[6] - MinMaxFEdg->Min[6]) & 0x80008000) == 0 &&
1118 ((MinMaxFEdg->Max[7] - myLEMinMax->Min[7]) & 0x80008000) == 0) { //-- Rejection en Z
1119 // not rejected perform intersection
1120 Standard_Boolean rej = Standard_False;
1121 if (myLE == myFE) { // test if an auto-intersection is not usefull
1122 if (((HLRBRep_EdgeData*)myLEData)->AutoIntersectionDone()) {
1123 ((HLRBRep_EdgeData*)myLEData)->
1124 AutoIntersectionDone(Standard_True);
1125 if (((HLRBRep_EdgeData*)myLEData)->Simple()) {
1126 rej = Standard_True;
1131 nbCal1Intersection++;
1132 Standard_Boolean h1 = Standard_False;
1133 Standard_Boolean e1 = Standard_False;
1134 Standard_Boolean h2 = Standard_False;
1135 Standard_Boolean e2 = Standard_False;
1136 mySameVertex = Standard_False;
1139 myIntersected = Standard_True;
1140 mySameVertex = Standard_False;
1143 myIntersected = Standard_True;
1144 if (SameVertex(Standard_True ,Standard_True )) {
1145 mySameVertex = Standard_True;
1149 if (SameVertex(Standard_True ,Standard_False)) {
1150 mySameVertex = Standard_True;
1154 if (SameVertex(Standard_False,Standard_True )) {
1155 mySameVertex = Standard_True;
1159 if (SameVertex(Standard_False,Standard_False)) {
1160 mySameVertex = Standard_True;
1166 myNbPoints = myNbSegments = 0;
1169 if (myIntersected) { // compute real intersection
1170 nbCal2Intersection++;
1172 Standard_Real da1 = 0;
1173 Standard_Real db1 = 0;
1174 Standard_Real da2 = 0;
1175 Standard_Real db2 = 0;
1177 if (mySameVertex || myLE == myFE) {
1178 if (h1) da1 = CutLar;
1179 if (e1) db1 = CutLar;
1180 if (h2) da2 = CutLar;
1181 if (e2) db2 = CutLar;
1183 Standard_Integer NoInter=0;
1185 myIntersector.Perform(myLEData,da1,db1);
1188 Standard_Real su,sv;
1189 ((TableauRejection *)myReject)->
1190 GetSingleIntersection(myLE,myFE,su,sv);
1191 if(su!=RealLast()) {
1192 myIntersector.SimulateOnePoint(myLEData,su,myFEData,sv);
1196 myIntersector.Perform
1197 (myLE,myLEData,da1,db1,
1198 myFE,myFEData,da2,db2,mySameVertex);
1199 if(myIntersector.IsDone()) {
1200 if(myIntersector.NbPoints() == 1 &&
1201 myIntersector.NbSegments()==0) {
1202 ((TableauRejection *)myReject)->
1203 SetIntersection(myLE,myFE,myIntersector.Point(1));
1210 myNbPoints = myNbSegments = 0;
1213 if (myIntersector.IsDone()) {
1214 myNbPoints = myIntersector.NbPoints();
1215 myNbSegments = myIntersector.NbSegments();
1216 if ((myNbSegments + myNbPoints) > 0) {
1220 ((TableauRejection *)myReject)->
1221 SetNoIntersection(myLE,myFE);
1225 myNbPoints = myNbSegments = 0;
1227 cout << "HLRBRep_Data::NextInterference : ";
1229 cout << "Edge " << myLE
1230 << " : Intersection not done" << endl;
1232 cout << "Edges " << myLE << " , " << myFE
1233 << " : Intersection not done" << endl;
1238 nbPtIntersection += myNbPoints;
1239 nbSegIntersection += myNbSegments;
1244 printf("\n Rejection myFE:%5d myLE:%5d\n",myFE,myLE);
1253 // next edge in face
1254 myFaceItr1.NextEdge();
1258 //=======================================================================
1259 //function : RejectedInterference
1261 //=======================================================================
1263 Standard_Boolean HLRBRep_Data::RejectedInterference ()
1265 if (iInterf <= myNbPoints) {
1266 return RejectedPoint(myIntersector.Point(iInterf),
1270 Standard_Integer n = iInterf - myNbPoints;
1271 Standard_Boolean firstPoint = (n & 1) != 0;
1272 Standard_Integer nseg=n>>1;
1275 Standard_Real pf = ((HLRBRep_Curve*)myLEGeom)->Parameter3d
1276 (myIntersector.Segment(nseg).FirstPoint().ParamOnFirst());
1277 Standard_Real pl = ((HLRBRep_Curve*)myLEGeom)->Parameter3d
1278 (myIntersector.Segment(nseg).LastPoint ().ParamOnFirst());
1280 firstPoint = !firstPoint;
1283 Standard_Boolean ret1 = RejectedPoint
1284 (myIntersector.Segment(nseg).FirstPoint(),TopAbs_FORWARD,nseg);
1288 Standard_Boolean ret2 = RejectedPoint
1289 (myIntersector.Segment(nseg).LastPoint (),TopAbs_REVERSED,-nseg);
1295 //=======================================================================
1296 //function : AboveInterference
1298 //=======================================================================
1300 Standard_Boolean HLRBRep_Data::AboveInterference ()
1301 { return myAboveIntf; }
1303 //=======================================================================
1304 //function : LocalLEGeometry2D
1306 //=======================================================================
1308 void HLRBRep_Data::LocalLEGeometry2D (const Standard_Real Param,
1313 myLLProps.SetParameter(Param);
1314 if (!myLLProps.IsTangentDefined())
1315 throw Standard_Failure("HLRBRep_Data::LocalGeometry2D");
1316 myLLProps.Tangent(Tg);
1317 Cu = myLLProps.Curvature();
1318 if (Cu > Epsilon(1.) && !Precision::IsInfinite(Cu)) myLLProps.Normal(Nm);
1319 else Nm = gp_Dir2d(-Tg.Y(),Tg.X());
1322 //=======================================================================
1323 //function : LocalFEGeometry2D
1325 //=======================================================================
1327 void HLRBRep_Data::LocalFEGeometry2D (const Standard_Integer FE,
1328 const Standard_Real Param,
1333 const HLRBRep_Curve* aCurve = &myEData(FE).ChangeGeometry();
1334 myFLProps.SetCurve(aCurve);
1335 myFLProps.SetParameter(Param);
1336 if (!myFLProps.IsTangentDefined())
1337 throw Standard_Failure("HLRBRep_Data::LocalGeometry2D");
1338 myFLProps.Tangent(Tg);
1339 Cu = myFLProps.Curvature();
1340 if (Cu > Epsilon(1.) && !Precision::IsInfinite(Cu)) myFLProps.Normal(Nm);
1341 else Nm = gp_Dir2d(-Tg.Y(),Tg.X());
1344 //=======================================================================
1345 //function : EdgeState
1347 //=======================================================================
1349 void HLRBRep_Data::EdgeState (const Standard_Real p1,
1350 const Standard_Real p2,
1351 TopAbs_State& stbef,
1352 TopAbs_State& staft)
1354 // compute the state of The Edge near the Intersection
1355 // this method should give the states before and after
1356 // it should get the parameters on the surface
1358 Standard_Real pu,pv;
1359 if (HLRBRep_EdgeFaceTool::UVPoint(p2,myFEGeom,iFaceGeom,pu,pv))
1361 mySLProps.SetParameters(pu,pv);
1362 if (mySLProps.IsNormalDefined())
1364 gp_Dir NrmFace = mySLProps.Normal();
1368 ((HLRBRep_Curve*)myLEGeom)->D1(p1,Pbid,TngEdge);
1370 const gp_Trsf& TI = myProj.InvertedTransformation();
1372 if (myProj.Perspective()) {
1374 myProj.Project(Pbid,P2d);
1375 V = gp_Dir(P2d.X(),P2d.Y(),-myProj.Focus());
1381 if (NrmFace.Dot(V) > 0.)
1384 const Standard_Real scal = (TngEdge.SquareMagnitude()>1.e-10)? NrmFace.Dot(gp_Dir(TngEdge)) : 0.;
1386 if (scal > myToler*10) {stbef = TopAbs_IN ;staft = TopAbs_OUT;}
1387 else if (scal < -myToler*10) {stbef = TopAbs_OUT;staft = TopAbs_IN ;}
1388 else {stbef = TopAbs_ON ;staft = TopAbs_ON ;}
1394 cout << "HLRBRep_Data::EdgeState : undefined" << endl;
1402 cout << "HLRBRep_Data::EdgeState : undefined" << endl;
1407 //=======================================================================
1408 //function : HidingStartLevel
1410 //=======================================================================
1413 HLRBRep_Data::HidingStartLevel (const Standard_Integer E,
1414 const HLRBRep_EdgeData& ED,
1415 const HLRAlgo_InterferenceList& IL)
1417 Standard_Boolean Loop;
1418 HLRAlgo_ListIteratorOfInterferenceList It;
1419 const HLRBRep_Curve& EC = ED.Geometry();
1420 Standard_Real sta = EC.Parameter3d(EC.FirstParameter());
1421 Standard_Real end = EC.Parameter3d(EC.LastParameter());
1422 Standard_Real tolpar = (end - sta) * 0.01;
1423 Standard_Real param;
1424 Loop = Standard_True;
1427 while(It.More() && Loop) {
1428 param = It.Value().Intersection().Parameter();
1430 Loop = Standard_False;
1432 if (Abs(param-sta) > Abs(param-end))
1439 param = 0.5 * (sta + end);
1440 Standard_Integer level = 0;
1441 /*TopAbs_State st = */Classify(E,ED,Standard_True,level,param);
1442 Loop = Standard_True;
1445 while(It.More() && Loop) {
1446 HLRAlgo_Interference& Int = It.Value();
1447 Standard_Real p = Int.Intersection().Parameter();
1448 if (p < param - tolpar) {
1449 switch (Int.Transition()) {
1451 case TopAbs_FORWARD :
1452 level -= Int.Intersection().Level();
1454 case TopAbs_REVERSED :
1455 level += Int.Intersection().Level();
1457 case TopAbs_EXTERNAL :
1458 case TopAbs_INTERNAL :
1463 else if (p > param + tolpar)
1464 Loop = Standard_False;
1467 cout << "HLRBRep_Data::HidingStartLevel : ";
1468 cout << "Bad Parameter." << endl;
1476 //=======================================================================
1477 //function : Compare
1479 //=======================================================================
1481 TopAbs_State HLRBRep_Data::Compare (const Standard_Integer E,
1482 const HLRBRep_EdgeData& ED)
1484 Standard_Integer level = 0;
1485 Standard_Real parbid = 0.;
1486 return Classify(E,ED,Standard_False,level,parbid);
1489 //=======================================================================
1490 //function : OrientOutLine
1492 //=======================================================================
1495 Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer I, HLRBRep_FaceData& FD)
1497 (void)I; // avoid compiler warning
1499 const Handle(HLRAlgo_WiresBlock)& wb = FD.Wires();
1500 Standard_Integer nw = wb->NbWires();
1501 Standard_Integer iw1,ie1,ne1;
1502 const gp_Trsf& T = myProj.Transformation();
1503 const gp_Trsf& TI = myProj.InvertedTransformation();
1504 Standard_Boolean inverted = Standard_False;
1505 Standard_Boolean FirstInversion = Standard_True;
1507 for (iw1 = 1; iw1 <= nw; iw1++) {
1508 const Handle(HLRAlgo_EdgesBlock)& eb1 = wb->Wire(iw1);
1509 ne1 = eb1->NbEdges();
1511 for (ie1 = 1; ie1 <= ne1; ie1++) {
1512 myFE = eb1->Edge(ie1);
1513 HLRBRep_EdgeData& ed1 = myEData(myFE);
1514 if (eb1->Double (ie1) ||
1515 eb1->IsoLine(ie1) ||
1516 ed1.Vertical()) ed1.Used(Standard_True );
1517 else ed1.Used(Standard_False);
1518 if ((eb1->OutLine(ie1) || eb1->Internal(ie1)) &&
1520 Standard_Real p,pu,pv,r;
1521 myFEGeom = &(ed1.ChangeGeometry());
1522 const HLRBRep_Curve& EC = ed1.Geometry();
1523 Standard_Integer vsta = ed1.VSta();
1524 Standard_Integer vend = ed1.VEnd();
1527 else if (vsta == 0) p = EC.Parameter3d(EC.LastParameter ());
1528 else if (vend == 0) p = EC.Parameter3d(EC.FirstParameter());
1529 else p = EC.Parameter3d((EC.LastParameter () +
1530 EC.FirstParameter()) / 2);
1531 if (HLRBRep_EdgeFaceTool::UVPoint(p,myFEGeom,iFaceGeom,pu,pv)) {
1534 mySLProps.SetParameters(pu,pv);
1537 if (myProj.Perspective()) {
1539 myProj.Project(Pt,P2d);
1540 V = gp_Dir(P2d.X(),P2d.Y(),-myProj.Focus());
1546 Standard_Real curv = HLRBRep_EdgeFaceTool::CurvatureValue
1547 (iFaceGeom,pu,pv,V);
1548 gp_Vec Nm = mySLProps.Normal();
1551 cout << "HLRBRep_Data::OrientOutLine " << I;
1552 cout << " Edge " << myFE << " : ";
1553 cout << "CurvatureValue == 0." << endl;
1562 if (Tg.Magnitude() < gp::Resolution()) {
1564 cout << "HLRBRep_Data::OrientOutLine " << I;
1565 cout << " Edge " << myFE << " : ";
1566 cout << "Tg.Magnitude() == 0." << endl;
1569 if (myProj.Perspective())
1570 r = Nm.Z() * myProj.Focus() -
1571 ( Nm.X() * Pt.X() + Nm.Y() * Pt.Y() + Nm.Z() * Pt.Z() );
1574 myFEOri = (r > 0) ? TopAbs_FORWARD : TopAbs_REVERSED;
1575 if (!FD.Cut() && FD.Closed() && FirstInversion) {
1576 if ((eb1->Orientation(ie1) == myFEOri) !=
1577 (FD.Orientation() == TopAbs_FORWARD)) {
1578 FirstInversion = Standard_False;
1579 inverted = Standard_True;
1582 eb1->Orientation(ie1,myFEOri);
1586 cout << "HLRBRep_Data::OrientOutLine " << I;
1587 cout << " Edge " << myFE << " : ";
1588 cout << "UVPoint not found, OutLine not Oriented" << endl;
1591 ed1.Used(Standard_True);
1598 //=======================================================================
1599 //function : OrientOthEdge
1601 //=======================================================================
1603 void HLRBRep_Data::OrientOthEdge (const Standard_Integer I,
1604 HLRBRep_FaceData& FD)
1606 Standard_Real p,pu,pv,r;
1607 const Handle(HLRAlgo_WiresBlock)& wb = FD.Wires();
1608 Standard_Integer nw = wb->NbWires();
1609 Standard_Integer iw1,ie1,ne1;
1610 const gp_Trsf& T = myProj.Transformation();
1612 for (iw1 = 1; iw1 <= nw; iw1++) {
1613 const Handle(HLRAlgo_EdgesBlock)& eb1 = wb->Wire(iw1);
1614 ne1 = eb1->NbEdges();
1616 for (ie1 = 1; ie1 <= ne1; ie1++) {
1617 myFE = eb1->Edge (ie1);
1618 myFEOri = eb1->Orientation(ie1);
1619 HLRBRep_EdgeData& ed1 = myEData(myFE);
1622 ed1.Used(Standard_True);
1623 myFEGeom = &(ed1.ChangeGeometry());
1624 const HLRBRep_Curve& EC = ed1.Geometry();
1625 p = EC.Parameter3d((EC.LastParameter () +
1626 EC.FirstParameter()) / 2);
1627 if (HLRBRep_EdgeFaceTool::UVPoint(p,myFEGeom,iFaceGeom,pu,pv)) {
1628 gp_Pnt Pt = EC.Value3D(p);
1629 mySLProps.SetParameters(pu,pv);
1630 gp_Vec Nm = mySLProps.Normal();
1633 if (myProj.Perspective()) {
1634 r = Nm.Z() * myProj.Focus() -
1635 ( Nm.X() * Pt.X() + Nm.Y() * Pt.Y() + Nm.Z() * Pt.Z() );
1641 myFEOri = TopAbs::Reverse(myFEOri);
1642 eb1->Orientation(ie1,myFEOri);
1647 cout << "HLRBRep_Data::OrientOthEdge " << I;
1648 cout << " Edge " << myFE << " : ";
1649 cout << "UVPoint not found, Edge not Oriented" << endl;
1652 (void)I; // avoid compiler warning
1659 //=======================================================================
1660 //function : Classify
1662 //=======================================================================
1666 static void REJECT1(
1667 const Standard_Real theDeca[],
1668 const Standard_Real theTotMin[],
1669 const Standard_Real theTotMax[],
1670 const Standard_Real theSurD[],
1671 HLRAlgo_EdgesBlock::MinMaxIndices& theVertMin,
1672 HLRAlgo_EdgesBlock::MinMaxIndices& theVertMax)
1674 theVertMin.Min[0] = (Standard_Integer)((theDeca[ 0]+theTotMin[ 0]) * theSurD[ 0]);
1675 theVertMax.Min[0] = (Standard_Integer)((theDeca[ 0]+theTotMax[ 0]) * theSurD[ 0]);
1676 theVertMin.Min[1] = (Standard_Integer)((theDeca[ 1]+theTotMin[ 1]) * theSurD[ 1]);
1677 theVertMax.Min[1] = (Standard_Integer)((theDeca[ 1]+theTotMax[ 1]) * theSurD[ 1]);
1678 theVertMin.Min[2] = (Standard_Integer)((theDeca[ 2]+theTotMin[ 2]) * theSurD[ 2]);
1679 theVertMax.Min[2] = (Standard_Integer)((theDeca[ 2]+theTotMax[ 2]) * theSurD[ 2]);
1680 theVertMin.Min[3] = (Standard_Integer)((theDeca[ 3]+theTotMin[ 3]) * theSurD[ 3]);
1681 theVertMax.Min[3] = (Standard_Integer)((theDeca[ 3]+theTotMax[ 3]) * theSurD[ 3]);
1682 theVertMin.Min[4] = (Standard_Integer)((theDeca[ 4]+theTotMin[ 4]) * theSurD[ 4]);
1683 theVertMax.Min[4] = (Standard_Integer)((theDeca[ 4]+theTotMax[ 4]) * theSurD[ 4]);
1684 theVertMin.Min[5] = (Standard_Integer)((theDeca[ 5]+theTotMin[ 5]) * theSurD[ 5]);
1685 theVertMax.Min[5] = (Standard_Integer)((theDeca[ 5]+theTotMax[ 5]) * theSurD[ 5]);
1686 theVertMin.Min[6] = (Standard_Integer)((theDeca[ 6]+theTotMin[ 6]) * theSurD[ 6]);
1687 theVertMax.Min[6] = (Standard_Integer)((theDeca[ 6]+theTotMax[ 6]) * theSurD[ 6]);
1688 theVertMin.Min[7] = (Standard_Integer)((theDeca[ 7]+theTotMin[ 7]) * theSurD[ 7]);
1689 theVertMax.Min[7] = (Standard_Integer)((theDeca[ 7]+theTotMax[ 7]) * theSurD[ 7]);
1690 theVertMin.Max[0] = (Standard_Integer)((theDeca[ 8]+theTotMin[ 8]) * theSurD[ 8]);
1691 theVertMax.Max[0] = (Standard_Integer)((theDeca[ 8]+theTotMax[ 8]) * theSurD[ 8]);
1692 theVertMin.Max[1] = (Standard_Integer)((theDeca[ 9]+theTotMin[ 9]) * theSurD[ 9]);
1693 theVertMax.Max[1] = (Standard_Integer)((theDeca[ 9]+theTotMax[ 9]) * theSurD[ 9]);
1694 theVertMin.Max[2] = (Standard_Integer)((theDeca[10]+theTotMin[10]) * theSurD[10]);
1695 theVertMax.Max[2] = (Standard_Integer)((theDeca[10]+theTotMax[10]) * theSurD[10]);
1696 theVertMin.Max[3] = (Standard_Integer)((theDeca[11]+theTotMin[11]) * theSurD[11]);
1697 theVertMax.Max[3] = (Standard_Integer)((theDeca[11]+theTotMax[11]) * theSurD[11]);
1698 theVertMin.Max[4] = (Standard_Integer)((theDeca[12]+theTotMin[12]) * theSurD[12]);
1699 theVertMax.Max[4] = (Standard_Integer)((theDeca[12]+theTotMax[12]) * theSurD[12]);
1700 theVertMin.Max[5] = (Standard_Integer)((theDeca[13]+theTotMin[13]) * theSurD[13]);
1701 theVertMax.Max[5] = (Standard_Integer)((theDeca[13]+theTotMax[13]) * theSurD[13]);
1702 theVertMin.Max[6] = (Standard_Integer)((theDeca[14]+theTotMin[14]) * theSurD[14]);
1703 theVertMax.Max[6] = (Standard_Integer)((theDeca[14]+theTotMax[14]) * theSurD[14]);
1704 theVertMin.Max[7] = (Standard_Integer)((theDeca[15]+theTotMin[15]) * theSurD[15]);
1705 theVertMax.Max[7] = (Standard_Integer)((theDeca[15]+theTotMax[15]) * theSurD[15]);
1711 HLRBRep_Data::Classify (const Standard_Integer E,
1712 const HLRBRep_EdgeData& ED,
1713 const Standard_Boolean LevelFlag,
1714 Standard_Integer& Level,
1715 const Standard_Real param)
1717 (void)E; // avoid compiler warning
1720 HLRAlgo_EdgesBlock::MinMaxIndices VertMin, VertMax, MinMaxVert;
1721 Standard_Real TotMin[16],TotMax[16];
1725 TopAbs_State state = TopAbs_OUT;
1726 // Standard_Boolean rej = Standard_False;
1727 const HLRBRep_Curve& EC = ED.Geometry();
1728 Standard_Real sta,xsta,ysta,zsta,end,xend,yend,zend;
1729 Standard_Real tol = (Standard_Real)(ED.Tolerance());
1733 myProj.Project(EC.Value3D(sta),xsta,ysta,zsta);
1735 //-- les rejections sont faites dans l intersecteur a moindre frais
1736 //-- puisque la surface sera chargee
1737 HLRAlgo::InitMinMax(Precision::Infinite(), TotMin, TotMax);
1738 HLRAlgo::UpdateMinMax(xsta,ysta,zsta, TotMin, TotMax);
1739 HLRAlgo::EnlargeMinMax(tol, TotMin, TotMax);
1740 REJECT1(myDeca, TotMin, TotMax, mySurD, VertMin, VertMax);
1742 HLRAlgo::EncodeMinMax(VertMin, VertMax, MinMaxVert);
1743 if (((iFaceMinMax->Max[0] - MinMaxVert.Min[0]) & 0x80008000) != 0 ||
1744 ((MinMaxVert.Max[0] - iFaceMinMax->Min[0]) & 0x80008000) != 0 ||
1745 ((iFaceMinMax->Max[1] - MinMaxVert.Min[1]) & 0x80008000) != 0 ||
1746 ((MinMaxVert.Max[1] - iFaceMinMax->Min[1]) & 0x80008000) != 0 ||
1747 ((iFaceMinMax->Max[2] - MinMaxVert.Min[2]) & 0x80008000) != 0 ||
1748 ((MinMaxVert.Max[2] - iFaceMinMax->Min[2]) & 0x80008000) != 0 ||
1749 ((iFaceMinMax->Max[3] - MinMaxVert.Min[3]) & 0x80008000) != 0 ||
1750 ((MinMaxVert.Max[3] - iFaceMinMax->Min[3]) & 0x80008000) != 0 ||
1751 ((iFaceMinMax->Max[4] - MinMaxVert.Min[4]) & 0x80008000) != 0 ||
1752 ((MinMaxVert.Max[4] - iFaceMinMax->Min[4]) & 0x80008000) != 0 ||
1753 ((iFaceMinMax->Max[5] - MinMaxVert.Min[5]) & 0x80008000) != 0 ||
1754 ((MinMaxVert.Max[5] - iFaceMinMax->Min[5]) & 0x80008000) != 0 ||
1755 ((iFaceMinMax->Max[6] - MinMaxVert.Min[6]) & 0x80008000) != 0 ||
1756 ((MinMaxVert.Max[6] - iFaceMinMax->Min[6]) & 0x80008000) != 0 ||
1757 ((iFaceMinMax->Max[7] - MinMaxVert.Min[7]) & 0x80008000) != 0) { //-- Rejection en Z
1762 sta = EC.Parameter3d(EC.FirstParameter());
1763 myProj.Project(EC.Value3D(sta),xsta,ysta,zsta);
1765 //-- les rejections sont faites dans l intersecteur a moindre frais
1766 //-- puisque la surface sera chargee
1767 HLRAlgo::InitMinMax(Precision::Infinite(), TotMin, TotMax);
1768 HLRAlgo::UpdateMinMax(xsta,ysta,zsta, TotMin, TotMax);
1769 HLRAlgo::EnlargeMinMax(tol, TotMin, TotMax);
1771 REJECT1(myDeca, TotMin, TotMax, mySurD, VertMin, VertMax);
1773 HLRAlgo::EncodeMinMax(VertMin, VertMax, MinMaxVert);
1774 if (((iFaceMinMax->Max[0] - MinMaxVert.Min[0]) & 0x80008000) != 0 ||
1775 ((MinMaxVert.Max[0] - iFaceMinMax->Min[0]) & 0x80008000) != 0 ||
1776 ((iFaceMinMax->Max[1] - MinMaxVert.Min[1]) & 0x80008000) != 0 ||
1777 ((MinMaxVert.Max[1] - iFaceMinMax->Min[1]) & 0x80008000) != 0 ||
1778 ((iFaceMinMax->Max[2] - MinMaxVert.Min[2]) & 0x80008000) != 0 ||
1779 ((MinMaxVert.Max[2] - iFaceMinMax->Min[2]) & 0x80008000) != 0 ||
1780 ((iFaceMinMax->Max[3] - MinMaxVert.Min[3]) & 0x80008000) != 0 ||
1781 ((MinMaxVert.Max[3] - iFaceMinMax->Min[3]) & 0x80008000) != 0 ||
1782 ((iFaceMinMax->Max[4] - MinMaxVert.Min[4]) & 0x80008000) != 0 ||
1783 ((MinMaxVert.Max[4] - iFaceMinMax->Min[4]) & 0x80008000) != 0 ||
1784 ((iFaceMinMax->Max[5] - MinMaxVert.Min[5]) & 0x80008000) != 0 ||
1785 ((MinMaxVert.Max[5] - iFaceMinMax->Min[5]) & 0x80008000) != 0 ||
1786 ((iFaceMinMax->Max[6] - MinMaxVert.Min[6]) & 0x80008000) != 0 ||
1787 ((MinMaxVert.Max[6] - iFaceMinMax->Min[6]) & 0x80008000) != 0 ||
1788 ((iFaceMinMax->Max[7] - MinMaxVert.Min[7]) & 0x80008000) != 0) { //-- Rejection en Z
1791 end = EC.Parameter3d(EC.LastParameter());
1792 myProj.Project(EC.Value3D(end),xend,yend,zend);
1794 HLRAlgo::InitMinMax(Precision::Infinite(), TotMin, TotMax);
1795 HLRAlgo::UpdateMinMax(xend,yend,zend, TotMin, TotMax);
1796 HLRAlgo::EnlargeMinMax(tol, TotMin, TotMax);
1798 REJECT1(myDeca, TotMin, TotMax, mySurD, VertMin, VertMax);
1800 HLRAlgo::EncodeMinMax(VertMin, VertMax, MinMaxVert);
1801 if (((iFaceMinMax->Max[0] - MinMaxVert.Min[0]) & 0x80008000) != 0 ||
1802 ((MinMaxVert.Max[0] - iFaceMinMax->Min[0]) & 0x80008000) != 0 ||
1803 ((iFaceMinMax->Max[1] - MinMaxVert.Min[1]) & 0x80008000) != 0 ||
1804 ((MinMaxVert.Max[1] - iFaceMinMax->Min[1]) & 0x80008000) != 0 ||
1805 ((iFaceMinMax->Max[2] - MinMaxVert.Min[2]) & 0x80008000) != 0 ||
1806 ((MinMaxVert.Max[2] - iFaceMinMax->Min[2]) & 0x80008000) != 0 ||
1807 ((iFaceMinMax->Max[3] - MinMaxVert.Min[3]) & 0x80008000) != 0 ||
1808 ((MinMaxVert.Max[3] - iFaceMinMax->Min[3]) & 0x80008000) != 0 ||
1809 ((iFaceMinMax->Max[4] - MinMaxVert.Min[4]) & 0x80008000) != 0 ||
1810 ((MinMaxVert.Max[4] - iFaceMinMax->Min[4]) & 0x80008000) != 0 ||
1811 ((iFaceMinMax->Max[5] - MinMaxVert.Min[5]) & 0x80008000) != 0 ||
1812 ((MinMaxVert.Max[5] - iFaceMinMax->Min[5]) & 0x80008000) != 0 ||
1813 ((iFaceMinMax->Max[6] - MinMaxVert.Min[6]) & 0x80008000) != 0 ||
1814 ((MinMaxVert.Max[6] - iFaceMinMax->Min[6]) & 0x80008000) != 0 ||
1815 ((iFaceMinMax->Max[7] - MinMaxVert.Min[7]) & 0x80008000) != 0) { //-- Rejection en Z
1818 sta = 0.4 * sta + 0.6 * end; // dangerous if it is the middle
1819 myProj.Project(EC.Value3D(sta),xsta,ysta,zsta);
1821 //-- les rejections sont faites dans l intersecteur a moindre frais
1822 //-- puisque la surface sera chargee
1823 HLRAlgo::InitMinMax(Precision::Infinite(), TotMin, TotMax);
1824 HLRAlgo::UpdateMinMax(xsta,ysta,zsta, TotMin, TotMax);
1825 HLRAlgo::EnlargeMinMax(tol, TotMin, TotMax);
1826 REJECT1(myDeca, TotMin, TotMax, mySurD, VertMin, VertMax);
1828 HLRAlgo::EncodeMinMax(VertMin, VertMax, MinMaxVert);
1832 Standard_Integer qwe,qwep8,q,q1,q2;
1833 printf("\n E:%d -------\n",E);
1834 for(qwe=0; qwe<8; qwe++) {
1835 q1 = (((Standard_Integer*)iFaceMinMax)[qwe ]) & 0x0000FFFF;
1836 q2 = (((Standard_Integer*)iFaceMinMax)[qwe+8]) & 0x0000FFFF;
1837 printf("\nFace: %3d %6d -> %6d delta : %6d ",qwe,q1,q2,q2-q1);
1839 q1 = (((Standard_Integer*)MinMaxVert)[qwe ]) & 0x0000FFFF;
1840 q2 = (((Standard_Integer*)MinMaxVert)[qwe+8]) & 0x0000FFFF;
1841 printf(" | Vtx: %3d %6d -> %6d delta : %6d ",qwe,q1,q2,q2-q1);
1843 q1 = ((((Standard_Integer*)iFaceMinMax)[qwe ])>>16) & 0x0000FFFF;
1844 q2 = ((((Standard_Integer*)iFaceMinMax)[qwe+8])>>16) & 0x0000FFFF;
1845 printf("\nFace: %3d %6d -> %6d delta : %6d ",qwe,q1,q2,q2-q1);
1847 q1 = ((((Standard_Integer*)MinMaxVert)[qwe ])>>16) & 0x0000FFFF;
1848 q2 = ((((Standard_Integer*)MinMaxVert)[qwe+8])>>16) & 0x0000FFFF;
1849 printf(" | Vtx: %3d %6d -> %6d delta : %6d ",qwe,q1,q2,q2-q1);
1854 for(qwe=0,qwep8=8; qwe<8; qwe++,qwep8++) {
1855 q = ((Standard_Integer*)iFaceMinMax)[qwep8]- ((Standard_Integer*)MinMaxVert)[qwe];
1857 q2 = (q& 0x0000FFFF);
1858 printf("\nmot: %3d q1 = %+10d q2=%+10d Mask : %d",qwe,(q1>32768)? (32768-q1) : q1,(q2>32768)? (32768-q2) : q2,q&0x80008000);
1860 for(qwe=0,qwep8=8; qwe<8; qwe++,qwep8++) {
1861 q = ((Standard_Integer*)MinMaxVert)[qwep8]- ((Standard_Integer*)iFaceMinMax)[qwe];
1863 q2 = (q& 0x0000FFFF);
1864 printf("\nmot: %3d q1 = %+10d q2=%+10d Mask : %d",qwe+8,(q1>32768)? (32768-q1) : q1,(q2>32768)? (32768-q2) : q2,q&0x80008000);
1871 if (((iFaceMinMax->Max[0] - MinMaxVert.Min[0]) & 0x80008000) != 0 ||
1872 ((MinMaxVert.Max[0] - iFaceMinMax->Min[0]) & 0x80008000) != 0 ||
1873 ((iFaceMinMax->Max[1] - MinMaxVert.Min[1]) & 0x80008000) != 0 ||
1874 ((MinMaxVert.Max[1] - iFaceMinMax->Min[1]) & 0x80008000) != 0 ||
1875 ((iFaceMinMax->Max[2] - MinMaxVert.Min[2]) & 0x80008000) != 0 ||
1876 ((MinMaxVert.Max[2] - iFaceMinMax->Min[2]) & 0x80008000) != 0 ||
1877 ((iFaceMinMax->Max[3] - MinMaxVert.Min[3]) & 0x80008000) != 0 ||
1878 ((MinMaxVert.Max[3] - iFaceMinMax->Min[3]) & 0x80008000) != 0 ||
1879 ((iFaceMinMax->Max[4] - MinMaxVert.Min[4]) & 0x80008000) != 0 ||
1880 ((MinMaxVert.Max[4] - iFaceMinMax->Min[4]) & 0x80008000) != 0 ||
1881 ((iFaceMinMax->Max[5] - MinMaxVert.Min[5]) & 0x80008000) != 0 ||
1882 ((MinMaxVert.Max[5] - iFaceMinMax->Min[5]) & 0x80008000) != 0 ||
1883 ((iFaceMinMax->Max[6] - MinMaxVert.Min[6]) & 0x80008000) != 0 ||
1884 ((MinMaxVert.Max[6] - iFaceMinMax->Min[6]) & 0x80008000) != 0 ||
1885 ((iFaceMinMax->Max[7] - MinMaxVert.Min[7]) & 0x80008000) != 0) { //-- Rejection en Z
1890 nbCal3Intersection++;
1893 Psta = EC.Value (sta);
1894 PLim = EC.Value3D(sta);
1899 static Standard_Integer nump1=0;
1900 printf("\npoint PNR%d %g %g %g",++nump1,PLim.X(),PLim.Y(),PLim.Z());
1903 gp_Lin L = myProj.Shoot(Psta.X(),Psta.Y());
1904 Standard_Real wLim = ElCLib::Parameter(L,PLim);
1905 myIntersector.Perform(L,wLim);
1906 if (myIntersector.IsDone()) {
1907 Standard_Integer nbPoints = myIntersector.NbPoints();
1909 Standard_Real TolZ = myBigSize * 0.000001;
1911 if (!myLEOutLine && !myLEInternal) TolZ = myBigSize * 0.001;
1912 else TolZ = myBigSize * 0.01;
1915 Standard_Real PeriodU,PeriodV,UMin =0.,UMax =0.,VMin =0.,VMax =0.;
1916 if (((HLRBRep_Surface*)iFaceGeom)->IsUPeriodic()) {
1917 PeriodU = ((HLRBRep_Surface*)iFaceGeom)->UPeriod();
1918 UMin = ((HLRBRep_Surface*)iFaceGeom)->FirstUParameter();
1919 UMax = ((HLRBRep_Surface*)iFaceGeom)->LastUParameter();
1923 if (((HLRBRep_Surface*)iFaceGeom)->IsVPeriodic()) {
1924 PeriodV = ((HLRBRep_Surface*)iFaceGeom)->VPeriod();
1925 VMin = ((HLRBRep_Surface*)iFaceGeom)->FirstVParameter();
1926 VMax = ((HLRBRep_Surface*)iFaceGeom)->LastVParameter();
1931 Standard_Real u,v,w;
1932 IntCurveSurface_TransitionOnCurve Tr;
1934 for (i = 1; i <= nbPoints; i++) {
1935 myIntersector.CSPoint(i).Values(PInter,u,v,w,Tr);
1937 Standard_Real aDummyShift;
1939 GeomInt::AdjustPeriodic(u, UMin, UMax, PeriodU, u, aDummyShift);
1941 GeomInt::AdjustPeriodic(v, VMin, VMax, PeriodV, v, aDummyShift);
1943 gp_Pnt2d pnt2d(u, v);
1944 if (myClassifier->Classify(pnt2d, Precision::PConfusion())
1961 //=======================================================================
1962 //function : SimplClassify
1964 //=======================================================================
1966 TopAbs_State HLRBRep_Data::SimplClassify (const Standard_Integer /*E*/,
1967 const HLRBRep_EdgeData& ED,
1968 const Standard_Integer Nbp,
1969 const Standard_Real p1,
1970 const Standard_Real p2)
1973 HLRAlgo_EdgesBlock::MinMaxIndices VertMin, VertMax, MinMaxVert;
1974 Standard_Real TotMin[16],TotMax[16];
1977 TopAbs_State state = TopAbs_IN;
1978 // Standard_Boolean rej = Standard_False;
1979 const HLRBRep_Curve& EC = ED.Geometry();
1980 Standard_Real sta,xsta,ysta,zsta, dp;
1981 Standard_Real tol = (Standard_Real)(ED.Tolerance());
1983 dp = (p2 - p1)/(Nbp+1);
1985 for(sta = p1+dp,i = 1; i <= Nbp; ++i, sta += dp) {
1986 myProj.Project(EC.Value3D(sta),xsta,ysta,zsta);
1988 //-- les rejections sont faites dans l intersecteur a moindre frais
1989 //-- puisque la surface sera chargee
1990 HLRAlgo::InitMinMax(Precision::Infinite(), TotMin, TotMax);
1991 HLRAlgo::UpdateMinMax(xsta,ysta,zsta, TotMin, TotMax);
1992 HLRAlgo::EnlargeMinMax(tol, TotMin, TotMax);
1993 REJECT1(myDeca, TotMin, TotMax, mySurD, VertMin, VertMax);
1995 HLRAlgo::EncodeMinMax(VertMin, VertMax, MinMaxVert);
1996 if (((iFaceMinMax->Max[0] - MinMaxVert.Min[0]) & 0x80008000) != 0 ||
1997 ((MinMaxVert.Max[0] - iFaceMinMax->Min[0]) & 0x80008000) != 0 ||
1998 ((iFaceMinMax->Max[1] - MinMaxVert.Min[1]) & 0x80008000) != 0 ||
1999 ((MinMaxVert.Max[1] - iFaceMinMax->Min[1]) & 0x80008000) != 0 ||
2000 ((iFaceMinMax->Max[2] - MinMaxVert.Min[2]) & 0x80008000) != 0 ||
2001 ((MinMaxVert.Max[2] - iFaceMinMax->Min[2]) & 0x80008000) != 0 ||
2002 ((iFaceMinMax->Max[3] - MinMaxVert.Min[3]) & 0x80008000) != 0 ||
2003 ((MinMaxVert.Max[3] - iFaceMinMax->Min[3]) & 0x80008000) != 0 ||
2004 ((iFaceMinMax->Max[4] - MinMaxVert.Min[4]) & 0x80008000) != 0 ||
2005 ((MinMaxVert.Max[4] - iFaceMinMax->Min[4]) & 0x80008000) != 0 ||
2006 ((iFaceMinMax->Max[5] - MinMaxVert.Min[5]) & 0x80008000) != 0 ||
2007 ((MinMaxVert.Max[5] - iFaceMinMax->Min[5]) & 0x80008000) != 0 ||
2008 ((iFaceMinMax->Max[6] - MinMaxVert.Min[6]) & 0x80008000) != 0 ||
2009 ((MinMaxVert.Max[6] - iFaceMinMax->Min[6]) & 0x80008000) != 0 ||
2010 ((iFaceMinMax->Max[7] - MinMaxVert.Min[7]) & 0x80008000) != 0) { //-- Rejection en Z
2017 //=======================================================================
2018 //function : RejectedPoint
2019 //purpose : build an interference if non Rejected intersection point
2020 //=======================================================================
2023 HLRBRep_Data::RejectedPoint (const IntRes2d_IntersectionPoint& PInter,
2024 const TopAbs_Orientation BoundOri,
2025 const Standard_Integer NumSeg)
2027 Standard_Integer Ind = 0;
2028 Standard_Integer decal;
2029 Standard_Real p1,p2,dz;
2030 Standard_ShortReal t1,t2;
2032 TopAbs_Orientation Orie =TopAbs_FORWARD ;
2033 TopAbs_Orientation Or2 = TopAbs_INTERNAL;
2034 Standard_Boolean inverted = Standard_False;
2035 const IntRes2d_Transition* Tr1;
2036 const IntRes2d_Transition* Tr2;
2037 Standard_Real TolZ = myBigSize * 0.00001;
2039 p1 = ((HLRBRep_Curve*)myLEGeom)->Parameter3d(PInter.ParamOnFirst ());
2040 p2 = ((HLRBRep_Curve*)myFEGeom)->Parameter3d(PInter.ParamOnSecond());
2041 dz = ((HLRBRep_Curve*)myLEGeom)->Z(p1)-((HLRBRep_Curve*)myFEGeom)->Z(p2);
2043 if (myLE == myFE) { // auto intersection can be inverted
2045 inverted = Standard_True;
2046 Standard_Real p = p1;
2054 myAboveIntf = Standard_True;
2055 return Standard_True;
2057 myAboveIntf = Standard_False;
2058 st = (dz <= -TolZ) ? TopAbs_IN : TopAbs_ON;
2061 Tr1 = &(PInter.TransitionOfSecond());
2062 Tr2 = &(PInter.TransitionOfFirst ());
2065 Tr1 = &(PInter.TransitionOfFirst ());
2066 Tr2 = &(PInter.TransitionOfSecond());
2071 if (st == TopAbs_IN)
2072 ((HLRBRep_EdgeData*)myLEData)->Simple(Standard_False);
2076 if ((st == TopAbs_ON) ||
2077 (Tr1->PositionOnCurve() != IntRes2d_Middle) ||
2078 (Tr2->PositionOnCurve() != IntRes2d_Middle))
2079 return Standard_True;
2082 if (st == TopAbs_IN) iFaceSmpl = Standard_False;
2085 switch (Tr1->TransitionType()) { // compute the transition
2087 Orie = (myFEOri == TopAbs_REVERSED ? TopAbs_REVERSED : TopAbs_FORWARD);
2090 Orie = (myFEOri == TopAbs_REVERSED ? TopAbs_FORWARD : TopAbs_REVERSED);
2092 case IntRes2d_Touch :
2093 switch (Tr1->Situation()) {
2094 case IntRes2d_Inside :
2095 Orie = (myFEOri == TopAbs_REVERSED ? TopAbs_EXTERNAL : TopAbs_INTERNAL);
2097 case IntRes2d_Outside :
2098 Orie = (myFEOri == TopAbs_REVERSED ? TopAbs_INTERNAL : TopAbs_EXTERNAL);
2100 case IntRes2d_Unknown :
2101 return Standard_True;
2104 case IntRes2d_Undecided :
2105 return Standard_True;
2108 if (iFaceBack) Orie = TopAbs::Complement(Orie); // change the transition
2109 TopAbs_Orientation Ori = TopAbs_FORWARD;
2110 switch (Tr1->PositionOnCurve()) {
2111 case IntRes2d_Head : Ori = TopAbs_FORWARD ; break;
2112 case IntRes2d_Middle : Ori = TopAbs_INTERNAL; break;
2113 case IntRes2d_End : Ori = TopAbs_REVERSED; break;
2116 if (st != TopAbs_OUT) {
2117 if (Tr2->PositionOnCurve() != IntRes2d_Middle) { // correction de la transition sur myFE
2118 if (mySameVertex) return Standard_True; // si intersection a une extremite verticale !
2120 Standard_Boolean douteux = Standard_False;
2121 Standard_Real psav = p2;
2123 gp_Vec2d Tgsav,Nmsav;
2124 if (Tr2->PositionOnCurve() == IntRes2d_Head) {
2125 Ind = ((HLRBRep_EdgeData*)myFEData)->VSta();
2126 Or2 = TopAbs_FORWARD ;
2127 AdjustParameter((HLRBRep_EdgeData*)myFEData,Standard_True ,p2,t2);
2128 if (((HLRBRep_EdgeData*)myFEData)->VerAtSta()) {
2129 douteux = Standard_True;
2130 ((HLRBRep_Curve*)myFEGeom)->D2(psav,Ptsav,Tgsav,Nmsav);
2131 if (Tgsav.SquareMagnitude() <= DERIVEE_PREMIERE_NULLE)
2136 Ind = ((HLRBRep_EdgeData*)myFEData)->VEnd();
2137 Or2 = TopAbs_REVERSED;
2138 AdjustParameter((HLRBRep_EdgeData*)myFEData,Standard_False,p2,t2);
2139 if (((HLRBRep_EdgeData*)myFEData)->VerAtEnd()) {
2140 douteux = Standard_True;
2141 ((HLRBRep_Curve*)myFEGeom)->D2(psav,Ptsav,Tgsav,Nmsav);
2142 if (Tgsav.SquareMagnitude() <= DERIVEE_PREMIERE_NULLE)
2147 ((HLRBRep_Curve*)myFEGeom)->D1(p2,Ptsav,TgFE);
2149 if (TgFE.XY().Dot(Tgsav.XY()) < 0.0) {
2150 if (Orie == TopAbs_FORWARD ) Orie = TopAbs_REVERSED;
2151 else if (Orie == TopAbs_REVERSED) Orie = TopAbs_FORWARD ;
2154 myIntf.ChangeBoundary().Set2D(myFE,p2);
2156 if (Ori != TopAbs_INTERNAL) { // correction de la transition sur myLE
2157 Standard_Boolean douteux = Standard_False; // si intersection a une extremite verticale !
2158 Standard_Real psav = p1;
2160 gp_Vec2d Tgsav,Nmsav;
2161 if (Ori == TopAbs_FORWARD) {
2162 AdjustParameter((HLRBRep_EdgeData*)myLEData,Standard_True ,p1,t1);
2163 if (((HLRBRep_EdgeData*)myLEData)->VerAtSta()) {
2164 douteux = Standard_True;
2165 ((HLRBRep_Curve*)myLEGeom)->D2(psav,Ptsav,Tgsav,Nmsav);
2166 if (Tgsav.SquareMagnitude() <= DERIVEE_PREMIERE_NULLE)
2171 AdjustParameter((HLRBRep_EdgeData*)myLEData,Standard_False,p1,t1);
2172 if (((HLRBRep_EdgeData*)myLEData)->VerAtEnd()) {
2173 douteux = Standard_True;
2174 ((HLRBRep_Curve*)myLEGeom)->D2(psav,Ptsav,Tgsav,Nmsav);
2175 if (Tgsav.SquareMagnitude() <= DERIVEE_PREMIERE_NULLE)
2181 ((HLRBRep_Curve*)myLEGeom)->D1(p1,Ptsav,TgLE);
2182 if (TgLE.XY().Dot(Tgsav.XY()) < 0.0) {
2183 if (Orie == TopAbs_FORWARD ) Orie = TopAbs_REVERSED;
2184 else if (Orie == TopAbs_REVERSED) Orie = TopAbs_FORWARD ;
2188 if (st == TopAbs_ON) {
2189 TopAbs_State stbef,staft;
2190 EdgeState(p1,p2,stbef,staft);
2191 myIntf.ChangeBoundary().SetState3D(stbef,staft);
2200 if (st == TopAbs_IN &&
2201 Ori == TopAbs_FORWARD &&
2202 Orie == TopAbs_FORWARD)
2205 HLRAlgo_Intersection& inter = myIntf.ChangeIntersection();
2206 inter.Orientation(Ori);
2208 inter.SegIndex(NumSeg);
2210 inter.Parameter(p1);
2211 inter.Tolerance(myLETol);
2213 myIntf.Orientation(Or2);
2214 myIntf.Transition(Orie);
2215 myIntf.BoundaryTransition(BoundOri);
2216 myIntf.ChangeBoundary().Set2D(myFE,p2);
2217 return Standard_False;
2220 //=======================================================================
2221 //function : SameVertex
2223 //=======================================================================
2226 HLRBRep_Data::SameVertex (const Standard_Boolean h1,
2227 const Standard_Boolean h2)
2229 Standard_Integer v1,v2;
2230 if (h1) v1 = ((HLRBRep_EdgeData*)myLEData)->VSta();
2231 else v1 = ((HLRBRep_EdgeData*)myLEData)->VEnd();
2232 if (h2) v2 = ((HLRBRep_EdgeData*)myFEData)->VSta();
2233 else v2 = ((HLRBRep_EdgeData*)myFEData)->VEnd();
2234 Standard_Boolean SameV = v1 == v2;
2236 myIntersected = Standard_True; // compute the intersections
2237 if ((myLEType == GeomAbs_Line ||
2238 myLEType == GeomAbs_Circle ||
2239 myLEType == GeomAbs_Ellipse ) &&
2240 (myFEType == GeomAbs_Line ||
2241 myFEType == GeomAbs_Circle ||
2242 myFEType == GeomAbs_Ellipse ))
2243 myIntersected = Standard_False; // no other intersection
2245 Standard_Boolean otherCase = Standard_True;
2247 if (( h1 && ((HLRBRep_EdgeData*)myLEData)->OutLVSta()) ||
2248 (!h1 && ((HLRBRep_EdgeData*)myLEData)->OutLVEnd())) {
2249 if (iFaceTest || myLEInternal)
2250 otherCase = Standard_False;
2253 otherCase = Standard_False;
2256 if (( h1 && ((HLRBRep_EdgeData*)myLEData)->CutAtSta()) ||
2257 (!h1 && ((HLRBRep_EdgeData*)myLEData)->CutAtEnd())) {
2258 myIntersected = Standard_False; // two connected OutLines do not
2259 } // intersect themselves.
2265 //=======================================================================
2266 //function : IsBadFace
2268 //=======================================================================
2270 Standard_Boolean HLRBRep_Data::IsBadFace() const
2274 // check for garbage data - if periodic then bounds must not exceed period
2275 HLRBRep_Surface *pGeom = (HLRBRep_Surface*)iFaceGeom;
2276 if (pGeom->IsUPeriodic())
2278 Standard_Real aPeriod = pGeom->UPeriod();
2279 Standard_Real aMin = pGeom->FirstUParameter();
2280 Standard_Real aMax = pGeom->LastUParameter();
2281 if (aPeriod * 2 < aMax - aMin)
2282 return Standard_True;
2284 if (pGeom->IsVPeriodic())
2286 Standard_Real aPeriod = pGeom->VPeriod();
2287 Standard_Real aMin = pGeom->FirstVParameter();
2288 Standard_Real aMax = pGeom->LastVParameter();
2289 if (aPeriod * 2 < aMax - aMin)
2290 return Standard_True;
2293 return Standard_False;