b311480e |
1 | // Created on: 1993-06-14 |
2 | // Created by: Jean Yves LEBEY |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
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 |
973c2be1 |
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. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
7fd59977 |
16 | |
17 | #include <TopOpeBRepBuild_Builder.jxx> |
18 | #include <TColStd_HArray1OfInteger.hxx> |
19 | #include <TopOpeBRepDS_CurveExplorer.hxx> |
20 | #include <TopOpeBRepDS_Curve.hxx> |
21 | #include <TopoDS.hxx> |
22 | #include <TopOpeBRepBuild_define.hxx> |
23 | |
0797d9d3 |
24 | #ifdef OCCT_DEBUG |
1d0a9d4d |
25 | extern Standard_Boolean TopOpeBRepBuild_GettraceCU(); |
7fd59977 |
26 | #endif |
27 | |
28 | //======================================================================= |
29 | //function : BuildEdges |
30 | //purpose : |
31 | //======================================================================= |
32 | void TopOpeBRepBuild_Builder::BuildEdges(const Standard_Integer iC,const Handle(TopOpeBRepDS_HDataStructure)& HDS) |
33 | { |
0797d9d3 |
34 | #ifdef OCCT_DEBUG |
7fd59977 |
35 | if (TopOpeBRepBuild_GettraceCU()) cout<<"\nBuildEdges on C "<<iC<<endl; |
36 | #endif |
37 | const TopOpeBRepDS_Curve& C = HDS->Curve(iC); |
38 | const Handle(Geom_Curve)& C3D = C.Curve(); |
39 | const Handle(TopOpeBRepDS_Interference)& I1 = C.GetSCI1(); |
40 | const Handle(TopOpeBRepDS_Interference)& I2 = C.GetSCI2(); |
41 | Standard_Boolean nnn = C3D.IsNull() && I1.IsNull() && I2.IsNull(); |
42 | if (nnn) { |
43 | return; |
44 | } |
45 | |
46 | TopoDS_Shape anEdge; |
47 | const TopOpeBRepDS_Curve& curC = HDS->Curve(iC); |
48 | myBuildTool.MakeEdge(anEdge,curC,HDS->DS()); |
49 | TopOpeBRepBuild_PaveSet PVS(anEdge); |
50 | TopOpeBRepDS_PointIterator CPIT(HDS->CurvePoints(iC)); |
51 | FillVertexSet(CPIT,TopAbs_IN,PVS); |
52 | TopOpeBRepBuild_PaveClassifier VCL(anEdge); |
53 | Standard_Boolean equalpar = PVS.HasEqualParameters(); |
54 | if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters()); |
55 | Standard_Boolean closvert = PVS.ClosedVertices(); |
56 | VCL.ClosedVertices(closvert); |
57 | PVS.InitLoop(); |
58 | if ( !PVS.MoreLoop() ) { |
59 | return; |
60 | } |
61 | TopOpeBRepBuild_EdgeBuilder EDBU(PVS,VCL); |
62 | TopTools_ListOfShape& EL = ChangeNewEdges(iC); |
63 | MakeEdges(anEdge,EDBU,EL); |
64 | TopTools_ListIteratorOfListOfShape It(EL); |
65 | Standard_Integer inewC = -1; |
66 | for (; It.More(); It.Next()) { |
67 | TopoDS_Edge& newEdge = TopoDS::Edge(It.Value()); |
68 | myBuildTool.RecomputeCurves(curC,TopoDS::Edge(anEdge),newEdge,inewC,HDS); |
69 | if (inewC != -1) ChangeNewEdges(inewC).Append(newEdge); |
70 | } |
71 | if (inewC != -1) { |
72 | HDS->RemoveCurve(iC); |
73 | } |
74 | else { |
75 | for (It.Initialize(EL);It.More();It.Next()) { |
76 | TopoDS_Edge& newEdge = TopoDS::Edge(It.Value()); |
77 | myBuildTool.UpdateEdge(anEdge,newEdge); |
78 | } |
79 | } |
80 | } |
81 | |
82 | //======================================================================= |
83 | //function : BuildEdges |
84 | //purpose : |
85 | //======================================================================= |
86 | void TopOpeBRepBuild_Builder::BuildEdges(const Handle(TopOpeBRepDS_HDataStructure)& HDS) |
87 | { |
88 | TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS(); |
89 | |
90 | myNewEdges.Clear(); |
7fd59977 |
91 | TopOpeBRepDS_CurveExplorer cex; |
92 | |
93 | Standard_Integer ick = 0; |
94 | for (cex.Init(BDS,Standard_False); cex.More(); cex.Next()) { |
95 | Standard_Integer ic = cex.Index(); |
96 | Standard_Boolean ck = cex.IsCurveKeep(ic); |
97 | Standard_Integer im = cex.Curve(ic).Mother(); |
98 | if (ck == 1 && im != 0 && ick == 0) { ick = ic; break; } |
99 | } |
100 | if (ick) { |
101 | for (cex.Init(BDS,Standard_True); cex.More(); cex.Next()) { |
102 | Standard_Integer ic = cex.Index(); |
103 | BDS.RemoveCurve(ic); |
104 | } |
105 | BDS.ChangeNbCurves(ick-1); |
106 | } |
107 | |
7fd59977 |
108 | for (cex.Init(BDS,Standard_False); cex.More(); cex.Next()) { |
109 | Standard_Integer ic = cex.Index(); |
110 | Standard_Integer im = cex.Curve(ic).Mother(); |
111 | if (im != 0 ) continue; |
112 | BuildEdges(ic,HDS); |
113 | } |
114 | |
115 | Standard_Integer ip, np = HDS->NbPoints(); |
116 | TColStd_HArray1OfInteger tp(0,np,0); |
117 | for (cex.Init(BDS); cex.More(); cex.Next()) { |
0797d9d3 |
118 | #ifdef OCCT_DEBUG |
7fd59977 |
119 | // const TopOpeBRepDS_Curve& C = cex.Curve(); |
120 | #endif |
121 | Standard_Integer ic = cex.Index(); |
122 | TopOpeBRepDS_ListIteratorOfListOfInterference it(BDS.CurveInterferences(ic)); |
123 | for(;it.More();it.Next()) { |
124 | const Handle(TopOpeBRepDS_Interference)& I = it.Value(); |
125 | { |
126 | Standard_Integer ig = I->Geometry(); |
127 | TopOpeBRepDS_Kind kg = I->GeometryType(); |
128 | if (kg == TopOpeBRepDS_POINT && ig <= np) tp.ChangeValue(ig) = tp.Value(ig) + 1; |
129 | } |
130 | { |
131 | Standard_Integer is = I->Support(); |
132 | TopOpeBRepDS_Kind ks = I->SupportType(); |
133 | if (ks == TopOpeBRepDS_POINT) tp.ChangeValue(is) = tp.Value(is) + 1; |
134 | } |
135 | } |
136 | } |
137 | Standard_Integer is, ns = BDS.NbShapes(); |
138 | for (is = 1; is <= ns; is++ ) { |
139 | const TopoDS_Shape& S = BDS.Shape(is); |
140 | if(S.IsNull()) continue; |
141 | Standard_Boolean test = (S.ShapeType() == TopAbs_EDGE); |
142 | if ( !test ) continue; |
143 | TopOpeBRepDS_ListIteratorOfListOfInterference it(BDS.ShapeInterferences(is)); |
144 | for(;it.More();it.Next()) { |
145 | const Handle(TopOpeBRepDS_Interference)& I = it.Value(); |
146 | { |
147 | Standard_Integer ig = I->Geometry(); |
148 | TopOpeBRepDS_Kind kg = I->GeometryType(); |
149 | if (kg == TopOpeBRepDS_POINT) tp.ChangeValue(ig) = tp.Value(ig) + 1; |
150 | } |
151 | { |
152 | Standard_Integer is1 = I->Support(); |
153 | TopOpeBRepDS_Kind ks = I->SupportType(); |
154 | if (ks == TopOpeBRepDS_POINT) tp.ChangeValue(is1) = tp.Value(is1) + 1; |
155 | } |
156 | } |
157 | } |
158 | for (ip = 1; ip <= np; ip++) if (tp.Value(ip) == 0) BDS.RemovePoint(ip); |
159 | } |