mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Coding - Apply .clang-format formatting #286
Update empty method guards to new style with regex (see PR). Used clang-format 18.1.8. New actions to validate code formatting is added. Update .clang-format with disabling of include sorting. It is temporary changes, then include will be sorted. Apply formatting for /src and /tools folder. The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
@@ -25,101 +25,93 @@
|
||||
*/
|
||||
class VrmlData_Appearance : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Appearance () {}
|
||||
inline VrmlData_Appearance() {}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_Appearance (const VrmlData_Scene& theScene,
|
||||
const char * theName)
|
||||
: VrmlData_Node (theScene, theName) {}
|
||||
inline VrmlData_Appearance(const VrmlData_Scene& theScene, const char* theName)
|
||||
: VrmlData_Node(theScene, theName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Material
|
||||
*/
|
||||
inline const Handle(VrmlData_Material)&
|
||||
Material () const { return myMaterial; }
|
||||
inline const Handle(VrmlData_Material)& Material() const { return myMaterial; }
|
||||
|
||||
/**
|
||||
* Query the Texture
|
||||
*/
|
||||
inline const Handle(VrmlData_Texture)&
|
||||
Texture () const { return myTexture; }
|
||||
inline const Handle(VrmlData_Texture)& Texture() const { return myTexture; }
|
||||
|
||||
/**
|
||||
* Query the TextureTransform
|
||||
*/
|
||||
inline const Handle(VrmlData_TextureTransform)&
|
||||
TextureTransform () const { return myTTransform; }
|
||||
inline const Handle(VrmlData_TextureTransform)& TextureTransform() const { return myTTransform; }
|
||||
|
||||
/**
|
||||
* Set the Material
|
||||
*/
|
||||
inline void SetMaterial (const Handle(VrmlData_Material)& theMat)
|
||||
{ myMaterial = theMat; }
|
||||
inline void SetMaterial(const Handle(VrmlData_Material)& theMat) { myMaterial = theMat; }
|
||||
|
||||
/**
|
||||
* Set the Texture
|
||||
*/
|
||||
inline void SetTexture (const Handle(VrmlData_Texture)& theTexture)
|
||||
{ myTexture = theTexture; }
|
||||
inline void SetTexture(const Handle(VrmlData_Texture)& theTexture) { myTexture = theTexture; }
|
||||
|
||||
/**
|
||||
* Set the Texture Transform
|
||||
*/
|
||||
inline void SetTextureTransform
|
||||
(const Handle(VrmlData_TextureTransform)& theTT)
|
||||
{ myTTransform = theTT; }
|
||||
inline void SetTextureTransform(const Handle(VrmlData_TextureTransform)& theTT)
|
||||
{
|
||||
myTTransform = theTT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.<p>
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)&)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)&) const
|
||||
Standard_OVERRIDE;
|
||||
/**
|
||||
* Read the node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Returns True if the node is default, so that it should not be written.
|
||||
*/
|
||||
Standard_EXPORT virtual Standard_Boolean
|
||||
IsDefault () const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsDefault() const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
Handle(VrmlData_Material) myMaterial;
|
||||
Handle(VrmlData_Texture) myTexture;
|
||||
Handle(VrmlData_TextureTransform) myTTransform;
|
||||
Handle(VrmlData_Material) myMaterial;
|
||||
Handle(VrmlData_Texture) myTexture;
|
||||
Handle(VrmlData_TextureTransform) myTTransform;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Appearance,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Appearance, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Appearance, VrmlData_Node)
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Appearance, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -25,83 +25,84 @@ class gp_XYZ;
|
||||
*/
|
||||
class VrmlData_ArrayVec3d : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_ArrayVec3d ()
|
||||
: myArray (0L), myLength (0)
|
||||
{}
|
||||
inline VrmlData_ArrayVec3d()
|
||||
: myArray(0L),
|
||||
myLength(0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_ArrayVec3d (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Size nVec,
|
||||
const gp_XYZ * arrVec)
|
||||
: VrmlData_Node (theScene, theName),
|
||||
myArray (arrVec),
|
||||
myLength (nVec)
|
||||
{}
|
||||
inline VrmlData_ArrayVec3d(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Size nVec,
|
||||
const gp_XYZ* arrVec)
|
||||
: VrmlData_Node(theScene, theName),
|
||||
myArray(arrVec),
|
||||
myLength(nVec)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the number of vectors
|
||||
*/
|
||||
inline Standard_Size Length () const { return myLength; }
|
||||
inline Standard_Size Length() const { return myLength; }
|
||||
|
||||
/**
|
||||
* Query the array
|
||||
*/
|
||||
inline const gp_XYZ * Values () const { return myArray; }
|
||||
inline const gp_XYZ* Values() const { return myArray; }
|
||||
|
||||
/**
|
||||
* Create a data array and assign the field myArray.
|
||||
* @return
|
||||
* True if allocation was successful.
|
||||
*/
|
||||
Standard_EXPORT Standard_Boolean
|
||||
AllocateValues (const Standard_Size theLength);
|
||||
*/
|
||||
Standard_EXPORT Standard_Boolean AllocateValues(const Standard_Size theLength);
|
||||
|
||||
/**
|
||||
* Set the array data
|
||||
*/
|
||||
inline void SetValues (const Standard_Size nValues,
|
||||
const gp_XYZ * arrValues)
|
||||
{ myLength = nValues; myArray = arrValues; }
|
||||
inline void SetValues(const Standard_Size nValues, const gp_XYZ* arrValues)
|
||||
{
|
||||
myLength = nValues;
|
||||
myArray = arrValues;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
// Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
// Clone (const Handle(VrmlData_Node)& theOther)const;
|
||||
// Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
// Clone (const Handle(VrmlData_Node)& theOther)const;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
ReadArray (VrmlData_InBuffer& theBuffer,
|
||||
const char * theName,
|
||||
const Standard_Boolean isScale);
|
||||
Standard_EXPORT VrmlData_ErrorStatus ReadArray(VrmlData_InBuffer& theBuffer,
|
||||
const char* theName,
|
||||
const Standard_Boolean isScale);
|
||||
|
||||
/**
|
||||
* Write the Node to the output stream currently opened in Scene.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
WriteArray(const char * theName,
|
||||
const Standard_Boolean isScale) const;
|
||||
Standard_EXPORT VrmlData_ErrorStatus WriteArray(const char* theName,
|
||||
const Standard_Boolean isScale) const;
|
||||
|
||||
/**
|
||||
* Returns True if the node is default, so that it should not be written.
|
||||
*/
|
||||
Standard_EXPORT virtual Standard_Boolean
|
||||
IsDefault () const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsDefault() const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
/**
|
||||
* Query one vector
|
||||
@@ -110,21 +111,20 @@ class VrmlData_ArrayVec3d : public VrmlData_Node
|
||||
* @return
|
||||
* the vector for the index. If index irrelevant, returns (0., 0., 0.)
|
||||
*/
|
||||
Standard_EXPORT const gp_XYZ& Value (const Standard_Size i) const;
|
||||
Standard_EXPORT const gp_XYZ& Value(const Standard_Size i) const;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED FIELDS ----------
|
||||
|
||||
const gp_XYZ * myArray;
|
||||
Standard_Size myLength;
|
||||
const gp_XYZ* myArray;
|
||||
Standard_Size myLength;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_ArrayVec3d,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_ArrayVec3d, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_ArrayVec3d, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_ArrayVec3d, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -26,78 +26,79 @@
|
||||
*/
|
||||
class VrmlData_Box : public VrmlData_Geometry
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Box ()
|
||||
: mySize (2., 2., 2.)
|
||||
{}
|
||||
inline VrmlData_Box()
|
||||
: mySize(2., 2., 2.)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_Box (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Real sizeX = 2.,
|
||||
const Standard_Real sizeY = 2.,
|
||||
const Standard_Real sizeZ = 2.)
|
||||
: VrmlData_Geometry (theScene, theName),
|
||||
mySize (sizeX, sizeY, sizeZ)
|
||||
{}
|
||||
inline VrmlData_Box(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Real sizeX = 2.,
|
||||
const Standard_Real sizeY = 2.,
|
||||
const Standard_Real sizeZ = 2.)
|
||||
: VrmlData_Geometry(theScene, theName),
|
||||
mySize(sizeX, sizeY, sizeZ)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Box size
|
||||
*/
|
||||
inline const gp_XYZ& Size () const { return mySize; }
|
||||
inline const gp_XYZ& Size() const { return mySize; }
|
||||
|
||||
/**
|
||||
* Set the Box Size
|
||||
*/
|
||||
inline void SetSize (const gp_XYZ& theSize)
|
||||
{ mySize = theSize; SetModified(); }
|
||||
inline void SetSize(const gp_XYZ& theSize)
|
||||
{
|
||||
mySize = theSize;
|
||||
SetModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the primitive topology. This method returns a Null shape if there
|
||||
* is an internal error during the primitive creation (zero radius, etc.)
|
||||
*/
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)&
|
||||
TShape () Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape() Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Fill the Node internal data from the given input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
gp_XYZ mySize;
|
||||
gp_XYZ mySize;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Box,VrmlData_Geometry)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Box, VrmlData_Geometry)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Box, VrmlData_Geometry)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Box, VrmlData_Geometry)
|
||||
|
||||
#endif
|
||||
|
@@ -25,23 +25,24 @@
|
||||
*/
|
||||
class VrmlData_Color : public VrmlData_ArrayVec3d
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor.
|
||||
*/
|
||||
inline VrmlData_Color () {}
|
||||
inline VrmlData_Color() {}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
inline VrmlData_Color (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const size_t nColors =0,
|
||||
const gp_XYZ * arrColors=0L)
|
||||
: VrmlData_ArrayVec3d (theScene, theName, nColors, arrColors)
|
||||
{}
|
||||
inline VrmlData_Color(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const size_t nColors = 0,
|
||||
const gp_XYZ* arrColors = 0L)
|
||||
: VrmlData_ArrayVec3d(theScene, theName, nColors, arrColors)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query one color
|
||||
@@ -50,50 +51,47 @@ class VrmlData_Color : public VrmlData_ArrayVec3d
|
||||
* @return
|
||||
* the color value for the index. If index irrelevant, returns (0., 0., 0.)
|
||||
*/
|
||||
inline const Quantity_Color Color (const Standard_Integer i) const
|
||||
{ return Quantity_Color (Value(i).X(), Value(i).Y(), Value(i).Z(),
|
||||
Quantity_TOC_sRGB); }
|
||||
inline const Quantity_Color Color(const Standard_Integer i) const
|
||||
{
|
||||
return Quantity_Color(Value(i).X(), Value(i).Y(), Value(i).Z(), Quantity_TOC_sRGB);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the array data
|
||||
*/
|
||||
inline void SetColors (const size_t nColors,
|
||||
const gp_XYZ * arrColors)
|
||||
{ myLength = nColors; myArray = arrColors; }
|
||||
inline void SetColors(const size_t nColors, const gp_XYZ* arrColors)
|
||||
{
|
||||
myLength = nColors;
|
||||
myArray = arrColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.<p>
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to the Scene output.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
|
||||
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Color,VrmlData_ArrayVec3d)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Color, VrmlData_ArrayVec3d)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Color, VrmlData_ArrayVec3d)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Color, VrmlData_ArrayVec3d)
|
||||
|
||||
#endif
|
||||
|
@@ -20,125 +20,129 @@
|
||||
|
||||
/**
|
||||
* Implementation of the Cone node.
|
||||
* The cone is located with its middle of the height segment in (0., 0., 0.)
|
||||
* The cone is located with its middle of the height segment in (0., 0., 0.)
|
||||
* The height is oriented along OY.
|
||||
*/
|
||||
class VrmlData_Cone : public VrmlData_Geometry
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Cone ()
|
||||
: myBottomRadius (1.),
|
||||
myHeight (2.),
|
||||
myHasSide (Standard_True),
|
||||
myHasBottom (Standard_True)
|
||||
{}
|
||||
inline VrmlData_Cone()
|
||||
: myBottomRadius(1.),
|
||||
myHeight(2.),
|
||||
myHasSide(Standard_True),
|
||||
myHasBottom(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_Cone (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Real theBottomRadius = 1.,
|
||||
const Standard_Real theHeight = 2.)
|
||||
: VrmlData_Geometry (theScene, theName),
|
||||
myBottomRadius (theBottomRadius),
|
||||
myHeight (theHeight),
|
||||
myHasSide (Standard_True),
|
||||
myHasBottom (Standard_True)
|
||||
{}
|
||||
inline VrmlData_Cone(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Real theBottomRadius = 1.,
|
||||
const Standard_Real theHeight = 2.)
|
||||
: VrmlData_Geometry(theScene, theName),
|
||||
myBottomRadius(theBottomRadius),
|
||||
myHeight(theHeight),
|
||||
myHasSide(Standard_True),
|
||||
myHasBottom(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Bottom Radius
|
||||
*/
|
||||
inline Standard_Real BottomRadius () const { return myBottomRadius; }
|
||||
inline Standard_Real BottomRadius() const { return myBottomRadius; }
|
||||
|
||||
/**
|
||||
* Query the Height
|
||||
*/
|
||||
inline Standard_Real Height () const { return myHeight; }
|
||||
inline Standard_Real Height() const { return myHeight; }
|
||||
|
||||
/**
|
||||
* Query if the bottom circle is included
|
||||
*/
|
||||
inline Standard_Boolean HasBottom () const { return myHasBottom; }
|
||||
inline Standard_Boolean HasBottom() const { return myHasBottom; }
|
||||
|
||||
/**
|
||||
* Query if the side surface is included
|
||||
*/
|
||||
inline Standard_Boolean HasSide () const { return myHasSide; }
|
||||
inline Standard_Boolean HasSide() const { return myHasSide; }
|
||||
|
||||
/**
|
||||
* Set the Bottom Radius
|
||||
*/
|
||||
inline void SetBottomRadius (const Standard_Real theRadius)
|
||||
{ myBottomRadius = theRadius; SetModified(); }
|
||||
inline void SetBottomRadius(const Standard_Real theRadius)
|
||||
{
|
||||
myBottomRadius = theRadius;
|
||||
SetModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Height
|
||||
*/
|
||||
inline void SetHeight (const Standard_Real theHeight)
|
||||
{ myHeight = theHeight; SetModified(); }
|
||||
inline void SetHeight(const Standard_Real theHeight)
|
||||
{
|
||||
myHeight = theHeight;
|
||||
SetModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set which faces are included
|
||||
*/
|
||||
inline void SetFaces (const Standard_Boolean hasBottom,
|
||||
const Standard_Boolean hasSide)
|
||||
{ myHasBottom = hasBottom; myHasSide = hasSide; SetModified(); }
|
||||
inline void SetFaces(const Standard_Boolean hasBottom, const Standard_Boolean hasSide)
|
||||
{
|
||||
myHasBottom = hasBottom;
|
||||
myHasSide = hasSide;
|
||||
SetModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the primitive topology. This method returns a Null shape if there
|
||||
* is an internal error during the primitive creation (zero radius, etc.)
|
||||
*/
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape () Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape() Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Fill the Node internal data from the given input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
Standard_Real myBottomRadius;
|
||||
Standard_Real myHeight;
|
||||
Standard_Boolean myHasSide : 1;
|
||||
Standard_Boolean myHasBottom : 1;
|
||||
Standard_Real myBottomRadius;
|
||||
Standard_Real myHeight;
|
||||
Standard_Boolean myHasSide : 1;
|
||||
Standard_Boolean myHasBottom : 1;
|
||||
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Cone,VrmlData_Geometry)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Cone, VrmlData_Geometry)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Cone, VrmlData_Geometry)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Cone, VrmlData_Geometry)
|
||||
|
||||
#endif
|
||||
|
@@ -23,23 +23,24 @@
|
||||
*/
|
||||
class VrmlData_Coordinate : public VrmlData_ArrayVec3d
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty Constructor
|
||||
*/
|
||||
inline VrmlData_Coordinate () {}
|
||||
inline VrmlData_Coordinate() {}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_Coordinate (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const size_t nPoints = 0,
|
||||
const gp_XYZ * arrPoints = 0L)
|
||||
: VrmlData_ArrayVec3d (theScene, theName, nPoints, arrPoints)
|
||||
{}
|
||||
inline VrmlData_Coordinate(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const size_t nPoints = 0,
|
||||
const gp_XYZ* arrPoints = 0L)
|
||||
: VrmlData_ArrayVec3d(theScene, theName, nPoints, arrPoints)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query one point
|
||||
@@ -48,39 +49,35 @@ class VrmlData_Coordinate : public VrmlData_ArrayVec3d
|
||||
* @return
|
||||
* the coordinate for the index. If index irrelevant, returns (0., 0., 0.)
|
||||
*/
|
||||
inline const gp_XYZ& Coordinate (const Standard_Integer i) const
|
||||
{ return Value(i); }
|
||||
inline const gp_XYZ& Coordinate(const Standard_Integer i) const { return Value(i); }
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to the Scene output.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Coordinate,VrmlData_ArrayVec3d)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Coordinate, VrmlData_ArrayVec3d)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Coordinate, VrmlData_ArrayVec3d)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Coordinate, VrmlData_ArrayVec3d)
|
||||
|
||||
#endif
|
||||
|
@@ -23,126 +23,134 @@
|
||||
*/
|
||||
class VrmlData_Cylinder : public VrmlData_Geometry
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Cylinder ()
|
||||
: myRadius (1.),
|
||||
myHeight (2.),
|
||||
myHasBottom (Standard_True),
|
||||
myHasSide (Standard_True),
|
||||
myHasTop (Standard_True)
|
||||
{}
|
||||
inline VrmlData_Cylinder()
|
||||
: myRadius(1.),
|
||||
myHeight(2.),
|
||||
myHasBottom(Standard_True),
|
||||
myHasSide(Standard_True),
|
||||
myHasTop(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_Cylinder (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Real theRadius = 1.,
|
||||
const Standard_Real theHeight = 2.)
|
||||
: VrmlData_Geometry (theScene, theName),
|
||||
myRadius (theRadius),
|
||||
myHeight (theHeight),
|
||||
myHasBottom (Standard_True),
|
||||
myHasSide (Standard_True),
|
||||
myHasTop (Standard_True)
|
||||
{}
|
||||
inline VrmlData_Cylinder(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Real theRadius = 1.,
|
||||
const Standard_Real theHeight = 2.)
|
||||
: VrmlData_Geometry(theScene, theName),
|
||||
myRadius(theRadius),
|
||||
myHeight(theHeight),
|
||||
myHasBottom(Standard_True),
|
||||
myHasSide(Standard_True),
|
||||
myHasTop(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Radius
|
||||
*/
|
||||
inline Standard_Real Radius () const { return myRadius; }
|
||||
inline Standard_Real Radius() const { return myRadius; }
|
||||
|
||||
/**
|
||||
* Query the Height
|
||||
*/
|
||||
inline Standard_Real Height () const { return myHeight; }
|
||||
inline Standard_Real Height() const { return myHeight; }
|
||||
|
||||
/**
|
||||
* Query if the bottom circle is included
|
||||
*/
|
||||
inline Standard_Boolean HasBottom () const { return myHasBottom; }
|
||||
inline Standard_Boolean HasBottom() const { return myHasBottom; }
|
||||
|
||||
/**
|
||||
* Query if the side surface is included
|
||||
*/
|
||||
inline Standard_Boolean HasSide () const { return myHasSide; }
|
||||
inline Standard_Boolean HasSide() const { return myHasSide; }
|
||||
|
||||
/**
|
||||
* Query if the top surface is included
|
||||
*/
|
||||
inline Standard_Boolean HasTop () const { return myHasTop; }
|
||||
inline Standard_Boolean HasTop() const { return myHasTop; }
|
||||
|
||||
/**
|
||||
* Set the Radius
|
||||
*/
|
||||
inline void SetRadius (const Standard_Real theRadius)
|
||||
{ myRadius = theRadius; SetModified(); }
|
||||
inline void SetRadius(const Standard_Real theRadius)
|
||||
{
|
||||
myRadius = theRadius;
|
||||
SetModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Height
|
||||
*/
|
||||
inline void SetHeight (const Standard_Real theHeight)
|
||||
{ myHeight = theHeight; SetModified(); }
|
||||
inline void SetHeight(const Standard_Real theHeight)
|
||||
{
|
||||
myHeight = theHeight;
|
||||
SetModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Set which faces are included
|
||||
*/
|
||||
inline void SetFaces (const Standard_Boolean hasBottom,
|
||||
const Standard_Boolean hasSide,
|
||||
const Standard_Boolean hasTop)
|
||||
{ myHasBottom = hasBottom; myHasSide = hasSide;
|
||||
myHasTop = hasTop; SetModified(); }
|
||||
inline void SetFaces(const Standard_Boolean hasBottom,
|
||||
const Standard_Boolean hasSide,
|
||||
const Standard_Boolean hasTop)
|
||||
{
|
||||
myHasBottom = hasBottom;
|
||||
myHasSide = hasSide;
|
||||
myHasTop = hasTop;
|
||||
SetModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the primitive topology. This method returns a Null shape if there
|
||||
* is an internal error during the primitive creation (zero radius, etc.)
|
||||
*/
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape () Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape() Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Fill the Node internal data from the given input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
Standard_Real myRadius;
|
||||
Standard_Real myHeight;
|
||||
Standard_Boolean myHasBottom : 1;
|
||||
Standard_Boolean myHasSide : 1;
|
||||
Standard_Boolean myHasTop : 1;
|
||||
Standard_Real myRadius;
|
||||
Standard_Real myHeight;
|
||||
Standard_Boolean myHasBottom : 1;
|
||||
Standard_Boolean myHasSide : 1;
|
||||
Standard_Boolean myHasTop : 1;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Cylinder,VrmlData_Geometry)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Cylinder, VrmlData_Geometry)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Cylinder, VrmlData_Geometry)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Cylinder, VrmlData_Geometry)
|
||||
|
||||
#endif
|
||||
|
@@ -20,6 +20,7 @@
|
||||
#include <VrmlData_Appearance.hxx>
|
||||
#include <TopoDS_TShape.hxx>
|
||||
|
||||
typedef NCollection_DataMap<Handle(TopoDS_TShape), Handle(VrmlData_Appearance)> VrmlData_DataMapOfShapeAppearance;
|
||||
typedef NCollection_DataMap<Handle(TopoDS_TShape), Handle(VrmlData_Appearance)>
|
||||
VrmlData_DataMapOfShapeAppearance;
|
||||
|
||||
#endif
|
||||
|
@@ -17,27 +17,28 @@
|
||||
#define VrmlData_ErrorStatus_HeaderFile
|
||||
|
||||
/**
|
||||
* Status of read/write or other operation.
|
||||
*/
|
||||
enum VrmlData_ErrorStatus {
|
||||
VrmlData_StatusOK = 0,
|
||||
VrmlData_EmptyData,
|
||||
VrmlData_UnrecoverableError,
|
||||
VrmlData_GeneralError,
|
||||
VrmlData_EndOfFile,
|
||||
VrmlData_NotVrmlFile,
|
||||
VrmlData_CannotOpenFile,
|
||||
VrmlData_VrmlFormatError,
|
||||
VrmlData_NumericInputError,
|
||||
VrmlData_IrrelevantNumber,
|
||||
VrmlData_BooleanInputError,
|
||||
VrmlData_StringInputError,
|
||||
VrmlData_NodeNameUnknown,
|
||||
VrmlData_NonPositiveSize,
|
||||
VrmlData_ReadUnknownNode,
|
||||
VrmlData_NonSupportedFeature,
|
||||
VrmlData_OutputStreamUndefined,
|
||||
VrmlData_NotImplemented
|
||||
};
|
||||
* Status of read/write or other operation.
|
||||
*/
|
||||
enum VrmlData_ErrorStatus
|
||||
{
|
||||
VrmlData_StatusOK = 0,
|
||||
VrmlData_EmptyData,
|
||||
VrmlData_UnrecoverableError,
|
||||
VrmlData_GeneralError,
|
||||
VrmlData_EndOfFile,
|
||||
VrmlData_NotVrmlFile,
|
||||
VrmlData_CannotOpenFile,
|
||||
VrmlData_VrmlFormatError,
|
||||
VrmlData_NumericInputError,
|
||||
VrmlData_IrrelevantNumber,
|
||||
VrmlData_BooleanInputError,
|
||||
VrmlData_StringInputError,
|
||||
VrmlData_NodeNameUnknown,
|
||||
VrmlData_NonPositiveSize,
|
||||
VrmlData_ReadUnknownNode,
|
||||
VrmlData_NonSupportedFeature,
|
||||
VrmlData_OutputStreamUndefined,
|
||||
VrmlData_NotImplemented
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -24,99 +24,95 @@
|
||||
*/
|
||||
class VrmlData_Faceted : public VrmlData_Geometry
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Faceted ()
|
||||
: myCreaseAngle (0.),
|
||||
myIsCCW (Standard_True),
|
||||
myIsSolid (Standard_True),
|
||||
myIsConvex (Standard_True)
|
||||
{}
|
||||
inline VrmlData_Faceted()
|
||||
: myCreaseAngle(0.),
|
||||
myIsCCW(Standard_True),
|
||||
myIsSolid(Standard_True),
|
||||
myIsConvex(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Faceted (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Boolean isCCW,
|
||||
const Standard_Boolean isSolid,
|
||||
const Standard_Boolean isConvex,
|
||||
const Standard_Real theCreaseAngle)
|
||||
: VrmlData_Geometry (theScene, theName),
|
||||
myCreaseAngle (theCreaseAngle),
|
||||
myIsCCW (isCCW),
|
||||
myIsSolid (isSolid),
|
||||
myIsConvex (isConvex)
|
||||
{}
|
||||
inline VrmlData_Faceted(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Boolean isCCW,
|
||||
const Standard_Boolean isSolid,
|
||||
const Standard_Boolean isConvex,
|
||||
const Standard_Real theCreaseAngle)
|
||||
: VrmlData_Geometry(theScene, theName),
|
||||
myCreaseAngle(theCreaseAngle),
|
||||
myIsCCW(isCCW),
|
||||
myIsSolid(isSolid),
|
||||
myIsConvex(isConvex)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query "Is Counter-Clockwise" attribute
|
||||
*/
|
||||
inline Standard_Boolean IsCCW () const { return myIsCCW; }
|
||||
inline Standard_Boolean IsCCW() const { return myIsCCW; }
|
||||
|
||||
/**
|
||||
* Query "Is Solid" attribute
|
||||
*/
|
||||
inline Standard_Boolean IsSolid () const { return myIsSolid; }
|
||||
inline Standard_Boolean IsSolid() const { return myIsSolid; }
|
||||
|
||||
/**
|
||||
* Query "Is Convex" attribute
|
||||
*/
|
||||
inline Standard_Boolean IsConvex () const { return myIsConvex; }
|
||||
inline Standard_Boolean IsConvex() const { return myIsConvex; }
|
||||
|
||||
/**
|
||||
* Query the Crease Angle
|
||||
*/
|
||||
inline Standard_Real CreaseAngle () const { return myCreaseAngle; }
|
||||
inline Standard_Real CreaseAngle() const { return myCreaseAngle; }
|
||||
|
||||
/**
|
||||
* Set "Is Counter-Clockwise" attribute
|
||||
*/
|
||||
inline void SetCCW (const Standard_Boolean theValue)
|
||||
{ myIsCCW = theValue; }
|
||||
inline void SetCCW(const Standard_Boolean theValue) { myIsCCW = theValue; }
|
||||
|
||||
/**
|
||||
* Set "Is Solid" attribute
|
||||
*/
|
||||
inline void SetSolid (const Standard_Boolean theValue)
|
||||
{ myIsSolid = theValue; }
|
||||
inline void SetSolid(const Standard_Boolean theValue) { myIsSolid = theValue; }
|
||||
|
||||
/**
|
||||
* Set "Is Convex" attribute
|
||||
*/
|
||||
inline void SetConvex (const Standard_Boolean theValue)
|
||||
{ myIsConvex = theValue; }
|
||||
inline void SetConvex(const Standard_Boolean theValue) { myIsConvex = theValue; }
|
||||
|
||||
/**
|
||||
* Set "Is Convex" attribute
|
||||
*/
|
||||
inline void SetCreaseAngle (const Standard_Real theValue)
|
||||
{ myCreaseAngle = theValue; }
|
||||
inline void SetCreaseAngle(const Standard_Real theValue) { myCreaseAngle = theValue; }
|
||||
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
protected:
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
readData (VrmlData_InBuffer& theBuffer);
|
||||
protected:
|
||||
Standard_EXPORT VrmlData_ErrorStatus readData(VrmlData_InBuffer& theBuffer);
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
Standard_Real myCreaseAngle;
|
||||
Standard_Boolean myIsCCW : 1;
|
||||
Standard_Boolean myIsSolid : 1;
|
||||
Standard_Boolean myIsConvex : 1;
|
||||
Standard_Real myCreaseAngle;
|
||||
Standard_Boolean myIsCCW : 1;
|
||||
Standard_Boolean myIsSolid : 1;
|
||||
Standard_Boolean myIsConvex : 1;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Faceted,VrmlData_Geometry)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Faceted, VrmlData_Geometry)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Faceted, VrmlData_Geometry)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Faceted, VrmlData_Geometry)
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -26,59 +26,57 @@
|
||||
|
||||
class VrmlData_Geometry : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Geometry ()
|
||||
: myIsModified (Standard_True)
|
||||
{}
|
||||
inline VrmlData_Geometry()
|
||||
: myIsModified(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_Geometry (const VrmlData_Scene& theScene,
|
||||
const char * theName)
|
||||
: VrmlData_Node (theScene, theName),
|
||||
myIsModified (Standard_True)
|
||||
{}
|
||||
inline VrmlData_Geometry(const VrmlData_Scene& theScene, const char* theName)
|
||||
: VrmlData_Node(theScene, theName),
|
||||
myIsModified(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the shape. This method checks the flag myIsModified; if True it
|
||||
* should rebuild the shape presentation.
|
||||
*/
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape () = 0;
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape() = 0;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
/**
|
||||
* Set the TShape.
|
||||
*/
|
||||
inline void SetTShape (const Handle(TopoDS_TShape)& theTShape)
|
||||
{ myTShape = theTShape; }
|
||||
inline void SetTShape(const Handle(TopoDS_TShape)& theTShape) { myTShape = theTShape; }
|
||||
|
||||
/**
|
||||
* Mark modification
|
||||
*/
|
||||
inline void SetModified () { myIsModified= Standard_True; }
|
||||
inline void SetModified() { myIsModified = Standard_True; }
|
||||
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED FIELDS ----------
|
||||
|
||||
Handle(TopoDS_TShape) myTShape;
|
||||
Standard_Boolean myIsModified;
|
||||
Handle(TopoDS_TShape) myTShape;
|
||||
Standard_Boolean myIsModified;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_Geometry,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_Geometry, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Geometry, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Geometry, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -27,125 +27,110 @@
|
||||
#include <Precision.hxx>
|
||||
#include <gp_Ax1.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_Group,VrmlData_Node)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_Group, VrmlData_Node)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning (disable:4996)
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Group
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
|
||||
VrmlData_Group::VrmlData_Group (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Boolean isTransform)
|
||||
: VrmlData_Node (theScene, theName),
|
||||
myIsTransform (isTransform),
|
||||
myNodes (theScene.Allocator())
|
||||
{}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveNode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean VrmlData_Group::RemoveNode
|
||||
(const Handle(VrmlData_Node)& theNode)
|
||||
VrmlData_Group::VrmlData_Group(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Boolean isTransform)
|
||||
: VrmlData_Node(theScene, theName),
|
||||
myIsTransform(isTransform),
|
||||
myNodes(theScene.Allocator())
|
||||
{
|
||||
Standard_Boolean aResult (Standard_False);
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean VrmlData_Group::RemoveNode(const Handle(VrmlData_Node)& theNode)
|
||||
{
|
||||
Standard_Boolean aResult(Standard_False);
|
||||
for (Iterator anIter = NodeIterator(); anIter.More(); anIter.Next())
|
||||
if (anIter.Value() == theNode) {
|
||||
if (anIter.Value() == theNode)
|
||||
{
|
||||
aResult = Standard_True;
|
||||
myNodes.Remove (anIter);
|
||||
myNodes.Remove(anIter);
|
||||
break;
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTransform
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean VrmlData_Group::SetTransform (const gp_Trsf& theTrsf)
|
||||
Standard_Boolean VrmlData_Group::SetTransform(const gp_Trsf& theTrsf)
|
||||
{
|
||||
Standard_Boolean aResult (Standard_False);
|
||||
if (myIsTransform) {
|
||||
myTrsf = theTrsf;
|
||||
Standard_Boolean aResult(Standard_False);
|
||||
if (myIsTransform)
|
||||
{
|
||||
myTrsf = theTrsf;
|
||||
aResult = Standard_True;
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Group::Clone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_Group::Clone
|
||||
(const Handle(VrmlData_Node)& theOther) const
|
||||
Handle(VrmlData_Node) VrmlData_Group::Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
{
|
||||
Handle(VrmlData_Group) aResult =
|
||||
Handle(VrmlData_Group)::DownCast (VrmlData_Node::Clone(theOther));
|
||||
Handle(VrmlData_Group) aResult = Handle(VrmlData_Group)::DownCast(VrmlData_Node::Clone(theOther));
|
||||
if (aResult.IsNull())
|
||||
aResult =
|
||||
new VrmlData_Group (theOther.IsNull() ? Scene() : theOther->Scene(),
|
||||
Name(), myIsTransform);
|
||||
new VrmlData_Group(theOther.IsNull() ? Scene() : theOther->Scene(), Name(), myIsTransform);
|
||||
|
||||
aResult->myIsTransform = myIsTransform;
|
||||
if (&aResult->Scene() == &Scene())
|
||||
aResult->myNodes = myNodes;
|
||||
else {
|
||||
else
|
||||
{
|
||||
// Create a dummy node to pass the different Scene instance to methods Clone
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode =
|
||||
new VrmlData_UnknownNode (aResult->Scene());
|
||||
Iterator anIter (myNodes);
|
||||
for (; anIter.More(); anIter.Next()) {
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode = new VrmlData_UnknownNode(aResult->Scene());
|
||||
Iterator anIter(myNodes);
|
||||
for (; anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(VrmlData_Node)& aNode = anIter.Value();
|
||||
if (aNode.IsNull() == Standard_False)
|
||||
aResult->myNodes.Append(aNode->Clone (aDummyNode));
|
||||
aResult->myNodes.Append(aNode->Clone(aDummyNode));
|
||||
}
|
||||
}
|
||||
if (myIsTransform)
|
||||
aResult->SetTransform (myTrsf);
|
||||
aResult->SetBox (myBox);
|
||||
aResult->SetTransform(myTrsf);
|
||||
aResult->SetBox(myBox);
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindNode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_Group::FindNode
|
||||
(const char * theName,
|
||||
gp_Trsf& theLocation) const
|
||||
Handle(VrmlData_Node) VrmlData_Group::FindNode(const char* theName, gp_Trsf& theLocation) const
|
||||
{
|
||||
Handle(VrmlData_Node) aResult;
|
||||
Iterator anIter (myNodes);
|
||||
for (; anIter.More(); anIter.Next()) {
|
||||
Iterator anIter(myNodes);
|
||||
for (; anIter.More(); anIter.Next())
|
||||
{
|
||||
const Handle(VrmlData_Node)& aNode = anIter.Value();
|
||||
if (aNode.IsNull() == Standard_False) {
|
||||
if (aNode.IsNull() == Standard_False)
|
||||
{
|
||||
if (strcmp(aNode->Name(), theName) == 0)
|
||||
{
|
||||
aResult = aNode;
|
||||
aResult = aNode;
|
||||
theLocation = myTrsf;
|
||||
break;
|
||||
}
|
||||
// Try a Group type of node
|
||||
if (aNode->IsKind(STANDARD_TYPE(VrmlData_Group)))
|
||||
{
|
||||
const Handle(VrmlData_Group) aGroup =
|
||||
Handle(VrmlData_Group)::DownCast (aNode);
|
||||
if (aGroup.IsNull() == Standard_False) {
|
||||
const Handle(VrmlData_Group) aGroup = Handle(VrmlData_Group)::DownCast(aNode);
|
||||
if (aGroup.IsNull() == Standard_False)
|
||||
{
|
||||
aResult = aGroup->FindNode(theName, theLocation);
|
||||
if (aResult.IsNull() == Standard_False) {
|
||||
//theLocation *= myTrsf;
|
||||
if (aResult.IsNull() == Standard_False)
|
||||
{
|
||||
// theLocation *= myTrsf;
|
||||
theLocation.PreMultiply(myTrsf);
|
||||
break;
|
||||
}
|
||||
@@ -156,35 +141,32 @@ Handle(VrmlData_Node) VrmlData_Group::FindNode
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Group::Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Group::Read (VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_Group::Read(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
gp_XYZ aBoxCenter(0., 0., 0.), aBoxSize(-1., -1., -1.);
|
||||
gp_XYZ aCenter (0., 0., 0.), aScale (1., 1., 1.), aTrans (0., 0., 0.);
|
||||
gp_XYZ aRotAxis (0., 0., 1.), aScaleAxis (0., 0., 1.);
|
||||
Standard_Real aRotAngle (0.), aScaleAngle(0.);
|
||||
gp_XYZ aBoxCenter(0., 0., 0.), aBoxSize(-1., -1., -1.);
|
||||
gp_XYZ aCenter(0., 0., 0.), aScale(1., 1., 1.), aTrans(0., 0., 0.);
|
||||
gp_XYZ aRotAxis(0., 0., 1.), aScaleAxis(0., 0., 1.);
|
||||
Standard_Real aRotAngle(0.), aScaleAngle(0.);
|
||||
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "bboxCenter"))
|
||||
aStatus = Scene().ReadXYZ (theBuffer, aBoxCenter,
|
||||
Standard_True, Standard_False);
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "bboxCenter"))
|
||||
aStatus = Scene().ReadXYZ(theBuffer, aBoxCenter, Standard_True, Standard_False);
|
||||
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "bboxSize"))
|
||||
aStatus = Scene().ReadXYZ (theBuffer, aBoxSize,
|
||||
Standard_True, Standard_False);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "bboxSize"))
|
||||
aStatus = Scene().ReadXYZ(theBuffer, aBoxSize, Standard_True, Standard_False);
|
||||
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "children")) {
|
||||
Standard_Boolean isBracketed (Standard_False);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "children"))
|
||||
{
|
||||
Standard_Boolean isBracketed(Standard_False);
|
||||
// Read the opening bracket for the list of children
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
if (theBuffer.LinePtr[0] == '[') {
|
||||
if (theBuffer.LinePtr[0] == '[')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
@@ -193,66 +175,36 @@ VrmlData_ErrorStatus VrmlData_Group::Read (VrmlData_InBuffer& theBuffer)
|
||||
|
||||
// Read the child nodes
|
||||
Handle(VrmlData_Node) aChildNode;
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
// read the end-of-list bracket
|
||||
if (isBracketed && theBuffer.LinePtr[0] == ']') {
|
||||
if (isBracketed && theBuffer.LinePtr[0] == ']')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
break;
|
||||
}
|
||||
// otherwise read a node
|
||||
if (!OK(aStatus, ReadNode (theBuffer, aChildNode)))
|
||||
if (!OK(aStatus, ReadNode(theBuffer, aChildNode)))
|
||||
break;
|
||||
AddNode (aChildNode);
|
||||
AddNode(aChildNode);
|
||||
if (isBracketed == Standard_False)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "collide")) {
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "collide"))
|
||||
{
|
||||
TCollection_AsciiString aDummy;
|
||||
aStatus = Scene().ReadWord (theBuffer, aDummy);
|
||||
aStatus = Scene().ReadWord(theBuffer, aDummy);
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "Switch"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Switch"))
|
||||
{
|
||||
Standard_Boolean isBracketed (Standard_False);
|
||||
// Read the opening bracket for the list of children
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
|
||||
if (theBuffer.LinePtr[0] == '{') {
|
||||
theBuffer.LinePtr++;
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
isBracketed = Standard_True;
|
||||
}
|
||||
|
||||
// Read the child nodes
|
||||
Handle(VrmlData_Node) aChildNode;
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
// read the end-of-list bracket
|
||||
if (isBracketed && theBuffer.LinePtr[0] == '}') {
|
||||
theBuffer.LinePtr++;
|
||||
break;
|
||||
}
|
||||
|
||||
// otherwise read a node
|
||||
if (!OK(aStatus, ReadNode (theBuffer, aChildNode)))
|
||||
break;
|
||||
|
||||
AddNode (aChildNode);
|
||||
if (isBracketed == Standard_False)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "TransformSeparator") ||
|
||||
VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Separator"))
|
||||
{
|
||||
Handle(VrmlData_Group) aGroupNode = new VrmlData_Group(Scene(), "");
|
||||
Standard_Boolean isBracketed(Standard_False);
|
||||
// Read the opening bracket for the list of children
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
|
||||
if (theBuffer.LinePtr[0] == '{') {
|
||||
if (theBuffer.LinePtr[0] == '{')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
@@ -261,9 +213,48 @@ VrmlData_ErrorStatus VrmlData_Group::Read (VrmlData_InBuffer& theBuffer)
|
||||
|
||||
// Read the child nodes
|
||||
Handle(VrmlData_Node) aChildNode;
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
// read the end-of-list bracket
|
||||
if (isBracketed && theBuffer.LinePtr[0] == '}') {
|
||||
if (isBracketed && theBuffer.LinePtr[0] == '}')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
break;
|
||||
}
|
||||
|
||||
// otherwise read a node
|
||||
if (!OK(aStatus, ReadNode(theBuffer, aChildNode)))
|
||||
break;
|
||||
|
||||
AddNode(aChildNode);
|
||||
if (isBracketed == Standard_False)
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "TransformSeparator")
|
||||
|| VRMLDATA_LCOMPARE(theBuffer.LinePtr, "Separator"))
|
||||
{
|
||||
Handle(VrmlData_Group) aGroupNode = new VrmlData_Group(Scene(), "");
|
||||
Standard_Boolean isBracketed(Standard_False);
|
||||
// Read the opening bracket for the list of children
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
|
||||
if (theBuffer.LinePtr[0] == '{')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
isBracketed = Standard_True;
|
||||
}
|
||||
|
||||
// Read the child nodes
|
||||
Handle(VrmlData_Node) aChildNode;
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
// read the end-of-list bracket
|
||||
if (isBracketed && theBuffer.LinePtr[0] == '}')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
break;
|
||||
}
|
||||
@@ -276,11 +267,12 @@ VrmlData_ErrorStatus VrmlData_Group::Read (VrmlData_InBuffer& theBuffer)
|
||||
break;
|
||||
}
|
||||
|
||||
Handle(VrmlData_Coordinate) aCoord;
|
||||
Handle(VrmlData_Coordinate) aCoord;
|
||||
Handle(VrmlData_IndexedFaceSet) anIndFaceSet;
|
||||
Handle(VrmlData_IndexedLineSet) anIndLineSet;
|
||||
Handle(VrmlData_Appearance) anAppearance;
|
||||
for (VrmlData_ListOfNode::Iterator anIt = aGroupNode->NodeIterator(); anIt.More(); anIt.Next())
|
||||
Handle(VrmlData_Appearance) anAppearance;
|
||||
for (VrmlData_ListOfNode::Iterator anIt = aGroupNode->NodeIterator(); anIt.More();
|
||||
anIt.Next())
|
||||
{
|
||||
Handle(VrmlData_Node) aNode = anIt.Value();
|
||||
if (aNode.IsNull())
|
||||
@@ -309,7 +301,7 @@ VrmlData_ErrorStatus VrmlData_Group::Read (VrmlData_InBuffer& theBuffer)
|
||||
else if (anIt.Value()->IsKind(STANDARD_TYPE(VrmlData_Material)))
|
||||
{
|
||||
Handle(VrmlData_Material) aMaterial = Handle(VrmlData_Material)::DownCast(anIt.Value());
|
||||
anAppearance = new VrmlData_Appearance();
|
||||
anAppearance = new VrmlData_Appearance();
|
||||
anAppearance->SetMaterial(aMaterial);
|
||||
}
|
||||
}
|
||||
@@ -334,71 +326,78 @@ VrmlData_ErrorStatus VrmlData_Group::Read (VrmlData_InBuffer& theBuffer)
|
||||
|
||||
AddNode(aGroupNode);
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "ShapeHints") ||
|
||||
VRMLDATA_LCOMPARE (theBuffer.LinePtr, "DirectionalLight")) {
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "ShapeHints")
|
||||
|| VRMLDATA_LCOMPARE(theBuffer.LinePtr, "DirectionalLight"))
|
||||
{
|
||||
// Skip this tag
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
|
||||
if (theBuffer.LinePtr[0] == '{') {
|
||||
|
||||
if (theBuffer.LinePtr[0] == '{')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
if (!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
// read the end-of-list bracket
|
||||
if (theBuffer.LinePtr[0] == '}') {
|
||||
if (theBuffer.LinePtr[0] == '}')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
break;
|
||||
}
|
||||
theBuffer.LinePtr++;
|
||||
}
|
||||
}
|
||||
} else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "center"))
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "center"))
|
||||
if (myIsTransform)
|
||||
aStatus = Scene().ReadXYZ (theBuffer, aCenter,
|
||||
Standard_True, Standard_False);
|
||||
else {
|
||||
aStatus = Scene().ReadXYZ(theBuffer, aCenter, Standard_True, Standard_False);
|
||||
else
|
||||
{
|
||||
aStatus = VrmlData_VrmlFormatError;
|
||||
break;
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "rotation"))
|
||||
if (myIsTransform) {
|
||||
if (OK(aStatus, Scene().ReadXYZ (theBuffer, aRotAxis,
|
||||
Standard_False, Standard_False)))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "rotation"))
|
||||
if (myIsTransform)
|
||||
{
|
||||
if (OK(aStatus, Scene().ReadXYZ(theBuffer, aRotAxis, Standard_False, Standard_False)))
|
||||
{
|
||||
if (aRotAxis.SquareModulus() < Precision::Confusion())
|
||||
aRotAxis.SetZ (1.0);
|
||||
aStatus = Scene().ReadReal (theBuffer, aRotAngle,
|
||||
Standard_False, Standard_False);
|
||||
aRotAxis.SetZ(1.0);
|
||||
aStatus = Scene().ReadReal(theBuffer, aRotAngle, Standard_False, Standard_False);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
aStatus = VrmlData_VrmlFormatError;
|
||||
break;
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "scaleOrientation"))
|
||||
if (myIsTransform) {
|
||||
if (OK(aStatus, Scene().ReadXYZ (theBuffer, aScaleAxis,
|
||||
Standard_False, Standard_False)))
|
||||
aStatus = Scene().ReadReal (theBuffer, aScaleAngle,
|
||||
Standard_False, Standard_False);
|
||||
} else {
|
||||
aStatus = VrmlData_VrmlFormatError;
|
||||
break;
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "scale"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "scaleOrientation"))
|
||||
if (myIsTransform)
|
||||
aStatus = Scene().ReadXYZ (theBuffer, aScale,
|
||||
Standard_False, Standard_True);
|
||||
else {
|
||||
{
|
||||
if (OK(aStatus, Scene().ReadXYZ(theBuffer, aScaleAxis, Standard_False, Standard_False)))
|
||||
aStatus = Scene().ReadReal(theBuffer, aScaleAngle, Standard_False, Standard_False);
|
||||
}
|
||||
else
|
||||
{
|
||||
aStatus = VrmlData_VrmlFormatError;
|
||||
break;
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "translation"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "scale"))
|
||||
if (myIsTransform)
|
||||
aStatus = Scene().ReadXYZ (theBuffer, aTrans,
|
||||
Standard_True, Standard_False);
|
||||
else {
|
||||
aStatus = Scene().ReadXYZ(theBuffer, aScale, Standard_False, Standard_True);
|
||||
else
|
||||
{
|
||||
aStatus = VrmlData_VrmlFormatError;
|
||||
break;
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "translation"))
|
||||
if (myIsTransform)
|
||||
aStatus = Scene().ReadXYZ(theBuffer, aTrans, Standard_True, Standard_False);
|
||||
else
|
||||
{
|
||||
aStatus = VrmlData_VrmlFormatError;
|
||||
break;
|
||||
}
|
||||
@@ -410,57 +409,63 @@ VrmlData_ErrorStatus VrmlData_Group::Read (VrmlData_InBuffer& theBuffer)
|
||||
setName(aWord.ToCString());
|
||||
}
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "url")) {
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "url"))
|
||||
{
|
||||
NCollection_List<TCollection_AsciiString> lstURL;
|
||||
if (OK(aStatus, ReadMultiString (theBuffer, lstURL))) {
|
||||
NCollection_List<TCollection_AsciiString>::Iterator anIter (lstURL);
|
||||
for (; anIter.More(); anIter.Next()) {
|
||||
std::ifstream aStream;
|
||||
if (OK(aStatus, ReadMultiString(theBuffer, lstURL)))
|
||||
{
|
||||
NCollection_List<TCollection_AsciiString>::Iterator anIter(lstURL);
|
||||
for (; anIter.More(); anIter.Next())
|
||||
{
|
||||
std::ifstream aStream;
|
||||
const TCollection_AsciiString& aFileName = anIter.Value();
|
||||
if (!OK(aStatus, openFile (aStream, aFileName)))
|
||||
if (!OK(aStatus, openFile(aStream, aFileName)))
|
||||
break;
|
||||
VrmlData_Scene aScene (Scene().Allocator());
|
||||
VrmlData_Scene aScene(Scene().Allocator());
|
||||
aScene.myLinearScale = Scene().myLinearScale;
|
||||
aScene.myVrmlDir = Scene().myVrmlDir;
|
||||
aScene.myVrmlDir = Scene().myVrmlDir;
|
||||
aScene << aStream;
|
||||
if (!OK(aStatus, aScene.Status()))
|
||||
break;
|
||||
VrmlData_Scene::Iterator anIterN = aScene.GetIterator();
|
||||
for (; anIterN.More(); anIterN.Next())
|
||||
if (!anIterN.Value()->IsKind(STANDARD_TYPE(VrmlData_WorldInfo)))
|
||||
AddNode (anIterN.Value());
|
||||
AddNode(anIterN.Value());
|
||||
VrmlData_Scene::Iterator anAllIter(aScene.myAllNodes);
|
||||
for (; anAllIter.More(); anAllIter.Next()) {
|
||||
for (; anAllIter.More(); anAllIter.Next())
|
||||
{
|
||||
const Handle(VrmlData_Node)& aNode = anAllIter.Value();
|
||||
if (aNode->IsKind(STANDARD_TYPE(VrmlData_WorldInfo)))
|
||||
continue;
|
||||
const_cast <VrmlData_Scene&> (Scene()).myAllNodes.Append (aNode);
|
||||
const_cast<VrmlData_Scene&>(Scene()).myAllNodes.Append(aNode);
|
||||
aNode->myScene = &Scene();
|
||||
// The name of the imported node should be prefixed by the URL
|
||||
// because each name must remain unique in the global scene.
|
||||
if (aNode->Name())
|
||||
if (* aNode->Name() != '\0') {
|
||||
if (*aNode->Name() != '\0')
|
||||
{
|
||||
TCollection_AsciiString buf;
|
||||
buf += aFileName;
|
||||
Standard_Integer aCharLocation = buf.Location (1, '.', 1, buf.Length());
|
||||
Standard_Integer aCharLocation = buf.Location(1, '.', 1, buf.Length());
|
||||
if (aCharLocation != 0)
|
||||
{
|
||||
buf.Remove (aCharLocation, buf.Length() - aCharLocation + 1);
|
||||
buf.Remove(aCharLocation, buf.Length() - aCharLocation + 1);
|
||||
}
|
||||
buf += '_';
|
||||
buf += aNode->Name();
|
||||
const size_t len = buf.Length();
|
||||
char * aNewName =
|
||||
static_cast<char *> (Scene().Allocator()->Allocate (len));
|
||||
if (aNewName) {
|
||||
const size_t len = buf.Length();
|
||||
char* aNewName = static_cast<char*>(Scene().Allocator()->Allocate(len));
|
||||
if (aNewName)
|
||||
{
|
||||
aNode->myName = aNewName;
|
||||
memcpy (aNewName, buf.ToCString(), len);
|
||||
memcpy(aNewName, buf.ToCString(), len);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
break;
|
||||
|
||||
if (!OK(aStatus))
|
||||
@@ -469,83 +474,74 @@ VrmlData_ErrorStatus VrmlData_Group::Read (VrmlData_InBuffer& theBuffer)
|
||||
|
||||
// Read the terminating (closing) brace
|
||||
if (OK(aStatus))
|
||||
aStatus = readBrace (theBuffer);
|
||||
if (OK(aStatus)) {
|
||||
aStatus = readBrace(theBuffer);
|
||||
if (OK(aStatus))
|
||||
{
|
||||
// Check if the Bounding Box has been imported
|
||||
if (aBoxSize.X() > -Precision::Confusion() &&
|
||||
aBoxSize.Y() > -Precision::Confusion() &&
|
||||
aBoxSize.Z() > -Precision::Confusion())
|
||||
if (aBoxSize.X() > -Precision::Confusion() && aBoxSize.Y() > -Precision::Confusion()
|
||||
&& aBoxSize.Z() > -Precision::Confusion())
|
||||
{
|
||||
myBox.SetCenter (aBoxCenter);
|
||||
myBox.SetHSize (aBoxSize*0.5);
|
||||
myBox.SetCenter(aBoxCenter);
|
||||
myBox.SetHSize(aBoxSize * 0.5);
|
||||
}
|
||||
if (myIsTransform) {
|
||||
if (myIsTransform)
|
||||
{
|
||||
// Create the corresponding transformation.
|
||||
gp_Trsf tRot, tCentInv;
|
||||
myTrsf.SetTranslation(aTrans+aCenter);
|
||||
gp_Ax1 aRotation (gp::Origin(), aRotAxis);
|
||||
tRot.SetRotation(gp_Ax1 (gp::Origin(), aRotAxis), aRotAngle);
|
||||
myTrsf.Multiply (tRot);
|
||||
myTrsf.SetTranslation(aTrans + aCenter);
|
||||
gp_Ax1 aRotation(gp::Origin(), aRotAxis);
|
||||
tRot.SetRotation(gp_Ax1(gp::Origin(), aRotAxis), aRotAngle);
|
||||
myTrsf.Multiply(tRot);
|
||||
// Check that the scale is uniform (the same value in all 3 directions.
|
||||
// Only in this case the scaling is applied.
|
||||
const Standard_Real aScaleDiff[2] = {
|
||||
aScale.X()-aScale.Y(),
|
||||
aScale.X()-aScale.Z()
|
||||
};
|
||||
if (aScaleDiff[0]*aScaleDiff[0] + aScaleDiff[1]*aScaleDiff[1]
|
||||
< Precision::Confusion())
|
||||
const Standard_Real aScaleDiff[2] = {aScale.X() - aScale.Y(), aScale.X() - aScale.Z()};
|
||||
if (aScaleDiff[0] * aScaleDiff[0] + aScaleDiff[1] * aScaleDiff[1] < Precision::Confusion())
|
||||
{
|
||||
gp_Trsf tScale;
|
||||
tScale.SetScale (gp::Origin(), (aScale.X()+aScale.Y()+aScale.Z())/3.);
|
||||
myTrsf.Multiply (tScale);
|
||||
tScale.SetScale(gp::Origin(), (aScale.X() + aScale.Y() + aScale.Z()) / 3.);
|
||||
myTrsf.Multiply(tScale);
|
||||
}
|
||||
tCentInv.SetTranslation (aCenter.Reversed());
|
||||
myTrsf.Multiply (tCentInv);
|
||||
tCentInv.SetTranslation(aCenter.Reversed());
|
||||
myTrsf.Multiply(tCentInv);
|
||||
}
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Shape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void VrmlData_Group::Shape (TopoDS_Shape& theShape,
|
||||
VrmlData_DataMapOfShapeAppearance * pMapApp)
|
||||
void VrmlData_Group::Shape(TopoDS_Shape& theShape, VrmlData_DataMapOfShapeAppearance* pMapApp)
|
||||
{
|
||||
VrmlData_Scene::createShape (theShape, myNodes, pMapApp);
|
||||
VrmlData_Scene::createShape(theShape, myNodes, pMapApp);
|
||||
theShape.Location(myTrsf, Standard_False);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : openFile
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Group::openFile
|
||||
(Standard_IStream& theStream,
|
||||
const TCollection_AsciiString& theFilename)
|
||||
VrmlData_ErrorStatus VrmlData_Group::openFile(Standard_IStream& theStream,
|
||||
const TCollection_AsciiString& theFilename)
|
||||
{
|
||||
std::ifstream& aStream = static_cast<std::ifstream&> (theStream);
|
||||
VrmlData_ErrorStatus aStatus (VrmlData_EmptyData);
|
||||
NCollection_List<TCollection_ExtendedString>::Iterator aDirIter =
|
||||
Scene().VrmlDirIterator();
|
||||
for (; aDirIter.More(); aDirIter.Next()) {
|
||||
std::ifstream& aStream = static_cast<std::ifstream&>(theStream);
|
||||
VrmlData_ErrorStatus aStatus(VrmlData_EmptyData);
|
||||
NCollection_List<TCollection_ExtendedString>::Iterator aDirIter = Scene().VrmlDirIterator();
|
||||
for (; aDirIter.More(); aDirIter.Next())
|
||||
{
|
||||
if (!aDirIter.Value().IsAscii())
|
||||
continue;
|
||||
const TCollection_AsciiString aFullName =
|
||||
TCollection_AsciiString (aDirIter.Value()) + theFilename;
|
||||
aStream.open (aFullName.ToCString(), std::ios::in);
|
||||
TCollection_AsciiString(aDirIter.Value()) + theFilename;
|
||||
aStream.open(aFullName.ToCString(), std::ios::in);
|
||||
if (aStream.fail())
|
||||
aStream.clear();
|
||||
else {
|
||||
else
|
||||
{
|
||||
aStatus = VrmlData_StatusOK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (aStatus == VrmlData_EmptyData) {
|
||||
aStream.open (theFilename.ToCString(), std::ios::in);
|
||||
if (aStatus == VrmlData_EmptyData)
|
||||
{
|
||||
aStream.open(theFilename.ToCString(), std::ios::in);
|
||||
if (!aStream.fail())
|
||||
aStatus = VrmlData_StatusOK;
|
||||
}
|
||||
@@ -554,43 +550,41 @@ VrmlData_ErrorStatus VrmlData_Group::openFile
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Group::Write (const char * thePrefix) const
|
||||
VrmlData_ErrorStatus VrmlData_Group::Write(const char* thePrefix) const
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus (VrmlData_StatusOK);
|
||||
if (myNodes.IsEmpty() == Standard_False) {
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
Standard_Boolean isTransform = myIsTransform;
|
||||
VrmlData_ErrorStatus aStatus(VrmlData_StatusOK);
|
||||
if (myNodes.IsEmpty() == Standard_False)
|
||||
{
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
Standard_Boolean isTransform = myIsTransform;
|
||||
if (isTransform && myTrsf.Form() == gp_Identity)
|
||||
isTransform = Standard_False;
|
||||
static const char * header[2] = { "Group {" , "Transform {" };
|
||||
if (OK (aStatus, aScene.WriteLine (thePrefix, header[isTransform ? 1 : 0],
|
||||
GlobalIndent())))
|
||||
static const char* header[2] = {"Group {", "Transform {"};
|
||||
if (OK(aStatus, aScene.WriteLine(thePrefix, header[isTransform ? 1 : 0], GlobalIndent())))
|
||||
{
|
||||
char buf[240];
|
||||
if (OK(aStatus) && aScene.IsDummyWrite() == Standard_False)
|
||||
{
|
||||
const gp_XYZ aBoxCorner[2] = {
|
||||
myBox.CornerMin(),
|
||||
myBox.CornerMax()
|
||||
};
|
||||
const gp_XYZ aBoxCorner[2] = {myBox.CornerMin(), myBox.CornerMax()};
|
||||
// Check that the box is not void
|
||||
if (aBoxCorner[0].X() < aBoxCorner[1].X() + Precision::Confusion()) {
|
||||
Sprintf (buf, "bboxCenter %.9g %.9g %.9g",
|
||||
0.5 * (aBoxCorner[0].X() + aBoxCorner[1].X()),
|
||||
0.5 * (aBoxCorner[0].Y() + aBoxCorner[1].Y()),
|
||||
0.5 * (aBoxCorner[0].Z() + aBoxCorner[1].Z()));
|
||||
aStatus = aScene.WriteLine (buf);
|
||||
if (OK(aStatus)) {
|
||||
Sprintf (buf, "bboxSize %.9g %.9g %.9g",
|
||||
aBoxCorner[1].X() - aBoxCorner[0].X(),
|
||||
aBoxCorner[1].Y() - aBoxCorner[0].Y(),
|
||||
aBoxCorner[1].Z() - aBoxCorner[0].Z());
|
||||
aStatus = aScene.WriteLine (buf);
|
||||
if (aBoxCorner[0].X() < aBoxCorner[1].X() + Precision::Confusion())
|
||||
{
|
||||
Sprintf(buf,
|
||||
"bboxCenter %.9g %.9g %.9g",
|
||||
0.5 * (aBoxCorner[0].X() + aBoxCorner[1].X()),
|
||||
0.5 * (aBoxCorner[0].Y() + aBoxCorner[1].Y()),
|
||||
0.5 * (aBoxCorner[0].Z() + aBoxCorner[1].Z()));
|
||||
aStatus = aScene.WriteLine(buf);
|
||||
if (OK(aStatus))
|
||||
{
|
||||
Sprintf(buf,
|
||||
"bboxSize %.9g %.9g %.9g",
|
||||
aBoxCorner[1].X() - aBoxCorner[0].X(),
|
||||
aBoxCorner[1].Y() - aBoxCorner[0].Y(),
|
||||
aBoxCorner[1].Z() - aBoxCorner[0].Z());
|
||||
aStatus = aScene.WriteLine(buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -598,49 +592,55 @@ VrmlData_ErrorStatus VrmlData_Group::Write (const char * thePrefix) const
|
||||
{
|
||||
// Output the Scale
|
||||
const Standard_Real aScaleFactor = myTrsf.ScaleFactor();
|
||||
if ((aScaleFactor - 1.)*(aScaleFactor - 1.) >
|
||||
0.0001*Precision::Confusion())
|
||||
if ((aScaleFactor - 1.) * (aScaleFactor - 1.) > 0.0001 * Precision::Confusion())
|
||||
{
|
||||
Sprintf (buf, "scale %.12g %.12g %.12g",
|
||||
aScaleFactor, aScaleFactor, aScaleFactor);
|
||||
aStatus = aScene.WriteLine (buf);
|
||||
Sprintf(buf, "scale %.12g %.12g %.12g", aScaleFactor, aScaleFactor, aScaleFactor);
|
||||
aStatus = aScene.WriteLine(buf);
|
||||
}
|
||||
|
||||
// Output the Translation
|
||||
const gp_XYZ& aTrans = myTrsf.TranslationPart();
|
||||
if (aTrans.SquareModulus() > 0.0001*Precision::Confusion()) {
|
||||
Sprintf (buf, "translation %.12g %.12g %.12g",
|
||||
aTrans.X(), aTrans.Y(), aTrans.Z());
|
||||
aStatus = aScene.WriteLine (buf);
|
||||
if (aTrans.SquareModulus() > 0.0001 * Precision::Confusion())
|
||||
{
|
||||
Sprintf(buf, "translation %.12g %.12g %.12g", aTrans.X(), aTrans.Y(), aTrans.Z());
|
||||
aStatus = aScene.WriteLine(buf);
|
||||
}
|
||||
|
||||
// Output the Rotation
|
||||
gp_XYZ anAxis;
|
||||
gp_XYZ anAxis;
|
||||
Standard_Real anAngle;
|
||||
if (myTrsf.GetRotation (anAxis, anAngle)) {
|
||||
if (myTrsf.GetRotation(anAxis, anAngle))
|
||||
{
|
||||
// output the Rotation
|
||||
Sprintf (buf, "rotation %.12g %.12g %.12g %.9g",
|
||||
anAxis.X(), anAxis.Y(), anAxis.Z(), anAngle);
|
||||
aStatus = aScene.WriteLine (buf);
|
||||
Sprintf(buf,
|
||||
"rotation %.12g %.12g %.12g %.9g",
|
||||
anAxis.X(),
|
||||
anAxis.Y(),
|
||||
anAxis.Z(),
|
||||
anAngle);
|
||||
aStatus = aScene.WriteLine(buf);
|
||||
}
|
||||
}
|
||||
|
||||
if (OK(aStatus)) {
|
||||
if (OK(aStatus))
|
||||
{
|
||||
|
||||
aStatus = aScene.WriteLine ("children [", 0L, GlobalIndent());
|
||||
aStatus = aScene.WriteLine("children [", 0L, GlobalIndent());
|
||||
|
||||
VrmlData_ListOfNode::Iterator anIterChild (myNodes);
|
||||
for (; anIterChild.More() && OK(aStatus); anIterChild.Next()) {
|
||||
VrmlData_ListOfNode::Iterator anIterChild(myNodes);
|
||||
for (; anIterChild.More() && OK(aStatus); anIterChild.Next())
|
||||
{
|
||||
const Handle(VrmlData_Node)& aNode = anIterChild.Value();
|
||||
aScene.WriteNode (0L, aNode);
|
||||
aScene.WriteNode(0L, aNode);
|
||||
}
|
||||
|
||||
if (OK(aStatus)) {
|
||||
aStatus = aScene.WriteLine ("]", 0L, -GlobalIndent());
|
||||
if (OK(aStatus))
|
||||
{
|
||||
aStatus = aScene.WriteLine("]", 0L, -GlobalIndent());
|
||||
}
|
||||
}
|
||||
aStatus = WriteClosing();
|
||||
}
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,7 @@ class TopoDS_Shape;
|
||||
|
||||
class VrmlData_Group : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
typedef VrmlData_ListOfNode::Iterator Iterator;
|
||||
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
@@ -41,9 +41,10 @@ class VrmlData_Group : public VrmlData_Node
|
||||
* @param theAlloc
|
||||
* Allocator used for the list of children
|
||||
*/
|
||||
VrmlData_Group (const Standard_Boolean isTransform = Standard_False)
|
||||
: myIsTransform (isTransform)
|
||||
{}
|
||||
VrmlData_Group(const Standard_Boolean isTransform = Standard_False)
|
||||
: myIsTransform(isTransform)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@@ -54,82 +55,74 @@ class VrmlData_Group : public VrmlData_Node
|
||||
* @param theAlloc
|
||||
* Allocator used for the list of children
|
||||
*/
|
||||
Standard_EXPORT VrmlData_Group
|
||||
(const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Boolean isTransform = Standard_False);
|
||||
Standard_EXPORT VrmlData_Group(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Boolean isTransform = Standard_False);
|
||||
|
||||
/**
|
||||
* Add one node to the Group.
|
||||
*/
|
||||
inline Handle(VrmlData_Node)&
|
||||
AddNode (const Handle(VrmlData_Node)& theNode)
|
||||
{ return myNodes.Append(theNode); }
|
||||
inline Handle(VrmlData_Node)& AddNode(const Handle(VrmlData_Node)& theNode)
|
||||
{
|
||||
return myNodes.Append(theNode);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove one node from the Group.
|
||||
* @return
|
||||
* True if the node was located and removed, False if none removed.
|
||||
*/
|
||||
Standard_EXPORT Standard_Boolean
|
||||
RemoveNode (const Handle(VrmlData_Node)& theNode);
|
||||
Standard_EXPORT Standard_Boolean RemoveNode(const Handle(VrmlData_Node)& theNode);
|
||||
|
||||
/**
|
||||
* Create iterator on nodes belonging to the Group.
|
||||
*/
|
||||
inline Iterator
|
||||
NodeIterator () const { return Iterator (myNodes); }
|
||||
inline Iterator NodeIterator() const { return Iterator(myNodes); }
|
||||
|
||||
/**
|
||||
* Query the bounding box.
|
||||
*/
|
||||
inline const Bnd_B3f&
|
||||
Box () const { return myBox; }
|
||||
inline const Bnd_B3f& Box() const { return myBox; }
|
||||
|
||||
/**
|
||||
* Set the bounding box.
|
||||
*/
|
||||
inline void SetBox (const Bnd_B3f& theBox) { myBox = theBox; }
|
||||
inline void SetBox(const Bnd_B3f& theBox) { myBox = theBox; }
|
||||
|
||||
/**
|
||||
* Set the transformation. Returns True if the group is Transform type,
|
||||
* otherwise do nothing and return False.
|
||||
*/
|
||||
Standard_EXPORT Standard_Boolean
|
||||
SetTransform (const gp_Trsf& theTrsf);
|
||||
Standard_EXPORT Standard_Boolean SetTransform(const gp_Trsf& theTrsf);
|
||||
|
||||
/**
|
||||
* Query the transform value.
|
||||
* For group without transformation this always returns Identity
|
||||
*/
|
||||
inline const gp_Trsf&
|
||||
GetTransform () const { return myTrsf; }
|
||||
*/
|
||||
inline const gp_Trsf& GetTransform() const { return myTrsf; }
|
||||
|
||||
/**
|
||||
* Query if the node is Transform type.
|
||||
*/
|
||||
inline Standard_Boolean
|
||||
IsTransform () const { return myIsTransform; }
|
||||
inline Standard_Boolean IsTransform() const { return myIsTransform; }
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Fill the Node internal data from the given input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Find a node by its name, inside this Group
|
||||
@@ -138,43 +131,37 @@ class VrmlData_Group : public VrmlData_Node
|
||||
* @param theLocation
|
||||
* Location of the found node with respect to this Group.
|
||||
*/
|
||||
Standard_EXPORT Handle(VrmlData_Node)
|
||||
FindNode (const char * theName,
|
||||
gp_Trsf& theLocation) const;
|
||||
Standard_EXPORT Handle(VrmlData_Node) FindNode(const char* theName, gp_Trsf& theLocation) const;
|
||||
|
||||
/**
|
||||
* Get the shape representing the group geometry.
|
||||
*/
|
||||
Standard_EXPORT void
|
||||
Shape (TopoDS_Shape& theShape,
|
||||
VrmlData_DataMapOfShapeAppearance * pMapApp);
|
||||
Standard_EXPORT void Shape(TopoDS_Shape& theShape, VrmlData_DataMapOfShapeAppearance* pMapApp);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
/**
|
||||
* Try to open a file by the given filename, using the search directories
|
||||
* list myVrmlDir of the Scene.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
openFile (Standard_IStream& theStream,
|
||||
const TCollection_AsciiString& theFilename);
|
||||
Standard_EXPORT VrmlData_ErrorStatus openFile(Standard_IStream& theStream,
|
||||
const TCollection_AsciiString& theFilename);
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
Standard_Boolean myIsTransform;
|
||||
VrmlData_ListOfNode myNodes;
|
||||
Bnd_B3f myBox;
|
||||
gp_Trsf myTrsf;
|
||||
Standard_Boolean myIsTransform;
|
||||
VrmlData_ListOfNode myNodes;
|
||||
Bnd_B3f myBox;
|
||||
gp_Trsf myTrsf;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_Group,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_Group, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Group, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Group, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -23,69 +23,60 @@
|
||||
*/
|
||||
class VrmlData_ImageTexture : public VrmlData_Texture
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_ImageTexture ()
|
||||
{}
|
||||
inline VrmlData_ImageTexture() {}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ImageTexture
|
||||
(const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const char * theURL = 0L,
|
||||
const Standard_Boolean theRepS = Standard_False,
|
||||
const Standard_Boolean theRepT = Standard_False);
|
||||
Standard_EXPORT VrmlData_ImageTexture(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const char* theURL = 0L,
|
||||
const Standard_Boolean theRepS = Standard_False,
|
||||
const Standard_Boolean theRepT = Standard_False);
|
||||
|
||||
/**
|
||||
* Query the associated URL.
|
||||
*/
|
||||
inline const NCollection_List<TCollection_AsciiString>&
|
||||
URL () const
|
||||
{ return myURL; }
|
||||
inline const NCollection_List<TCollection_AsciiString>& URL() const { return myURL; }
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
NCollection_List<TCollection_AsciiString> myURL;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_ImageTexture,VrmlData_Texture)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_ImageTexture, VrmlData_Texture)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_ImageTexture, VrmlData_Texture)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_ImageTexture, VrmlData_Texture)
|
||||
|
||||
#endif
|
||||
|
@@ -17,22 +17,25 @@
|
||||
#define VrmlData_InBuffer_HeaderFile
|
||||
|
||||
#include <Standard_IStream.hxx>
|
||||
|
||||
/**
|
||||
* Structure passed to the methods dealing with input stream.
|
||||
*/
|
||||
struct VrmlData_InBuffer {
|
||||
struct VrmlData_InBuffer
|
||||
{
|
||||
Standard_IStream& Input;
|
||||
char Line[8096];
|
||||
char * LinePtr;
|
||||
char* LinePtr;
|
||||
Standard_Boolean IsProcessed;
|
||||
Standard_Integer LineCount;
|
||||
VrmlData_InBuffer (Standard_IStream& theStream)
|
||||
: Input (theStream),
|
||||
LinePtr (&Line[0]),
|
||||
IsProcessed (Standard_False),
|
||||
LineCount (0) {};
|
||||
private:
|
||||
void operator= (const VrmlData_InBuffer&);
|
||||
VrmlData_InBuffer(Standard_IStream& theStream)
|
||||
: Input(theStream),
|
||||
LinePtr(&Line[0]),
|
||||
IsProcessed(Standard_False),
|
||||
LineCount(0) {};
|
||||
|
||||
private:
|
||||
void operator=(const VrmlData_InBuffer&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -31,39 +31,40 @@
|
||||
#include <TColgp_SequenceOfXYZ.hxx>
|
||||
#include <TColStd_SequenceOfInteger.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_IndexedFaceSet,VrmlData_Faceted)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_IndexedFaceSet, VrmlData_Faceted)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning (disable:4996)
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : readData
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Faceted::readData (VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_Faceted::readData(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus (VrmlData_EmptyData);
|
||||
Standard_Boolean aBool;
|
||||
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "ccw")) {
|
||||
if (OK(aStatus, ReadBoolean (theBuffer, aBool)))
|
||||
VrmlData_ErrorStatus aStatus(VrmlData_EmptyData);
|
||||
Standard_Boolean aBool;
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "ccw"))
|
||||
{
|
||||
if (OK(aStatus, ReadBoolean(theBuffer, aBool)))
|
||||
myIsCCW = aBool;
|
||||
} else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "convex")) {
|
||||
if (OK(aStatus, ReadBoolean (theBuffer, aBool)))
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "convex"))
|
||||
{
|
||||
if (OK(aStatus, ReadBoolean(theBuffer, aBool)))
|
||||
myIsConvex = aBool;
|
||||
} else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "solid")) {
|
||||
if (OK(aStatus, ReadBoolean (theBuffer, aBool)))
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "solid"))
|
||||
{
|
||||
if (OK(aStatus, ReadBoolean(theBuffer, aBool)))
|
||||
myIsSolid = aBool;
|
||||
} else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "creaseAngle")) {
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "creaseAngle"))
|
||||
{
|
||||
Standard_Real anAngle;
|
||||
if (OK(aStatus, Scene().ReadReal (theBuffer, anAngle,
|
||||
Standard_False, Standard_False))) {
|
||||
if (anAngle < -Precision::Confusion()*0.001)
|
||||
if (OK(aStatus, Scene().ReadReal(theBuffer, anAngle, Standard_False, Standard_False)))
|
||||
{
|
||||
if (anAngle < -Precision::Confusion() * 0.001)
|
||||
aStatus = VrmlData_IrrelevantNumber;
|
||||
else
|
||||
myCreaseAngle = anAngle;
|
||||
@@ -72,42 +73,40 @@ VrmlData_ErrorStatus VrmlData_Faceted::readData (VrmlData_InBuffer& theBuffer)
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_IndexedFaceSet::TShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
|
||||
const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape()
|
||||
{
|
||||
if (myNbPolygons == 0)
|
||||
{
|
||||
myTShape.Nullify();
|
||||
return myTShape;
|
||||
}
|
||||
else if (!myIsModified) {
|
||||
else if (!myIsModified)
|
||||
{
|
||||
return myTShape;
|
||||
}
|
||||
|
||||
// list of nodes:
|
||||
const gp_XYZ * arrNodes = myCoords->Values();
|
||||
const int nNodes = (int)myCoords->Length();
|
||||
const gp_XYZ* arrNodes = myCoords->Values();
|
||||
const int nNodes = (int)myCoords->Length();
|
||||
|
||||
NCollection_Map <int> mapNodeId;
|
||||
NCollection_Map <int> mapPolyId;
|
||||
NCollection_Map<int> mapNodeId;
|
||||
NCollection_Map<int> mapPolyId;
|
||||
NCollection_List<TColStd_SequenceOfInteger> aPolygons;
|
||||
NCollection_List<gp_Dir> aNorms;
|
||||
Standard_Integer i = 0;
|
||||
NCollection_List<gp_Dir> aNorms;
|
||||
Standard_Integer i = 0;
|
||||
for (; i < (int)myNbPolygons; i++)
|
||||
{
|
||||
const Standard_Integer * arrIndice = myArrPolygons[i];
|
||||
Standard_Integer nn = arrIndice[0];
|
||||
const Standard_Integer* arrIndice = myArrPolygons[i];
|
||||
Standard_Integer nn = arrIndice[0];
|
||||
if (nn < 3)
|
||||
{
|
||||
// bad polygon
|
||||
continue;
|
||||
}
|
||||
TColStd_SequenceOfInteger aPolygon;
|
||||
int in = 1;
|
||||
int in = 1;
|
||||
for (; in <= nn; in++)
|
||||
{
|
||||
if (arrIndice[in] > nNodes)
|
||||
@@ -130,7 +129,7 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
|
||||
gp_XYZ aP2 = arrNodes[aPolygon(in + 1)];
|
||||
gp_XYZ aV1 = aP1 - aPrevP;
|
||||
gp_XYZ aV2 = aP2 - aPrevP;
|
||||
gp_XYZ S = aV1.Crossed(aV2);
|
||||
gp_XYZ S = aV1.Crossed(aV2);
|
||||
aSum += S;
|
||||
}
|
||||
if (aSum.Modulus() < Precision::Confusion())
|
||||
@@ -157,11 +156,11 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
|
||||
return myTShape;
|
||||
}
|
||||
// prepare vector of nodes
|
||||
NCollection_Vector<gp_XYZ> aNodes;
|
||||
NCollection_DataMap <int, int> mapIdId;
|
||||
NCollection_Vector<gp_XYZ> aNodes;
|
||||
NCollection_DataMap<int, int> mapIdId;
|
||||
for (i = 0; i < nNodes; i++)
|
||||
{
|
||||
if(mapNodeId.Contains(i))
|
||||
if (mapNodeId.Contains(i))
|
||||
{
|
||||
const gp_XYZ& aN1 = arrNodes[i];
|
||||
mapIdId.Bind(i, aNodes.Length());
|
||||
@@ -175,7 +174,7 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
|
||||
TColStd_SequenceOfInteger& aPolygon = itP.ChangeValue();
|
||||
for (int in = 1; in <= aPolygon.Length(); in++)
|
||||
{
|
||||
Standard_Integer newIdx = mapIdId.Find(aPolygon.Value(in));
|
||||
Standard_Integer newIdx = mapIdId.Find(aPolygon.Value(in));
|
||||
aPolygon.ChangeValue(in) = newIdx;
|
||||
}
|
||||
}
|
||||
@@ -209,13 +208,13 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
|
||||
// Copy the triangulation vertices
|
||||
for (i = 0; i < aNodes.Length(); i++)
|
||||
{
|
||||
aTriangulation->SetNode (i + 1, gp_Pnt (aNodes (i)));
|
||||
aTriangulation->SetNode(i + 1, gp_Pnt(aNodes(i)));
|
||||
}
|
||||
// Copy the triangles.
|
||||
NCollection_List<Poly_Triangle>::Iterator itT(aTriangles);
|
||||
for (i = 1; itT.More(); itT.Next(), i++)
|
||||
{
|
||||
aTriangulation->SetTriangle (i, itT.Value());
|
||||
aTriangulation->SetTriangle(i, itT.Value());
|
||||
}
|
||||
|
||||
Handle(BRep_TFace) aFace = new BRep_TFace();
|
||||
@@ -223,7 +222,8 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
|
||||
myTShape = aFace;
|
||||
|
||||
// Normals should be defined; if they are not, compute them
|
||||
if (myNormals.IsNull()) {
|
||||
if (myNormals.IsNull())
|
||||
{
|
||||
Poly::ComputeNormals(aTriangulation);
|
||||
}
|
||||
else
|
||||
@@ -236,31 +236,32 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
|
||||
{
|
||||
for (i = 0; i < nbNodes; i++)
|
||||
{
|
||||
const gp_XYZ& aNormal = myNormals->Normal (i);
|
||||
aTriangulation->SetNormal (i + 1, aNormal);
|
||||
const gp_XYZ& aNormal = myNormals->Normal(i);
|
||||
aTriangulation->SetNormal(i + 1, aNormal);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < (int)myNbPolygons; i++)
|
||||
{
|
||||
if(mapPolyId.Contains(i)) // check to avoid previously skipped faces
|
||||
if (mapPolyId.Contains(i)) // check to avoid previously skipped faces
|
||||
{
|
||||
const Standard_Integer * anArrNodes;
|
||||
const Standard_Integer* anArrNodes;
|
||||
Polygon(i, anArrNodes);
|
||||
const Standard_Integer * arrIndice;
|
||||
int nbn = IndiceNormals(i, arrIndice);
|
||||
const Standard_Integer* arrIndice;
|
||||
int nbn = IndiceNormals(i, arrIndice);
|
||||
for (Standard_Integer j = 0; j < nbn; j++)
|
||||
{
|
||||
const gp_XYZ& aNormal = myNormals->Normal(arrIndice[j]);
|
||||
aTriangulation->SetNormal (mapIdId (anArrNodes[j]) + 1, aNormal);
|
||||
aTriangulation->SetNormal(mapIdId(anArrNodes[j]) + 1, aNormal);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
//TODO ..
|
||||
else
|
||||
{
|
||||
// TODO ..
|
||||
}
|
||||
}
|
||||
|
||||
@@ -269,129 +270,116 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedFaceSet::TShape ()
|
||||
return myTShape;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_IndexedFaceSet::Clone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_IndexedFaceSet::Clone
|
||||
(const Handle(VrmlData_Node)& theOther) const
|
||||
Handle(VrmlData_Node) VrmlData_IndexedFaceSet::Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
{
|
||||
Handle(VrmlData_IndexedFaceSet) aResult =
|
||||
Handle(VrmlData_IndexedFaceSet)::DownCast (VrmlData_Node::Clone(theOther));
|
||||
Handle(VrmlData_IndexedFaceSet)::DownCast(VrmlData_Node::Clone(theOther));
|
||||
if (aResult.IsNull())
|
||||
aResult =
|
||||
new VrmlData_IndexedFaceSet(theOther.IsNull()? Scene(): theOther->Scene(),
|
||||
Name());
|
||||
aResult = new VrmlData_IndexedFaceSet(theOther.IsNull() ? Scene() : theOther->Scene(), Name());
|
||||
|
||||
if (&aResult->Scene() == &Scene()) {
|
||||
aResult->SetCoordinates (myCoords);
|
||||
aResult->SetNormals (myNormals);
|
||||
aResult->SetColors (myColors);
|
||||
aResult->SetPolygons (myNbPolygons, myArrPolygons);
|
||||
aResult->SetNormalInd (myNbNormals, myArrNormalInd);
|
||||
aResult->SetColorInd (myNbColors, myArrColorInd);
|
||||
aResult->SetTextureCoordInd (myNbTextures, myArrTextureInd);
|
||||
} else {
|
||||
// Create a dummy node to pass the different Scene instance to methods Clone
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode =
|
||||
new VrmlData_UnknownNode (aResult->Scene());
|
||||
if (myCoords.IsNull() == Standard_False)
|
||||
aResult->SetCoordinates (Handle(VrmlData_Coordinate)::DownCast
|
||||
(myCoords->Clone (aDummyNode)));
|
||||
if (myNormals.IsNull() == Standard_False)
|
||||
aResult->SetNormals (Handle(VrmlData_Normal)::DownCast
|
||||
(myNormals->Clone (aDummyNode)));
|
||||
if (myColors.IsNull() == Standard_False)
|
||||
aResult->SetColors (Handle(VrmlData_Color)::DownCast
|
||||
(myColors->Clone (aDummyNode)));
|
||||
//TODO: Replace the following lines with the relevant copying
|
||||
aResult->SetPolygons (myNbPolygons, myArrPolygons);
|
||||
aResult->SetNormalInd (myNbNormals, myArrNormalInd);
|
||||
aResult->SetColorInd (myNbColors, myArrColorInd);
|
||||
aResult->SetTextureCoordInd (myNbTextures, myArrTextureInd);
|
||||
if (&aResult->Scene() == &Scene())
|
||||
{
|
||||
aResult->SetCoordinates(myCoords);
|
||||
aResult->SetNormals(myNormals);
|
||||
aResult->SetColors(myColors);
|
||||
aResult->SetPolygons(myNbPolygons, myArrPolygons);
|
||||
aResult->SetNormalInd(myNbNormals, myArrNormalInd);
|
||||
aResult->SetColorInd(myNbColors, myArrColorInd);
|
||||
aResult->SetTextureCoordInd(myNbTextures, myArrTextureInd);
|
||||
}
|
||||
aResult->SetNormalPerVertex (myNormalPerVertex);
|
||||
aResult->SetColorPerVertex (myColorPerVertex);
|
||||
else
|
||||
{
|
||||
// Create a dummy node to pass the different Scene instance to methods Clone
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode = new VrmlData_UnknownNode(aResult->Scene());
|
||||
if (myCoords.IsNull() == Standard_False)
|
||||
aResult->SetCoordinates(Handle(VrmlData_Coordinate)::DownCast(myCoords->Clone(aDummyNode)));
|
||||
if (myNormals.IsNull() == Standard_False)
|
||||
aResult->SetNormals(Handle(VrmlData_Normal)::DownCast(myNormals->Clone(aDummyNode)));
|
||||
if (myColors.IsNull() == Standard_False)
|
||||
aResult->SetColors(Handle(VrmlData_Color)::DownCast(myColors->Clone(aDummyNode)));
|
||||
// TODO: Replace the following lines with the relevant copying
|
||||
aResult->SetPolygons(myNbPolygons, myArrPolygons);
|
||||
aResult->SetNormalInd(myNbNormals, myArrNormalInd);
|
||||
aResult->SetColorInd(myNbColors, myArrColorInd);
|
||||
aResult->SetTextureCoordInd(myNbTextures, myArrTextureInd);
|
||||
}
|
||||
aResult->SetNormalPerVertex(myNormalPerVertex);
|
||||
aResult->SetColorPerVertex(myColorPerVertex);
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_IndexedFaceSet::Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Read(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (OK(aStatus, VrmlData_Faceted::readData (theBuffer)))
|
||||
if (OK(aStatus, VrmlData_Faceted::readData(theBuffer)))
|
||||
continue;
|
||||
if (aStatus != VrmlData_EmptyData)
|
||||
break;
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "colorPerVertex"))
|
||||
aStatus = ReadBoolean (theBuffer, myColorPerVertex);
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "normalPerVertex"))
|
||||
aStatus = ReadBoolean (theBuffer, myNormalPerVertex);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "colorPerVertex"))
|
||||
aStatus = ReadBoolean(theBuffer, myColorPerVertex);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "normalPerVertex"))
|
||||
aStatus = ReadBoolean(theBuffer, myNormalPerVertex);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "coordIndex"))
|
||||
{
|
||||
aStatus = aScene.ReadArrIndex(theBuffer, myArrPolygons, myNbPolygons);
|
||||
//for (int i = 0; i < myNbPolygons; i++)
|
||||
// for (int i = 0; i < myNbPolygons; i++)
|
||||
//{
|
||||
// const Standard_Integer * anArray = myArrPolygons[i];
|
||||
// Standard_Integer nbPoints = anArray[0];
|
||||
// std::cout << "i = " << i << " indexes:";
|
||||
// for (int ip = 1; ip <= nbPoints; ip++)
|
||||
// {
|
||||
// std::cout << " " << anArray[ip];
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
//}
|
||||
// const Standard_Integer * anArray = myArrPolygons[i];
|
||||
// Standard_Integer nbPoints = anArray[0];
|
||||
// std::cout << "i = " << i << " indexes:";
|
||||
// for (int ip = 1; ip <= nbPoints; ip++)
|
||||
// {
|
||||
// std::cout << " " << anArray[ip];
|
||||
// }
|
||||
// std::cout << std::endl;
|
||||
// }
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "colorIndex"))
|
||||
aStatus = aScene.ReadArrIndex (theBuffer, myArrColorInd, myNbColors);
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "normalIndex"))
|
||||
aStatus = aScene.ReadArrIndex (theBuffer, myArrNormalInd, myNbNormals);
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "texCoordIndex"))
|
||||
aStatus = aScene.ReadArrIndex (theBuffer, myArrTextureInd, myNbTextures);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "colorIndex"))
|
||||
aStatus = aScene.ReadArrIndex(theBuffer, myArrColorInd, myNbColors);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "normalIndex"))
|
||||
aStatus = aScene.ReadArrIndex(theBuffer, myArrNormalInd, myNbNormals);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "texCoordIndex"))
|
||||
aStatus = aScene.ReadArrIndex(theBuffer, myArrTextureInd, myNbTextures);
|
||||
// These four checks should be the last one to avoid their interference
|
||||
// with the other tokens (e.g., coordIndex)
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "texCoord"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "texCoord"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode,
|
||||
STANDARD_TYPE(VrmlData_TextureCoordinate));
|
||||
myTxCoords = Handle(VrmlData_TextureCoordinate)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode, STANDARD_TYPE(VrmlData_TextureCoordinate));
|
||||
myTxCoords = Handle(VrmlData_TextureCoordinate)::DownCast(aNode);
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "color"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "color"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode,
|
||||
STANDARD_TYPE(VrmlData_Color));
|
||||
myColors = Handle(VrmlData_Color)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode, STANDARD_TYPE(VrmlData_Color));
|
||||
myColors = Handle(VrmlData_Color)::DownCast(aNode);
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "coord"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "coord"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode,
|
||||
STANDARD_TYPE(VrmlData_Coordinate));
|
||||
myCoords = Handle(VrmlData_Coordinate)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode, STANDARD_TYPE(VrmlData_Coordinate));
|
||||
myCoords = Handle(VrmlData_Coordinate)::DownCast(aNode);
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "normal"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "normal"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode,
|
||||
STANDARD_TYPE(VrmlData_Normal));
|
||||
myNormals = Handle(VrmlData_Normal)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode, STANDARD_TYPE(VrmlData_Normal));
|
||||
myNormals = Handle(VrmlData_Normal)::DownCast(aNode);
|
||||
}
|
||||
if (!OK(aStatus))
|
||||
break;
|
||||
}
|
||||
// Read the terminating (closing) brace
|
||||
if (OK(aStatus) || aStatus == VrmlData_EmptyData)
|
||||
if (OK(aStatus, readBrace (theBuffer))) {
|
||||
if (OK(aStatus, readBrace(theBuffer)))
|
||||
{
|
||||
// Post-processing
|
||||
;
|
||||
}
|
||||
@@ -429,14 +417,11 @@ VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Read(VrmlData_InBuffer& theBuffer)
|
||||
// return aStatus;
|
||||
// }
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDefault
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean VrmlData_IndexedFaceSet::IsDefault () const
|
||||
Standard_Boolean VrmlData_IndexedFaceSet::IsDefault() const
|
||||
{
|
||||
Standard_Boolean aResult (Standard_True);
|
||||
Standard_Boolean aResult(Standard_True);
|
||||
if (myNbPolygons)
|
||||
aResult = Standard_False;
|
||||
else if (myCoords.IsNull() == Standard_False)
|
||||
@@ -444,72 +429,64 @@ Standard_Boolean VrmlData_IndexedFaceSet::IsDefault () const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Write
|
||||
(const char * thePrefix) const
|
||||
VrmlData_ErrorStatus VrmlData_IndexedFaceSet::Write(const char* thePrefix) const
|
||||
{
|
||||
static char header[] = "IndexedFaceSet {";
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
if (OK (aStatus, aScene.WriteLine (thePrefix, header, GlobalIndent()))) {
|
||||
static char header[] = "IndexedFaceSet {";
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
if (OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent())))
|
||||
{
|
||||
|
||||
// Write the attributes of interface "VrmlData_Faceted"
|
||||
if (IsCCW() == Standard_False)
|
||||
aStatus = aScene.WriteLine ("ccw FALSE");
|
||||
aStatus = aScene.WriteLine("ccw FALSE");
|
||||
if (OK(aStatus) && IsSolid() == Standard_False)
|
||||
aStatus = aScene.WriteLine ("solid FALSE");
|
||||
aStatus = aScene.WriteLine("solid FALSE");
|
||||
if (OK(aStatus) && IsConvex() == Standard_False)
|
||||
aStatus = aScene.WriteLine ("convex FALSE");
|
||||
if (OK(aStatus) && CreaseAngle() > Precision::Confusion()) {
|
||||
aStatus = aScene.WriteLine("convex FALSE");
|
||||
if (OK(aStatus) && CreaseAngle() > Precision::Confusion())
|
||||
{
|
||||
char buf[64];
|
||||
Sprintf (buf, "%.9g", CreaseAngle());
|
||||
aStatus = aScene.WriteLine ("creaseAngle", buf);
|
||||
Sprintf(buf, "%.9g", CreaseAngle());
|
||||
aStatus = aScene.WriteLine("creaseAngle", buf);
|
||||
}
|
||||
|
||||
if (OK(aStatus) && myCoords.IsNull() == Standard_False)
|
||||
aStatus = aScene.WriteNode ("coord", myCoords);
|
||||
aStatus = aScene.WriteNode("coord", myCoords);
|
||||
if (OK(aStatus))
|
||||
aStatus = aScene.WriteArrIndex ("coordIndex", myArrPolygons,myNbPolygons);
|
||||
aStatus = aScene.WriteArrIndex("coordIndex", myArrPolygons, myNbPolygons);
|
||||
|
||||
if (OK(aStatus) && myNormalPerVertex == Standard_False)
|
||||
aStatus = aScene.WriteLine ("normalPerVertex FALSE");
|
||||
aStatus = aScene.WriteLine("normalPerVertex FALSE");
|
||||
if (OK(aStatus) && myNormals.IsNull() == Standard_False)
|
||||
aStatus = aScene.WriteNode ("normal", myNormals);
|
||||
aStatus = aScene.WriteNode("normal", myNormals);
|
||||
if (OK(aStatus))
|
||||
aStatus = aScene.WriteArrIndex ("normalIndex",myArrNormalInd,myNbNormals);
|
||||
aStatus = aScene.WriteArrIndex("normalIndex", myArrNormalInd, myNbNormals);
|
||||
|
||||
if (OK(aStatus) && myColorPerVertex == Standard_False)
|
||||
aStatus = aScene.WriteLine ("colorPerVertex FALSE");
|
||||
aStatus = aScene.WriteLine("colorPerVertex FALSE");
|
||||
if (OK(aStatus) && myColors.IsNull() == Standard_False)
|
||||
aStatus = aScene.WriteNode ("color", myColors);
|
||||
aStatus = aScene.WriteNode("color", myColors);
|
||||
if (OK(aStatus))
|
||||
aStatus = aScene.WriteArrIndex ("colorIndex", myArrColorInd, myNbColors);
|
||||
aStatus = aScene.WriteArrIndex("colorIndex", myArrColorInd, myNbColors);
|
||||
|
||||
if (OK(aStatus) && myTxCoords.IsNull() == Standard_False)
|
||||
aStatus = aScene.WriteNode ("texCoord", myTxCoords);
|
||||
aStatus = aScene.WriteNode("texCoord", myTxCoords);
|
||||
if (OK(aStatus))
|
||||
aStatus = aScene.WriteArrIndex ("texCoordIndex", myArrTextureInd,
|
||||
myNbTextures);
|
||||
aStatus = aScene.WriteArrIndex("texCoordIndex", myArrTextureInd, myNbTextures);
|
||||
|
||||
aStatus = WriteClosing();
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Quantity_Color VrmlData_IndexedFaceSet::GetColor
|
||||
(const Standard_Integer /*iFace*/,
|
||||
const Standard_Integer /*iVertex*/)
|
||||
Quantity_Color VrmlData_IndexedFaceSet::GetColor(const Standard_Integer /*iFace*/,
|
||||
const Standard_Integer /*iVertex*/)
|
||||
{
|
||||
//TODO
|
||||
// TODO
|
||||
return Quantity_NOC_BLACK;
|
||||
}
|
||||
|
||||
|
@@ -27,81 +27,81 @@
|
||||
/**
|
||||
* Implementation of IndexedFaceSet node
|
||||
*/
|
||||
class VrmlData_IndexedFaceSet : public VrmlData_Faceted
|
||||
class VrmlData_IndexedFaceSet : public VrmlData_Faceted
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_IndexedFaceSet ()
|
||||
: myArrPolygons (0L),
|
||||
myArrNormalInd (0L),
|
||||
myArrColorInd (0L),
|
||||
myArrTextureInd (0L),
|
||||
myNbPolygons (0),
|
||||
myNbNormals (0),
|
||||
myNbColors (0),
|
||||
myNbTextures (0),
|
||||
myNormalPerVertex (Standard_True),
|
||||
myColorPerVertex (Standard_True)
|
||||
{}
|
||||
inline VrmlData_IndexedFaceSet()
|
||||
: myArrPolygons(0L),
|
||||
myArrNormalInd(0L),
|
||||
myArrColorInd(0L),
|
||||
myArrTextureInd(0L),
|
||||
myNbPolygons(0),
|
||||
myNbNormals(0),
|
||||
myNbColors(0),
|
||||
myNbTextures(0),
|
||||
myNormalPerVertex(Standard_True),
|
||||
myColorPerVertex(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_IndexedFaceSet (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Boolean isCCW =Standard_True,
|
||||
const Standard_Boolean isSolid =Standard_True,
|
||||
const Standard_Boolean isConvex=Standard_True,
|
||||
const Standard_Real theCreaseAngle = 0.)
|
||||
: VrmlData_Faceted (theScene, theName, isCCW, isSolid, isConvex,
|
||||
theCreaseAngle),
|
||||
myArrPolygons (0L),
|
||||
myArrNormalInd (0L),
|
||||
myArrColorInd (0L),
|
||||
myArrTextureInd (0L),
|
||||
myNbPolygons (0),
|
||||
myNbNormals (0),
|
||||
myNbColors (0),
|
||||
myNbTextures (0),
|
||||
myNormalPerVertex (Standard_True),
|
||||
myColorPerVertex (Standard_True)
|
||||
{}
|
||||
inline VrmlData_IndexedFaceSet(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Boolean isCCW = Standard_True,
|
||||
const Standard_Boolean isSolid = Standard_True,
|
||||
const Standard_Boolean isConvex = Standard_True,
|
||||
const Standard_Real theCreaseAngle = 0.)
|
||||
: VrmlData_Faceted(theScene, theName, isCCW, isSolid, isConvex, theCreaseAngle),
|
||||
myArrPolygons(0L),
|
||||
myArrNormalInd(0L),
|
||||
myArrColorInd(0L),
|
||||
myArrTextureInd(0L),
|
||||
myNbPolygons(0),
|
||||
myNbNormals(0),
|
||||
myNbColors(0),
|
||||
myNbTextures(0),
|
||||
myNormalPerVertex(Standard_True),
|
||||
myColorPerVertex(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Normals.
|
||||
*/
|
||||
inline const Handle(VrmlData_Normal)&
|
||||
Normals () const { return myNormals; }
|
||||
inline const Handle(VrmlData_Normal)& Normals() const { return myNormals; }
|
||||
|
||||
/**
|
||||
* Query the Colors.
|
||||
*/
|
||||
inline const Handle(VrmlData_Color)&
|
||||
Colors () const { return myColors; }
|
||||
inline const Handle(VrmlData_Color)& Colors() const { return myColors; }
|
||||
|
||||
/**
|
||||
* Query the Texture Coordinates.
|
||||
*/
|
||||
inline const Handle(VrmlData_TextureCoordinate)&
|
||||
TextureCoords () const { return myTxCoords; }
|
||||
inline const Handle(VrmlData_TextureCoordinate)& TextureCoords() const { return myTxCoords; }
|
||||
|
||||
// ========================================================================
|
||||
// =========================== TRIANGULATION GRID =========================
|
||||
/**
|
||||
* Query the Coordinates.
|
||||
*/
|
||||
inline const Handle(VrmlData_Coordinate)&
|
||||
Coordinates () const { return myCoords; }
|
||||
inline const Handle(VrmlData_Coordinate)& Coordinates() const { return myCoords; }
|
||||
|
||||
/**
|
||||
* Query the array of polygons
|
||||
*/
|
||||
inline size_t Polygons (const Standard_Integer**& arrPolygons) const
|
||||
{ arrPolygons = myArrPolygons; return myNbPolygons; }
|
||||
inline size_t Polygons(const Standard_Integer**& arrPolygons) const
|
||||
{
|
||||
arrPolygons = myArrPolygons;
|
||||
return myNbPolygons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query one polygon.
|
||||
@@ -112,23 +112,24 @@ class VrmlData_IndexedFaceSet : public VrmlData_Faceted
|
||||
* @return
|
||||
* number of vertice in the polygon - the dimension of outIndice array
|
||||
*/
|
||||
inline Standard_Integer
|
||||
Polygon (const Standard_Integer iFace,
|
||||
const Standard_Integer *& outIndice)
|
||||
{ return * (outIndice = myArrPolygons[iFace])++; }
|
||||
inline Standard_Integer Polygon(const Standard_Integer iFace, const Standard_Integer*& outIndice)
|
||||
{
|
||||
return *(outIndice = myArrPolygons[iFace])++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the nodes
|
||||
*/
|
||||
inline void SetCoordinates (const Handle(VrmlData_Coordinate)& theCoord)
|
||||
{ myCoords = theCoord; }
|
||||
inline void SetCoordinates(const Handle(VrmlData_Coordinate)& theCoord) { myCoords = theCoord; }
|
||||
|
||||
/**
|
||||
* Set the polygons
|
||||
*/
|
||||
inline void SetPolygons (const Standard_Size nPolygons,
|
||||
const Standard_Integer ** thePolygons)
|
||||
{ myNbPolygons = nPolygons; myArrPolygons = thePolygons; }
|
||||
inline void SetPolygons(const Standard_Size nPolygons, const Standard_Integer** thePolygons)
|
||||
{
|
||||
myNbPolygons = nPolygons;
|
||||
myArrPolygons = thePolygons;
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// ================================ NORMALS ===============================
|
||||
@@ -140,8 +141,11 @@ class VrmlData_IndexedFaceSet : public VrmlData_Faceted
|
||||
* @return
|
||||
* Number of integers in the array arrNormalInd.
|
||||
*/
|
||||
inline size_t ArrayNormalInd (const Standard_Integer**& arrNormalInd) const
|
||||
{ arrNormalInd = myArrNormalInd; return myNbNormals; }
|
||||
inline size_t ArrayNormalInd(const Standard_Integer**& arrNormalInd) const
|
||||
{
|
||||
arrNormalInd = myArrNormalInd;
|
||||
return myNbNormals;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query normals indice for one face. This method should be called after
|
||||
@@ -153,10 +157,11 @@ class VrmlData_IndexedFaceSet : public VrmlData_Faceted
|
||||
* @return
|
||||
* number of indice in the array - the dimension of outIndice array
|
||||
*/
|
||||
inline Standard_Integer
|
||||
IndiceNormals (const Standard_Integer iFace,
|
||||
const Standard_Integer *& outIndice)
|
||||
{ return * (outIndice = myArrNormalInd[iFace])++; }
|
||||
inline Standard_Integer IndiceNormals(const Standard_Integer iFace,
|
||||
const Standard_Integer*& outIndice)
|
||||
{
|
||||
return *(outIndice = myArrNormalInd[iFace])++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query a normal for one node in the given element. The normal is
|
||||
@@ -170,28 +175,29 @@ class VrmlData_IndexedFaceSet : public VrmlData_Faceted
|
||||
* @return
|
||||
* Normal vector; if the normal is indefinite then returns (0., 0., 0.)
|
||||
*/
|
||||
Standard_EXPORT gp_XYZ
|
||||
GetNormal (const Standard_Integer iFace,
|
||||
const Standard_Integer iVertex);
|
||||
Standard_EXPORT gp_XYZ GetNormal(const Standard_Integer iFace, const Standard_Integer iVertex);
|
||||
|
||||
/**
|
||||
* Set the normals array of indice
|
||||
*/
|
||||
inline void SetNormalInd (const Standard_Size nIndice,
|
||||
const Standard_Integer ** theIndice)
|
||||
{ myNbNormals = nIndice; myArrNormalInd = theIndice; }
|
||||
inline void SetNormalInd(const Standard_Size nIndice, const Standard_Integer** theIndice)
|
||||
{
|
||||
myNbNormals = nIndice;
|
||||
myArrNormalInd = theIndice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the normals node
|
||||
*/
|
||||
inline void SetNormals (const Handle(VrmlData_Normal)& theNormals)
|
||||
{ myNormals = theNormals; }
|
||||
inline void SetNormals(const Handle(VrmlData_Normal)& theNormals) { myNormals = theNormals; }
|
||||
|
||||
/**
|
||||
* Set the boolean value "normalPerVertex"
|
||||
*/
|
||||
inline void SetNormalPerVertex (const Standard_Boolean isNormalPerVertex)
|
||||
{ myNormalPerVertex = isNormalPerVertex; }
|
||||
inline void SetNormalPerVertex(const Standard_Boolean isNormalPerVertex)
|
||||
{
|
||||
myNormalPerVertex = isNormalPerVertex;
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// ================================ COLORS ================================
|
||||
@@ -203,8 +209,11 @@ class VrmlData_IndexedFaceSet : public VrmlData_Faceted
|
||||
* @return
|
||||
* Number of integers in the array arrColorInd.
|
||||
*/
|
||||
inline size_t ArrayColorInd (const Standard_Integer**& arrColorInd) const
|
||||
{ arrColorInd = myArrColorInd; return myNbColors; }
|
||||
inline size_t ArrayColorInd(const Standard_Integer**& arrColorInd) const
|
||||
{
|
||||
arrColorInd = myArrColorInd;
|
||||
return myNbColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query a color for one node in the given element. The color is
|
||||
@@ -218,28 +227,30 @@ class VrmlData_IndexedFaceSet : public VrmlData_Faceted
|
||||
* @return
|
||||
* Color value (RGB); if the color is indefinite then returns (0., 0., 0.)
|
||||
*/
|
||||
Standard_EXPORT Quantity_Color
|
||||
GetColor (const Standard_Integer iFace,
|
||||
const Standard_Integer iVertex);
|
||||
Standard_EXPORT Quantity_Color GetColor(const Standard_Integer iFace,
|
||||
const Standard_Integer iVertex);
|
||||
|
||||
/**
|
||||
* Set the colors array of indice
|
||||
*/
|
||||
inline void SetColorInd (const Standard_Size nIndice,
|
||||
const Standard_Integer ** theIndice)
|
||||
{ myNbColors = nIndice; myArrColorInd = theIndice; }
|
||||
inline void SetColorInd(const Standard_Size nIndice, const Standard_Integer** theIndice)
|
||||
{
|
||||
myNbColors = nIndice;
|
||||
myArrColorInd = theIndice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Color node
|
||||
*/
|
||||
inline void SetColors (const Handle(VrmlData_Color)& theColors)
|
||||
{ myColors = theColors; }
|
||||
inline void SetColors(const Handle(VrmlData_Color)& theColors) { myColors = theColors; }
|
||||
|
||||
/**
|
||||
* Set the boolean value "colorPerVertex"
|
||||
*/
|
||||
inline void SetColorPerVertex (const Standard_Boolean isColorPerVertex)
|
||||
{ myColorPerVertex = isColorPerVertex; }
|
||||
inline void SetColorPerVertex(const Standard_Boolean isColorPerVertex)
|
||||
{
|
||||
myColorPerVertex = isColorPerVertex;
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// ========================== TEXTURE COIRDINATES =========================
|
||||
@@ -251,93 +262,92 @@ class VrmlData_IndexedFaceSet : public VrmlData_Faceted
|
||||
* @return
|
||||
* Number of integers in the array texCoordIndex.
|
||||
*/
|
||||
inline size_t ArrayTextureCoordInd
|
||||
(const Standard_Integer**& arrTextureCoordInd) const
|
||||
{ arrTextureCoordInd = myArrTextureInd; return myNbTextures; }
|
||||
inline size_t ArrayTextureCoordInd(const Standard_Integer**& arrTextureCoordInd) const
|
||||
{
|
||||
arrTextureCoordInd = myArrTextureInd;
|
||||
return myNbTextures;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the TexCoordiante array of indice
|
||||
*/
|
||||
inline void SetTextureCoordInd (const Standard_Size nIndice,
|
||||
const Standard_Integer ** theIndice)
|
||||
{ myNbTextures = nIndice; myArrTextureInd = theIndice; }
|
||||
inline void SetTextureCoordInd(const Standard_Size nIndice, const Standard_Integer** theIndice)
|
||||
{
|
||||
myNbTextures = nIndice;
|
||||
myArrTextureInd = theIndice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Texture Coordinate node
|
||||
*/
|
||||
inline void SetTextureCoords(const Handle(VrmlData_TextureCoordinate)& tc)
|
||||
{ myTxCoords = tc; }
|
||||
inline void SetTextureCoords(const Handle(VrmlData_TextureCoordinate)& tc) { myTxCoords = tc; }
|
||||
|
||||
/**
|
||||
* Query the shape. This method checks the flag myIsModified; if True it
|
||||
* should rebuild the shape presentation.
|
||||
*/
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape () Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape() Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Returns True if the node is default, so that it should not be written.
|
||||
*/
|
||||
Standard_EXPORT virtual Standard_Boolean
|
||||
IsDefault () const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsDefault() const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
// /**
|
||||
// * If the normals are not defined, here we compute them from the polygons.
|
||||
// * @param theArray
|
||||
// * Array of float values having length:<ul>
|
||||
// * <li>if myNormalPerVertex==TRUE : 3 * myCoords->Length()</li>
|
||||
// * <li>if myNormalPerVertex==FALSE: 9 * number_of_triangles </li>
|
||||
// * </ul>
|
||||
// */
|
||||
// Standard_EXPORT void
|
||||
// computeNormals (Standard_ShortReal * theArray);
|
||||
// /**
|
||||
// * If the normals are not defined, here we compute them from the polygons.
|
||||
// * @param theArray
|
||||
// * Array of float values having length:<ul>
|
||||
// * <li>if myNormalPerVertex==TRUE : 3 * myCoords->Length()</li>
|
||||
// * <li>if myNormalPerVertex==FALSE: 9 * number_of_triangles </li>
|
||||
// * </ul>
|
||||
// */
|
||||
// Standard_EXPORT void
|
||||
// computeNormals (Standard_ShortReal * theArray);
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
Handle(VrmlData_Coordinate) myCoords;
|
||||
Handle(VrmlData_Normal) myNormals;
|
||||
Handle(VrmlData_Color) myColors;
|
||||
Handle(VrmlData_TextureCoordinate) myTxCoords;
|
||||
const Standard_Integer ** myArrPolygons;
|
||||
const Standard_Integer ** myArrNormalInd;
|
||||
const Standard_Integer ** myArrColorInd;
|
||||
const Standard_Integer ** myArrTextureInd;
|
||||
Standard_Size myNbPolygons;
|
||||
Standard_Size myNbNormals;
|
||||
Standard_Size myNbColors;
|
||||
Standard_Size myNbTextures;
|
||||
Standard_Boolean myNormalPerVertex;
|
||||
Standard_Boolean myColorPerVertex;
|
||||
Handle(VrmlData_Coordinate) myCoords;
|
||||
Handle(VrmlData_Normal) myNormals;
|
||||
Handle(VrmlData_Color) myColors;
|
||||
Handle(VrmlData_TextureCoordinate) myTxCoords;
|
||||
const Standard_Integer** myArrPolygons;
|
||||
const Standard_Integer** myArrNormalInd;
|
||||
const Standard_Integer** myArrColorInd;
|
||||
const Standard_Integer** myArrTextureInd;
|
||||
Standard_Size myNbPolygons;
|
||||
Standard_Size myNbNormals;
|
||||
Standard_Size myNbColors;
|
||||
Standard_Size myNbTextures;
|
||||
Standard_Boolean myNormalPerVertex;
|
||||
Standard_Boolean myColorPerVertex;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_IndexedFaceSet,VrmlData_Faceted)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_IndexedFaceSet, VrmlData_Faceted)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_IndexedFaceSet, VrmlData_Faceted)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_IndexedFaceSet, VrmlData_Faceted)
|
||||
|
||||
#endif
|
||||
|
@@ -26,59 +26,56 @@
|
||||
#include <VrmlData_Color.hxx>
|
||||
#include <VrmlData_Coordinate.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_IndexedLineSet,VrmlData_Geometry)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_IndexedLineSet, VrmlData_Geometry)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning (disable:4996)
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Quantity_Color VrmlData_IndexedLineSet::GetColor
|
||||
(const Standard_Integer /*iFace*/,
|
||||
const Standard_Integer /*iVertex*/)
|
||||
Quantity_Color VrmlData_IndexedLineSet::GetColor(const Standard_Integer /*iFace*/,
|
||||
const Standard_Integer /*iVertex*/)
|
||||
{
|
||||
//TODO
|
||||
// TODO
|
||||
return Quantity_NOC_BLACK;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : TShape
|
||||
//purpose : Query the shape. This method checks the flag myIsModified;
|
||||
// function : TShape
|
||||
// purpose : Query the shape. This method checks the flag myIsModified;
|
||||
// if True it should rebuild the shape presentation.
|
||||
//=======================================================================
|
||||
|
||||
const Handle(TopoDS_TShape)& VrmlData_IndexedLineSet::TShape ()
|
||||
const Handle(TopoDS_TShape)& VrmlData_IndexedLineSet::TShape()
|
||||
{
|
||||
if (myNbPolygons == 0)
|
||||
myTShape.Nullify();
|
||||
else if (myIsModified) {
|
||||
else if (myIsModified)
|
||||
{
|
||||
Standard_Integer i;
|
||||
BRep_Builder aBuilder;
|
||||
const gp_XYZ * arrNodes = myCoords->Values();
|
||||
BRep_Builder aBuilder;
|
||||
const gp_XYZ* arrNodes = myCoords->Values();
|
||||
|
||||
// Create the Wire
|
||||
TopoDS_Wire aWire;
|
||||
aBuilder.MakeWire(aWire);
|
||||
for (i = 0; i < (int)myNbPolygons; i++) {
|
||||
const Standard_Integer * arrIndice;
|
||||
const Standard_Integer nNodes = Polygon(i, arrIndice);
|
||||
TColgp_Array1OfPnt arrPoint (1, nNodes);
|
||||
TColStd_Array1OfReal arrParam (1, nNodes);
|
||||
for (Standard_Integer j = 0; j < nNodes; j++) {
|
||||
arrPoint(j+1).SetXYZ (arrNodes[arrIndice[j]]);
|
||||
arrParam(j+1) = j;
|
||||
for (i = 0; i < (int)myNbPolygons; i++)
|
||||
{
|
||||
const Standard_Integer* arrIndice;
|
||||
const Standard_Integer nNodes = Polygon(i, arrIndice);
|
||||
TColgp_Array1OfPnt arrPoint(1, nNodes);
|
||||
TColStd_Array1OfReal arrParam(1, nNodes);
|
||||
for (Standard_Integer j = 0; j < nNodes; j++)
|
||||
{
|
||||
arrPoint(j + 1).SetXYZ(arrNodes[arrIndice[j]]);
|
||||
arrParam(j + 1) = j;
|
||||
}
|
||||
const Handle(Poly_Polygon3D) aPolyPolygon =
|
||||
new Poly_Polygon3D (arrPoint, arrParam);
|
||||
TopoDS_Edge anEdge;
|
||||
aBuilder.MakeEdge (anEdge, aPolyPolygon);
|
||||
aBuilder.Add (aWire, anEdge);
|
||||
const Handle(Poly_Polygon3D) aPolyPolygon = new Poly_Polygon3D(arrPoint, arrParam);
|
||||
TopoDS_Edge anEdge;
|
||||
aBuilder.MakeEdge(anEdge, aPolyPolygon);
|
||||
aBuilder.Add(aWire, anEdge);
|
||||
}
|
||||
myTShape = aWire.TShape();
|
||||
}
|
||||
@@ -86,76 +83,70 @@ const Handle(TopoDS_TShape)& VrmlData_IndexedLineSet::TShape ()
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clone
|
||||
//purpose : Create a copy of this node
|
||||
// function : Clone
|
||||
// purpose : Create a copy of this node
|
||||
//=======================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_IndexedLineSet::Clone
|
||||
(const Handle(VrmlData_Node)& theOther) const
|
||||
Handle(VrmlData_Node) VrmlData_IndexedLineSet::Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
{
|
||||
Handle(VrmlData_IndexedLineSet) aResult =
|
||||
Handle(VrmlData_IndexedLineSet)::DownCast (VrmlData_Node::Clone(theOther));
|
||||
Handle(VrmlData_IndexedLineSet)::DownCast(VrmlData_Node::Clone(theOther));
|
||||
if (aResult.IsNull())
|
||||
aResult =
|
||||
new VrmlData_IndexedLineSet(theOther.IsNull()? Scene(): theOther->Scene(),
|
||||
Name());
|
||||
aResult = new VrmlData_IndexedLineSet(theOther.IsNull() ? Scene() : theOther->Scene(), Name());
|
||||
|
||||
if (&aResult->Scene() == &Scene()) {
|
||||
aResult->SetCoordinates (myCoords);
|
||||
aResult->SetColors (myColors);
|
||||
aResult->SetPolygons (myNbPolygons, myArrPolygons);
|
||||
aResult->SetColorInd (myNbColors, myArrColorInd);
|
||||
} else {
|
||||
// Create a dummy node to pass the different Scene instance to methods Clone
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode =
|
||||
new VrmlData_UnknownNode (aResult->Scene());
|
||||
if (myCoords.IsNull() == Standard_False)
|
||||
aResult->SetCoordinates (Handle(VrmlData_Coordinate)::DownCast
|
||||
(myCoords->Clone (aDummyNode)));
|
||||
if (myColors.IsNull() == Standard_False)
|
||||
aResult->SetColors (Handle(VrmlData_Color)::DownCast
|
||||
(myColors->Clone (aDummyNode)));
|
||||
//TODO: Replace the following lines with the relevant copying
|
||||
aResult->SetPolygons (myNbPolygons, myArrPolygons);
|
||||
aResult->SetColorInd (myNbColors, myArrColorInd);
|
||||
if (&aResult->Scene() == &Scene())
|
||||
{
|
||||
aResult->SetCoordinates(myCoords);
|
||||
aResult->SetColors(myColors);
|
||||
aResult->SetPolygons(myNbPolygons, myArrPolygons);
|
||||
aResult->SetColorInd(myNbColors, myArrColorInd);
|
||||
}
|
||||
aResult->SetColorPerVertex (myColorPerVertex);
|
||||
else
|
||||
{
|
||||
// Create a dummy node to pass the different Scene instance to methods Clone
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode = new VrmlData_UnknownNode(aResult->Scene());
|
||||
if (myCoords.IsNull() == Standard_False)
|
||||
aResult->SetCoordinates(Handle(VrmlData_Coordinate)::DownCast(myCoords->Clone(aDummyNode)));
|
||||
if (myColors.IsNull() == Standard_False)
|
||||
aResult->SetColors(Handle(VrmlData_Color)::DownCast(myColors->Clone(aDummyNode)));
|
||||
// TODO: Replace the following lines with the relevant copying
|
||||
aResult->SetPolygons(myNbPolygons, myArrPolygons);
|
||||
aResult->SetColorInd(myNbColors, myArrColorInd);
|
||||
}
|
||||
aResult->SetColorPerVertex(myColorPerVertex);
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read the Node from input stream.
|
||||
// function : Read
|
||||
// purpose : Read the Node from input stream.
|
||||
//=======================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_IndexedLineSet::Read
|
||||
(VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_IndexedLineSet::Read(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "colorPerVertex"))
|
||||
aStatus = ReadBoolean (theBuffer, myColorPerVertex);
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "coordIndex"))
|
||||
aStatus = aScene.ReadArrIndex (theBuffer, myArrPolygons, myNbPolygons);
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "colorIndex"))
|
||||
aStatus = aScene.ReadArrIndex (theBuffer, myArrColorInd, myNbColors);
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "colorPerVertex"))
|
||||
aStatus = ReadBoolean(theBuffer, myColorPerVertex);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "coordIndex"))
|
||||
aStatus = aScene.ReadArrIndex(theBuffer, myArrPolygons, myNbPolygons);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "colorIndex"))
|
||||
aStatus = aScene.ReadArrIndex(theBuffer, myArrColorInd, myNbColors);
|
||||
// These two checks should be the last one to avoid their interference
|
||||
// with the other tokens (e.g., coordIndex)
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "color"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "color"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode,
|
||||
STANDARD_TYPE(VrmlData_Color));
|
||||
myColors = Handle(VrmlData_Color)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode, STANDARD_TYPE(VrmlData_Color));
|
||||
myColors = Handle(VrmlData_Color)::DownCast(aNode);
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "coord"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "coord"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode,
|
||||
STANDARD_TYPE(VrmlData_Coordinate));
|
||||
myCoords = Handle(VrmlData_Coordinate)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode, STANDARD_TYPE(VrmlData_Coordinate));
|
||||
myCoords = Handle(VrmlData_Coordinate)::DownCast(aNode);
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -164,7 +155,8 @@ VrmlData_ErrorStatus VrmlData_IndexedLineSet::Read
|
||||
}
|
||||
// Read the terminating (closing) brace
|
||||
if (OK(aStatus) || aStatus == VrmlData_EmptyData)
|
||||
if (OK(aStatus, readBrace (theBuffer))) {
|
||||
if (OK(aStatus, readBrace(theBuffer)))
|
||||
{
|
||||
// Post-processing
|
||||
;
|
||||
}
|
||||
@@ -172,29 +164,29 @@ VrmlData_ErrorStatus VrmlData_IndexedLineSet::Read
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write the Node to output stream
|
||||
// function : Write
|
||||
// purpose : Write the Node to output stream
|
||||
//=======================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_IndexedLineSet::Write
|
||||
(const char * thePrefix) const
|
||||
VrmlData_ErrorStatus VrmlData_IndexedLineSet::Write(const char* thePrefix) const
|
||||
{
|
||||
static char header[] = "IndexedLineSet {";
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
if (OK (aStatus, aScene.WriteLine (thePrefix, header, GlobalIndent()))) {
|
||||
static char header[] = "IndexedLineSet {";
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
if (OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent())))
|
||||
{
|
||||
|
||||
if (OK(aStatus) && myCoords.IsNull() == Standard_False)
|
||||
aStatus = aScene.WriteNode ("coord", myCoords);
|
||||
aStatus = aScene.WriteNode("coord", myCoords);
|
||||
if (OK(aStatus))
|
||||
aStatus = aScene.WriteArrIndex ("coordIndex", myArrPolygons,myNbPolygons);
|
||||
aStatus = aScene.WriteArrIndex("coordIndex", myArrPolygons, myNbPolygons);
|
||||
|
||||
if (OK(aStatus) && myColorPerVertex == Standard_False)
|
||||
aStatus = aScene.WriteLine ("colorPerVertex FALSE");
|
||||
aStatus = aScene.WriteLine("colorPerVertex FALSE");
|
||||
if (OK(aStatus) && myColors.IsNull() == Standard_False)
|
||||
aStatus = aScene.WriteNode ("color", myColors);
|
||||
aStatus = aScene.WriteNode("color", myColors);
|
||||
if (OK(aStatus))
|
||||
aStatus = aScene.WriteArrIndex ("colorIndex", myArrColorInd, myNbColors);
|
||||
aStatus = aScene.WriteArrIndex("colorIndex", myArrColorInd, myNbColors);
|
||||
|
||||
aStatus = WriteClosing();
|
||||
}
|
||||
@@ -202,18 +194,17 @@ VrmlData_ErrorStatus VrmlData_IndexedLineSet::Write
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDefault
|
||||
//purpose : Returns True if the node is default,
|
||||
// function : IsDefault
|
||||
// purpose : Returns True if the node is default,
|
||||
// so that it should not be written.
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean VrmlData_IndexedLineSet::IsDefault () const
|
||||
Standard_Boolean VrmlData_IndexedLineSet::IsDefault() const
|
||||
{
|
||||
Standard_Boolean aResult (Standard_True);
|
||||
Standard_Boolean aResult(Standard_True);
|
||||
if (myNbPolygons)
|
||||
aResult = Standard_False;
|
||||
else if (myCoords.IsNull() == Standard_False)
|
||||
aResult = myCoords->IsDefault();
|
||||
return aResult;
|
||||
}
|
||||
|
||||
|
@@ -19,7 +19,8 @@
|
||||
#include <VrmlData_Geometry.hxx>
|
||||
#include <VrmlData_Coordinate.hxx>
|
||||
#include <VrmlData_Color.hxx>
|
||||
//#include <Quantity_Color.hxx>
|
||||
|
||||
// #include <Quantity_Color.hxx>
|
||||
|
||||
/**
|
||||
* Data type to store a set of polygons.
|
||||
@@ -27,67 +28,66 @@
|
||||
|
||||
class VrmlData_IndexedLineSet : public VrmlData_Geometry
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
|
||||
/**
|
||||
* Empty constructor.
|
||||
*/
|
||||
inline VrmlData_IndexedLineSet ()
|
||||
: myArrPolygons (0L),
|
||||
myArrColorInd (0L),
|
||||
myNbPolygons (0),
|
||||
myNbColors (0),
|
||||
myColorPerVertex (Standard_True)
|
||||
{}
|
||||
inline VrmlData_IndexedLineSet()
|
||||
: myArrPolygons(0L),
|
||||
myArrColorInd(0L),
|
||||
myNbPolygons(0),
|
||||
myNbColors(0),
|
||||
myColorPerVertex(Standard_True)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
inline VrmlData_IndexedLineSet (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Boolean isColorPerVertex
|
||||
= Standard_True)
|
||||
: VrmlData_Geometry (theScene, theName),
|
||||
myArrPolygons (0L),
|
||||
myArrColorInd (0L),
|
||||
myNbPolygons (0),
|
||||
myNbColors (0),
|
||||
myColorPerVertex (isColorPerVertex)
|
||||
{}
|
||||
inline VrmlData_IndexedLineSet(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Boolean isColorPerVertex = Standard_True)
|
||||
: VrmlData_Geometry(theScene, theName),
|
||||
myArrPolygons(0L),
|
||||
myArrColorInd(0L),
|
||||
myNbPolygons(0),
|
||||
myNbColors(0),
|
||||
myColorPerVertex(isColorPerVertex)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Coordinates.
|
||||
*/
|
||||
inline const Handle(VrmlData_Coordinate)&
|
||||
Coordinates () const { return myCoords; }
|
||||
inline const Handle(VrmlData_Coordinate)& Coordinates() const { return myCoords; }
|
||||
|
||||
/**
|
||||
* Set the nodes
|
||||
*/
|
||||
inline void SetCoordinates (const Handle(VrmlData_Coordinate)& theCoord)
|
||||
{ myCoords = theCoord; }
|
||||
inline void SetCoordinates(const Handle(VrmlData_Coordinate)& theCoord) { myCoords = theCoord; }
|
||||
|
||||
/**
|
||||
* Query the Colors.
|
||||
*/
|
||||
inline const Handle(VrmlData_Color)&
|
||||
Colors () const { return myColors; }
|
||||
inline const Handle(VrmlData_Color)& Colors() const { return myColors; }
|
||||
|
||||
/**
|
||||
* Set the Color node
|
||||
*/
|
||||
inline void SetColors (const Handle(VrmlData_Color)& theColors)
|
||||
{ myColors = theColors; }
|
||||
inline void SetColors(const Handle(VrmlData_Color)& theColors) { myColors = theColors; }
|
||||
|
||||
// ========================================================================
|
||||
// =========================== POLYLINES =================================
|
||||
/**
|
||||
* Query the array of polygons
|
||||
*/
|
||||
inline size_t Polygons (const Standard_Integer**& arrPolygons) const
|
||||
{ arrPolygons = myArrPolygons; return myNbPolygons; }
|
||||
inline size_t Polygons(const Standard_Integer**& arrPolygons) const
|
||||
{
|
||||
arrPolygons = myArrPolygons;
|
||||
return myNbPolygons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query one polygon.
|
||||
@@ -98,17 +98,20 @@ class VrmlData_IndexedLineSet : public VrmlData_Geometry
|
||||
* @return
|
||||
* number of vertice in the polygon - the dimension of outIndice array
|
||||
*/
|
||||
inline Standard_Integer
|
||||
Polygon (const Standard_Integer iPolygon,
|
||||
const Standard_Integer *& outIndice)
|
||||
{ return * (outIndice = myArrPolygons[iPolygon])++; }
|
||||
inline Standard_Integer Polygon(const Standard_Integer iPolygon,
|
||||
const Standard_Integer*& outIndice)
|
||||
{
|
||||
return *(outIndice = myArrPolygons[iPolygon])++;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the polygons
|
||||
*/
|
||||
inline void SetPolygons (const Standard_Size nPolygons,
|
||||
const Standard_Integer ** thePolygons)
|
||||
{ myNbPolygons = nPolygons; myArrPolygons = thePolygons; }
|
||||
inline void SetPolygons(const Standard_Size nPolygons, const Standard_Integer** thePolygons)
|
||||
{
|
||||
myNbPolygons = nPolygons;
|
||||
myArrPolygons = thePolygons;
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// ================================ COLORS ================================
|
||||
@@ -119,8 +122,11 @@ class VrmlData_IndexedLineSet : public VrmlData_Geometry
|
||||
* @return
|
||||
* Number of integers in the array arrColorInd.
|
||||
*/
|
||||
inline size_t ArrayColorInd (const Standard_Integer**& arrColorInd) const
|
||||
{ arrColorInd = myArrColorInd; return myNbColors; }
|
||||
inline size_t ArrayColorInd(const Standard_Integer**& arrColorInd) const
|
||||
{
|
||||
arrColorInd = myArrColorInd;
|
||||
return myNbColors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query a color for one node in the given element. The color is
|
||||
@@ -134,74 +140,71 @@ class VrmlData_IndexedLineSet : public VrmlData_Geometry
|
||||
* @return
|
||||
* Color value (RGB); if the color is indefinite then returns (0., 0., 0.)
|
||||
*/
|
||||
Standard_EXPORT Quantity_Color
|
||||
GetColor (const Standard_Integer iFace,
|
||||
const Standard_Integer iVertex);
|
||||
Standard_EXPORT Quantity_Color GetColor(const Standard_Integer iFace,
|
||||
const Standard_Integer iVertex);
|
||||
|
||||
/**
|
||||
* Set the colors array of indice
|
||||
*/
|
||||
inline void SetColorInd (const Standard_Size nIndice,
|
||||
const Standard_Integer ** theIndice)
|
||||
{ myNbColors = nIndice; myArrColorInd = theIndice; }
|
||||
inline void SetColorInd(const Standard_Size nIndice, const Standard_Integer** theIndice)
|
||||
{
|
||||
myNbColors = nIndice;
|
||||
myArrColorInd = theIndice;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the boolean value "colorPerVertex"
|
||||
*/
|
||||
inline void SetColorPerVertex (const Standard_Boolean isColorPerVertex)
|
||||
{ myColorPerVertex = isColorPerVertex; }
|
||||
inline void SetColorPerVertex(const Standard_Boolean isColorPerVertex)
|
||||
{
|
||||
myColorPerVertex = isColorPerVertex;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the shape. This method checks the flag myIsModified; if True it
|
||||
* should rebuild the shape presentation.
|
||||
*/
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)&
|
||||
TShape () Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape() Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Returns True if the node is default, so that it should not be written.
|
||||
*/
|
||||
Standard_EXPORT virtual Standard_Boolean
|
||||
IsDefault () const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsDefault() const Standard_OVERRIDE;
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
Handle(VrmlData_Coordinate) myCoords;
|
||||
Handle(VrmlData_Color) myColors;
|
||||
const Standard_Integer ** myArrPolygons;
|
||||
const Standard_Integer ** myArrColorInd;
|
||||
Standard_Size myNbPolygons;
|
||||
Standard_Size myNbColors;
|
||||
Standard_Boolean myColorPerVertex;
|
||||
Handle(VrmlData_Coordinate) myCoords;
|
||||
Handle(VrmlData_Color) myColors;
|
||||
const Standard_Integer** myArrPolygons;
|
||||
const Standard_Integer** myArrColorInd;
|
||||
Standard_Size myNbPolygons;
|
||||
Standard_Size myNbColors;
|
||||
Standard_Boolean myColorPerVertex;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_IndexedLineSet,VrmlData_Geometry)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_IndexedLineSet, VrmlData_Geometry)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_IndexedLineSet, VrmlData_Geometry)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_IndexedLineSet, VrmlData_Geometry)
|
||||
|
||||
#endif
|
||||
|
@@ -23,6 +23,6 @@
|
||||
* Container of List type, holding handles to VrmlData_Node objects
|
||||
*/
|
||||
|
||||
typedef NCollection_List<Handle(VrmlData_Node)> VrmlData_ListOfNode;
|
||||
typedef NCollection_List<Handle(VrmlData_Node)> VrmlData_ListOfNode;
|
||||
|
||||
#endif
|
||||
|
@@ -23,6 +23,6 @@
|
||||
* Container of Map type, holding handles to VrmlData_Node objects
|
||||
*/
|
||||
|
||||
typedef NCollection_Map<Handle(VrmlData_Node)> VrmlData_MapOfNode;
|
||||
typedef NCollection_Map<Handle(VrmlData_Node)> VrmlData_MapOfNode;
|
||||
|
||||
#endif
|
||||
|
@@ -19,214 +19,200 @@
|
||||
#include <VrmlData_Scene.hxx>
|
||||
#include <gp_XYZ.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_Material,VrmlData_Node)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_Material, VrmlData_Node)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning (disable:4996)
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
namespace
|
||||
{
|
||||
static const Standard_Real THE_MAT_PREC = 0.001 * Precision::Confusion();
|
||||
static const Standard_Real THE_MAT_PREC = 0.001 * Precision::Confusion();
|
||||
|
||||
//=======================================================================
|
||||
//function : isValidValue
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static bool isValidValue(Standard_Real theVal)
|
||||
{
|
||||
return theVal >= -THE_MAT_PREC && theVal <= 1.0 + THE_MAT_PREC;
|
||||
}
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : isValidColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static bool isValidColor(const gp_XYZ & theVec3)
|
||||
{
|
||||
return isValidValue(theVec3.X()) && isValidValue(theVec3.Y()) && isValidValue(theVec3.Z());
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : parseColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static bool parseColor(VrmlData_ErrorStatus & theStatus,
|
||||
VrmlData_InBuffer & theBuffer,
|
||||
gp_XYZ & theColor,
|
||||
const VrmlData_Scene & theScene)
|
||||
{
|
||||
if (!VrmlData_Node::OK(theStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isArray = *theBuffer.LinePtr == '[';
|
||||
if (isArray)
|
||||
{
|
||||
++theBuffer.LinePtr;
|
||||
}
|
||||
theStatus = theScene.ReadXYZ(theBuffer, theColor, Standard_False, Standard_False);
|
||||
if (isArray)
|
||||
{
|
||||
if (VrmlData_Node::OK(theStatus, VrmlData_Scene::ReadLine(theBuffer))
|
||||
&& *theBuffer.LinePtr == ']')
|
||||
{
|
||||
++theBuffer.LinePtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
theStatus = VrmlData_VrmlFormatError;
|
||||
}
|
||||
}
|
||||
if (!isValidColor(theColor))
|
||||
{
|
||||
theStatus = VrmlData_IrrelevantNumber;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : parseScalar
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
static bool parseScalar(VrmlData_ErrorStatus & theStatus,
|
||||
VrmlData_InBuffer & theBuffer,
|
||||
Standard_Real & theValue,
|
||||
const VrmlData_Scene & theScene)
|
||||
{
|
||||
if (!VrmlData_Node::OK(theStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isArray = *theBuffer.LinePtr == '[';
|
||||
if (isArray)
|
||||
{
|
||||
++theBuffer.LinePtr;
|
||||
}
|
||||
|
||||
theStatus = theScene.ReadReal(theBuffer, theValue, Standard_False, Standard_False);
|
||||
if (isArray)
|
||||
{
|
||||
if (VrmlData_Node::OK(theStatus, VrmlData_Scene::ReadLine(theBuffer))
|
||||
&& *theBuffer.LinePtr == ']')
|
||||
{
|
||||
++theBuffer.LinePtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
theStatus = VrmlData_VrmlFormatError;
|
||||
}
|
||||
}
|
||||
if (!isValidValue(theValue))
|
||||
{
|
||||
theStatus = VrmlData_IrrelevantNumber;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
static bool isValidValue(Standard_Real theVal)
|
||||
{
|
||||
return theVal >= -THE_MAT_PREC && theVal <= 1.0 + THE_MAT_PREC;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Material()
|
||||
//purpose : Empty Constructor
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_Material::VrmlData_Material ()
|
||||
: myAmbientIntensity (0.2),
|
||||
myShininess (0.2),
|
||||
myTransparency (0.),
|
||||
myAmbientColor(0., 0., 0., Quantity_TOC_RGB),
|
||||
myDiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
|
||||
myEmissiveColor (Quantity_NOC_BLACK),
|
||||
mySpecularColor (Quantity_NOC_BLACK)
|
||||
{}
|
||||
static bool isValidColor(const gp_XYZ& theVec3)
|
||||
{
|
||||
return isValidValue(theVec3.X()) && isValidValue(theVec3.Y()) && isValidValue(theVec3.Z());
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
static bool parseColor(VrmlData_ErrorStatus& theStatus,
|
||||
VrmlData_InBuffer& theBuffer,
|
||||
gp_XYZ& theColor,
|
||||
const VrmlData_Scene& theScene)
|
||||
{
|
||||
if (!VrmlData_Node::OK(theStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isArray = *theBuffer.LinePtr == '[';
|
||||
if (isArray)
|
||||
{
|
||||
++theBuffer.LinePtr;
|
||||
}
|
||||
theStatus = theScene.ReadXYZ(theBuffer, theColor, Standard_False, Standard_False);
|
||||
if (isArray)
|
||||
{
|
||||
if (VrmlData_Node::OK(theStatus, VrmlData_Scene::ReadLine(theBuffer))
|
||||
&& *theBuffer.LinePtr == ']')
|
||||
{
|
||||
++theBuffer.LinePtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
theStatus = VrmlData_VrmlFormatError;
|
||||
}
|
||||
}
|
||||
if (!isValidColor(theColor))
|
||||
{
|
||||
theStatus = VrmlData_IrrelevantNumber;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
static bool parseScalar(VrmlData_ErrorStatus& theStatus,
|
||||
VrmlData_InBuffer& theBuffer,
|
||||
Standard_Real& theValue,
|
||||
const VrmlData_Scene& theScene)
|
||||
{
|
||||
if (!VrmlData_Node::OK(theStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
bool isArray = *theBuffer.LinePtr == '[';
|
||||
if (isArray)
|
||||
{
|
||||
++theBuffer.LinePtr;
|
||||
}
|
||||
|
||||
theStatus = theScene.ReadReal(theBuffer, theValue, Standard_False, Standard_False);
|
||||
if (isArray)
|
||||
{
|
||||
if (VrmlData_Node::OK(theStatus, VrmlData_Scene::ReadLine(theBuffer))
|
||||
&& *theBuffer.LinePtr == ']')
|
||||
{
|
||||
++theBuffer.LinePtr;
|
||||
}
|
||||
else
|
||||
{
|
||||
theStatus = VrmlData_VrmlFormatError;
|
||||
}
|
||||
}
|
||||
if (!isValidValue(theValue))
|
||||
{
|
||||
theStatus = VrmlData_IrrelevantNumber;
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} // namespace
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Material
|
||||
//purpose : Constructor
|
||||
// function : VrmlData_Material()
|
||||
// purpose : Empty Constructor
|
||||
//=======================================================================
|
||||
|
||||
VrmlData_Material::VrmlData_Material (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Real theAmbientIntens,
|
||||
const Standard_Real theShininess,
|
||||
const Standard_Real theTransparency)
|
||||
: VrmlData_Node (theScene, theName),
|
||||
myAmbientIntensity (theAmbientIntens < 0. ? 0.2 : theAmbientIntens),
|
||||
myShininess (theShininess < 0. ? 0.2 : theShininess),
|
||||
myTransparency (theTransparency < 0 ? 0. : theTransparency),
|
||||
myAmbientColor (0., 0., 0., Quantity_TOC_RGB),
|
||||
myDiffuseColor (0.8, 0.8, 0.8, Quantity_TOC_sRGB),
|
||||
myEmissiveColor (Quantity_NOC_BLACK),
|
||||
mySpecularColor (Quantity_NOC_BLACK)
|
||||
{}
|
||||
VrmlData_Material::VrmlData_Material()
|
||||
: myAmbientIntensity(0.2),
|
||||
myShininess(0.2),
|
||||
myTransparency(0.),
|
||||
myAmbientColor(0., 0., 0., Quantity_TOC_RGB),
|
||||
myDiffuseColor(0.8, 0.8, 0.8, Quantity_TOC_sRGB),
|
||||
myEmissiveColor(Quantity_NOC_BLACK),
|
||||
mySpecularColor(Quantity_NOC_BLACK)
|
||||
{
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Material::Clone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
VrmlData_Material::VrmlData_Material(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Real theAmbientIntens,
|
||||
const Standard_Real theShininess,
|
||||
const Standard_Real theTransparency)
|
||||
: VrmlData_Node(theScene, theName),
|
||||
myAmbientIntensity(theAmbientIntens < 0. ? 0.2 : theAmbientIntens),
|
||||
myShininess(theShininess < 0. ? 0.2 : theShininess),
|
||||
myTransparency(theTransparency < 0 ? 0. : theTransparency),
|
||||
myAmbientColor(0., 0., 0., Quantity_TOC_RGB),
|
||||
myDiffuseColor(0.8, 0.8, 0.8, Quantity_TOC_sRGB),
|
||||
myEmissiveColor(Quantity_NOC_BLACK),
|
||||
mySpecularColor(Quantity_NOC_BLACK)
|
||||
{
|
||||
}
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_Material::Clone
|
||||
(const Handle(VrmlData_Node)& theOther) const
|
||||
//=================================================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_Material::Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
{
|
||||
Handle(VrmlData_Material) aResult =
|
||||
Handle(VrmlData_Material)::DownCast (VrmlData_Node::Clone(theOther));
|
||||
Handle(VrmlData_Material)::DownCast(VrmlData_Node::Clone(theOther));
|
||||
if (aResult.IsNull())
|
||||
aResult =
|
||||
new VrmlData_Material (theOther.IsNull() ? Scene() : theOther->Scene(),
|
||||
Name());
|
||||
aResult = new VrmlData_Material(theOther.IsNull() ? Scene() : theOther->Scene(), Name());
|
||||
|
||||
aResult->SetAmbientIntensity (myAmbientIntensity);
|
||||
aResult->SetShininess (myShininess);
|
||||
aResult->SetTransparency (myTransparency);
|
||||
aResult->SetAmbientColor (myAmbientColor);
|
||||
aResult->SetDiffuseColor (myDiffuseColor);
|
||||
aResult->SetEmissiveColor (myEmissiveColor);
|
||||
aResult->SetSpecularColor (mySpecularColor);
|
||||
aResult->SetAmbientIntensity(myAmbientIntensity);
|
||||
aResult->SetShininess(myShininess);
|
||||
aResult->SetTransparency(myTransparency);
|
||||
aResult->SetAmbientColor(myAmbientColor);
|
||||
aResult->SetDiffuseColor(myDiffuseColor);
|
||||
aResult->SetEmissiveColor(myEmissiveColor);
|
||||
aResult->SetSpecularColor(mySpecularColor);
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Material::Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Material::Read (VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_Material::Read(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
Standard_Real anIntensity[3] = { 0.2, 0.2, 0. };
|
||||
gp_XYZ aColor[4] = {
|
||||
gp_XYZ (0.0, 0.0, 0.0),
|
||||
gp_XYZ (0.8, 0.8, 0.8),
|
||||
gp_XYZ (0.0, 0.0, 0.0),
|
||||
gp_XYZ (0.0, 0.0, 0.0)
|
||||
};
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "ambientIntensity"))
|
||||
Standard_Real anIntensity[3] = {0.2, 0.2, 0.};
|
||||
gp_XYZ aColor[4] = {gp_XYZ(0.0, 0.0, 0.0),
|
||||
gp_XYZ(0.8, 0.8, 0.8),
|
||||
gp_XYZ(0.0, 0.0, 0.0),
|
||||
gp_XYZ(0.0, 0.0, 0.0)};
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "ambientIntensity"))
|
||||
{
|
||||
parseScalar(aStatus, theBuffer, anIntensity[0], Scene());
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "shininess")) {
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "shininess"))
|
||||
{
|
||||
parseScalar(aStatus, theBuffer, anIntensity[1], Scene());
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "transparency")) {
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "transparency"))
|
||||
{
|
||||
parseScalar(aStatus, theBuffer, anIntensity[2], Scene());
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "ambientColor")) {
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "ambientColor"))
|
||||
{
|
||||
parseColor(aStatus, theBuffer, aColor[0], Scene());
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "diffuseColor")) {
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "diffuseColor"))
|
||||
{
|
||||
parseColor(aStatus, theBuffer, aColor[1], Scene());
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "emissiveColor")) {
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "emissiveColor"))
|
||||
{
|
||||
parseColor(aStatus, theBuffer, aColor[2], Scene());
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "specularColor")) {
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "specularColor"))
|
||||
{
|
||||
parseColor(aStatus, theBuffer, aColor[3], Scene());
|
||||
}
|
||||
else
|
||||
@@ -235,81 +221,83 @@ VrmlData_ErrorStatus VrmlData_Material::Read (VrmlData_InBuffer& theBuffer)
|
||||
if (!OK(aStatus))
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Read the terminating (closing) brace
|
||||
if (OK(aStatus))
|
||||
aStatus = readBrace (theBuffer);
|
||||
aStatus = readBrace(theBuffer);
|
||||
|
||||
// Store the values in the Material node instance
|
||||
if (OK(aStatus)) {
|
||||
myAmbientIntensity = anIntensity[0];
|
||||
myShininess = anIntensity[1];
|
||||
myTransparency = anIntensity[2];
|
||||
myAmbientColor.SetValues (aColor[0].X(), aColor[0].Y(), aColor[0].Z(),
|
||||
Quantity_TOC_sRGB);
|
||||
myDiffuseColor.SetValues (aColor[1].X(), aColor[1].Y(), aColor[1].Z(),
|
||||
Quantity_TOC_sRGB);
|
||||
myEmissiveColor.SetValues (aColor[2].X(), aColor[2].Y(), aColor[2].Z(),
|
||||
Quantity_TOC_sRGB);
|
||||
mySpecularColor.SetValues (aColor[3].X(), aColor[3].Y(), aColor[3].Z(),
|
||||
Quantity_TOC_sRGB);
|
||||
if (OK(aStatus))
|
||||
{
|
||||
myAmbientIntensity = anIntensity[0];
|
||||
myShininess = anIntensity[1];
|
||||
myTransparency = anIntensity[2];
|
||||
myAmbientColor.SetValues(aColor[0].X(), aColor[0].Y(), aColor[0].Z(), Quantity_TOC_sRGB);
|
||||
myDiffuseColor.SetValues(aColor[1].X(), aColor[1].Y(), aColor[1].Z(), Quantity_TOC_sRGB);
|
||||
myEmissiveColor.SetValues(aColor[2].X(), aColor[2].Y(), aColor[2].Z(), Quantity_TOC_sRGB);
|
||||
mySpecularColor.SetValues(aColor[3].X(), aColor[3].Y(), aColor[3].Z(), Quantity_TOC_sRGB);
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Material::Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Material::Write (const char * thePrefix) const
|
||||
VrmlData_ErrorStatus VrmlData_Material::Write(const char* thePrefix) const
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus = VrmlData_StatusOK;
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
static char header[] = "Material {";
|
||||
if (aScene.IsDummyWrite() == Standard_False &&
|
||||
OK (aStatus, aScene.WriteLine (thePrefix, header, GlobalIndent())))
|
||||
VrmlData_ErrorStatus aStatus = VrmlData_StatusOK;
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
static char header[] = "Material {";
|
||||
if (aScene.IsDummyWrite() == Standard_False
|
||||
&& OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent())))
|
||||
{
|
||||
char buf[128];
|
||||
Standard_Real val[3];
|
||||
char buf[128];
|
||||
Standard_Real val[3];
|
||||
const Quantity_TypeOfColor bidType = Quantity_TOC_sRGB;
|
||||
constexpr Standard_Real aConf (0.001 * Precision::Confusion());
|
||||
constexpr Standard_Real aConf(0.001 * Precision::Confusion());
|
||||
|
||||
if (OK(aStatus) && fabs(myAmbientIntensity - 0.2) > aConf) {
|
||||
Sprintf (buf, "%.6g", myAmbientIntensity);
|
||||
aStatus = aScene.WriteLine ("ambientIntensity ", buf);
|
||||
if (OK(aStatus) && fabs(myAmbientIntensity - 0.2) > aConf)
|
||||
{
|
||||
Sprintf(buf, "%.6g", myAmbientIntensity);
|
||||
aStatus = aScene.WriteLine("ambientIntensity ", buf);
|
||||
}
|
||||
if (OK(aStatus)) {
|
||||
myDiffuseColor.Values (val[0], val[1], val[2], bidType);
|
||||
if ((val[0] - 0.8) * (val[0] - 0.8) +
|
||||
(val[1] - 0.8) * (val[1] - 0.8) +
|
||||
(val[2] - 0.8) * (val[2] - 0.8) > 1e-7)
|
||||
if (OK(aStatus))
|
||||
{
|
||||
myDiffuseColor.Values(val[0], val[1], val[2], bidType);
|
||||
if ((val[0] - 0.8) * (val[0] - 0.8) + (val[1] - 0.8) * (val[1] - 0.8)
|
||||
+ (val[2] - 0.8) * (val[2] - 0.8)
|
||||
> 1e-7)
|
||||
{
|
||||
Sprintf (buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
|
||||
aStatus = aScene.WriteLine ("diffuseColor ", buf);
|
||||
Sprintf(buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
|
||||
aStatus = aScene.WriteLine("diffuseColor ", buf);
|
||||
}
|
||||
}
|
||||
if (OK(aStatus)) {
|
||||
myEmissiveColor.Values (val[0], val[1], val[2], bidType);
|
||||
if (val[0] * val[0] + val[1] * val[1] + val[2] * val[2] > 1e-7) {
|
||||
Sprintf (buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
|
||||
aStatus = aScene.WriteLine ("emissiveColor ", buf);
|
||||
if (OK(aStatus))
|
||||
{
|
||||
myEmissiveColor.Values(val[0], val[1], val[2], bidType);
|
||||
if (val[0] * val[0] + val[1] * val[1] + val[2] * val[2] > 1e-7)
|
||||
{
|
||||
Sprintf(buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
|
||||
aStatus = aScene.WriteLine("emissiveColor ", buf);
|
||||
}
|
||||
}
|
||||
if (OK(aStatus) && fabs(myShininess - 0.2) > aConf) {
|
||||
Sprintf (buf, "%.6g", myShininess);
|
||||
aStatus = aScene.WriteLine ("shininess ", buf);
|
||||
if (OK(aStatus) && fabs(myShininess - 0.2) > aConf)
|
||||
{
|
||||
Sprintf(buf, "%.6g", myShininess);
|
||||
aStatus = aScene.WriteLine("shininess ", buf);
|
||||
}
|
||||
if (OK(aStatus)) {
|
||||
mySpecularColor.Values (val[0], val[1], val[2], bidType);
|
||||
if (val[0] * val[0] + val[1] * val[1] + val[2] * val[2] > 1e-7) {
|
||||
Sprintf (buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
|
||||
aStatus = aScene.WriteLine ("specularColor ", buf);
|
||||
if (OK(aStatus))
|
||||
{
|
||||
mySpecularColor.Values(val[0], val[1], val[2], bidType);
|
||||
if (val[0] * val[0] + val[1] * val[1] + val[2] * val[2] > 1e-7)
|
||||
{
|
||||
Sprintf(buf, "%.6g %.6g %.6g", val[0], val[1], val[2]);
|
||||
aStatus = aScene.WriteLine("specularColor ", buf);
|
||||
}
|
||||
}
|
||||
if (OK(aStatus) && myTransparency > aConf) {
|
||||
Sprintf (buf, "%.6g", myTransparency);
|
||||
aStatus = aScene.WriteLine ("transparency ", buf);
|
||||
if (OK(aStatus) && myTransparency > aConf)
|
||||
{
|
||||
Sprintf(buf, "%.6g", myTransparency);
|
||||
aStatus = aScene.WriteLine("transparency ", buf);
|
||||
}
|
||||
|
||||
aStatus = WriteClosing();
|
||||
@@ -317,35 +305,25 @@ VrmlData_ErrorStatus VrmlData_Material::Write (const char * thePrefix) const
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDefault
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean VrmlData_Material::IsDefault () const
|
||||
Standard_Boolean VrmlData_Material::IsDefault() const
|
||||
{
|
||||
constexpr Standard_Real aConf (0.001 * Precision::Confusion());
|
||||
Standard_Boolean aResult (Standard_False);
|
||||
if (fabs(myAmbientIntensity - 0.2) < aConf &&
|
||||
fabs(myShininess - 0.2) < aConf &&
|
||||
myTransparency < aConf)
|
||||
constexpr Standard_Real aConf(0.001 * Precision::Confusion());
|
||||
Standard_Boolean aResult(Standard_False);
|
||||
if (fabs(myAmbientIntensity - 0.2) < aConf && fabs(myShininess - 0.2) < aConf
|
||||
&& myTransparency < aConf)
|
||||
{
|
||||
Standard_Real val[3][3];
|
||||
Standard_Real val[3][3];
|
||||
const Quantity_TypeOfColor bidType = Quantity_TOC_sRGB;
|
||||
myDiffuseColor.Values (val[0][0], val[0][1], val[0][2], bidType);
|
||||
myEmissiveColor.Values (val[1][0], val[1][1], val[1][2], bidType);
|
||||
mySpecularColor.Values (val[2][0], val[2][1], val[2][2], bidType);
|
||||
aResult = (((val[0][0] - 0.8)*(val[0][0] - 0.8) +
|
||||
(val[0][1] - 0.8)*(val[0][1] - 0.8) +
|
||||
(val[0][2] - 0.8)*(val[0][2] - 0.8) < 1e-7) &&
|
||||
(val[1][0] * val[1][0] +
|
||||
val[1][1] * val[1][0] +
|
||||
val[1][2] * val[1][0] < 1e-7) &&
|
||||
(val[2][0] * val[2][0] +
|
||||
val[2][1] * val[2][0] +
|
||||
val[2][2] * val[2][0] < 1e-7));
|
||||
myDiffuseColor.Values(val[0][0], val[0][1], val[0][2], bidType);
|
||||
myEmissiveColor.Values(val[1][0], val[1][1], val[1][2], bidType);
|
||||
mySpecularColor.Values(val[2][0], val[2][1], val[2][2], bidType);
|
||||
aResult = (((val[0][0] - 0.8) * (val[0][0] - 0.8) + (val[0][1] - 0.8) * (val[0][1] - 0.8)
|
||||
+ (val[0][2] - 0.8) * (val[0][2] - 0.8)
|
||||
< 1e-7)
|
||||
&& (val[1][0] * val[1][0] + val[1][1] * val[1][0] + val[1][2] * val[1][0] < 1e-7)
|
||||
&& (val[2][0] * val[2][0] + val[2][1] * val[2][0] + val[2][2] * val[2][0] < 1e-7));
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -24,158 +24,142 @@
|
||||
*/
|
||||
class VrmlData_Material : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
Standard_EXPORT VrmlData_Material ();
|
||||
Standard_EXPORT VrmlData_Material();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Standard_EXPORT VrmlData_Material
|
||||
(const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Real theAmbientIntensity = -1.,
|
||||
const Standard_Real theShininess = -1.,
|
||||
const Standard_Real theTransparency = -1.);
|
||||
Standard_EXPORT VrmlData_Material(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Real theAmbientIntensity = -1.,
|
||||
const Standard_Real theShininess = -1.,
|
||||
const Standard_Real theTransparency = -1.);
|
||||
|
||||
/**
|
||||
* Query the Ambient Intensity value
|
||||
*/
|
||||
inline Standard_Real
|
||||
AmbientIntensity() const { return myAmbientIntensity; }
|
||||
inline Standard_Real AmbientIntensity() const { return myAmbientIntensity; }
|
||||
|
||||
/**
|
||||
* Query the Shininess value
|
||||
*/
|
||||
inline Standard_Real
|
||||
Shininess () const { return myShininess; }
|
||||
inline Standard_Real Shininess() const { return myShininess; }
|
||||
|
||||
/**
|
||||
* Query the Transparency value
|
||||
*/
|
||||
inline Standard_Real
|
||||
Transparency () const { return myTransparency; }
|
||||
inline Standard_Real Transparency() const { return myTransparency; }
|
||||
|
||||
/**
|
||||
* Query the Ambient color
|
||||
*/
|
||||
inline const Quantity_Color&
|
||||
AmbientColor () const { return myAmbientColor; }
|
||||
* Query the Ambient color
|
||||
*/
|
||||
inline const Quantity_Color& AmbientColor() const { return myAmbientColor; }
|
||||
|
||||
/**
|
||||
* Query the Diffuse color
|
||||
*/
|
||||
inline const Quantity_Color&
|
||||
DiffuseColor () const { return myDiffuseColor; }
|
||||
inline const Quantity_Color& DiffuseColor() const { return myDiffuseColor; }
|
||||
|
||||
/**
|
||||
* Query the Emissive color
|
||||
*/
|
||||
inline const Quantity_Color&
|
||||
EmissiveColor () const { return myEmissiveColor; }
|
||||
inline const Quantity_Color& EmissiveColor() const { return myEmissiveColor; }
|
||||
|
||||
/**
|
||||
* Query the Specular color
|
||||
*/
|
||||
inline const Quantity_Color&
|
||||
SpecularColor () const { return mySpecularColor; }
|
||||
inline const Quantity_Color& SpecularColor() const { return mySpecularColor; }
|
||||
|
||||
/**
|
||||
* Set the Ambient Intensity value
|
||||
*/
|
||||
inline void SetAmbientIntensity
|
||||
(const Standard_Real theAmbientIntensity)
|
||||
{ myAmbientIntensity = theAmbientIntensity; }
|
||||
inline void SetAmbientIntensity(const Standard_Real theAmbientIntensity)
|
||||
{
|
||||
myAmbientIntensity = theAmbientIntensity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Shininess value
|
||||
*/
|
||||
inline void SetShininess (const Standard_Real theShininess)
|
||||
{ myShininess = theShininess; }
|
||||
inline void SetShininess(const Standard_Real theShininess) { myShininess = theShininess; }
|
||||
|
||||
/**
|
||||
* Set the Transparency value
|
||||
*/
|
||||
inline void SetTransparency (const Standard_Real theTransparency)
|
||||
{ myTransparency = theTransparency; }
|
||||
inline void SetTransparency(const Standard_Real theTransparency)
|
||||
{
|
||||
myTransparency = theTransparency;
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Ambient color
|
||||
*/
|
||||
inline void SetAmbientColor (const Quantity_Color& theColor)
|
||||
{
|
||||
myAmbientColor = theColor;
|
||||
}
|
||||
* Query the Ambient color
|
||||
*/
|
||||
inline void SetAmbientColor(const Quantity_Color& theColor) { myAmbientColor = theColor; }
|
||||
|
||||
/**
|
||||
* Query the Diffuse color
|
||||
*/
|
||||
inline void SetDiffuseColor (const Quantity_Color& theColor)
|
||||
{ myDiffuseColor = theColor; }
|
||||
inline void SetDiffuseColor(const Quantity_Color& theColor) { myDiffuseColor = theColor; }
|
||||
|
||||
/**
|
||||
* Query the Emissive color
|
||||
*/
|
||||
inline void SetEmissiveColor (const Quantity_Color& theColor)
|
||||
{ myEmissiveColor = theColor; }
|
||||
inline void SetEmissiveColor(const Quantity_Color& theColor) { myEmissiveColor = theColor; }
|
||||
|
||||
/**
|
||||
* Query the Specular color
|
||||
*/
|
||||
inline void SetSpecularColor (const Quantity_Color& theColor)
|
||||
{ mySpecularColor = theColor; }
|
||||
inline void SetSpecularColor(const Quantity_Color& theColor) { mySpecularColor = theColor; }
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to the Scene output.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Returns True if the node is default, so that it should not be written.
|
||||
*/
|
||||
Standard_EXPORT virtual Standard_Boolean
|
||||
IsDefault () const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsDefault() const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
Standard_Real myAmbientIntensity;
|
||||
Standard_Real myShininess;
|
||||
Standard_Real myTransparency;
|
||||
Quantity_Color myAmbientColor;
|
||||
Quantity_Color myDiffuseColor;
|
||||
Quantity_Color myEmissiveColor;
|
||||
Quantity_Color mySpecularColor;
|
||||
Standard_Real myAmbientIntensity;
|
||||
Standard_Real myShininess;
|
||||
Standard_Real myTransparency;
|
||||
Quantity_Color myAmbientColor;
|
||||
Quantity_Color myDiffuseColor;
|
||||
Quantity_Color myEmissiveColor;
|
||||
Quantity_Color mySpecularColor;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_Material,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_Material, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Material, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Material, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -25,134 +25,110 @@
|
||||
#include <VrmlData_TextureTransform.hxx>
|
||||
#include <VrmlData_Texture.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_Node,Standard_Transient)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_Node, Standard_Transient)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning (disable:4996)
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
static VrmlData_Scene MyDefaultScene;
|
||||
|
||||
//=======================================================================
|
||||
//function : IsEqual
|
||||
//purpose : Global method
|
||||
// function : IsEqual
|
||||
// purpose : Global method
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean IsEqual (const Handle(VrmlData_Node)& theOne,
|
||||
const Handle(VrmlData_Node)& theTwo)
|
||||
Standard_Boolean IsEqual(const Handle(VrmlData_Node)& theOne, const Handle(VrmlData_Node)& theTwo)
|
||||
{
|
||||
Standard_Boolean aResult (Standard_False);
|
||||
Standard_Boolean aResult(Standard_False);
|
||||
if (theOne->Name() != 0L && theTwo->Name() != 0L)
|
||||
aResult = (strcmp (theOne->Name(), theTwo->Name()) == 0);
|
||||
aResult = (strcmp(theOne->Name(), theTwo->Name()) == 0);
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Node
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_Node::VrmlData_Node ()
|
||||
: myScene (&MyDefaultScene),
|
||||
myName (0L) {}
|
||||
VrmlData_Node::VrmlData_Node()
|
||||
: myScene(&MyDefaultScene),
|
||||
myName(0L)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Node
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_Node::VrmlData_Node (const VrmlData_Scene& theScene,
|
||||
const char * theName)
|
||||
: myScene (&theScene)
|
||||
VrmlData_Node::VrmlData_Node(const VrmlData_Scene& theScene, const char* theName)
|
||||
: myScene(&theScene)
|
||||
{
|
||||
if (theName == 0L)
|
||||
theName = "";
|
||||
setName (theName);
|
||||
setName(theName);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clone
|
||||
//purpose : Create a copy of this node.
|
||||
// function : Clone
|
||||
// purpose : Create a copy of this node.
|
||||
//=======================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_Node::Clone
|
||||
(const Handle(VrmlData_Node)& theOther) const
|
||||
Handle(VrmlData_Node) VrmlData_Node::Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
{
|
||||
if (theOther.IsNull() == Standard_False) {
|
||||
if (theOther->IsKind (DynamicType()) == Standard_False)
|
||||
if (theOther.IsNull() == Standard_False)
|
||||
{
|
||||
if (theOther->IsKind(DynamicType()) == Standard_False)
|
||||
return NULL;
|
||||
if (&theOther->Scene() == myScene)
|
||||
theOther->myName = myName;
|
||||
else
|
||||
theOther->setName (myName);
|
||||
theOther->setName(myName);
|
||||
}
|
||||
return theOther;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : setName
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
void VrmlData_Node::setName (const char * theName, const char * theSuffix)
|
||||
void VrmlData_Node::setName(const char* theName, const char* theSuffix)
|
||||
{
|
||||
size_t len[2] = {
|
||||
strlen(theName) + 1,
|
||||
0
|
||||
};
|
||||
size_t len[2] = {strlen(theName) + 1, 0};
|
||||
if (theSuffix)
|
||||
len[1] = strlen (theSuffix);
|
||||
char * aName = (char *)Scene().Allocator()->Allocate(len[0]+len[1]);
|
||||
myName = aName;
|
||||
memcpy (aName, theName, len[0]);
|
||||
len[1] = strlen(theSuffix);
|
||||
char* aName = (char*)Scene().Allocator()->Allocate(len[0] + len[1]);
|
||||
myName = aName;
|
||||
memcpy(aName, theName, len[0]);
|
||||
if (len[1])
|
||||
memcpy (&aName[len[0] - 1], theSuffix, len[1]+1);
|
||||
memcpy(&aName[len[0] - 1], theSuffix, len[1] + 1);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDefault
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean VrmlData_Node::IsDefault () const
|
||||
Standard_Boolean VrmlData_Node::IsDefault() const
|
||||
{
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Node::Write (const char *) const
|
||||
VrmlData_ErrorStatus VrmlData_Node::Write(const char*) const
|
||||
{
|
||||
return VrmlData_NotImplemented;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : WriteClosing
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Node::WriteClosing () const
|
||||
VrmlData_ErrorStatus VrmlData_Node::WriteClosing() const
|
||||
{
|
||||
VrmlData_ErrorStatus aResult = Scene().Status();
|
||||
if (aResult == VrmlData_StatusOK || aResult == VrmlData_NotImplemented)
|
||||
aResult = Scene().WriteLine ("}", 0L, -GlobalIndent());
|
||||
aResult = Scene().WriteLine("}", 0L, -GlobalIndent());
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : readBrace
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Node::readBrace (VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_Node::readBrace(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (theBuffer.LinePtr[0] == '}')
|
||||
theBuffer.LinePtr++;
|
||||
else
|
||||
@@ -161,19 +137,17 @@ VrmlData_ErrorStatus VrmlData_Node::readBrace (VrmlData_InBuffer& theBuffer)
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadBoolean
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadBoolean (VrmlData_InBuffer& theBuffer,
|
||||
Standard_Boolean& theResult)
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadBoolean(VrmlData_InBuffer& theBuffer,
|
||||
Standard_Boolean& theResult)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "TRUE"))
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "TRUE"))
|
||||
theResult = Standard_True;
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "FALSE"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "FALSE"))
|
||||
theResult = Standard_False;
|
||||
else
|
||||
aStatus = VrmlData_BooleanInputError;
|
||||
@@ -181,77 +155,75 @@ VrmlData_ErrorStatus VrmlData_Node::ReadBoolean (VrmlData_InBuffer& theBuffer,
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadInteger
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadInteger (VrmlData_InBuffer& theBuffer,
|
||||
long& theResult)
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadInteger(VrmlData_InBuffer& theBuffer, long& theResult)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
char * endptr;
|
||||
long aResult;
|
||||
aResult = strtol (theBuffer.LinePtr, &endptr, 10);
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
char* endptr;
|
||||
long aResult;
|
||||
aResult = strtol(theBuffer.LinePtr, &endptr, 10);
|
||||
if (endptr == theBuffer.LinePtr)
|
||||
aStatus = VrmlData_NumericInputError;
|
||||
else {
|
||||
theResult = aResult;
|
||||
else
|
||||
{
|
||||
theResult = aResult;
|
||||
theBuffer.LinePtr = endptr;
|
||||
}
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadString
|
||||
(VrmlData_InBuffer& theBuffer,
|
||||
TCollection_AsciiString& theResult)
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadString(VrmlData_InBuffer& theBuffer,
|
||||
TCollection_AsciiString& theResult)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (theBuffer.LinePtr[0] != '\"')
|
||||
aStatus = VrmlData_StringInputError;
|
||||
else {
|
||||
char * ptr = &theBuffer.LinePtr[1];
|
||||
else
|
||||
{
|
||||
char* ptr = &theBuffer.LinePtr[1];
|
||||
while (*ptr != '\0' && *ptr != '\"')
|
||||
ptr++;
|
||||
if (*ptr == '\0')
|
||||
aStatus = VrmlData_StringInputError;
|
||||
else {
|
||||
*ptr = '\0';
|
||||
theResult = (Standard_CString) &theBuffer.LinePtr[1];
|
||||
theBuffer.LinePtr = ptr+1;
|
||||
else
|
||||
{
|
||||
*ptr = '\0';
|
||||
theResult = (Standard_CString)&theBuffer.LinePtr[1];
|
||||
theBuffer.LinePtr = ptr + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadMultiString
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadMultiString
|
||||
(VrmlData_InBuffer& theBuffer,
|
||||
NCollection_List<TCollection_AsciiString>& theResult)
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadMultiString(
|
||||
VrmlData_InBuffer& theBuffer,
|
||||
NCollection_List<TCollection_AsciiString>& theResult)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
Standard_Boolean isBracketed (Standard_False);
|
||||
Standard_Boolean isBracketed(Standard_False);
|
||||
// Read the list of URL
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (theBuffer.LinePtr[0] == '[') {
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (theBuffer.LinePtr[0] == '[')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
isBracketed = Standard_True;
|
||||
}
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (isBracketed && theBuffer.LinePtr[0] == ']') { // closing bracket
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (isBracketed && theBuffer.LinePtr[0] == ']')
|
||||
{ // closing bracket
|
||||
theBuffer.LinePtr++;
|
||||
break;
|
||||
}
|
||||
@@ -259,13 +231,14 @@ VrmlData_ErrorStatus VrmlData_Node::ReadMultiString
|
||||
if (!OK(aStatus, ReadString(theBuffer, aString)))
|
||||
break;
|
||||
theResult.Append(aString);
|
||||
if (isBracketed == Standard_False ||
|
||||
!OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
if (isBracketed == Standard_False || !OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
break;
|
||||
if (theBuffer.LinePtr[0] == ',') {
|
||||
if (theBuffer.LinePtr[0] == ',')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
continue;
|
||||
} else if (theBuffer.LinePtr[0] == ']') // closing bracket
|
||||
}
|
||||
else if (theBuffer.LinePtr[0] == ']') // closing bracket
|
||||
theBuffer.LinePtr++;
|
||||
else
|
||||
aStatus = VrmlData_VrmlFormatError;
|
||||
@@ -275,37 +248,34 @@ VrmlData_ErrorStatus VrmlData_Node::ReadMultiString
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ReadNode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadNode
|
||||
(VrmlData_InBuffer& theBuffer,
|
||||
Handle(VrmlData_Node)& theNode,
|
||||
const Handle(Standard_Type)& theType)
|
||||
VrmlData_ErrorStatus VrmlData_Node::ReadNode(VrmlData_InBuffer& theBuffer,
|
||||
Handle(VrmlData_Node)& theNode,
|
||||
const Handle(Standard_Type)& theType)
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
// First line of a new node should identify this node type
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "USE")) {
|
||||
if (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "USE"))
|
||||
{
|
||||
TCollection_AsciiString aName;
|
||||
aStatus = VrmlData_Scene::ReadWord (theBuffer, aName);
|
||||
if (aStatus == VrmlData_StatusOK) {
|
||||
aNode = myScene->FindNode (aName.ToCString(), theType);
|
||||
aStatus = VrmlData_Scene::ReadWord(theBuffer, aName);
|
||||
if (aStatus == VrmlData_StatusOK)
|
||||
{
|
||||
aNode = myScene->FindNode(aName.ToCString(), theType);
|
||||
if (aNode.IsNull())
|
||||
aStatus = VrmlData_NodeNameUnknown;
|
||||
// else
|
||||
// aNode = aNode->Clone(0L);
|
||||
// else
|
||||
// aNode = aNode->Clone(0L);
|
||||
}
|
||||
}
|
||||
|
||||
// We create a relevant node using the line with the type ID
|
||||
else if (OK(aStatus,
|
||||
const_cast<VrmlData_Scene *>(myScene)->createNode (theBuffer,
|
||||
aNode,
|
||||
theType)))
|
||||
const_cast<VrmlData_Scene*>(myScene)->createNode(theBuffer, aNode, theType)))
|
||||
if (aNode.IsNull() == Standard_False)
|
||||
// The node data are read here, including the final closing brace
|
||||
aStatus = aNode->Read(theBuffer);
|
||||
@@ -316,60 +286,53 @@ VrmlData_ErrorStatus VrmlData_Node::ReadNode
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_ShapeNode::Clone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_ShapeNode::Clone
|
||||
(const Handle(VrmlData_Node)& theOther) const
|
||||
Handle(VrmlData_Node) VrmlData_ShapeNode::Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
{
|
||||
Handle(VrmlData_ShapeNode) aResult =
|
||||
Handle(VrmlData_ShapeNode)::DownCast (VrmlData_Node::Clone(theOther));
|
||||
Handle(VrmlData_ShapeNode)::DownCast(VrmlData_Node::Clone(theOther));
|
||||
if (aResult.IsNull())
|
||||
aResult= new VrmlData_ShapeNode(theOther.IsNull()?Scene():theOther->Scene(),
|
||||
Name());
|
||||
if (&aResult->Scene() == &Scene()) {
|
||||
aResult->SetAppearance (myAppearance);
|
||||
aResult->SetGeometry (myGeometry);
|
||||
} else {
|
||||
aResult = new VrmlData_ShapeNode(theOther.IsNull() ? Scene() : theOther->Scene(), Name());
|
||||
if (&aResult->Scene() == &Scene())
|
||||
{
|
||||
aResult->SetAppearance(myAppearance);
|
||||
aResult->SetGeometry(myGeometry);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a dummy node to pass the different Scene instance to methods Clone
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode =
|
||||
new VrmlData_UnknownNode (aResult->Scene());
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode = new VrmlData_UnknownNode(aResult->Scene());
|
||||
if (myAppearance.IsNull() == Standard_False)
|
||||
aResult->SetAppearance(Handle(VrmlData_Appearance)::DownCast
|
||||
(myAppearance->Clone (aDummyNode)));
|
||||
aResult->SetAppearance(
|
||||
Handle(VrmlData_Appearance)::DownCast(myAppearance->Clone(aDummyNode)));
|
||||
if (myGeometry.IsNull() == Standard_False)
|
||||
aResult->SetGeometry (Handle(VrmlData_Geometry)::DownCast
|
||||
(myGeometry->Clone (aDummyNode)));
|
||||
aResult->SetGeometry(Handle(VrmlData_Geometry)::DownCast(myGeometry->Clone(aDummyNode)));
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_ShapeNode::Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_ShapeNode::Read (VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_ShapeNode::Read(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "appearance"))
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "appearance"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode,
|
||||
STANDARD_TYPE(VrmlData_Appearance));
|
||||
myAppearance = Handle(VrmlData_Appearance)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode, STANDARD_TYPE(VrmlData_Appearance));
|
||||
myAppearance = Handle(VrmlData_Appearance)::DownCast(aNode);
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "geometry"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "geometry"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode);
|
||||
myGeometry = Handle(VrmlData_Geometry)::DownCast (aNode);
|
||||
// here we do not check for the Geometry type because unknown node types can
|
||||
// occur (IndexedLineSet, etc.)
|
||||
// STANDARD_TYPE(VrmlData_Geometry));
|
||||
aStatus = ReadNode(theBuffer, aNode);
|
||||
myGeometry = Handle(VrmlData_Geometry)::DownCast(aNode);
|
||||
// here we do not check for the Geometry type because unknown node types can
|
||||
// occur (IndexedLineSet, etc.)
|
||||
// STANDARD_TYPE(VrmlData_Geometry));
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -380,67 +343,61 @@ VrmlData_ErrorStatus VrmlData_ShapeNode::Read (VrmlData_InBuffer& theBuffer)
|
||||
|
||||
// Read the terminating (closing) brace
|
||||
if (OK(aStatus))
|
||||
aStatus = readBrace (theBuffer);
|
||||
aStatus = readBrace(theBuffer);
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_ShapeNode::Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_ShapeNode::Write (const char * thePrefix) const
|
||||
VrmlData_ErrorStatus VrmlData_ShapeNode::Write(const char* thePrefix) const
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus (VrmlData_StatusOK);
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
static char header[] = "Shape {";
|
||||
if (OK (aStatus, aScene.WriteLine (thePrefix, header, GlobalIndent())))
|
||||
VrmlData_ErrorStatus aStatus(VrmlData_StatusOK);
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
static char header[] = "Shape {";
|
||||
if (OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent())))
|
||||
{
|
||||
if (myAppearance.IsNull() == Standard_False)
|
||||
aStatus = aScene.WriteNode ("appearance", myAppearance);
|
||||
aStatus = aScene.WriteNode("appearance", myAppearance);
|
||||
if (myGeometry.IsNull() == Standard_False && OK(aStatus))
|
||||
aStatus = aScene.WriteNode ("geometry", myGeometry);
|
||||
aStatus = aScene.WriteNode("geometry", myGeometry);
|
||||
|
||||
aStatus = WriteClosing();
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_ShapeNode::IsDefault
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean VrmlData_ShapeNode::IsDefault () const
|
||||
Standard_Boolean VrmlData_ShapeNode::IsDefault() const
|
||||
{
|
||||
Standard_Boolean aResult (Standard_True);
|
||||
Standard_Boolean aResult(Standard_True);
|
||||
if (myGeometry.IsNull() == Standard_False)
|
||||
aResult = myGeometry->IsDefault();
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_UnknownNode::Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_UnknownNode::Read (VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_UnknownNode::Read(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus = VrmlData_StatusOK;
|
||||
Standard_Integer aLevelCounter (0);
|
||||
Standard_Integer aLevelCounter(0);
|
||||
// This loop searches for any opening brace.
|
||||
// Such brace increments the level counter. A closing brace decrements
|
||||
// the counter. The loop terminates when the counter becomes negative.
|
||||
while (aLevelCounter >= 0 &&
|
||||
OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
while (aLevelCounter >= 0 && OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
int aChar;
|
||||
while ((aChar = theBuffer.LinePtr[0]) != '\0') {
|
||||
while ((aChar = theBuffer.LinePtr[0]) != '\0')
|
||||
{
|
||||
theBuffer.LinePtr++;
|
||||
if (aChar == '{') {
|
||||
if (aChar == '{')
|
||||
{
|
||||
aLevelCounter++;
|
||||
break;
|
||||
} else if (aChar == '}') {
|
||||
}
|
||||
else if (aChar == '}')
|
||||
{
|
||||
aLevelCounter--;
|
||||
break;
|
||||
}
|
||||
@@ -449,79 +406,67 @@ VrmlData_ErrorStatus VrmlData_UnknownNode::Read (VrmlData_InBuffer& theBuffer)
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_UnknownNode::IsDefault
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean VrmlData_UnknownNode::IsDefault () const
|
||||
Standard_Boolean VrmlData_UnknownNode::IsDefault() const
|
||||
{
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Appearance::Clone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_Appearance::Clone
|
||||
(const Handle(VrmlData_Node)& theOther) const
|
||||
Handle(VrmlData_Node) VrmlData_Appearance::Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
{
|
||||
Handle(VrmlData_Appearance) aResult =
|
||||
Handle(VrmlData_Appearance)::DownCast (VrmlData_Node::Clone(theOther));
|
||||
Handle(VrmlData_Appearance)::DownCast(VrmlData_Node::Clone(theOther));
|
||||
if (aResult.IsNull())
|
||||
aResult = new VrmlData_Appearance
|
||||
(theOther.IsNull() ? Scene() : theOther->Scene(), Name());
|
||||
if (&aResult->Scene() == &Scene()) {
|
||||
aResult->SetMaterial (myMaterial);
|
||||
aResult->SetTexture (myTexture);
|
||||
aResult->SetTextureTransform (myTTransform);
|
||||
} else {
|
||||
aResult = new VrmlData_Appearance(theOther.IsNull() ? Scene() : theOther->Scene(), Name());
|
||||
if (&aResult->Scene() == &Scene())
|
||||
{
|
||||
aResult->SetMaterial(myMaterial);
|
||||
aResult->SetTexture(myTexture);
|
||||
aResult->SetTextureTransform(myTTransform);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Create a dummy node to pass the different Scene instance to methods Clone
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode =
|
||||
new VrmlData_UnknownNode (aResult->Scene());
|
||||
if (myMaterial.IsNull() == Standard_False)
|
||||
aResult->SetMaterial (Handle(VrmlData_Material)::DownCast
|
||||
(myMaterial->Clone (aDummyNode)));
|
||||
if (myTexture.IsNull() == Standard_False)
|
||||
aResult->SetTexture(Handle(VrmlData_Texture)::DownCast
|
||||
(myTexture->Clone (aDummyNode)));
|
||||
const Handle(VrmlData_UnknownNode) aDummyNode = new VrmlData_UnknownNode(aResult->Scene());
|
||||
if (myMaterial.IsNull() == Standard_False)
|
||||
aResult->SetMaterial(Handle(VrmlData_Material)::DownCast(myMaterial->Clone(aDummyNode)));
|
||||
if (myTexture.IsNull() == Standard_False)
|
||||
aResult->SetTexture(Handle(VrmlData_Texture)::DownCast(myTexture->Clone(aDummyNode)));
|
||||
if (myTTransform.IsNull() == Standard_False)
|
||||
aResult->SetTextureTransform(Handle(VrmlData_TextureTransform)::DownCast
|
||||
(myTTransform->Clone (aDummyNode)));
|
||||
aResult->SetTextureTransform(
|
||||
Handle(VrmlData_TextureTransform)::DownCast(myTTransform->Clone(aDummyNode)));
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Appearance::Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Appearance::Read (VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_Appearance::Read(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "material"))
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "material"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode,
|
||||
STANDARD_TYPE(VrmlData_Material));
|
||||
myMaterial = Handle(VrmlData_Material)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode, STANDARD_TYPE(VrmlData_Material));
|
||||
myMaterial = Handle(VrmlData_Material)::DownCast(aNode);
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "textureTransform"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "textureTransform"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode
|
||||
/*,STANDARD_TYPE(VrmlData_TextureTransform)*/);
|
||||
myTTransform = Handle(VrmlData_TextureTransform)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode
|
||||
/*,STANDARD_TYPE(VrmlData_TextureTransform)*/);
|
||||
myTTransform = Handle(VrmlData_TextureTransform)::DownCast(aNode);
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "texture"))
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "texture"))
|
||||
{
|
||||
Handle(VrmlData_Node) aNode;
|
||||
aStatus = ReadNode (theBuffer, aNode,
|
||||
STANDARD_TYPE(VrmlData_Texture));
|
||||
myTexture = Handle(VrmlData_Texture)::DownCast (aNode);
|
||||
aStatus = ReadNode(theBuffer, aNode, STANDARD_TYPE(VrmlData_Texture));
|
||||
myTexture = Handle(VrmlData_Texture)::DownCast(aNode);
|
||||
}
|
||||
else
|
||||
break;
|
||||
@@ -532,42 +477,36 @@ VrmlData_ErrorStatus VrmlData_Appearance::Read (VrmlData_InBuffer& theBuffer)
|
||||
|
||||
// Read the terminating (closing) brace
|
||||
if (OK(aStatus))
|
||||
aStatus = readBrace (theBuffer);
|
||||
aStatus = readBrace(theBuffer);
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_Appearance::Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_Appearance::Write (const char * thePrefix) const
|
||||
VrmlData_ErrorStatus VrmlData_Appearance::Write(const char* thePrefix) const
|
||||
{
|
||||
static char header[] = "Appearance {";
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
static char header[] = "Appearance {";
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
if (OK (aStatus, aScene.WriteLine (thePrefix, header, GlobalIndent())))
|
||||
if (OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent())))
|
||||
{
|
||||
if (myMaterial.IsNull() == Standard_False)
|
||||
aStatus = aScene.WriteNode ("material", myMaterial);
|
||||
aStatus = aScene.WriteNode("material", myMaterial);
|
||||
if (myTexture.IsNull() == Standard_False && OK(aStatus))
|
||||
aStatus = aScene.WriteNode ("texture", myTexture);
|
||||
aStatus = aScene.WriteNode("texture", myTexture);
|
||||
if (myTTransform.IsNull() == Standard_False && OK(aStatus))
|
||||
aStatus = aScene.WriteNode ("textureTransform", myTTransform);
|
||||
aStatus = aScene.WriteNode("textureTransform", myTTransform);
|
||||
|
||||
aStatus = WriteClosing();
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDefault
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean VrmlData_Appearance::IsDefault () const
|
||||
Standard_Boolean VrmlData_Appearance::IsDefault() const
|
||||
{
|
||||
Standard_Boolean aResult (Standard_True);
|
||||
Standard_Boolean aResult(Standard_True);
|
||||
if (myMaterial.IsNull() == Standard_False)
|
||||
aResult = myMaterial->IsDefault();
|
||||
if (aResult && myTexture.IsNull() == Standard_False)
|
||||
@@ -577,93 +516,80 @@ Standard_Boolean VrmlData_Appearance::IsDefault () const
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_ImageTexture
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ImageTexture::VrmlData_ImageTexture (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const char * theURL,
|
||||
const Standard_Boolean theRepS,
|
||||
const Standard_Boolean theRepT)
|
||||
: VrmlData_Texture (theScene, theName, theRepS, theRepT),
|
||||
myURL (theScene.Allocator())
|
||||
VrmlData_ImageTexture::VrmlData_ImageTexture(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const char* theURL,
|
||||
const Standard_Boolean theRepS,
|
||||
const Standard_Boolean theRepT)
|
||||
: VrmlData_Texture(theScene, theName, theRepS, theRepT),
|
||||
myURL(theScene.Allocator())
|
||||
{
|
||||
myURL.Append (theURL ? (Standard_CString)theURL : "");
|
||||
myURL.Append(theURL ? (Standard_CString)theURL : "");
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_ImageTexture::Clone
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_ImageTexture::Clone
|
||||
(const Handle(VrmlData_Node)& theOther) const
|
||||
Handle(VrmlData_Node) VrmlData_ImageTexture::Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
{
|
||||
Handle(VrmlData_ImageTexture) aResult =
|
||||
Handle(VrmlData_ImageTexture)::DownCast (VrmlData_Node::Clone(theOther));
|
||||
Handle(VrmlData_ImageTexture)::DownCast(VrmlData_Node::Clone(theOther));
|
||||
if (aResult.IsNull())
|
||||
aResult =
|
||||
new VrmlData_ImageTexture(theOther.IsNull() ? Scene() : theOther->Scene(),
|
||||
Name());
|
||||
aResult = new VrmlData_ImageTexture(theOther.IsNull() ? Scene() : theOther->Scene(), Name());
|
||||
aResult->myURL = myURL;
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_ImageTexture::Read
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_ImageTexture::Read (VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_ImageTexture::Read(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
Standard_Boolean aRepeatS (Standard_True), aRepeatT (Standard_True);
|
||||
Standard_Boolean aRepeatS(Standard_True), aRepeatT(Standard_True);
|
||||
myURL.Clear();
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "url"))
|
||||
aStatus = ReadMultiString (theBuffer, myURL);
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "repeatS"))
|
||||
aStatus = ReadBoolean (theBuffer, aRepeatS);
|
||||
else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "repeatT"))
|
||||
aStatus = ReadBoolean (theBuffer, aRepeatT);
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "url"))
|
||||
aStatus = ReadMultiString(theBuffer, myURL);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "repeatS"))
|
||||
aStatus = ReadBoolean(theBuffer, aRepeatS);
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "repeatT"))
|
||||
aStatus = ReadBoolean(theBuffer, aRepeatT);
|
||||
else
|
||||
break;
|
||||
|
||||
if (!OK(aStatus))
|
||||
break;
|
||||
}
|
||||
if (OK(aStatus) && OK(aStatus, readBrace (theBuffer))) {
|
||||
SetRepeatS (aRepeatS);
|
||||
SetRepeatT (aRepeatT);
|
||||
if (OK(aStatus) && OK(aStatus, readBrace(theBuffer)))
|
||||
{
|
||||
SetRepeatS(aRepeatS);
|
||||
SetRepeatT(aRepeatT);
|
||||
}
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_ImageTexture::Write(const char *thePrefix) const
|
||||
VrmlData_ErrorStatus VrmlData_ImageTexture::Write(const char* thePrefix) const
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus = VrmlData_StatusOK;
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
static char header[] = "ImageTexture {";
|
||||
if (aScene.IsDummyWrite() == Standard_False &&
|
||||
OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent())))
|
||||
VrmlData_ErrorStatus aStatus = VrmlData_StatusOK;
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
static char header[] = "ImageTexture {";
|
||||
if (aScene.IsDummyWrite() == Standard_False
|
||||
&& OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent())))
|
||||
{
|
||||
TCollection_AsciiString url = "\"";
|
||||
url += URL().First();
|
||||
url += "\"";
|
||||
|
||||
try {
|
||||
try
|
||||
{
|
||||
aStatus = aScene.WriteLine("url ", url.ToCString());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
|
||||
}
|
||||
aStatus = WriteClosing();
|
||||
}
|
||||
|
@@ -23,8 +23,7 @@
|
||||
#include <Standard_CStringHasher.hxx>
|
||||
#include <VrmlData_ErrorStatus.hxx>
|
||||
|
||||
#define VRMLDATA_LCOMPARE(aa, bb) \
|
||||
((strncmp (aa, bb, sizeof(bb)-1)) ? 0L : (aa += sizeof(bb)-1))
|
||||
#define VRMLDATA_LCOMPARE(aa, bb) ((strncmp(aa, bb, sizeof(bb) - 1)) ? 0L : (aa += sizeof(bb) - 1))
|
||||
|
||||
struct VrmlData_InBuffer;
|
||||
class VrmlData_Scene;
|
||||
@@ -35,29 +34,28 @@ class TCollection_AsciiString;
|
||||
*/
|
||||
class VrmlData_Node : public Standard_Transient
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
Standard_EXPORT VrmlData_Node ();
|
||||
Standard_EXPORT VrmlData_Node();
|
||||
|
||||
/**
|
||||
* Destructor
|
||||
*/
|
||||
virtual ~VrmlData_Node () {}
|
||||
virtual ~VrmlData_Node() {}
|
||||
|
||||
/**
|
||||
* Query the Scene that contains this Node
|
||||
*/
|
||||
inline const VrmlData_Scene& Scene () const
|
||||
{ return * myScene; }
|
||||
inline const VrmlData_Scene& Scene() const { return *myScene; }
|
||||
|
||||
/**
|
||||
* Query the name
|
||||
*/
|
||||
inline const char * Name () const { return myName; }
|
||||
inline const char* Name() const { return myName; }
|
||||
|
||||
/**
|
||||
* Read a complete node definition from VRML stream
|
||||
@@ -70,35 +68,29 @@ class VrmlData_Node : public Standard_Transient
|
||||
* Otherwise the created node is matched and an error is returned if
|
||||
* no match detected.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
ReadNode (VrmlData_InBuffer& theBuffer,
|
||||
Handle(VrmlData_Node)&theNode,
|
||||
const Handle(Standard_Type)& Type
|
||||
= NULL);
|
||||
Standard_EXPORT VrmlData_ErrorStatus ReadNode(VrmlData_InBuffer& theBuffer,
|
||||
Handle(VrmlData_Node)& theNode,
|
||||
const Handle(Standard_Type)& Type = NULL);
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) = 0;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) = 0;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const;
|
||||
|
||||
/**
|
||||
* Returns True if the node is default, then it would not be written.
|
||||
*/
|
||||
Standard_EXPORT virtual Standard_Boolean
|
||||
IsDefault () const;
|
||||
Standard_EXPORT virtual Standard_Boolean IsDefault() const;
|
||||
|
||||
/**
|
||||
* Write the closing brace in the end of a node output.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
WriteClosing () const;
|
||||
Standard_EXPORT VrmlData_ErrorStatus WriteClosing() const;
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
@@ -107,126 +99,120 @@ class VrmlData_Node : public Standard_Transient
|
||||
* This method nullifies the argument node if its member myScene differs
|
||||
* from that one of the current instance.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)&)const;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)&) const;
|
||||
|
||||
/**
|
||||
* Read one boolean value (TRUE or FALSE).
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus
|
||||
ReadBoolean (VrmlData_InBuffer& theBuffer,
|
||||
Standard_Boolean& theResult);
|
||||
Standard_EXPORT static VrmlData_ErrorStatus ReadBoolean(VrmlData_InBuffer& theBuffer,
|
||||
Standard_Boolean& theResult);
|
||||
|
||||
/**
|
||||
* Read one quoted string, the quotes are removed.
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus
|
||||
ReadString (VrmlData_InBuffer& theBuffer,
|
||||
TCollection_AsciiString& theRes);
|
||||
Standard_EXPORT static VrmlData_ErrorStatus ReadString(VrmlData_InBuffer& theBuffer,
|
||||
TCollection_AsciiString& theRes);
|
||||
|
||||
/**
|
||||
* Read one quoted string, the quotes are removed.
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus
|
||||
ReadMultiString
|
||||
(VrmlData_InBuffer& theBuffer,
|
||||
NCollection_List<TCollection_AsciiString>& theRes);
|
||||
Standard_EXPORT static VrmlData_ErrorStatus ReadMultiString(
|
||||
VrmlData_InBuffer& theBuffer,
|
||||
NCollection_List<TCollection_AsciiString>& theRes);
|
||||
|
||||
/**
|
||||
* Read one integer value.
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus
|
||||
ReadInteger (VrmlData_InBuffer& theBuffer,
|
||||
long& theResult);
|
||||
Standard_EXPORT static VrmlData_ErrorStatus ReadInteger(VrmlData_InBuffer& theBuffer,
|
||||
long& theResult);
|
||||
|
||||
static inline Standard_Boolean OK (const VrmlData_ErrorStatus theStat)
|
||||
{ return theStat == VrmlData_StatusOK; }
|
||||
static inline Standard_Boolean OK(const VrmlData_ErrorStatus theStat)
|
||||
{
|
||||
return theStat == VrmlData_StatusOK;
|
||||
}
|
||||
|
||||
static inline Standard_Boolean OK (VrmlData_ErrorStatus& outStat,
|
||||
const VrmlData_ErrorStatus theStat)
|
||||
{ return (outStat = theStat) == VrmlData_StatusOK; }
|
||||
static inline Standard_Boolean OK(VrmlData_ErrorStatus& outStat,
|
||||
const VrmlData_ErrorStatus theStat)
|
||||
{
|
||||
return (outStat = theStat) == VrmlData_StatusOK;
|
||||
}
|
||||
|
||||
/**
|
||||
* Define the common Indent in spaces, for writing all nodes.
|
||||
*/
|
||||
static inline Standard_Integer GlobalIndent ()
|
||||
{ return 2; }
|
||||
*/
|
||||
static inline Standard_Integer GlobalIndent() { return 2; }
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
Standard_EXPORT VrmlData_Node (const VrmlData_Scene& theScene,
|
||||
const char * theName);
|
||||
Standard_EXPORT VrmlData_Node(const VrmlData_Scene& theScene, const char* theName);
|
||||
|
||||
/**
|
||||
* Read the closing brace. If successful, theBufrfer is incremented.
|
||||
* If no brace is found, theBuffer stays in untouched and the method returns
|
||||
* VrmlFormatError.
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus
|
||||
readBrace (VrmlData_InBuffer& theBuffer);
|
||||
Standard_EXPORT static VrmlData_ErrorStatus readBrace(VrmlData_InBuffer& theBuffer);
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE METHODS ----------
|
||||
|
||||
/**
|
||||
* Method called from VrmlData_Scene when a name should be assigned
|
||||
* automatically.
|
||||
*/
|
||||
Standard_EXPORT void setName (const char * theName,
|
||||
const char * theSuffix = 0L);
|
||||
Standard_EXPORT void setName(const char* theName, const char* theSuffix = 0L);
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
const VrmlData_Scene * myScene;
|
||||
const char * myName; ///< name of the node
|
||||
const VrmlData_Scene* myScene;
|
||||
const char* myName; ///< name of the node
|
||||
#ifdef OCCT_DEBUG
|
||||
Standard_Integer myLineCount;
|
||||
Standard_Integer myLineCount;
|
||||
#endif
|
||||
|
||||
friend class VrmlData_Group;
|
||||
friend class VrmlData_Scene;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_Node,Standard_Transient)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_Node, Standard_Transient)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Node, Standard_Transient)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Node, Standard_Transient)
|
||||
|
||||
Standard_EXPORT Standard_Boolean IsEqual(const Handle(VrmlData_Node)& theOne,
|
||||
const Handle(VrmlData_Node)& theTwo);
|
||||
|
||||
namespace std
|
||||
{
|
||||
template <>
|
||||
struct hash<Handle(VrmlData_Node)>
|
||||
template <>
|
||||
struct hash<Handle(VrmlData_Node)>
|
||||
{
|
||||
size_t operator()(const Handle(VrmlData_Node)& theNode) const
|
||||
{
|
||||
size_t operator()(const Handle(VrmlData_Node)& theNode) const
|
||||
if (!theNode->Name())
|
||||
{
|
||||
if (!theNode->Name())
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
return Standard_CStringHasher{}(theNode->Name());
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
return Standard_CStringHasher{}(theNode->Name());
|
||||
}
|
||||
};
|
||||
|
||||
template<>
|
||||
struct equal_to<Handle(VrmlData_Node)>
|
||||
template <>
|
||||
struct equal_to<Handle(VrmlData_Node)>
|
||||
{
|
||||
bool operator()(const Handle(VrmlData_Node)& theNode1,
|
||||
const Handle(VrmlData_Node)& theNode2) const noexcept
|
||||
{
|
||||
bool operator()(const Handle(VrmlData_Node)& theNode1,
|
||||
const Handle(VrmlData_Node)& theNode2) const noexcept
|
||||
{
|
||||
return IsEqual(theNode1, theNode2);
|
||||
}
|
||||
};
|
||||
}
|
||||
return IsEqual(theNode1, theNode2);
|
||||
}
|
||||
};
|
||||
} // namespace std
|
||||
|
||||
#endif
|
||||
|
@@ -23,23 +23,24 @@
|
||||
*/
|
||||
class VrmlData_Normal : public VrmlData_ArrayVec3d
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Normal () {}
|
||||
inline VrmlData_Normal() {}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_Normal (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const size_t nVec = 0,
|
||||
const gp_XYZ * arrVec = 0L)
|
||||
: VrmlData_ArrayVec3d (theScene, theName, nVec, arrVec)
|
||||
{}
|
||||
inline VrmlData_Normal(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const size_t nVec = 0,
|
||||
const gp_XYZ* arrVec = 0L)
|
||||
: VrmlData_ArrayVec3d(theScene, theName, nVec, arrVec)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query one normal
|
||||
@@ -48,41 +49,35 @@ class VrmlData_Normal : public VrmlData_ArrayVec3d
|
||||
* @return
|
||||
* the normal value for the index. If index irrelevant, returns (0., 0., 0.)
|
||||
*/
|
||||
inline const gp_XYZ& Normal (const Standard_Integer i) const
|
||||
{ return Value(i); }
|
||||
inline const gp_XYZ& Normal(const Standard_Integer i) const { return Value(i); }
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to the Scene output.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Normal,VrmlData_ArrayVec3d)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Normal, VrmlData_ArrayVec3d)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Normal, VrmlData_ArrayVec3d)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Normal, VrmlData_ArrayVec3d)
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -39,9 +39,9 @@ struct VrmlData_InBuffer;
|
||||
* Block of comments describing class VrmlData_Scene
|
||||
*/
|
||||
|
||||
class VrmlData_Scene
|
||||
class VrmlData_Scene
|
||||
{
|
||||
public:
|
||||
public:
|
||||
/**
|
||||
* Iterator type to get all contained Nodes one-by-one.
|
||||
*/
|
||||
@@ -52,14 +52,13 @@ class VrmlData_Scene
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_Scene (const Handle(NCollection_IncAllocator)& = 0L);
|
||||
Standard_EXPORT VrmlData_Scene(const Handle(NCollection_IncAllocator)& = 0L);
|
||||
|
||||
/**
|
||||
* Query the status of the previous operation.
|
||||
* Normally it should be equal to VrmlData_StatusOK (no error).
|
||||
*/
|
||||
inline VrmlData_ErrorStatus Status () const
|
||||
{ return myStatus; }
|
||||
inline VrmlData_ErrorStatus Status() const { return myStatus; }
|
||||
|
||||
/**
|
||||
* Add the given directory path to the list of VRML file search directories.
|
||||
@@ -70,53 +69,47 @@ class VrmlData_Scene
|
||||
* ("."). It takes effect if the list is empty or if there is no match with
|
||||
* existing directories.
|
||||
*/
|
||||
Standard_EXPORT void SetVrmlDir (const TCollection_ExtendedString&);
|
||||
Standard_EXPORT void SetVrmlDir(const TCollection_ExtendedString&);
|
||||
|
||||
/**
|
||||
* Set the scale factor that would be further used in methods
|
||||
* ReadReal, ReadXYZ and ReadXY. All coordinates, distances and sized are
|
||||
* multiplied by this factor during reading the data.
|
||||
*/
|
||||
inline void SetLinearScale (const Standard_Real theScale)
|
||||
{ myLinearScale = theScale; }
|
||||
inline void SetLinearScale(const Standard_Real theScale) { myLinearScale = theScale; }
|
||||
|
||||
/**
|
||||
* Returns the directory iterator, to check the presence of requested VRML
|
||||
* file in each iterated directory.
|
||||
*/
|
||||
inline NCollection_List<TCollection_ExtendedString>::Iterator
|
||||
VrmlDirIterator () const
|
||||
{ return NCollection_List<TCollection_ExtendedString>::Iterator(myVrmlDir); }
|
||||
inline NCollection_List<TCollection_ExtendedString>::Iterator VrmlDirIterator() const
|
||||
{
|
||||
return NCollection_List<TCollection_ExtendedString>::Iterator(myVrmlDir);
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterator of Nodes
|
||||
*/
|
||||
inline Iterator GetIterator () const
|
||||
{ return Iterator (myLstNodes); }
|
||||
inline Iterator GetIterator() const { return Iterator(myLstNodes); }
|
||||
|
||||
/**
|
||||
* Get the iterator of named nodes.
|
||||
*/
|
||||
inline VrmlData_MapOfNode::Iterator
|
||||
NamedNodesIterator() const
|
||||
{ return myNamedNodes; }
|
||||
inline VrmlData_MapOfNode::Iterator NamedNodesIterator() const { return myNamedNodes; }
|
||||
|
||||
/**
|
||||
* Allocator used by all nodes contained in the Scene.
|
||||
*/
|
||||
inline const Handle(NCollection_IncAllocator)&
|
||||
Allocator () const
|
||||
{ return myAllocator; }
|
||||
inline const Handle(NCollection_IncAllocator)& Allocator() const { return myAllocator; }
|
||||
|
||||
/**
|
||||
* Add a Node. If theN belongs to another Scene, it is cloned.
|
||||
* <p>VrmlData_WorldInfo cannot be added, in this case the method
|
||||
* returns a NULL handle.
|
||||
*/
|
||||
Standard_EXPORT const Handle(VrmlData_Node)&
|
||||
AddNode (const Handle(VrmlData_Node)& theN,
|
||||
const Standard_Boolean isTopLevel
|
||||
= Standard_True);
|
||||
Standard_EXPORT const Handle(VrmlData_Node)& AddNode(
|
||||
const Handle(VrmlData_Node)& theN,
|
||||
const Standard_Boolean isTopLevel = Standard_True);
|
||||
|
||||
/**
|
||||
* Find a node by its name.
|
||||
@@ -127,10 +120,8 @@ class VrmlData_Scene
|
||||
* given name is returned. If theType is given, only the node that has
|
||||
* that type is returned.
|
||||
*/
|
||||
Standard_EXPORT Handle(VrmlData_Node)
|
||||
FindNode (const char * theName,
|
||||
const Handle(Standard_Type)&
|
||||
theType = 0L) const;
|
||||
Standard_EXPORT Handle(VrmlData_Node) FindNode(const char* theName,
|
||||
const Handle(Standard_Type)& theType = 0L) const;
|
||||
|
||||
/**
|
||||
* Find a node by its name.
|
||||
@@ -139,9 +130,7 @@ class VrmlData_Scene
|
||||
* @param theLocation
|
||||
* Location of the found node with respect to the whole VRML shape.
|
||||
*/
|
||||
Standard_EXPORT Handle(VrmlData_Node)
|
||||
FindNode(const char * theName,
|
||||
gp_Trsf& theLocation) const;
|
||||
Standard_EXPORT Handle(VrmlData_Node) FindNode(const char* theName, gp_Trsf& theLocation) const;
|
||||
|
||||
/**
|
||||
* Export to text stream (file or else).
|
||||
@@ -151,11 +140,10 @@ class VrmlData_Scene
|
||||
* <code>
|
||||
* #VRML V2.0 <encoding type> [optional comment] <line terminator>
|
||||
* </code>
|
||||
*
|
||||
*
|
||||
*/
|
||||
friend Standard_EXPORT Standard_OStream&
|
||||
operator << (Standard_OStream& theOutput,
|
||||
const VrmlData_Scene& theScene);
|
||||
friend Standard_EXPORT Standard_OStream& operator<<(Standard_OStream& theOutput,
|
||||
const VrmlData_Scene& theScene);
|
||||
|
||||
/**
|
||||
* Import from text stream (file or else).
|
||||
@@ -167,7 +155,7 @@ class VrmlData_Scene
|
||||
/**
|
||||
* Convert the scene to a Shape.
|
||||
*/
|
||||
Standard_EXPORT operator TopoDS_Shape () const;
|
||||
Standard_EXPORT operator TopoDS_Shape() const;
|
||||
|
||||
/**
|
||||
* Convert the scene to a Shape, with the information on materials defined
|
||||
@@ -181,13 +169,12 @@ class VrmlData_Scene
|
||||
* TopoDS_Shape (Compound) holding all the scene, similar to the result of
|
||||
* explicit TopoDS_Shape conversion operator.
|
||||
*/
|
||||
Standard_EXPORT TopoDS_Shape GetShape (VrmlData_DataMapOfShapeAppearance& M);
|
||||
Standard_EXPORT TopoDS_Shape GetShape(VrmlData_DataMapOfShapeAppearance& M);
|
||||
|
||||
/**
|
||||
* Query the WorldInfo member.
|
||||
*/
|
||||
Standard_EXPORT const Handle(VrmlData_WorldInfo)&
|
||||
WorldInfo() const;
|
||||
Standard_EXPORT const Handle(VrmlData_WorldInfo)& WorldInfo() const;
|
||||
|
||||
/**
|
||||
* Read a VRML line. Empty lines and comments are skipped.
|
||||
@@ -201,71 +188,60 @@ class VrmlData_Scene
|
||||
* @param theLen
|
||||
* Length of the input buffer (maximal line length)
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus
|
||||
ReadLine (VrmlData_InBuffer& theBuffer);
|
||||
Standard_EXPORT static VrmlData_ErrorStatus ReadLine(VrmlData_InBuffer& theBuffer);
|
||||
|
||||
/**
|
||||
* Read a single word from the input stream, delimited by whitespace.
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus
|
||||
ReadWord (VrmlData_InBuffer& theBuffer,
|
||||
TCollection_AsciiString& theStr);
|
||||
Standard_EXPORT static VrmlData_ErrorStatus ReadWord(VrmlData_InBuffer& theBuffer,
|
||||
TCollection_AsciiString& theStr);
|
||||
|
||||
/**
|
||||
* Diagnostic dump of the contents
|
||||
*/
|
||||
Standard_EXPORT void Dump (Standard_OStream& theStream) const;
|
||||
Standard_EXPORT void Dump(Standard_OStream& theStream) const;
|
||||
|
||||
/**
|
||||
* Read one real value.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
ReadReal (VrmlData_InBuffer& theBuffer,
|
||||
Standard_Real& theResult,
|
||||
Standard_Boolean isApplyScale,
|
||||
Standard_Boolean isOnlyPositive)
|
||||
const;
|
||||
Standard_EXPORT VrmlData_ErrorStatus ReadReal(VrmlData_InBuffer& theBuffer,
|
||||
Standard_Real& theResult,
|
||||
Standard_Boolean isApplyScale,
|
||||
Standard_Boolean isOnlyPositive) const;
|
||||
|
||||
/**
|
||||
* Read one triplet of real values.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
ReadXYZ (VrmlData_InBuffer& theBuffer,
|
||||
gp_XYZ& theXYZ,
|
||||
Standard_Boolean isApplyScale,
|
||||
Standard_Boolean isOnlyPositive)
|
||||
const;
|
||||
Standard_EXPORT VrmlData_ErrorStatus ReadXYZ(VrmlData_InBuffer& theBuffer,
|
||||
gp_XYZ& theXYZ,
|
||||
Standard_Boolean isApplyScale,
|
||||
Standard_Boolean isOnlyPositive) const;
|
||||
|
||||
/**
|
||||
* Read one doublet of real values.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
ReadXY (VrmlData_InBuffer& theBuffer,
|
||||
gp_XY& theXYZ,
|
||||
Standard_Boolean isApplyScale,
|
||||
Standard_Boolean isOnlyPositive)
|
||||
const;
|
||||
Standard_EXPORT VrmlData_ErrorStatus ReadXY(VrmlData_InBuffer& theBuffer,
|
||||
gp_XY& theXYZ,
|
||||
Standard_Boolean isApplyScale,
|
||||
Standard_Boolean isOnlyPositive) const;
|
||||
/**
|
||||
* Read an array of integer indices, for IndexedfaceSet and IndexedLineSet.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
ReadArrIndex(VrmlData_InBuffer& theBuffer,
|
||||
const Standard_Integer **& theArr,
|
||||
Standard_Size& theNBl)
|
||||
const;
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus ReadArrIndex(VrmlData_InBuffer& theBuffer,
|
||||
const Standard_Integer**& theArr,
|
||||
Standard_Size& theNBl) const;
|
||||
|
||||
/**
|
||||
* Query the line where the error occurred (if the status is not OK)
|
||||
*/
|
||||
inline Standard_Integer GetLineError() const { return myLineError; }
|
||||
inline Standard_Integer GetLineError() const { return myLineError; }
|
||||
|
||||
/**
|
||||
* Store the indentation for VRML output.
|
||||
* @param nSpc
|
||||
* number of spaces to insert at every indentation level
|
||||
*/
|
||||
inline void SetIndent (const Standard_Integer nSpc)
|
||||
{ myIndent = nSpc; }
|
||||
inline void SetIndent(const Standard_Integer nSpc) { myIndent = nSpc; }
|
||||
|
||||
/**
|
||||
* Write a triplet of real values on a separate line.
|
||||
@@ -276,20 +252,15 @@ class VrmlData_Scene
|
||||
* @param thePostfix
|
||||
* Optional string that is added before the end of the line.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
WriteXYZ (const gp_XYZ& theXYZ,
|
||||
const Standard_Boolean isScale,
|
||||
const char * thePostfix
|
||||
= 0L) const;
|
||||
Standard_EXPORT VrmlData_ErrorStatus WriteXYZ(const gp_XYZ& theXYZ,
|
||||
const Standard_Boolean isScale,
|
||||
const char* thePostfix = 0L) const;
|
||||
/**
|
||||
* Write an array of integer indices, for IndexedFaceSet and IndexedLineSet.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
WriteArrIndex(const char * thePrefix,
|
||||
const Standard_Integer ** theArr,
|
||||
const Standard_Size theNbBl)
|
||||
const;
|
||||
|
||||
Standard_EXPORT VrmlData_ErrorStatus WriteArrIndex(const char* thePrefix,
|
||||
const Standard_Integer** theArr,
|
||||
const Standard_Size theNbBl) const;
|
||||
|
||||
/**
|
||||
* Write a string to the output stream respecting the indentation. The string
|
||||
@@ -303,47 +274,41 @@ class VrmlData_Scene
|
||||
* @param theIndent
|
||||
* - 0 value ignored.
|
||||
* - negative decreases the current indent and then outputs.
|
||||
* - positive outputs and then increases the current indent.
|
||||
* - positive outputs and then increases the current indent.
|
||||
* @return
|
||||
* Error status of the stream, or a special error if myOutput == NULL.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
WriteLine (const char * theLine0,
|
||||
const char * theLine1=0L,
|
||||
const Standard_Integer theIndent
|
||||
= 0) const;
|
||||
Standard_EXPORT VrmlData_ErrorStatus WriteLine(const char* theLine0,
|
||||
const char* theLine1 = 0L,
|
||||
const Standard_Integer theIndent = 0) const;
|
||||
|
||||
/**
|
||||
* Write the given node to output stream 'myOutput'.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
WriteNode (const char * thePrefix,
|
||||
const Handle(VrmlData_Node)&) const;
|
||||
Standard_EXPORT VrmlData_ErrorStatus WriteNode(const char* thePrefix,
|
||||
const Handle(VrmlData_Node)&) const;
|
||||
|
||||
/**
|
||||
* Query if the current write operation is dummy, i.e., for the purpose of
|
||||
* collecting information before the real write is commenced.
|
||||
*/
|
||||
inline Standard_Boolean IsDummyWrite() const
|
||||
{ return myOutput == 0L; }
|
||||
inline Standard_Boolean IsDummyWrite() const { return myOutput == 0L; }
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE METHODS (PROHIBITED) ----------
|
||||
VrmlData_Scene (const VrmlData_Scene&);
|
||||
VrmlData_Scene& operator = (const VrmlData_Scene&);
|
||||
VrmlData_Scene(const VrmlData_Scene&);
|
||||
VrmlData_Scene& operator=(const VrmlData_Scene&);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
/**
|
||||
* Read whatever line from the input checking the std::istream flags.
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus
|
||||
readLine (VrmlData_InBuffer& theBuffer);
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus readLine(VrmlData_InBuffer& theBuffer);
|
||||
|
||||
/**
|
||||
* Read and verify the VRML header (the 1st line of the file)
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus
|
||||
readHeader (VrmlData_InBuffer& theBuffer);
|
||||
*/
|
||||
Standard_EXPORT static VrmlData_ErrorStatus readHeader(VrmlData_InBuffer& theBuffer);
|
||||
|
||||
/**
|
||||
* Create the node.
|
||||
@@ -356,51 +321,49 @@ class VrmlData_Scene
|
||||
* Otherwise the created node is matched and an error is returned if
|
||||
* no match detected.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_ErrorStatus
|
||||
createNode (VrmlData_InBuffer& theBuffer,
|
||||
Handle(VrmlData_Node)& theNode,
|
||||
const Handle(Standard_Type)& Type);
|
||||
Standard_EXPORT VrmlData_ErrorStatus createNode(VrmlData_InBuffer& theBuffer,
|
||||
Handle(VrmlData_Node)& theNode,
|
||||
const Handle(Standard_Type)& Type);
|
||||
|
||||
/**
|
||||
* Create a single Shape object from all geometric nodes in the list.
|
||||
*/
|
||||
Standard_EXPORT static void createShape (TopoDS_Shape& outShape,
|
||||
const VrmlData_ListOfNode&,
|
||||
VrmlData_DataMapOfShapeAppearance*);
|
||||
Standard_EXPORT static void createShape(TopoDS_Shape& outShape,
|
||||
const VrmlData_ListOfNode&,
|
||||
VrmlData_DataMapOfShapeAppearance*);
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
Standard_Real myLinearScale;
|
||||
VrmlData_ListOfNode myLstNodes; ///! top-level nodes
|
||||
VrmlData_ListOfNode myAllNodes; ///! all nodes
|
||||
VrmlData_ErrorStatus myStatus;
|
||||
Handle(NCollection_IncAllocator) myAllocator;
|
||||
Handle(VrmlData_WorldInfo) myWorldInfo;
|
||||
VrmlData_MapOfNode myNamedNodes;
|
||||
Standard_Real myLinearScale;
|
||||
VrmlData_ListOfNode myLstNodes; ///! top-level nodes
|
||||
VrmlData_ListOfNode myAllNodes; ///! all nodes
|
||||
VrmlData_ErrorStatus myStatus;
|
||||
Handle(NCollection_IncAllocator) myAllocator;
|
||||
Handle(VrmlData_WorldInfo) myWorldInfo;
|
||||
VrmlData_MapOfNode myNamedNodes;
|
||||
|
||||
// read from stream
|
||||
NCollection_List<TCollection_ExtendedString> myVrmlDir;
|
||||
Standard_Mutex myMutex;
|
||||
Standard_Integer myLineError;///! #0 if error
|
||||
NCollection_List<TCollection_ExtendedString> myVrmlDir;
|
||||
Standard_Mutex myMutex;
|
||||
Standard_Integer myLineError; ///! #0 if error
|
||||
|
||||
// write to stream
|
||||
Standard_OStream * myOutput;
|
||||
Standard_Integer myIndent;
|
||||
Standard_Integer myCurrentIndent;
|
||||
Standard_OStream* myOutput;
|
||||
Standard_Integer myIndent;
|
||||
Standard_Integer myCurrentIndent;
|
||||
/**
|
||||
* This map is used to avoid multiple storage of the same named node: each
|
||||
* named node is added here when it is written the first time.
|
||||
*/
|
||||
VrmlData_MapOfNode myNamedNodesOut;
|
||||
VrmlData_MapOfNode myNamedNodesOut;
|
||||
/**
|
||||
* This map allows to resolve multiple reference to any unnamed node. It
|
||||
* is used during the dummy write (myOutput == 0L). When a node is processed
|
||||
* the first time it is added to this map, the second time it is automatically
|
||||
* assigned a name.
|
||||
*/
|
||||
NCollection_Map<Standard_Address> myUnnamedNodesOut;
|
||||
Standard_Integer myAutoNameCounter;
|
||||
NCollection_Map<Standard_Address> myUnnamedNodesOut;
|
||||
Standard_Integer myAutoNameCounter;
|
||||
friend class VrmlData_Group;
|
||||
friend class VrmlData_Node;
|
||||
};
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -31,16 +31,15 @@ class XCAFPrs_Style;
|
||||
class TDocStd_Document;
|
||||
class TDF_Label;
|
||||
|
||||
|
||||
/**
|
||||
* Algorithm converting one shape or a set of shapes to VrmlData_Scene.
|
||||
*/
|
||||
|
||||
class VrmlData_ShapeConvert
|
||||
class VrmlData_ShapeConvert
|
||||
{
|
||||
public:
|
||||
|
||||
typedef struct {
|
||||
public:
|
||||
typedef struct
|
||||
{
|
||||
TCollection_AsciiString Name;
|
||||
TopoDS_Shape Shape;
|
||||
Handle(VrmlData_Node) Node;
|
||||
@@ -48,7 +47,6 @@ class VrmlData_ShapeConvert
|
||||
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param theScene
|
||||
@@ -57,95 +55,92 @@ class VrmlData_ShapeConvert
|
||||
* Scale factor, considering that VRML standard specifies coordinates in
|
||||
* meters. So if your data are in mm, you should provide theScale=0.001
|
||||
*/
|
||||
inline VrmlData_ShapeConvert (VrmlData_Scene& theScene,
|
||||
const Standard_Real theScale = 1.)
|
||||
: myScene (theScene),
|
||||
myScale (theScale),
|
||||
myDeflection(0.0),
|
||||
myDeflAngle(0.0)
|
||||
{}
|
||||
inline VrmlData_ShapeConvert(VrmlData_Scene& theScene, const Standard_Real theScale = 1.)
|
||||
: myScene(theScene),
|
||||
myScale(theScale),
|
||||
myDeflection(0.0),
|
||||
myDeflAngle(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Add one shape to the internal list, may be called several times with
|
||||
* different shapes.
|
||||
*/
|
||||
Standard_EXPORT void AddShape (const TopoDS_Shape& theShape,
|
||||
const char * theName = 0L);
|
||||
Standard_EXPORT void AddShape(const TopoDS_Shape& theShape, const char* theName = 0L);
|
||||
|
||||
/**
|
||||
* Convert all accumulated shapes and store them in myScene.
|
||||
* The internal data structures are cleared in the end of conversion.
|
||||
* @param theExtractFaces
|
||||
* If True, converter extracst faces from the shapes.
|
||||
* If True, converter extracst faces from the shapes.
|
||||
* @param theExtractEdges
|
||||
* If True, converter extracts edges from the shapes.
|
||||
* @param theDeflection
|
||||
* @param theDeflection
|
||||
* Deflection for tessellation of geometrical lines/surfaces. Existing mesh
|
||||
* is used if its deflection is smaller than the one given by this
|
||||
* parameter.
|
||||
* @param theDeflAngle
|
||||
* Angular deflection for tessellation of geometrical lines.
|
||||
* @param theDeflAngle
|
||||
* Angular deflection for tessellation of geometrical lines.
|
||||
*/
|
||||
Standard_EXPORT void Convert (const Standard_Boolean theExtractFaces,
|
||||
const Standard_Boolean theExtractEdges,
|
||||
const Standard_Real theDeflection = 0.01,
|
||||
const Standard_Real theDeflAngle = 20.*M_PI/180.);
|
||||
//this value of theDeflAngle is used by default
|
||||
//for tesselation while shading (Drawer->HLRAngle())
|
||||
Standard_EXPORT void Convert(const Standard_Boolean theExtractFaces,
|
||||
const Standard_Boolean theExtractEdges,
|
||||
const Standard_Real theDeflection = 0.01,
|
||||
const Standard_Real theDeflAngle = 20. * M_PI / 180.);
|
||||
// this value of theDeflAngle is used by default
|
||||
// for tesselation while shading (Drawer->HLRAngle())
|
||||
|
||||
/**
|
||||
* Add all shapes start from given document with colors and names to the internal structure
|
||||
*/
|
||||
Standard_EXPORT void ConvertDocument(const Handle(TDocStd_Document)& theDoc);
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
Handle(VrmlData_Geometry) triToIndexedFaceSet
|
||||
(const Handle(Poly_Triangulation)&,
|
||||
const TopoDS_Face&,
|
||||
const Handle(VrmlData_Coordinate)&);
|
||||
Handle(VrmlData_Geometry) triToIndexedFaceSet(const Handle(Poly_Triangulation)&,
|
||||
const TopoDS_Face&,
|
||||
const Handle(VrmlData_Coordinate)&);
|
||||
|
||||
Handle(VrmlData_Geometry) polToIndexedLineSet
|
||||
(const Handle(Poly_Polygon3D)&);
|
||||
Handle(VrmlData_Geometry) polToIndexedLineSet(const Handle(Poly_Polygon3D)&);
|
||||
|
||||
Handle(VrmlData_Appearance) defaultMaterialFace () const;
|
||||
Handle(VrmlData_Appearance) defaultMaterialFace() const;
|
||||
|
||||
Handle(VrmlData_Appearance) defaultMaterialEdge () const;
|
||||
Handle(VrmlData_Appearance) defaultMaterialEdge() const;
|
||||
|
||||
Handle(VrmlData_Geometry) makeTShapeNode(const TopoDS_Shape& theShape,
|
||||
Handle(VrmlData_Geometry) makeTShapeNode(const TopoDS_Shape& theShape,
|
||||
const TopAbs_ShapeEnum theShapeType,
|
||||
TopLoc_Location& theLoc);
|
||||
TopLoc_Location& theLoc);
|
||||
|
||||
void addAssembly (const Handle(VrmlData_Group)& theParent,
|
||||
const TDF_Label& theLabel,
|
||||
const Handle(TDocStd_Document)& theDoc,
|
||||
const Standard_Boolean theNeedCreateGroup);
|
||||
void addAssembly(const Handle(VrmlData_Group)& theParent,
|
||||
const TDF_Label& theLabel,
|
||||
const Handle(TDocStd_Document)& theDoc,
|
||||
const Standard_Boolean theNeedCreateGroup);
|
||||
|
||||
void addInstance (const Handle(VrmlData_Group)& theParent,
|
||||
const TDF_Label& theLabel,
|
||||
const Handle(TDocStd_Document)& theDoc);
|
||||
void addInstance(const Handle(VrmlData_Group)& theParent,
|
||||
const TDF_Label& theLabel,
|
||||
const Handle(TDocStd_Document)& theDoc);
|
||||
|
||||
void addShape (const Handle(VrmlData_Group)& theParent,
|
||||
const TDF_Label& theLabel,
|
||||
const Handle(TDocStd_Document)& theDoc);
|
||||
void addShape(const Handle(VrmlData_Group)& theParent,
|
||||
const TDF_Label& theLabel,
|
||||
const Handle(TDocStd_Document)& theDoc);
|
||||
|
||||
Handle(VrmlData_Appearance) makeMaterialFromStyle (const XCAFPrs_Style& theStyle,
|
||||
const TDF_Label& theAttribLab) const;
|
||||
Handle(VrmlData_Appearance) makeMaterialFromStyle(const XCAFPrs_Style& theStyle,
|
||||
const TDF_Label& theAttribLab) const;
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
VrmlData_Scene& myScene;
|
||||
Standard_Real myScale;
|
||||
NCollection_List <ShapeData> myShapes;
|
||||
VrmlData_Scene& myScene;
|
||||
Standard_Real myScale;
|
||||
NCollection_List<ShapeData> myShapes;
|
||||
|
||||
Standard_Real myDeflection;
|
||||
Standard_Real myDeflAngle;
|
||||
NCollection_DataMap <TopoDS_Shape, Handle(VrmlData_Geometry)> myRelMap;
|
||||
Standard_Real myDeflection;
|
||||
Standard_Real myDeflAngle;
|
||||
NCollection_DataMap<TopoDS_Shape, Handle(VrmlData_Geometry)> myRelMap;
|
||||
|
||||
// ---------- PRIVATE METHODS ----------
|
||||
void operator= (const VrmlData_ShapeConvert&);
|
||||
void operator=(const VrmlData_ShapeConvert&);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -24,89 +24,86 @@
|
||||
*/
|
||||
class VrmlData_ShapeNode : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_ShapeNode () {}
|
||||
inline VrmlData_ShapeNode() {}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_ShapeNode (const VrmlData_Scene& theScene,
|
||||
const char * theName)
|
||||
: VrmlData_Node (theScene, theName) {}
|
||||
inline VrmlData_ShapeNode(const VrmlData_Scene& theScene, const char* theName)
|
||||
: VrmlData_Node(theScene, theName)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Appearance.
|
||||
*/
|
||||
inline const Handle(VrmlData_Appearance)&
|
||||
Appearance () const { return myAppearance; }
|
||||
inline const Handle(VrmlData_Appearance)& Appearance() const { return myAppearance; }
|
||||
|
||||
/**
|
||||
* Query the Geometry.
|
||||
*/
|
||||
inline const Handle(VrmlData_Geometry)&
|
||||
Geometry () const { return myGeometry; }
|
||||
inline const Handle(VrmlData_Geometry)& Geometry() const { return myGeometry; }
|
||||
|
||||
/**
|
||||
* Set the Appearance
|
||||
*/
|
||||
inline void SetAppearance (const Handle(VrmlData_Appearance)& theAppear)
|
||||
{ myAppearance = theAppear; }
|
||||
inline void SetAppearance(const Handle(VrmlData_Appearance)& theAppear)
|
||||
{
|
||||
myAppearance = theAppear;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the Geometry
|
||||
*/
|
||||
inline void SetGeometry (const Handle(VrmlData_Geometry)& theGeometry)
|
||||
{ myGeometry = theGeometry; }
|
||||
inline void SetGeometry(const Handle(VrmlData_Geometry)& theGeometry)
|
||||
{
|
||||
myGeometry = theGeometry;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Fill the Node internal data from the given input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Check if the Shape Node is writeable.
|
||||
*/
|
||||
Standard_EXPORT virtual Standard_Boolean
|
||||
IsDefault () const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsDefault() const Standard_OVERRIDE;
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
Handle(VrmlData_Appearance) myAppearance;
|
||||
Handle(VrmlData_Geometry) myGeometry;
|
||||
Handle(VrmlData_Appearance) myAppearance;
|
||||
Handle(VrmlData_Geometry) myGeometry;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_ShapeNode,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_ShapeNode, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_ShapeNode, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_ShapeNode, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -23,75 +23,77 @@
|
||||
*/
|
||||
class VrmlData_Sphere : public VrmlData_Geometry
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Sphere ()
|
||||
: myRadius (1.)
|
||||
{}
|
||||
inline VrmlData_Sphere()
|
||||
: myRadius(1.)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_Sphere (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Real theRadius = 1.)
|
||||
: VrmlData_Geometry (theScene, theName),
|
||||
myRadius (theRadius)
|
||||
{}
|
||||
inline VrmlData_Sphere(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Real theRadius = 1.)
|
||||
: VrmlData_Geometry(theScene, theName),
|
||||
myRadius(theRadius)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the sphere radius
|
||||
*/
|
||||
inline Standard_Real Radius () const { return myRadius; }
|
||||
inline Standard_Real Radius() const { return myRadius; }
|
||||
|
||||
/**
|
||||
* Set the sphere radius
|
||||
*/
|
||||
inline void SetRadius (const Standard_Real theRadius)
|
||||
{ myRadius = theRadius; SetModified(); }
|
||||
inline void SetRadius(const Standard_Real theRadius)
|
||||
{
|
||||
myRadius = theRadius;
|
||||
SetModified();
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the primitive topology. This method returns a Null shape if there
|
||||
* is an internal error during the primitive creation (zero radius, etc.)
|
||||
*/
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape () Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual const Handle(TopoDS_TShape)& TShape() Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Fill the Node internal data from the given input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to output stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
Standard_Real myRadius;
|
||||
Standard_Real myRadius;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Sphere,VrmlData_Geometry)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Sphere, VrmlData_Geometry)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Sphere, VrmlData_Geometry)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Sphere, VrmlData_Geometry)
|
||||
|
||||
#endif
|
||||
|
@@ -23,71 +23,66 @@
|
||||
*/
|
||||
class VrmlData_Texture : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_Texture ()
|
||||
: myRepeatS (Standard_False),
|
||||
myRepeatT (Standard_False)
|
||||
{}
|
||||
inline VrmlData_Texture()
|
||||
: myRepeatS(Standard_False),
|
||||
myRepeatT(Standard_False)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_Texture (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const Standard_Boolean theRepeatS = Standard_False,
|
||||
const Standard_Boolean theRepeatT = Standard_False)
|
||||
: VrmlData_Node (theScene, theName),
|
||||
myRepeatS (theRepeatS),
|
||||
myRepeatT (theRepeatT)
|
||||
{}
|
||||
inline VrmlData_Texture(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const Standard_Boolean theRepeatS = Standard_False,
|
||||
const Standard_Boolean theRepeatT = Standard_False)
|
||||
: VrmlData_Node(theScene, theName),
|
||||
myRepeatS(theRepeatS),
|
||||
myRepeatT(theRepeatT)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the RepeatS value
|
||||
*/
|
||||
inline Standard_Boolean
|
||||
RepeatS () const { return myRepeatS; }
|
||||
inline Standard_Boolean RepeatS() const { return myRepeatS; }
|
||||
|
||||
/**
|
||||
* Query the RepeatT value
|
||||
*/
|
||||
inline Standard_Boolean
|
||||
RepeatT () const { return myRepeatT; }
|
||||
inline Standard_Boolean RepeatT() const { return myRepeatT; }
|
||||
|
||||
/**
|
||||
* Set the RepeatS flag
|
||||
*/
|
||||
inline void SetRepeatS (const Standard_Boolean theFlag)
|
||||
{ myRepeatS = theFlag; }
|
||||
inline void SetRepeatS(const Standard_Boolean theFlag) { myRepeatS = theFlag; }
|
||||
|
||||
/**
|
||||
* Set the RepeatT flag
|
||||
*/
|
||||
inline void SetRepeatT (const Standard_Boolean theFlag)
|
||||
{ myRepeatT = theFlag; }
|
||||
inline void SetRepeatT(const Standard_Boolean theFlag) { myRepeatT = theFlag; }
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
Standard_Boolean myRepeatS;
|
||||
Standard_Boolean myRepeatT;
|
||||
Standard_Boolean myRepeatS;
|
||||
Standard_Boolean myRepeatT;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Texture,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_Texture, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_Texture, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_Texture, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -24,79 +24,82 @@ class gp_XY;
|
||||
*/
|
||||
class VrmlData_TextureCoordinate : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_TextureCoordinate ()
|
||||
: myPoints (0L), myLength (0) {}
|
||||
inline VrmlData_TextureCoordinate()
|
||||
: myPoints(0L),
|
||||
myLength(0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_TextureCoordinate (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const size_t nPoints = 0,
|
||||
const gp_XY * arrPoints = 0L)
|
||||
: VrmlData_Node (theScene, theName),
|
||||
myPoints (arrPoints),
|
||||
myLength (nPoints)
|
||||
{}
|
||||
inline VrmlData_TextureCoordinate(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const size_t nPoints = 0,
|
||||
const gp_XY* arrPoints = 0L)
|
||||
: VrmlData_Node(theScene, theName),
|
||||
myPoints(arrPoints),
|
||||
myLength(nPoints)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a data array and assign the field myArray.
|
||||
* @return
|
||||
* True if allocation was successful.
|
||||
*/
|
||||
Standard_EXPORT Standard_Boolean
|
||||
AllocateValues (const Standard_Size theLength);
|
||||
*/
|
||||
Standard_EXPORT Standard_Boolean AllocateValues(const Standard_Size theLength);
|
||||
|
||||
/**
|
||||
* Query the number of points
|
||||
*/
|
||||
inline size_t Length () { return myLength; }
|
||||
inline size_t Length() { return myLength; }
|
||||
|
||||
/**
|
||||
* Query the points
|
||||
*/
|
||||
inline const gp_XY * Points () { return myPoints; }
|
||||
inline const gp_XY* Points() { return myPoints; }
|
||||
|
||||
/**
|
||||
* Set the points array
|
||||
*/
|
||||
inline void SetPoints (const size_t nPoints,
|
||||
const gp_XY * arrPoints)
|
||||
{ myPoints = arrPoints; myLength = nPoints; }
|
||||
inline void SetPoints(const size_t nPoints, const gp_XY* arrPoints)
|
||||
{
|
||||
myPoints = arrPoints;
|
||||
myLength = nPoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther)const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
const gp_XY * myPoints;
|
||||
size_t myLength;
|
||||
const gp_XY* myPoints;
|
||||
size_t myLength;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_TextureCoordinate,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_TextureCoordinate, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_TextureCoordinate, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_TextureCoordinate, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -23,73 +23,70 @@
|
||||
|
||||
class VrmlData_TextureTransform : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty constructor
|
||||
*/
|
||||
inline VrmlData_TextureTransform ()
|
||||
: myRotation(0.0)
|
||||
inline VrmlData_TextureTransform()
|
||||
: myRotation(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
inline VrmlData_TextureTransform (const VrmlData_Scene& theScene,
|
||||
const char * theName)
|
||||
: VrmlData_Node (theScene, theName),
|
||||
myRotation(0.)
|
||||
{}
|
||||
inline VrmlData_TextureTransform(const VrmlData_Scene& theScene, const char* theName)
|
||||
: VrmlData_Node(theScene, theName),
|
||||
myRotation(0.)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Query the Center
|
||||
*/
|
||||
inline const gp_XY& Center () const { return myCenter; }
|
||||
|
||||
inline const gp_XY& Center() const { return myCenter; }
|
||||
|
||||
/**
|
||||
* Query the Rotation
|
||||
*/
|
||||
inline Standard_Real Rotation () const { return myRotation; }
|
||||
|
||||
inline Standard_Real Rotation() const { return myRotation; }
|
||||
|
||||
/**
|
||||
* Query the Scale
|
||||
*/
|
||||
inline const gp_XY& Scale () const { return myScale; }
|
||||
inline const gp_XY& Scale() const { return myScale; }
|
||||
|
||||
/**
|
||||
* Query the Translation
|
||||
*/
|
||||
inline const gp_XY& Translation () const { return myTranslation; }
|
||||
inline const gp_XY& Translation() const { return myTranslation; }
|
||||
|
||||
/**
|
||||
* Set the Center
|
||||
*/
|
||||
inline void SetCenter (const gp_XY& V) { myCenter = V; }
|
||||
inline void SetCenter(const gp_XY& V) { myCenter = V; }
|
||||
|
||||
/**
|
||||
* Set the Rotation
|
||||
*/
|
||||
inline void SetRotation (const Standard_Real V)
|
||||
{ myRotation = V; }
|
||||
inline void SetRotation(const Standard_Real V) { myRotation = V; }
|
||||
|
||||
/**
|
||||
* Set the Scale
|
||||
*/
|
||||
inline void SetScale (const gp_XY& V) { myScale = V; }
|
||||
inline void SetScale(const gp_XY& V) { myScale = V; }
|
||||
|
||||
/**
|
||||
* Set the Translation
|
||||
*/
|
||||
inline void SetTranslation (const gp_XY& V) { myTranslation = V; }
|
||||
inline void SetTranslation(const gp_XY& V) { myTranslation = V; }
|
||||
|
||||
protected:
|
||||
protected:
|
||||
// ---------- PROTECTED METHODS ----------
|
||||
|
||||
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
gp_XY myCenter;
|
||||
@@ -97,13 +94,12 @@ class VrmlData_TextureTransform : public VrmlData_Node
|
||||
gp_XY myScale;
|
||||
gp_XY myTranslation;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_TextureTransform,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_TextureTransform, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_TextureTransform, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_TextureTransform, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -26,54 +26,52 @@
|
||||
|
||||
class VrmlData_UnknownNode : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty Constructor.
|
||||
*/
|
||||
inline VrmlData_UnknownNode () {}
|
||||
inline VrmlData_UnknownNode() {}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
inline VrmlData_UnknownNode (const VrmlData_Scene& theScene,
|
||||
const char * theName = 0L,
|
||||
const char * theTitle= 0L)
|
||||
: VrmlData_Node (theScene, theName)
|
||||
{ if (theTitle) myTitle = (Standard_CString)theTitle; }
|
||||
inline VrmlData_UnknownNode(const VrmlData_Scene& theScene,
|
||||
const char* theName = 0L,
|
||||
const char* theTitle = 0L)
|
||||
: VrmlData_Node(theScene, theName)
|
||||
{
|
||||
if (theTitle)
|
||||
myTitle = (Standard_CString)theTitle;
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the unknown node, till the last closing brace of it.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Query the title of the unknown node.
|
||||
*/
|
||||
inline const TCollection_AsciiString&
|
||||
GetTitle () const
|
||||
{ return myTitle; }
|
||||
inline const TCollection_AsciiString& GetTitle() const { return myTitle; }
|
||||
|
||||
/**
|
||||
* Check if the Node is non-writeable -- always returns true.
|
||||
*/
|
||||
Standard_EXPORT virtual Standard_Boolean
|
||||
IsDefault () const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsDefault() const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
TCollection_AsciiString myTitle;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_UnknownNode,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTI_INLINE(VrmlData_UnknownNode, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_UnknownNode, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_UnknownNode, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
@@ -17,155 +17,163 @@
|
||||
#include <VrmlData_Scene.hxx>
|
||||
#include <VrmlData_InBuffer.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_WorldInfo,VrmlData_Node)
|
||||
IMPLEMENT_STANDARD_RTTIEXT(VrmlData_WorldInfo, VrmlData_Node)
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning (disable:4996)
|
||||
#define _CRT_SECURE_NO_DEPRECATE
|
||||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
|
||||
//=================================================================================================
|
||||
|
||||
//=======================================================================
|
||||
//function : VrmlData_WorldInfo::VrmlData_WorldInfo
|
||||
//purpose : Constructor
|
||||
//=======================================================================
|
||||
|
||||
VrmlData_WorldInfo::VrmlData_WorldInfo (const VrmlData_Scene& theScene,
|
||||
const char * theName,
|
||||
const char * theTitle)
|
||||
: VrmlData_Node (theScene, theName),
|
||||
myInfo (theScene.Allocator())
|
||||
VrmlData_WorldInfo::VrmlData_WorldInfo(const VrmlData_Scene& theScene,
|
||||
const char* theName,
|
||||
const char* theTitle)
|
||||
: VrmlData_Node(theScene, theName),
|
||||
myInfo(theScene.Allocator())
|
||||
{
|
||||
SetTitle (theTitle);
|
||||
SetTitle(theTitle);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetTitle
|
||||
//purpose : Set or modify the title.
|
||||
// function : SetTitle
|
||||
// purpose : Set or modify the title.
|
||||
//=======================================================================
|
||||
|
||||
void VrmlData_WorldInfo::SetTitle (const char * theString)
|
||||
void VrmlData_WorldInfo::SetTitle(const char* theString)
|
||||
{
|
||||
if (theString == 0L)
|
||||
myTitle = 0L;
|
||||
else {
|
||||
const size_t len = strlen (theString) + 1;
|
||||
else
|
||||
{
|
||||
const size_t len = strlen(theString) + 1;
|
||||
if (len == 1)
|
||||
myTitle = 0L;
|
||||
else {
|
||||
myTitle = static_cast <const char *>(Scene().Allocator()->Allocate(len));
|
||||
memcpy (const_cast<char *> (myTitle), theString, len);
|
||||
else
|
||||
{
|
||||
myTitle = static_cast<const char*>(Scene().Allocator()->Allocate(len));
|
||||
memcpy(const_cast<char*>(myTitle), theString, len);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddInfo
|
||||
//purpose : Add a string to the list of info strings.
|
||||
// function : AddInfo
|
||||
// purpose : Add a string to the list of info strings.
|
||||
//=======================================================================
|
||||
|
||||
void VrmlData_WorldInfo::AddInfo (const char * theString)
|
||||
void VrmlData_WorldInfo::AddInfo(const char* theString)
|
||||
{
|
||||
if (theString != 0L)
|
||||
if (* theString != '\0') {
|
||||
const size_t len = strlen (theString) + 1;
|
||||
char * aStr = static_cast <char *>(Scene().Allocator()->Allocate(len));
|
||||
memcpy (aStr, theString, len);
|
||||
myInfo.Append (aStr);
|
||||
if (*theString != '\0')
|
||||
{
|
||||
const size_t len = strlen(theString) + 1;
|
||||
char* aStr = static_cast<char*>(Scene().Allocator()->Allocate(len));
|
||||
memcpy(aStr, theString, len);
|
||||
myInfo.Append(aStr);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Clone
|
||||
//purpose : Create a copy of this node
|
||||
// function : Clone
|
||||
// purpose : Create a copy of this node
|
||||
//=======================================================================
|
||||
|
||||
Handle(VrmlData_Node) VrmlData_WorldInfo::Clone
|
||||
(const Handle(VrmlData_Node)& theOther) const
|
||||
Handle(VrmlData_Node) VrmlData_WorldInfo::Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
{
|
||||
Handle(VrmlData_WorldInfo) aResult =
|
||||
Handle(VrmlData_WorldInfo)::DownCast (VrmlData_Node::Clone(theOther));
|
||||
Handle(VrmlData_WorldInfo)::DownCast(VrmlData_Node::Clone(theOther));
|
||||
if (aResult.IsNull())
|
||||
aResult =
|
||||
new VrmlData_WorldInfo (theOther.IsNull() ? Scene() : theOther->Scene(),
|
||||
Name());
|
||||
aResult = new VrmlData_WorldInfo(theOther.IsNull() ? Scene() : theOther->Scene(), Name());
|
||||
|
||||
if (&aResult->Scene() == &Scene()) {
|
||||
if (&aResult->Scene() == &Scene())
|
||||
{
|
||||
aResult->myTitle = myTitle;
|
||||
aResult->myInfo = myInfo;
|
||||
} else {
|
||||
aResult->SetTitle (myTitle);
|
||||
NCollection_List <const char *>::Iterator anIter (myInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
aResult->SetTitle(myTitle);
|
||||
NCollection_List<const char*>::Iterator anIter(myInfo);
|
||||
for (; anIter.More(); anIter.Next())
|
||||
aResult->AddInfo (anIter.Value());
|
||||
aResult->AddInfo(anIter.Value());
|
||||
}
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Read
|
||||
//purpose : Read the Node from input stream.
|
||||
// function : Read
|
||||
// purpose : Read the Node from input stream.
|
||||
//=======================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_WorldInfo::Read (VrmlData_InBuffer& theBuffer)
|
||||
VrmlData_ErrorStatus VrmlData_WorldInfo::Read(VrmlData_InBuffer& theBuffer)
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus;
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer))) {
|
||||
while (OK(aStatus, VrmlData_Scene::ReadLine(theBuffer)))
|
||||
{
|
||||
|
||||
if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "title")) {
|
||||
if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "title"))
|
||||
{
|
||||
TCollection_AsciiString aTitleString;
|
||||
if (OK (aStatus, ReadString (theBuffer, aTitleString)))
|
||||
SetTitle (aTitleString.ToCString());
|
||||
|
||||
} else if (VRMLDATA_LCOMPARE (theBuffer.LinePtr, "info")) {
|
||||
if (OK(aStatus, ReadString(theBuffer, aTitleString)))
|
||||
SetTitle(aTitleString.ToCString());
|
||||
}
|
||||
else if (VRMLDATA_LCOMPARE(theBuffer.LinePtr, "info"))
|
||||
{
|
||||
NCollection_List<TCollection_AsciiString> lstInfo;
|
||||
if (OK (aStatus, ReadMultiString (theBuffer, lstInfo))) {
|
||||
NCollection_List<TCollection_AsciiString>::Iterator anIter (lstInfo);
|
||||
if (OK(aStatus, ReadMultiString(theBuffer, lstInfo)))
|
||||
{
|
||||
NCollection_List<TCollection_AsciiString>::Iterator anIter(lstInfo);
|
||||
for (; anIter.More(); anIter.Next())
|
||||
AddInfo (anIter.Value().ToCString());
|
||||
AddInfo(anIter.Value().ToCString());
|
||||
}
|
||||
} else
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
|
||||
// Read the terminating (closing) brace
|
||||
if (OK(aStatus))
|
||||
aStatus = readBrace (theBuffer);
|
||||
aStatus = readBrace(theBuffer);
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Write
|
||||
//purpose : Write the Node to the Scene output.
|
||||
// function : Write
|
||||
// purpose : Write the Node to the Scene output.
|
||||
//=======================================================================
|
||||
|
||||
VrmlData_ErrorStatus VrmlData_WorldInfo::Write (const char * thePrefix) const
|
||||
VrmlData_ErrorStatus VrmlData_WorldInfo::Write(const char* thePrefix) const
|
||||
{
|
||||
VrmlData_ErrorStatus aStatus (VrmlData_StatusOK);
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
static char header[] = "WorldInfo {";
|
||||
if (aScene.IsDummyWrite() == Standard_False &&
|
||||
OK (aStatus, aScene.WriteLine (thePrefix, header, GlobalIndent())))
|
||||
VrmlData_ErrorStatus aStatus(VrmlData_StatusOK);
|
||||
const VrmlData_Scene& aScene = Scene();
|
||||
static char header[] = "WorldInfo {";
|
||||
if (aScene.IsDummyWrite() == Standard_False
|
||||
&& OK(aStatus, aScene.WriteLine(thePrefix, header, GlobalIndent())))
|
||||
{
|
||||
char buf[4096];
|
||||
if (myTitle) {
|
||||
Sprintf (buf, "title \"%s\"", myTitle);
|
||||
aStatus = aScene.WriteLine (buf);
|
||||
if (myTitle)
|
||||
{
|
||||
Sprintf(buf, "title \"%s\"", myTitle);
|
||||
aStatus = aScene.WriteLine(buf);
|
||||
}
|
||||
|
||||
if (myInfo.IsEmpty() == Standard_False && OK(aStatus)) {
|
||||
if (OK (aStatus, aScene.WriteLine ("info [", 0L, GlobalIndent()))) {
|
||||
NCollection_List<const char *>::Iterator anIter (myInfo);
|
||||
while (anIter.More()) {
|
||||
Sprintf (buf, "\"%s\"", anIter.Value());
|
||||
if (myInfo.IsEmpty() == Standard_False && OK(aStatus))
|
||||
{
|
||||
if (OK(aStatus, aScene.WriteLine("info [", 0L, GlobalIndent())))
|
||||
{
|
||||
NCollection_List<const char*>::Iterator anIter(myInfo);
|
||||
while (anIter.More())
|
||||
{
|
||||
Sprintf(buf, "\"%s\"", anIter.Value());
|
||||
anIter.Next();
|
||||
if (anIter.More())
|
||||
aStatus = aScene.WriteLine (buf, ",");
|
||||
aStatus = aScene.WriteLine(buf, ",");
|
||||
else
|
||||
aStatus = aScene.WriteLine (buf);
|
||||
aStatus = aScene.WriteLine(buf);
|
||||
}
|
||||
}
|
||||
aStatus = aScene.WriteLine ("]", 0L, -GlobalIndent());
|
||||
aStatus = aScene.WriteLine("]", 0L, -GlobalIndent());
|
||||
}
|
||||
|
||||
aStatus = WriteClosing();
|
||||
@@ -173,10 +181,7 @@ VrmlData_ErrorStatus VrmlData_WorldInfo::Write (const char * thePrefix) const
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDefault
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
//=================================================================================================
|
||||
|
||||
Standard_Boolean VrmlData_WorldInfo::IsDefault() const
|
||||
{
|
||||
|
@@ -24,83 +24,79 @@
|
||||
|
||||
class VrmlData_WorldInfo : public VrmlData_Node
|
||||
{
|
||||
public:
|
||||
public:
|
||||
// ---------- PUBLIC METHODS ----------
|
||||
|
||||
/**
|
||||
* Empty Constructor.
|
||||
*/
|
||||
inline VrmlData_WorldInfo () : myTitle (0L) {}
|
||||
inline VrmlData_WorldInfo()
|
||||
: myTitle(0L)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
Standard_EXPORT VrmlData_WorldInfo (const VrmlData_Scene& theScene,
|
||||
const char * theName = 0L,
|
||||
const char * theTitle = 0L);
|
||||
Standard_EXPORT VrmlData_WorldInfo(const VrmlData_Scene& theScene,
|
||||
const char* theName = 0L,
|
||||
const char* theTitle = 0L);
|
||||
|
||||
/**
|
||||
* Set or modify the title.
|
||||
*/
|
||||
Standard_EXPORT void SetTitle (const char * theString);
|
||||
Standard_EXPORT void SetTitle(const char* theString);
|
||||
|
||||
/**
|
||||
* Add a string to the list of info strings.
|
||||
*/
|
||||
Standard_EXPORT void AddInfo (const char * theString);
|
||||
Standard_EXPORT void AddInfo(const char* theString);
|
||||
|
||||
/**
|
||||
* Query the title string.
|
||||
*/
|
||||
inline const char * Title () const
|
||||
{ return myTitle; }
|
||||
inline const char* Title() const { return myTitle; }
|
||||
|
||||
/**
|
||||
* Return the iterator of Info strings.
|
||||
*/
|
||||
inline NCollection_List <const char *>::Iterator
|
||||
InfoIterator () const
|
||||
{ return myInfo; }
|
||||
inline NCollection_List<const char*>::Iterator InfoIterator() const { return myInfo; }
|
||||
|
||||
/**
|
||||
* Create a copy of this node.
|
||||
* If the parameter is null, a new copied node is created. Otherwise new node
|
||||
* is not created, but rather the given one is modified.
|
||||
*/
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node)
|
||||
Clone (const Handle(VrmlData_Node)& theOther) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Handle(VrmlData_Node) Clone(const Handle(VrmlData_Node)& theOther) const
|
||||
Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Read the Node from input stream.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Read (VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Read(VrmlData_InBuffer& theBuffer) Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Write the Node to the Scene output.
|
||||
*/
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus
|
||||
Write (const char * thePrefix) const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual VrmlData_ErrorStatus Write(const char* thePrefix) const Standard_OVERRIDE;
|
||||
|
||||
/**
|
||||
* Returns True if the node is default, then it would not be written.
|
||||
*/
|
||||
Standard_EXPORT virtual Standard_Boolean
|
||||
IsDefault() const Standard_OVERRIDE;
|
||||
Standard_EXPORT virtual Standard_Boolean IsDefault() const Standard_OVERRIDE;
|
||||
|
||||
private:
|
||||
private:
|
||||
// ---------- PRIVATE FIELDS ----------
|
||||
|
||||
const char * myTitle;
|
||||
NCollection_List <const char *> myInfo;
|
||||
const char* myTitle;
|
||||
NCollection_List<const char*> myInfo;
|
||||
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_WorldInfo,VrmlData_Node)
|
||||
public:
|
||||
// Declaration of CASCADE RTTI
|
||||
DEFINE_STANDARD_RTTIEXT(VrmlData_WorldInfo, VrmlData_Node)
|
||||
};
|
||||
|
||||
// Definition of HANDLE object using Standard_DefineHandle.hxx
|
||||
DEFINE_STANDARD_HANDLE (VrmlData_WorldInfo, VrmlData_Node)
|
||||
|
||||
DEFINE_STANDARD_HANDLE(VrmlData_WorldInfo, VrmlData_Node)
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user