mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-09 13:22:24 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
27
src/XmlMFunction/XmlMFunction.cdl
Executable file
27
src/XmlMFunction/XmlMFunction.cdl
Executable file
@@ -0,0 +1,27 @@
|
||||
-- File: XmlMFunction.cdl
|
||||
-- Created: Mon Jul 9 12:29:49 MSK DST 2001
|
||||
-- Author: Julia DOROVSKIKH
|
||||
---Copyright: MATRA DATAVISION 2001
|
||||
|
||||
package XmlMFunction
|
||||
|
||||
|
||||
uses
|
||||
TDF,
|
||||
CDM,
|
||||
XmlMDF,
|
||||
XmlObjMgt
|
||||
|
||||
is
|
||||
---Category: Classes
|
||||
-- =============================================================
|
||||
|
||||
class FunctionDriver;
|
||||
class ScopeDriver;
|
||||
class GraphNodeDriver;
|
||||
|
||||
AddDrivers (aDriverTable : ADriverTable from XmlMDF;
|
||||
theMessageDriver: MessageDriver from CDM);
|
||||
---Purpose: Adds the attribute storage drivers to <aDriverTable>.
|
||||
|
||||
end XmlMFunction;
|
22
src/XmlMFunction/XmlMFunction.cxx
Executable file
22
src/XmlMFunction/XmlMFunction.cxx
Executable file
@@ -0,0 +1,22 @@
|
||||
// File: XmlMFunction.cxx
|
||||
// Created: Mon Jul 9 12:29:49 MSK DST 2001
|
||||
// Author: Julia DOROVSKIKH
|
||||
// Copyright: Matra Datavision 2001
|
||||
|
||||
#include <XmlMFunction.ixx>
|
||||
|
||||
#include <XmlMFunction_FunctionDriver.hxx>
|
||||
#include <XmlMFunction_ScopeDriver.hxx>
|
||||
#include <XmlMFunction_GraphNodeDriver.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : AddDrivers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void XmlMFunction::AddDrivers (const Handle(XmlMDF_ADriverTable)& aDriverTable,
|
||||
const Handle(CDM_MessageDriver)& aMessageDriver)
|
||||
{
|
||||
aDriverTable->AddDriver(new XmlMFunction_FunctionDriver(aMessageDriver));
|
||||
aDriverTable->AddDriver(new XmlMFunction_ScopeDriver(aMessageDriver));
|
||||
aDriverTable->AddDriver(new XmlMFunction_GraphNodeDriver(aMessageDriver));
|
||||
}
|
32
src/XmlMFunction/XmlMFunction_FunctionDriver.cdl
Executable file
32
src/XmlMFunction/XmlMFunction_FunctionDriver.cdl
Executable file
@@ -0,0 +1,32 @@
|
||||
-- File: XmlMFunction_FunctionDriver.cdl
|
||||
-- Created: 04.09.01 14:47:31
|
||||
-- Author: Julia DOROVSKIKH
|
||||
-- Copyright: Open Cascade 2001
|
||||
|
||||
class FunctionDriver from XmlMFunction inherits ADriver from XmlMDF
|
||||
|
||||
---Purpose: Attribute Driver.
|
||||
|
||||
uses
|
||||
SRelocationTable from XmlObjMgt,
|
||||
RRelocationTable from XmlObjMgt,
|
||||
Persistent from XmlObjMgt,
|
||||
MessageDriver from CDM,
|
||||
Attribute from TDF
|
||||
|
||||
is
|
||||
Create (theMessageDriver:MessageDriver from CDM)
|
||||
returns mutable FunctionDriver from XmlMFunction;
|
||||
|
||||
NewEmpty (me) returns mutable Attribute from TDF;
|
||||
|
||||
Paste(me; Source : Persistent from XmlObjMgt;
|
||||
Target : mutable Attribute from TDF;
|
||||
RelocTable : out RRelocationTable from XmlObjMgt)
|
||||
returns Boolean from Standard;
|
||||
|
||||
Paste(me; Source : Attribute from TDF;
|
||||
Target : in out Persistent from XmlObjMgt;
|
||||
RelocTable : out SRelocationTable from XmlObjMgt);
|
||||
|
||||
end FunctionDriver;
|
97
src/XmlMFunction/XmlMFunction_FunctionDriver.cxx
Executable file
97
src/XmlMFunction/XmlMFunction_FunctionDriver.cxx
Executable file
@@ -0,0 +1,97 @@
|
||||
// File: XmlMFunction_FunctionDriver.cxx
|
||||
// Created: 04.09.01 14:47:31
|
||||
// Author: Julia DOROVSKIKH
|
||||
// Copyright: Open Cascade 2001
|
||||
// History:
|
||||
|
||||
#include <XmlMFunction_FunctionDriver.ixx>
|
||||
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
#include <TFunction_Function.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (GuidString, "guid")
|
||||
IMPLEMENT_DOMSTRING (FailureString, "failure")
|
||||
|
||||
//=======================================================================
|
||||
//function : XmlMFunction_FunctionDriver
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
XmlMFunction_FunctionDriver::XmlMFunction_FunctionDriver
|
||||
(const Handle(CDM_MessageDriver)& theMsgDriver)
|
||||
: XmlMDF_ADriver (theMsgDriver, NULL)
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) XmlMFunction_FunctionDriver::NewEmpty() const
|
||||
{
|
||||
return (new TFunction_Function());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMFunction_FunctionDriver::Paste
|
||||
(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Handle(TFunction_Function) aF = Handle(TFunction_Function)::DownCast(theTarget);
|
||||
|
||||
// function GUID
|
||||
XmlObjMgt_DOMString aGuidDomStr =
|
||||
theSource.Element().getAttribute(::GuidString());
|
||||
Standard_CString aGuidStr = (Standard_CString)aGuidDomStr.GetString();
|
||||
if (aGuidStr[0] == '\0')
|
||||
{
|
||||
WriteMessage ("error retrieving GUID for type TFunction_Function");
|
||||
return Standard_False;
|
||||
}
|
||||
aF->SetDriverGUID(aGuidStr);
|
||||
|
||||
// failure
|
||||
Standard_Integer aValue;
|
||||
XmlObjMgt_DOMString aFStr = theSource.Element().getAttribute(::FailureString());
|
||||
if (!aFStr.GetInteger(aValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString
|
||||
("Cannot retrieve failure number for TFunction_Function attribute from \"")
|
||||
+ aFStr + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
aF->SetFailure(aValue);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMFunction_FunctionDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TFunction_Function) aF =
|
||||
Handle(TFunction_Function)::DownCast(theSource);
|
||||
if (!aF.IsNull())
|
||||
{
|
||||
//convert GUID into attribute value
|
||||
Standard_Character aGuidStr [40];
|
||||
Standard_PCharacter pGuidStr;
|
||||
//
|
||||
pGuidStr=aGuidStr;
|
||||
aF->GetDriverGUID().ToCString(pGuidStr);
|
||||
theTarget.Element().setAttribute(::GuidString(), aGuidStr);
|
||||
|
||||
//integer value of failure
|
||||
theTarget.Element().setAttribute(::FailureString(), aF->GetFailure());
|
||||
}
|
||||
}
|
35
src/XmlMFunction/XmlMFunction_GraphNodeDriver.cdl
Executable file
35
src/XmlMFunction/XmlMFunction_GraphNodeDriver.cdl
Executable file
@@ -0,0 +1,35 @@
|
||||
-- File: XmlMFunction_GraphNodeDriver.cdl
|
||||
-- Created: 05.03.08 13:27:31
|
||||
-- Author: Vlad ROMASHKO
|
||||
-- Copyright: Open Cascade 2008
|
||||
|
||||
class GraphNodeDriver from XmlMFunction inherits ADriver from XmlMDF
|
||||
|
||||
---Purpose: XML persistence driver for dependencies of a function.
|
||||
|
||||
uses
|
||||
|
||||
SRelocationTable from XmlObjMgt,
|
||||
RRelocationTable from XmlObjMgt,
|
||||
Persistent from XmlObjMgt,
|
||||
MessageDriver from CDM,
|
||||
Attribute from TDF
|
||||
|
||||
is
|
||||
|
||||
Create (theMessageDriver : MessageDriver from CDM)
|
||||
returns mutable GraphNodeDriver from XmlMFunction;
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste(me; Source : Persistent from XmlObjMgt;
|
||||
Target : mutable Attribute from TDF;
|
||||
RelocTable : out RRelocationTable from XmlObjMgt)
|
||||
returns Boolean from Standard;
|
||||
|
||||
Paste(me; Source : Attribute from TDF;
|
||||
Target : in out Persistent from XmlObjMgt;
|
||||
RelocTable : out SRelocationTable from XmlObjMgt);
|
||||
|
||||
end GraphNodeDriver;
|
191
src/XmlMFunction/XmlMFunction_GraphNodeDriver.cxx
Executable file
191
src/XmlMFunction/XmlMFunction_GraphNodeDriver.cxx
Executable file
@@ -0,0 +1,191 @@
|
||||
// File: XmlMFunction_GraphNodeDriver.cxx
|
||||
// Created: 07.03.08 16:14:21
|
||||
// Author: Vlad ROMASHKO
|
||||
// Copyright: Open Cascade 2008
|
||||
|
||||
#include <XmlMFunction_GraphNodeDriver.ixx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
|
||||
#include <TFunction_GraphNode.hxx>
|
||||
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (LastPreviousIndex, "lastprev")
|
||||
IMPLEMENT_DOMSTRING (LastNextIndex, "lastnext")
|
||||
IMPLEMENT_DOMSTRING (ExecutionStatus, "exec")
|
||||
|
||||
//=======================================================================
|
||||
//function : XmlMFunction_GraphNodeDriver
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
XmlMFunction_GraphNodeDriver::XmlMFunction_GraphNodeDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
|
||||
: XmlMDF_ADriver (theMsgDriver, NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) XmlMFunction_GraphNodeDriver::NewEmpty() const
|
||||
{
|
||||
return (new TFunction_GraphNode());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMFunction_GraphNodeDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Handle(TFunction_GraphNode) G = Handle(TFunction_GraphNode)::DownCast(theTarget);
|
||||
|
||||
Standard_Integer aFirstIndPrev, aLastIndPrev, aFirstIndNext, aLastIndNext, aValue, ind;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
|
||||
// Previous
|
||||
// ========
|
||||
|
||||
// Read the FirstIndex; if the attribute is absent initialize to 1
|
||||
aFirstIndPrev = 1; // It is absent :-) because I didn't wrote it on the stage of writing the file.
|
||||
|
||||
// Read the LastIndex; the attribute should present
|
||||
if (!anElement.getAttribute(::LastPreviousIndex()).GetInteger(aLastIndPrev))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the last index"
|
||||
" for previous functions of GraphNode attribute");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
if (aFirstIndPrev == aLastIndPrev)
|
||||
{
|
||||
Standard_Integer anInteger;
|
||||
if (!XmlObjMgt::GetStringValue(anElement).GetInteger(anInteger))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve integer member"
|
||||
" for previous functions of GraphNode attribute");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
G->AddPrevious(anInteger);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_CString aValueStr =
|
||||
Standard_CString(XmlObjMgt::GetStringValue(anElement).GetString());
|
||||
|
||||
for (ind = aFirstIndPrev; ind <= aLastIndPrev; ind++)
|
||||
{
|
||||
if (!XmlObjMgt::GetInteger(aValueStr, aValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve integer member"
|
||||
" for previous functions of GraphNode attribute as \"")
|
||||
+ aValueStr + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
G->AddPrevious(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Next
|
||||
// ====
|
||||
|
||||
// Read the FirstIndex; if the attribute is absent initialize to 1
|
||||
aFirstIndNext = aLastIndPrev + 1; // It is absent :-) because I didn't wrote it on the stage of writing the file.
|
||||
|
||||
// Read the LastIndex; the attribute should present
|
||||
if (!anElement.getAttribute(::LastNextIndex()).GetInteger(aLastIndNext))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the last index"
|
||||
" for next functions of GraphNode attribute");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
aLastIndNext += aLastIndPrev;
|
||||
|
||||
Standard_CString aValueStr =
|
||||
Standard_CString(XmlObjMgt::GetStringValue(anElement).GetString());
|
||||
|
||||
for (ind = 1; ind <= aLastIndNext; ind++)
|
||||
{
|
||||
if (!XmlObjMgt::GetInteger(aValueStr, aValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve integer member"
|
||||
" for next functions of GraphNode attribute as \"")
|
||||
+ aValueStr + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
if (ind < aFirstIndNext)
|
||||
continue;
|
||||
G->AddNext(aValue);
|
||||
}
|
||||
|
||||
// Execution status
|
||||
Standard_Integer exec = 0;
|
||||
if (!anElement.getAttribute(::ExecutionStatus()).GetInteger(exec))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the execution status"
|
||||
" for GraphNode attribute");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
G->SetStatus((TFunction_ExecutionStatus) exec);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMFunction_GraphNodeDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TFunction_GraphNode) G = Handle(TFunction_GraphNode)::DownCast(theSource);
|
||||
|
||||
// Previous
|
||||
// ========
|
||||
|
||||
theTarget.Element().setAttribute(::LastPreviousIndex(), G->GetPrevious().Extent());
|
||||
|
||||
TCollection_AsciiString aValueStr;
|
||||
TColStd_MapIteratorOfMapOfInteger itrm(G->GetPrevious());
|
||||
for (; itrm.More(); itrm.Next())
|
||||
{
|
||||
const Standard_Integer ID = itrm.Key();
|
||||
aValueStr += TCollection_AsciiString(ID);
|
||||
aValueStr += ' ';
|
||||
}
|
||||
aValueStr += "\n";
|
||||
|
||||
// Next
|
||||
// ====
|
||||
|
||||
theTarget.Element().setAttribute(::LastNextIndex(), G->GetNext().Extent());
|
||||
|
||||
itrm.Initialize(G->GetNext());
|
||||
for (; itrm.More(); itrm.Next())
|
||||
{
|
||||
const Standard_Integer ID = itrm.Key();
|
||||
aValueStr += TCollection_AsciiString(ID);
|
||||
aValueStr += ' ';
|
||||
}
|
||||
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
|
||||
// Execution status
|
||||
theTarget.Element().setAttribute(::ExecutionStatus(), (Standard_Integer) G->GetStatus());
|
||||
}
|
35
src/XmlMFunction/XmlMFunction_ScopeDriver.cdl
Executable file
35
src/XmlMFunction/XmlMFunction_ScopeDriver.cdl
Executable file
@@ -0,0 +1,35 @@
|
||||
-- File: XmlMFunction_ScopeDriver.cdl
|
||||
-- Created: 04.03.08 15:37:51
|
||||
-- Author: Vlad ROMASHKO
|
||||
-- Copyright: Open Cascade 2008
|
||||
|
||||
class ScopeDriver from XmlMFunction inherits ADriver from XmlMDF
|
||||
|
||||
---Purpose: XML persistence driver for a scope of functions.
|
||||
|
||||
uses
|
||||
|
||||
SRelocationTable from XmlObjMgt,
|
||||
RRelocationTable from XmlObjMgt,
|
||||
Persistent from XmlObjMgt,
|
||||
MessageDriver from CDM,
|
||||
Attribute from TDF
|
||||
|
||||
is
|
||||
|
||||
Create (theMessageDriver : MessageDriver from CDM)
|
||||
returns mutable ScopeDriver from XmlMFunction;
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste(me; Source : Persistent from XmlObjMgt;
|
||||
Target : mutable Attribute from TDF;
|
||||
RelocTable : out RRelocationTable from XmlObjMgt)
|
||||
returns Boolean from Standard;
|
||||
|
||||
Paste(me; Source : Attribute from TDF;
|
||||
Target : in out Persistent from XmlObjMgt;
|
||||
RelocTable : out SRelocationTable from XmlObjMgt);
|
||||
|
||||
end ScopeDriver;
|
268
src/XmlMFunction/XmlMFunction_ScopeDriver.cxx
Executable file
268
src/XmlMFunction/XmlMFunction_ScopeDriver.cxx
Executable file
@@ -0,0 +1,268 @@
|
||||
// File: XmlMFunction_ScopeDriver.cxx
|
||||
// Created: 05.03.08 17:17:31
|
||||
// Author: Vlad ROMASHKO
|
||||
// Copyright: Open Cascade 2008
|
||||
|
||||
#include <XmlMFunction_ScopeDriver.ixx>
|
||||
#include <XmlObjMgt.hxx>
|
||||
#include <XmlObjMgt_Document.hxx>
|
||||
#include <LDOM_MemManager.hxx>
|
||||
|
||||
#include <TColStd_ListOfInteger.hxx>
|
||||
#include <TColStd_ListIteratorOfListOfInteger.hxx>
|
||||
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_LabelList.hxx>
|
||||
#include <TDF_ListIteratorOfLabelList.hxx>
|
||||
|
||||
#include <TFunction_Scope.hxx>
|
||||
#include <TFunction_DoubleMapIteratorOfDoubleMapOfIntegerLabel.hxx>
|
||||
|
||||
IMPLEMENT_DOMSTRING (LastIDIndex, "lastid")
|
||||
IMPLEMENT_DOMSTRING (LastLabelIndex, "lastlabel")
|
||||
|
||||
IMPLEMENT_DOMSTRING (ExtString, "string")
|
||||
|
||||
//=======================================================================
|
||||
//function : XmlMFunction_ScopeDriver
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
XmlMFunction_ScopeDriver::XmlMFunction_ScopeDriver(const Handle(CDM_MessageDriver)& theMsgDriver)
|
||||
: XmlMDF_ADriver (theMsgDriver, NULL)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Handle(TDF_Attribute) XmlMFunction_ScopeDriver::NewEmpty() const
|
||||
{
|
||||
return (new TFunction_Scope());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose : persistent -> transient (retrieve)
|
||||
//=======================================================================
|
||||
Standard_Boolean XmlMFunction_ScopeDriver::Paste(const XmlObjMgt_Persistent& theSource,
|
||||
const Handle(TDF_Attribute)& theTarget,
|
||||
XmlObjMgt_RRelocationTable& ) const
|
||||
{
|
||||
Handle(TFunction_Scope) S = Handle(TFunction_Scope)::DownCast(theTarget);
|
||||
TColStd_ListOfInteger IDs;
|
||||
TDF_LabelList Labels;
|
||||
|
||||
Standard_Integer aFirstInd, aLastInd, aValue, ind, nbIDs = 0, nbLabels = 0;
|
||||
const XmlObjMgt_Element& anElement = theSource;
|
||||
|
||||
// IDs
|
||||
// ===
|
||||
|
||||
// Read the FirstIndex; if the attribute is absent initialize to 1
|
||||
aFirstInd = 1;
|
||||
|
||||
// Read the LastIndex; the attribute should present
|
||||
if (!anElement.getAttribute(::LastIDIndex()).GetInteger(aLastInd))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the last index"
|
||||
" for Scope attribute");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
nbIDs = aLastInd - aFirstInd + 1;
|
||||
|
||||
if (aFirstInd == aLastInd)
|
||||
{
|
||||
Standard_Integer anInteger;
|
||||
if (!XmlObjMgt::GetStringValue(anElement).GetInteger(anInteger))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve integer member"
|
||||
" for Scope attribute as \"");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
IDs.Append(anInteger);
|
||||
}
|
||||
else
|
||||
{
|
||||
Standard_CString aValueStr =
|
||||
Standard_CString(XmlObjMgt::GetStringValue(anElement).GetString());
|
||||
|
||||
for (ind = aFirstInd; ind <= aLastInd; ind++)
|
||||
{
|
||||
if (!XmlObjMgt::GetInteger(aValueStr, aValue))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve integer member"
|
||||
" for Scope attribute as \"")
|
||||
+ aValueStr + "\"";
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
IDs.Append(aValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Labels
|
||||
// ======
|
||||
|
||||
aFirstInd = 1;
|
||||
|
||||
// Read the LastIndex; the attribute should present
|
||||
if (!anElement.getAttribute(::LastLabelIndex()).GetInteger(aLastInd))
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve the last index"
|
||||
" for Scope attribute");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
nbLabels = aLastInd - aFirstInd + 1;
|
||||
|
||||
if (!anElement.hasChildNodes())
|
||||
{
|
||||
TCollection_ExtendedString aMessageString =
|
||||
TCollection_ExtendedString("Cannot retrieve an array of labels");
|
||||
WriteMessage (aMessageString);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
LDOM_Node aCurNode = anElement.getFirstChild()/*.getNextSibling().getNextSibling()*/;
|
||||
LDOM_Element* aCurElement = (LDOM_Element*)&aCurNode;
|
||||
XmlObjMgt_DOMString aValueStr;
|
||||
Standard_Integer i = aFirstInd;
|
||||
while (*aCurElement != anElement.getLastChild())
|
||||
{
|
||||
aValueStr = XmlObjMgt::GetStringValue( *aCurElement );
|
||||
if (aValueStr == NULL)
|
||||
{
|
||||
aCurNode = aCurElement->getNextSibling();
|
||||
aCurElement = (LDOM_Element*)&aCurNode;
|
||||
continue;
|
||||
}
|
||||
TCollection_AsciiString anEntry;
|
||||
if (XmlObjMgt::GetTagEntryString (aValueStr, anEntry) == Standard_False)
|
||||
{
|
||||
TCollection_ExtendedString aMessage =
|
||||
TCollection_ExtendedString ("Cannot retrieve reference from \"")
|
||||
+ aValueStr + '\"';
|
||||
WriteMessage (aMessage);
|
||||
return Standard_False;
|
||||
}
|
||||
// Find label by entry
|
||||
TDF_Label tLab; // Null label.
|
||||
if (anEntry.Length() > 0)
|
||||
{
|
||||
TDF_Tool::Label(S->Label().Data(), anEntry, tLab, Standard_True);
|
||||
}
|
||||
Labels.Append(tLab);
|
||||
aCurNode = aCurElement->getNextSibling();
|
||||
aCurElement = (LDOM_Element*)&aCurNode;
|
||||
}
|
||||
|
||||
// Last reference
|
||||
aValueStr = XmlObjMgt::GetStringValue( *aCurElement );
|
||||
if (aValueStr == NULL)
|
||||
{
|
||||
WriteMessage ("Cannot retrieve reference string from element");
|
||||
return Standard_False;
|
||||
}
|
||||
TCollection_AsciiString anEntry;
|
||||
if (XmlObjMgt::GetTagEntryString (aValueStr, anEntry) == Standard_False)
|
||||
{
|
||||
TCollection_ExtendedString aMessage =
|
||||
TCollection_ExtendedString ("Cannot retrieve reference from \"")
|
||||
+ aValueStr + '\"';
|
||||
WriteMessage (aMessage);
|
||||
return Standard_False;
|
||||
}
|
||||
// Find label by entry
|
||||
TDF_Label tLab; // Null label.
|
||||
if (anEntry.Length() > 0)
|
||||
{
|
||||
TDF_Tool::Label(S->Label().Data(), anEntry, tLab, Standard_True);
|
||||
}
|
||||
Labels.Append(tLab);
|
||||
|
||||
// Check equality of lengths of the list of IDs & Labels.
|
||||
if (nbIDs != nbLabels)
|
||||
{
|
||||
TCollection_ExtendedString aMessage =
|
||||
TCollection_ExtendedString ("Numbers of IDs & Labels are different");
|
||||
WriteMessage (aMessage);
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
// Set IDs & Labels into the Scope attribute
|
||||
int freeID = 0;
|
||||
TColStd_ListIteratorOfListOfInteger itri(IDs);
|
||||
TDF_ListIteratorOfLabelList itrl(Labels);
|
||||
for (; itri.More(); itri.Next(), itrl.Next())
|
||||
{
|
||||
int ID = itri.Value();
|
||||
if (ID > freeID)
|
||||
freeID = ID;
|
||||
S->ChangeFunctions().Bind(ID, itrl.Value());
|
||||
}
|
||||
freeID++;
|
||||
S->SetFreeID(freeID);
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose : transient -> persistent (store)
|
||||
//=======================================================================
|
||||
void XmlMFunction_ScopeDriver::Paste (const Handle(TDF_Attribute)& theSource,
|
||||
XmlObjMgt_Persistent& theTarget,
|
||||
XmlObjMgt_SRelocationTable& ) const
|
||||
{
|
||||
Handle(TFunction_Scope) S = Handle(TFunction_Scope)::DownCast(theSource);
|
||||
|
||||
// IDs
|
||||
// ===
|
||||
|
||||
theTarget.Element().setAttribute(::LastIDIndex(), S->GetFunctions().Extent());
|
||||
|
||||
TCollection_AsciiString aValueStr;
|
||||
TFunction_DoubleMapIteratorOfDoubleMapOfIntegerLabel itrd(S->GetFunctions());
|
||||
for (; itrd.More(); itrd.Next())
|
||||
{
|
||||
const Standard_Integer ID = itrd.Key1();
|
||||
aValueStr += TCollection_AsciiString(ID);
|
||||
aValueStr += ' ';
|
||||
}
|
||||
aValueStr += "\n";
|
||||
|
||||
XmlObjMgt::SetStringValue (theTarget, aValueStr.ToCString(), Standard_True);
|
||||
|
||||
|
||||
// Labels
|
||||
// ======
|
||||
|
||||
XmlObjMgt_Element& anElement = theTarget;
|
||||
anElement.setAttribute(::LastLabelIndex(), S->GetFunctions().Extent());
|
||||
|
||||
XmlObjMgt_Document aDoc = anElement.getOwnerDocument().Doc();
|
||||
|
||||
for (itrd.Initialize(S->GetFunctions()); itrd.More(); itrd.Next())
|
||||
{
|
||||
TDF_Label L = itrd.Key2();
|
||||
|
||||
TCollection_AsciiString anEntry;
|
||||
TDF_Tool::Entry(L, anEntry);
|
||||
|
||||
XmlObjMgt_DOMString aDOMString;
|
||||
XmlObjMgt::SetTagEntryString (aDOMString, anEntry);
|
||||
XmlObjMgt_Element aCurTarget = aDoc.createElement( ::ExtString() );
|
||||
XmlObjMgt::SetStringValue (aCurTarget, aDOMString, Standard_True);
|
||||
anElement.appendChild( aCurTarget );
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user