0025418: Debug output to be limited to OCC development environment
[occt.git] / src / TopOpeBRep / TopOpeBRep_mergePDS.cxx
CommitLineData
b311480e 1// Created on: 1993-06-24
2// Created by: Jean Yves LEBEY
3// Copyright (c) 1993-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 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
973c2be1 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <TopoDS.hxx>
18#include <TopExp_Explorer.hxx>
19#include <TopOpeBRepDS_CurveExplorer.hxx>
20#include <TopOpeBRepDS_IndexedDataMapOfVertexPoint.hxx>
21#include <TopOpeBRepDS_CurveExplorer.hxx>
22#include <TopOpeBRepDS_Curve.hxx>
23#include <TopOpeBRepDS_Point.hxx>
24#include <TopOpeBRepDS.hxx>
25
26#include <TopOpeBRep_define.hxx>
27
28
29Standard_Integer BREP_findPDSamongIDMOVP(const TopOpeBRepDS_Point& PDS,const TopOpeBRepDS_IndexedDataMapOfVertexPoint& IDMOVP)
30{
31 Standard_Integer iIDMOVP = 0;
32 Standard_Integer i = 1, n = IDMOVP.Extent();
33 for(; i <= n; i++) {
34 const TopOpeBRepDS_Point& PM = IDMOVP.FindFromIndex(i);
35 if (PDS.IsEqual(PM)) { iIDMOVP = i; break; }
36 }
37 return iIDMOVP;
38}
39
40void BREP_makeIDMOVP(const TopoDS_Shape& S,TopOpeBRepDS_IndexedDataMapOfVertexPoint& IDMOVP)
41{
42 TopExp_Explorer Ex;
43 for (Ex.Init(S,TopAbs_VERTEX);Ex.More();Ex.Next()) {
44 const TopoDS_Vertex& v = TopoDS::Vertex(Ex.Current());
45 TopOpeBRepDS_Point PDS(v); IDMOVP.Add(v,PDS);
46 }
47}
48
1d0a9d4d 49void BREP_mergePDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
7fd59977 50{
51 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
52 TopOpeBRepDS_CurveExplorer cex(BDS);if (!cex.More()) return;
53
54 TopOpeBRepDS_IndexedDataMapOfVertexPoint Mvp1;
55 TopOpeBRepDS_IndexedDataMapOfVertexPoint Mvp2;
56
57 for (;cex.More();cex.Next()) {
58
59 const TopOpeBRepDS_Curve& c = cex.Curve(); const Standard_Integer ic = cex.Index();
60 TopOpeBRepDS_ListIteratorOfListOfInterference itI;itI.Initialize(BDS.ChangeCurveInterferences(ic));if (!itI.More()) continue;
61
62 const TopoDS_Face& f1 = TopoDS::Face(c.Shape1());
0797d9d3 63#ifdef OCCT_DEBUG
7fd59977 64 Standard_Integer if1 =
65#endif
66 BDS.Shape(f1);
67 const TopoDS_Face& f2 = TopoDS::Face(c.Shape2());
0797d9d3 68#ifdef OCCT_DEBUG
7fd59977 69 Standard_Integer if2 =
70#endif
71 BDS.Shape(f2);
72
73 Mvp1.Clear();BREP_makeIDMOVP(f1,Mvp1);
74 Mvp2.Clear();BREP_makeIDMOVP(f2,Mvp2);
75
76 for (; itI.More(); itI.Next()) {
77 Handle(TopOpeBRepDS_Interference) ITF = itI.Value();
78 Handle(TopOpeBRepDS_CurvePointInterference) CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(ITF); if (CPI.IsNull()) continue;
79 TopOpeBRepDS_Kind GK = CPI->GeometryType(); if (GK != TopOpeBRepDS_POINT) continue;
80 Standard_Integer GI = CPI->Geometry();
81 //**!
82 if(GI > BDS.NbPoints()) continue;
83 //**!
84 const TopOpeBRepDS_Point& PDS = BDS.Point(GI);
85
96a95605 86 Standard_Integer ivp1; TopoDS_Shape v1; TopOpeBRepDS_Kind k1=TopOpeBRepDS_UNKNOWN; Standard_Integer iv1 = 0;
1d47d8d0 87
7fd59977 88 ivp1 = BREP_findPDSamongIDMOVP(PDS,Mvp1);
89 if (ivp1) {
90 v1 = Mvp1.FindKey(ivp1);
7fd59977 91 iv1 = BDS.AddShape(v1);
92 k1 = TopOpeBRepDS_VERTEX;
93 }
94
1d47d8d0 95
96a95605 96 Standard_Integer ivp2; TopoDS_Shape v2; TopOpeBRepDS_Kind k2=TopOpeBRepDS_UNKNOWN; Standard_Integer iv2 = 0;
1d47d8d0 97
7fd59977 98 ivp2 = BREP_findPDSamongIDMOVP(PDS,Mvp2);
99 if (ivp2) {
100 v2 = Mvp2.FindKey(ivp2);
7fd59977 101 iv2 = BDS.AddShape(v2);
102 k2 = TopOpeBRepDS_VERTEX;
103 }
104
105 if (ivp1 && ivp2) BDS.FillShapesSameDomain(v1,v2);
106
107 Standard_Boolean editITF = (ivp1 || ivp2);
108 if (editITF) {
109 if (ivp1) { CPI->GeometryType(k1); CPI->Geometry(iv1); }
110 else if (ivp2) { CPI->GeometryType(k2); CPI->Geometry(iv2); }
111 }
112
0797d9d3 113#ifdef OCCT_DEBUG
7fd59977 114 if (editITF) {
115 if (ivp1 != 0) {
116 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS_CURVE,ic,"# BREP_mergePDS "," : ");
117 cout<<TopOpeBRepDS::SPrint(GK,GI,""," = ");
96a95605 118 TCollection_AsciiString str (BDS.HasShape(v1) ? "old" : "new ");
7fd59977 119 cout<<TopOpeBRepDS::SPrint(k1,iv1,str);
120 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(f1.ShapeType()),if1," de ")<<endl;
121 }
122 if (ivp2 != 0) {
123 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS_CURVE,ic,"# BREP_mergePDS "," : ");
124 cout<<TopOpeBRepDS::SPrint(GK,GI,""," = ");
96a95605 125 TCollection_AsciiString str (BDS.HasShape(v2) ? "old" : "new ");
7fd59977 126 cout<<TopOpeBRepDS::SPrint(k2,iv2,str);
127 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(f2.ShapeType()),if2," de ")<<endl;
128 }
129 ITF->Dump(cout,"# BREP_mergePDS resu ","\n");
130 }
131#endif
132
133 } // itI.More()
134 }
135} // BREP_mergePDS