b311480e |
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 |
5 | // |
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. |
10 | // |
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. |
13 | // |
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. |
20 | |
7fd59977 |
21 | |
22 | #include <TopoDS.hxx> |
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> |
30 | |
31 | #include <TopOpeBRep_define.hxx> |
32 | |
33 | |
34 | Standard_Integer BREP_findPDSamongIDMOVP(const TopOpeBRepDS_Point& PDS,const TopOpeBRepDS_IndexedDataMapOfVertexPoint& IDMOVP) |
35 | { |
36 | Standard_Integer iIDMOVP = 0; |
37 | Standard_Integer i = 1, n = IDMOVP.Extent(); |
38 | for(; i <= n; i++) { |
39 | const TopOpeBRepDS_Point& PM = IDMOVP.FindFromIndex(i); |
40 | if (PDS.IsEqual(PM)) { iIDMOVP = i; break; } |
41 | } |
42 | return iIDMOVP; |
43 | } |
44 | |
45 | void BREP_makeIDMOVP(const TopoDS_Shape& S,TopOpeBRepDS_IndexedDataMapOfVertexPoint& IDMOVP) |
46 | { |
47 | TopExp_Explorer Ex; |
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); |
51 | } |
52 | } |
53 | |
1d0a9d4d |
54 | void BREP_mergePDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS) |
7fd59977 |
55 | { |
56 | TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS(); |
57 | TopOpeBRepDS_CurveExplorer cex(BDS);if (!cex.More()) return; |
58 | |
59 | TopOpeBRepDS_IndexedDataMapOfVertexPoint Mvp1; |
60 | TopOpeBRepDS_IndexedDataMapOfVertexPoint Mvp2; |
61 | |
62 | for (;cex.More();cex.Next()) { |
63 | |
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; |
66 | |
67 | const TopoDS_Face& f1 = TopoDS::Face(c.Shape1()); |
68 | #ifdef DEB |
69 | Standard_Integer if1 = |
70 | #endif |
71 | BDS.Shape(f1); |
72 | const TopoDS_Face& f2 = TopoDS::Face(c.Shape2()); |
73 | #ifdef DEB |
74 | Standard_Integer if2 = |
75 | #endif |
76 | BDS.Shape(f2); |
77 | |
78 | Mvp1.Clear();BREP_makeIDMOVP(f1,Mvp1); |
79 | Mvp2.Clear();BREP_makeIDMOVP(f2,Mvp2); |
80 | |
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(); |
86 | //**! |
87 | if(GI > BDS.NbPoints()) continue; |
88 | //**! |
89 | const TopOpeBRepDS_Point& PDS = BDS.Point(GI); |
90 | |
7fd59977 |
91 | Standard_Integer ivp1; TopoDS_Shape v1; Standard_Boolean newv1 = Standard_False; TopOpeBRepDS_Kind k1=TopOpeBRepDS_UNKNOWN; Standard_Integer iv1 = 0; |
1d47d8d0 |
92 | |
7fd59977 |
93 | ivp1 = BREP_findPDSamongIDMOVP(PDS,Mvp1); |
94 | if (ivp1) { |
95 | v1 = Mvp1.FindKey(ivp1); |
96 | newv1 = !BDS.HasShape(v1); |
97 | iv1 = BDS.AddShape(v1); |
98 | k1 = TopOpeBRepDS_VERTEX; |
99 | } |
100 | |
1d47d8d0 |
101 | |
7fd59977 |
102 | Standard_Integer ivp2; TopoDS_Shape v2; Standard_Boolean newv2 = Standard_False; TopOpeBRepDS_Kind k2=TopOpeBRepDS_UNKNOWN; Standard_Integer iv2 = 0; |
1d47d8d0 |
103 | |
7fd59977 |
104 | ivp2 = BREP_findPDSamongIDMOVP(PDS,Mvp2); |
105 | if (ivp2) { |
106 | v2 = Mvp2.FindKey(ivp2); |
107 | newv2 = !BDS.HasShape(v2); |
108 | iv2 = BDS.AddShape(v2); |
109 | k2 = TopOpeBRepDS_VERTEX; |
110 | } |
111 | |
112 | if (ivp1 && ivp2) BDS.FillShapesSameDomain(v1,v2); |
113 | |
114 | Standard_Boolean editITF = (ivp1 || ivp2); |
115 | if (editITF) { |
116 | if (ivp1) { CPI->GeometryType(k1); CPI->Geometry(iv1); } |
117 | else if (ivp2) { CPI->GeometryType(k2); CPI->Geometry(iv2); } |
118 | } |
119 | |
120 | #ifdef DEB |
121 | if (editITF) { |
122 | if (ivp1 != 0) { |
123 | cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS_CURVE,ic,"# BREP_mergePDS "," : "); |
124 | cout<<TopOpeBRepDS::SPrint(GK,GI,""," = "); |
125 | TCollection_AsciiString str; if (newv1) str = "new "; else str = "old "; |
126 | cout<<TopOpeBRepDS::SPrint(k1,iv1,str); |
127 | cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(f1.ShapeType()),if1," de ")<<endl; |
128 | } |
129 | if (ivp2 != 0) { |
130 | cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS_CURVE,ic,"# BREP_mergePDS "," : "); |
131 | cout<<TopOpeBRepDS::SPrint(GK,GI,""," = "); |
132 | TCollection_AsciiString str; if (newv2) str = "new "; else str = "old "; |
133 | cout<<TopOpeBRepDS::SPrint(k2,iv2,str); |
134 | cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(f2.ShapeType()),if2," de ")<<endl; |
135 | } |
136 | ITF->Dump(cout,"# BREP_mergePDS resu ","\n"); |
137 | } |
138 | #endif |
139 | |
140 | } // itI.More() |
141 | } |
142 | } // BREP_mergePDS |