1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-29 14:00:49 +03:00

Integration of OCCT 6.5.0 from SVN

This commit is contained in:
bugmaster
2011-03-16 07:30:28 +00:00
committed by bugmaster
parent 4903637061
commit 7fd59977df
16375 changed files with 3882564 additions and 0 deletions

3
src/XmlObjMgt/FILES Executable file
View File

@@ -0,0 +1,3 @@
XmlObjMgt_Element.hxx
XmlObjMgt_Document.hxx
XmlObjMgt_DOMString.hxx

97
src/XmlObjMgt/XmlObjMgt.cdl Executable file
View File

@@ -0,0 +1,97 @@
-- File: XmlObjMgt.cdl
-- Created: Tue Jul 17 12:30:46 2001
-- Author: Julia DOROVSKIKH <jfa@hotdox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2001-2002
-- History: AGV 150202: Add parameter isClearText to SetStringValue()
package XmlObjMgt
---Purpose: This package defines services to manage the storage
-- grain of data produced by applications and those classes
-- to manage persistent extern reference.
uses
TCollection, TColStd, gp
is
class Persistent;
---Purpose: root for XML-persistence
class GP;
---Purpose: translation of gp objects
imported DOMString;
imported Document;
imported Element;
-- Storage Relocation Table
alias SRelocationTable is IndexedMapOfTransient from TColStd;
-- Retrieval Relocation Table
alias RRelocationTable is DataMapOfIntegerTransient from TColStd;
generic class Array1;
-- Package methods
IdString returns DOMString from XmlObjMgt;
---C++: return const &
---Purpose: Define the name of XMLattribute 'ID' (to be used everywhere)
SetExtendedString (theElement: in out Element from XmlObjMgt;
theString : ExtendedString from TCollection)
returns Boolean from Standard;
---Purpose: Add attribute <theElement extstring="theString" ...>
GetExtendedString (theElement: Element from XmlObjMgt;
theString : out ExtendedString from TCollection)
returns Boolean from Standard;
---Purpose: Get attribute <theElement extstring="theString" ...>
GetStringValue (theElement : Element from XmlObjMgt)
returns DOMString from XmlObjMgt;
---Purpose: Returns the first child text node
SetStringValue (theElement : in out Element from XmlObjMgt;
theData : DOMString from XmlObjMgt;
isClearText: Boolean from Standard = Standard_False);
---Purpose: Add theData as the last child text node to theElement
-- isClearText(True) avoids analysis of the string and replacement
-- of characters like '<' and '&' during XML file storage.
-- Do NEVER set isClearText unless you have a hell of a reason
GetTagEntryString (theTarget : DOMString from XmlObjMgt;
theTagEntry: out AsciiString from TCollection)
returns Boolean from Standard;
---Purpose: Convert XPath expression (DOMString) into TagEntry string
-- returns False on Error
SetTagEntryString (theSource : out DOMString from XmlObjMgt;
theTagEntry: AsciiString from TCollection);
---Purpose: Convert XPath expression (DOMString) into TagEntry string
-- returns False on Error
FindChildElement (theSource: Element from XmlObjMgt;
theObjId : Integer from Standard)
returns Element from XmlObjMgt;
FindChildByRef (theSource : Element from XmlObjMgt;
theRefName: DOMString from XmlObjMgt)
returns Element from XmlObjMgt;
FindChildByName (theSource : Element from XmlObjMgt;
theName : DOMString from XmlObjMgt)
returns Element from XmlObjMgt;
GetInteger (theString : in out CString from Standard;
theValue : in out Integer from Standard)
returns Boolean from Standard;
GetReal (theString : in out CString from Standard;
theValue : in out Real from Standard)
returns Boolean from Standard;
GetReal (theString : DOMString from XmlObjMgt;
theValue : in out Real from Standard)
returns Boolean from Standard;
end XmlObjMgt;

371
src/XmlObjMgt/XmlObjMgt.cxx Executable file
View File

@@ -0,0 +1,371 @@
// File: XmlObjMgt.cxx
// Created: 18.07.01 13:36:59
// Author: Julia DOROVSKIKH
// Copyright: Matra Datavision 2001-2002
// History: AGV 150202: Add parameter isClearText to SetStringValue()
#include <XmlObjMgt.ixx>
#include <XmlObjMgt_Document.hxx>
#include <LDOM_Text.hxx>
#include <errno.h>
#include <stdio.h>
static const char aRefPrefix [] = "/document/label";
static const char aRefElem1 [] = "/label[@tag=";
static const char aRefElem2 [] = "]";
//=======================================================================
//function : IdString
//purpose : return name of ID attribute to be used everywhere
//=======================================================================
const XmlObjMgt_DOMString& XmlObjMgt::IdString ()
{
static const LDOMString aString ("id");
return aString;
}
//=======================================================================
//function : SetStringValue
//purpose : Add theData as the last child text node to theElement
//remark : Set isClearText to True if only you guarantee that the string
// does not contain '&', '<', '>', '\"', '\'', etc.
//=======================================================================
void XmlObjMgt::SetStringValue (XmlObjMgt_Element& theElement,
const XmlObjMgt_DOMString& theData,
const Standard_Boolean isClearText)
{
XmlObjMgt_Document aDocument = theElement.getOwnerDocument();
LDOM_Text aText = aDocument.createTextNode (theData);
if (isClearText) aText.SetValueClear();
theElement.appendChild (aText);
}
//=======================================================================
//function : GetStringValue
//purpose : returns the first child text node
//=======================================================================
XmlObjMgt_DOMString XmlObjMgt::GetStringValue
(const XmlObjMgt_Element& theElement)
{
XmlObjMgt_DOMString aString;
for (LDOM_Node aNode = theElement.getFirstChild();
aNode != NULL;
aNode = aNode.getNextSibling())
{
if (aNode.getNodeType() == LDOM_Node::TEXT_NODE) {
aString = ((const LDOM_Text&)aNode).getData();
break;
}
}
return aString;
}
//=======================================================================
//function : SprintfExtStr
//purpose : Converts theString to hex printable representation and put it
// : to the out buffer
//=======================================================================
void SprintfExtStr(char * out, const TCollection_ExtendedString& theString) {
unsigned short * p = (unsigned short *)theString.ToExtString();
int len = theString.Length();
int i = 0;
unsigned short mask[4] = {0xf000,0x0f00,0x00f0,0x000f};
while (len) {
for(int j = 0,k=3; j<4; j++,k--) {
unsigned short v = *(p+i) & mask[j];//x000
v = v >> (4*k);
if(v < 10)
v |= 0x30;
else
v += 87;
out[4*i+j] = (char)v;
}
i++;len--;
}
out[4*theString.Length()] = 0x00;
}
//=======================================================================
//function : SetExtendedString
//purpose : Add text node to element and initialize it with string
//=======================================================================
Standard_Boolean XmlObjMgt::SetExtendedString
(XmlObjMgt_Element& theElement,
const TCollection_ExtendedString& theString)
{
TCollection_AsciiString anAString;
if (theString.IsAscii()) {
anAString = TCollection_AsciiString (theString, '?');
SetStringValue (theElement, anAString.ToCString());
} else {
const Standard_Integer aLen = theString.Length();
// const Standard_ExtCharacter * aString = theString.ToExtString();
char * buf0 = new char [4 * (aLen + 1) + 3];
sprintf (&buf0[0], "##%04x", 0xfeff); // set UNICODE header
char * buf = &buf0[6];
// Standard_Integer i = 0;
// while (i <= (aLen - 4)) {
// sprintf (&buf[i*4], "%04x%04x%04x%04x", aString[i], aString[i+1],
// aString[i+2], aString[i+3]);
// i += 4;
// }
// while (i < aLen) {
// sprintf (&buf[i*4], "%04x", aString[i]);
// ++i;
// }
// buf[4*aLen] = '\0';
SprintfExtStr(buf, theString);
SetStringValue (theElement, buf0);
delete [] buf0;
}
return Standard_True;
}
//=======================================================================
//function : GetExtendedString
//purpose : Get the first text node in theElement and convert to ExtendedStr
//=======================================================================
Standard_Boolean XmlObjMgt::GetExtendedString
(const XmlObjMgt_Element& theElement,
TCollection_ExtendedString& theString)
{
theString = GetStringValue (theElement);
return Standard_True;
}
//=======================================================================
//function : GetTagEntryString
//purpose : Convert XPath expression (DOMString) into TagEntry string
// Returns False on error
//=======================================================================
Standard_Boolean XmlObjMgt::GetTagEntryString
(const XmlObjMgt_DOMString& theSource,
TCollection_AsciiString& theTagEntry)
{
// Check the prefix
const size_t aPrefixSize = sizeof(aRefPrefix) - 1;
const char * aSource = theSource.GetString();
if (strncmp (aSource, aRefPrefix, aPrefixSize))
return Standard_False;
// Beging aTagEntry string
char * aTagEntry =
(char *) Standard::Allocate (strlen(aSource)/2); // quite enough to hold it
char * aTagEntryPtr = aTagEntry + 1;
* aTagEntry = '0';
aSource += aPrefixSize;
// Find all individual tags in a loop
const size_t anElem1Size = sizeof(aRefElem1) - 1;
const size_t anElem2Size = sizeof(aRefElem2) - 1;
while (aSource[0] != '\0') {
// Check the first part of individual tag: "/label[@tag="
if (strncmp (aSource, aRefElem1, anElem1Size))
return Standard_False;
aSource += anElem1Size;
const char aQuote = aSource[0];
if (aQuote != '\'' && aQuote != '\"')
return Standard_False;
// Check the integer value of the tag
errno = 0;
char * aPtr;
long aTagValue = strtol (&aSource[1], &aPtr, 10);
if (aTagValue <= 0 || aPtr[0] != aQuote ||
errno == ERANGE || errno == EINVAL)
return Standard_False;
Standard_Integer aLen = aPtr - &aSource[1];
aTagEntryPtr[0] = ':';
memcpy (&aTagEntryPtr[1], &aSource[1], aLen);
aTagEntryPtr += (aLen + 1);
// Check the final part of individual tag : "]"
if (strncmp (aPtr + 1, aRefElem2, anElem2Size))
return Standard_False;
aSource = aPtr + 1 + anElem2Size;
}
aTagEntryPtr[0] = '\0';
theTagEntry = aTagEntry;
Standard::Free ((Standard_Address&)aTagEntry);
return Standard_True;
}
//=======================================================================
//function : SetTagEntryString
//purpose : Form an XPath string corresponding to the input TagEntry
//=======================================================================
void XmlObjMgt::SetTagEntryString (XmlObjMgt_DOMString& theTarget,
const TCollection_AsciiString& theTagEntry)
{
// Begin parsing theTagEntry
const char * aTagEntry = (const char*) theTagEntry.ToCString() + 1;
if (aTagEntry[-1] != '0')
return;
// Count the number of tags in the label entry string
const char * aPtr = aTagEntry;
Standard_Integer aTagCount = 0;
while (* aPtr) if (* aPtr++ == ':') aTagCount ++;
// Create a buffer to accumulate the XPath reference
const size_t anElem1Size = sizeof(aRefElem1) - 1;
const size_t anElem2Size = sizeof(aRefElem2) - 1;
char * aTarget =
(char *) Standard::Allocate (sizeof(aRefPrefix) + aTagCount *
(anElem1Size + anElem2Size + 12));
memcpy (aTarget, aRefPrefix, sizeof (aRefPrefix) - 1);
char * aTargetPtr = aTarget + (sizeof (aRefPrefix) - 1);
while (1) {
// Check for the end-of-string; find the delimeter ':'
aPtr = strchr (aTagEntry, ':');
if (aPtr == NULL) break;
aTagEntry = aPtr + 1;
// Find the range of characters for an integer number
errno = 0;
char * ptr;
long aTagValue = strtol (aTagEntry, &ptr, 10);
if (aTagValue <= 0 || errno == ERANGE || errno == EINVAL)
return; // error
Standard_Integer aTagSize = ptr - aTagEntry;
// Add one XPath level to the expression in aTarget
memcpy (&aTargetPtr[0], aRefElem1, anElem1Size);
aTargetPtr[anElem1Size] = '\"';
memcpy (&aTargetPtr[anElem1Size+1], aTagEntry, aTagSize);
aTargetPtr[anElem1Size+aTagSize+1] = '\"';
memcpy (&aTargetPtr[anElem1Size+aTagSize+2],aRefElem2, anElem2Size);
aTargetPtr += (anElem1Size + aTagSize + anElem2Size + 2);
}
* aTargetPtr = '\0';
theTarget = aTarget;
Standard::Free ((Standard_Address&)aTarget);
}
//=======================================================================
//function : FindChildElement
//purpose :
//=======================================================================
XmlObjMgt_Element XmlObjMgt::FindChildElement
(const XmlObjMgt_Element& theSource,
const Standard_Integer theId)
{
LDOM_Node aNode = theSource.getFirstChild();
Standard_Integer anId;
while ( !aNode.isNull() )
{
if ( aNode.getNodeType() == LDOM_Node::ELEMENT_NODE )
{
LDOM_Element anElem = (LDOM_Element &) aNode;
if (anElem.getAttribute (IdString()).GetInteger(anId))
if (anId == theId) return anElem;
}
aNode = aNode.getNextSibling();
}
// find in all the document // to be done
// LDOM_Document aDoc = theSource.getOwnerDocument();
return LDOM_Element();
}
//=======================================================================
//function : FindChildByRef
//purpose :
//=======================================================================
XmlObjMgt_Element XmlObjMgt::FindChildByRef
(const XmlObjMgt_Element& theSource,
const XmlObjMgt_DOMString& theRefName)
{
Standard_Integer anID;
if (theSource.getAttribute (theRefName).GetInteger (anID))
return FindChildElement (theSource, anID);
return LDOM_Element();
}
//=======================================================================
//function : FindChildByName
//purpose :
//=======================================================================
XmlObjMgt_Element XmlObjMgt::FindChildByName
(const XmlObjMgt_Element& theSource,
const XmlObjMgt_DOMString& theName)
{
return theSource.GetChildByTagName(theName);
}
//=======================================================================
//function : GetInteger
//purpose :
//=======================================================================
Standard_Boolean XmlObjMgt::GetInteger (Standard_CString& theString,
Standard_Integer& theValue)
{
char * ptr;
errno = 0;
long aValue = strtol (theString, &ptr, 10);
if (ptr == theString || errno == ERANGE || errno == EINVAL)
return Standard_False;
theValue = Standard_Integer (aValue);
theString = ptr;
return Standard_True;
}
//=======================================================================
//function : GetReal
//purpose :
//=======================================================================
Standard_Boolean XmlObjMgt::GetReal (Standard_CString& theString,
Standard_Real& theValue)
{
char * ptr;
errno = 0;
double aValue = strtod (theString, &ptr);
if (ptr == theString || errno == ERANGE || errno == EINVAL)
return Standard_False;
theValue = Standard_Real (aValue);
theString = ptr;
return Standard_True;
}
//=======================================================================
//function : GetReal
//purpose : Convert LDOMString to Real
//=======================================================================
Standard_Boolean XmlObjMgt::GetReal (const XmlObjMgt_DOMString& theString,
Standard_Real& theValue)
{
switch (theString.Type()) {
case LDOMBasicString::LDOM_NULL:
return Standard_False;
case LDOMBasicString::LDOM_Integer:
{
Standard_Integer anIntValue;
theString.GetInteger(anIntValue);
theValue = Standard_Real(anIntValue);
break;
}
default: // LDOM_Ascii*
{
char * ptr;
const char * aString = theString.GetString();
errno = 0;
double aValue = strtod (aString, &ptr);
if (ptr == aString || errno == ERANGE || errno == EINVAL)
return Standard_False;
theValue = Standard_Real (aValue);
}
}
return Standard_True;
}

View File

@@ -0,0 +1,77 @@
-- File: XmlObjMgt_Array1.cdl
-- Created: Wed Nov 25 17:47:24 1992
-- Author: Julia DOROVSKIKH
---Copyright: Open Cascade 2001
generic class Array1 from XmlObjMgt (Item as Storable)
---Purpose: The class Array1 represents unidimensionnal
-- array of fixed size known at run time.
-- The range of the index is user defined.
-- Warning: Programs clients of such class must be independant
-- of the range of the first element. Then, a C++ for
-- loop must be written like this
-- for (i = A->Lower(); i <= A->Upper(); i++)
uses
Element from XmlObjMgt,
DOMString from XmlObjMgt
is
Create (Low, Up: Integer from Standard) returns Array1;
---Purpose: Create an array of lower bound <Low> and
-- upper bound <Up>. Range error is raised
-- when <Up> is less than <Low>.
Create (theParent: Element from XmlObjMgt;
theName: DOMString from XmlObjMgt) returns Array1;
---Purpose: for restoration from DOM_Element which is child of
-- theParent:
-- <theParent ...>
-- <theName ...>
CreateArrayElement (me:in out; theParent: in out Element from XmlObjMgt;
theName : DOMString from XmlObjMgt);
---Purpose: Create DOM_Element representing the array, under 'theParent'
Element(me) returns Element from XmlObjMgt
is static;
---Purpose: Returns the DOM element of <me>.
---Level: Public
---C++: inline
---C++: return const &
Length (me) returns Integer from Standard
is static;
---Purpose: Returns the number of elements of <me>.
---Level: Public
---C++: inline
Lower (me) returns Integer from Standard
is static;
---Purpose: Returns the lower bound.
---Level: Public
---C++: inline
Upper (me) returns Integer from Standard
is static;
---Purpose: Returns the upper bound.
---Level: Public
---C++: inline
SetValue (me: in out; Index: Integer from Standard;
Value: in out Element from XmlObjMgt)
is static;
---Purpose: Set the <Index>th element of the array to <Value>.
---Level: Public
Value (me; Index: Integer from Standard) returns Element from XmlObjMgt
is static;
---Purpose: Returns the value of <Index>th element of the array.
---Level: Public
fields
myElement : Element from XmlObjMgt;
myFirst : Integer from Standard;
myLast : Integer from Standard;
end Array1;

View File

@@ -0,0 +1,106 @@
// File: XmlObjMgt_Array1.gxx
// Created: 01.08.01 16:05:40
// Author: Julia DOROVSKIKH
// Copyright: Open Cascade 2001
// History: AGV 130202: Changed prototype LDOM_Node::getOwnerDocument()
#include <XmlObjMgt.hxx>
#include <XmlObjMgt_DOMString.hxx>
#include <TCollection_AsciiString.hxx>
IMPLEMENT_DOMSTRING (LowerString, "lower")
IMPLEMENT_DOMSTRING (UpperString, "upper")
IMPLEMENT_DOMSTRING (IndString, "index")
//=======================================================================
//function : XmlObjMgt_Array1
//purpose : Constructor
//=======================================================================
XmlObjMgt_Array1::XmlObjMgt_Array1 (const XmlObjMgt_Element& theParent,
const XmlObjMgt_DOMString& theName)
: myElement (XmlObjMgt::FindChildByName (theParent, theName)),
myFirst (1),
myLast (0)
{
if (myElement != NULL) {
if (!myElement.getAttribute(::LowerString()).GetInteger(myFirst))
myFirst = 1;
if (!myElement.getAttribute(::UpperString()).GetInteger (myLast))
myLast = 1;
}
}
//=======================================================================
//function : XmlObjMgt_Array1
//purpose : Constructor
//=======================================================================
XmlObjMgt_Array1::XmlObjMgt_Array1 (const Standard_Integer aFirst,
const Standard_Integer aLast)
: myFirst (aFirst), myLast (aLast)
{}
//=======================================================================
//function : CreateArrayElement
//purpose : Create DOM_Element representing the array, under 'theParent'
//=======================================================================
void XmlObjMgt_Array1::CreateArrayElement (XmlObjMgt_Element& theParent,
const XmlObjMgt_DOMString& theName)
{
if (myLast > 0)
{
//AGV XmlObjMgt_Document& anOwnerDoc =
//AGV (XmlObjMgt_Document&)theParent.getOwnerDocument();
XmlObjMgt_Document anOwnerDoc =
XmlObjMgt_Document (theParent.getOwnerDocument());
myElement = anOwnerDoc.createElement (theName);
theParent.appendChild (myElement);
if (myLast > 1) {
myElement.setAttribute (::UpperString(), myLast);
if (myFirst != 1)
myElement.setAttribute (::LowerString(), myFirst);
}
}
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
void XmlObjMgt_Array1::SetValue
(const Standard_Integer theIndex, XmlObjMgt_Element& theValue)
{
myElement.appendChild (theValue);
theValue.setAttribute(::IndString(), theIndex);
}
//=======================================================================
//function : Value
//purpose :
//=======================================================================
XmlObjMgt_Element XmlObjMgt_Array1::Value(const Standard_Integer theIndex) const
{
XmlObjMgt_Element anElem;
if (theIndex >= myFirst && theIndex <= myLast)
{
Standard_Integer ind;
LDOM_Node aNode = myElement.getFirstChild();
while (!aNode.isNull())
{
if (aNode.getNodeType() == LDOM_Node::ELEMENT_NODE)
{
anElem = (XmlObjMgt_Element &) aNode;
if (anElem.getAttribute(::IndString()).GetInteger(ind))
if (ind == theIndex)
break;
}
aNode = aNode.getNextSibling();
}
}
return anElem;
}

View File

@@ -0,0 +1,44 @@
// File: XmlObjMgt_Array1.lxx
// Created: 01.08.01 17:42:23
// Author: Alexander GRIGORIEV
// Copyright: Open Cascade 2001
//=======================================================================
//function : Element
//purpose :
//=======================================================================
inline const XmlObjMgt_Element& XmlObjMgt_Array1::Element () const
{
return myElement;
}
//=======================================================================
//function : Length
//purpose :
//=======================================================================
inline Standard_Integer XmlObjMgt_Array1::Length () const
{
return myLast - myFirst + 1;
}
//=======================================================================
//function : Lower
//purpose :
//=======================================================================
inline Standard_Integer XmlObjMgt_Array1::Lower () const
{
return myFirst;
}
//=======================================================================
//function : Upper
//purpose :
//=======================================================================
inline Standard_Integer XmlObjMgt_Array1::Upper () const
{
return myLast;
}

View File

@@ -0,0 +1,14 @@
#ifndef _XmlObjMgt_DOMString_HeaderFile
#define _XmlObjMgt_DOMString_HeaderFile
#include <LDOMString.hxx>
typedef LDOMString XmlObjMgt_DOMString;
#define IMPLEMENT_DOMSTRING(FnName, String) \
static const XmlObjMgt_DOMString& FnName () { \
static const XmlObjMgt_DOMString aString (String); \
return aString; \
}
#endif

View File

@@ -0,0 +1,8 @@
#ifndef _XmlObjMgt_Document_HeaderFile
#define _XmlObjMgt_Document_HeaderFile
#include <LDOM_Document.hxx>
typedef LDOM_Document XmlObjMgt_Document;
#endif

View File

@@ -0,0 +1,8 @@
#ifndef _XmlObjMgt_Element_HeaderFile
#define _XmlObjMgt_Element_HeaderFile
#include <LDOM_Element.hxx>
typedef LDOM_Element XmlObjMgt_Element;
#endif

45
src/XmlObjMgt/XmlObjMgt_GP.cdl Executable file
View File

@@ -0,0 +1,45 @@
-- File: XmlObjMgt_GP.cdl
class GP from XmlObjMgt
---Purpose: Translation of gp (simple geometry) objects
uses
Trsf from gp,
Mat from gp,
XYZ from gp,
DOMString from XmlObjMgt
is
-- ---------------
-- Package Methods
-- ---------------
-- from gp to string
Translate (myclass; aTrsf : Trsf from gp)
returns DOMString from XmlObjMgt;
---Level: Advanced
Translate (myclass; aMat : Mat from gp)
returns DOMString from XmlObjMgt;
---Level: Advanced
Translate (myclass; anXYZ : XYZ from gp)
returns DOMString from XmlObjMgt;
---Level: Advanced
-- from string to gp
Translate (myclass; aStr : DOMString from XmlObjMgt; T : out Trsf from gp)
returns Boolean from Standard;
---Level: Advanced
Translate (myclass; aStr : DOMString from XmlObjMgt; T : out Mat from gp)
returns Boolean from Standard;
---Level: Advanced
Translate (myclass; aStr : DOMString from XmlObjMgt; T : out XYZ from gp)
returns Boolean from Standard;
---Level: Advanced
end;

163
src/XmlObjMgt/XmlObjMgt_GP.cxx Executable file
View File

@@ -0,0 +1,163 @@
// File: XmlObjMgt_GP.cxx
// Created: 02.08.01 21:10:37
// Author: Alexander GRIGORIEV
// Copyright: Open Cascade 2001
// History:
#include <XmlObjMgt_GP.ixx>
#include <stdio.h>
#include <errno.h>
static const char * Translate (const char * theStr, gp_Mat& M);
static const char * Translate (const char * theStr, gp_XYZ& P);
// STORE
//=======================================================================
//function : Translate
//purpose :
//=======================================================================
XmlObjMgt_DOMString XmlObjMgt_GP::Translate (const gp_Trsf& aTrsf)
{
char buf [256];
XmlObjMgt_DOMString S1 (Translate(aTrsf.HVectorialPart())),
S2 (Translate(aTrsf.TranslationPart()));
sprintf (buf, "%.17g %d %s %s", aTrsf.ScaleFactor(), aTrsf.Form(),
S1.GetString(), S2.GetString());
return XmlObjMgt_DOMString (buf);
}
//=======================================================================
//function : Translate
//purpose :
//=======================================================================
XmlObjMgt_DOMString XmlObjMgt_GP::Translate (const gp_Mat& aMat)
{
char buf[128];
XmlObjMgt_DOMString S1 (Translate(aMat.Row(1))),
S2 (Translate(aMat.Row(2))),
S3 (Translate(aMat.Row(3)));
sprintf (buf, "%s %s %s", S1.GetString(), S2.GetString(), S3.GetString());
return XmlObjMgt_DOMString (buf);
}
//=======================================================================
//function : Translate
//purpose :
//=======================================================================
XmlObjMgt_DOMString XmlObjMgt_GP::Translate (const gp_XYZ& anXYZ)
{
char buf [64];
sprintf (buf, "%.17g %.17g %.17g", anXYZ.X(), anXYZ.Y(), anXYZ.Z());
return XmlObjMgt_DOMString (buf);
}
// RETRIEVE
//=======================================================================
//function : Translate
//purpose :
//=======================================================================
Standard_Boolean XmlObjMgt_GP::Translate
(const XmlObjMgt_DOMString& theStr, gp_Trsf& T)
{
Standard_Boolean aResult = Standard_False;
const char * aStr = theStr.GetString();
char * ptr;
errno = 0;
Standard_Real aScaleFactor = Standard_Real(strtod (aStr, &ptr));
if (ptr != aStr && errno != ERANGE && errno != EINVAL)
{
T._CSFDB_Setgp_Trsfscale(aScaleFactor);
aStr = ptr;
Standard_Integer aForm = Standard_Integer(strtol(aStr, &ptr, 10));
if (ptr != aStr && errno != ERANGE && errno != EINVAL) {
T._CSFDB_Setgp_Trsfshape((gp_TrsfForm)aForm);
aStr = ptr;
// gp_Mat aMatr;
aStr = ::Translate(aStr, (gp_Mat&)T._CSFDB_Getgp_Trsfmatrix());
if (aStr) {
// gp_XYZ aTransl;
::Translate(aStr, (gp_XYZ&)T._CSFDB_Getgp_Trsfloc());
aResult = Standard_True;
}
}
}
return aResult;
}
//=======================================================================
//function : Translate
//purpose :
//=======================================================================
Standard_Boolean XmlObjMgt_GP::Translate
(const XmlObjMgt_DOMString& theStr, gp_Mat& M)
{
return (::Translate (theStr.GetString(), M) != 0);
}
//=======================================================================
//function : Translate
//purpose :
//=======================================================================
Standard_Boolean XmlObjMgt_GP::Translate
(const XmlObjMgt_DOMString& theStr, gp_XYZ& P)
{
return (::Translate (theStr.GetString(), P) != 0);
}
//=======================================================================
//function : Translate
//purpose :
//=======================================================================
static const char * Translate (const char * theStr, gp_Mat& M)
{
gp_XYZ aC;
theStr = Translate(theStr, aC);
if (theStr) {
M.SetRow(1, aC);
theStr = Translate(theStr, aC);
if (theStr) {
M.SetRow(2, aC);
theStr = Translate(theStr, aC);
if (theStr)
M.SetRow(3, aC);
}
}
return theStr;
}
//=======================================================================
//function : Translate
//purpose :
//=======================================================================
static const char * Translate (const char * theStr, gp_XYZ& P)
{
char * ptr;
if (theStr) {
errno = 0;
Standard_Real aC = strtod (theStr, &ptr);
if (ptr != theStr && errno != ERANGE && errno != EINVAL) {
P.SetX(aC);
theStr = ptr;
aC = strtod (theStr, &ptr);
if (ptr != theStr && errno != ERANGE && errno != EINVAL) {
P.SetY(aC);
theStr = ptr;
aC = strtod (theStr, &ptr);
if (ptr != theStr && errno != ERANGE && errno != EINVAL) {
P.SetZ(aC);
theStr = ptr;
} else
theStr = 0;
} else
theStr = 0;
} else
theStr = 0;
}
return theStr;
}

View File

@@ -0,0 +1,55 @@
-- File: XmlObjMgt_Persistent.cdl
-- Created: Tue Jul 17 12:30:46 2001
-- Author: Julia DOROVSKIKH <jfa@hotdox.nnov.matra-dtv.fr>
---Copyright: Matra Datavision 2001
class Persistent from XmlObjMgt
uses
Element from XmlObjMgt,
DOMString from XmlObjMgt
is
Create returns Persistent from XmlObjMgt;
---Purpose: empty constructor
Create (theElement : Element from XmlObjMgt)
returns Persistent from XmlObjMgt;
---Purpose: constructor
Create (theElement : Element from XmlObjMgt;
theRef : DOMString from XmlObjMgt)
returns Persistent from XmlObjMgt;
---Purpose: constructor from sub-element of Element referenced by theRef
CreateElement (me:in out; theParent: out Element from XmlObjMgt;
theType: DOMString from XmlObjMgt;
theID: Integer from Standard);
---Purpose: myElement := <theType id="theID"/>
SetId (me:in out; theId: Integer from Standard)
is static;
---Level: Internal
Element (me) returns Element from XmlObjMgt;
---C++: inline
---C++: return const &
---C++: alias "inline operator const XmlObjMgt_Element&() const;"
---Purpose: return myElement
Element (me:in out) returns Element from XmlObjMgt;
---C++: inline
---C++: return &
---C++: alias "inline operator XmlObjMgt_Element&();"
---Purpose: return myElement
Id(me) returns Integer from Standard
is static;
---C++: inline
---Level: Internal
fields
myElement: Element from XmlObjMgt;
myID : Integer from Standard;
end Persistent;

View File

@@ -0,0 +1,75 @@
// File: XmlObjMgt_Persistent.cxx
// Created: Tue Jul 17 12:30:46 2001
// Author: Julia DOROVSKIKH <jfa@hotdox.nnov.matra-dtv.fr>
// Copyright: Matra Datavision 2001
// History: AGV 130202: Changed prototype LDOM_Node::getOwnerDocument()
#include <XmlObjMgt_Persistent.ixx>
#include <XmlObjMgt_Document.hxx>
#include <XmlObjMgt.hxx>
#include <TCollection_AsciiString.hxx>
//=======================================================================
//function : XmlObjMgt_Persistent
//purpose : empty constructor
//=======================================================================
XmlObjMgt_Persistent::XmlObjMgt_Persistent ()
: myID (0)
{}
//=======================================================================
//function : XmlObjMgt_Persistent
//purpose :
//=======================================================================
XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement)
: myElement (theElement), myID (0)
{
if (theElement != NULL)
theElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID);
}
//=======================================================================
//function : XmlObjMgt_Persistent
//purpose :
//=======================================================================
XmlObjMgt_Persistent::XmlObjMgt_Persistent (const XmlObjMgt_Element& theElement,
const XmlObjMgt_DOMString& theRef)
: myID (0)
{
if (theElement != NULL) {
Standard_Integer aRefID;
if (theElement.getAttribute (theRef).GetInteger (aRefID)) {
myElement = XmlObjMgt::FindChildElement (theElement, aRefID);
if (myElement != NULL)
myElement.getAttribute(XmlObjMgt::IdString()).GetInteger(myID);
}
}
}
//=======================================================================
//function : CreateElement
//purpose : <theType id="theID"/>
//=======================================================================
void XmlObjMgt_Persistent::CreateElement (XmlObjMgt_Element& theParent,
const XmlObjMgt_DOMString& theType,
const Standard_Integer theID)
{
//AGV XmlObjMgt_Document& anOwnerDoc =
//AGV (XmlObjMgt_Document&)theParent.getOwnerDocument();
XmlObjMgt_Document anOwnerDoc =
XmlObjMgt_Document (theParent.getOwnerDocument());
myElement = anOwnerDoc.createElement (theType);
theParent.appendChild (myElement);
SetId (theID);
}
//=======================================================================
//function : SetId
//purpose :
//=======================================================================
void XmlObjMgt_Persistent::SetId(const Standard_Integer theId)
{
myID = theId;
myElement.setAttribute (XmlObjMgt::IdString(), theId);
}

View File

@@ -0,0 +1,51 @@
// File: XmlObjMgt_Persistent.lxx
// Created: 01.08.01 11:23:22
// Author: Alexander GRIGORIEV
// Copyright: Open Cascade 2001
//=======================================================================
//function : Element
//purpose :
//=======================================================================
inline const XmlObjMgt_Element& XmlObjMgt_Persistent::Element() const
{
return myElement;
}
//=======================================================================
//function : Element
//purpose :
//=======================================================================
inline XmlObjMgt_Element& XmlObjMgt_Persistent::Element()
{
return myElement;
}
//=======================================================================
//function : operator XmlObjMgt_Element
//purpose :
//=======================================================================
inline XmlObjMgt_Persistent::operator const XmlObjMgt_Element&() const
{
return myElement;
}
//=======================================================================
//function : operator XmlObjMgt_Element
//purpose :
//=======================================================================
inline XmlObjMgt_Persistent::operator XmlObjMgt_Element&()
{
return myElement;
}
//=======================================================================
//function : Id
//purpose :
//=======================================================================
inline Standard_Integer XmlObjMgt_Persistent::Id() const
{
return myID;
}