1 // Created on: 1993-06-24
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2012 OPEN CASCADE SAS
6 // The content of this file is subject to the Open CASCADE Technology Public
7 // License Version 6.5 (the "License"). You may not use the content of this file
8 // except in compliance with the License. Please obtain a copy of the License
9 // at http://www.opencascade.org and read it completely before using this file.
11 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
12 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
14 // The Original Code and all software distributed under the License is
15 // distributed on an "AS IS" basis, without warranty of any kind, and the
16 // Initial Developer hereby disclaims all such warranties, including without
17 // limitation, any warranties of merchantability, fitness for a particular
18 // purpose or non-infringement. Please see the License for the specific terms
19 // and conditions governing the rights and limitations under the License.
23 #include <TopExp_Explorer.hxx>
24 #include <TopOpeBRepDS_CurveExplorer.hxx>
25 #include <TopOpeBRepDS_IndexedDataMapOfVertexPoint.hxx>
26 #include <TopOpeBRepDS_CurveExplorer.hxx>
27 #include <TopOpeBRepDS_Curve.hxx>
28 #include <TopOpeBRepDS_Point.hxx>
29 #include <TopOpeBRepDS.hxx>
31 #include <TopOpeBRep_define.hxx>
34 Standard_Integer BREP_findPDSamongIDMOVP(const TopOpeBRepDS_Point& PDS,const TopOpeBRepDS_IndexedDataMapOfVertexPoint& IDMOVP)
36 Standard_Integer iIDMOVP = 0;
37 Standard_Integer i = 1, n = IDMOVP.Extent();
39 const TopOpeBRepDS_Point& PM = IDMOVP.FindFromIndex(i);
40 if (PDS.IsEqual(PM)) { iIDMOVP = i; break; }
45 void BREP_makeIDMOVP(const TopoDS_Shape& S,TopOpeBRepDS_IndexedDataMapOfVertexPoint& IDMOVP)
48 for (Ex.Init(S,TopAbs_VERTEX);Ex.More();Ex.Next()) {
49 const TopoDS_Vertex& v = TopoDS::Vertex(Ex.Current());
50 TopOpeBRepDS_Point PDS(v); IDMOVP.Add(v,PDS);
54 Standard_EXPORT void BREP_mergePDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
56 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
57 TopOpeBRepDS_CurveExplorer cex(BDS);if (!cex.More()) return;
59 TopOpeBRepDS_IndexedDataMapOfVertexPoint Mvp1;
60 TopOpeBRepDS_IndexedDataMapOfVertexPoint Mvp2;
62 for (;cex.More();cex.Next()) {
64 const TopOpeBRepDS_Curve& c = cex.Curve(); const Standard_Integer ic = cex.Index();
65 TopOpeBRepDS_ListIteratorOfListOfInterference itI;itI.Initialize(BDS.ChangeCurveInterferences(ic));if (!itI.More()) continue;
67 const TopoDS_Face& f1 = TopoDS::Face(c.Shape1());
69 Standard_Integer if1 =
72 const TopoDS_Face& f2 = TopoDS::Face(c.Shape2());
74 Standard_Integer if2 =
78 Mvp1.Clear();BREP_makeIDMOVP(f1,Mvp1);
79 Mvp2.Clear();BREP_makeIDMOVP(f2,Mvp2);
81 for (; itI.More(); itI.Next()) {
82 Handle(TopOpeBRepDS_Interference) ITF = itI.Value();
83 Handle(TopOpeBRepDS_CurvePointInterference) CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(ITF); if (CPI.IsNull()) continue;
84 TopOpeBRepDS_Kind GK = CPI->GeometryType(); if (GK != TopOpeBRepDS_POINT) continue;
85 Standard_Integer GI = CPI->Geometry();
87 if(GI > BDS.NbPoints()) continue;
89 const TopOpeBRepDS_Point& PDS = BDS.Point(GI);
92 Standard_Integer ivp1; TopoDS_Shape v1; Standard_Boolean newv1 = Standard_False; TopOpeBRepDS_Kind k1; Standard_Integer iv1 = 0;
94 Standard_Integer ivp1; TopoDS_Shape v1; Standard_Boolean newv1 = Standard_False; TopOpeBRepDS_Kind k1=TopOpeBRepDS_UNKNOWN; Standard_Integer iv1 = 0;
96 ivp1 = BREP_findPDSamongIDMOVP(PDS,Mvp1);
98 v1 = Mvp1.FindKey(ivp1);
99 newv1 = !BDS.HasShape(v1);
100 iv1 = BDS.AddShape(v1);
101 k1 = TopOpeBRepDS_VERTEX;
105 Standard_Integer ivp2; TopoDS_Shape v2; Standard_Boolean newv2 = Standard_False; TopOpeBRepDS_Kind k2; Standard_Integer iv2 = 0;
107 Standard_Integer ivp2; TopoDS_Shape v2; Standard_Boolean newv2 = Standard_False; TopOpeBRepDS_Kind k2=TopOpeBRepDS_UNKNOWN; Standard_Integer iv2 = 0;
109 ivp2 = BREP_findPDSamongIDMOVP(PDS,Mvp2);
111 v2 = Mvp2.FindKey(ivp2);
112 newv2 = !BDS.HasShape(v2);
113 iv2 = BDS.AddShape(v2);
114 k2 = TopOpeBRepDS_VERTEX;
117 if (ivp1 && ivp2) BDS.FillShapesSameDomain(v1,v2);
119 Standard_Boolean editITF = (ivp1 || ivp2);
121 if (ivp1) { CPI->GeometryType(k1); CPI->Geometry(iv1); }
122 else if (ivp2) { CPI->GeometryType(k2); CPI->Geometry(iv2); }
128 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS_CURVE,ic,"# BREP_mergePDS "," : ");
129 cout<<TopOpeBRepDS::SPrint(GK,GI,""," = ");
130 TCollection_AsciiString str; if (newv1) str = "new "; else str = "old ";
131 cout<<TopOpeBRepDS::SPrint(k1,iv1,str);
132 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(f1.ShapeType()),if1," de ")<<endl;
135 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS_CURVE,ic,"# BREP_mergePDS "," : ");
136 cout<<TopOpeBRepDS::SPrint(GK,GI,""," = ");
137 TCollection_AsciiString str; if (newv2) str = "new "; else str = "old ";
138 cout<<TopOpeBRepDS::SPrint(k2,iv2,str);
139 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(f2.ShapeType()),if2," de ")<<endl;
141 ITF->Dump(cout,"# BREP_mergePDS resu ","\n");