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
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16 
17 
18 #include <BRep_Builder.hxx>
19 #include <BRep_Tool.hxx>
20 #include <gp_Pnt.hxx>
21 #include <Standard_NoSuchObject.hxx>
22 #include <TCollection_AsciiString.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_CurveIterator.hxx>
40 #include <TopOpeBRepDS_HDataStructure.hxx>
41 #include <TopOpeBRepDS_PointIterator.hxx>
42 #include <TopOpeBRepDS_SurfaceIterator.hxx>
43 #include <TopOpeBRepTool_ShapeExplorer.hxx>
44 
45 #ifdef OCCT_DEBUG
46 extern Standard_Boolean TopOpeBRepBuild_GettraceCU();
47 extern Standard_Boolean TopOpeBRepBuild_GettraceCUV();
48 extern Standard_Boolean TopOpeBRepBuild_GettraceSPF();
49 extern Standard_Boolean TopOpeBRepBuild_GettraceSPS();
50 extern Standard_Boolean TopOpeBRepBuild_GetcontextSF2();
51 extern Standard_Boolean TopOpeBRepBuild_GettraceSHEX();
52 #endif
53 
54 //=======================================================================
55 //function : BuildFaces
56 //purpose  :
57 //=======================================================================
BuildFaces(const Standard_Integer iS,const Handle (TopOpeBRepDS_HDataStructure)& HDS)58 void TopOpeBRepBuild_Builder::BuildFaces(const Standard_Integer iS,
59 					 const Handle(TopOpeBRepDS_HDataStructure)& HDS)
60 {
61   Standard_Real aTBSTol, aTBCTol;
62   BRep_Builder aBB;
63   TopoDS_Shape aFace;
64   //
65   //modified by NIZNHY-PKV Mon Dec 13 10:00:23 2010f
66   const TopOpeBRepDS_Surface& aTBS=HDS->Surface(iS);
67   aTBSTol=aTBS.Tolerance();
68   //
69   myBuildTool.MakeFace(aFace, aTBS);
70   //
71   //myBuildTool.MakeFace(aFace,HDS->Surface(iS));
72   //modified by NIZNHY-PKV Mon Dec 13 10:01:03 2010t
73   //
74   TopOpeBRepBuild_WireEdgeSet WES(aFace, this);
75   //
76 #ifdef OCCT_DEBUG
77   Standard_Boolean tSE = TopOpeBRepBuild_GettraceSPF();
78 #endif
79   //
80   TopOpeBRepDS_CurveIterator SCurves(HDS->SurfaceCurves(iS));
81   for (;  SCurves.More(); SCurves.Next()) {
82     Standard_Integer iC = SCurves.Current();
83     const TopOpeBRepDS_Curve& CDS = HDS->Curve(iC);
84 #ifdef OCCT_DEBUG
85     if (tSE) std::cout<<std::endl<<"BuildFaces : C "<<iC<<" on S "<<iS<<std::endl;
86 #endif
87     TopoDS_Shape anEdge;
88     TopTools_ListIteratorOfListOfShape Iti(NewEdges(iC));
89     for (;  Iti.More();  Iti.Next()) {
90       anEdge = Iti.Value();
91       //modified by NIZNHY-PKV Mon Dec 13 10:09:38 2010f
92       TopoDS_Edge& aE=*((TopoDS_Edge*)&anEdge);
93       aTBCTol=BRep_Tool::Tolerance(aE);
94       if (aTBCTol < aTBSTol) {
95 	aBB.UpdateEdge(aE, aTBSTol);
96       }
97       //modified by NIZNHY-PKV Mon Dec 13 10:09:43 2010f
98       TopAbs_Orientation ori = SCurves.Orientation(TopAbs_IN);
99       myBuildTool.Orientation(anEdge,ori);
100       const Handle(Geom2d_Curve)& PC = SCurves.PCurve();
101       myBuildTool.PCurve(aFace,anEdge,CDS,PC);
102       WES.AddStartElement(anEdge);
103     }
104   }
105   //
106   TopOpeBRepBuild_FaceBuilder FABU(WES,aFace);
107   TopTools_ListOfShape& FaceList = ChangeNewFaces(iS);
108   MakeFaces(aFace,FABU,FaceList);
109 }
110 
111 //=======================================================================
112 //function : BuildFaces
113 //purpose  :
114 //=======================================================================
BuildFaces(const Handle (TopOpeBRepDS_HDataStructure)& HDS)115 void TopOpeBRepBuild_Builder::BuildFaces(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
116 {
117   Standard_Integer iS, n = HDS->NbSurfaces();
118   myNewFaces = new TopTools_HArray1OfListOfShape(0,n);
119   for (iS = 1; iS <= n; iS++) BuildFaces(iS,HDS);
120 }
121