1 // Created on: 1998-05-07
2 // Created by: Xuan PHAM PHU
3 // Copyright (c) 1998-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
22 #include <TopOpeBRepBuild_BuilderON.jxx>
24 #include <TopOpeBRepTool_EXPORT.hxx>
25 #include <TopOpeBRepTool_SC.hxx>
26 #include <TopOpeBRepDS_InterferenceTool.hxx>
27 #include <TopOpeBRepDS_EXPORT.hxx>
28 #include <TopOpeBRepDS_connex.hxx>
29 #include <TopOpeBRepDS.hxx>
30 #include <TopOpeBRepBuild_define.hxx>
31 #include <BRep_Tool.hxx>
34 #include <Precision.hxx>
37 #define M_OUT(st) (st == TopAbs_OUT)
38 #define M_IN( st) (st == TopAbs_IN)
39 #define M_FORWARD(st) (st == TopAbs_FORWARD)
40 #define M_REVERSED(st) (st == TopAbs_REVERSED)
43 Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEINTERNAL();
44 Standard_EXPORT Standard_Boolean TopOpeBRepBuild_GetcontextEEXTERNAL();
45 Standard_EXPORT void debfillonf(const Standard_Integer iF);
46 Standard_EXPORT void debON2d(const Standard_Integer iF)
47 {cout<<"++ debON2d "<<iF<<" "<<endl;}
50 Standard_EXPORT TopAbs_State FUN_build_TB(const TopOpeBRepBuild_PBuilder& PB,const Standard_Integer rank); // xpu290698
51 Standard_EXPORT Standard_Boolean FUN_keepEON(const TopOpeBRepBuild_Builder& B,
52 const TopoDS_Shape& sEG,const TopoDS_Shape& sFOR,const TopoDS_Shape& sFS,
53 const Standard_Boolean EGBoundFOR,
54 const TopOpeBRepDS_Transition& TFE,const TopAbs_State TB1,const TopAbs_State TB2);
55 Standard_EXPORT void FUN_coutmess(const TCollection_AsciiString& m);
57 Standard_EXPORTEXTERN TopOpeBRepDS_PDataStructure GLOBAL_DS2d;
59 //=======================================================================
60 //function : Perform2d
62 //=======================================================================
63 void TopOpeBRepBuild_BuilderON::Perform2d
64 (const TopOpeBRepBuild_PBuilder& PB,
65 const TopoDS_Shape& FOR,const TopOpeBRepBuild_PGTopo& PG,
66 const TopOpeBRepTool_Plos& PLSclass, const TopOpeBRepBuild_PWireEdgeSet& PWES)
71 myPLSclass = PLSclass;
74 const TopOpeBRepDS_DataStructure& BDS=myPB->DataStructure()->DS();
75 if (GLOBAL_DS2d == NULL) GLOBAL_DS2d = (TopOpeBRepDS_PDataStructure)new TopOpeBRepDS_DataStructure();
76 const TopOpeBRepDS_ListOfInterference& lFEI = GLOBAL_DS2d->ShapeInterferences(FOR);
79 Standard_Integer iFOR;Standard_Boolean tFOR=myPB->GtraceSPS(FOR,iFOR);
80 if (tFOR) debfillonf(iFOR);
81 if (tFOR) {cout<<endl<<"LI on F"<<iFOR<<":"<<endl;
82 for (TopOpeBRepDS_ListIteratorOfListOfInterference iit(lFEI); iit.More(); iit.Next())
83 {iit.Value()->Dump(cout);cout<<endl;}}
86 for (TopOpeBRepDS_ListIteratorOfListOfInterference itI(lFEI); itI.More(); itI.Next()){
87 const Handle(TopOpeBRepDS_Interference)& I = itI.Value();
88 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(I,GT,GI,ST,SI);
90 const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI));
92 // Standard_Integer iEG=BDS.Shape(EG);
94 const TopTools_ListOfShape& lEspON=myPB->Splits(EG,TopAbs_ON);
96 // Standard_Integer nEspON=lEspON.Extent();
98 for(TopTools_ListIteratorOfListOfShape it(lEspON);it.More();it.Next()) {
99 const TopoDS_Shape& EspON=it.Value();
100 GFillONParts2dWES2(I,EspON);
105 //=======================================================================
106 //function : GFillONPartsWES2
108 //=======================================================================
109 void TopOpeBRepBuild_BuilderON::GFillONParts2dWES2(const Handle(TopOpeBRepDS_Interference)& I,const TopoDS_Shape& EspON)
111 const Handle(TopOpeBRepDS_HDataStructure)& HDS=myPB->DataStructure();
112 const TopOpeBRepDS_DataStructure& BDS= HDS->DS();
113 const Handle(TopOpeBRepDS_ShapeShapeInterference)& SSI=Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I);
114 TopAbs_State TB1,TB2;myPG->StatesON(TB1,TB2);
115 TopOpeBRepDS_Kind GT,ST;Standard_Integer GI,SI;FDS_data(SSI,GT,GI,ST,SI);
116 // const TopOpeBRepDS_Transition& TFE=SSI->Transition();
117 Standard_Boolean EGBoundFOR=SSI->GBound();
118 const TopoDS_Face& FOR=TopoDS::Face(myFace); Standard_Integer iFOR=BDS.Shape(FOR);
119 const TopoDS_Edge& EG=TopoDS::Edge(BDS.Shape(GI));
121 // Standard_Integer iEG=BDS.Shape(EG);
123 const TopoDS_Face& FS=TopoDS::Face(BDS.Shape(SI));
125 // Standard_Integer iFS=BDS.Shape(FS);
126 // Standard_Boolean isclosedFF=BRep_Tool::IsClosed(EG,FOR);
127 // Standard_Boolean isclosedFS=BRep_Tool::IsClosed(EG,FS);
128 // Standard_Boolean isclosed=(isclosedFF || isclosedFS);
129 // Standard_Boolean isrest=BDS.IsSectionEdge(EG);
130 // Standard_Boolean issplit=myPB->IsSplit(EG,TopAbs_ON);
131 // Standard_Integer rankFS=myPB->GShapeRank(FS);
133 Standard_Integer rankEG=myPB->GShapeRank(EG);
135 // Standard_Integer rankFOR=myPB->GShapeRank(FOR);
138 // TopAbs_State TBEG = (rankEG == 1) ? TB1 : TB2;
139 TopAbs_State TBEG = FUN_build_TB(myPB,rankEG);
141 // TopAbs_State TFEbef = TFE.Before();
142 // TopAbs_State TFEaft = TFE.After();
143 // Standard_Boolean EGboundFOR =
144 // Handle(TopOpeBRepDS_ShapeShapeInterference)::DownCast(I)->GBound();
146 Standard_Boolean eghassd = HDS->HasSameDomain(EG);
149 Standard_Boolean tFOR=myPB->GtraceSPS(iFOR);
150 // Standard_Boolean tE=myPB->GtraceSPS(GI);
151 // Standard_Boolean tEFOR = (tE && tFOR);
152 if (tFOR) {debON2d(iFOR);}
153 if (tFOR) {I->Dump(cout);cout<<endl;}
156 Standard_Integer iFCX=SI;
157 Standard_Boolean FFinSDSO = Standard_True;
159 // Standard_Boolean FFinSDDO = Standard_False;
161 Standard_Boolean FFinSD= Standard_True;
162 TopoDS_Face FCX = FS;
165 // TopAbs_Orientation oFOR = BDS.Shape(iFOR).Orientation();
166 // TopAbs_Orientation oFS = BDS.Shape(iFS).Orientation();
167 // TopAbs_Orientation oFCX = BDS.Shape(iFCX).Orientation();
168 // Standard_Integer irefFOR = BDS.SameDomainRef(FOR);
169 // Standard_Integer irefFCX = BDS.SameDomainRef(FCX);
170 // Standard_Boolean FORisref = (irefFOR == iFOR);
171 // Standard_Boolean FCXisref = (irefFCX == iFCX);
174 TopAbs_Orientation oegFCXF;Standard_Boolean EGBoundFCX = FUN_tool_orientEinFFORWARD(EG,FCX,oegFCXF);
175 TopAbs_Orientation oegFCX ;
177 // Standard_Boolean ok2 =
179 FUN_tool_orientEinF(EG,FCX,oegFCX);
181 Standard_Boolean opeFus = myPB->Opefus();
182 Standard_Boolean opeCut = myPB->Opec12() || myPB->Opec21();
183 Standard_Boolean opeCom = myPB->Opecom();
186 Standard_Boolean yap6 = Standard_True;
187 yap6 = yap6 && FFinSD;
188 // yap6 = yap6 && (!EGBoundFOR);
189 // yap6 = yap6 && EGBoundFCX;
190 yap6 = yap6 && (EGBoundFOR || EGBoundFCX);
191 yap6 = yap6 && eghassd;
193 //=========================================
196 if (tFOR) cout<<"* yap6 = 1"<<endl;
198 TopAbs_Orientation neworiE = TopAbs_FORWARD;
199 // FF est samedomain avec FCX
200 // on evalue la transition de FOR par rapport a la matiere 2d de la face FCX
201 // au lieu de la transition par rapport a la matiere 3d de la face FS
202 // EG est une arete de FCX, oegFCXF=O.T. de EG dans FCX orientee FORWARD
204 Standard_Boolean b = Standard_False;
206 Standard_Boolean SO = FFinSDSO;//(FFinSDSO && (oFOR == oFCX)) || (FFinSDDO && (oFOR != oFCX));
208 // Standard_Integer rkToFill = BDS.AncestorRank(myFace); //DEB
210 Standard_Boolean rk1 = (rankEG == 1);
213 TopAbs_Orientation oegFOR;
214 Standard_Boolean shareG = Standard_False;
215 Standard_Boolean ok = Standard_False;
217 ok = FUN_ds_shareG(myPB->DataStructure(),iFOR,iFCX,GI,TopoDS::Edge(EspON),shareG);
219 ok = FUN_ds_shareG(myPB->DataStructure(),iFCX,iFOR,GI,TopoDS::Edge(EspON),shareG);
220 if (!ok) return; // nyiFUNRAISE
222 if (tFOR) cout<<" shareG="<<shareG<<endl;
226 // FOR and FCX share geometric domain.
227 if (opeFus) b = shareG;
228 else if (opeCut) b = (!shareG) && M_OUT(TBEG);
229 else if (opeCom) b = shareG;
234 TopAbs_Orientation oegFCXF1; FUN_tool_orientEinFFORWARD(EG,FCX,oegFCXF1);
237 else if (EGBoundFOR) {
238 FUN_tool_orientEinFFORWARD(EG,TopoDS::Face(FOR),oegFOR);
242 // Standard_Real f,l; FUN_tool_bounds(EG,f,l); Standard_Real parON = (f+l)*.4352;
243 Standard_Real f,l; FUN_tool_bounds(TopoDS::Edge(EspON),f,l); Standard_Real parON = (f+l)*.4352; // xpu120698
244 Standard_Boolean ESO; ok = FUN_tool_curvesSO(TopoDS::Edge(EspON),parON,EG,ESO);
245 if (!ok) return; // xpu120698
246 if (!ESO) neworiE = TopAbs::Complement(neworiE);
248 TopAbs_Orientation oFOR = BDS.Shape(iFOR).Orientation();
249 TopAbs_Orientation oFCX = BDS.Shape(iFCX).Orientation();
250 if (oFOR != oFCX) neworiE = TopAbs::Complement(neworiE);
252 TopoDS_Shape newE = EspON;
253 newE.Orientation(neworiE);
254 myPWES->AddStartElement(newE);
256 if (tFOR) cout<<" add spON e"<<GI<<endl;
261 } // GFillONPartsWES2