1 // Created on: 1995-06-14
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1995-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 <gp_Pnt2d.hxx>
20 #include <TopoDS_Edge.hxx>
21 #include <TopoDS_Face.hxx>
22 #include <TopoDS_Shape.hxx>
23 #include <TopOpeBRep_FaceEdgeFiller.hxx>
24 #include <TopOpeBRep_FaceEdgeIntersector.hxx>
25 #include <TopOpeBRep_PointGeomTool.hxx>
26 #include <TopOpeBRepDS_CurvePointInterference.hxx>
27 #include <TopOpeBRepDS_DataStructure.hxx>
28 #include <TopOpeBRepDS_HDataStructure.hxx>
29 #include <TopOpeBRepDS_Interference.hxx>
30 #include <TopOpeBRepDS_InterferenceTool.hxx>
31 #include <TopOpeBRepDS_Point.hxx>
34 extern void FEINT_DUMPPOINTS(TopOpeBRep_FaceEdgeIntersector& FEINT,
35 const TopOpeBRepDS_DataStructure& BDS);
38 //=======================================================================
39 //function : TopOpeBRep_FaceEdgeFiller
41 //=======================================================================
43 TopOpeBRep_FaceEdgeFiller::TopOpeBRep_FaceEdgeFiller()
48 //=======================================================================
51 //=======================================================================
53 void TopOpeBRep_FaceEdgeFiller::Insert
54 (const TopoDS_Shape& F,
55 const TopoDS_Shape& E,
56 TopOpeBRep_FaceEdgeIntersector& FEINT,
57 const Handle(TopOpeBRepDS_HDataStructure)& HDS)
59 const TopoDS_Face& FF = TopoDS::Face(F);
60 const TopoDS_Edge& EE = TopoDS::Edge(E);
64 if ( ! FEINT.MorePoint() ) return;
66 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
68 TopAbs_Orientation FFori = FF.Orientation();
70 // --- Add <FF,EE> in BDS
71 Standard_Integer FFindex = BDS.AddShape(FF,1);
74 // --- get list of interferences connected to edges <FF>,<EE>
75 TopOpeBRepDS_ListOfInterference& EIL1 = BDS.ChangeShapeInterferences(FF);
76 TopOpeBRepDS_ListOfInterference& EIL2 = BDS.ChangeShapeInterferences(EE);
78 Handle(TopOpeBRepDS_Interference) EPI; //edge/point interference
79 Handle(TopOpeBRepDS_Interference) EVI; //edge/vertex interference
81 for (; FEINT.MorePoint(); FEINT.NextPoint() ) {
82 gp_Pnt2d pUV; FEINT.UVPoint(pUV);
83 Standard_Real parE = FEINT.Parameter();
86 TopAbs_Orientation EEori = EE.Orientation();
87 TopOpeBRepDS_Transition TFF = FEINT.Transition(1,EEori); (void)TFF;
89 TopOpeBRepDS_Transition TEE = FEINT.Transition(2,FFori);
93 Standard_Boolean isvertexF = FEINT.IsVertex(1,V1);
95 Standard_Boolean isvertexE = FEINT.IsVertex(2,V2);
96 Standard_Boolean isvertex = isvertexF || isvertexE;
98 Standard_Integer DSPindex;
99 Standard_Boolean EPIfound;
102 // create a new geometry in DS ( and get its index <DSPindex> )
103 // or get the index <DSPindex> of an equal geometry
104 // among those of Edge/Point interferences connected to <FF> (or <EE>).
106 TopOpeBRepDS_ListIteratorOfListOfInterference itEIL1(EIL1);
107 EPIfound = GetGeometry(itEIL1,FEINT,DSPindex,BDS);
108 if ( ! EPIfound ) DSPindex = MakeGeometry(FEINT,BDS);
111 // NYI : FacePointInterference : on ajoute un point INTERNAL a F
112 // FPI = new TopOpeBRepDS_FacePointInterference(TopAbs_INTERNAL,
113 // TopOpeBRepDS_FACE,FFindex,
114 // TopOpeBRepDS_POINT,DSPindex,
116 // StoreInterference(FPI,EIL1,BDS);
119 EPI = TopOpeBRepDS_InterferenceTool::MakeCurveInterference
120 (TEE,TopOpeBRepDS_FACE,FFindex,TopOpeBRepDS_POINT,DSPindex,parE);
121 StoreInterference(EPI,EIL2,BDS);
124 else if ( isvertexF ) {
125 // si aussi vertex de E, in privilegie le vertex de la face
126 Standard_Integer Vindex = BDS.AddShape(V1,1);
129 // NYI pour toute arete de F qui accede V , une EVI
130 // EVI = new TopOpeBRepDS_EdgeVertexInterference(Transition ?? <-> TFF,
131 // TopOpeBRepDS_EDGE,E de F,
132 // TopOpeBRepDS_VERTEX,Vindex,
133 // param de V sur E de F);
134 // StoreInterference(EVI,EIL1,BDS);
137 EPI = new TopOpeBRepDS_CurvePointInterference(TEE,
138 TopOpeBRepDS_FACE,FFindex,
139 TopOpeBRepDS_VERTEX,Vindex,
141 StoreInterference(EPI,EIL2,BDS);
144 else if ( isvertexE ) {
145 Standard_Integer Vindex = BDS.AddShape(V2,2);
148 // NYI : FaceVertexInterference : on ajoute un vertex INTERNAL a F
149 // FVI = new TopOpeBRepDS_FaceVertexInterference(TopAbs_INTERNAL,
150 // TopOpeBRepDS_FACE,FFindex,
151 // TopOpeBRepDS_VERTEX,Vindex,
153 // StoreInterference(FPI,EIL1,BDS);
156 EPI = new TopOpeBRepDS_CurvePointInterference(TEE,
157 TopOpeBRepDS_FACE,FFindex,
158 TopOpeBRepDS_VERTEX,Vindex,
160 StoreInterference(EPI,EIL2,BDS);
171 //-----------------------------------------------------------------------
172 // Search, among a list of interferences accessed by the iterator <IT>,
173 // a geometry whose 3D point is identical yo the 3D point of a DS point <DSP>.
174 // TheDSPointGeomTool is a tool able to access the 3D point of the DS point
175 // DSP,and to test identity (according to tolerance connected to DSP) of the
177 // return True if such an interference has been found, False else.
178 // if True, iterator <IT> points (by the Value() method) on the first
179 // interference accessing an identical 3D point.
180 //-----------------------------------------------------------------------
181 //=======================================================================
182 //function : ScanInterfList
184 //=======================================================================
186 Standard_Boolean TopOpeBRep_FaceEdgeFiller::ScanInterfList
187 (TopOpeBRepDS_ListIteratorOfListOfInterference& IT,
188 const TopOpeBRepDS_Point& DSP,
189 const TopOpeBRepDS_DataStructure& BDS) const
191 for ( ; IT.More(); IT.Next() ) {
192 Standard_Integer DSPG = IT.Value()->Geometry();
193 const TopOpeBRepDS_Point& otherDSP = BDS.Point(DSPG);
194 if (TopOpeBRep_PointGeomTool::IsEqual(DSP,otherDSP)) return Standard_True;
196 return Standard_False;
200 //=======================================================================
201 //function : GetGeometry
203 //=======================================================================
205 Standard_Boolean TopOpeBRep_FaceEdgeFiller::GetGeometry
206 (TopOpeBRepDS_ListIteratorOfListOfInterference& IT,
207 const TopOpeBRep_FaceEdgeIntersector& FEINT,
209 const TopOpeBRepDS_DataStructure& BDS) const
211 TopOpeBRepDS_Point DSP = TopOpeBRep_PointGeomTool::MakePoint(FEINT);
212 Standard_Boolean found = ScanInterfList(IT,DSP,BDS);
213 if (found) G = IT.Value()->Geometry();
218 //=======================================================================
219 //function : GetGeometry
221 //=======================================================================
223 Standard_Boolean TopOpeBRep_FaceEdgeFiller::GetGeometry
224 (const TopOpeBRepDS_ListOfInterference& L,
225 const TopOpeBRepDS_Point& DSP,
227 TopOpeBRepDS_DataStructure& BDS) const
229 TopOpeBRepDS_ListIteratorOfListOfInterference itI(L);
230 Standard_Boolean Ifound = ScanInterfList(itI,DSP,BDS);
231 if (Ifound) G = itI.Value()->Geometry();
232 else G = BDS.AddPoint(DSP);
233 return Ifound; // interference found or not
237 //-----------------------------------------------------------------------
238 // StoreInterference : Append an interference I to a list of interference LI
239 // : Append I to the interf. list connected to I Geometry()
240 //-----------------------------------------------------------------------
241 //=======================================================================
242 //function : StoreInterference
244 //=======================================================================
246 void TopOpeBRep_FaceEdgeFiller::StoreInterference
247 (const Handle(TopOpeBRepDS_Interference)& I,
248 TopOpeBRepDS_ListOfInterference& LI,
249 TopOpeBRepDS_DataStructure& BDS) const
251 // append I to list LI
254 Standard_Integer G = I->Geometry();
256 // append I to list of interference connected to G = I->Geometry()
257 switch (I->GeometryType()) {
259 case TopOpeBRepDS_SOLID : case TopOpeBRepDS_FACE :
260 case TopOpeBRepDS_EDGE : case TopOpeBRepDS_VERTEX :
261 // appendtoG = Standard_True;
262 // BDS.ChangeShapeInterferences(G).Append(I);
265 case TopOpeBRepDS_SURFACE :
266 BDS.ChangeSurfaceInterferences(G).Append(I);
269 case TopOpeBRepDS_CURVE :
270 BDS.ChangeCurveInterferences(G).Append(I);
273 case TopOpeBRepDS_POINT :
274 // appendtoG = Standard_True;
275 // BDS.ChangePointInterferences(G).Append(I);
282 //=======================================================================
283 //function : MakeGeometry
285 //=======================================================================
287 Standard_Integer TopOpeBRep_FaceEdgeFiller::MakeGeometry
288 (TopOpeBRep_FaceEdgeIntersector& FEINT,
289 TopOpeBRepDS_DataStructure& BDS) const
291 Standard_Integer G=0;
294 Standard_Boolean isvertexF = FEINT.IsVertex(1,V1);
296 Standard_Boolean isvertexE = FEINT.IsVertex(2,V2);
297 Standard_Boolean isvertex = isvertexF || isvertexE;
300 if ( isvertexF ) G = BDS.AddShape(V1,1);
301 else if ( isvertexE ) G = BDS.AddShape(V2,2);
304 G = BDS.AddPoint(TopOpeBRep_PointGeomTool::MakePoint(FEINT));