summaryrefslogtreecommitdiff
path: root/src/TopOpeBRepBuild/TopOpeBRepBuild_ffwesk.cxx
blob: c66fcba22da6f211964ea9f39906942ef4e188c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
// file:	TopOpeBRepBuild_ffwesk.cxx
// Created:	Thu Mar  7 10:49:33 1996
// Author:	Jean Yves LEBEY
//		<jyl@meteox>

#include <TopOpeBRepBuild_Builder.ixx>

#include <TopOpeBRepDS.hxx>
#include <TopoDS.hxx>
#include <TopOpeBRepBuild_define.hxx>
#include <TopOpeBRepDS_EXPORT.hxx>
#include <TopOpeBRepTool_EXPORT.hxx>
#include <TopOpeBRepTool_2d.hxx>

#ifdef DEB
Standard_EXPORT void debfctwesmess(const Standard_Integer i,const TCollection_AsciiString& s = "");
Standard_EXPORT void debffwesON(const Standard_Integer i);
Standard_EXPORT void debffwesk(const Standard_Integer i) {cout<<"++ debffwesk "<<i<<endl;}
#endif

Standard_EXPORT Standard_Boolean TopOpeBRepBuild_FUN_aresamegeom(const TopoDS_Shape& S1,const TopoDS_Shape& S2);

#define M_IN(st )      (st == TopAbs_IN)
#define M_OUT(st)      (st == TopAbs_OUT)
#define M_FORWARD(st ) (st == TopAbs_FORWARD)
#define M_REVERSED(st) (st == TopAbs_REVERSED)
#define M_INTERNAL(st) (st == TopAbs_INTERNAL)
#define M_EXTERNAL(st) (st == TopAbs_EXTERNAL)

//=======================================================================
//function : GFillFacesWESK
//purpose  : 
//=======================================================================
void TopOpeBRepBuild_Builder::GFillFacesWESK(const TopTools_ListOfShape& LS1,const TopTools_ListOfShape& LS2,const TopOpeBRepBuild_GTopo& G1,TopOpeBRepBuild_WireEdgeSet& WES,const Standard_Integer Kfill)
{
  if ( LS1.IsEmpty() ) return;
  TopAbs_State TB1,TB2; G1.StatesON(TB1,TB2);

  const TopOpeBRepDS_DataStructure& BDS = myDataStructure->DS();

  const TopoDS_Shape& F1 = LS1.First();
  myFaceReference = TopoDS::Face(F1);
#ifdef DEB
  Standard_Integer iF1 =
#endif
            BDS.Shape(F1);
  Standard_Integer iref = BDS.SameDomainRef(F1);
  TopAbs_Orientation oref = BDS.Shape(iref).Orientation();

#ifdef DEB
  Standard_Boolean tSPS = GtraceSPS(F1,iF1);
  if(tSPS) cout<<"\n%%%%%%%%%%%%% K = "<<Kfill<<" %%%%%%%%%%%%% ";
  if(tSPS) GdumpSHASTA(iF1,TB1,WES,"GFillFacesWESK","myFaceReference");
  if(tSPS) debffwesk(iF1);
#endif

  TopAbs_State TB;
  TopOpeBRepBuild_GTopo G;
  TopTools_ListIteratorOfListOfShape it;
  Standard_Boolean gistoreverse1;

  G = G1; 
  gistoreverse1 = G.IsToReverse1();
  TB = TB1;
  it.Initialize(LS1); 

#ifdef DEB
  if(tSPS){
    cout<<"\n^^^^^^^^ GFillFacesWESK : traitement de 1/2";
    TopAbs_State TB11,TB21; G.StatesON(TB11,TB21);
    cout<<" TB = ";TopAbs::Print(TB,cout); cout<<" ";
    cout<<"(TB1 = ";TopAbs::Print(TB11,cout);cout<<",";
    cout<<" TB2 = ";TopAbs::Print(TB21,cout);cout<<")\n\n";
  }
#endif

  for(; it.More(); it.Next()) {
    const TopoDS_Shape& S = it.Value(); Standard_Integer iS = myDataStructure->Shape(S);
    Standard_Boolean tomerge = !IsMerged(S,TB);
    if (!tomerge) continue;    
    
    // lors de l'insertion des composantes (edges splitees) de S dans le WES :
    // - faces de meme orientation geometrique : 
    //     la grille indique l'orientation des composantes
    // - faces d'orientation geometrique != : 
    //     les aretes de S sont exprimees dans une surface
    //     d'orientation opposee a la surface de la face de reference. 
    //     Leur orientation dans la face resultat (reference) est le contraire 
    //     de la grille.
//  Modified by Sergey KHROMOV - Sat Apr 27 14:40:35 2002 Begin
//     const TopoDS_Shape& Fref = WES.Face();
//     const TopoDS_Shape& F = S;
//     Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(Fref,F);
//     Standard_Boolean r = gistoreverse1;
//     if ( !samegeom ) { r = !r; G.SetReverse(r); }
    
//     Standard_Boolean rev = Standard_False;
//  Modified by Sergey KHROMOV - Sat Apr 27 14:40:36 2002 End
    TopAbs_Orientation oS = BDS.Shape(iS).Orientation();
    TopOpeBRepDS_Config conf = BDS.SameDomainOri(S);
    Standard_Boolean b1 = (conf == TopOpeBRepDS_DIFFORIENTED && (oS == oref));
    Standard_Boolean b2 = (conf == TopOpeBRepDS_SAMEORIENTED && (oS != oref));
    Standard_Boolean b = b1 || b2;
//  Modified by Sergey KHROMOV - Sat Apr 27 14:40:01 2002 Begin
//     if (b) {
//       rev = Standard_True;
//       G.SetReverse(rev);
//     }
    if (b)
      G.SetReverse(!gistoreverse1);
//  Modified by Sergey KHROMOV - Sat Apr 27 14:40:03 2002 End
    
    if      (Kfill == 1) {
      GFillFaceWES(S,LS2,G,WES);
    }
    else if (Kfill == 2) {
#ifdef DEB
      if (tSPS) debfctwesmess(iF1);
#endif
      GFillCurveTopologyWES(S,G,WES);
    }
    else if (Kfill == 3) {
#ifdef DEB
      if (tSPS) debffwesON(iF1);
#endif
      GFillONPartsWES(S,G,LS2,WES);
    }
    else {
      // error
    } 
  } // it(LS1)

  
  G = G1.CopyPermuted();
  gistoreverse1 = G.IsToReverse1();
  TB = TB2;
  it.Initialize(LS2);

#ifdef DEB
  if(tSPS){
    cout<<"\n^^^^^^^^ GFillFacesWESK : traitement de 2/1";
    TopAbs_State TB12,TB22; G.StatesON(TB12,TB22);
    cout<<" TB = ";TopAbs::Print(TB,cout); cout<<" ";
    cout<<"(TB1 = ";TopAbs::Print(TB12,cout);cout<<",";
    cout<<" TB2 = ";TopAbs::Print(TB22,cout);cout<<")\n\n";
  }
#endif

  for (; it.More(); it.Next()) {
    const TopoDS_Shape& S = it.Value(); Standard_Integer iS = myDataStructure->Shape(S);
    Standard_Boolean tomerge = !IsMerged(S,TB);
    if (!tomerge) continue;

//  Modified by Sergey KHROMOV - Sat Apr 27 14:38:33 2002 Begin
//     const TopoDS_Shape& Fref = WES.Face();
//     const TopoDS_Shape& F = S;
//     Standard_Boolean samegeom = ::TopOpeBRepBuild_FUN_aresamegeom(Fref,F);
//     Standard_Boolean r = gistoreverse1;
//     if ( !samegeom ) { r = !r; G.SetReverse(r); }
    
//     Standard_Boolean rev = Standard_False;
//  Modified by Sergey KHROMOV - Sat Apr 27 14:38:30 2002 End
    TopAbs_Orientation oS = BDS.Shape(iS).Orientation();
    TopOpeBRepDS_Config conf = BDS.SameDomainOri(S);
    Standard_Boolean b1 = (conf == TopOpeBRepDS_DIFFORIENTED && (oS == oref));
    Standard_Boolean b2 = (conf == TopOpeBRepDS_SAMEORIENTED && (oS != oref));
    Standard_Boolean b = b1 || b2;
//  Modified by Sergey KHROMOV - Sat Apr 27 14:39:04 2002 Begin
//     if (b) {
//       rev = Standard_True;
//       G.SetReverse(rev);
//     }
    if (b)
      G.SetReverse(!gistoreverse1);
//  Modified by Sergey KHROMOV - Sat Apr 27 14:39:08 2002 End
    
    if      (Kfill == 1) {
      GFillFaceWES(S,LS1,G,WES);
    }
    else if (Kfill == 2) {
      GFillCurveTopologyWES(S,G,WES);
    }
    else if (Kfill == 3) {
#ifdef DEB
      if(tSPS) debffwesON(iF1);
#endif
      GFillONPartsWES(S,G,LS1,WES);
    }
    else {
    }

  } // it(LS2)

} // GFillFacesWESK