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_Shape.hxx>
21 #include <TopOpeBRep_FaceEdgeFiller.hxx>
22 #include <TopOpeBRep_FaceEdgeIntersector.hxx>
23 #include <TopOpeBRep_PointGeomTool.hxx>
24 #include <TopOpeBRepDS_CurvePointInterference.hxx>
25 #include <TopOpeBRepDS_HDataStructure.hxx>
26 #include <TopOpeBRepDS_Interference.hxx>
27 #include <TopOpeBRepDS_InterferenceTool.hxx>
28 #include <TopOpeBRepDS_Point.hxx>
31 extern void FEINT_DUMPPOINTS(TopOpeBRep_FaceEdgeIntersector& FEINT,
32 const TopOpeBRepDS_DataStructure& BDS);
35 //=======================================================================
36 //function : TopOpeBRep_FaceEdgeFiller
38 //=======================================================================
40 TopOpeBRep_FaceEdgeFiller::TopOpeBRep_FaceEdgeFiller()
45 //=======================================================================
48 //=======================================================================
50 void TopOpeBRep_FaceEdgeFiller::Insert
51 (const TopoDS_Shape& F,
52 const TopoDS_Shape& E,
53 TopOpeBRep_FaceEdgeIntersector& FEINT,
54 const Handle(TopOpeBRepDS_HDataStructure)& HDS)
56 const TopoDS_Face& FF = TopoDS::Face(F);
57 const TopoDS_Edge& EE = TopoDS::Edge(E);
61 if ( ! FEINT.MorePoint() ) return;
63 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
65 TopAbs_Orientation FFori = FF.Orientation();
67 // --- Add <FF,EE> in BDS
68 Standard_Integer FFindex = BDS.AddShape(FF,1);
71 // --- get list of interferences connected to edges <FF>,<EE>
72 TopOpeBRepDS_ListOfInterference& EIL1 = BDS.ChangeShapeInterferences(FF);
73 TopOpeBRepDS_ListOfInterference& EIL2 = BDS.ChangeShapeInterferences(EE);
75 Handle(TopOpeBRepDS_Interference) EPI; //edge/point interference
76 Handle(TopOpeBRepDS_Interference) EVI; //edge/vertex interference
78 for (; FEINT.MorePoint(); FEINT.NextPoint() ) {
79 gp_Pnt2d pUV; FEINT.UVPoint(pUV);
80 Standard_Real parE = FEINT.Parameter();
83 TopAbs_Orientation EEori = EE.Orientation();
84 TopOpeBRepDS_Transition TFF = FEINT.Transition(1,EEori); (void)TFF;
86 TopOpeBRepDS_Transition TEE = FEINT.Transition(2,FFori);
90 Standard_Boolean isvertexF = FEINT.IsVertex(1,V1);
92 Standard_Boolean isvertexE = FEINT.IsVertex(2,V2);
93 Standard_Boolean isvertex = isvertexF || isvertexE;
95 Standard_Integer DSPindex;
96 Standard_Boolean EPIfound;
99 // create a new geometry in DS ( and get its index <DSPindex> )
100 // or get the index <DSPindex> of an equal geometry
101 // among those of Edge/Point interferences connected to <FF> (or <EE>).
103 TopOpeBRepDS_ListIteratorOfListOfInterference itEIL1(EIL1);
104 EPIfound = GetGeometry(itEIL1,FEINT,DSPindex,BDS);
105 if ( ! EPIfound ) DSPindex = MakeGeometry(FEINT,BDS);
108 // NYI : FacePointInterference : on ajoute un point INTERNAL a F
109 // FPI = new TopOpeBRepDS_FacePointInterference(TopAbs_INTERNAL,
110 // TopOpeBRepDS_FACE,FFindex,
111 // TopOpeBRepDS_POINT,DSPindex,
113 // StoreInterference(FPI,EIL1,BDS);
116 EPI = TopOpeBRepDS_InterferenceTool::MakeCurveInterference
117 (TEE,TopOpeBRepDS_FACE,FFindex,TopOpeBRepDS_POINT,DSPindex,parE);
118 StoreInterference(EPI,EIL2,BDS);
121 else if ( isvertexF ) {
122 // si aussi vertex de E, in privilegie le vertex de la face
123 Standard_Integer Vindex = BDS.AddShape(V1,1);
126 // NYI pour toute arete de F qui accede V , une EVI
127 // EVI = new TopOpeBRepDS_EdgeVertexInterference(Transition ?? <-> TFF,
128 // TopOpeBRepDS_EDGE,E de F,
129 // TopOpeBRepDS_VERTEX,Vindex,
130 // param de V sur E de F);
131 // StoreInterference(EVI,EIL1,BDS);
134 EPI = new TopOpeBRepDS_CurvePointInterference(TEE,
135 TopOpeBRepDS_FACE,FFindex,
136 TopOpeBRepDS_VERTEX,Vindex,
138 StoreInterference(EPI,EIL2,BDS);
141 else if ( isvertexE ) {
142 Standard_Integer Vindex = BDS.AddShape(V2,2);
145 // NYI : FaceVertexInterference : on ajoute un vertex INTERNAL a F
146 // FVI = new TopOpeBRepDS_FaceVertexInterference(TopAbs_INTERNAL,
147 // TopOpeBRepDS_FACE,FFindex,
148 // TopOpeBRepDS_VERTEX,Vindex,
150 // StoreInterference(FPI,EIL1,BDS);
153 EPI = new TopOpeBRepDS_CurvePointInterference(TEE,
154 TopOpeBRepDS_FACE,FFindex,
155 TopOpeBRepDS_VERTEX,Vindex,
157 StoreInterference(EPI,EIL2,BDS);
168 //-----------------------------------------------------------------------
169 // Search, among a list of interferences accessed by the iterator <IT>,
170 // a geometry whose 3D point is identical yo the 3D point of a DS point <DSP>.
171 // TheDSPointGeomTool is a tool able to access the 3D point of the DS point
172 // DSP,and to test identity (according to tolerance connected to DSP) of the
174 // return True if such an interference has been found, False else.
175 // if True, iterator <IT> points (by the Value() method) on the first
176 // interference accessing an identical 3D point.
177 //-----------------------------------------------------------------------
178 //=======================================================================
179 //function : ScanInterfList
181 //=======================================================================
183 Standard_Boolean TopOpeBRep_FaceEdgeFiller::ScanInterfList
184 (TopOpeBRepDS_ListIteratorOfListOfInterference& IT,
185 const TopOpeBRepDS_Point& DSP,
186 const TopOpeBRepDS_DataStructure& BDS) const
188 for ( ; IT.More(); IT.Next() ) {
189 Standard_Integer DSPG = IT.Value()->Geometry();
190 const TopOpeBRepDS_Point& otherDSP = BDS.Point(DSPG);
191 if (TopOpeBRep_PointGeomTool::IsEqual(DSP,otherDSP)) return Standard_True;
193 return Standard_False;
197 //=======================================================================
198 //function : GetGeometry
200 //=======================================================================
202 Standard_Boolean TopOpeBRep_FaceEdgeFiller::GetGeometry
203 (TopOpeBRepDS_ListIteratorOfListOfInterference& IT,
204 const TopOpeBRep_FaceEdgeIntersector& FEINT,
206 const TopOpeBRepDS_DataStructure& BDS) const
208 TopOpeBRepDS_Point DSP = TopOpeBRep_PointGeomTool::MakePoint(FEINT);
209 Standard_Boolean found = ScanInterfList(IT,DSP,BDS);
210 if (found) G = IT.Value()->Geometry();
215 //=======================================================================
216 //function : GetGeometry
218 //=======================================================================
220 Standard_Boolean TopOpeBRep_FaceEdgeFiller::GetGeometry
221 (const TopOpeBRepDS_ListOfInterference& L,
222 const TopOpeBRepDS_Point& DSP,
224 TopOpeBRepDS_DataStructure& BDS) const
226 TopOpeBRepDS_ListIteratorOfListOfInterference itI(L);
227 Standard_Boolean Ifound = ScanInterfList(itI,DSP,BDS);
228 if (Ifound) G = itI.Value()->Geometry();
229 else G = BDS.AddPoint(DSP);
230 return Ifound; // interference found or not
234 //-----------------------------------------------------------------------
235 // StoreInterference : Append an interference I to a list of interference LI
236 // : Append I to the interf. list connected to I Geometry()
237 //-----------------------------------------------------------------------
238 //=======================================================================
239 //function : StoreInterference
241 //=======================================================================
243 void TopOpeBRep_FaceEdgeFiller::StoreInterference
244 (const Handle(TopOpeBRepDS_Interference)& I,
245 TopOpeBRepDS_ListOfInterference& LI,
246 TopOpeBRepDS_DataStructure& BDS) const
248 // append I to list LI
251 Standard_Integer G = I->Geometry();
253 // append I to list of interference connected to G = I->Geometry()
254 switch (I->GeometryType()) {
256 case TopOpeBRepDS_SOLID : case TopOpeBRepDS_FACE :
257 case TopOpeBRepDS_EDGE : case TopOpeBRepDS_VERTEX :
258 // appendtoG = Standard_True;
259 // BDS.ChangeShapeInterferences(G).Append(I);
262 case TopOpeBRepDS_SURFACE :
263 BDS.ChangeSurfaceInterferences(G).Append(I);
266 case TopOpeBRepDS_CURVE :
267 BDS.ChangeCurveInterferences(G).Append(I);
270 case TopOpeBRepDS_POINT :
271 // appendtoG = Standard_True;
272 // BDS.ChangePointInterferences(G).Append(I);
279 //=======================================================================
280 //function : MakeGeometry
282 //=======================================================================
284 Standard_Integer TopOpeBRep_FaceEdgeFiller::MakeGeometry
285 (TopOpeBRep_FaceEdgeIntersector& FEINT,
286 TopOpeBRepDS_DataStructure& BDS) const
288 Standard_Integer G=0;
291 Standard_Boolean isvertexF = FEINT.IsVertex(1,V1);
293 Standard_Boolean isvertexE = FEINT.IsVertex(2,V2);
294 Standard_Boolean isvertex = isvertexF || isvertexE;
297 if ( isvertexF ) G = BDS.AddShape(V1,1);
298 else if ( isvertexE ) G = BDS.AddShape(V2,2);
301 G = BDS.AddPoint(TopOpeBRep_PointGeomTool::MakePoint(FEINT));