1 // Created on: 1993-06-14
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1993-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.
19 #include <Standard_NoSuchObject.hxx>
20 #include <TCollection_AsciiString.hxx>
21 #include <TColStd_HArray1OfInteger.hxx>
23 #include <TopoDS_Edge.hxx>
24 #include <TopoDS_Face.hxx>
25 #include <TopoDS_Shape.hxx>
26 #include <TopoDS_Vertex.hxx>
27 #include <TopOpeBRepBuild_Builder.hxx>
28 #include <TopOpeBRepBuild_define.hxx>
29 #include <TopOpeBRepBuild_EdgeBuilder.hxx>
30 #include <TopOpeBRepBuild_FaceBuilder.hxx>
31 #include <TopOpeBRepBuild_GTopo.hxx>
32 #include <TopOpeBRepBuild_HBuilder.hxx>
33 #include <TopOpeBRepBuild_PaveSet.hxx>
34 #include <TopOpeBRepBuild_ShapeSet.hxx>
35 #include <TopOpeBRepBuild_ShellFaceSet.hxx>
36 #include <TopOpeBRepBuild_SolidBuilder.hxx>
37 #include <TopOpeBRepBuild_WireEdgeSet.hxx>
38 #include <TopOpeBRepDS_BuildTool.hxx>
39 #include <TopOpeBRepDS_Curve.hxx>
40 #include <TopOpeBRepDS_CurveExplorer.hxx>
41 #include <TopOpeBRepDS_CurveIterator.hxx>
42 #include <TopOpeBRepDS_HDataStructure.hxx>
43 #include <TopOpeBRepDS_PointIterator.hxx>
44 #include <TopOpeBRepDS_SurfaceIterator.hxx>
45 #include <TopOpeBRepTool_ShapeExplorer.hxx>
48 extern Standard_Boolean TopOpeBRepBuild_GettraceCU();
51 //=======================================================================
52 //function : BuildEdges
54 //=======================================================================
55 void TopOpeBRepBuild_Builder::BuildEdges(const Standard_Integer iC,const Handle(TopOpeBRepDS_HDataStructure)& HDS)
58 if (TopOpeBRepBuild_GettraceCU()) cout<<"\nBuildEdges on C "<<iC<<endl;
60 const TopOpeBRepDS_Curve& C = HDS->Curve(iC);
61 const Handle(Geom_Curve)& C3D = C.Curve();
62 const Handle(TopOpeBRepDS_Interference)& I1 = C.GetSCI1();
63 const Handle(TopOpeBRepDS_Interference)& I2 = C.GetSCI2();
64 Standard_Boolean nnn = C3D.IsNull() && I1.IsNull() && I2.IsNull();
70 const TopOpeBRepDS_Curve& curC = HDS->Curve(iC);
71 myBuildTool.MakeEdge(anEdge,curC,HDS->DS());
72 TopOpeBRepBuild_PaveSet PVS(anEdge);
73 TopOpeBRepDS_PointIterator CPIT(HDS->CurvePoints(iC));
74 FillVertexSet(CPIT,TopAbs_IN,PVS);
75 TopOpeBRepBuild_PaveClassifier VCL(anEdge);
76 Standard_Boolean equalpar = PVS.HasEqualParameters();
77 if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
78 Standard_Boolean closvert = PVS.ClosedVertices();
79 VCL.ClosedVertices(closvert);
81 if ( !PVS.MoreLoop() ) {
84 TopOpeBRepBuild_EdgeBuilder EDBU(PVS,VCL);
85 TopTools_ListOfShape& EL = ChangeNewEdges(iC);
86 MakeEdges(anEdge,EDBU,EL);
87 TopTools_ListIteratorOfListOfShape It(EL);
88 Standard_Integer inewC = -1;
89 for (; It.More(); It.Next()) {
90 TopoDS_Edge& newEdge = TopoDS::Edge(It.Value());
91 myBuildTool.RecomputeCurves(curC,TopoDS::Edge(anEdge),newEdge,inewC,HDS);
92 if (inewC != -1) ChangeNewEdges(inewC).Append(newEdge);
98 for (It.Initialize(EL);It.More();It.Next()) {
99 TopoDS_Edge& newEdge = TopoDS::Edge(It.Value());
100 myBuildTool.UpdateEdge(anEdge,newEdge);
105 //=======================================================================
106 //function : BuildEdges
108 //=======================================================================
109 void TopOpeBRepBuild_Builder::BuildEdges(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
111 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
114 TopOpeBRepDS_CurveExplorer cex;
116 Standard_Integer ick = 0;
117 for (cex.Init(BDS,Standard_False); cex.More(); cex.Next()) {
118 Standard_Integer ic = cex.Index();
119 Standard_Boolean ck = cex.IsCurveKeep(ic);
120 Standard_Integer im = cex.Curve(ic).Mother();
121 if (ck == 1 && im != 0 && ick == 0) { ick = ic; break; }
124 for (cex.Init(BDS,Standard_True); cex.More(); cex.Next()) {
125 Standard_Integer ic = cex.Index();
128 BDS.ChangeNbCurves(ick-1);
131 for (cex.Init(BDS,Standard_False); cex.More(); cex.Next()) {
132 Standard_Integer ic = cex.Index();
133 Standard_Integer im = cex.Curve(ic).Mother();
134 if (im != 0 ) continue;
138 Standard_Integer ip, np = HDS->NbPoints();
139 TColStd_HArray1OfInteger tp(0,np,0);
140 for (cex.Init(BDS); cex.More(); cex.Next()) {
142 // const TopOpeBRepDS_Curve& C = cex.Curve();
144 Standard_Integer ic = cex.Index();
145 TopOpeBRepDS_ListIteratorOfListOfInterference it(BDS.CurveInterferences(ic));
146 for(;it.More();it.Next()) {
147 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
149 Standard_Integer ig = I->Geometry();
150 TopOpeBRepDS_Kind kg = I->GeometryType();
151 if (kg == TopOpeBRepDS_POINT && ig <= np) tp.ChangeValue(ig) = tp.Value(ig) + 1;
154 Standard_Integer is = I->Support();
155 TopOpeBRepDS_Kind ks = I->SupportType();
156 if (ks == TopOpeBRepDS_POINT) tp.ChangeValue(is) = tp.Value(is) + 1;
160 Standard_Integer is, ns = BDS.NbShapes();
161 for (is = 1; is <= ns; is++ ) {
162 const TopoDS_Shape& S = BDS.Shape(is);
163 if(S.IsNull()) continue;
164 Standard_Boolean test = (S.ShapeType() == TopAbs_EDGE);
165 if ( !test ) continue;
166 TopOpeBRepDS_ListIteratorOfListOfInterference it(BDS.ShapeInterferences(is));
167 for(;it.More();it.Next()) {
168 const Handle(TopOpeBRepDS_Interference)& I = it.Value();
170 Standard_Integer ig = I->Geometry();
171 TopOpeBRepDS_Kind kg = I->GeometryType();
172 if (kg == TopOpeBRepDS_POINT) tp.ChangeValue(ig) = tp.Value(ig) + 1;
175 Standard_Integer is1 = I->Support();
176 TopOpeBRepDS_Kind ks = I->SupportType();
177 if (ks == TopOpeBRepDS_POINT) tp.ChangeValue(is1) = tp.Value(is1) + 1;
181 for (ip = 1; ip <= np; ip++) if (tp.Value(ip) == 0) BDS.RemovePoint(ip);