1 // Created on: 1996-03-07
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1996-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
9 // under the terms of the GNU Lesser General Public 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.
17 #include <TopOpeBRepBuild_Builder.ixx>
21 #include <BRep_Tool.hxx>
22 #include <TopOpeBRepTool_TOOL.hxx>
23 #include <TopOpeBRepDS_EXPORT.hxx>
24 #include <TopOpeBRepBuild_define.hxx>
27 extern void debfillp(const Standard_Integer i);
28 extern void debedbu(const Standard_Integer i) {cout<<"++ debedbu "<<i<<endl;}
32 #include <TopOpeBRepTool_DRAW.hxx>
35 //=======================================================================
36 //function : GPVSMakeEdges
38 //=======================================================================
39 void TopOpeBRepBuild_Builder::GPVSMakeEdges
40 (const TopoDS_Shape& EF,TopOpeBRepBuild_PaveSet& PVS,TopTools_ListOfShape& LOE) const
43 Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(EF,iE);
44 if (tSPS) debfillp(iE);
47 TopOpeBRepBuild_PaveClassifier VCL(EF);
48 Standard_Boolean equalpar = PVS.HasEqualParameters();
49 if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
52 Standard_Boolean novertex = ( ! PVS.MoreLoop() );
54 if(tSPS&&novertex)cout<<"#--- GPVSMakeEdges : no vertex from edge "<<iE<<endl;
58 TopOpeBRepBuild_EdgeBuilder EDBU;
59 Standard_Boolean ForceClass = Standard_False;
60 EDBU.InitEdgeBuilder(PVS,VCL,ForceClass);
61 GEDBUMakeEdges(EF,EDBU,LOE);
65 //=======================================================================
66 //function : GEDBUMakeEdges
68 //=======================================================================
69 void TopOpeBRepBuild_Builder::GEDBUMakeEdges
70 (const TopoDS_Shape& EF,TopOpeBRepBuild_EdgeBuilder& EDBU,TopTools_ListOfShape& LOE) const
73 Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(EF,iE);
74 if(tSPS){cout<<endl;GdumpSHA(EF, (char *) "#--- GEDBUMakeEdges ");cout<<endl;}
75 if(tSPS){GdumpEDBU(EDBU);}
76 if(tSPS){debedbu(iE);}
80 for (EDBU.InitEdge(); EDBU.MoreEdge(); EDBU.NextEdge()) {
82 Standard_Integer nloop = 0;
83 Standard_Boolean tosplit = Standard_False;
84 for (EDBU.InitVertex(); EDBU.MoreVertex(); EDBU.NextVertex()) nloop++;
85 // 0 ou 1 vertex sur edge courante => suppression edge
86 if ( nloop <= 1 ) continue;
88 myBuildTool.CopyEdge(EF,newEdge);
90 Standard_Integer nVF = 0, nVR = 0; // nb vertex FORWARD,REVERSED
92 TopoDS_Shape VF,VR; // gestion du bit Closed
96 for (EDBU.InitVertex(); EDBU.MoreVertex(); EDBU.NextVertex()) {
97 TopoDS_Shape V = EDBU.Vertex();
98 TopAbs_Orientation Vori = V.Orientation();
100 Standard_Boolean hassd = myDataStructure->HasSameDomain(V);
101 if (hassd) { // on prend le vertex reference de V
102 Standard_Integer iref = myDataStructure->SameDomainReference(V);
103 V = myDataStructure->Shape(iref);
107 TopAbs_Orientation oriV = V.Orientation();
108 if ( oriV == TopAbs_EXTERNAL ) continue;
110 Standard_Boolean equafound = Standard_False;
111 TopExp_Explorer exE(newEdge,TopAbs_VERTEX);
112 for (; exE.More(); exE.Next() ) {
113 const TopoDS_Shape& VE = exE.Current();
114 TopAbs_Orientation oriVE = VE.Orientation();
116 if ( V.IsEqual(VE) ) {
117 equafound = Standard_True;
120 else if (oriVE == TopAbs_FORWARD || oriVE == TopAbs_REVERSED) {
122 equafound = Standard_True;
126 else if (oriVE == TopAbs_INTERNAL || oriVE == TopAbs_EXTERNAL) {
127 Standard_Real parV = EDBU.Parameter();
128 Standard_Real parVE = BRep_Tool::Parameter(TopoDS::Vertex(VE),TopoDS::Edge(newEdge));
129 if ( parV == parVE ) {
130 equafound = Standard_True;
136 if (Vori == TopAbs_FORWARD) {
138 if (nVF == 1) VF = V;
140 if (Vori == TopAbs_REVERSED) {
142 if (nVR == 1) VR = V;
144 if (oriV == TopAbs_INTERNAL) tosplit = Standard_True;
145 Standard_Real parV = EDBU.Parameter();
146 myBuildTool.AddEdgeVertex(newEdge,V);
147 myBuildTool.Parameter(newEdge,V,parV);
150 } // EDBUloop.InitVertex : on vertices of new edge newEdge
152 Standard_Boolean addedge = (nVF == 1 && nVR == 1);
153 Standard_Boolean bitclosed = Standard_False;
154 if (nVF == 1 && nVR == 1) {
155 bitclosed = VF.IsSame(VR);
156 newEdge.Closed(bitclosed);
160 TopTools_ListOfShape loe; Standard_Boolean ok = TopOpeBRepTool_TOOL::SplitE(TopoDS::Edge(newEdge),loe);
161 if (!ok) tosplit = Standard_False;
162 else LOE.Append(loe);
164 if (!tosplit) LOE.Append(newEdge);
166 } // EDBU.InitEdge : loop on EDBU edges
171 TCollection_AsciiString str1; str1 = "e";
172 TCollection_AsciiString str2; str2 = iE;
173 FDRAW_DINLOE("",LOE,str1,str2);