0027961: Visualization - remove unused and no more working OpenGl_AVIWriter
[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>
ec357c5c 27#include <TopOpeBRepDS_CurvePointInterference.hxx>
7fd59977 28
29
30Standard_Integer BREP_findPDSamongIDMOVP(const TopOpeBRepDS_Point& PDS,const TopOpeBRepDS_IndexedDataMapOfVertexPoint& IDMOVP)
31{
32 Standard_Integer iIDMOVP = 0;
33 Standard_Integer i = 1, n = IDMOVP.Extent();
34 for(; i <= n; i++) {
35 const TopOpeBRepDS_Point& PM = IDMOVP.FindFromIndex(i);
36 if (PDS.IsEqual(PM)) { iIDMOVP = i; break; }
37 }
38 return iIDMOVP;
39}
40
41void BREP_makeIDMOVP(const TopoDS_Shape& S,TopOpeBRepDS_IndexedDataMapOfVertexPoint& IDMOVP)
42{
43 TopExp_Explorer Ex;
44 for (Ex.Init(S,TopAbs_VERTEX);Ex.More();Ex.Next()) {
45 const TopoDS_Vertex& v = TopoDS::Vertex(Ex.Current());
46 TopOpeBRepDS_Point PDS(v); IDMOVP.Add(v,PDS);
47 }
48}
49
1d0a9d4d 50void BREP_mergePDS(const Handle(TopOpeBRepDS_HDataStructure)& HDS)
7fd59977 51{
52 TopOpeBRepDS_DataStructure& BDS = HDS->ChangeDS();
53 TopOpeBRepDS_CurveExplorer cex(BDS);if (!cex.More()) return;
54
55 TopOpeBRepDS_IndexedDataMapOfVertexPoint Mvp1;
56 TopOpeBRepDS_IndexedDataMapOfVertexPoint Mvp2;
57
58 for (;cex.More();cex.Next()) {
59
60 const TopOpeBRepDS_Curve& c = cex.Curve(); const Standard_Integer ic = cex.Index();
61 TopOpeBRepDS_ListIteratorOfListOfInterference itI;itI.Initialize(BDS.ChangeCurveInterferences(ic));if (!itI.More()) continue;
62
63 const TopoDS_Face& f1 = TopoDS::Face(c.Shape1());
0797d9d3 64#ifdef OCCT_DEBUG
7fd59977 65 Standard_Integer if1 =
66#endif
67 BDS.Shape(f1);
68 const TopoDS_Face& f2 = TopoDS::Face(c.Shape2());
0797d9d3 69#ifdef OCCT_DEBUG
7fd59977 70 Standard_Integer if2 =
71#endif
72 BDS.Shape(f2);
73
74 Mvp1.Clear();BREP_makeIDMOVP(f1,Mvp1);
75 Mvp2.Clear();BREP_makeIDMOVP(f2,Mvp2);
76
77 for (; itI.More(); itI.Next()) {
78 Handle(TopOpeBRepDS_Interference) ITF = itI.Value();
79 Handle(TopOpeBRepDS_CurvePointInterference) CPI = Handle(TopOpeBRepDS_CurvePointInterference)::DownCast(ITF); if (CPI.IsNull()) continue;
80 TopOpeBRepDS_Kind GK = CPI->GeometryType(); if (GK != TopOpeBRepDS_POINT) continue;
81 Standard_Integer GI = CPI->Geometry();
82 //**!
83 if(GI > BDS.NbPoints()) continue;
84 //**!
85 const TopOpeBRepDS_Point& PDS = BDS.Point(GI);
86
96a95605 87 Standard_Integer ivp1; TopoDS_Shape v1; TopOpeBRepDS_Kind k1=TopOpeBRepDS_UNKNOWN; Standard_Integer iv1 = 0;
1d47d8d0 88
7fd59977 89 ivp1 = BREP_findPDSamongIDMOVP(PDS,Mvp1);
90 if (ivp1) {
91 v1 = Mvp1.FindKey(ivp1);
7fd59977 92 iv1 = BDS.AddShape(v1);
93 k1 = TopOpeBRepDS_VERTEX;
94 }
95
1d47d8d0 96
96a95605 97 Standard_Integer ivp2; TopoDS_Shape v2; TopOpeBRepDS_Kind k2=TopOpeBRepDS_UNKNOWN; Standard_Integer iv2 = 0;
1d47d8d0 98
7fd59977 99 ivp2 = BREP_findPDSamongIDMOVP(PDS,Mvp2);
100 if (ivp2) {
101 v2 = Mvp2.FindKey(ivp2);
7fd59977 102 iv2 = BDS.AddShape(v2);
103 k2 = TopOpeBRepDS_VERTEX;
104 }
105
106 if (ivp1 && ivp2) BDS.FillShapesSameDomain(v1,v2);
107
108 Standard_Boolean editITF = (ivp1 || ivp2);
109 if (editITF) {
110 if (ivp1) { CPI->GeometryType(k1); CPI->Geometry(iv1); }
111 else if (ivp2) { CPI->GeometryType(k2); CPI->Geometry(iv2); }
112 }
113
0797d9d3 114#ifdef OCCT_DEBUG
7fd59977 115 if (editITF) {
116 if (ivp1 != 0) {
117 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS_CURVE,ic,"# BREP_mergePDS "," : ");
118 cout<<TopOpeBRepDS::SPrint(GK,GI,""," = ");
96a95605 119 TCollection_AsciiString str (BDS.HasShape(v1) ? "old" : "new ");
7fd59977 120 cout<<TopOpeBRepDS::SPrint(k1,iv1,str);
121 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(f1.ShapeType()),if1," de ")<<endl;
122 }
123 if (ivp2 != 0) {
124 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS_CURVE,ic,"# BREP_mergePDS "," : ");
125 cout<<TopOpeBRepDS::SPrint(GK,GI,""," = ");
96a95605 126 TCollection_AsciiString str (BDS.HasShape(v2) ? "old" : "new ");
7fd59977 127 cout<<TopOpeBRepDS::SPrint(k2,iv2,str);
128 cout<<TopOpeBRepDS::SPrint(TopOpeBRepDS::ShapeToKind(f2.ShapeType()),if2," de ")<<endl;
129 }
7fd59977 130 }
131#endif
132
133 } // itI.More()
134 }
135} // BREP_mergePDS