1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
|
// File: MDocStd.cxx
// Created: Wed Nov 12 10:04:20 1997
// Author: Guest Design
// <g_design@salgox.paris1.matra-dtv.fr>
#include <MDocStd.ixx>
#include <MDocStd_DocumentStorageDriver.hxx>
#include <MDocStd_DocumentRetrievalDriver.hxx>
#include <Standard_Failure.hxx>
#include <MDocStd_XLinkStorageDriver.hxx>
#include <MDocStd_XLinkRetrievalDriver.hxx>
#include <CDM_MessageDriver.hxx>
#include <TDF_Tool.hxx>
static Standard_GUID StandardStorageDriver ("ad696000-5b34-11d1-b5ba-00a0c9064368");
static Standard_GUID StandardRetrievalDriver ("ad696001-5b34-11d1-b5ba-00a0c9064368");
/* ======= not used functionality ======
//#include <TDocStd_Document.hxx>
//#include <MDocStd_PersistentMap.hxx>
//#include <TDocStd_XLink.hxx>
//#include <TDocStd_XLinkIterator.hxx>
//#include <MDocStd_ListIteratorOfDocEntryList.hxx>
//#include <TDF_Label.hxx>
//#include <TDF_ChildIterator.hxx>
//#include <TNaming_NamedShape.hxx>
//#include <PNaming_NamedShape.hxx>
//#include <PTopoDS_Shape1.hxx>
//#include <TopoDS_Shape.hxx>
//#include <PTopoDS_TShape1.hxx>
//#include <PTopoDS_HArray1OfShape1.hxx>
//#include <PBRep_TVertex1.hxx>
//#include <PBRep_PointRepresentation.hxx>
//#include <PBRep_TEdge1.hxx>
//#include <PBRep_CurveRepresentation.hxx>
//#include <PBRep_TFace1.hxx>
//#include <PGeom_Surface.hxx>
//#include <TColStd_ListOfAsciiString.hxx>
//=======================================================================
//function : WeightWatcher
//purpose :
//=======================================================================
static void ShapeWeightWatcher (const PTopoDS_Shape1& PS,
MDocStd_PersistentMap& aMap)
{
if (aMap.Add(PS.TShape())) {
Handle(PTopoDS_TShape1) TS = PS.TShape();
Handle(PTopoDS_HArray1OfShape1) HS = TS->Shapes();
if (!HS.IsNull()) {
for (Standard_Integer i=1;i<=HS->Length();i++) {
const PTopoDS_Shape1& VAL = HS->Value(i);
if (!VAL.TShape().IsNull())ShapeWeightWatcher(VAL,aMap);
}
Handle(PBRep_TVertex1) TV = Handle(PBRep_TVertex1)::DownCast(TS);
if (!TV.IsNull()) {
Handle(PBRep_PointRepresentation) PR;
TV->Points(PR);
return;
}
Handle(PBRep_TEdge1) TE = Handle(PBRep_TEdge1)::DownCast(TS);
if (!TE.IsNull()) {
Handle(PBRep_CurveRepresentation) CR;
TE->Curves(CR);
return;
}
Handle(PBRep_TFace1) TF = Handle(PBRep_TFace1)::DownCast(TS);
if (!TF.IsNull()) {
Handle(PGeom_Surface) PGeomS;
TF->Surface(PGeomS);
return;
}
}
}
}
//=======================================================================
//function : AttributeWeightWatcher
//purpose :
//=======================================================================
static void AttributeWeightWatcher(const TDF_Label& LabS,
const Handle(MDF_SRelocationTable)& aReloc,
MDocStd_PersistentMap& aMap)
{
TCollection_AsciiString STR;
TDF_Tool::Entry(LabS,STR);
#ifdef DEB
cout << "Label to process: "<<STR<<endl;
#endif
Handle(TNaming_NamedShape) NS;
Handle(PNaming_NamedShape) PNS;
if (LabS.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
if (aReloc->HasRelocation(NS,PNS)) {
const Handle(PTopoDS_HArray1OfShape1)& HOldS = PNS->OldShapes();
if (!HOldS.IsNull()) {
for (Standard_Integer i=1;i<=HOldS->Length();i++) {
const PTopoDS_Shape1& POS = HOldS->Value(i);
if (!POS.TShape().IsNull()) ShapeWeightWatcher(POS,aMap);
}
}
const Handle(PTopoDS_HArray1OfShape1)& HNewS = PNS->NewShapes();
if (!HNewS.IsNull()) {
for (Standard_Integer j=1;j<=HNewS->Length();j++) {
const PTopoDS_Shape1& PTS = HNewS->Value(j);
if (!PTS.TShape().IsNull()) ShapeWeightWatcher(PTS,aMap);
}
}
}
}
//traiter les fils
for (TDF_ChildIterator itr(LabS) ; itr.More(); itr.Next()) {
AttributeWeightWatcher(itr.Value(),aReloc,aMap);
}
}
//=======================================================================
//function : WeightWatcher
//purpose :
//=======================================================================
void MDocStd::WeightWatcher(const Handle(TDF_Data)& aSource,
const Handle(MDF_SRelocationTable)& aReloc,
const TColStd_ListOfAsciiString& aEntry)
{
Handle(TDocStd_Document) D;
D = TDocStd_Document::Get(aSource->Root());
if (!D.IsNull()) {
TDocStd_XLink* xRefPtr;
MDocStd_PersistentMap aMap;
//for (TDocStd_XLinkIterator xItr(aSource); xItr.More(); xItr.Next()) {
for (TDocStd_XLinkIterator xItr(D); xItr.More(); xItr.Next()) {
xRefPtr = xItr.Value();
const TCollection_AsciiString & DocEntry= xRefPtr->DocumentEntry();
TColStd_ListIteratorOfListOfAsciiString It(aEntry);
for (;It.More();It.Next()) {
if (It.Value()==DocEntry) AttributeWeightWatcher(xRefPtr->Label(),aReloc,aMap);
}
}
}
}
***** */
//=======================================================================
//function : AddStorageDrivers
//purpose :
//=======================================================================
void MDocStd::AddStorageDrivers(const Handle(MDF_ASDriverHSequence)& aDriverSeq,
const Handle(CDM_MessageDriver)& theMsgDriver)
{ aDriverSeq->Append(new MDocStd_XLinkStorageDriver(theMsgDriver)); }
//=======================================================================
//function : AddRetrievalDrivers
//purpose :
//=======================================================================
void MDocStd::AddRetrievalDrivers(const Handle(MDF_ARDriverHSequence)& aDriverSeq,
const Handle(CDM_MessageDriver)& theMsgDriver)
{ aDriverSeq->Append(new MDocStd_XLinkRetrievalDriver(theMsgDriver)); }
//=======================================================================
//function : Factory
//purpose :
//=======================================================================
Handle(Standard_Transient) MDocStd::Factory(const Standard_GUID& aGUID) {
if(aGUID == StandardStorageDriver) {
#ifdef DEB
cout << "MDocStd : Storage Plugin" << endl;
#endif
static Handle(MDocStd_DocumentStorageDriver) standard_sd = new MDocStd_DocumentStorageDriver;
return standard_sd;
}
if(aGUID == StandardRetrievalDriver) {
#ifdef DEB
cout << "MDocStd : Retrieval Plugin" << endl;
#endif
static Handle (MDocStd_DocumentRetrievalDriver) standard_rd = new MDocStd_DocumentRetrievalDriver;
return standard_rd;
}
Standard_Failure::Raise("MDocStd : Factory: unknown GUID");
Handle(Standard_Transient) t;
return t;
}
|