mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-14 13:30:48 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
2
src/XCAFDoc/FILES
Executable file
2
src/XCAFDoc/FILES
Executable file
@@ -0,0 +1,2 @@
|
||||
FILES
|
||||
GUID.txt
|
49
src/XCAFDoc/GUID.txt
Executable file
49
src/XCAFDoc/GUID.txt
Executable file
@@ -0,0 +1,49 @@
|
||||
GUIDs defined here:
|
||||
|
||||
5b896afe-3adf-11d4-b9b7-0060b0ee281b: TreeNode for Shape Reference
|
||||
5b896afd-3adf-11d4-b9b7-0060b0ee281b
|
||||
5b896aff-3adf-11d4-b9b7-0060b0ee281b: UAttribute indicating invisibility of object
|
||||
5b896b00-3adf-11d4-b9b7-0060b0ee281b: UAttribute indicating Assembly
|
||||
6b896b01-3adf-11d4-b9b7-0060b0ee281b: UAttribute extern reference
|
||||
|
||||
e9439b64-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b65-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b66-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b67-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b68-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b69-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b6a-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b6b-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b6c-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b6d-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b6e-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b6f-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b70-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b71-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b72-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b73-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b74-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b75-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b76-6dfd-11d4-b9c8-0060b0ee281b
|
||||
e9439b77-6dfd-11d4-b9c8-0060b0ee281b
|
||||
|
||||
efd212e4-6dfd-11d4-b9c8-0060b0ee281b: TreeNode for Color Reference
|
||||
efd212e5-6dfd-11d4-b9c8-0060b0ee281b: TreeNode for Surface Color Reference
|
||||
efd212e6-6dfd-11d4-b9c8-0060b0ee281b: TreeNode for Curve Color Reference
|
||||
efd212e7-6dfd-11d4-b9c8-0060b0ee281b:
|
||||
efd212e8-6dfd-11d4-b9c8-0060b0ee281b: GraphNode for Layer Reference
|
||||
efd212e9-6dfd-11d4-b9c8-0060b0ee281b
|
||||
efd212ea-6dfd-11d4-b9c8-0060b0ee281b: GraphNode for Specified Higher Usage Occurrenace
|
||||
efd212eb-6dfd-11d4-b9c8-0060b0ee281b
|
||||
efd212ec-6dfd-11d4-b9c8-0060b0ee281b: DocumentTool attribute
|
||||
efd212ed-6dfd-11d4-b9c8-0060b0ee281b: ColorTool attribute
|
||||
efd212ee-6dfd-11d4-b9c8-0060b0ee281b: ShapeTool attribute
|
||||
efd212ef-6dfd-11d4-b9c8-0060b0ee281b: Location attribute
|
||||
efd212f0-6dfd-11d4-b9c8-0060b0ee281b: Color attribute
|
||||
efd212f1-6dfd-11d4-b9c8-0060b0ee281b: Volume attribute
|
||||
efd212f2-6dfd-11d4-b9c8-0060b0ee281b: Area attribute
|
||||
efd212f3-6dfd-11d4-b9c8-0060b0ee281b: Centroid attribute
|
||||
efd212f4-6dfd-11d4-b9c8-0060b0ee281b: LayerTool attribute
|
||||
efd212f5-6dfd-11d4-b9c8-0060b0ee281b: GraphNode attribute
|
||||
efd212f6-6dfd-11d4-b9c8-0060b0ee281b
|
||||
efd212f7-6dfd-11d4-b9c8-0060b0ee281b
|
145
src/XCAFDoc/XCAFDoc.cdl
Executable file
145
src/XCAFDoc/XCAFDoc.cdl
Executable file
@@ -0,0 +1,145 @@
|
||||
-- File: XCAFDoc.cdl
|
||||
-- Created: Tue Aug 8 13:10:20 2000
|
||||
-- Author: data exchange team
|
||||
-- <det@doomox>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
package XCAFDoc
|
||||
|
||||
---Purpose: Definition of general structure of DECAF document
|
||||
-- and tools to work with it
|
||||
--
|
||||
-- The document is composed of sections, each section
|
||||
-- storing its own kind of data and managing by corresponding
|
||||
-- tool
|
||||
-- Some properties can be attached directly to shapes. These properties are:
|
||||
-- * Name (the standard definition from OCAF) - class TDataStd_Name
|
||||
-- * Centroid (for the validation of transfer) - class XCAFDoc_Centroid
|
||||
-- * Volume (for the validation of transfer) - class XCAFDoc_Volume
|
||||
-- * Area (for the validation of transfer) - class XCafDoc_Area
|
||||
-- Management of these attributes is realized by OCAF. For getting
|
||||
-- the attributes attached to a label the method class
|
||||
-- TDF_Label::FindAttribute() should be used.
|
||||
|
||||
uses
|
||||
Quantity,
|
||||
TCollection,
|
||||
TColStd,
|
||||
TopLoc,
|
||||
TopoDS,
|
||||
TopTools,
|
||||
TDF,
|
||||
TDocStd,
|
||||
TDataStd,
|
||||
gp
|
||||
|
||||
is
|
||||
|
||||
enumeration ColorType is
|
||||
---Purpose: Defines types of color assignments
|
||||
ColorGen, -- simple color
|
||||
ColorSurf, -- color of surfaces
|
||||
ColorCurv -- color of curves
|
||||
end ColorType;
|
||||
|
||||
|
||||
class DocumentTool;
|
||||
---Purpose: Defines sections structure of an XDE document.
|
||||
-- attribute marking CAF document as being DECAF document.
|
||||
-- Creates the sections structure of the document.
|
||||
|
||||
class Location;
|
||||
---Purpose: attribute to store TopLoc_Location
|
||||
|
||||
class Color;
|
||||
---Purpose: attribute to store color
|
||||
|
||||
class DimTol;
|
||||
---Purpose: attribute to store dimension and tolerance
|
||||
|
||||
class Datum;
|
||||
---Purpose: attribute to store datum
|
||||
|
||||
class Material;
|
||||
---Purpose: attribute to store material
|
||||
|
||||
class Volume;
|
||||
---Purpose: attribute to store volume
|
||||
|
||||
class Area;
|
||||
---Purpose: attribute to store area
|
||||
|
||||
class Centroid;
|
||||
---Purpose: attribute to store centroid
|
||||
|
||||
class ShapeTool;
|
||||
---Purpose: attribute containing Shapes section of DECAF document.
|
||||
-- Provide tools for management of Shapes section.
|
||||
|
||||
class ShapeMapTool;
|
||||
---Purpose: attribute containing map of sub shapes
|
||||
|
||||
class ColorTool;
|
||||
---Purpose: attribute containing Colors section of DECAF document.
|
||||
-- Provide tools for management of Colors section of document.
|
||||
|
||||
class DimTolTool;
|
||||
---Purpose: attribute containing DimTol section of DECAF document.
|
||||
-- Provide tools for management of DimTol section of document.
|
||||
|
||||
class LayerTool;
|
||||
---Purpose: attribute containing Layers section og DECAF document.
|
||||
-- Provide tools for management of Layers section of document.
|
||||
|
||||
class MaterialTool;
|
||||
---Purpose: attribute containing Materials section og DECAF document.
|
||||
-- Provide tools for management of Materialss section of document.
|
||||
|
||||
class GraphNode;
|
||||
---Purpose: attribute containg sequence of father's and chaild's labels.
|
||||
-- Provide create and work with Graph in XCAFDocument.
|
||||
|
||||
class GraphNodeSequence instantiates Sequence from TCollection
|
||||
(GraphNode from XCAFDoc);
|
||||
---Purpose: class for containing GraphNodes.
|
||||
|
||||
class DataMapOfShapeLabel instantiates
|
||||
DataMap from TCollection (Shape from TopoDS,
|
||||
Label from TDF,
|
||||
ShapeMapHasher from TopTools);
|
||||
|
||||
|
||||
---Package methods: definition of GUIDs
|
||||
|
||||
AssemblyGUID returns GUID from Standard;
|
||||
---Purpose: Returns GUID for UAttribute identifying assembly
|
||||
|
||||
ShapeRefGUID returns GUID from Standard;
|
||||
---Purpose: Returns GUID for TreeNode representing assembly link
|
||||
|
||||
ColorRefGUID (type: ColorType from XCAFDoc) returns GUID from Standard;
|
||||
---Purpose: Return GUIDs for TreeNode representing specified types of colors
|
||||
|
||||
DimTolRefGUID returns GUID from Standard;
|
||||
---Purpose: Return GUIDs for TreeNode representing specified types of DGT
|
||||
|
||||
DatumRefGUID returns GUID from Standard;
|
||||
---Purpose: Return GUIDs for TreeNode representing specified types of datum
|
||||
|
||||
DatumTolRefGUID returns GUID from Standard;
|
||||
---Purpose: Return GUIDs for TreeNode representing connections Datum-Toler
|
||||
|
||||
LayerRefGUID returns GUID from Standard;
|
||||
|
||||
MaterialRefGUID returns GUID from Standard;
|
||||
|
||||
InvisibleGUID returns GUID from Standard;
|
||||
|
||||
ExternRefGUID returns GUID from Standard;
|
||||
---Purpose: Returns GUID for UAttribute identifying external reference on no-step file
|
||||
|
||||
SHUORefGUID returns GUID from Standard;
|
||||
---Purpose: Returns GUID for UAttribute identifying specified higher usage occurrence
|
||||
|
||||
end XCAFDoc;
|
151
src/XCAFDoc/XCAFDoc.cxx
Executable file
151
src/XCAFDoc/XCAFDoc.cxx
Executable file
@@ -0,0 +1,151 @@
|
||||
#include <XCAFDoc.hxx>
|
||||
#include <XCAFDoc_ColorType.hxx>
|
||||
|
||||
#include <TDF_Label.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDocStd_Document.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeRefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::ShapeRefGUID ()
|
||||
{
|
||||
static Standard_GUID ID ("5b896afe-3adf-11d4-b9b7-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AssemblyGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::AssemblyGUID ()
|
||||
{
|
||||
static Standard_GUID ID ("5b896b00-3adf-11d4-b9b7-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ExternRefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::ExternRefGUID ()
|
||||
{
|
||||
static Standard_GUID ID ("6b896b01-3adf-11d4-b9b7-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ColorRefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::ColorRefGUID (const XCAFDoc_ColorType type)
|
||||
{
|
||||
static Standard_GUID IDcol ("efd212e4-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
static Standard_GUID IDcolSurf ("efd212e5-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
static Standard_GUID IDcolCurv ("efd212e6-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
|
||||
switch ( type ) {
|
||||
default:
|
||||
case XCAFDoc_ColorGen : return IDcol;
|
||||
case XCAFDoc_ColorSurf: return IDcolSurf;
|
||||
case XCAFDoc_ColorCurv: return IDcolCurv;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DimTolRefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::DimTolRefGUID()
|
||||
{
|
||||
//static Standard_GUID IDDimTol("58ed092d-44de-11d8-8776-001083004c77");
|
||||
static Standard_GUID ID("efd212e9-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
//return IDDimTol;
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DatumRefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::DatumRefGUID()
|
||||
{
|
||||
static Standard_GUID ID("efd212e2-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DatumTolRefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::DatumTolRefGUID()
|
||||
{
|
||||
//static Standard_GUID IDDimTol("58ed092d-44de-11d8-8776-001083004c77");
|
||||
static Standard_GUID ID("efd212e7-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
//return IDDimTol;
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : LayerRefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::LayerRefGUID ()
|
||||
{
|
||||
static Standard_GUID ID ("efd212e8-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MaterialRefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::MaterialRefGUID ()
|
||||
{
|
||||
static Standard_GUID ID ("efd212f7-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : InvisibleGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::InvisibleGUID ()
|
||||
{
|
||||
static Standard_GUID ID ("5b896aff-3adf-11d4-b9b7-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SHUORefGUID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_GUID XCAFDoc::SHUORefGUID ()
|
||||
{
|
||||
static Standard_GUID ID ("efd212ea-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return ID;
|
||||
}
|
65
src/XCAFDoc/XCAFDoc_Area.cdl
Executable file
65
src/XCAFDoc/XCAFDoc_Area.cdl
Executable file
@@ -0,0 +1,65 @@
|
||||
-- File: XCAFDoc_Area.cdl
|
||||
-- Created: Fri Sep 8 10:54:04 2000
|
||||
-- Author: data exchange team
|
||||
-- <det@nordox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class Area from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Attribute from TDF,
|
||||
Label from TDF,
|
||||
GUID from Standard,
|
||||
Real from Standard,
|
||||
RelocationTable from TDF
|
||||
|
||||
is
|
||||
Create returns Area from XCAFDoc;
|
||||
|
||||
---Purpose: class methods
|
||||
-- =============
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Set (me: mutable; vol: Real from Standard);
|
||||
---Purpose: Sets a value of volume
|
||||
|
||||
Set (myclass ; label : Label from TDF; area: Real from Standard)
|
||||
returns Area from XCAFDoc;
|
||||
---Purpose: Find, or create, an Area attribute and set its value
|
||||
|
||||
Get (me)
|
||||
returns Real from Standard;
|
||||
|
||||
Get (myclass ; label : Label from TDF; area: in out Real from Standard)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Returns volume of area as argument and succes status
|
||||
-- returns false if no such attribute at the <label>
|
||||
|
||||
Restore (me: mutable; With : Attribute from TDF);
|
||||
|
||||
NewEmpty(me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; Into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
Dump(me; anOS : in out OStream from Standard)
|
||||
returns OStream from Standard
|
||||
is redefined;
|
||||
---C++: return &
|
||||
|
||||
fields
|
||||
|
||||
myValue : Real from Standard;
|
||||
|
||||
end Area from XCAFDoc;
|
132
src/XCAFDoc/XCAFDoc_Area.cxx
Executable file
132
src/XCAFDoc/XCAFDoc_Area.cxx
Executable file
@@ -0,0 +1,132 @@
|
||||
// File: XCAFDoc_Area.cxx
|
||||
// Created: Fri Sep 8 10:58:42 2000
|
||||
// Author: data exchange team
|
||||
// <det@nordox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <XCAFDoc_Area.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_Area::XCAFDoc_Area()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Area::GetID()
|
||||
{
|
||||
static Standard_GUID AreaID ("efd212f2-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return AreaID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Area::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_Area) XCAFDoc_Area::Set (const TDF_Label& L,const Standard_Real V)
|
||||
{
|
||||
Handle(XCAFDoc_Area) A;
|
||||
if (!L.FindAttribute(XCAFDoc_Area::GetID(), A)) {
|
||||
A = new XCAFDoc_Area;
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set(V);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Area::Set (const Standard_Real V)
|
||||
{
|
||||
Backup();
|
||||
myValue = V;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Get
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real XCAFDoc_Area::Get() const { return myValue; }
|
||||
|
||||
//=======================================================================
|
||||
//function : Get
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_Area::Get(const TDF_Label& label,Standard_Real& area)
|
||||
{
|
||||
Handle(XCAFDoc_Area) anArea;
|
||||
if (!label.FindAttribute(XCAFDoc_Area::GetID(), anArea))
|
||||
return Standard_False;
|
||||
|
||||
area = anArea->Get();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_Area::NewEmpty () const
|
||||
{
|
||||
return new XCAFDoc_Area();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Area::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
Handle(XCAFDoc_Area) R = Handle(XCAFDoc_Area)::DownCast (With);
|
||||
myValue = R->Get();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Area::Paste (const Handle(TDF_Attribute)& Into,
|
||||
const Handle(TDF_RelocationTable)& /* RT */) const
|
||||
{
|
||||
Handle(XCAFDoc_Area) R = Handle(XCAFDoc_Area)::DownCast (Into);
|
||||
R->Set(myValue);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_OStream& XCAFDoc_Area::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
anOS << "Area ";
|
||||
anOS << Get();
|
||||
return anOS;
|
||||
}
|
68
src/XCAFDoc/XCAFDoc_Centroid.cdl
Executable file
68
src/XCAFDoc/XCAFDoc_Centroid.cdl
Executable file
@@ -0,0 +1,68 @@
|
||||
-- File: XCAFDoc_Centroid.cdl
|
||||
-- Created: Fri Sep 8 11:12:09 2000
|
||||
-- Author: data exchange team
|
||||
-- <det@nordox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class Centroid from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Pnt from gp,
|
||||
Label from TDF,
|
||||
RelocationTable from TDF
|
||||
|
||||
is
|
||||
Create returns Centroid from XCAFDoc;
|
||||
---Purpose: class methods
|
||||
-- =============
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Set (myclass; label : Label from TDF; pnt : Pnt from gp)
|
||||
---Purpose: Find, or create, a Location attribute and set it's value
|
||||
-- the Location attribute is returned.
|
||||
returns Centroid from XCAFDoc;
|
||||
|
||||
---Purpose: Location methods
|
||||
-- ===============
|
||||
|
||||
Set (me : mutable; pnt : Pnt from gp);
|
||||
|
||||
Get (me)
|
||||
returns Pnt from gp;
|
||||
|
||||
Get (myclass ; label : Label from TDF; pnt: in out Pnt from gp)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Returns point as argument
|
||||
-- returns false if no such attribute at the <label>
|
||||
|
||||
---Category: methodes de TDF_Attribute
|
||||
-- =========================
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; With : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; Into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
Dump(me; anOS : in out OStream from Standard)
|
||||
returns OStream from Standard
|
||||
is redefined;
|
||||
---C++: return &
|
||||
|
||||
fields
|
||||
|
||||
myCentroid : Pnt from gp;
|
||||
|
||||
end Centroid;
|
134
src/XCAFDoc/XCAFDoc_Centroid.cxx
Executable file
134
src/XCAFDoc/XCAFDoc_Centroid.cxx
Executable file
@@ -0,0 +1,134 @@
|
||||
// File: XCAFDoc_Centroid.cxx
|
||||
// Created: Fri Sep 8 12:56:06 2000
|
||||
// Author: data exchange team
|
||||
// <det@nordox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <XCAFDoc_Centroid.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_Centroid::XCAFDoc_Centroid()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Centroid::GetID()
|
||||
{
|
||||
static Standard_GUID CentroidID ("efd212f3-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return CentroidID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_Centroid) XCAFDoc_Centroid::Set(const TDF_Label& L,const gp_Pnt& pnt)
|
||||
{
|
||||
Handle(XCAFDoc_Centroid) A;
|
||||
if (!L.FindAttribute (XCAFDoc_Centroid::GetID(), A)) {
|
||||
A = new XCAFDoc_Centroid ();
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set(pnt);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Centroid::Set(const gp_Pnt& pnt)
|
||||
{
|
||||
Backup();
|
||||
myCentroid = pnt;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Get
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
gp_Pnt XCAFDoc_Centroid::Get() const
|
||||
{
|
||||
return myCentroid;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Get
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_Centroid::Get(const TDF_Label& label,gp_Pnt& pnt)
|
||||
{
|
||||
Handle(XCAFDoc_Centroid) aCentroid;
|
||||
if (!label.FindAttribute(XCAFDoc_Centroid::GetID(), aCentroid))
|
||||
return Standard_False;
|
||||
|
||||
pnt = aCentroid->Get();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Centroid::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Centroid::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
myCentroid = Handle(XCAFDoc_Centroid)::DownCast(With)->Get();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_Centroid::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_Centroid();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Centroid::Paste(const Handle(TDF_Attribute)& Into,const Handle(TDF_RelocationTable)& /* RT */) const
|
||||
{
|
||||
Handle(XCAFDoc_Centroid)::DownCast(Into)->Set(myCentroid);
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_OStream& XCAFDoc_Centroid::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
anOS << "Centroid ( ";
|
||||
anOS << myCentroid.X() << ",";
|
||||
anOS << myCentroid.Y() << ",";
|
||||
anOS << myCentroid.Z() << ")";
|
||||
return anOS;
|
||||
}
|
84
src/XCAFDoc/XCAFDoc_Color.cdl
Executable file
84
src/XCAFDoc/XCAFDoc_Color.cdl
Executable file
@@ -0,0 +1,84 @@
|
||||
-- File: XCAFDoc_Color.cdl
|
||||
-- Created: Wed Aug 16 11:36:32 2000
|
||||
-- Author: data exchange team
|
||||
-- <det@strelox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class Color from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Color from Quantity,
|
||||
NameOfColor from Quantity,
|
||||
Label from TDF,
|
||||
RelocationTable from TDF
|
||||
|
||||
is
|
||||
Create returns Color from XCAFDoc;
|
||||
|
||||
---Category: class methods
|
||||
-- =============
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
|
||||
Set (myclass; label : Label from TDF; C : Color from Quantity)
|
||||
returns Color from XCAFDoc;
|
||||
|
||||
Set (myclass; label : Label from TDF; C : NameOfColor from Quantity)
|
||||
returns Color from XCAFDoc;
|
||||
|
||||
Set (myclass; label : Label from TDF; R,G,B : Real from Standard)
|
||||
returns Color from XCAFDoc;
|
||||
|
||||
---Purpose: Find, or create, a Color attribute and set it's value
|
||||
-- the Color attribute is returned.
|
||||
|
||||
|
||||
|
||||
---Category: Color methods
|
||||
-- ===============
|
||||
|
||||
Set (me : mutable; C : Color from Quantity);
|
||||
|
||||
Set (me : mutable; C : NameOfColor from Quantity);
|
||||
|
||||
Set (me : mutable; R,G,B : Real from Standard);
|
||||
|
||||
GetColor (me) returns Color from Quantity;
|
||||
|
||||
GetNOC (me) returns NameOfColor from Quantity;
|
||||
|
||||
GetRGB (me; R,G,B : out Real from Standard);
|
||||
|
||||
--IsCaptured(me) returns Boolean;
|
||||
---Purpose: Returns True if there is a reference on the same label
|
||||
|
||||
---Category: methodes de TDF_Attribute
|
||||
-- =========================
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; With : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; Into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
-- Dump(me; anOS : in out OStream from Standard)
|
||||
-- returns OStream from Standard
|
||||
-- is redefined;
|
||||
-- -C++: return &
|
||||
|
||||
fields
|
||||
myColor : Color from Quantity;
|
||||
|
||||
end Color;
|
189
src/XCAFDoc/XCAFDoc_Color.cxx
Executable file
189
src/XCAFDoc/XCAFDoc_Color.cxx
Executable file
@@ -0,0 +1,189 @@
|
||||
// File: XCAFDoc_Color.cxx
|
||||
// Created: Wed Aug 16 11:52:13 2000
|
||||
// Author: data exchange team
|
||||
// <det@strelox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <TDF_RelocationTable.hxx>
|
||||
#include <XCAFDoc_Color.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_Color::XCAFDoc_Color()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Color::GetID()
|
||||
{
|
||||
static Standard_GUID ColorID ("efd212f0-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return ColorID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
|
||||
const Quantity_Color& C)
|
||||
{
|
||||
Handle(XCAFDoc_Color) A;
|
||||
if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
|
||||
A = new XCAFDoc_Color ();
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (C);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
|
||||
const Quantity_NameOfColor C)
|
||||
{
|
||||
Handle(XCAFDoc_Color) A;
|
||||
if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
|
||||
A = new XCAFDoc_Color ();
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (C);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_Color) XCAFDoc_Color::Set(const TDF_Label& L,
|
||||
const Standard_Real R,
|
||||
const Standard_Real G,
|
||||
const Standard_Real B)
|
||||
{
|
||||
Handle(XCAFDoc_Color) A;
|
||||
if (!L.FindAttribute (XCAFDoc_Color::GetID(), A)) {
|
||||
A = new XCAFDoc_Color ();
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (R,G,B);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Color::Set(const Quantity_Color& C)
|
||||
{
|
||||
Backup();
|
||||
myColor = C;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Color::Set(const Quantity_NameOfColor C)
|
||||
{
|
||||
Backup();
|
||||
myColor.SetValues(C);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Color::Set(const Standard_Real R,
|
||||
const Standard_Real G,
|
||||
const Standard_Real B)
|
||||
{
|
||||
Backup();
|
||||
myColor.SetValues(R,G,B, Quantity_TOC_RGB);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Quantity_Color XCAFDoc_Color::GetColor() const
|
||||
{
|
||||
return myColor;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetNOC
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Quantity_NameOfColor XCAFDoc_Color::GetNOC() const
|
||||
{
|
||||
return myColor.Name();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetRGB
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Color::GetRGB(Standard_Real& R,
|
||||
Standard_Real& G,
|
||||
Standard_Real& B) const
|
||||
{
|
||||
myColor.Values(R,G,B, Quantity_TOC_RGB);
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Color::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Color::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
myColor = Handle(XCAFDoc_Color)::DownCast(With)->GetColor();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_Color::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_Color();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Color::Paste(const Handle(TDF_Attribute)& Into,
|
||||
const Handle(TDF_RelocationTable)& /* RT */) const
|
||||
{
|
||||
Handle(XCAFDoc_Color)::DownCast(Into)->Set(myColor);
|
||||
}
|
||||
|
216
src/XCAFDoc/XCAFDoc_ColorTool.cdl
Executable file
216
src/XCAFDoc/XCAFDoc_ColorTool.cdl
Executable file
@@ -0,0 +1,216 @@
|
||||
-- File: XCAFDoc_ColorTool.cdl
|
||||
-- Created: Thu May 11 10:05:27 2000
|
||||
-- Author: Edward AGAPOV
|
||||
-- <det@strelox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class ColorTool from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose: Provides tools to store and retrieve attributes (colors)
|
||||
-- of TopoDS_Shape in and from TDocStd_Document
|
||||
-- A Document is intended to hold different
|
||||
-- attributes of ONE shape and it's sub-shapes
|
||||
|
||||
uses
|
||||
Color from Quantity,
|
||||
Shape from TopoDS,
|
||||
Label from TDF,
|
||||
LabelSequence from TDF,
|
||||
Document from TDocStd,
|
||||
ColorType from XCAFDoc,
|
||||
ShapeTool from XCAFDoc,
|
||||
RelocationTable from TDF
|
||||
|
||||
is
|
||||
Create returns ColorTool from XCAFDoc;
|
||||
|
||||
Set (myclass; L : Label from TDF) returns ColorTool from XCAFDoc;
|
||||
---Purpose: Creates (if not exist) ColorTool.
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
|
||||
|
||||
---API: General structure
|
||||
|
||||
BaseLabel(me) returns Label from TDF;
|
||||
---Purpose: returns the label under which colors are stored
|
||||
|
||||
ShapeTool (me: mutable) returns ShapeTool from XCAFDoc;
|
||||
---Purpose: Returns internal XCAFDoc_ShapeTool tool
|
||||
---C++: return const &
|
||||
|
||||
---API: Color table management
|
||||
|
||||
IsColor (me; lab: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if label belongs to a colortable and
|
||||
-- is a color definition
|
||||
|
||||
GetColor (me; lab: Label from TDF; col: out Color from Quantity)
|
||||
returns Boolean;
|
||||
---Purpose: Returns color defined by label lab
|
||||
-- Returns False if the label is not in colortable
|
||||
-- or does not define a color
|
||||
|
||||
FindColor (me; col: Color from Quantity; lab: out Label from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Finds a color definition in a colortable and returns
|
||||
-- its label if found
|
||||
-- Returns False if color is not found in colortable
|
||||
|
||||
FindColor (me; col: Color from Quantity) returns Label from TDF;
|
||||
---Purpose: Finds a color definition in a colortable and returns
|
||||
-- its label if found (or Null label else)
|
||||
|
||||
AddColor (me; col: Color from Quantity) returns Label from TDF;
|
||||
---Purpose: Adds a color definition to a colortable and returns
|
||||
-- its label (returns existing label if the same color
|
||||
-- is already defined)
|
||||
|
||||
RemoveColor (me; lab: Label from TDF);
|
||||
---Purpose: Removes color from the colortable
|
||||
|
||||
GetColors (me; Labels: out LabelSequence from TDF);
|
||||
---Purpose: Returns a sequence of colors currently stored
|
||||
-- in the colortable
|
||||
|
||||
---API: Assignment of colors to labels
|
||||
|
||||
SetColor (me; L: Label from TDF;
|
||||
colorL: Label from TDF;
|
||||
type : ColorType from XCAFDoc);
|
||||
---Purpose: Sets a link with GUID defined by <type> (see
|
||||
-- XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||
-- defined by <colorL>
|
||||
|
||||
SetColor (me; L: Label from TDF;
|
||||
Color: Color from Quantity;
|
||||
type : ColorType from XCAFDoc);
|
||||
---Purpose: Sets a link with GUID defined by <type> (see
|
||||
-- XCAFDoc::ColorRefGUID()) from label <L> to color <Color>
|
||||
-- in the colortable
|
||||
-- Adds a color as necessary
|
||||
|
||||
UnSetColor (me; L: Label from TDF;
|
||||
type : ColorType from XCAFDoc);
|
||||
---Purpose: Removes a link with GUID defined by <type> (see
|
||||
-- XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||
|
||||
IsSet (me; L: Label from TDF;
|
||||
type : ColorType from XCAFDoc) returns Boolean;
|
||||
---Purpose: Returns True if label <L> has a color assignment
|
||||
-- of the type <type>
|
||||
|
||||
GetColor (me: mutable; L: Label from TDF;
|
||||
type : ColorType from XCAFDoc;
|
||||
colorL: out Label from TDF) returns Boolean;
|
||||
---Purpose: Returns label with color assigned to <L> as <type>
|
||||
-- Returns False if no such color is assigned
|
||||
|
||||
GetColor (me: mutable; L: Label from TDF;
|
||||
type : ColorType from XCAFDoc;
|
||||
color: out Color from Quantity) returns Boolean;
|
||||
---Purpose: Returns color assigned to <L> as <type>
|
||||
-- Returns False if no such color is assigned
|
||||
|
||||
---API: Assignment of colors to shapes in Shapes section
|
||||
|
||||
SetColor (me: mutable; S: Shape from TopoDS;
|
||||
colorL: Label from TDF;
|
||||
type : ColorType from XCAFDoc) returns Boolean;
|
||||
---Purpose: Sets a link with GUID defined by <type> (see
|
||||
-- XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||
-- defined by <colorL>
|
||||
-- Returns False if cannot find a label for shape S
|
||||
|
||||
SetColor (me: mutable; S: Shape from TopoDS;
|
||||
Color: Color from Quantity;
|
||||
type : ColorType from XCAFDoc) returns Boolean;
|
||||
---Purpose: Sets a link with GUID defined by <type> (see
|
||||
-- XCAFDoc::ColorRefGUID()) from label <L> to color <Color>
|
||||
-- in the colortable
|
||||
-- Adds a color as necessary
|
||||
-- Returns False if cannot find a label for shape S
|
||||
|
||||
UnSetColor (me: mutable; S: Shape from TopoDS;
|
||||
type : ColorType from XCAFDoc) returns Boolean;
|
||||
---Purpose: Removes a link with GUID defined by <type> (see
|
||||
-- XCAFDoc::ColorRefGUID()) from label <L> to color
|
||||
-- Returns True if such link existed
|
||||
|
||||
IsSet (me: mutable; S: Shape from TopoDS;
|
||||
type : ColorType from XCAFDoc) returns Boolean;
|
||||
---Purpose: Returns True if label <L> has a color assignment
|
||||
-- of the type <type>
|
||||
|
||||
GetColor (me: mutable; S: Shape from TopoDS;
|
||||
type : ColorType from XCAFDoc;
|
||||
colorL: out Label from TDF) returns Boolean;
|
||||
---Purpose: Returns label with color assigned to <L> as <type>
|
||||
-- Returns False if no such color is assigned
|
||||
|
||||
GetColor (me: mutable; S: Shape from TopoDS;
|
||||
type : ColorType from XCAFDoc;
|
||||
color: out Color from Quantity) returns Boolean;
|
||||
---Purpose: Returns color assigned to <L> as <type>
|
||||
-- Returns False if no such color is assigned
|
||||
|
||||
IsVisible (me; L: Label from TDF)
|
||||
---Purpose: Return TRUE if object on this label is visible, FALSE if invisible.
|
||||
returns Boolean;
|
||||
|
||||
SetVisibility (me: mutable; shapeLabel: Label from TDF;
|
||||
isvisible: Boolean = Standard_True);
|
||||
---Purpose: Set the visibility of object on label. Do nothing if there no any object.
|
||||
-- Set UAttribute with corresponding GUID.
|
||||
|
||||
SetInstanceColor (me: mutable; theShape : Shape from TopoDS;
|
||||
type : ColorType from XCAFDoc;
|
||||
color: Color from Quantity;
|
||||
isCreateSHUO : Boolean = Standard_True)
|
||||
returns Boolean;
|
||||
---Purpose: Sets the color of component that styled with SHUO structure
|
||||
-- Returns FALSE if no sush component found
|
||||
-- NOTE: create SHUO structeure if it is necessary and if <isCreateSHUO>
|
||||
|
||||
GetInstanceColor (me: mutable; theShape : Shape from TopoDS;
|
||||
type : ColorType from XCAFDoc;
|
||||
color: out Color from Quantity)
|
||||
returns Boolean;
|
||||
---Purpose: Gets the color of component that styled with SHUO structure
|
||||
-- Returns FALSE if no sush component or color type
|
||||
|
||||
IsInstanceVisible (me: mutable; theShape : Shape from TopoDS)
|
||||
returns Boolean;
|
||||
---Purpose: Gets the visibility status of component that styled with SHUO structure
|
||||
-- Returns FALSE if no sush component
|
||||
|
||||
ReverseChainsOfTreeNodes(me: mutable) returns Boolean; -- skl 11.11.2003
|
||||
---Purpose: Reverses order in chains of TreeNodes (from Last to First) under
|
||||
-- each Color Label since we became to use function ::Prepend()
|
||||
-- instead of ::Append() in method SetColor() for acceleration
|
||||
|
||||
|
||||
---Category: TDF_Attribute methods
|
||||
-- =====================
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; with : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
fields
|
||||
|
||||
myShapeTool: ShapeTool from XCAFDoc;
|
||||
|
||||
end ColorTool;
|
592
src/XCAFDoc/XCAFDoc_ColorTool.cxx
Executable file
592
src/XCAFDoc/XCAFDoc_ColorTool.cxx
Executable file
@@ -0,0 +1,592 @@
|
||||
#include <XCAFDoc_ColorTool.ixx>
|
||||
#include <XCAFDoc.hxx>
|
||||
#include <XCAFDoc_Color.hxx>
|
||||
|
||||
#include <TDF_ChildIDIterator.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TNaming_NamedShape.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_Color.hxx>
|
||||
#include <TDataStd_UAttribute.hxx>
|
||||
#include <XCAFDoc_GraphNode.hxx>
|
||||
|
||||
#define AUTONAMING // automatically set names for labels
|
||||
|
||||
//=======================================================================
|
||||
//function : BaseLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_ColorTool::BaseLabel() const
|
||||
{
|
||||
return Label();
|
||||
}
|
||||
//=======================================================================
|
||||
//function : ShapeTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Handle(XCAFDoc_ShapeTool)& XCAFDoc_ColorTool::ShapeTool()
|
||||
{
|
||||
if (myShapeTool.IsNull())
|
||||
myShapeTool = XCAFDoc_DocumentTool::ShapeTool(Label());
|
||||
return myShapeTool;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::IsColor (const TDF_Label& lab) const
|
||||
{
|
||||
Quantity_Color C;
|
||||
return GetColor ( lab, C );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::GetColor (const TDF_Label& lab,
|
||||
Quantity_Color& col) const
|
||||
{
|
||||
if ( lab.Father() != Label() ) return Standard_False;
|
||||
|
||||
Handle(XCAFDoc_Color) ColorAttribute;
|
||||
if ( ! lab.FindAttribute ( XCAFDoc_Color::GetID(), ColorAttribute ))
|
||||
return Standard_False;
|
||||
|
||||
col = ColorAttribute->GetColor();
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::FindColor (const Quantity_Color& col, TDF_Label& lab) const
|
||||
{
|
||||
TDF_ChildIDIterator it(Label(),XCAFDoc_Color::GetID());
|
||||
for (; it.More(); it.Next()) {
|
||||
TDF_Label aLabel = it.Value()->Label();
|
||||
Quantity_Color C;
|
||||
if ( ! GetColor ( aLabel, C ) ) continue;
|
||||
if ( C.IsEqual ( col ) ) {
|
||||
lab = aLabel;
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_ColorTool::FindColor (const Quantity_Color& col) const
|
||||
{
|
||||
TDF_Label L;
|
||||
FindColor ( col, L );
|
||||
return L;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_ColorTool::AddColor (const Quantity_Color& col) const
|
||||
{
|
||||
TDF_Label L;
|
||||
if ( FindColor ( col, L ) ) return L;
|
||||
|
||||
// create a new color entry
|
||||
|
||||
TDF_TagSource aTag;
|
||||
L = aTag.NewChild ( Label() );
|
||||
|
||||
XCAFDoc_Color::Set(L, col);
|
||||
|
||||
#ifdef AUTONAMING
|
||||
// set name according to color value
|
||||
TCollection_AsciiString str;
|
||||
str += col.StringName ( col.Name() );
|
||||
str += " (";
|
||||
str += TCollection_AsciiString ( col.Red() );
|
||||
str += ",";
|
||||
str += TCollection_AsciiString ( col.Green() );
|
||||
str += ",";
|
||||
str += TCollection_AsciiString ( col.Blue() );
|
||||
str += ")";
|
||||
TDataStd_Name::Set ( L, str );
|
||||
#endif
|
||||
|
||||
return L;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ColorTool::RemoveColor (const TDF_Label& lab) const
|
||||
{
|
||||
lab.ForgetAllAttributes (Standard_True);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColors
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ColorTool::GetColors (TDF_LabelSequence& Labels) const
|
||||
{
|
||||
Labels.Clear();
|
||||
|
||||
TDF_ChildIDIterator ChildIDIterator(Label(),XCAFDoc_Color::GetID());
|
||||
for (; ChildIDIterator.More(); ChildIDIterator.Next()) {
|
||||
TDF_Label L = ChildIDIterator.Value()->Label();
|
||||
if ( IsColor ( L ) ) Labels.Append ( L );
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ColorTool::SetColor (const TDF_Label& L,
|
||||
const TDF_Label& colorL,
|
||||
const XCAFDoc_ColorType type) const
|
||||
{
|
||||
// set reference
|
||||
Handle(TDataStd_TreeNode) refNode, mainNode;
|
||||
mainNode = TDataStd_TreeNode::Set ( colorL, XCAFDoc::ColorRefGUID(type) );
|
||||
refNode = TDataStd_TreeNode::Set ( L, XCAFDoc::ColorRefGUID(type) );
|
||||
refNode->Remove(); // abv: fix against bug in TreeNode::Append()
|
||||
mainNode->Prepend(refNode);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ColorTool::SetColor (const TDF_Label& L,
|
||||
const Quantity_Color& Color,
|
||||
const XCAFDoc_ColorType type) const
|
||||
{
|
||||
TDF_Label colorL = AddColor ( Color );
|
||||
SetColor ( L, colorL, type );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ColorTool::UnSetColor (const TDF_Label& L, const XCAFDoc_ColorType type) const
|
||||
{
|
||||
L.ForgetAttribute ( XCAFDoc::ColorRefGUID(type) );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::IsSet (const TDF_Label& L, const XCAFDoc_ColorType type) const
|
||||
{
|
||||
Handle(TDataStd_TreeNode) Node;
|
||||
return L.FindAttribute ( XCAFDoc::ColorRefGUID(type), Node) && Node->HasFather();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::GetColor (const TDF_Label& L,
|
||||
const XCAFDoc_ColorType type,
|
||||
TDF_Label& colorL)
|
||||
{
|
||||
Handle(TDataStd_TreeNode) Node;
|
||||
if ( ! L.FindAttribute ( XCAFDoc::ColorRefGUID(type), Node) ||
|
||||
! Node->HasFather() ) return Standard_False;
|
||||
colorL = Node->Father()->Label();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::GetColor (const TDF_Label& L,
|
||||
const XCAFDoc_ColorType type,
|
||||
Quantity_Color& color)
|
||||
{
|
||||
TDF_Label colorL;
|
||||
if ( ! GetColor ( L, type, colorL ) ) return Standard_False;
|
||||
return GetColor ( colorL, color );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::SetColor (const TopoDS_Shape& S,
|
||||
const TDF_Label& colorL,
|
||||
const XCAFDoc_ColorType type)
|
||||
{
|
||||
TDF_Label L;
|
||||
if ( ! ShapeTool()->Search ( S, L ) ) return Standard_False;
|
||||
SetColor ( L, colorL, type );
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::SetColor (const TopoDS_Shape& S,
|
||||
const Quantity_Color& Color,
|
||||
const XCAFDoc_ColorType type)
|
||||
{
|
||||
TDF_Label colorL = AddColor ( Color );
|
||||
return SetColor ( S, colorL, type );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::UnSetColor (const TopoDS_Shape& S,
|
||||
const XCAFDoc_ColorType type)
|
||||
{
|
||||
TDF_Label L;
|
||||
if ( ! ShapeTool()->Search ( S, L ) ) return Standard_False;
|
||||
UnSetColor ( L, type );
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::IsSet (const TopoDS_Shape& S,
|
||||
const XCAFDoc_ColorType type)
|
||||
{
|
||||
TDF_Label L;
|
||||
if ( ! ShapeTool()->Search ( S, L ) ) return Standard_False;
|
||||
return IsSet ( L, type );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::GetColor (const TopoDS_Shape& S,
|
||||
const XCAFDoc_ColorType type,
|
||||
TDF_Label& colorL)
|
||||
{
|
||||
TDF_Label L;
|
||||
if ( ! ShapeTool()->Search ( S, L ) ) return Standard_False;
|
||||
return GetColor ( L, type, colorL );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::GetColor (const TopoDS_Shape& S,
|
||||
const XCAFDoc_ColorType type,
|
||||
Quantity_Color& color)
|
||||
{
|
||||
TDF_Label colorL;
|
||||
if ( ! GetColor ( S, type, colorL ) ) return Standard_False;
|
||||
return GetColor ( colorL, color );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_ColorTool::GetID()
|
||||
{
|
||||
static Standard_GUID ColorTblID ("efd212ed-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return ColorTblID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_ColorTool) XCAFDoc_ColorTool::Set(const TDF_Label& L)
|
||||
{
|
||||
Handle(XCAFDoc_ColorTool) A;
|
||||
if (!L.FindAttribute (XCAFDoc_ColorTool::GetID(), A)) {
|
||||
A = new XCAFDoc_ColorTool ();
|
||||
L.AddAttribute(A);
|
||||
A->myShapeTool = XCAFDoc_DocumentTool::ShapeTool(L);
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_ColorTool::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ColorTool::Restore(const Handle(TDF_Attribute)& /*with*/)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_ColorTool::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_ColorTool;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ColorTool::Paste (const Handle(TDF_Attribute)& /*into*/,
|
||||
const Handle(TDF_RelocationTable)& /*RT*/) const
|
||||
{
|
||||
}
|
||||
|
||||
/**/
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFDoc_ColorTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_ColorTool::XCAFDoc_ColorTool()
|
||||
{
|
||||
}
|
||||
|
||||
// PTV 23.01.2003 add visibility flag for objects (CAX-IF TRJ11)
|
||||
//=======================================================================
|
||||
//function : IsVisible
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::IsVisible (const TDF_Label& L) const
|
||||
{
|
||||
Handle(TDataStd_UAttribute) aUAttr;
|
||||
return (!L.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetVisibility
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ColorTool::SetVisibility (const TDF_Label& L,
|
||||
const Standard_Boolean isvisible)
|
||||
{
|
||||
Handle(TDataStd_UAttribute) aUAttr;
|
||||
if (! isvisible ) {
|
||||
Handle(XCAFDoc_GraphNode) aSHUO;
|
||||
if (ShapeTool()->IsShape(L) || ShapeTool()->GetSHUO( L, aSHUO ) )
|
||||
if (!L.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr))
|
||||
aUAttr->Set( L, XCAFDoc::InvisibleGUID() );
|
||||
}
|
||||
else L.ForgetAttribute( XCAFDoc::InvisibleGUID() );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetInstanceColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::SetInstanceColor (const TopoDS_Shape& theShape,
|
||||
const XCAFDoc_ColorType type,
|
||||
const Quantity_Color& color,
|
||||
const Standard_Boolean IsCreateSHUO)
|
||||
{
|
||||
// find shuo label structure
|
||||
TDF_LabelSequence aLabels;
|
||||
if ( !ShapeTool()->FindComponent( theShape, aLabels ) )
|
||||
return Standard_False;
|
||||
Handle(XCAFDoc_GraphNode) aSHUO;
|
||||
// set the SHUO structure for this component if it is not exist
|
||||
if ( !ShapeTool()->FindSHUO( aLabels, aSHUO ) )
|
||||
if (aLabels.Length() == 1) {
|
||||
// set color directly for component as NAUO
|
||||
SetColor(aLabels.Value(1), color, type);
|
||||
return Standard_True;
|
||||
}
|
||||
else if ( !IsCreateSHUO || !ShapeTool()->SetSHUO( aLabels, aSHUO ) )
|
||||
return Standard_False;
|
||||
TDF_Label aSHUOLabel = aSHUO->Label();
|
||||
SetColor( aSHUOLabel, color, type );
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetInstanceColor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::GetInstanceColor (const TopoDS_Shape& theShape,
|
||||
const XCAFDoc_ColorType type,
|
||||
Quantity_Color& color)
|
||||
{
|
||||
// find shuo label structure
|
||||
TDF_LabelSequence aLabels;
|
||||
if ( !ShapeTool()->FindComponent( theShape, aLabels ) )
|
||||
return Standard_False;
|
||||
Handle(XCAFDoc_GraphNode) aSHUO;
|
||||
// get shuo from document by label structure
|
||||
TDF_Label aCompLab = aLabels.Value(aLabels.Length());
|
||||
while (aLabels.Length() > 1) {
|
||||
if ( !ShapeTool()->FindSHUO( aLabels, aSHUO ) ) {
|
||||
// try to find other shuo
|
||||
aLabels.Remove(aLabels.Length());
|
||||
continue;
|
||||
} else {
|
||||
TDF_Label aSHUOLabel = aSHUO->Label();
|
||||
if (GetColor ( aSHUOLabel, type, color ) )
|
||||
return Standard_True;
|
||||
else
|
||||
// try to find other shuo
|
||||
aLabels.Remove(aLabels.Length());
|
||||
}
|
||||
}
|
||||
// attempt to get color exactly of component
|
||||
if (GetColor( aCompLab, type, color ))
|
||||
return Standard_True;
|
||||
|
||||
// attempt to get color of solid
|
||||
TopLoc_Location aLoc;
|
||||
TopoDS_Shape S0 = theShape;
|
||||
S0.Location( aLoc );
|
||||
TDF_Label aRefLab = ShapeTool()->FindShape( S0 );
|
||||
if (!aRefLab.IsNull())
|
||||
return GetColor( aRefLab, type, color );
|
||||
// no color assigned
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsInstanceVisible
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::IsInstanceVisible (const TopoDS_Shape& theShape)
|
||||
{
|
||||
// check visibility status of top-level solid, cause it is have highest priority
|
||||
TopLoc_Location NullLoc;
|
||||
TopoDS_Shape S0 = theShape;
|
||||
S0.Location( NullLoc );
|
||||
TDF_Label aRefL = ShapeTool()->FindShape( S0 );
|
||||
if (!aRefL.IsNull() && !IsVisible(aRefL))
|
||||
return Standard_False;
|
||||
// find shuo label structure
|
||||
TDF_LabelSequence aLabels;
|
||||
if ( !ShapeTool()->FindComponent( theShape, aLabels ) )
|
||||
return Standard_True;
|
||||
TDF_Label aCompLab = aLabels.Value(aLabels.Length());
|
||||
// visibility status of component withouts SHUO.
|
||||
if (!IsVisible( aCompLab ))
|
||||
return Standard_False;
|
||||
// check by SHUO structure
|
||||
TDF_LabelSequence aCurLabels;
|
||||
aCurLabels.Append(aCompLab);
|
||||
Standard_Integer i = aLabels.Length() - 1;
|
||||
// while (aCurLabels.Length() < aLabels.Length()) {
|
||||
while (i >= 1) {
|
||||
aCurLabels.Prepend( aLabels.Value(i--) );
|
||||
// get shuo from document by label structure
|
||||
Handle(XCAFDoc_GraphNode) aSHUO;
|
||||
if ( !ShapeTool()->FindSHUO( aCurLabels, aSHUO ) )
|
||||
continue;
|
||||
if ( !IsVisible(aSHUO->Label()) )
|
||||
return Standard_False;
|
||||
}
|
||||
return Standard_True; //visible, cause cannot find invisibility status
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReverseTreeNodes
|
||||
//purpose : auxilary
|
||||
//=======================================================================
|
||||
static void ReverseTreeNodes(Handle(TDataStd_TreeNode)& mainNode)
|
||||
{
|
||||
if(mainNode->HasFirst()) {
|
||||
Handle(TDataStd_TreeNode) tmpNode;
|
||||
Handle(TDataStd_TreeNode) pNode = mainNode->First();
|
||||
Handle(TDataStd_TreeNode) nNode = pNode->Next();
|
||||
while(!nNode.IsNull()) {
|
||||
tmpNode = pNode->Previous();
|
||||
pNode->SetPrevious(nNode);
|
||||
pNode->SetNext(tmpNode);
|
||||
pNode = nNode;
|
||||
nNode = pNode->Next();
|
||||
}
|
||||
tmpNode = pNode->Previous();
|
||||
pNode->SetPrevious(nNode);
|
||||
pNode->SetNext(tmpNode);
|
||||
mainNode->SetFirst(pNode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ReverseChainsOfTreeNodes
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ColorTool::ReverseChainsOfTreeNodes()
|
||||
{
|
||||
TDF_ChildIDIterator it(Label(),XCAFDoc_Color::GetID());
|
||||
for (; it.More(); it.Next()) {
|
||||
TDF_Label aLabel = it.Value()->Label();
|
||||
Handle(TDataStd_TreeNode) mainNode;
|
||||
if(aLabel.FindAttribute(XCAFDoc::ColorRefGUID(XCAFDoc_ColorSurf),mainNode)) {
|
||||
ReverseTreeNodes(mainNode);
|
||||
}
|
||||
if(aLabel.FindAttribute(XCAFDoc::ColorRefGUID(XCAFDoc_ColorCurv),mainNode)) {
|
||||
ReverseTreeNodes(mainNode);
|
||||
}
|
||||
if(aLabel.FindAttribute(XCAFDoc::ColorRefGUID(XCAFDoc_ColorGen),mainNode)) {
|
||||
ReverseTreeNodes(mainNode);
|
||||
}
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
59
src/XCAFDoc/XCAFDoc_Datum.cdl
Executable file
59
src/XCAFDoc/XCAFDoc_Datum.cdl
Executable file
@@ -0,0 +1,59 @@
|
||||
-- File: XCAFDoc_Datum.cdl
|
||||
-- Created: Thu Jan 15 16:30:53 2004
|
||||
-- Author: Sergey KUUL
|
||||
-- <skl@petrox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2004
|
||||
|
||||
class Datum from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Label from TDF,
|
||||
RelocationTable from TDF,
|
||||
HAsciiString from TCollection
|
||||
|
||||
is
|
||||
Create returns Datum from XCAFDoc;
|
||||
|
||||
---Category: class methods
|
||||
-- =============
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Set (myclass; label : Label from TDF;
|
||||
aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
anIdentification : HAsciiString from TCollection)
|
||||
returns Datum from XCAFDoc;
|
||||
|
||||
Set (me : mutable; aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
anIdentification : HAsciiString from TCollection);
|
||||
|
||||
GetName (me) returns HAsciiString from TCollection;
|
||||
|
||||
GetDescription (me) returns HAsciiString from TCollection;
|
||||
|
||||
GetIdentification (me) returns HAsciiString from TCollection;
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; With : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; Into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
fields
|
||||
myName : HAsciiString from TCollection;
|
||||
myDescription : HAsciiString from TCollection;
|
||||
myIdentification : HAsciiString from TCollection;
|
||||
|
||||
end Datum;
|
143
src/XCAFDoc/XCAFDoc_Datum.cxx
Executable file
143
src/XCAFDoc/XCAFDoc_Datum.cxx
Executable file
@@ -0,0 +1,143 @@
|
||||
#include <XCAFDoc_Datum.ixx>
|
||||
|
||||
#include <TDF_RelocationTable.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFDoc_Datum
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_Datum::XCAFDoc_Datum()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Datum::GetID()
|
||||
{
|
||||
static Standard_GUID DID("58ed092e-44de-11d8-8776-001083004c77");
|
||||
//static Standard_GUID ID("efd212e2-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return DID;
|
||||
//return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_Datum) XCAFDoc_Datum::Set(const TDF_Label& label,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
const Handle(TCollection_HAsciiString)& anIdentification)
|
||||
{
|
||||
Handle(XCAFDoc_Datum) A;
|
||||
if (!label.FindAttribute(XCAFDoc_Datum::GetID(), A)) {
|
||||
A = new XCAFDoc_Datum();
|
||||
label.AddAttribute(A);
|
||||
}
|
||||
A->Set(aName,aDescription,anIdentification);
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Datum::Set(const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
const Handle(TCollection_HAsciiString)& anIdentification)
|
||||
{
|
||||
myName = aName;
|
||||
myDescription = aDescription;
|
||||
myIdentification = anIdentification;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetName
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TCollection_HAsciiString) XCAFDoc_Datum::GetName() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDescription
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TCollection_HAsciiString) XCAFDoc_Datum::GetDescription() const
|
||||
{
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetIdentification
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TCollection_HAsciiString) XCAFDoc_Datum::GetIdentification() const
|
||||
{
|
||||
return myIdentification;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Datum::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Datum::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
myName = Handle(XCAFDoc_Datum)::DownCast(With)->GetName();
|
||||
myDescription = Handle(XCAFDoc_Datum)::DownCast(With)->GetDescription();
|
||||
myIdentification = Handle(XCAFDoc_Datum)::DownCast(With)->GetIdentification();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_Datum::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_Datum();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Datum::Paste(const Handle(TDF_Attribute)& Into,
|
||||
const Handle(TDF_RelocationTable)& /*RT*/) const
|
||||
{
|
||||
Handle(XCAFDoc_Datum)::DownCast(Into)->Set(myName,myDescription,myIdentification);
|
||||
}
|
||||
|
91
src/XCAFDoc/XCAFDoc_DimTol.cdl
Executable file
91
src/XCAFDoc/XCAFDoc_DimTol.cdl
Executable file
@@ -0,0 +1,91 @@
|
||||
-- File: XCAFDoc_DimTol.cdl
|
||||
-- Created: Fri Jan 9 14:24:20 2004
|
||||
-- Author: Sergey KUUL
|
||||
-- <skl@petrox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2004
|
||||
|
||||
class DimTol from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Label from TDF,
|
||||
RelocationTable from TDF,
|
||||
HArray1OfReal from TColStd,
|
||||
HAsciiString from TCollection
|
||||
|
||||
is
|
||||
Create returns DimTol from XCAFDoc;
|
||||
|
||||
---Category: class methods
|
||||
-- =============
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Set (myclass; label : Label from TDF; kind : Integer from Standard;
|
||||
aVal : HArray1OfReal from TColStd;
|
||||
aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection)
|
||||
returns DimTol from XCAFDoc;
|
||||
|
||||
Set (me : mutable; kind : Integer from Standard;
|
||||
aVal : HArray1OfReal from TColStd;
|
||||
aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection);
|
||||
|
||||
GetKind (me) returns Integer from Standard;
|
||||
|
||||
GetVal (me) returns HArray1OfReal from TColStd;
|
||||
|
||||
GetName (me) returns HAsciiString from TCollection;
|
||||
|
||||
GetDescription (me) returns HAsciiString from TCollection;
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; With : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; Into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
fields
|
||||
myKind : Integer from Standard;
|
||||
myVal : HArray1OfReal from TColStd;
|
||||
myName : HAsciiString from TCollection;
|
||||
myDescription : HAsciiString from TCollection;
|
||||
-- Table of kinds:
|
||||
-- dimensions:
|
||||
-- 1 - diameter
|
||||
--
|
||||
-- tolerances with datum references:
|
||||
-- 21 - GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol (ModGeoTol->MaximumMaterialCondition)
|
||||
-- 22 - GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol (ModGeoTol->LeastMaterialCondition)
|
||||
-- 23 - GeoTolAndGeoTolWthDatRefAndModGeoTolAndPosTol (ModGeoTol->RegardlessOfFeatureSize)
|
||||
-- 24 - AngularityTolerance
|
||||
-- 25 - CircularRunoutTolerance
|
||||
-- 26 - CoaxialityTolerance
|
||||
-- 27 - ConcentricityTolerance
|
||||
-- 28 - ParallelismTolerance
|
||||
-- 29 - PerpendicularityTolerance
|
||||
-- 30 - SymmetryTolerance
|
||||
-- 31 - TotalRunoutTolerance
|
||||
-- tolerances without datum references:
|
||||
-- 35 - ModifiedGeometricTolerance (MaximumMaterialCondition)
|
||||
-- 36 - ModifiedGeometricTolerance (LeastMaterialCondition)
|
||||
-- 37 - ModifiedGeometricTolerance (RegardlessOfFeatureSize)
|
||||
-- 38 - CylindricityTolerance
|
||||
-- 39 - FlatnessTolerance
|
||||
-- 40 - LineProfileTolerance
|
||||
-- 41 - PositionTolerance
|
||||
-- 42 - RoundnessTolerance
|
||||
-- 43 - StraightnessTolerance
|
||||
-- 44 - SurfaceProfileTolerance
|
||||
|
||||
end DimTol;
|
158
src/XCAFDoc/XCAFDoc_DimTol.cxx
Executable file
158
src/XCAFDoc/XCAFDoc_DimTol.cxx
Executable file
@@ -0,0 +1,158 @@
|
||||
#include <XCAFDoc_DimTol.ixx>
|
||||
|
||||
#include <TDF_RelocationTable.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFDoc_DimTol
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_DimTol::XCAFDoc_DimTol()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_DimTol::GetID()
|
||||
{
|
||||
static Standard_GUID DGTID ("58ed092d-44de-11d8-8776-001083004c77");
|
||||
//static Standard_GUID ID("efd212e9-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return DGTID;
|
||||
//return ID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_DimTol) XCAFDoc_DimTol::Set(const TDF_Label& label,
|
||||
const Standard_Integer kind,
|
||||
const Handle(TColStd_HArray1OfReal)& aVal,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription)
|
||||
{
|
||||
Handle(XCAFDoc_DimTol) A;
|
||||
if (!label.FindAttribute(XCAFDoc_DimTol::GetID(), A)) {
|
||||
A = new XCAFDoc_DimTol();
|
||||
label.AddAttribute(A);
|
||||
}
|
||||
A->Set(kind,aVal,aName,aDescription);
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTol::Set(const Standard_Integer kind,
|
||||
const Handle(TColStd_HArray1OfReal)& aVal,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription)
|
||||
{
|
||||
myKind = kind;
|
||||
myVal = aVal;
|
||||
myName = aName;
|
||||
myDescription = aDescription;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetKind
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer XCAFDoc_DimTol::GetKind() const
|
||||
{
|
||||
return myKind;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetVal
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TColStd_HArray1OfReal) XCAFDoc_DimTol::GetVal() const
|
||||
{
|
||||
return myVal;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetName
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TCollection_HAsciiString) XCAFDoc_DimTol::GetName() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDescription
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TCollection_HAsciiString) XCAFDoc_DimTol::GetDescription() const
|
||||
{
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_DimTol::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTol::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
myKind = Handle(XCAFDoc_DimTol)::DownCast(With)->GetKind();
|
||||
myVal = Handle(XCAFDoc_DimTol)::DownCast(With)->GetVal();
|
||||
myName = Handle(XCAFDoc_DimTol)::DownCast(With)->GetName();
|
||||
myDescription = Handle(XCAFDoc_DimTol)::DownCast(With)->GetDescription();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_DimTol::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_DimTol();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTol::Paste(const Handle(TDF_Attribute)& Into,
|
||||
const Handle(TDF_RelocationTable)& /*RT*/) const
|
||||
{
|
||||
Handle(XCAFDoc_DimTol)::DownCast(Into)->Set(myKind,myVal,myName,myDescription);
|
||||
}
|
||||
|
171
src/XCAFDoc/XCAFDoc_DimTolTool.cdl
Executable file
171
src/XCAFDoc/XCAFDoc_DimTolTool.cdl
Executable file
@@ -0,0 +1,171 @@
|
||||
-- File: XCAFDoc_DimTolTool.cdl
|
||||
-- Created: Fri Jan 9 15:37:26 2004
|
||||
-- Author: Sergey KUUL
|
||||
-- <skl@petrox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2004
|
||||
|
||||
class DimTolTool from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose: Provides tools to store and retrieve attributes (colors)
|
||||
-- of TopoDS_Shape in and from TDocStd_Document
|
||||
-- A Document is intended to hold different
|
||||
-- attributes of ONE shape and it's sub-shapes
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Label from TDF,
|
||||
LabelSequence from TDF,
|
||||
Document from TDocStd,
|
||||
ShapeTool from XCAFDoc,
|
||||
RelocationTable from TDF,
|
||||
HArray1OfReal from TColStd,
|
||||
HAsciiString from TCollection
|
||||
|
||||
is
|
||||
Create returns DimTolTool from XCAFDoc;
|
||||
|
||||
Set (myclass; L : Label from TDF) returns DimTolTool from XCAFDoc;
|
||||
---Purpose: Creates (if not exist) DimTolTool.
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
|
||||
|
||||
---API: General structure
|
||||
|
||||
BaseLabel(me) returns Label from TDF;
|
||||
---Purpose: returns the label under which colors are stored
|
||||
|
||||
ShapeTool (me: mutable) returns ShapeTool from XCAFDoc;
|
||||
---Purpose: Returns internal XCAFDoc_ShapeTool tool
|
||||
---C++: return const &
|
||||
|
||||
|
||||
-- Methods for DimTol:
|
||||
|
||||
IsDimTol (me; lab: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if label belongs to a dimtoltable and
|
||||
-- is a DimTol definition
|
||||
|
||||
GetDimTolLabels (me; Labels: out LabelSequence from TDF);
|
||||
---Purpose: Returns a sequence of D>s currently stored
|
||||
-- in the DGTtable
|
||||
|
||||
FindDimTol (me; kind : Integer from Standard; aVal : HArray1OfReal from TColStd;
|
||||
aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
lab: out Label from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Finds a dimtol definition in a DGTtable and returns
|
||||
-- its label if found
|
||||
-- Returns False if dimtol is not found in DGTtable
|
||||
|
||||
FindDimTol (me; kind : Integer from Standard; aVal : HArray1OfReal from TColStd;
|
||||
aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection)
|
||||
returns Label from TDF;
|
||||
---Purpose: Finds a dimtol definition in a DGTtable and returns
|
||||
-- its label if found (or Null label else)
|
||||
|
||||
AddDimTol (me; kind : Integer from Standard;
|
||||
aVal : HArray1OfReal from TColStd;
|
||||
aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection)
|
||||
returns Label from TDF;
|
||||
---Purpose: Adds a dimtol definition to a DGTtable and returns its label
|
||||
|
||||
SetDimTol (me; L: Label from TDF;
|
||||
DimTolL: Label from TDF);
|
||||
---Purpose: Sets a link with GUID
|
||||
|
||||
SetDimTol (me; L: Label from TDF; kind : Integer from Standard;
|
||||
aVal : HArray1OfReal from TColStd;
|
||||
aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection)
|
||||
returns Label from TDF;
|
||||
---Purpose: Sets a link with GUID
|
||||
-- Adds a DimTol as necessary
|
||||
|
||||
GetRefShapeLabel (me; DimTolL: Label from TDF; ShapeL: out Label from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Returns ShapeL defined for label DimTolL
|
||||
-- Returns False if the DimTolL is not in DGTtable
|
||||
|
||||
GetRefDGTLabels (me; ShapeL: Label from TDF; DimTols: out LabelSequence from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Returns all DimTol labels defined for label ShapeL
|
||||
|
||||
GetDimTol (me; DimTolL: Label from TDF; kind : out Integer from Standard;
|
||||
aVal : out HArray1OfReal from TColStd;
|
||||
aName : out HAsciiString from TCollection;
|
||||
aDescription : out HAsciiString from TCollection) returns Boolean;
|
||||
---Purpose: Returns dimtol assigned to <DimTolL>
|
||||
-- Returns False if no such dimtol is assigned
|
||||
|
||||
|
||||
-- Methods for Datum:
|
||||
|
||||
IsDatum (me; lab: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if label belongs to a dimtoltable and
|
||||
-- is a Datum definition
|
||||
|
||||
GetDatumLabels (me; Labels: out LabelSequence from TDF);
|
||||
---Purpose: Returns a sequence of Datumss currently stored
|
||||
-- in the DGTtable
|
||||
|
||||
FindDatum (me; aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
anIdentification : HAsciiString from TCollection;
|
||||
lab: out Label from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Finds a datum and returns its label if found
|
||||
|
||||
AddDatum (me; aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
anIdentification : HAsciiString from TCollection)
|
||||
returns Label from TDF;
|
||||
---Purpose: Adds a datum definition to a DGTtable and returns its label
|
||||
|
||||
SetDatum (me; L: Label from TDF;
|
||||
DatumL: Label from TDF);
|
||||
---Purpose: Sets a link with GUID
|
||||
|
||||
SetDatum (me; L: Label from TDF; TolerL: Label from TDF;
|
||||
aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
anIdentification : HAsciiString from TCollection);
|
||||
---Purpose: Sets a link with GUID for Datum
|
||||
-- Adds a Datum as necessary
|
||||
-- Sets connection between Datum and Tolerance
|
||||
|
||||
GetDatum (me; DatumL: Label from TDF;
|
||||
aName : out HAsciiString from TCollection;
|
||||
aDescription : out HAsciiString from TCollection;
|
||||
anIdentification : out HAsciiString from TCollection) returns Boolean;
|
||||
---Purpose: Returns datum assigned to <DatumL>
|
||||
-- Returns False if no such datum is assigned
|
||||
|
||||
GetDatumTolerLabels (me; DimTolL: Label from TDF; Datums: out LabelSequence from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Returns all Datum labels defined for label DimTolL
|
||||
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; with : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
fields
|
||||
|
||||
myShapeTool: ShapeTool from XCAFDoc;
|
||||
|
||||
end DimTolTool;
|
496
src/XCAFDoc/XCAFDoc_DimTolTool.cxx
Executable file
496
src/XCAFDoc/XCAFDoc_DimTolTool.cxx
Executable file
@@ -0,0 +1,496 @@
|
||||
#include <XCAFDoc_DimTolTool.ixx>
|
||||
|
||||
#include <XCAFDoc.hxx>
|
||||
#include <XCAFDoc_DimTol.hxx>
|
||||
#include <XCAFDoc_Datum.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_GraphNode.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDF_ChildIDIterator.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFDoc_DimTolTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_DimTolTool::XCAFDoc_DimTolTool()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_DimTolTool) XCAFDoc_DimTolTool::Set(const TDF_Label& L)
|
||||
{
|
||||
Handle(XCAFDoc_DimTolTool) A;
|
||||
if (!L.FindAttribute (XCAFDoc_DimTolTool::GetID(), A)) {
|
||||
A = new XCAFDoc_DimTolTool ();
|
||||
L.AddAttribute(A);
|
||||
A->myShapeTool = XCAFDoc_DocumentTool::ShapeTool(L);
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_DimTolTool::GetID()
|
||||
{
|
||||
static Standard_GUID DGTTblID ("72afb19b-44de-11d8-8776-001083004c77");
|
||||
return DGTTblID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BaseLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DimTolTool::BaseLabel() const
|
||||
{
|
||||
return Label();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Handle(XCAFDoc_ShapeTool)& XCAFDoc_DimTolTool::ShapeTool()
|
||||
{
|
||||
if(myShapeTool.IsNull())
|
||||
myShapeTool = XCAFDoc_DocumentTool::ShapeTool(Label());
|
||||
return myShapeTool;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDimTol
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DimTolTool::IsDimTol(const TDF_Label& DimTolL) const
|
||||
{
|
||||
Handle(XCAFDoc_DimTol) DimTolAttr;
|
||||
if(DimTolL.FindAttribute(XCAFDoc_DimTol::GetID(),DimTolAttr)) {
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDimTolLabels
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTolTool::GetDimTolLabels(TDF_LabelSequence& Labels) const
|
||||
{
|
||||
Labels.Clear();
|
||||
TDF_ChildIterator ChildIterator( Label() );
|
||||
for (; ChildIterator.More(); ChildIterator.Next()) {
|
||||
TDF_Label L = ChildIterator.Value();
|
||||
if ( IsDimTol(L)) Labels.Append(L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FindDimTol
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DimTolTool::FindDimTol(const Standard_Integer kind,
|
||||
const Handle(TColStd_HArray1OfReal)& aVal,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
TDF_Label& lab) const
|
||||
{
|
||||
TDF_ChildIDIterator it(Label(),XCAFDoc_DimTol::GetID());
|
||||
for(; it.More(); it.Next()) {
|
||||
TDF_Label DimTolL = it.Value()->Label();
|
||||
Handle(XCAFDoc_DimTol) DimTolAttr;
|
||||
if(!DimTolL.FindAttribute(XCAFDoc_DimTol::GetID(),DimTolAttr)) continue;
|
||||
Standard_Integer kind1 = DimTolAttr->GetKind();
|
||||
Handle(TColStd_HArray1OfReal) aVal1 = DimTolAttr->GetVal();
|
||||
Handle(TCollection_HAsciiString) aName1 = DimTolAttr->GetName();
|
||||
Handle(TCollection_HAsciiString) aDescription1 = DimTolAttr->GetDescription();
|
||||
Standard_Boolean IsEqual = Standard_True;
|
||||
if(!(kind1==kind)) continue;
|
||||
if(!(aName==aName1)) continue;
|
||||
if(!(aDescription==aDescription1)) continue;
|
||||
if(kind<20) { //dimension
|
||||
for(Standard_Integer i=1; i<=aVal->Length(); i++) {
|
||||
if(Abs(aVal->Value(i)-aVal1->Value(i))>Precision::Confusion())
|
||||
IsEqual = Standard_False;
|
||||
}
|
||||
}
|
||||
else if(kind<50) { //tolerance
|
||||
if(Abs(aVal->Value(1)-aVal1->Value(1))>Precision::Confusion())
|
||||
IsEqual = Standard_False;
|
||||
}
|
||||
if(IsEqual) {
|
||||
lab = DimTolL;
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FindDimTol
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DimTolTool::FindDimTol(const Standard_Integer kind,
|
||||
const Handle(TColStd_HArray1OfReal)& aVal,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription) const
|
||||
{
|
||||
TDF_Label L;
|
||||
FindDimTol(kind,aVal,aName,aDescription,L);
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AddDimTol
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DimTolTool::AddDimTol(const Standard_Integer kind,
|
||||
const Handle(TColStd_HArray1OfReal)& aVal,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription) const
|
||||
{
|
||||
TDF_Label DimTolL;
|
||||
TDF_TagSource aTag;
|
||||
DimTolL = aTag.NewChild ( Label() );
|
||||
XCAFDoc_DimTol::Set(DimTolL,kind,aVal,aName,aDescription);
|
||||
TCollection_AsciiString str = "DGT:";
|
||||
if(kind<20) str.AssignCat("Dimension");
|
||||
else str.AssignCat("Tolerance");
|
||||
TDataStd_Name::Set(DimTolL,str);
|
||||
return DimTolL;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDimTol
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTolTool::SetDimTol(const TDF_Label& L,
|
||||
const TDF_Label& DimTolL) const
|
||||
{
|
||||
// set reference
|
||||
Handle(TDataStd_TreeNode) refNode, mainNode;
|
||||
// mainNode = TDataStd_TreeNode::Set ( DimTolL, XCAFDoc::DimTolRefGUID() );
|
||||
// refNode = TDataStd_TreeNode::Set ( L, XCAFDoc::DimTolRefGUID() );
|
||||
refNode = TDataStd_TreeNode::Set ( DimTolL, XCAFDoc::DimTolRefGUID() );
|
||||
mainNode = TDataStd_TreeNode::Set ( L, XCAFDoc::DimTolRefGUID() );
|
||||
refNode->Remove(); // abv: fix against bug in TreeNode::Append()
|
||||
mainNode->Append(refNode);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDimTol
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DimTolTool::SetDimTol(const TDF_Label& L,
|
||||
const Standard_Integer kind,
|
||||
const Handle(TColStd_HArray1OfReal)& aVal,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription) const
|
||||
{
|
||||
TDF_Label DimTolL = AddDimTol(kind,aVal,aName,aDescription);
|
||||
SetDimTol(L,DimTolL);
|
||||
return DimTolL;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetRefShapeLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DimTolTool::GetRefShapeLabel(const TDF_Label& L,
|
||||
TDF_Label& ShapeL) const
|
||||
{
|
||||
Handle(TDataStd_TreeNode) Node;
|
||||
if( !L.FindAttribute(XCAFDoc::DimTolRefGUID(),Node) || !Node->HasFather() ) {
|
||||
if( !L.FindAttribute(XCAFDoc::DatumRefGUID(),Node) || !Node->HasFather() ) {
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
ShapeL = Node->Father()->Label();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetRefDGTLabels
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DimTolTool::GetRefDGTLabels(const TDF_Label& ShapeL,
|
||||
TDF_LabelSequence &DimTols) const
|
||||
{
|
||||
Handle(TDataStd_TreeNode) Node;
|
||||
if( !ShapeL.FindAttribute(XCAFDoc::DimTolRefGUID(),Node) ||
|
||||
!Node->HasFirst() ) {
|
||||
return Standard_False;
|
||||
}
|
||||
Handle(TDataStd_TreeNode) Last = Node->First();
|
||||
DimTols.Append(Last->Label());
|
||||
while(Last->HasNext()) {
|
||||
Last = Last->Next();
|
||||
DimTols.Append(Last->Label());
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDimTol
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DimTolTool::GetDimTol(const TDF_Label& DimTolL,
|
||||
Standard_Integer& kind,
|
||||
Handle(TColStd_HArray1OfReal)& aVal,
|
||||
Handle(TCollection_HAsciiString)& aName,
|
||||
Handle(TCollection_HAsciiString)& aDescription) const
|
||||
{
|
||||
Handle(XCAFDoc_DimTol) DimTolAttr;
|
||||
if(!DimTolL.FindAttribute(XCAFDoc_DimTol::GetID(),DimTolAttr)) {
|
||||
return Standard_False;
|
||||
}
|
||||
kind = DimTolAttr->GetKind();
|
||||
aVal = DimTolAttr->GetVal();
|
||||
aName = DimTolAttr->GetName();
|
||||
aDescription = DimTolAttr->GetDescription();
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsDatum
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DimTolTool::IsDatum(const TDF_Label& DimTolL) const
|
||||
{
|
||||
Handle(XCAFDoc_Datum) DatumAttr;
|
||||
if(DimTolL.FindAttribute(XCAFDoc_Datum::GetID(),DatumAttr)) {
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDatumLabels
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTolTool::GetDatumLabels(TDF_LabelSequence& Labels) const
|
||||
{
|
||||
Labels.Clear();
|
||||
TDF_ChildIterator ChildIterator( Label() );
|
||||
for (; ChildIterator.More(); ChildIterator.Next()) {
|
||||
TDF_Label L = ChildIterator.Value();
|
||||
if ( IsDatum(L)) Labels.Append(L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FindDatum
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DimTolTool::FindDatum(const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
const Handle(TCollection_HAsciiString)& anIdentification,
|
||||
TDF_Label& lab) const
|
||||
{
|
||||
TDF_ChildIDIterator it(Label(),XCAFDoc_Datum::GetID());
|
||||
for(; it.More(); it.Next()) {
|
||||
Handle(TCollection_HAsciiString) aName1, aDescription1, anIdentification1;
|
||||
TDF_Label aLabel = it.Value()->Label();
|
||||
if ( !GetDatum( aLabel, aName1, aDescription1, anIdentification1 ) )
|
||||
continue;
|
||||
if(!(aName==aName1)) continue;
|
||||
if(!(aDescription==aDescription1)) continue;
|
||||
if(!(anIdentification==anIdentification1)) continue;
|
||||
lab = aLabel;
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AddDatum
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DimTolTool::AddDatum(const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
const Handle(TCollection_HAsciiString)& anIdentification) const
|
||||
{
|
||||
TDF_Label DatumL;
|
||||
TDF_TagSource aTag;
|
||||
DatumL = aTag.NewChild ( Label() );
|
||||
XCAFDoc_Datum::Set(DatumL,aName,aDescription,anIdentification);
|
||||
TDataStd_Name::Set(DatumL,"DGT:Datum");
|
||||
return DatumL;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDatum
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTolTool::SetDatum(const TDF_Label& L,
|
||||
const TDF_Label& DatumL) const
|
||||
{
|
||||
// set reference
|
||||
Handle(TDataStd_TreeNode) refNode, mainNode;
|
||||
refNode = TDataStd_TreeNode::Set ( DatumL, XCAFDoc::DatumRefGUID() );
|
||||
mainNode = TDataStd_TreeNode::Set ( L, XCAFDoc::DatumRefGUID() );
|
||||
refNode->Remove();
|
||||
mainNode->Append(refNode);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetDatum
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTolTool::SetDatum(const TDF_Label& L,
|
||||
const TDF_Label& TolerL,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
const Handle(TCollection_HAsciiString)& anIdentification) const
|
||||
{
|
||||
TDF_Label DatumL;
|
||||
if(!FindDatum(aName,aDescription,anIdentification,DatumL))
|
||||
DatumL = AddDatum(aName,aDescription,anIdentification);
|
||||
SetDatum(L,DatumL);
|
||||
// set reference
|
||||
Handle(XCAFDoc_GraphNode) FGNode;
|
||||
Handle(XCAFDoc_GraphNode) ChGNode;
|
||||
if (! TolerL.FindAttribute( XCAFDoc::DatumTolRefGUID(), FGNode) ) {
|
||||
FGNode = new XCAFDoc_GraphNode;
|
||||
FGNode = XCAFDoc_GraphNode::Set(TolerL);
|
||||
}
|
||||
if (! DatumL.FindAttribute( XCAFDoc::DatumTolRefGUID(), ChGNode) ) {
|
||||
ChGNode = new XCAFDoc_GraphNode;
|
||||
ChGNode = XCAFDoc_GraphNode::Set(DatumL);
|
||||
}
|
||||
FGNode->SetGraphID( XCAFDoc::DatumTolRefGUID() );
|
||||
ChGNode->SetGraphID( XCAFDoc::DatumTolRefGUID() );
|
||||
FGNode->SetChild(ChGNode);
|
||||
ChGNode->SetFather(FGNode);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDatum
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DimTolTool::GetDatum(const TDF_Label& theDatumL,
|
||||
Handle(TCollection_HAsciiString)& theName,
|
||||
Handle(TCollection_HAsciiString)& theDescription,
|
||||
Handle(TCollection_HAsciiString)& theIdentification) const
|
||||
{
|
||||
Handle(XCAFDoc_Datum) aDatumAttr;
|
||||
if( theDatumL.IsNull() ||
|
||||
!theDatumL.FindAttribute(XCAFDoc_Datum::GetID(),aDatumAttr) )
|
||||
return Standard_False;
|
||||
|
||||
theName = aDatumAttr->GetName();
|
||||
theDescription = aDatumAttr->GetDescription();
|
||||
theIdentification = aDatumAttr->GetIdentification();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDatumTolerLabels
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DimTolTool::GetDatumTolerLabels(const TDF_Label& DimTolL,
|
||||
TDF_LabelSequence &Datums) const
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) Node;
|
||||
if( !DimTolL.FindAttribute(XCAFDoc::DatumTolRefGUID(),Node) )
|
||||
return Standard_False;
|
||||
for(Standard_Integer i=1; i<=Node->NbChildren(); i++) {
|
||||
Handle(XCAFDoc_GraphNode) DatumNode = Node->GetChild(i);
|
||||
Datums.Append(DatumNode->Label());
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_DimTolTool::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTolTool::Restore(const Handle(TDF_Attribute)& /*with*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_DimTolTool::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_DimTolTool;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DimTolTool::Paste(const Handle(TDF_Attribute)& /*into*/,
|
||||
const Handle(TDF_RelocationTable)& /*RT*/) const
|
||||
{
|
||||
}
|
||||
|
103
src/XCAFDoc/XCAFDoc_DocumentTool.cdl
Executable file
103
src/XCAFDoc/XCAFDoc_DocumentTool.cdl
Executable file
@@ -0,0 +1,103 @@
|
||||
-- File: XCAFDoc_DocumentTool.cdl
|
||||
-- Created: Wed Aug 30 15:14:59 2000
|
||||
-- Author: data exchange team
|
||||
-- <det@strelox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class DocumentTool from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose: Defines sections structure of an XDE document.
|
||||
|
||||
uses
|
||||
Label from TDF,
|
||||
Document from TDocStd,
|
||||
RelocationTable from TDF,
|
||||
ShapeTool from XCAFDoc,
|
||||
ColorTool from XCAFDoc,
|
||||
LayerTool from XCAFDoc,
|
||||
DimTolTool from XCAFDoc,
|
||||
MaterialTool from XCAFDoc
|
||||
|
||||
is
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Set (myclass; L: Label from TDF;
|
||||
IsAcces: Boolean from Standard = Standard_True)
|
||||
---Purpose: Create (if not exist) DocumentTool attribute
|
||||
-- on 0.1 label if <IsAcces> is true, else
|
||||
-- on <L> label.
|
||||
-- This label will be returned by DocLabel();
|
||||
-- If the attribute is already set it won't be reset on
|
||||
-- <L> even if <IsAcces> is false.
|
||||
-- ColorTool and ShapeTool attributes are also set by this method.
|
||||
returns DocumentTool from XCAFDoc;
|
||||
|
||||
IsXCAFDocument(myclass; Doc : Document from TDocStd)
|
||||
returns Boolean from Standard;
|
||||
|
||||
|
||||
|
||||
---Category: methods defining document structure
|
||||
|
||||
DocLabel(myclass; acces: Label from TDF) returns Label from TDF;
|
||||
---Purpose: Returns label where the DocumentTool attribute is or
|
||||
-- 0.1 if DocumentTool is not yet set.
|
||||
|
||||
ShapesLabel (myclass; acces: Label from TDF) returns Label from TDF;
|
||||
---Purpose: Returns sub-label of DocLabel() with tag 1.
|
||||
|
||||
ColorsLabel (myclass; acces: Label from TDF) returns Label from TDF;
|
||||
---Purpose: Returns sub-label of DocLabel() with tag 2.
|
||||
|
||||
LayersLabel (myclass; acces: Label from TDF) returns Label from TDF;
|
||||
---Purpose: Returns sub-label of DocLabel() with tag 3.
|
||||
|
||||
DGTsLabel (myclass; acces: Label from TDF) returns Label from TDF;
|
||||
---Purpose: Returns sub-label of DocLabel() with tag 4.
|
||||
|
||||
MaterialsLabel (myclass; acces: Label from TDF) returns Label from TDF;
|
||||
---Purpose: Returns sub-label of DocLabel() with tag 5.
|
||||
|
||||
|
||||
ShapeTool (myclass; acces: Label from TDF) returns ShapeTool from XCAFDoc;
|
||||
---Purpose: Creates (if it does not exist) ShapeTool attribute on ShapesLabel().
|
||||
|
||||
ColorTool(myclass; acces: Label from TDF) returns ColorTool from XCAFDoc;
|
||||
---Purpose: Creates (if it does not exist) ColorTool attribute on ColorsLabel().
|
||||
|
||||
LayerTool(myclass; acces: Label from TDF) returns LayerTool from XCAFDoc;
|
||||
---Purpose: Creates (if it does not exist) LayerTool attribute on LayersLabel().
|
||||
|
||||
DimTolTool(myclass; acces: Label from TDF) returns DimTolTool from XCAFDoc;
|
||||
---Purpose: Creates (if it does not exist) DimTolTool attribute on DGTsLabel().
|
||||
|
||||
MaterialTool(myclass; acces: Label from TDF) returns MaterialTool from XCAFDoc;
|
||||
---Purpose: Creates (if it does not exist) DimTolTool attribute on DGTsLabel().
|
||||
|
||||
|
||||
Create
|
||||
returns mutable DocumentTool from XCAFDoc;
|
||||
|
||||
Init(me);
|
||||
---Purpose: to be called when reading this attribute from file
|
||||
|
||||
---Category: TDF_Attribute methods
|
||||
-- =====================
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; with : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
end DocumentTool;
|
267
src/XCAFDoc/XCAFDoc_DocumentTool.cxx
Executable file
267
src/XCAFDoc/XCAFDoc_DocumentTool.cxx
Executable file
@@ -0,0 +1,267 @@
|
||||
// File: XCAFDoc_DocumentTool.cxx
|
||||
// Created: Wed Aug 30 15:22:16 2000
|
||||
// Author: data exchange team
|
||||
// <det@strelox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <XCAFDoc_DocumentTool.ixx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDF_Data.hxx>
|
||||
#include <TDF_Tool.hxx>
|
||||
#include <TDF_LabelLabelMap.hxx>
|
||||
|
||||
// purpose: give acces to DocumentTool->Label() for static methods
|
||||
static TDF_LabelLabelMap RootLDocLMap;
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_DocumentTool::GetID()
|
||||
{
|
||||
static Standard_GUID DocumentToolID ("efd212ec-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return DocumentToolID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_DocumentTool) XCAFDoc_DocumentTool::Set(const TDF_Label& L,
|
||||
const Standard_Boolean IsAcces)
|
||||
{
|
||||
Handle(XCAFDoc_DocumentTool) A;
|
||||
if (!DocLabel(L).FindAttribute (XCAFDoc_DocumentTool::GetID(), A)) {
|
||||
if (!IsAcces) {
|
||||
TDF_Label RootL = L.Root();
|
||||
if (RootLDocLMap.IsBound(RootL)) RootLDocLMap.UnBind(RootL);
|
||||
RootLDocLMap.Bind(RootL, L);
|
||||
}
|
||||
A = new XCAFDoc_DocumentTool;
|
||||
DocLabel(L).AddAttribute(A);
|
||||
// set ShapeTool, ColorTool and LayerTool attributes
|
||||
XCAFDoc_ShapeTool::Set(ShapesLabel(L));
|
||||
XCAFDoc_ColorTool::Set(ColorsLabel(L));
|
||||
XCAFDoc_LayerTool::Set(LayersLabel(L));
|
||||
XCAFDoc_DimTolTool::Set(DGTsLabel(L));
|
||||
XCAFDoc_MaterialTool::Set(MaterialsLabel(L));
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DocLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DocumentTool::DocLabel(const TDF_Label& acces)
|
||||
{
|
||||
TDF_Label DocL, RootL = acces.Root();
|
||||
if (RootLDocLMap.IsBound(RootL))
|
||||
return RootLDocLMap.Find(RootL);
|
||||
|
||||
DocL = RootL.FindChild(1);
|
||||
RootLDocLMap.Bind(RootL, DocL);
|
||||
return DocL;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_DocumentTool::XCAFDoc_DocumentTool()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapesLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DocumentTool::ShapesLabel(const TDF_Label& acces)
|
||||
{
|
||||
TDF_Label L = DocLabel(acces).FindChild(1,Standard_True);
|
||||
TDataStd_Name::Set(L, "Shapes");
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ColorsLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DocumentTool::ColorsLabel(const TDF_Label& acces)
|
||||
{
|
||||
TDF_Label L = DocLabel(acces).FindChild(2,Standard_True);
|
||||
TDataStd_Name::Set(L, "Colors");
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : LayersLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DocumentTool::LayersLabel(const TDF_Label& acces)
|
||||
{
|
||||
TDF_Label L = DocLabel(acces).FindChild(3,Standard_True);
|
||||
TDataStd_Name::Set(L, "Layers");
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DGTsLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DocumentTool::DGTsLabel(const TDF_Label& acces)
|
||||
{
|
||||
TDF_Label L = DocLabel(acces).FindChild(4,Standard_True);
|
||||
TDataStd_Name::Set(L, "D>s");
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MaterialsLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_DocumentTool::MaterialsLabel(const TDF_Label& acces)
|
||||
{
|
||||
TDF_Label L = DocLabel(acces).FindChild(5,Standard_True);
|
||||
TDataStd_Name::Set(L, "Materials");
|
||||
return L;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_ShapeTool) XCAFDoc_DocumentTool::ShapeTool(const TDF_Label& acces)
|
||||
{
|
||||
return XCAFDoc_ShapeTool::Set(ShapesLabel(acces));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ColorTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_ColorTool) XCAFDoc_DocumentTool::ColorTool (const TDF_Label& acces)
|
||||
{
|
||||
return XCAFDoc_ColorTool::Set(ColorsLabel(acces));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : LayerTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_LayerTool) XCAFDoc_DocumentTool::LayerTool (const TDF_Label& acces)
|
||||
{
|
||||
return XCAFDoc_LayerTool::Set(LayersLabel(acces));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : DimTolTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_DimTolTool) XCAFDoc_DocumentTool::DimTolTool(const TDF_Label& acces)
|
||||
{
|
||||
return XCAFDoc_DimTolTool::Set(DGTsLabel(acces));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : MaterialTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_MaterialTool) XCAFDoc_DocumentTool::MaterialTool(const TDF_Label& acces)
|
||||
{
|
||||
return XCAFDoc_MaterialTool::Set(MaterialsLabel(acces));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_DocumentTool::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DocumentTool::Restore(const Handle(TDF_Attribute)& /* with */)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_DocumentTool::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_DocumentTool;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DocumentTool::Paste (const Handle(TDF_Attribute)& /* into */,
|
||||
const Handle(TDF_RelocationTable)& /* RT */) const
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Init
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_DocumentTool::Init() const
|
||||
{
|
||||
TDF_Label DocL = Label(), RootL = DocL.Root();
|
||||
if ( ! RootLDocLMap.IsBound(RootL) ) RootLDocLMap.Bind(RootL, DocL);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsXCAFDocument
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_DocumentTool::IsXCAFDocument(const Handle(TDocStd_Document)& D)
|
||||
{
|
||||
return RootLDocLMap.IsBound(D->Main().Root());
|
||||
}
|
162
src/XCAFDoc/XCAFDoc_GraphNode.cdl
Executable file
162
src/XCAFDoc/XCAFDoc_GraphNode.cdl
Executable file
@@ -0,0 +1,162 @@
|
||||
-- File: XCAFDoc_GraphNode.cdl
|
||||
-- Created: Wed Sep 27 16:00:50 2000
|
||||
-- Author: Pavel TELKOV.
|
||||
-- <det@nordox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class GraphNode from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose: This attribute allow user multirelation tree of labels.
|
||||
-- This GraphNode is experimental Graph that not control looping and redundance.
|
||||
uses
|
||||
|
||||
GUID from Standard,
|
||||
OStream from Standard,
|
||||
Attribute from TDF,
|
||||
RelocationTable from TDF,
|
||||
DataSet from TDF,
|
||||
Label from TDF,
|
||||
GraphNodeSequence from XCAFDoc
|
||||
|
||||
is
|
||||
---Purpose: class methods working on the node
|
||||
-- ===================================
|
||||
|
||||
Find (myclass; L : Label from TDF;
|
||||
G : out GraphNode from XCAFDoc)
|
||||
---Purpose: Shortcut to search a Graph node attribute with default
|
||||
-- GraphID. Returns true if found.
|
||||
returns Boolean from Standard;
|
||||
|
||||
Set (myclass; L : Label from TDF)
|
||||
---Purpose: Finds or Creates a GraphNode attribute on the label <L>
|
||||
-- with the default Graph ID, returned by the method
|
||||
-- <GetDefaultGraphID>. Returns the created/found GraphNode
|
||||
-- attribute.
|
||||
returns GraphNode from XCAFDoc;
|
||||
|
||||
Set (myclass; L : Label from TDF; ExplicitGraphID : GUID from Standard)
|
||||
---Purpose: Finds or Creates a GraphNode attribute on the label
|
||||
-- <L>, with an explicit tree ID. <ExplicitGraphID> is
|
||||
-- the ID returned by <TDF_Attribute::ID> method.
|
||||
-- Returns the found/created GraphNode attribute.
|
||||
returns GraphNode from XCAFDoc;
|
||||
|
||||
GetDefaultGraphID (myclass)
|
||||
---Purpose: returns a default Graph ID. this ID is used by the
|
||||
-- <Set> method without explicit tree ID.
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
|
||||
---Purpose: Instance methods:
|
||||
-- ================
|
||||
|
||||
Create returns mutable GraphNode from XCAFDoc;
|
||||
|
||||
SetGraphID (me : mutable; explicitID : GUID from Standard);
|
||||
|
||||
SetFather (me : mutable;F : GraphNode from XCAFDoc)
|
||||
---Purpose: Set GraphNode <F> as father of me and returns index of <F>
|
||||
-- in Sequence that containing Fathers GraphNodes.
|
||||
-- return index of <F> from GraphNodeSequnece
|
||||
returns Integer from Standard;
|
||||
|
||||
SetChild (me : mutable;Ch : GraphNode from XCAFDoc)
|
||||
---Purpose: Set GraphNode <Ch> as child of me and returns index of <Ch>
|
||||
-- in Sequence that containing Children GraphNodes.
|
||||
-- return index of <Ch> from GraphNodeSequnece
|
||||
returns Integer from Standard;
|
||||
|
||||
UnSetFather (me : mutable;F : GraphNode from XCAFDoc);
|
||||
---Purpose: Remove <F> from Fathers GraphNodeSequence.
|
||||
-- and remove link between father and child.
|
||||
|
||||
UnSetFather (me : mutable; Findex : Integer from Standard);
|
||||
---Purpose: Remove Father GraphNode by index from Fathers GraphNodeSequence.
|
||||
-- and remove link between father and child.
|
||||
|
||||
UnSetFatherlink (me : mutable; F: GraphNode from XCAFDoc) is private;
|
||||
---Purpose: remove link between father and child.
|
||||
|
||||
UnSetChild (me : mutable; Ch : GraphNode from XCAFDoc);
|
||||
---Purpose: Remove <Ch> from GraphNodeSequence.
|
||||
-- and remove link between father and child.
|
||||
|
||||
UnSetChild (me : mutable; Chindex : Integer from Standard);
|
||||
---Purpose: Remove Child GraphNode by index from Children GraphNodeSequence.
|
||||
-- and remove link between father and child.
|
||||
|
||||
UnSetChildlink (me : mutable; C : GraphNode from XCAFDoc) is private;
|
||||
---Purpose: remove link between father and child.
|
||||
|
||||
GetFather (me ; Findex : Integer from Standard)
|
||||
---Purpose: Return GraphNode by index from GraphNodeSequence.
|
||||
returns GraphNode from XCAFDoc;
|
||||
|
||||
GetChild (me ; Chindex : Integer from Standard)
|
||||
---Purpose: Return GraphNode by index from GraphNodeSequence.
|
||||
returns GraphNode from XCAFDoc;
|
||||
|
||||
FatherIndex (me ; F : GraphNode from XCAFDoc)
|
||||
---Purpose: Return index of <F>, or zero if there is no such Graphnode.
|
||||
returns Integer from Standard;
|
||||
|
||||
ChildIndex (me ; Ch : GraphNode from XCAFDoc)
|
||||
---Purpose: Return index of <Ch>, or zero if there is no such Graphnode.
|
||||
returns Integer from Standard;
|
||||
|
||||
IsFather (me ; Ch : GraphNode from XCAFDoc)
|
||||
---Purpose: returns TRUE if <me> is father of <Ch>.
|
||||
returns Boolean from Standard;
|
||||
|
||||
IsChild (me ; F : GraphNode from XCAFDoc)
|
||||
---Purpose: returns TRUE if <me> is child of <F>.
|
||||
returns Boolean from Standard;
|
||||
|
||||
NbFathers (me) returns Integer from Standard;
|
||||
---Purpose: return Number of Fathers GraphNodes.
|
||||
|
||||
NbChildren (me) returns Integer from Standard;
|
||||
---Purpose: return Number of Childrens GraphNodes.
|
||||
|
||||
|
||||
---Purpose: Implementation of Attribute methods:
|
||||
-- ===================================
|
||||
|
||||
ID (me)
|
||||
---Purpose: Returns the Graph ID (default or explicit one depending
|
||||
-- onthe Set method used).
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; with : Attribute from TDF)
|
||||
is virtual;
|
||||
|
||||
Paste (me; into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF)
|
||||
is virtual;
|
||||
|
||||
NewEmpty(me)
|
||||
returns mutable Attribute from TDF
|
||||
is redefined;
|
||||
|
||||
References(me;
|
||||
aDataSet : DataSet from TDF)
|
||||
is redefined;
|
||||
|
||||
Dump(me; anOS : in out OStream from Standard)
|
||||
returns OStream from Standard
|
||||
---C++: return &
|
||||
is redefined;
|
||||
|
||||
BeforeForget(me: mutable)
|
||||
is redefined;
|
||||
|
||||
fields
|
||||
myFathers : GraphNodeSequence from XCAFDoc;
|
||||
myChildren : GraphNodeSequence from XCAFDoc;
|
||||
myGraphID : GUID from Standard;
|
||||
|
||||
end GraphNode;
|
427
src/XCAFDoc/XCAFDoc_GraphNode.cxx
Executable file
427
src/XCAFDoc/XCAFDoc_GraphNode.cxx
Executable file
@@ -0,0 +1,427 @@
|
||||
// File: XCAFDoc_GraphNode.cxx
|
||||
// Created: Wed Sep 27 16:01:18 2000
|
||||
// Author: Pavel TELKOV
|
||||
// <ptv@nordox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <XCAFDoc_GraphNode.ixx>
|
||||
|
||||
// class methods working on the node:
|
||||
// ===================================
|
||||
|
||||
//=======================================================================
|
||||
//function : Find
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_GraphNode::Find(const TDF_Label& L,
|
||||
Handle(XCAFDoc_GraphNode)& G)
|
||||
{
|
||||
return L.FindAttribute(XCAFDoc_GraphNode::GetDefaultGraphID(), G);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//GraphNode : GetDefaultGraphID
|
||||
//purpose : Static method to get the default ID of a GraphNode
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_GraphNode::GetDefaultGraphID()
|
||||
{
|
||||
static Standard_GUID XCAFDoc_GraphNodeID ("efd212f5-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return XCAFDoc_GraphNodeID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//GraphNode : Set
|
||||
//purpose : Finds or creates a GraphNode attribute with default ID
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_GraphNode) XCAFDoc_GraphNode::Set(const TDF_Label& L)
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) GN;
|
||||
if (!L.FindAttribute(XCAFDoc_GraphNode::GetDefaultGraphID(), GN)) {
|
||||
GN = new XCAFDoc_GraphNode();
|
||||
GN->SetGraphID(XCAFDoc_GraphNode::GetDefaultGraphID());
|
||||
L.AddAttribute(GN);
|
||||
}
|
||||
return GN;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose : Finds or creates a GraphNode attribute with explicit ID
|
||||
// : a driver for it
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_GraphNode) XCAFDoc_GraphNode::Set (const TDF_Label& L,
|
||||
const Standard_GUID& explicitID)
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) GN;
|
||||
if (!L.FindAttribute(explicitID, GN)) {
|
||||
GN = new XCAFDoc_GraphNode ();
|
||||
GN->SetGraphID( explicitID );
|
||||
L.AddAttribute( GN );
|
||||
}
|
||||
return GN;
|
||||
}
|
||||
|
||||
// Instance methods:
|
||||
// ================
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFDoc_GraphNode
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_GraphNode::XCAFDoc_GraphNode ()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetGraphID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::SetGraphID (const Standard_GUID& explicitID)
|
||||
{
|
||||
Backup();
|
||||
myGraphID = explicitID;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetFather
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer XCAFDoc_GraphNode::SetFather(const Handle(XCAFDoc_GraphNode)& F)
|
||||
{
|
||||
Backup();
|
||||
Standard_Integer Findex = myFathers.Length();
|
||||
myFathers.Append(F);
|
||||
return ++Findex;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : SetChild
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer XCAFDoc_GraphNode::SetChild(const Handle(XCAFDoc_GraphNode)& Ch)
|
||||
{
|
||||
Backup();
|
||||
Standard_Integer Chindex = myChildren.Length();
|
||||
myChildren.Append(Ch);
|
||||
return ++Chindex;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetFather
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::UnSetFather(const Handle(XCAFDoc_GraphNode)& F)
|
||||
{
|
||||
Backup();
|
||||
Standard_Integer Findex = FatherIndex(F);
|
||||
if (Findex != 0)
|
||||
F->UnSetChildlink(this);
|
||||
UnSetFatherlink(F);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetFather
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::UnSetFather(const Standard_Integer Findex)
|
||||
{
|
||||
if (Findex != 0)
|
||||
UnSetFather( GetFather(Findex) );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetFatherlink
|
||||
//purpose : Remove link finily
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::UnSetFatherlink(const Handle(XCAFDoc_GraphNode)& F)
|
||||
{
|
||||
myFathers.Remove( FatherIndex(F) );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetChild
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::UnSetChild(const Handle(XCAFDoc_GraphNode)& Ch)
|
||||
{
|
||||
Backup();
|
||||
Standard_Integer Chindex = ChildIndex(Ch);
|
||||
if (Chindex != 0)
|
||||
Ch->UnSetFatherlink(this);
|
||||
UnSetChildlink(Ch);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetChild
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::UnSetChild(const Standard_Integer Chindex)
|
||||
{
|
||||
if (Chindex != 0 )
|
||||
UnSetChild( GetChild(Chindex) );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetChildlink
|
||||
//purpose : Remove link finily
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::UnSetChildlink(const Handle(XCAFDoc_GraphNode)& Ch)
|
||||
{
|
||||
myChildren.Remove( ChildIndex(Ch) );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetFather
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_GraphNode) XCAFDoc_GraphNode::GetFather(const Standard_Integer Findex) const
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) F = myFathers.Value(Findex);
|
||||
return F;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetChild
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_GraphNode) XCAFDoc_GraphNode::GetChild(const Standard_Integer Chindex) const
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) Ch = myChildren.Value(Chindex);
|
||||
return Ch;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FatherIndex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer XCAFDoc_GraphNode::FatherIndex(const Handle(XCAFDoc_GraphNode)& F) const
|
||||
{
|
||||
Standard_Integer Findex = 0;
|
||||
if (NbFathers()!=0) {
|
||||
for (Findex = 1 ; Findex <= NbFathers(); Findex++) {
|
||||
if ( F == myFathers.Value(Findex)) return Findex;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ChildIndex
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer XCAFDoc_GraphNode::ChildIndex(const Handle(XCAFDoc_GraphNode)& Ch) const
|
||||
{
|
||||
Standard_Integer Chindex;
|
||||
if (NbChildren()!=0) {
|
||||
for (Chindex = 1; Chindex <= NbChildren(); Chindex++) {
|
||||
if ( Ch == myChildren.Value(Chindex)) return Chindex;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsFather
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_GraphNode::IsFather(const Handle(XCAFDoc_GraphNode)& Ch) const
|
||||
{
|
||||
if ( ChildIndex(Ch) ) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsChild
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_GraphNode::IsChild(const Handle(XCAFDoc_GraphNode)& F) const
|
||||
{
|
||||
if ( FatherIndex(F) ) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbFathers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer XCAFDoc_GraphNode::NbFathers() const
|
||||
{
|
||||
return myFathers.Length();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NbChildren
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Integer XCAFDoc_GraphNode::NbChildren() const
|
||||
{
|
||||
return myChildren.Length();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Implementation of Attribute methods:
|
||||
// ===================================
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_GraphNode::ID() const
|
||||
{
|
||||
return myGraphID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::Restore(const Handle(TDF_Attribute)& other)
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) F = Handle(XCAFDoc_GraphNode)::DownCast(other);
|
||||
myFathers = F->myFathers;
|
||||
myChildren = F->myChildren;
|
||||
myGraphID = F->myGraphID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::Paste(const Handle(TDF_Attribute)& into,
|
||||
const Handle(TDF_RelocationTable)& RT) const
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) intof = Handle(XCAFDoc_GraphNode)::DownCast(into);
|
||||
Handle(XCAFDoc_GraphNode) func;
|
||||
Standard_Integer i = 1;
|
||||
for (; i <= NbFathers(); i++) {
|
||||
if (!RT->HasRelocation(myFathers(i), func) && RT->AfterRelocate()) {
|
||||
func.Nullify();
|
||||
}
|
||||
intof->SetFather(func);
|
||||
}
|
||||
|
||||
i = 1;
|
||||
for (; i <= NbChildren(); i++) {
|
||||
if (!RT->HasRelocation(myChildren(i), func) && RT->AfterRelocate()) {
|
||||
func.Nullify();
|
||||
}
|
||||
intof->SetFather(func);
|
||||
}
|
||||
intof->SetGraphID(myGraphID);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_GraphNode::NewEmpty() const
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) G = new XCAFDoc_GraphNode();
|
||||
G->SetGraphID(myGraphID);
|
||||
return G;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : References
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::References(const Handle(TDF_DataSet)& aDataSet) const
|
||||
{
|
||||
Standard_Integer i;
|
||||
Handle(XCAFDoc_GraphNode) fct;
|
||||
for ( i = 1; i <= NbChildren(); i++ ) {
|
||||
fct = myChildren(i);
|
||||
if (!fct.IsNull()) {
|
||||
aDataSet->AddAttribute(fct);
|
||||
}
|
||||
}
|
||||
for ( i = 1; i <= NbFathers(); i++ ) {
|
||||
fct = myFathers(i);
|
||||
if ( !fct.IsNull()) {
|
||||
aDataSet->AddAttribute(fct);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_OStream& XCAFDoc_GraphNode::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
TDF_Attribute::Dump (anOS);
|
||||
Standard_Integer i = 1;
|
||||
if ( myFathers.Length()!= 0 ) {
|
||||
anOS<<" Fathers=";
|
||||
for (; i <= NbFathers(); i++) {
|
||||
if ( !myFathers(i)->Label().IsNull() )
|
||||
myFathers(i)->Label().EntryDump(anOS);
|
||||
anOS<<endl;
|
||||
}
|
||||
}
|
||||
i = 1;
|
||||
if ( myChildren.Length()!= 0 ) {
|
||||
anOS<<" Children=";
|
||||
for (; i <= NbChildren(); i++) {
|
||||
if ( !myChildren(i)->Label().IsNull() )
|
||||
myChildren(i)->Label().EntryDump(anOS);
|
||||
anOS<<endl;
|
||||
}
|
||||
}
|
||||
// anOS<<endl;
|
||||
return anOS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : BeforeForget
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_GraphNode::BeforeForget()
|
||||
{
|
||||
while ( myFathers.Length() > 0 )
|
||||
UnSetFather(1);
|
||||
while ( myChildren.Length() > 0 )
|
||||
UnSetChild(1);
|
||||
}
|
194
src/XCAFDoc/XCAFDoc_LayerTool.cdl
Executable file
194
src/XCAFDoc/XCAFDoc_LayerTool.cdl
Executable file
@@ -0,0 +1,194 @@
|
||||
-- File: XCAFDoc_LayerTool.cdl
|
||||
-- Created: Tue Sep 26 15:15:27 2000
|
||||
-- Author: Pavel TELKOV.
|
||||
-- <ptv@nordox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class LayerTool from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose: Provides tools to store and retrieve attributes (Layers)
|
||||
-- of TopoDS_Shape in and from TDocStd_Document
|
||||
-- A Document is intended to hold different
|
||||
-- attributes of ONE shape and it's sub-shapes
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Label from TDF,
|
||||
LabelSequence from TDF,
|
||||
Document from TDocStd,
|
||||
ShapeTool from XCAFDoc,
|
||||
RelocationTable from TDF,
|
||||
GraphNode from XCAFDoc,
|
||||
ExtendedString from TCollection,
|
||||
HSequenceOfExtendedString from TColStd
|
||||
is
|
||||
Create returns LayerTool from XCAFDoc;
|
||||
|
||||
Set (myclass; L : Label from TDF) returns LayerTool from XCAFDoc;
|
||||
---Purpose: Creates (if not exist) LayerTool.
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
|
||||
---API: General structure
|
||||
|
||||
BaseLabel(me) returns Label from TDF;
|
||||
---Purpose: returns the label under which Layers are stored
|
||||
|
||||
ShapeTool (me: mutable) returns ShapeTool from XCAFDoc;
|
||||
---Purpose: Returns internal XCAFDoc_ShapeTool tool
|
||||
---C++: return const &
|
||||
|
||||
|
||||
---API: Layer table management
|
||||
|
||||
IsLayer (me; lab: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if label belongs to a Layertable and
|
||||
-- is a Layer definition
|
||||
|
||||
GetLayer (me; lab: Label from TDF; aLayer: out ExtendedString from TCollection)
|
||||
returns Boolean;
|
||||
---Purpose: Returns Layer defined by label lab
|
||||
-- Returns False if the label is not in Layertable
|
||||
-- or does not define a Layer
|
||||
|
||||
FindLayer (me; aLayer : ExtendedString from TCollection; lab: out Label from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Finds a Layer definition in a Layertable and returns
|
||||
-- its label if found
|
||||
-- Returns False if Layer is not found in Layertable
|
||||
|
||||
FindLayer (me; aLayer : ExtendedString from TCollection) returns Label from TDF;
|
||||
---Purpose: Finds a Layer definition in a Layertable and returns
|
||||
-- its label if found (or Null label else)
|
||||
|
||||
AddLayer (me; aLayer : ExtendedString from TCollection) returns Label from TDF;
|
||||
---Purpose: Adds a Layer definition to a Layertable and returns
|
||||
-- its label (returns existing label if the same Layer
|
||||
-- is already defined)
|
||||
|
||||
RemoveLayer (me; lab: Label from TDF);
|
||||
---Purpose: Removes Layer from the Layertable
|
||||
|
||||
GetLayerLabels (me; Labels: out LabelSequence from TDF);
|
||||
---Purpose: Returns a sequence of Layers currently stored
|
||||
-- in the Layertable
|
||||
|
||||
---API: Assignment of Layers to labels
|
||||
|
||||
SetLayer (me; L: Label from TDF;
|
||||
LayerL: Label from TDF;
|
||||
shapeInOneLayer: Boolean = Standard_False);
|
||||
---Purpose: Sets a link from label <L> to Layer
|
||||
-- defined by <LayerL>
|
||||
-- optional parametr <shapeInOneLayer> show could shape be
|
||||
-- in number of layers or only in one.
|
||||
|
||||
SetLayer (me; L: Label from TDF;
|
||||
aLayer : ExtendedString from TCollection;
|
||||
shapeInOneLayer: Boolean = Standard_False);
|
||||
---Purpose: Sets a link from label <L> to Layer <aLayer>
|
||||
-- in the Layertable
|
||||
-- Adds a Layer as necessary
|
||||
-- optional parametr <shapeInOneLayer> show could shape be
|
||||
-- in number of layers or only in one.
|
||||
|
||||
UnSetLayers (me; L: Label from TDF);
|
||||
---Purpose: Removes a link from label <L> to all layers
|
||||
|
||||
UnSetOneLayer (me; L: Label from TDF;
|
||||
aLayer : ExtendedString from TCollection) returns Boolean;
|
||||
---Purpose: Remove link from label <L> and Layer <aLayer>.
|
||||
-- returns FALSE if no such layer.
|
||||
|
||||
IsSet (me; L: Label from TDF;
|
||||
aLayer : ExtendedString from TCollection) returns Boolean;
|
||||
---Purpose: Returns True if label <L> has a Layer assosiated
|
||||
-- with the <aLayer>.
|
||||
|
||||
GetLayers (me: mutable; L: Label from TDF;
|
||||
aLayerS : out HSequenceOfExtendedString from TColStd)
|
||||
returns Boolean;
|
||||
---Purpose: Return sequence of strings <aLayerS> that assosiated with label <L>.
|
||||
|
||||
GetLayers (me: mutable; L: Label from TDF) returns HSequenceOfExtendedString from TColStd;
|
||||
---Purpose: Return sequence of strings that assosiated with label <L>.
|
||||
|
||||
GetShapesOfLayer (me; layerL: Label from TDF; ShLabels: out LabelSequence from TDF);
|
||||
---Purpose: Return sequanese of shape labels that assigned with layers to <ShLabels>.
|
||||
|
||||
IsVisible (me; layerL: Label from TDF)
|
||||
---Purpose: Return TRUE if layer is visible, FALSE if invisible.
|
||||
returns Boolean;
|
||||
|
||||
SetVisibility(me; layerL: Label from TDF;
|
||||
isvisible: Boolean = Standard_True);
|
||||
---Purpose: Set the visibility of layer. If layer is invisible when on it's layer
|
||||
-- will set UAttribute with corresponding GUID.
|
||||
|
||||
---API: Assignment of Layers to shapes in Shapes section
|
||||
|
||||
SetLayer (me: mutable; Sh: Shape from TopoDS;
|
||||
LayerL: Label from TDF;
|
||||
shapeInOneLayer: Boolean = Standard_False)
|
||||
returns Boolean;
|
||||
---Purpose: Sets a link from label that containig shape <Sh>
|
||||
-- with layer that situated at label <LayerL>.
|
||||
-- optional parametr <shapeInOneLayer> show could shape be
|
||||
-- in number of layers or only in one.
|
||||
-- return FALSE if no such shape <Sh> or label <LayerL>
|
||||
|
||||
SetLayer (me: mutable; Sh: Shape from TopoDS;
|
||||
aLayer : ExtendedString from TCollection;
|
||||
shapeInOneLayer: Boolean = Standard_False)
|
||||
returns Boolean;
|
||||
---Purpose: Sets a link from label that containig shape <Sh>
|
||||
-- with layer <aLayer>. Add <aLayer> to LayerTable if nessesery.
|
||||
-- optional parametr <shapeInOneLayer> show could shape be
|
||||
-- in number of layers or only in one.
|
||||
-- return FALSE if no such shape <Sh>.
|
||||
|
||||
UnSetLayers (me: mutable; Sh: Shape from TopoDS) returns Boolean;
|
||||
---Purpose: Remove link between shape <Sh> and all Layers at LayerTable.
|
||||
-- return FALSE if no such shape <Sh> in XCAF Document.
|
||||
|
||||
UnSetOneLayer (me: mutable; Sh: Shape from TopoDS;
|
||||
aLayer : ExtendedString from TCollection) returns Boolean;
|
||||
---Purpose: Remove link between shape <Sh> and layer <aLayer>.
|
||||
-- returns FALSE if no such layer <aLayer> or shape <Sh>.
|
||||
|
||||
IsSet (me: mutable; Sh: Shape from TopoDS;
|
||||
aLayer : ExtendedString from TCollection) returns Boolean;
|
||||
---Purpose: Returns True if shape <Sh> has a Layer assosiated
|
||||
-- with the <aLayer>.
|
||||
|
||||
GetLayers (me: mutable; Sh: Shape from TopoDS;
|
||||
aLayerS : out HSequenceOfExtendedString from TColStd) returns Boolean;
|
||||
---Purpose: Return sequence of strings <aLayerS> that assosiated with shape <Sh>.
|
||||
|
||||
GetLayers (me: mutable; Sh: Shape from TopoDS) returns HSequenceOfExtendedString from TColStd;
|
||||
---Purpose: Return sequence of strings that assosiated with shape <Sh>.
|
||||
|
||||
---Category: TDF_Attribute methods
|
||||
-- =====================
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; with : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
fields
|
||||
|
||||
myShapeTool: ShapeTool from XCAFDoc;
|
||||
|
||||
end LayerTool;
|
523
src/XCAFDoc/XCAFDoc_LayerTool.cxx
Executable file
523
src/XCAFDoc/XCAFDoc_LayerTool.cxx
Executable file
@@ -0,0 +1,523 @@
|
||||
// File: XCAFDoc_LayerTool.cxx
|
||||
// Created: Mon Oct 2 15:09:32 2000
|
||||
// Author: Pavel TELKOV
|
||||
// <ptv@nordox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <XCAFDoc_LayerTool.ixx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <XCAFDoc_GraphNode.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDF_ChildIDIterator.hxx>
|
||||
#include <TDF_ChildIterator.hxx>
|
||||
#include <XCAFDoc.hxx>
|
||||
#include <TDataStd_UAttribute.hxx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_LayerTool::XCAFDoc_LayerTool()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_LayerTool) XCAFDoc_LayerTool::Set(const TDF_Label& L)
|
||||
{
|
||||
Handle(XCAFDoc_LayerTool) A;
|
||||
if (!L.FindAttribute (XCAFDoc_LayerTool::GetID(), A)) {
|
||||
A = new XCAFDoc_LayerTool ();
|
||||
L.AddAttribute(A);
|
||||
A->myShapeTool = XCAFDoc_DocumentTool::ShapeTool(L);
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_LayerTool::GetID()
|
||||
{
|
||||
static Standard_GUID LayerTblID ("efd212f4-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return LayerTblID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BaseLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_LayerTool::BaseLabel() const
|
||||
{
|
||||
return Label();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Handle(XCAFDoc_ShapeTool)& XCAFDoc_LayerTool::ShapeTool()
|
||||
{
|
||||
if (myShapeTool.IsNull())
|
||||
myShapeTool = XCAFDoc_DocumentTool::ShapeTool( Label() );
|
||||
return myShapeTool;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::IsLayer(const TDF_Label& lab) const
|
||||
{
|
||||
TCollection_ExtendedString aLayer;
|
||||
return GetLayer ( lab, aLayer);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::GetLayer(const TDF_Label& lab,
|
||||
TCollection_ExtendedString& aLayer) const
|
||||
{
|
||||
if ( lab.Father() != Label() ) return Standard_False;
|
||||
// Handle(XCAFDoc_GraphNode) aGN;
|
||||
// if (! lab.FindAttribute (XCAFDoc::LayerRefGUID(), aGN))
|
||||
// return Standard_False;
|
||||
Handle(TDataStd_Name) aName;
|
||||
Standard_Boolean status = Standard_False;
|
||||
if ( lab.FindAttribute (TDataStd_Name::GetID(), aName) ) {
|
||||
aLayer = aName->Get();
|
||||
status = Standard_True;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : FindLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::FindLayer(const TCollection_ExtendedString& aLayer,
|
||||
TDF_Label& lab) const
|
||||
{
|
||||
lab = FindLayer(aLayer);
|
||||
return ( !lab.IsNull() );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : FindLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_LayerTool::FindLayer(const TCollection_ExtendedString& aLayer) const
|
||||
{
|
||||
TDF_ChildIterator it( Label() );
|
||||
TDF_Label lab;
|
||||
for (; it.More(); it.Next()) {
|
||||
TDF_Label aLabel = it.Value();
|
||||
Handle(TDataStd_Name) aName;
|
||||
if ( aLabel.FindAttribute (TDataStd_Name::GetID(), aName) && (aName->Get().IsEqual(aLayer)) ) {
|
||||
lab = aLabel;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return lab;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AddLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_LayerTool::AddLayer(const TCollection_ExtendedString& aLayer) const
|
||||
{
|
||||
TDF_Label lab;
|
||||
if ( FindLayer(aLayer, lab) )
|
||||
return lab;
|
||||
TDF_TagSource aTag;
|
||||
TDF_Label aLabel = aTag.NewChild( Label() );
|
||||
Handle(TDataStd_Name) aName = new TDataStd_Name;
|
||||
aName->Set(aLabel, aLayer);
|
||||
return aLabel;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : RemoveLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_LayerTool::RemoveLayer(const TDF_Label& lab) const
|
||||
{
|
||||
lab.ForgetAllAttributes (Standard_True);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLayerLabels
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_LayerTool::GetLayerLabels(TDF_LabelSequence& Labels) const
|
||||
{
|
||||
Labels.Clear();
|
||||
TDF_ChildIterator ChildIterator( Label() );
|
||||
for (; ChildIterator.More(); ChildIterator.Next()) {
|
||||
TDF_Label L = ChildIterator.Value();
|
||||
if ( IsLayer(L)) Labels.Append(L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_LayerTool::SetLayer(const TDF_Label& L,
|
||||
const TDF_Label& LayerL,
|
||||
const Standard_Boolean shapeInOneLayer) const
|
||||
{
|
||||
if (shapeInOneLayer) UnSetLayers( L );
|
||||
Handle(XCAFDoc_GraphNode) FGNode;
|
||||
Handle(XCAFDoc_GraphNode) ChGNode;
|
||||
if (! LayerL.FindAttribute( XCAFDoc::LayerRefGUID(), FGNode) ) {
|
||||
FGNode = new XCAFDoc_GraphNode;
|
||||
FGNode = XCAFDoc_GraphNode::Set(LayerL);
|
||||
}
|
||||
if (! L.FindAttribute( XCAFDoc::LayerRefGUID(), ChGNode) ) {
|
||||
ChGNode = new XCAFDoc_GraphNode;
|
||||
ChGNode = XCAFDoc_GraphNode::Set(L);
|
||||
}
|
||||
FGNode->SetGraphID( XCAFDoc::LayerRefGUID() );
|
||||
ChGNode->SetGraphID( XCAFDoc::LayerRefGUID() );
|
||||
FGNode->SetChild(ChGNode);
|
||||
ChGNode->SetFather(FGNode);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_LayerTool::SetLayer(const TDF_Label& L,
|
||||
const TCollection_ExtendedString& aLayer,
|
||||
const Standard_Boolean shapeInOneLayer) const
|
||||
{
|
||||
TDF_Label aLayerL = AddLayer(aLayer);
|
||||
SetLayer(L, aLayerL, shapeInOneLayer);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetLayers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_LayerTool::UnSetLayers(const TDF_Label& L) const
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) ChGNode, FGNode;
|
||||
if ( L.FindAttribute (XCAFDoc::LayerRefGUID(), ChGNode) ) {
|
||||
while (ChGNode->NbFathers()!= 0) {
|
||||
FGNode = ChGNode->GetFather(1);
|
||||
FGNode-> UnSetChild(ChGNode);
|
||||
// ChGNode->GetFather(1)->UnSetChild(ChGNode);
|
||||
}
|
||||
L.ForgetAttribute ( XCAFDoc::LayerRefGUID() );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetOneLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::UnSetOneLayer(const TDF_Label& L,
|
||||
const TCollection_ExtendedString& aLayer) const
|
||||
{
|
||||
TDF_Label alab;
|
||||
if ( !FindLayer(aLayer, alab) ) return Standard_False;
|
||||
|
||||
Handle(XCAFDoc_GraphNode) FGNode, ChGNode;
|
||||
if ( !L.FindAttribute (XCAFDoc::LayerRefGUID(), ChGNode) ) return Standard_False;
|
||||
if ( !alab.FindAttribute (XCAFDoc::LayerRefGUID(), FGNode) ) return Standard_False;
|
||||
ChGNode->UnSetFather(FGNode);
|
||||
return Standard_True;
|
||||
}
|
||||
//=======================================================================
|
||||
//function : IsSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::IsSet(const TDF_Label& L,
|
||||
const TCollection_ExtendedString& aLayer) const
|
||||
{
|
||||
Handle(XCAFDoc_GraphNode) Node;
|
||||
Handle(TDataStd_Name) aName;
|
||||
TDF_Label lab;
|
||||
if (L.FindAttribute(XCAFDoc::LayerRefGUID(), Node) && (Node->NbFathers() != 0 ) ) {
|
||||
Standard_Integer i = 1;
|
||||
for (; i <= Node->NbFathers(); i++) {
|
||||
lab = Node->GetFather(i)->Label();
|
||||
if (lab.FindAttribute(TDataStd_Name::GetID(), aName) && ( aName->Get().IsEqual(aLayer) ) )
|
||||
return Standard_True;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLayers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::GetLayers(const TDF_Label& L,
|
||||
Handle(TColStd_HSequenceOfExtendedString)& aLayerS)
|
||||
{
|
||||
aLayerS = GetLayers(L);
|
||||
if (aLayerS->Length() != 0) return Standard_True;
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLayers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TColStd_HSequenceOfExtendedString) XCAFDoc_LayerTool::GetLayers(const TDF_Label& L)
|
||||
{
|
||||
Handle(TColStd_HSequenceOfExtendedString) aLayerS = new TColStd_HSequenceOfExtendedString;
|
||||
Handle(XCAFDoc_GraphNode) aGNode;
|
||||
if ( L.FindAttribute( XCAFDoc::LayerRefGUID(), aGNode) ) {
|
||||
if ( aGNode->NbFathers() == 0 ) {
|
||||
return aLayerS;
|
||||
}
|
||||
Standard_Integer i = 1;
|
||||
TDF_Label aLab;
|
||||
Handle(TDataStd_Name) aName;
|
||||
for (; i <= aGNode->NbFathers(); i++) {
|
||||
aLab = aGNode->GetFather(i)->Label();
|
||||
if ( aLab.FindAttribute(TDataStd_Name::GetID(), aName) ) {
|
||||
aLayerS->Append( aName->Get() );
|
||||
// cout << aName->Get() <<endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
return aLayerS;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetShapesOfLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_LayerTool::GetShapesOfLayer(const TDF_Label& layerL,
|
||||
TDF_LabelSequence& ShLabels) const
|
||||
{
|
||||
ShLabels.Clear();
|
||||
Handle(XCAFDoc_GraphNode) aGNode;
|
||||
if ( layerL.FindAttribute( XCAFDoc::LayerRefGUID(), aGNode) ) {
|
||||
for (Standard_Integer i = 1; i <= aGNode->NbChildren(); i++) {
|
||||
ShLabels.Append( aGNode->GetChild(i)->Label() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsVisible
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::IsVisible (const TDF_Label& layerL) const
|
||||
{
|
||||
Handle(TDataStd_UAttribute) aUAttr;
|
||||
return (!layerL.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr));
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetVisibility
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_LayerTool::SetVisibility (const TDF_Label& layerL,
|
||||
const Standard_Boolean isvisible) const
|
||||
{
|
||||
Handle(TDataStd_UAttribute) aUAttr;
|
||||
if (! isvisible ) {
|
||||
if (!layerL.FindAttribute(XCAFDoc::InvisibleGUID(), aUAttr)) {
|
||||
aUAttr->Set( layerL, XCAFDoc::InvisibleGUID() );
|
||||
}
|
||||
}
|
||||
else layerL.ForgetAttribute( XCAFDoc::InvisibleGUID() );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::SetLayer(const TopoDS_Shape& Sh,
|
||||
const TDF_Label& LayerL,
|
||||
const Standard_Boolean shapeInOneLayer)
|
||||
{
|
||||
TDF_Label aLab;
|
||||
// if (! myShapeTool->FindShape(Sh, aLab) ) return Standard_False;
|
||||
// PTV 22.01.2003 set layer for shape with location if it is necessary
|
||||
if (! myShapeTool->Search( Sh, aLab ) ) return Standard_False;
|
||||
SetLayer(aLab, LayerL, shapeInOneLayer);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::SetLayer(const TopoDS_Shape& Sh,
|
||||
const TCollection_ExtendedString& aLayer,
|
||||
const Standard_Boolean shapeInOneLayer)
|
||||
{
|
||||
TDF_Label aLayerL = AddLayer(aLayer);
|
||||
return SetLayer(Sh, aLayerL, shapeInOneLayer);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetLayers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::UnSetLayers(const TopoDS_Shape& Sh)
|
||||
{
|
||||
TDF_Label aLab;
|
||||
if (! myShapeTool->FindShape(Sh, aLab) ) return Standard_False;
|
||||
UnSetLayers(aLab);
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : UnSetOneLayer
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::UnSetOneLayer(const TopoDS_Shape& Sh,
|
||||
const TCollection_ExtendedString& aLayer)
|
||||
{
|
||||
TDF_Label aLab;
|
||||
if (! myShapeTool->FindShape(Sh, aLab) ) return Standard_False;
|
||||
return UnSetOneLayer(aLab, aLayer);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSet
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::IsSet(const TopoDS_Shape& Sh,
|
||||
const TCollection_ExtendedString& aLayer)
|
||||
{
|
||||
TDF_Label aLab;
|
||||
if (! myShapeTool->FindShape(Sh, aLab) ) return Standard_False;
|
||||
return IsSet(aLab, aLayer);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLayers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_LayerTool::GetLayers(const TopoDS_Shape& Sh,
|
||||
Handle(TColStd_HSequenceOfExtendedString)& aLayerS)
|
||||
{
|
||||
TDF_Label aLab;
|
||||
if (! myShapeTool->FindShape(Sh, aLab) ) return Standard_False;
|
||||
return GetLayers(aLab, aLayerS);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLayers
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TColStd_HSequenceOfExtendedString) XCAFDoc_LayerTool::GetLayers(const TopoDS_Shape& Sh)
|
||||
{
|
||||
Handle(TColStd_HSequenceOfExtendedString) aLayerS = new TColStd_HSequenceOfExtendedString;
|
||||
TDF_Label aLab;
|
||||
if ( myShapeTool->FindShape(Sh, aLab) )
|
||||
aLayerS = GetLayers(aLab);
|
||||
return aLayerS;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_LayerTool::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_LayerTool::Restore(const Handle(TDF_Attribute)& /* with */)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_LayerTool::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_LayerTool;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_LayerTool::Paste(const Handle(TDF_Attribute)& /* into */,
|
||||
const Handle(TDF_RelocationTable)& /* RT */) const
|
||||
{
|
||||
}
|
||||
|
66
src/XCAFDoc/XCAFDoc_Location.cdl
Executable file
66
src/XCAFDoc/XCAFDoc_Location.cdl
Executable file
@@ -0,0 +1,66 @@
|
||||
-- File: XCAFDoc_Location.cdl
|
||||
-- Created: Tue Aug 15 10:34:27 2000
|
||||
-- Author: data exchange team
|
||||
-- <det@strelox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class Location from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Location from TopLoc,
|
||||
Label from TDF,
|
||||
RelocationTable from TDF
|
||||
|
||||
is
|
||||
Create returns Location from XCAFDoc;
|
||||
|
||||
---Purpose: class methods
|
||||
-- =============
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Set (myclass; label : Label from TDF; Loc : Location from TopLoc)
|
||||
---Purpose: Find, or create, a Location attribute and set it's value
|
||||
-- the Location attribute is returned.
|
||||
returns Location from XCAFDoc;
|
||||
|
||||
---Purpose: Location methods
|
||||
-- ===============
|
||||
|
||||
Set (me : mutable; Loc : Location from TopLoc);
|
||||
|
||||
Get (me)
|
||||
returns Location from TopLoc;
|
||||
|
||||
--IsCaptured(me) returns Boolean;
|
||||
---Purpose: Returns True if there is a reference on the same label
|
||||
|
||||
---Category: methodes de TDF_Attribute
|
||||
-- =========================
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; With : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; Into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
-- Dump(me; anOS : in out OStream from Standard)
|
||||
-- returns OStream from Standard
|
||||
-- is redefined;
|
||||
-- -C++: return &
|
||||
|
||||
fields
|
||||
myLocation : Location from TopLoc;
|
||||
|
||||
end Location;
|
106
src/XCAFDoc/XCAFDoc_Location.cxx
Executable file
106
src/XCAFDoc/XCAFDoc_Location.cxx
Executable file
@@ -0,0 +1,106 @@
|
||||
// File: XCAFDoc_Location.cxx
|
||||
// Created: Tue Aug 15 11:14:56 2000
|
||||
// Author: data exchange team
|
||||
// <det@strelox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <XCAFDoc_Location.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_Location::XCAFDoc_Location()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Location::GetID()
|
||||
{
|
||||
static Standard_GUID LocationID ("efd212ef-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return LocationID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_Location) XCAFDoc_Location::Set(const TDF_Label& L,const TopLoc_Location& Loc)
|
||||
{
|
||||
Handle(XCAFDoc_Location) A;
|
||||
if (!L.FindAttribute (XCAFDoc_Location::GetID(), A)) {
|
||||
A = new XCAFDoc_Location ();
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set (Loc);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Location::Set(const TopLoc_Location& Loc)
|
||||
{
|
||||
Backup();
|
||||
myLocation = Loc;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Get
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TopLoc_Location XCAFDoc_Location::Get() const
|
||||
{
|
||||
return myLocation;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Location::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Location::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
myLocation = Handle(XCAFDoc_Location)::DownCast(With)->Get();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_Location::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_Location();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Location::Paste(const Handle(TDF_Attribute)& Into,const Handle(TDF_RelocationTable)& /* RT */) const
|
||||
{
|
||||
Handle(XCAFDoc_Location)::DownCast(Into)->Set(myLocation);
|
||||
|
||||
}
|
||||
|
66
src/XCAFDoc/XCAFDoc_Material.cdl
Executable file
66
src/XCAFDoc/XCAFDoc_Material.cdl
Executable file
@@ -0,0 +1,66 @@
|
||||
-- File: XCAFDoc_Material.cdl
|
||||
-- Created: Wed Mar 5 16:11:43 2003
|
||||
-- Author: Sergey KUUL
|
||||
-- <skl@friendox>
|
||||
---Copyright: Matra Datavision 2003
|
||||
|
||||
class Material from XCAFDoc inherits Attribute from TDF
|
||||
uses
|
||||
Label from TDF,
|
||||
RelocationTable from TDF,
|
||||
HAsciiString from TCollection
|
||||
|
||||
is
|
||||
Create returns Material from XCAFDoc;
|
||||
|
||||
---Category: class methods
|
||||
-- =============
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Set (myclass; label : Label from TDF;
|
||||
aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
aDensity : Real from Standard;
|
||||
aDensName : HAsciiString from TCollection;
|
||||
aDensValType : HAsciiString from TCollection)
|
||||
returns Material from XCAFDoc;
|
||||
|
||||
Set (me : mutable; aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
aDensity : Real from Standard;
|
||||
aDensName : HAsciiString from TCollection;
|
||||
aDensValType : HAsciiString from TCollection);
|
||||
|
||||
GetName (me) returns HAsciiString from TCollection;
|
||||
|
||||
GetDescription (me) returns HAsciiString from TCollection;
|
||||
|
||||
GetDensity (me) returns Real from Standard;
|
||||
|
||||
GetDensName (me) returns HAsciiString from TCollection;
|
||||
|
||||
GetDensValType (me) returns HAsciiString from TCollection;
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; With : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; Into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
fields
|
||||
myName : HAsciiString from TCollection;
|
||||
myDescription : HAsciiString from TCollection;
|
||||
myDensity : Real from Standard;
|
||||
myDensName : HAsciiString from TCollection;
|
||||
myDensValType : HAsciiString from TCollection;
|
||||
|
||||
end Material;
|
172
src/XCAFDoc/XCAFDoc_Material.cxx
Executable file
172
src/XCAFDoc/XCAFDoc_Material.cxx
Executable file
@@ -0,0 +1,172 @@
|
||||
#include <XCAFDoc_Material.ixx>
|
||||
|
||||
#include <TDF_RelocationTable.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFDoc_Material
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_Material::XCAFDoc_Material()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Material::GetID()
|
||||
{
|
||||
static Standard_GUID MatID ("efd212f8-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return MatID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_Material) XCAFDoc_Material::Set(const TDF_Label& label,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
const Standard_Real aDensity,
|
||||
const Handle(TCollection_HAsciiString)& aDensName,
|
||||
const Handle(TCollection_HAsciiString)& aDensValType)
|
||||
{
|
||||
Handle(XCAFDoc_Material) A;
|
||||
if (!label.FindAttribute(XCAFDoc_Material::GetID(), A)) {
|
||||
A = new XCAFDoc_Material();
|
||||
label.AddAttribute(A);
|
||||
}
|
||||
A->Set(aName,aDescription,aDensity,aDensName,aDensValType);
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Material::Set(const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
const Standard_Real aDensity,
|
||||
const Handle(TCollection_HAsciiString)& aDensName,
|
||||
const Handle(TCollection_HAsciiString)& aDensValType)
|
||||
{
|
||||
myName = aName;
|
||||
myDescription = aDescription;
|
||||
myDensity = aDensity;
|
||||
myDensName = aDensName;
|
||||
myDensValType = aDensValType;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetName
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TCollection_HAsciiString) XCAFDoc_Material::GetName() const
|
||||
{
|
||||
return myName;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDescription
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TCollection_HAsciiString) XCAFDoc_Material::GetDescription() const
|
||||
{
|
||||
return myDescription;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDensity
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real XCAFDoc_Material::GetDensity() const
|
||||
{
|
||||
return myDensity;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDensName
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TCollection_HAsciiString) XCAFDoc_Material::GetDensName() const
|
||||
{
|
||||
return myDensName;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDensValType
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TCollection_HAsciiString) XCAFDoc_Material::GetDensValType() const
|
||||
{
|
||||
return myDensValType;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Material::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Material::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
myName = Handle(XCAFDoc_Material)::DownCast(With)->GetName();
|
||||
myDensity = Handle(XCAFDoc_Material)::DownCast(With)->GetDensity();
|
||||
myDescription = Handle(XCAFDoc_Material)::DownCast(With)->GetDescription();
|
||||
myDensName = Handle(XCAFDoc_Material)::DownCast(With)->GetDensName();
|
||||
myDensValType = Handle(XCAFDoc_Material)::DownCast(With)->GetDensValType();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_Material::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_Material();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Material::Paste(const Handle(TDF_Attribute)& Into,
|
||||
const Handle(TDF_RelocationTable)& /*RT*/) const
|
||||
{
|
||||
Handle(XCAFDoc_Material)::DownCast(Into)->Set(myName,myDescription,myDensity,
|
||||
myDensName,myDensValType);
|
||||
}
|
||||
|
104
src/XCAFDoc/XCAFDoc_MaterialTool.cdl
Executable file
104
src/XCAFDoc/XCAFDoc_MaterialTool.cdl
Executable file
@@ -0,0 +1,104 @@
|
||||
-- File: XCAFDoc_MaterialTool.cdl
|
||||
-- Created: Wed Mar 5 16:40:41 2003
|
||||
-- Author: Sergey KUUL
|
||||
-- <skl@friendox>
|
||||
---Copyright: Matra Datavision 2003
|
||||
|
||||
class MaterialTool from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose: Provides tools to store and retrieve attributes (materials)
|
||||
-- of TopoDS_Shape in and from TDocStd_Document
|
||||
-- A Document is intended to hold different
|
||||
-- attributes of ONE shape and it's sub-shapes
|
||||
|
||||
uses
|
||||
Shape from TopoDS,
|
||||
Label from TDF,
|
||||
LabelSequence from TDF,
|
||||
Document from TDocStd,
|
||||
ShapeTool from XCAFDoc,
|
||||
RelocationTable from TDF,
|
||||
HAsciiString from TCollection
|
||||
|
||||
is
|
||||
Create returns MaterialTool from XCAFDoc;
|
||||
|
||||
Set (myclass; L : Label from TDF) returns MaterialTool from XCAFDoc;
|
||||
---Purpose: Creates (if not exist) MaterialTool.
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
|
||||
---API: General structure
|
||||
|
||||
BaseLabel(me) returns Label from TDF;
|
||||
---Purpose: returns the label under which colors are stored
|
||||
|
||||
ShapeTool (me: mutable) returns ShapeTool from XCAFDoc;
|
||||
---Purpose: Returns internal XCAFDoc_ShapeTool tool
|
||||
---C++: return const &
|
||||
|
||||
|
||||
-- Methods for Material:
|
||||
|
||||
IsMaterial (me; lab: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if label belongs to a material table and
|
||||
-- is a Material definition
|
||||
|
||||
GetMaterialLabels (me; Labels: out LabelSequence from TDF);
|
||||
---Purpose: Returns a sequence of materials currently stored
|
||||
-- in the material table
|
||||
|
||||
AddMaterial (me; aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
aDensity : Real from Standard;
|
||||
aDensName : HAsciiString from TCollection;
|
||||
aDensValType : HAsciiString from TCollection)
|
||||
returns Label from TDF;
|
||||
---Purpose: Adds a Material definition to a table and returns its label
|
||||
|
||||
SetMaterial (me; L: Label from TDF;
|
||||
MatL: Label from TDF);
|
||||
---Purpose: Sets a link with GUID
|
||||
|
||||
SetMaterial (me; L: Label from TDF; aName : HAsciiString from TCollection;
|
||||
aDescription : HAsciiString from TCollection;
|
||||
aDensity : Real from Standard;
|
||||
aDensName : HAsciiString from TCollection;
|
||||
aDensValType : HAsciiString from TCollection);
|
||||
---Purpose: Sets a link with GUID
|
||||
-- Adds a Material as necessary
|
||||
|
||||
GetMaterial (me; MatL: Label from TDF; aName : out HAsciiString from TCollection;
|
||||
aDescription : out HAsciiString from TCollection;
|
||||
aDensity : out Real from Standard;
|
||||
aDensName : out HAsciiString from TCollection;
|
||||
aDensValType : out HAsciiString from TCollection) returns Boolean;
|
||||
---Purpose: Returns Material assigned to <MatL>
|
||||
-- Returns False if no such Material is assigned
|
||||
|
||||
GetDensityForShape (myclass; ShapeL: Label from TDF) returns Real from Standard;
|
||||
---Purpose: Find referred material and return density from it
|
||||
-- if no material --> return 0
|
||||
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; with : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
fields
|
||||
|
||||
myShapeTool: ShapeTool from XCAFDoc;
|
||||
|
||||
end MaterialTool;
|
||||
|
248
src/XCAFDoc/XCAFDoc_MaterialTool.cxx
Executable file
248
src/XCAFDoc/XCAFDoc_MaterialTool.cxx
Executable file
@@ -0,0 +1,248 @@
|
||||
#include <XCAFDoc_MaterialTool.ixx>
|
||||
|
||||
#include <XCAFDoc.hxx>
|
||||
#include <XCAFDoc_Material.hxx>
|
||||
#include <XCAFDoc_DocumentTool.hxx>
|
||||
#include <TDataStd_TreeNode.hxx>
|
||||
#include <TDataStd_Name.hxx>
|
||||
#include <TDF_ChildIDIterator.hxx>
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : XCAFDoc_MaterialTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_MaterialTool::XCAFDoc_MaterialTool()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_MaterialTool) XCAFDoc_MaterialTool::Set(const TDF_Label& L)
|
||||
{
|
||||
Handle(XCAFDoc_MaterialTool) A;
|
||||
if (!L.FindAttribute (XCAFDoc_MaterialTool::GetID(), A)) {
|
||||
A = new XCAFDoc_MaterialTool ();
|
||||
L.AddAttribute(A);
|
||||
A->myShapeTool = XCAFDoc_DocumentTool::ShapeTool(L);
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_MaterialTool::GetID()
|
||||
{
|
||||
static Standard_GUID MatTblID ("efd212f9-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return MatTblID;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : BaseLabel
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_MaterialTool::BaseLabel() const
|
||||
{
|
||||
return Label();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ShapeTool
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Handle(XCAFDoc_ShapeTool)& XCAFDoc_MaterialTool::ShapeTool()
|
||||
{
|
||||
if(myShapeTool.IsNull())
|
||||
myShapeTool = XCAFDoc_DocumentTool::ShapeTool(Label());
|
||||
return myShapeTool;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_MaterialTool::IsMaterial(const TDF_Label& lab) const
|
||||
{
|
||||
Handle(XCAFDoc_Material) MatAttr;
|
||||
if(lab.FindAttribute(XCAFDoc_Material::GetID(),MatAttr)) {
|
||||
return Standard_True;
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetMaterialLabels
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_MaterialTool::GetMaterialLabels(TDF_LabelSequence& Labels) const
|
||||
{
|
||||
Labels.Clear();
|
||||
TDF_ChildIterator ChildIterator( Label() );
|
||||
for (; ChildIterator.More(); ChildIterator.Next()) {
|
||||
TDF_Label L = ChildIterator.Value();
|
||||
if ( IsMaterial(L)) Labels.Append(L);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : AddMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
TDF_Label XCAFDoc_MaterialTool::AddMaterial(const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
const Standard_Real aDensity,
|
||||
const Handle(TCollection_HAsciiString)& aDensName,
|
||||
const Handle(TCollection_HAsciiString)& aDensValType) const
|
||||
{
|
||||
TDF_Label MatL;
|
||||
TDF_TagSource aTag;
|
||||
MatL = aTag.NewChild ( Label() );
|
||||
XCAFDoc_Material::Set(MatL,aName,aDescription,aDensity,aDensName,aDensValType);
|
||||
TDataStd_Name::Set(MatL,TCollection_AsciiString(aName->ToCString()));
|
||||
return MatL;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_MaterialTool::SetMaterial(const TDF_Label& L,const TDF_Label& MatL) const
|
||||
{
|
||||
// set reference
|
||||
Handle(TDataStd_TreeNode) refNode, mainNode;
|
||||
mainNode = TDataStd_TreeNode::Set ( MatL, XCAFDoc::MaterialRefGUID() );
|
||||
refNode = TDataStd_TreeNode::Set ( L, XCAFDoc::MaterialRefGUID() );
|
||||
refNode->Remove(); // abv: fix against bug in TreeNode::Append()
|
||||
mainNode->Append(refNode);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_MaterialTool::SetMaterial(const TDF_Label& L,
|
||||
const Handle(TCollection_HAsciiString)& aName,
|
||||
const Handle(TCollection_HAsciiString)& aDescription,
|
||||
const Standard_Real aDensity,
|
||||
const Handle(TCollection_HAsciiString)& aDensName,
|
||||
const Handle(TCollection_HAsciiString)& aDensValType) const
|
||||
{
|
||||
TDF_Label MatL = AddMaterial(aName,aDescription,aDensity,aDensName,aDensValType);
|
||||
SetMaterial(L,MatL);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetMaterial
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_MaterialTool::GetMaterial(const TDF_Label& MatL,
|
||||
Handle(TCollection_HAsciiString)& aName,
|
||||
Handle(TCollection_HAsciiString)& aDescription,
|
||||
Standard_Real& aDensity,
|
||||
Handle(TCollection_HAsciiString)& aDensName,
|
||||
Handle(TCollection_HAsciiString)& aDensValType) const
|
||||
{
|
||||
Handle(XCAFDoc_Material) MatAttr;
|
||||
if(!MatL.FindAttribute(XCAFDoc_Material::GetID(),MatAttr)) {
|
||||
return Standard_False;
|
||||
}
|
||||
aName = MatAttr->GetName();
|
||||
aDescription = MatAttr->GetDescription();
|
||||
aDensity = MatAttr->GetDensity();
|
||||
aDensName = MatAttr->GetDensName();
|
||||
aDensValType = MatAttr->GetDensValType();
|
||||
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetDensityForShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real XCAFDoc_MaterialTool::GetDensityForShape(const TDF_Label& ShapeL)
|
||||
{
|
||||
Standard_Real Dens=0.0;
|
||||
Handle(TDataStd_TreeNode) Node;
|
||||
if ( ! ShapeL.FindAttribute ( XCAFDoc::MaterialRefGUID(), Node) ||
|
||||
! Node->HasFather() ) return Dens;
|
||||
TDF_Label MatL = Node->Father()->Label();
|
||||
Handle(XCAFDoc_Material) MatAttr;
|
||||
if(!MatL.FindAttribute(XCAFDoc_Material::GetID(),MatAttr)) {
|
||||
return Dens;
|
||||
}
|
||||
// defaul dimension fo density - gram/sm^3
|
||||
// we transfer "sm" into "mm"
|
||||
Dens = MatAttr->GetDensity()*0.001;
|
||||
return Dens;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_MaterialTool::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_MaterialTool::Restore(const Handle(TDF_Attribute)& /*with*/)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_MaterialTool::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_MaterialTool;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_MaterialTool::Paste(const Handle(TDF_Attribute)& /*into*/,
|
||||
const Handle(TDF_RelocationTable)& /*RT*/) const
|
||||
{
|
||||
}
|
||||
|
64
src/XCAFDoc/XCAFDoc_ShapeMapTool.cdl
Executable file
64
src/XCAFDoc/XCAFDoc_ShapeMapTool.cdl
Executable file
@@ -0,0 +1,64 @@
|
||||
-- File: XCAFDoc_ShapeMapTool.cdl
|
||||
-- Created: Fri Aug 29 15:53:19 2003
|
||||
-- Author: data exchange team
|
||||
-- <det@doomox>
|
||||
---Copyright: Matra Datavision 2003
|
||||
|
||||
class ShapeMapTool from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
uses
|
||||
|
||||
SequenceOfHAsciiString from TColStd,
|
||||
Shape from TopoDS,
|
||||
IndexedMapOfShape from TopTools,
|
||||
Label from TDF,
|
||||
RelocationTable from TDF
|
||||
|
||||
is
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
|
||||
Set (myclass; L : Label from TDF) returns ShapeMapTool from XCAFDoc;
|
||||
---Purpose: Create (if not exist) ShapeTool from XCAFDoc on <L>.
|
||||
|
||||
|
||||
Create returns ShapeMapTool from XCAFDoc;
|
||||
---Purpose: Creates an empty tool
|
||||
|
||||
|
||||
---API: Analysis
|
||||
|
||||
|
||||
IsSubShape (me; sub: Shape from TopoDS)
|
||||
returns Boolean;
|
||||
---Purpose: Checks whether shape <sub> is subshape of shape stored on
|
||||
-- label shapeL
|
||||
|
||||
SetShape (me: mutable; S: Shape from TopoDS);
|
||||
---Purpose: Sets representation (TopoDS_Shape) for top-level shape
|
||||
|
||||
---Category: TDF_Attribute methods
|
||||
-- =====================
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; with : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
GetMap (me) returns IndexedMapOfShape from TopTools;
|
||||
---C++: return const &
|
||||
|
||||
fields
|
||||
|
||||
myMap: IndexedMapOfShape from TopTools;
|
||||
|
||||
end ShapeTool;
|
131
src/XCAFDoc/XCAFDoc_ShapeMapTool.cxx
Executable file
131
src/XCAFDoc/XCAFDoc_ShapeMapTool.cxx
Executable file
@@ -0,0 +1,131 @@
|
||||
|
||||
|
||||
#include <XCAFDoc_ShapeMapTool.ixx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
|
||||
#define AUTONAMING // automatically set names for labels
|
||||
|
||||
// attribute methods //////////////////////////////////////////////////
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_ShapeMapTool::GetID()
|
||||
{
|
||||
static Standard_GUID ShapeToolID ("3B913F4D-4A82-44ef-A0BF-9E01E9FF317A");
|
||||
return ShapeToolID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_ShapeMapTool) XCAFDoc_ShapeMapTool::Set(const TDF_Label& L)
|
||||
{
|
||||
Handle(XCAFDoc_ShapeMapTool) A;
|
||||
if (!L.FindAttribute (XCAFDoc_ShapeMapTool::GetID(), A)) {
|
||||
A = new XCAFDoc_ShapeMapTool ();
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_ShapeMapTool::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ShapeMapTool::Restore(const Handle(TDF_Attribute)& /*with*/)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_ShapeMapTool::NewEmpty() const
|
||||
{
|
||||
return new XCAFDoc_ShapeMapTool;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ShapeMapTool::Paste (const Handle(TDF_Attribute)& /*into*/,
|
||||
const Handle(TDF_RelocationTable)& /*RT*/) const
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_ShapeMapTool::XCAFDoc_ShapeMapTool()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : IsSubShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_ShapeMapTool::IsSubShape(const TopoDS_Shape& sub) const
|
||||
{
|
||||
return myMap.Contains(sub);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetShape
|
||||
//purpose : auxilary
|
||||
//=======================================================================
|
||||
static void AddSubShape(const TopoDS_Shape& S,
|
||||
TopTools_IndexedMapOfShape& myMap)
|
||||
{
|
||||
myMap.Add(S);
|
||||
for ( TopoDS_Iterator it(S); it.More(); it.Next() )
|
||||
AddSubShape(it.Value(),myMap);
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : SetShape
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_ShapeMapTool::SetShape(const TopoDS_Shape& S)
|
||||
{
|
||||
myMap.Clear();
|
||||
for ( TopoDS_Iterator it(S); it.More(); it.Next() )
|
||||
AddSubShape(it.Value(),myMap);
|
||||
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : GetMap
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const TopTools_IndexedMapOfShape& XCAFDoc_ShapeMapTool::GetMap() const
|
||||
{
|
||||
return myMap;
|
||||
}
|
472
src/XCAFDoc/XCAFDoc_ShapeTool.cdl
Executable file
472
src/XCAFDoc/XCAFDoc_ShapeTool.cdl
Executable file
@@ -0,0 +1,472 @@
|
||||
-- File: XCAFDoc_ShapeTool.cdl
|
||||
-- Created: Thu Jun 15 17:25:45 2000
|
||||
-- Author: Edward AGAPOV
|
||||
-- <eap@strelox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class ShapeTool from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose: A tool to store shapes in an XDE
|
||||
-- document in the form of assembly structure, and to maintain this structure.
|
||||
-- The API provided by this class allows to work with this
|
||||
-- structure regardless of its low-level implementation.
|
||||
-- All the shapes are stored on child labels of a main label which is
|
||||
-- XCAFDoc_DocumentTool::LabelShapes(). The label for assembly also has
|
||||
-- sub-labels, each of which represents the instance of
|
||||
-- another shape in that assembly (component). Such sub-label
|
||||
-- stores reference to the label of the original shape in the form
|
||||
-- of TDataStd_TreeNode with GUID XCAFDoc::ShapeRefGUID(), and its
|
||||
-- location encapsulated into the NamedShape.
|
||||
-- For correct work with an XDE document, it is necessary to use
|
||||
-- methods for analysis and methods for working with shapes.
|
||||
-- For example:
|
||||
-- if ( STool->IsAssembly(aLabel) )
|
||||
-- { Standard_Boolean subchilds = Standard_False; (default)
|
||||
-- Standard_Integer nbc = STool->NbComponents
|
||||
-- (aLabel[,subchilds]);
|
||||
-- }
|
||||
-- If subchilds is True, commands also consider sub-levels. By
|
||||
-- default, only level one is checked.
|
||||
-- In this example, number of children from the first level of
|
||||
-- assembly will be returned. Methods for creation and initialization:
|
||||
-- Constructor:
|
||||
-- XCAFDoc_ShapeTool::XCAFDoc_ShapeTool()
|
||||
-- Getting a guid:
|
||||
-- Standard_GUID GetID ();
|
||||
-- Creation (if does not exist) of ShapeTool on label L:
|
||||
-- Handle(XCAFDoc_ShapeTool) XCAFDoc_ShapeTool::Set(const TDF_Label& L)
|
||||
-- Analyze whether shape is a simple shape or an instance or a
|
||||
-- component of an assembly or it is an assembly ( methods of analysis).
|
||||
-- For example:
|
||||
-- STool->IsShape(aLabel) ;
|
||||
-- Analyze that the label represents a shape (simple
|
||||
-- shape, assembly or reference) or
|
||||
-- STool->IsTopLevel(aLabel);
|
||||
-- Analyze that the label is a label of a top-level shape.
|
||||
-- Work with simple shapes, assemblies and instances (
|
||||
-- methods for work with shapes).
|
||||
-- For example:
|
||||
-- Add shape:
|
||||
-- Standard_Boolean makeAssembly;
|
||||
-- // True to interpret a Compound as an Assembly, False to take it
|
||||
-- as a whole
|
||||
-- aLabel = STool->AddShape(aShape, makeAssembly);
|
||||
-- Get shape:
|
||||
-- TDF_Label aLabel...
|
||||
-- // A label must be present if
|
||||
-- (aLabel.IsNull()) { ... no such label : abandon .. }
|
||||
-- TopoDS_Shape aShape;
|
||||
-- aShape = STool->GetShape(aLabel);
|
||||
-- if (aShape.IsNull())
|
||||
-- { ... this label is not for a Shape ... }
|
||||
-- To get a label from shape.
|
||||
-- Standard_Boolean findInstance = Standard_False;
|
||||
-- (this is default value)
|
||||
-- aLabel = STool->FindShape(aShape [,findInstance]);
|
||||
-- if (aLabel.IsNull())
|
||||
-- { ... no label found for this shape ... }
|
||||
|
||||
uses
|
||||
Document from TDocStd,
|
||||
TreeNode from TDataStd,
|
||||
Location from TopLoc,
|
||||
Label from TDF,
|
||||
LabelSequence from TDF,
|
||||
LabelMap from TDF,
|
||||
Shape from TopoDS,
|
||||
SequenceOfShape from TopTools,
|
||||
HAsciiString from TCollection,
|
||||
RelocationTable from TDF,
|
||||
SequenceOfHAsciiString from TColStd,
|
||||
GraphNode from XCAFDoc,
|
||||
AttributeSequence from TDF,
|
||||
DataMapOfShapeLabel from XCAFDoc
|
||||
|
||||
is
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
|
||||
Set (myclass; L : Label from TDF) returns ShapeTool from XCAFDoc;
|
||||
---Purpose: Create (if not exist) ShapeTool from XCAFDoc on <L>.
|
||||
|
||||
|
||||
|
||||
|
||||
Create returns ShapeTool from XCAFDoc;
|
||||
---Purpose: Creates an empty tool
|
||||
|
||||
--Create (Doc: Document from TDocStd) returns ShapeTool from XCAFDoc;
|
||||
---Purpose: Creates a tool to work with a document <Doc>
|
||||
-- Attaches to label XCAFDoc::LabelShapes()
|
||||
|
||||
|
||||
|
||||
---API: Analysis
|
||||
|
||||
IsTopLevel (me; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if the label is a label of top-level shape,
|
||||
-- as opposed to component of assembly or subshape
|
||||
|
||||
IsFree (myclass; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if the label is not used by any assembly, i.e.
|
||||
-- contains sublabels which are assembly components
|
||||
-- This is relevant only if IsShape() is True
|
||||
-- (There is no Father TreeNode on this <L>)
|
||||
|
||||
IsShape (myclass; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if the label represents a shape (simple shape,
|
||||
-- assembly or reference)
|
||||
|
||||
IsSimpleShape (myclass; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if the label is a label of simple shape
|
||||
|
||||
IsReference (myclass; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Return true if <L> is a located instance of other shape
|
||||
-- i.e. reference
|
||||
|
||||
IsAssembly (myclass; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if the label is a label of assembly, i.e.
|
||||
-- contains sublabels which are assembly components
|
||||
-- This is relevant only if IsShape() is True
|
||||
|
||||
IsComponent (myclass; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Return true if <L> is reference serving as component
|
||||
-- of assembly
|
||||
|
||||
IsCompound (myclass; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if the label is a label of compound, i.e.
|
||||
-- contains some sublabels
|
||||
-- This is relevant only if IsShape() is True
|
||||
|
||||
IsSubShape (myclass; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Return true if <L> is subshape of the top-level shape
|
||||
|
||||
IsSubShape (me; shapeL: Label from TDF;
|
||||
sub: Shape from TopoDS)
|
||||
returns Boolean;
|
||||
---Purpose: Checks whether shape <sub> is subshape of shape stored on
|
||||
-- label shapeL
|
||||
|
||||
---API: Work with top-level structure of shapes
|
||||
|
||||
SearchUsingMap (me; S: Shape from TopoDS; L: out Label from TDF;
|
||||
findWithoutLoc: Boolean; findSubshape: Boolean)
|
||||
returns Boolean from Standard;
|
||||
|
||||
Search (me; S: Shape from TopoDS; L: out Label from TDF;
|
||||
findInstance: Boolean = Standard_True;
|
||||
findComponent: Boolean = Standard_True;
|
||||
findSubshape: Boolean = Standard_True)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: General tool to find a (sub) shape in the document
|
||||
-- * If findInstance is True, and S has a non-null location,
|
||||
-- first tries to find the shape among the top-level shapes
|
||||
-- with this location
|
||||
-- * If not found, and findComponent is True, tries to find the shape
|
||||
-- among the components of assemblies
|
||||
-- * If not found, tries to find the shape without location
|
||||
-- among top-level shapes
|
||||
-- * If not found and findSubshape is True, tries to find a
|
||||
-- shape as a subshape of top-level simple shapes
|
||||
-- Returns False if nothing is found
|
||||
|
||||
FindShape (me; S: Shape from TopoDS; L: out Label from TDF;
|
||||
findInstance: Boolean = Standard_False)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Returns the label corresponding to shape S
|
||||
-- (searches among top-level shapes, not including subcomponents
|
||||
-- of assemblies)
|
||||
-- If findInstance is False (default), searches for the
|
||||
-- non-located shape (i.e. among original shapes)
|
||||
-- If findInstance is True, searches for the shape with the same
|
||||
-- location, including shape instances
|
||||
-- Return True if <S> is found.
|
||||
|
||||
FindShape (me; S: Shape from TopoDS;
|
||||
findInstance: Boolean = Standard_False)
|
||||
returns Label from TDF;
|
||||
---Purpose: Does the same as previous method
|
||||
-- Returns Null label if not found
|
||||
|
||||
GetShape (myclass; L: Label from TDF;
|
||||
S: out Shape from TopoDS) returns Boolean from Standard;
|
||||
---Purpose: To get TopoDS_Shape from shape's label
|
||||
-- For component, returns new shape with correct location
|
||||
-- Returns False if label does not contain shape
|
||||
|
||||
GetShape (myclass; L: Label from TDF) returns Shape from TopoDS;
|
||||
---Purpose: To get TopoDS_Shape from shape's label
|
||||
-- For component, returns new shape with correct location
|
||||
-- Returns Null shape if label does not contain shape
|
||||
|
||||
NewShape (me) returns Label from TDF;
|
||||
---Purpose: Creates new (empty) top-level shape.
|
||||
-- Initially it holds empty TopoDS_Compound
|
||||
|
||||
SetShape (me:mutable; L: Label from TDF; S: Shape from TopoDS);
|
||||
---Purpose: Sets representation (TopoDS_Shape) for top-level shape
|
||||
|
||||
AddShape (me:mutable; S: Shape from TopoDS;
|
||||
makeAssembly: Boolean = Standard_True;
|
||||
makePrepare : Boolean = Standard_True)
|
||||
returns Label from TDF;
|
||||
---Purpose: Adds a new top-level (creates and returns a new label)
|
||||
-- If makeAssembly is True, treats TopAbs_COMPOUND shapes
|
||||
-- as assemblies (creates assembly structure).
|
||||
-- NOTE: <makePrepare> replace components without location
|
||||
-- in assmebly by located components to avoid some problems.
|
||||
|
||||
addShape (me:mutable; S: Shape from TopoDS;
|
||||
makeAssembly: Boolean = Standard_True)
|
||||
returns Label from TDF is private;
|
||||
---Purpose: Adds a new top-level (creates and returns a new label)
|
||||
-- For internal use. Used by public method AddShape.
|
||||
|
||||
RemoveShape (me; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Removes shape (whole label and all its sublabels)
|
||||
-- Returns False (and does nothing) if shape is not free
|
||||
-- or is not top-level shape
|
||||
|
||||
Init (me: mutable);
|
||||
---Purpose: set hasComponents into false
|
||||
|
||||
ComputeShapes (me: mutable; L: Label from TDF);
|
||||
---Purpose: recursive
|
||||
|
||||
ComputeSimpleShapes (me: mutable);
|
||||
---Purpose: Compute a sequence of simple shapes
|
||||
|
||||
GetShapes (me; Labels: out LabelSequence from TDF);
|
||||
---Purpose: Returns a sequence of all top-level shapes
|
||||
|
||||
GetFreeShapes (me; FreeLabels : out LabelSequence from TDF);
|
||||
---Purpose: Returns a sequence of all top-level shapes
|
||||
-- which are free (i.e. not referred by any other)
|
||||
|
||||
GetUsers (myclass; L: Label from TDF;
|
||||
Labels : out LabelSequence from TDF;
|
||||
getsubchilds: Boolean from Standard = Standard_False)
|
||||
returns Integer;
|
||||
---Purpose: Returns list of labels which refer shape L as component
|
||||
-- Returns number of users (0 if shape is free)
|
||||
|
||||
GetLocation (myclass; L: Label from TDF)
|
||||
returns Location from TopLoc;
|
||||
---Purpose: Returns location of instance
|
||||
|
||||
GetReferredShape (myclass; L: Label from TDF;
|
||||
Label: out Label from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Returns label which corresponds to a shape referred by L
|
||||
-- Returns False if label is not reference
|
||||
|
||||
---API: Work with assembly structure
|
||||
|
||||
NbComponents (myclass; L: Label from TDF;
|
||||
getsubchilds: Boolean from Standard = Standard_False)
|
||||
returns Integer;
|
||||
---Purpose: Returns number of Assembles components
|
||||
|
||||
GetComponents (myclass; L: Label from TDF;
|
||||
Labels : out LabelSequence from TDF;
|
||||
getsubchilds: Boolean from Standard = Standard_False)
|
||||
returns Boolean;
|
||||
---Purpose: Returns list of components of assembly
|
||||
-- Returns False if label is not assembly
|
||||
|
||||
AddComponent (me; assembly, comp: Label from TDF;
|
||||
Loc: Location from TopLoc)
|
||||
returns Label from TDF;
|
||||
---Purpose: Adds a component given by its label and location to the assembly
|
||||
-- Note: assembly must be IsAssembly() or IsSimpleShape()
|
||||
|
||||
AddComponent (me:mutable; assembly: Label from TDF;
|
||||
comp: Shape from TopoDS; expand: Boolean = Standard_False)
|
||||
returns Label from TDF;
|
||||
---Purpose: Adds a shape (located) as a component to the assembly
|
||||
-- If necessary, creates an additional top-level shape for
|
||||
-- component and return the Label of component.
|
||||
-- If expand is True and component is Compound, it will
|
||||
-- be created as assembly also
|
||||
-- Note: assembly must be IsAssembly() or IsSimpleShape()
|
||||
|
||||
RemoveComponent (me; comp: Label from TDF);
|
||||
---Purpose: Removes a component from its assembly
|
||||
|
||||
UpdateAssembly (me; L: Label from TDF);
|
||||
---Purpose: Update an assembly at label <L>
|
||||
|
||||
---API: work with sub-shapes of shape
|
||||
|
||||
FindSubShape (me; shapeL: Label from TDF;
|
||||
sub: Shape from TopoDS;
|
||||
L: out Label from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Finds a label for subshape <sub> of shape stored on
|
||||
-- label shapeL
|
||||
-- Returns Null label if it is not found
|
||||
|
||||
AddSubShape (me; shapeL: Label from TDF;
|
||||
sub: Shape from TopoDS)
|
||||
returns Label from TDF;
|
||||
---Purpose: Adds a label for subshape <sub> of shape stored on
|
||||
-- label shapeL
|
||||
-- Returns Null label if it is not subshape
|
||||
|
||||
FindMainShapeUsingMap (me; sub: Shape from TopoDS)
|
||||
returns Label from TDF;
|
||||
|
||||
FindMainShape (me; sub: Shape from TopoDS)
|
||||
returns Label from TDF;
|
||||
---Purpose: Performs a search among top-level shapes to find
|
||||
-- the shape containing <sub> as subshape
|
||||
-- Checks only simple shapes, and returns the first found
|
||||
-- label (which should be the only one for valid model)
|
||||
|
||||
GetSubShapes (myclass; L: Label from TDF;
|
||||
Labels : out LabelSequence from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Returns list of labels identifying subshapes of the given shape
|
||||
-- Returns False if no subshapes are placed on that label
|
||||
|
||||
---API: Auxiliary
|
||||
|
||||
BaseLabel(me) returns Label from TDF;
|
||||
---Purpose: returns the label under which shapes are stored
|
||||
|
||||
Dump(me; deep : Boolean from Standard = Standard_False);
|
||||
|
||||
DumpShape(myclass; L: Label from TDF;
|
||||
level :Integer from Standard = 0;
|
||||
deep : Boolean from Standard = Standard_False);
|
||||
---Purpose: Print in cout type of shape found on <L> label
|
||||
-- and the entry of <L>, with <level> tabs before.
|
||||
-- If <deep>, print also TShape and Location addresses
|
||||
|
||||
--- Private
|
||||
|
||||
MakeReference (myclass; L, refL: Label from TDF; loc: Location from TopLoc)
|
||||
is private;
|
||||
---Purpose: Makes a shape on label L to be a reference to shape refL
|
||||
-- with location loc
|
||||
|
||||
|
||||
---Category: TDF_Attribute methods
|
||||
-- =====================
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Restore (me: mutable; with : Attribute from TDF);
|
||||
|
||||
NewEmpty (me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
IsExternRef (myclass; L: Label from TDF) returns Boolean;
|
||||
---Purpose: Returns True if the label is a label of external references, i.e.
|
||||
-- there are some reference on the no-step files, which are
|
||||
-- described in document only their names
|
||||
|
||||
SetExternRefs (me; SHAS: SequenceOfHAsciiString from TColStd) returns Label from TDF;
|
||||
---Purpose: Sets the names of references on the no-step files
|
||||
|
||||
SetExternRefs (me; L: Label from TDF; SHAS: SequenceOfHAsciiString from TColStd);
|
||||
---Purpose: Sets the names of references on the no-step files
|
||||
|
||||
GetExternRefs (myclass; L: Label from TDF; SHAS: in out SequenceOfHAsciiString from TColStd);
|
||||
---Purpose: Gets the names of references on the no-step files
|
||||
|
||||
---API: Work with SHUO (Specified Higher Usage Occurrance) structure
|
||||
|
||||
SetSHUO (me; Labels : LabelSequence from TDF;
|
||||
MainSHUOAttr : in out GraphNode from XCAFDoc)
|
||||
returns Boolean;
|
||||
---Purpose: Sets the SHUO structure between upper_usage and next_usage
|
||||
-- create multy-level (if number of labels > 2) SHUO from first to last
|
||||
-- Initialise out <MainSHUOAttr> by main upper_usage SHUO attribute.
|
||||
-- Returns FALSE if some of labels in not component label
|
||||
|
||||
GetSHUO (myclass; SHUOLabel : Label from TDF;
|
||||
aSHUOAttr : in out GraphNode from XCAFDoc)
|
||||
returns Boolean;
|
||||
---Purpose: Returns founded SHUO GraphNode attribute <aSHUOAttr>
|
||||
-- Returns false in other case
|
||||
|
||||
GetAllComponentSHUO (myclass; CompLabel : Label from TDF;
|
||||
SHUOAttrs : in out AttributeSequence from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Returns founded SHUO GraphNodes of indicated component
|
||||
-- Returns false in other case
|
||||
|
||||
GetSHUOUpperUsage (myclass; NextUsageL: Label from TDF;
|
||||
Labels : out LabelSequence from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Returns the sequence of labels of SHUO attributes,
|
||||
-- which is upper_usage for this next_usage SHUO attribute
|
||||
-- (that indicated by label)
|
||||
-- NOTE: returns upper_usages only on one level (not recurse)
|
||||
-- NOTE: do not clear the sequence before filling
|
||||
|
||||
GetSHUONextUsage (myclass; UpperUsageL: Label from TDF;
|
||||
Labels : out LabelSequence from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Returns the sequence of labels of SHUO attributes,
|
||||
-- which is next_usage for this upper_usage SHUO attribute
|
||||
-- (that indicated by label)
|
||||
-- NOTE: returns next_usages only on one level (not recurse)
|
||||
-- NOTE: do not clear the sequence before filling
|
||||
|
||||
RemoveSHUO (me; SHUOLabel : Label from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Remove SHUO from component sublabel,
|
||||
-- remove all dependencies on other SHUO.
|
||||
-- Returns FALSE if cannot remove SHUO dependencies.
|
||||
-- NOTE: remove any styles that associated with this SHUO.
|
||||
|
||||
FindComponent (me; theShape : Shape from TopoDS;
|
||||
Labels : out LabelSequence from TDF)
|
||||
returns Boolean;
|
||||
---Purpose: Serach the path of labels in the document,
|
||||
-- that corresponds the component from any assembly
|
||||
-- Try to search the sequence of labels with location that
|
||||
-- produce this shape as component of any assembly
|
||||
-- NOTE: Clear sequence of labels before filling
|
||||
|
||||
GetSHUOInstance (me; theSHUO : GraphNode from XCAFDoc)
|
||||
returns Shape from TopoDS;
|
||||
---Purpose: Search for the component shape that styled by shuo
|
||||
-- Returns null shape if no any shape is found.
|
||||
|
||||
SetInstanceSHUO (me; theShape : Shape from TopoDS)
|
||||
returns GraphNode from XCAFDoc;
|
||||
---Purpose: Search for the component shape by labelks path
|
||||
-- and set SHUO structure for founded label structure
|
||||
-- Returns null attribute if no component in any assembly found.
|
||||
|
||||
GetAllSHUOInstances (me; theSHUO : GraphNode from XCAFDoc;
|
||||
theSHUOShapeSeq : in out SequenceOfShape from TopTools)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Seaching for component shapes that styled by shuo
|
||||
-- Returns empty sequence of shape if no any shape is found.
|
||||
|
||||
FindSHUO (myclass; Labels : LabelSequence from TDF;
|
||||
theSHUOAttr : in out GraphNode from XCAFDoc)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Searchs the SHUO by labels of components
|
||||
-- from upper_usage componet to next_usage
|
||||
-- Returns null attribute if no SHUO found
|
||||
|
||||
fields
|
||||
myShapeLabels : DataMapOfShapeLabel from XCAFDoc; --skl 15.10.2003
|
||||
mySubShapes : DataMapOfShapeLabel from XCAFDoc;
|
||||
mySimpleShapes : DataMapOfShapeLabel from XCAFDoc;
|
||||
hasSimpleShapes : Boolean from Standard;
|
||||
|
||||
end ShapeTool;
|
1711
src/XCAFDoc/XCAFDoc_ShapeTool.cxx
Executable file
1711
src/XCAFDoc/XCAFDoc_ShapeTool.cxx
Executable file
File diff suppressed because it is too large
Load Diff
65
src/XCAFDoc/XCAFDoc_Volume.cdl
Executable file
65
src/XCAFDoc/XCAFDoc_Volume.cdl
Executable file
@@ -0,0 +1,65 @@
|
||||
-- File: XCAFDoc_Volume.cdl
|
||||
-- Created: Fri Sep 8 10:54:04 2000
|
||||
-- Author: data exchange team
|
||||
-- <det@nordox.nnov.matra-dtv.fr>
|
||||
---Copyright: Matra Datavision 2000
|
||||
|
||||
|
||||
class Volume from XCAFDoc inherits Attribute from TDF
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses
|
||||
Attribute from TDF,
|
||||
Label from TDF,
|
||||
GUID from Standard,
|
||||
Real from Standard,
|
||||
RelocationTable from TDF
|
||||
|
||||
is
|
||||
Create returns Volume from XCAFDoc;
|
||||
|
||||
---Purpose: class methods
|
||||
-- =============
|
||||
|
||||
GetID (myclass)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
ID (me)
|
||||
---C++: return const &
|
||||
returns GUID from Standard;
|
||||
|
||||
Set (me: mutable; vol: Real from Standard);
|
||||
---Purpose: Sets a value of volume
|
||||
|
||||
Set (myclass ; label : Label from TDF; vol: Real from Standard)
|
||||
returns Volume from XCAFDoc;
|
||||
---Purpose: Find, or create, an Volume attribute and set its value
|
||||
|
||||
Get (me)
|
||||
returns Real from Standard;
|
||||
|
||||
Get (myclass ; label : Label from TDF; vol: in out Real from Standard)
|
||||
returns Boolean from Standard;
|
||||
---Purpose: Returns volume as argument
|
||||
-- returns false if no such attribute at the <label>
|
||||
|
||||
Restore (me: mutable; With : Attribute from TDF);
|
||||
|
||||
NewEmpty(me)
|
||||
returns mutable Attribute from TDF;
|
||||
|
||||
Paste (me; Into : mutable Attribute from TDF;
|
||||
RT : mutable RelocationTable from TDF);
|
||||
|
||||
Dump(me; anOS : in out OStream from Standard)
|
||||
returns OStream from Standard
|
||||
is redefined;
|
||||
---C++: return &
|
||||
|
||||
fields
|
||||
|
||||
myValue : Real from Standard;
|
||||
|
||||
end Volume from XCAFDoc;
|
132
src/XCAFDoc/XCAFDoc_Volume.cxx
Executable file
132
src/XCAFDoc/XCAFDoc_Volume.cxx
Executable file
@@ -0,0 +1,132 @@
|
||||
// File: XCAFDoc_Volume.cxx
|
||||
// Created: Fri Sep 8 10:58:42 2000
|
||||
// Author: data exchange team
|
||||
// <det@nordox.nnov.matra-dtv.fr>
|
||||
|
||||
|
||||
#include <XCAFDoc_Volume.ixx>
|
||||
|
||||
//=======================================================================
|
||||
//function : Constructor
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
XCAFDoc_Volume::XCAFDoc_Volume()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Volume::GetID()
|
||||
{
|
||||
static Standard_GUID VolumeID ("efd212f1-6dfd-11d4-b9c8-0060b0ee281b");
|
||||
return VolumeID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ID
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
const Standard_GUID& XCAFDoc_Volume::ID() const
|
||||
{
|
||||
return GetID();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(XCAFDoc_Volume) XCAFDoc_Volume::Set (const TDF_Label& L,const Standard_Real V)
|
||||
{
|
||||
Handle(XCAFDoc_Volume) A;
|
||||
if (!L.FindAttribute(XCAFDoc_Volume::GetID(), A)) {
|
||||
A = new XCAFDoc_Volume;
|
||||
L.AddAttribute(A);
|
||||
}
|
||||
A->Set(V);
|
||||
return A;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Set
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Volume::Set (const Standard_Real V)
|
||||
{
|
||||
Backup();
|
||||
myValue = V;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Get
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Real XCAFDoc_Volume::Get() const { return myValue; }
|
||||
|
||||
//=======================================================================
|
||||
//function : Get
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean XCAFDoc_Volume::Get(const TDF_Label& label,Standard_Real& vol)
|
||||
{
|
||||
Handle(XCAFDoc_Volume) aVolume;
|
||||
if (!label.FindAttribute(XCAFDoc_Volume::GetID(), aVolume))
|
||||
return Standard_False;
|
||||
|
||||
vol = aVolume->Get();
|
||||
return Standard_True;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : NewEmpty
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Handle(TDF_Attribute) XCAFDoc_Volume::NewEmpty () const
|
||||
{
|
||||
return new XCAFDoc_Volume();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Restore
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Volume::Restore(const Handle(TDF_Attribute)& With)
|
||||
{
|
||||
Handle(XCAFDoc_Volume) R = Handle(XCAFDoc_Volume)::DownCast (With);
|
||||
myValue = R->Get();
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
//function : Paste
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void XCAFDoc_Volume::Paste (const Handle(TDF_Attribute)& Into,
|
||||
const Handle(TDF_RelocationTable)& /* RT */) const
|
||||
{
|
||||
Handle(XCAFDoc_Volume) R = Handle(XCAFDoc_Volume)::DownCast (Into);
|
||||
R->Set(myValue);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : Dump
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_OStream& XCAFDoc_Volume::Dump (Standard_OStream& anOS) const
|
||||
{
|
||||
anOS << "Volume ";
|
||||
anOS << Get();
|
||||
return anOS;
|
||||
}
|
Reference in New Issue
Block a user