1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-04 13:13:25 +03:00

Integration of OCCT 6.5.0 from SVN

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

137
src/TDataXtd/TDataXtd.cdl Executable file
View File

@@ -0,0 +1,137 @@
-- File: TDataXtd.cdl
-- Created: Thu May 29 14:35:52 2008
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2008
package TDataXtd
---Purpose: This package defines extension of standard attributes for
-- modelling (mainly for work with geometry).
--- Category: GUID - AttributeID
-- 2a96b602-ec8b-11d0-bee7-080009dc3333 TDataXtd_Constraint
-- 2a96b618-ec8b-11d0-bee7-080009dc3333 TDataXtd_Pattern
-- 2a96b61b-ec8b-11d0-bee7-080009dc3333 TDataXtd_PatternStd
-- 2a96b620-ec8b-11d0-bee7-080009dc3333 TDataXtd_Shape
-- 2a96b60d-ec8b-11d0-bee7-080009dc3333 TDataXtd_Point
-- 2a96b601-ec8b-11d0-bee7-080009dc3333 TDataXtd_Axis
-- 2a96b60c-ec8b-11d0-bee7-080009dc3333 TDataXtd_Plane
-- 2a96b604-ec8b-11d0-bee7-080009dc3333 TDataXtd_Geometry
-- 2a96b60b-ec8b-11d0-bee7-080009dc3333 TDataXtd_Placement
uses Standard,
TCollection,
TColStd,
gp,
BRep,
Geom,
TopoDS,
TDF,
TDataStd,
TNaming
is
enumeration ConstraintEnum is
--- Purpose: The terms of this enumeration define the types
-- of available constraint.
-- ==================
RADIUS,
DIAMETER,
MINOR_RADIUS,
MAJOR_RADIUS,
TANGENT,
PARALLEL,
PERPENDICULAR,
CONCENTRIC,
COINCIDENT,
DISTANCE,
ANGLE,
EQUAL_RADIUS,
SYMMETRY,
MIDPOINT,
EQUAL_DISTANCE,
FIX,
RIGID,
-- placement constraints
-- =====================
FROM,
AXIS,
MATE,
ALIGN_FACES,
ALIGN_AXES,
AXES_ANGLE,
FACES_ANGLE,
ROUND,
OFFSET
end ConstraintEnum;
enumeration GeometryEnum is
---Purpose:
-- The terms of this enumeration define the types of geometric shapes available.
ANY_GEOM,
POINT,
LINE,
CIRCLE,
ELLIPSE,
SPLINE,
PLANE,
CYLINDER
end GeometryEnum;
---Category: Basic attributes for geometry
-- =============================
class Position;
class Constraint;
class Placement;
class Geometry;
class Point;
class Axis;
class Plane;
deferred class Pattern;
class PatternStd;
---Purpose: LinearPattern, CircularPattern, RectangularPattern,
-- RadialCircularPattern, MirrorPattern
class Shape;
---Purpose: tools
-- =====
class Array1OfTrsf instantiates Array1 from TCollection (Trsf from gp);
class HArray1OfTrsf instantiates HArray1 from TCollection (Trsf from gp,
Array1OfTrsf from TDataXtd);
IDList (anIDList : in out IDList from TDF);
---Purpose: Appends to <anIDList> the list of the attributes
-- IDs of this package. CAUTION: <anIDList> is NOT
-- cleared before use.
---Purpose: Print of TDataExt enumeration
-- =============================
Print (GEO : GeometryEnum from TDataXtd; S : in out OStream)
---Purpose: Prints the name of the geometry dimension <GEO> as a String on
-- the Stream <S> and returns <S>.
---C++: return &
returns OStream;
Print (CTR : ConstraintEnum from TDataXtd; S : in out OStream)
---Purpose: Prints the name of the constraint <CTR> as a String on
-- the Stream <S> and returns <S>.
---C++: return &
returns OStream;
end TDataXtd;

135
src/TDataXtd/TDataXtd.cxx Executable file
View File

@@ -0,0 +1,135 @@
// File: TDataXtd.cxx
// Created: Thu May 29 12:53:57 2008
// Author: Sergey ZARITCHNY
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2009
#include <TDataXtd.ixx>
#include <TDataXtd.ixx>
#include <TDataXtd_Axis.hxx>
#include <TDataXtd_Constraint.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TDataXtd_PatternStd.hxx>
#include <TDataXtd_Placement.hxx>
#include <TDataXtd_Point.hxx>
#include <TDataXtd_Plane.hxx>
#include <TDataXtd_Position.hxx>
#include <TDataXtd_Shape.hxx>
#include <TDF_IDList.hxx>
//=======================================================================
//function : IDList
//purpose :
//=======================================================================
void TDataXtd::IDList(TDF_IDList& anIDList)
{
anIDList.Append(TDataXtd_Axis::GetID());
anIDList.Append(TDataXtd_Constraint::GetID());
anIDList.Append(TDataXtd_Geometry::GetID());
anIDList.Append(TDataXtd_PatternStd::GetID());
anIDList.Append(TDataXtd_Placement::GetID());
anIDList.Append(TDataXtd_Point::GetID());
anIDList.Append(TDataXtd_Plane::GetID());
anIDList.Append(TDataXtd_Position::GetID());
anIDList.Append(TDataXtd_Shape::GetID());
}
//=======================================================================
//function :
//purpose : print the name of the constraint
//=======================================================================
Standard_OStream& TDataXtd::Print(const TDataXtd_ConstraintEnum C, Standard_OStream& s)
{
switch (C) {
//2d planar constraints
case TDataXtd_RADIUS : { s << "RADIUS"; break;}
case TDataXtd_DIAMETER : { s << "DIAMETER"; break;}
case TDataXtd_MINOR_RADIUS : { s << "MINOR_RADIUS"; break;}
case TDataXtd_MAJOR_RADIUS : { s << "MAJOR_RADIUS"; break;}
case TDataXtd_TANGENT : { s << "TANGENT"; break;}
case TDataXtd_PARALLEL : { s << "PARALLEL"; break;}
case TDataXtd_PERPENDICULAR : { s << "PERPENDICULAR"; break;}
case TDataXtd_CONCENTRIC : { s << "CONCENTRIC"; break;}
case TDataXtd_COINCIDENT : { s << "COINCIDENT"; break;}
case TDataXtd_DISTANCE : { s << "DISTANCE"; break;}
case TDataXtd_ANGLE : { s << "ANGLE"; break;}
case TDataXtd_EQUAL_RADIUS : { s << "EQUAL_RADIUS"; break;}
case TDataXtd_SYMMETRY : { s << "SYMMETRY"; break;}
case TDataXtd_MIDPOINT : { s << "MIDPOINT"; break;}
case TDataXtd_EQUAL_DISTANCE : { s << "EQUAL_DISTANCE"; break;}
case TDataXtd_FIX : { s << "FIX"; break;}
case TDataXtd_RIGID : { s << "RIGID"; break;}
// placement constraint
case TDataXtd_FROM : { s << "FROM"; break;}
case TDataXtd_AXIS : { s << "AXIS"; break;}
case TDataXtd_MATE : { s << "MATE"; break;}
case TDataXtd_ALIGN_FACES : { s << "ALIGN_FACES"; break;}
case TDataXtd_ALIGN_AXES : { s << "ALIGN_AXES"; break;}
case TDataXtd_AXES_ANGLE : { s << "AXES_ANGLE"; break;}
case TDataXtd_FACES_ANGLE : { s << "FACES_ANGLE"; break;}
case TDataXtd_ROUND : { s << "ROUND"; break;}
case TDataXtd_OFFSET : { s << "OFFSET"; break;}
default :
{
s << "UNKNOWN"; break;
}
}
return s;
}
//=======================================================================
//function :
//purpose : print the name of the real dimension
//=======================================================================
Standard_OStream& TDataXtd::Print(const TDataXtd_GeometryEnum G, Standard_OStream& s)
{
switch (G) {
case TDataXtd_ANY_GEOM :
{
s << "ANY_GEOM"; break;
}
case TDataXtd_POINT :
{
s << "POINT"; break;
}
case TDataXtd_LINE :
{
s << "LINE"; break;
}
case TDataXtd_CIRCLE :
{
s << "CIRCLE"; break;
}
case TDataXtd_ELLIPSE :
{
s << "ELLIPSE"; break;
}
case TDataXtd_SPLINE :
{
s << "SPLINE"; break;
}
case TDataXtd_PLANE :
{
s << "PLANE"; break;
}
case TDataXtd_CYLINDER :
{
s << "CYLINDER"; break;
}
default :
{
s << "UNKNOWN"; break;
}
}
return s;
}

81
src/TDataXtd/TDataXtd_Axis.cdl Executable file
View File

@@ -0,0 +1,81 @@
-- File: TDataXtd_Axis.cdl
-- Created: Mon Apr 6 17:29:46 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2009
class Axis from TDataXtd inherits Attribute from TDF
---Purpose: The basis to define an axis attribute.
--
-- Warning: Use TDataXtd_Geometry attribute to retrieve the
-- gp_Lin of the Axis attribute
uses Attribute from TDF,
Label from TDF,
GUID from Standard,
Line from Geom,
Lin from gp,
DataSet from TDF,
RelocationTable from TDF
is
---Purpose: class methods
-- =============
GetID(myclass)
---C++: return const &
---Purpose: Returns the GUID for an axis.
returns GUID from Standard;
Set (myclass ; label : Label from TDF)
---Purpose: Finds or creates an axis attribute defined by the label.
-- In the case of a creation of an axis, a compatible
-- named shape should already be associated with label.
-- Exceptions
-- Standard_NullObject if no compatible named
-- shape is associated with the label.
returns Axis from TDataXtd;
Set (myclass ; label : Label from TDF; L : Lin from gp)
---Purpose: Find, or create, an Axis attribute and set <P> as
-- generated in the associated NamedShape.
returns Axis from TDataXtd;
---Purpose: Axis methods
-- ============
Create
returns mutable Axis from TDataXtd;
---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);
Dump(me; anOS : in out OStream from Standard)
returns OStream from Standard
is redefined;
---C++: return &
end Axis;

147
src/TDataXtd/TDataXtd_Axis.cxx Executable file
View File

@@ -0,0 +1,147 @@
// File: TDataXtd_Axis.cxx
// Created: Mon Apr 6 17:33:17 2009
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2009
#include <TDataXtd_Axis.ixx>
#include <TDataStd.hxx>
#include <TDataXtd.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <TNaming_Builder.hxx>
#include <TDF_Label.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Edge.hxx>
#include <TopAbs.hxx>
#include <gp_Lin.hxx>
#include <BRep_Tool.hxx>
#include <TopLoc_Location.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <Geom_Line.hxx>
#include <Geom_Curve.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <GeomAbs_CurveType.hxx>
#define OCC2932
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Axis::GetID ()
{
static Standard_GUID TDataXtd_AxisID("2a96b601-ec8b-11d0-bee7-080009dc3333");
return TDataXtd_AxisID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Axis) TDataXtd_Axis::Set (const TDF_Label& L)
{
Handle(TDataXtd_Axis) A;
if (!L.FindAttribute(TDataXtd_Axis::GetID(),A)) {
A = new TDataXtd_Axis ();
L.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Axis) TDataXtd_Axis::Set (const TDF_Label& L, const gp_Lin& line)
{
Handle(TDataXtd_Axis) A = Set (L);
#ifdef OCC2932
Handle(TNaming_NamedShape) aNS;
if(L.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
if(!aNS->Get().IsNull())
if(aNS->Get().ShapeType() == TopAbs_EDGE) {
TopoDS_Edge anEdge = TopoDS::Edge(aNS->Get());
BRepAdaptor_Curve anAdaptor(anEdge);
if(anAdaptor.GetType() == GeomAbs_Line) {
gp_Lin anOldLine = anAdaptor.Line();
if(anOldLine.Direction().X() == line.Direction().X() &&
anOldLine.Direction().Y() == line.Direction().Y() &&
anOldLine.Direction().Z() == line.Direction().Z() &&
anOldLine.Location().X() == line.Location().X() &&
anOldLine.Location().Y() == line.Location().Y() &&
anOldLine.Location().Z() == line.Location().Z()
)
return A;
}
}
}
#endif
TNaming_Builder B (L);
B.Generated (BRepBuilderAPI_MakeEdge(line));
return A;
}
//=======================================================================
//function : TDataXtd_Axis
//purpose :
//=======================================================================
TDataXtd_Axis::TDataXtd_Axis () { }
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Axis::ID() const { return GetID(); }
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataXtd_Axis::NewEmpty () const
{
return new TDataXtd_Axis();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataXtd_Axis::Restore (const Handle(TDF_Attribute)& With) { }
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataXtd_Axis::Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const { }
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
Standard_OStream& TDataXtd_Axis::Dump (Standard_OStream& anOS) const
{
anOS << "Axis";
return anOS;
}

View File

@@ -0,0 +1,238 @@
-- File: TDataXtd_Constraint.cdl
-- Created: Mon Apr 6 17:38:41 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2009
class Constraint from TDataXtd inherits Attribute from TDF
---Purpose: The groundwork to define constraint attributes.
-- The constraint attribute contains the following sorts of data:
-- - Type whether the constraint attribute is a
-- geometric constraint or a dimension
-- - Value the real number value of a numeric
-- constraint such as an angle or a radius
-- - Geometries to identify the geometries
-- underlying the topological attributes which
-- define the constraint (up to 4)
-- - Plane for 2D constraints.
uses ConstraintEnum from TDataXtd,
Attribute from TDF,
Label from TDF,
LabelList from TDF,
LabelMap from TDF,
GUID from Standard,
Integer from Standard,
DataSet from TDF,
RelocationTable from TDF,
NamedShape from TNaming,
Constraint from TDataXtd,
Real from TDataStd
is
GetID (myclass)
---C++: return const &
---Purpose: Returns the GUID for constraints.
returns GUID from Standard;
Set (myclass; label : Label from TDF)
---Purpose: Finds or creates the 2D constraint attribute
-- defined by the planar topological attribute plane
-- and the label label.
returns Constraint from TDataXtd;
---Purpose: Constraint methods
-- ==================
Create
returns mutable Constraint from TDataXtd;
Set (me : mutable; type : ConstraintEnum from TDataXtd;
G1 : NamedShape from TNaming);
---Purpose:
-- Finds or creates the constraint attribute defined
-- by the topological attribute G1 and the constraint type type.
Set (me : mutable; type : ConstraintEnum;
G1 : NamedShape from TNaming;
G2 : NamedShape from TNaming);
---Purpose:
-- Finds or creates the constraint attribute defined
-- by the topological attributes G1 and G2, and by
-- the constraint type type.
Set (me : mutable; type : ConstraintEnum;
G1 : NamedShape from TNaming;
G2 : NamedShape from TNaming;
G3 : NamedShape from TNaming);
---Purpose:
-- Finds or creates the constraint attribute defined
-- by the topological attributes G1, G2 and G3, and
-- by the constraint type type.
Set (me : mutable; type : ConstraintEnum;
G1 : NamedShape from TNaming;
G2 : NamedShape from TNaming;
G3 : NamedShape from TNaming;
G4 : NamedShape from TNaming); ---Purpose:
-- Finds or creates the constraint attribute defined
-- by the topological attributes G1, G2, G3 and G4,
-- and by the constraint type type.
---Purpose: methods to read constraint fields
-- =================================
Verified(me)
returns Boolean from Standard;
---Purpose:
-- Returns true if this constraint attribute is valid.
-- By default, true is returned.
-- When the value of a dimension is changed or
-- when a geometry is moved, false is returned
-- until the solver sets it back to true.
GetType (me)
returns ConstraintEnum from TDataXtd;
---Purpose:
-- Returns the type of constraint.
-- This will be an element of the
-- TDataXtd_ConstraintEnum enumeration.
IsPlanar (me)
---Purpose: Returns true if this constraint attribute is
-- two-dimensional.
returns Boolean from Standard;
GetPlane(me)
---C++: return const &
--- Purpose: Returns the topological attribute of the plane
-- used for planar - i.e., 2D - constraints.
-- This plane is attached to another label.
-- If the constraint is not planar, in other words, 3D,
-- this function will return a null handle.
returns NamedShape from TNaming;
IsDimension (me)
---Purpose: Returns true if this constraint attribute is a
-- dimension, and therefore has a value.
returns Boolean from Standard;
GetValue(me)
---C++: return const &
---Purpose: Returns the value of a dimension.
-- This value is a reference to a TDataStd_Real attribute.
-- If the attribute is not a dimension, this value will
-- be 0. Use IsDimension to test this condition.
returns Real from TDataStd;
NbGeometries (me)
---Purpose:
-- Returns the number of geometry attributes in this constraint attribute.
-- This number will be between 1 and 4.
returns Integer from Standard;
GetGeometry (me; Index : Integer from Standard)
---Purpose: Returns the integer index Index used to access
-- the array of the constraint or stored geometries of a dimension
-- Index has a value between 1 and 4.
returns NamedShape from TNaming;
---Purpose: methods to write constraint fields (use builder)
-- ==================================
ClearGeometries (me : mutable);
---Purpose: Removes the geometries involved in the
-- constraint or dimension from the array of
-- topological attributes where they are stored.
SetType (me : mutable; CTR : ConstraintEnum from TDataXtd);
---Purpose: Finds or creates the type of constraint CTR.
SetPlane(me:mutable; plane : NamedShape from TNaming);
---Purpose: Finds or creates the plane of the 2D constraint
-- attribute, defined by the planar topological attribute plane.
SetValue (me : mutable; V : Real from TDataStd);
---Purpose:
-- Finds or creates the real number value V of the dimension constraint attribute.
SetGeometry (me : mutable; Index : Integer from Standard; G : NamedShape from TNaming);
---Purpose:
-- Finds or creates the underlying geometry of the
-- constraint defined by the topological attribute G
-- and the integer index Index.
Verified (me : mutable; status : Boolean from Standard);
---Purpose:
-- Returns true if this constraint attribute defined by status is valid.
-- By default, true is returned.
-- When the value of a dimension is changed or
-- when a geometry is moved, false is returned until
-- the solver sets it back to true.
-- If status is false, Verified is set to false.
-- Category: Angle management
-- ==========================
Inverted(me:mutable; status : Boolean from Standard);
Inverted(me)
returns Boolean from Standard;
Reversed(me:mutable; status : Boolean from Standard);
Reversed(me)
returns Boolean from Standard;
-- Category: Chirality management for DCM
-- ======================================
--ChangeChirality (me:mutable; status : Boolean from Standard);
--ChangeChirality (me)
--returns Boolean from Standard;
---Category: Utilities
-- =========
CollectChildConstraints(myclass;
aLabel : Label from TDF;
TheList:in out LabelList from TDF);
---Purpose: collects constraints on Childs for label <aLabel>
---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);
Dump (me; anOS : in out OStream from Standard)
returns OStream from Standard
is redefined;
---C++: return &
References (me; DS : DataSet from TDF) is redefined;
fields
myType : ConstraintEnum from TDataXtd;
myValue : Real from TDataStd;
myGeometries : Attribute from TDF[4];
myPlane : Attribute from TDF;
myIsReversed : Boolean from Standard;
myIsInverted : Boolean from Standard;
myIsVerified : Boolean from Standard;
end Constraint;

View File

@@ -0,0 +1,543 @@
// File: TDataXtd_Constraint.cxx
// Created: Mon Apr 6 17:41:29 2009
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2009
#include <TDataXtd_Constraint.ixx>
#include <TDataStd.hxx>
#include <TDataXtd.hxx>
#include <TDF_ChildIterator.hxx>
#include <TDataXtd_ConstraintEnum.hxx>
#include <TopoDS_Shape.hxx>
//
//
// for symmetry midpoint the third argument is the axis or the point
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Constraint::GetID ()
{
static Standard_GUID TDataXtd_ConstraintID("2a96b602-ec8b-11d0-bee7-080009dc3333");
return TDataXtd_ConstraintID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Constraint) TDataXtd_Constraint::Set (const TDF_Label& L)
{
Handle (TDataXtd_Constraint) A;
if (!L.FindAttribute (TDataXtd_Constraint::GetID (), A)) {
A = new TDataXtd_Constraint ();
L.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : TDataXtd_Constraint
//purpose :
//=======================================================================
TDataXtd_Constraint::TDataXtd_Constraint()
: myType (TDataXtd_RADIUS),
myIsReversed (Standard_False),
myIsInverted (Standard_False),
myIsVerified (Standard_True)
{}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void TDataXtd_Constraint::Set(const TDataXtd_ConstraintEnum type,
const Handle(TNaming_NamedShape)& G1)
{
// OCC2932 correction
if(myType == type)
{
Handle(TNaming_NamedShape) aShape =
Handle(TNaming_NamedShape)::DownCast(myGeometries[0]);
if (aShape.IsNull() == Standard_False && G1.IsNull() == Standard_False)
if (aShape -> Get() == G1 -> Get())
return;
}
Backup();
myType = type;
myGeometries[0] = G1;
}
// =======================================================================
//function : Set
//purpose :
//=======================================================================
void TDataXtd_Constraint::Set(const TDataXtd_ConstraintEnum type,
const Handle(TNaming_NamedShape)& G1,
const Handle(TNaming_NamedShape)& G2)
{
// OCC2932 correction
if(myType == type)
{
Handle(TNaming_NamedShape) aShape1 =
Handle(TNaming_NamedShape)::DownCast(myGeometries[0]);
Handle(TNaming_NamedShape) aShape2 =
Handle(TNaming_NamedShape)::DownCast(myGeometries[1]);
if (aShape1.IsNull() == Standard_False && G1.IsNull() == Standard_False &&
aShape2.IsNull() == Standard_False && G2.IsNull() == Standard_False)
if (aShape1->Get() == G1->Get() && aShape2->Get() == G2->Get())
return;
}
Backup();
myType = type;
myGeometries[0] = G1;
myGeometries[1] = G2;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void TDataXtd_Constraint::Set(const TDataXtd_ConstraintEnum type,
const Handle(TNaming_NamedShape)& G1,
const Handle(TNaming_NamedShape)& G2,
const Handle(TNaming_NamedShape)& G3)
{
// OCC2932 correction
if (myType == type)
{
Handle(TNaming_NamedShape) aShape1 =
Handle(TNaming_NamedShape)::DownCast(myGeometries[0]);
Handle(TNaming_NamedShape) aShape2 =
Handle(TNaming_NamedShape)::DownCast(myGeometries[1]);
Handle(TNaming_NamedShape) aShape3 =
Handle(TNaming_NamedShape)::DownCast(myGeometries[2]);
if (aShape1.IsNull() == Standard_False && G1.IsNull() == Standard_False &&
aShape2.IsNull() == Standard_False && G2.IsNull() == Standard_False &&
aShape3.IsNull() == Standard_False && G3.IsNull() == Standard_False)
if (aShape1->Get() == G1->Get() &&
aShape2->Get() == G2->Get() &&
aShape3->Get() == G3->Get())
return;
}
Backup();
myType = type;
myGeometries[0] = G1;
myGeometries[1] = G2;
myGeometries[2] = G3;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
void TDataXtd_Constraint::Set(const TDataXtd_ConstraintEnum type,
const Handle(TNaming_NamedShape)& G1,
const Handle(TNaming_NamedShape)& G2,
const Handle(TNaming_NamedShape)& G3,
const Handle(TNaming_NamedShape)& G4)
{
// OCC2932 correction
if (myType == type)
{
Handle(TNaming_NamedShape) aShape1 =
Handle(TNaming_NamedShape)::DownCast(myGeometries[0]);
Handle(TNaming_NamedShape) aShape2 =
Handle(TNaming_NamedShape)::DownCast(myGeometries[1]);
Handle(TNaming_NamedShape) aShape3 =
Handle(TNaming_NamedShape)::DownCast(myGeometries[2]);
Handle(TNaming_NamedShape) aShape4 =
Handle(TNaming_NamedShape)::DownCast(myGeometries[3]);
if (aShape1.IsNull() == Standard_False && G1.IsNull() == Standard_False &&
aShape2.IsNull() == Standard_False && G2.IsNull() == Standard_False &&
aShape3.IsNull() == Standard_False && G3.IsNull() == Standard_False &&
aShape4.IsNull() == Standard_False && G4.IsNull() == Standard_False)
if (aShape1->Get() == G1->Get() &&
aShape2->Get() == G2->Get() &&
aShape3->Get() == G3->Get() &&
aShape3->Get() == G4->Get())
return;
}
Backup();
myType = type;
myGeometries[0] = G1;
myGeometries[1] = G2;
myGeometries[2] = G3;
myGeometries[3] = G4;
}
//=======================================================================
//function : SetPlane
//purpose :
//=======================================================================
void TDataXtd_Constraint::SetPlane(const Handle(TNaming_NamedShape)& plane)
{
// OCC2932 correction
Handle(TNaming_NamedShape) aPlane =
Handle(TNaming_NamedShape)::DownCast(myPlane);
if (aPlane.IsNull() == Standard_False && plane.IsNull() == Standard_False)
if ( aPlane -> Get() == plane->Get())
return;
Backup();
myPlane = plane;
}
//=======================================================================
//function : Plane
//purpose :
//=======================================================================
const Handle(TNaming_NamedShape)& TDataXtd_Constraint::GetPlane() const
{
return (Handle(TNaming_NamedShape)&) myPlane;
}
//=======================================================================
//function : SetType
//purpose :
//=======================================================================
void TDataXtd_Constraint::SetType (const TDataXtd_ConstraintEnum CTR)
{
// OCC2932 correction
if(myType = CTR) return;
Backup();
myType = CTR;
}
//=======================================================================
//function : GetType
//purpose :
//=======================================================================
TDataXtd_ConstraintEnum TDataXtd_Constraint::GetType () const
{
return myType;
}
//=======================================================================
//function : ClearGeometries
//purpose :
//=======================================================================
void TDataXtd_Constraint::ClearGeometries ()
{
// OCC2932 correction
if(myGeometries[0].IsNull() && myGeometries[1].IsNull() &&
myGeometries[2].IsNull() && myGeometries[3].IsNull())
return;
Backup();
(myGeometries [0]).Nullify ();
(myGeometries [1]).Nullify ();
(myGeometries [2]).Nullify ();
(myGeometries [3]).Nullify ();
}
//=======================================================================
//function : SetGeometry
//purpose :
//=======================================================================
void TDataXtd_Constraint::SetGeometry (const Standard_Integer Index,
const Handle(TNaming_NamedShape)& G)
{
// OCC2932 correction
Handle(TNaming_NamedShape) aGeom =
Handle(TNaming_NamedShape)::DownCast(myGeometries[Index - 1]);
if (aGeom.IsNull() == Standard_False && G.IsNull() == Standard_False)
if (aGeom -> Get() == G->Get())
return;
Backup();
myGeometries [Index-1] = G;
}
//=======================================================================
//function : GetGeometry
//purpose :
//=======================================================================
Handle(TNaming_NamedShape) TDataXtd_Constraint::GetGeometry
(const Standard_Integer Index) const
{
return Handle(TNaming_NamedShape)::DownCast (myGeometries [Index-1]);
}
//=======================================================================
//function : NbGeometries
//purpose :
//=======================================================================
Standard_Integer TDataXtd_Constraint::NbGeometries () const
{
Standard_Integer num_geom = 0 ;
while (num_geom < 4 && ! myGeometries[num_geom].IsNull()) {
num_geom += 1 ;
}
return num_geom ;
}
//=======================================================================
//function : IsDimension
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Constraint::IsDimension () const
{
return !myValue.IsNull();
}
//=======================================================================
//function : IsPlanar
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Constraint::IsPlanar () const
{
return !myPlane.IsNull();
}
//=======================================================================
//function : SetValue
//purpose :
//=======================================================================
void TDataXtd_Constraint::SetValue (const Handle(TDataStd_Real)& V)
{
// OCC2932 correction
if (myValue.IsNull() == Standard_False && V.IsNull() == Standard_False)
if(myValue->Get() == V->Get()) return;
Backup();
myValue = V;
}
//=======================================================================
//function : GetValue
//purpose :
//=======================================================================
const Handle(TDataStd_Real)& TDataXtd_Constraint::GetValue () const
{
return myValue;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Constraint::ID () const { return GetID(); }
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataXtd_Constraint::NewEmpty () const
{
return new TDataXtd_Constraint ();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataXtd_Constraint::Restore(const Handle(TDF_Attribute)& with)
{
Handle(TDataXtd_Constraint) CTR =Handle(TDataXtd_Constraint)::DownCast(with);
myGeometries [0] = CTR->GetGeometry (1);
myGeometries [1] = CTR->GetGeometry (2);
myGeometries [2] = CTR->GetGeometry (3);
myGeometries [3] = CTR->GetGeometry (4);
myType = CTR->GetType ();
myValue = CTR->GetValue ();
myIsVerified = CTR->Verified();
myIsInverted = CTR->Inverted();
myIsReversed = CTR->Reversed();
myPlane = CTR->GetPlane();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataXtd_Constraint::Paste (const Handle(TDF_Attribute)& into,
const Handle(TDF_RelocationTable)& RT) const
{
Handle(TDataXtd_Constraint) CTR =Handle(TDataXtd_Constraint)::DownCast (into);
Handle(TNaming_NamedShape) G1, G2, G3, G4, plane;
RT->HasRelocation (myGeometries[0], G1);
CTR->SetGeometry (1, G1);
RT->HasRelocation (myGeometries[1], G2);
CTR->SetGeometry (2, G2);
RT->HasRelocation (myGeometries[2], G3);
CTR->SetGeometry (3, G3);
RT->HasRelocation (myGeometries[3], G4);
CTR->SetGeometry (4, G4);
RT->HasRelocation (myPlane, plane);
CTR->SetPlane(plane);
Handle(TDataStd_Real) Value;
RT->HasRelocation (myValue,Value);
CTR->SetValue (Value);
CTR->SetType (myType);
CTR->Verified(Verified());
CTR->Inverted(Inverted());
CTR->Reversed(Reversed());
}
//=======================================================================
//function : References
//purpose :
//=======================================================================
void TDataXtd_Constraint::References(const Handle(TDF_DataSet)& DS) const
{
//bidouille en attendant traitement des contraintes d assemblage en dehors de la part
// l attribut placement devrait oriente vers les contraintes de placement en dehors
Standard_Integer Lim;
if (myType >= TDataXtd_MATE && myType<=TDataXtd_FACES_ANGLE) Lim =1;
else Lim =3;
for (Standard_Integer i=0; i<=Lim; i++) {
if (!myGeometries [i].IsNull()) DS->AddAttribute (myGeometries[i]);
}
if (!myValue.IsNull()) DS->AddAttribute (myValue);
if (!myPlane.IsNull()) DS->AddAttribute (myPlane);
}
//=======================================================================
//function : Verified
//purpose :
//=======================================================================
void TDataXtd_Constraint::Verified(const Standard_Boolean status)
{
// OCC2932 correction
if(myIsVerified == status) return;
Backup();
myIsVerified = status;
}
//=======================================================================
//function : Verified
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Constraint::Verified() const
{
return myIsVerified;
}
//=======================================================================
//function : Reversed
//purpose :
//=======================================================================
void TDataXtd_Constraint::Reversed(const Standard_Boolean status)
{
// OCC2932 correction
if(myIsReversed == status ) return;
Backup();
myIsReversed = status;
}
//=======================================================================
//function : Reversed
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Constraint::Reversed() const
{
return myIsReversed;
}
//=======================================================================
//function : Inverted
//purpose :
//=======================================================================
void TDataXtd_Constraint::Inverted(const Standard_Boolean status)
{
// OCC2932 correction
if(myIsInverted == status) return;
Backup();
myIsInverted = status;
}
//=======================================================================
//function : Inverted
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Constraint::Inverted() const
{
return myIsInverted;
}
//=======================================================================
//function : CollectChildConstraints
//purpose :
//=======================================================================
void TDataXtd_Constraint::CollectChildConstraints(const TDF_Label& aLabel,
TDF_LabelList& LL)
{
TDF_ChildIterator it(aLabel,Standard_True);
Handle(TDataXtd_Constraint) aConstraint;
for (; it.More(); it.Next()) {
if (it.Value().FindAttribute(TDataXtd_Constraint::GetID(), aConstraint)) {
LL.Append(it.Value());
}
}
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
Standard_OStream& TDataXtd_Constraint::Dump (Standard_OStream& anOS) const
{
anOS << "Constraint ";
TDataXtd::Print(GetType(),anOS);
return anOS;
}

View File

@@ -0,0 +1,177 @@
-- File: TDataXtd_Geometry.cdl
-- Created: Mon Apr 6 17:49:28 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2009
class Geometry from TDataXtd inherits Attribute from TDF
---Purpose: This class is used to model construction geometry.
-- The specific geometric construction of the
-- attribute is defined by an element of the
-- enumeration TDataXtd_GeometryEnum.
-- This attribute may also be used to qualify underlying
-- geometry of the associated NamedShape. for
-- Constructuion element by example.
uses Attribute from TDF,
Label from TDF,
GUID from Standard,
GeometryEnum from TDataXtd,
DataSet from TDF,
RelocationTable from TDF,
NamedShape from TNaming,
Pnt from gp,
Ax1 from gp,
Lin from gp,
Circ from gp,
Elips from gp,
Pln from gp,
Cylinder from gp
is
---Purpose: API class methods
-- =================
Set (myclass ; label : Label from TDF)
---Purpose: Finds, or creates, a Geometry attribute defined by the label label.
-- The default type of geometry is the value
-- ANY_GEOM of the enumeration TDataXtd_GeometryEnum.
-- To specify another value of this enumeration, use
-- the function SetType.
returns Geometry from TDataXtd;
Type (myclass; L : Label from TDF)
returns GeometryEnum from TDataXtd;
---Purpose:
-- Returns the label L used to define the type of
-- geometric construction for the geometry attribute.
Type (myclass; S : NamedShape from TNaming)
returns GeometryEnum from TDataXtd;
---Purpose: Returns the topological attribute S used to define
-- the type of geometric construction for the geometry attribute.
Point (myclass; L : Label from TDF; G : in out Pnt from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the point attribute defined by the label L and the point G.
Point (myclass; S : NamedShape from TNaming; G : in out Pnt from gp)
---Purpose:
-- Returns the point attribute defined by the topological attribute S and the point G.
returns Boolean from Standard;
Axis (myclass; L : Label from TDF; G : in out Ax1 from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the axis attribute defined by the label L and the axis G.
Axis (myclass; S : NamedShape from TNaming; G : in out Ax1 from gp)
---Purpose:
-- Returns the axis attribute defined by the topological attribute S and the axis G.
returns Boolean from Standard;
Line (myclass; L : Label from TDF; G : in out Lin from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the line attribute defined by the label L and the line G.
Line (myclass; S : NamedShape from TNaming; G : in out Lin from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the line attribute defined by the topological attribute S and the line G.
Circle (myclass; L : Label from TDF; G : in out Circ from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the circle attribute defined by the label L and the circle G.
Circle (myclass; S : NamedShape from TNaming; G : in out Circ from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the circle attribute defined by the topological attribute S and the circle G.
Ellipse (myclass; L : Label from TDF; G : in out Elips from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the ellipse attribute defined by the label L and the ellipse G.
Ellipse (myclass; S : NamedShape from TNaming; G : in out Elips from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the ellipse attribute defined by the
-- topological attribute S and the ellipse G.
Plane (myclass; L : Label from TDF; G : in out Pln from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the plane attribute defined by the label L and the plane G.
Plane (myclass; S : NamedShape from TNaming; G : in out Pln from gp)
returns Boolean from Standard;
---Purpose:
-- Returns the plane attribute defined by the
-- topological attribute S and the plane G.
Cylinder (myclass; L : Label from TDF; G : in out Cylinder from gp)
---Purpose:
-- Returns the cylinder attribute defined by the label L and the cylinder G.
returns Boolean from Standard;
Cylinder (myclass; S : NamedShape from TNaming; G : in out Cylinder from gp)
---Purpose:
-- Returns the cylinder attribute defined by the
-- topological attribute S and the cylinder G.
returns Boolean from Standard;
GetID(myclass)
---C++: return const &
---Purpose: Returns the GUID for geometry attributes.
returns GUID from Standard;
Create
returns mutable Geometry from TDataXtd;
---Purpose: This and the next methods are used to retrieve underlying geometry of the
-- NamedShape, even if noone Geometry Attribute is
-- associated . if not found or not compliant geometry return False.
SetType (me : mutable; T : GeometryEnum from TDataXtd);
---Purpose: Returns the type of geometric construction T of this attribute.
-- T will be a value of the enumeration TDataXtd_GeometryEnum.
GetType (me)
returns GeometryEnum from TDataXtd;
---Purpose: Returns the type of geometric construction.
---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);
Dump(me; anOS : in out OStream from Standard)
returns OStream from Standard
is redefined;
---C++: return &
fields
myType : GeometryEnum from TDataXtd;
end Geometry;

View File

@@ -0,0 +1,505 @@
// File: TDataXtd_Geometry.cxx
// Created: Mon Apr 6 17:51:45 2009
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2009
#include <TDataXtd_Geometry.ixx>
#include <TDataStd.hxx>
#include <TDataXtd.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx>
#include <TopAbs.hxx>
#include <BRep_Tool.hxx>
#include <Geom_CartesianPoint.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <Geom_Curve.hxx>
#include <Geom_Line.hxx>
#include <Geom_Ellipse.hxx>
#include <Geom_Circle.hxx>
#include <Geom_Curve.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_Plane.hxx>
#include <Geom_CylindricalSurface.hxx>
#include <Standard_Failure.hxx>
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Geometry::GetID ()
{
static Standard_GUID TDataXtd_GeometryID ("2a96b604-ec8b-11d0-bee7-080009dc3333");
return TDataXtd_GeometryID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Geometry) TDataXtd_Geometry::Set (const TDF_Label& L)
{
Handle(TDataXtd_Geometry) A;
if (!L.FindAttribute(TDataXtd_Geometry::GetID(),A)) {
A = new TDataXtd_Geometry ();
// A->SetType(TDataXtd_ANY_GEOM);
L.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : Point
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Point(const TDF_Label& L,gp_Pnt& G)
{
Handle(TNaming_NamedShape) NS;
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
return Point(NS,G);
}
return Standard_False;
}
//=======================================================================
//function : Point
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Point(const Handle(TNaming_NamedShape)& NS, gp_Pnt& G)
{
const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS);
if (shape.IsNull()) return Standard_False;
if (shape.ShapeType() == TopAbs_VERTEX) {
const TopoDS_Vertex& vertex = TopoDS::Vertex(shape);
G = BRep_Tool::Pnt (TopoDS::Vertex (vertex));
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Axis
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Axis(const TDF_Label& L,gp_Ax1& G)
{
Handle(TNaming_NamedShape) NS;
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
return Axis(NS,G);
}
return Standard_False;
}
//=======================================================================
//function : Axis
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Axis(const Handle(TNaming_NamedShape)& NS, gp_Ax1& G)
{
gp_Lin lin;
if (Line(NS, lin)) {
G = lin.Position();
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : Line
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Line(const TDF_Label& L,gp_Lin& G)
{
Handle(TNaming_NamedShape) NS;
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
return Line(NS,G);
}
return Standard_False;
}
//=======================================================================
//function : Line
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Line(const Handle(TNaming_NamedShape)& NS,gp_Lin& G)
{
const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS);
if (shape.IsNull()) return Standard_False;
if (shape.ShapeType() == TopAbs_EDGE) {
const TopoDS_Edge& edge = TopoDS::Edge(shape);
Standard_Real first,last;
// TopLoc_Location loc;
Handle(Geom_Curve) curve = BRep_Tool::Curve (edge,first,last);
if (!curve.IsNull()) {
if (curve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
curve = (Handle(Geom_TrimmedCurve)::DownCast (curve))->BasisCurve ();
Handle(Geom_Line) C = Handle(Geom_Line)::DownCast(curve);
if (!C.IsNull()) {
G = C->Lin();
return Standard_True;
}
}
}
return Standard_False;
}
//=======================================================================
//function : Circle
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Circle(const TDF_Label& L,gp_Circ& G)
{
Handle(TNaming_NamedShape) NS;
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
return Circle(NS,G);
}
return Standard_False;
}
//=======================================================================
//function : Circle
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Circle(const Handle(TNaming_NamedShape)& NS,gp_Circ& G)
{
const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS);
if (shape.IsNull()) return Standard_False;
if (shape.ShapeType() == TopAbs_EDGE) {
const TopoDS_Edge& edge = TopoDS::Edge(shape);
Standard_Real first,last;
// TopLoc_Location loc;
Handle(Geom_Curve) curve = BRep_Tool::Curve (edge,first,last);
if (!curve.IsNull()) {
if (curve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
curve = (Handle(Geom_TrimmedCurve)::DownCast (curve))->BasisCurve ();
Handle(Geom_Circle) C = Handle(Geom_Circle)::DownCast(curve);
if (!C.IsNull()) {
G = C->Circ();
return Standard_True;
}
}
}
return Standard_False;
}
//=======================================================================
//function : Ellipse
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Ellipse(const TDF_Label& L,gp_Elips& G)
{
Handle(TNaming_NamedShape) NS;
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
return Ellipse(NS,G);
}
return Standard_False;
}
//=======================================================================
//function : Ellipse
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Ellipse(const Handle(TNaming_NamedShape)& NS, gp_Elips& G)
{
const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS);
if (shape.IsNull()) return Standard_False;
if (shape.ShapeType() == TopAbs_EDGE) {
const TopoDS_Edge& edge = TopoDS::Edge(shape);
Standard_Real first,last;
Handle(Geom_Curve) curve = BRep_Tool::Curve (edge,first,last);
if (!curve.IsNull()) {
if (curve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve)))
curve = (Handle(Geom_TrimmedCurve)::DownCast (curve))->BasisCurve ();
Handle(Geom_Ellipse) C = Handle(Geom_Ellipse)::DownCast(curve);
if (!C.IsNull()) {
G = C->Elips();
return Standard_True;
}
}
}
return Standard_False;
}
//=======================================================================
//function : Plane
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Plane(const TDF_Label& L, gp_Pln& G)
{
Handle(TNaming_NamedShape) NS;
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
return Plane(NS,G);
}
return Standard_False;
}
//=======================================================================
//function : Plane
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Plane(const Handle(TNaming_NamedShape)& NS, gp_Pln& G)
{
const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS);
if (shape.IsNull()) return Standard_False;
if (shape.ShapeType() == TopAbs_FACE) {
const TopoDS_Face& face = TopoDS::Face(shape);
Handle(Geom_Surface) surface = BRep_Tool::Surface (face);
if (!surface.IsNull()) {
if (surface->IsInstance(STANDARD_TYPE(Geom_RectangularTrimmedSurface)))
surface = ((Handle(Geom_RectangularTrimmedSurface)&) surface)->BasisSurface();
Handle(Geom_Plane) S = Handle(Geom_Plane)::DownCast(surface);
if (!S.IsNull()) {
G = S->Pln();
return Standard_True;
}
}
}
return Standard_False;
}
//=======================================================================
//function : Cylinder
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Cylinder(const TDF_Label& L, gp_Cylinder& G)
{
Handle(TNaming_NamedShape) NS;
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
return Cylinder (NS,G);
}
return Standard_False;
}
//=======================================================================
//function : Cylinder
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Geometry::Cylinder(const Handle(TNaming_NamedShape)& NS, gp_Cylinder& G)
{
const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS);
if (shape.IsNull()) return Standard_False;
if (shape.ShapeType() == TopAbs_FACE) {
const TopoDS_Face& face = TopoDS::Face(shape);
Handle(Geom_Surface) surface = BRep_Tool::Surface (face);
if (!surface.IsNull()) {
if (surface->IsInstance(STANDARD_TYPE(Geom_RectangularTrimmedSurface)))
surface = ((Handle(Geom_RectangularTrimmedSurface)&) surface)->BasisSurface();
Handle(Geom_CylindricalSurface) S = Handle(Geom_CylindricalSurface)::DownCast(surface);
if (!S.IsNull()) {
G = S->Cylinder();
return Standard_True;
}
}
}
return Standard_False;
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
TDataXtd_GeometryEnum TDataXtd_Geometry::Type (const TDF_Label& L)
{
Handle(TNaming_NamedShape) NS;
if (L.FindAttribute(TNaming_NamedShape::GetID(),NS)) {
return Type (NS);
}
return TDataXtd_ANY_GEOM;
}
//=======================================================================
//function : Type
//purpose :
//=======================================================================
TDataXtd_GeometryEnum TDataXtd_Geometry::Type (const Handle(TNaming_NamedShape)& NS)
{
TDataXtd_GeometryEnum type (TDataXtd_ANY_GEOM);
const TopoDS_Shape& shape = TNaming_Tool::GetShape(NS);
switch (shape.ShapeType()) {
case TopAbs_VERTEX :
{
type = TDataXtd_POINT;
break;
}
case TopAbs_EDGE :
{
const TopoDS_Edge& edge = TopoDS::Edge(shape);
Standard_Real first,last;
// TopLoc_Location loc;
Handle(Geom_Curve) curve = BRep_Tool::Curve (edge,first,last);
if (!curve.IsNull()) {
if (curve->IsInstance (STANDARD_TYPE (Geom_TrimmedCurve))) {
curve = (Handle(Geom_TrimmedCurve)::DownCast (curve))->BasisCurve ();
}
if (curve->IsInstance(STANDARD_TYPE(Geom_Line))) {
type = TDataXtd_LINE;
}
else if (curve->IsInstance(STANDARD_TYPE(Geom_Circle))) {
type = TDataXtd_CIRCLE;
}
else if (curve->IsInstance(STANDARD_TYPE(Geom_Ellipse))) {
type = TDataXtd_ELLIPSE;
}
break;
}
#ifdef DEB
else {
Standard_Failure::Raise("curve Null dans TDataXtd_Geometry");
}
#endif
}
case TopAbs_FACE :
{
const TopoDS_Face& face = TopoDS::Face(shape);
Handle(Geom_Surface) surface = BRep_Tool::Surface (face);
if (!surface.IsNull()) {
if (surface->IsInstance(STANDARD_TYPE(Geom_RectangularTrimmedSurface))) {
surface = ((Handle(Geom_RectangularTrimmedSurface)&) surface)->BasisSurface();
}
if (surface->IsInstance(STANDARD_TYPE(Geom_CylindricalSurface))) {
type = TDataXtd_CYLINDER;
}
else if (surface->IsInstance(STANDARD_TYPE(Geom_Plane))) {
type = TDataXtd_PLANE;
}
}
#ifdef DEB
else {
Standard_Failure::Raise("surface Null dans TDataXtd_Geometry");
}
#endif
break;
}
default :
{
break;
}
}
return type;
}
//=======================================================================
//function : TDataXtd_Geometry
//purpose :
//=======================================================================
TDataXtd_Geometry::TDataXtd_Geometry ()
: myType (TDataXtd_ANY_GEOM)
{ }
//=======================================================================
//function : GetType
//purpose :
//=======================================================================
TDataXtd_GeometryEnum TDataXtd_Geometry::GetType () const
{
return myType;
}
//=======================================================================
//function : SetType
//purpose :
//=======================================================================
void TDataXtd_Geometry::SetType (const TDataXtd_GeometryEnum G)
{
// OCC2932 correction
if(myType == G) return;
Backup();
myType = G;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Geometry::ID() const { return GetID(); }
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataXtd_Geometry::NewEmpty () const
{
return new TDataXtd_Geometry();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataXtd_Geometry::Restore (const Handle(TDF_Attribute)& With)
{
myType = Handle(TDataXtd_Geometry)::DownCast(With)->GetType();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataXtd_Geometry::Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const {
Handle(TDataXtd_Geometry)::DownCast(Into)->SetType(myType);
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
Standard_OStream& TDataXtd_Geometry::Dump (Standard_OStream& anOS) const
{
anOS << "Geometry ";
TDataXtd::Print(GetType(),anOS);
return anOS;
}

View File

@@ -0,0 +1,47 @@
-- File: TDataXtd_Pattern.cdl
-- Created: Mon Apr 6 17:58:39 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2009
deferred class Pattern from TDataXtd inherits Attribute from TDF
---Purpose: a general pattern model
uses
Array1OfTrsf from TDataXtd,
LabelList from TDF,
GUID from Standard
is
GetID (myclass)
---C++: return const &
returns GUID from Standard;
ID(me)
returns GUID from Standard
is redefined static;
---Purpose: Returns the ID of the attribute.
--
---C++: return const &
PatternID(me)
returns GUID from Standard
is deferred;
---Purpose: Returns the ID of the attribute.
--
---C++: return const &
NbTrsfs(me)
returns Integer from Standard
is deferred;
---Purpose: Give the number of transformation
ComputeTrsfs(me; Trsfs : in out Array1OfTrsf from TDataXtd)
is deferred;
---Purpose: Give the transformations
end Pattern;

View File

@@ -0,0 +1,27 @@
// File: TDataXtd_Pattern.cxx
// Created: Mon Apr 6 18:00:08 2009
// Author: Sergey ZARITCHNY
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2009
#include <TDataXtd_Pattern.ixx>
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Pattern::GetID()
{
static Standard_GUID myID("2a96b618-ec8b-11d0-bee7-080009dc3333");
return myID;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Pattern::ID() const
{ return GetID(); }

View File

@@ -0,0 +1,152 @@
-- File: TDataXtd_PatternStd.cdl
-- Created: Mon Apr 6 18:02:51 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2009
class PatternStd from TDataXtd inherits Pattern from TDataXtd
---Purpose: to create a PatternStd
uses
Label from TDF,
Attribute from TDF,
RelocationTable from TDF,
DataSet from TDF,
NamedShape from TNaming,
Real from TDataStd,
Integer from TDataStd,
Array1OfTrsf from TDataXtd,
OStream from Standard,
GUID from Standard
is
---Category: class methods
-- =============
GetPatternID(myclass)
---C++: return const &
returns GUID from Standard;
Set (myclass ; label : Label from TDF)
returns PatternStd from TDataXtd;
---Purpose: Find, or create, a PatternStd attribute
---Category: constructor
-- ===========
Create
returns mutable PatternStd from TDataXtd;
--- Category: Set and Get methods
Signature(me: mutable; signature: Integer from Standard);
-- Use SetSignature to set the signature
-- signature = 1 : linear PatternStd
-- (axis1 + dist1 + nb1)
-- = 2 : circular PatternStd
-- (axis1 + angle + nb1)
-- = 3 : rentagular PatternStd
-- (axis1 + dist1 + nb1 + axis2 + dist2 + nb2)
-- = 4 : circular rectangulaire PatternStd
-- (axis1 + dist1 + nb1 + axis2 + angle + nb2)
-- = 5 : mirror PatternStd
-- (plane)
Axis1(me: mutable; Axis1: NamedShape from TNaming);
Axis2(me: mutable; Axis2: NamedShape from TNaming);
Axis1Reversed(me: mutable; Axis1Reversed: Boolean from Standard);
Axis2Reversed(me: mutable; Axis2Reversed: Boolean from Standard);
Value1(me: mutable; value : Real from TDataStd);
Value2(me: mutable; value : Real from TDataStd);
NbInstances1(me: mutable; NbInstances1: Integer from TDataStd);
NbInstances2(me: mutable; NbInstances2: Integer from TDataStd);
Mirror(me: mutable; plane: NamedShape from TNaming);
Signature(me) returns Integer from Standard;
---C++: inline
Axis1(me) returns NamedShape from TNaming;
---C++: inline
Axis2(me) returns NamedShape from TNaming;
---C++: inline
Axis1Reversed(me) returns Boolean from Standard;
---C++: inline
Axis2Reversed(me) returns Boolean from Standard;
---C++: inline
Value1(me) returns Real from TDataStd;
---C++: inline
Value2(me) returns Real from TDataStd;
---C++: inline
NbInstances1(me) returns Integer from TDataStd;
---C++: inline
NbInstances2(me) returns Integer from TDataStd;
---C++: inline
Mirror(me) returns NamedShape from TNaming;
---C++: inline
--- Category: TDataXtd_Pattern methods
NbTrsfs(me) returns Integer from Standard;
ComputeTrsfs(me; Trsfs: in out Array1OfTrsf from TDataXtd);
---Category: Deferred methods from TDF_Attribute
PatternID (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);
References(me; aDataSet : DataSet from TDF)
is redefined;
Dump(me; anOS : in out OStream from Standard)
---C++: return &
returns OStream from Standard
is redefined;
fields
mySignature : Integer from Standard;
myAxis1Reversed : Boolean from Standard;
myAxis2Reversed : Boolean from Standard;
myAxis1 : NamedShape from TNaming;
myAxis2 : NamedShape from TNaming;
myValue1 : Real from TDataStd;
myValue2 : Real from TDataStd;
myNb1 : Integer from TDataStd;
myNb2 : Integer from TDataStd;
myMirror : NamedShape from TNaming;
end PatternStd;

View File

@@ -0,0 +1,419 @@
// File: TDataXtd_PatternStd.cxx
// Created: Mon Apr 6 18:05:31 2009
// Author: Sergey ZARITCHNY
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2009
#include <TDataXtd_PatternStd.ixx>
#include <TDataStd.hxx>
#include <TDataXtd_Geometry.hxx>
#include <TDF_Label.hxx>
#include <gp_Vec.hxx>
#include <gp_Lin.hxx>
#include <gp_Trsf.hxx>
#include <gp_Pln.hxx>
#include <gp_Ax1.hxx>
#include <TopoDS_Shape.hxx>
//=======================================================================
//function : GetPatternID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_PatternStd::GetPatternID()
{
static Standard_GUID TDataXtd_PatternStdID("2a96b61b-ec8b-11d0-bee7-080009dc3333");
return TDataXtd_PatternStdID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_PatternStd) TDataXtd_PatternStd::Set (const TDF_Label& L)
{
Handle(TDataXtd_PatternStd) A;
if (!L.FindAttribute(TDataXtd_Pattern::GetID(), A)) {
A = new TDataXtd_PatternStd();
L.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : TDataXtd_PatternStd
//purpose :
//=======================================================================
TDataXtd_PatternStd::TDataXtd_PatternStd()
: mySignature (0),
myAxis1Reversed (Standard_False),
myAxis2Reversed (Standard_False)
{}
//=======================================================================
//function : Signature
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Signature(const Standard_Integer signature)
{
// OCC2932 correction
if(mySignature == signature) return;
Backup();
mySignature = signature;
}
//=======================================================================
//function : Axis1
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Axis1(const Handle(TNaming_NamedShape)& Axis1)
{
// OCC2932 correction
if(!myAxis1.IsNull())
if(myAxis1->Get() == Axis1->Get())
return;
Backup();
myAxis1 = Axis1;
}
//=======================================================================
//function : Axis2
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Axis2(const Handle(TNaming_NamedShape)& Axis2)
{
// OCC2932 correction
if(!myAxis2.IsNull())
if(myAxis2->Get() == Axis2->Get())
return;
Backup();
myAxis2 = Axis2;
}
//=======================================================================
//function : Axis1Reversed
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Axis1Reversed(const Standard_Boolean Axis1Reversed)
{
// OCC2932 correction
if(myAxis1Reversed == Axis1Reversed) return;
Backup();
myAxis1Reversed = Axis1Reversed;
}
//=======================================================================
//function : Axis2Reversed
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Axis2Reversed(const Standard_Boolean Axis2Reversed)
{
// OCC2932 correction
if(myAxis2Reversed == Axis2Reversed) return;
Backup();
myAxis2Reversed = Axis2Reversed;
}
//=======================================================================
//function : Value1
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Value1(const Handle(TDataStd_Real)& value)
{
// OCC2932 correction
if(!myValue1.IsNull())
if(myValue1->Get() == value->Get())
return;
Backup();
myValue1 = value;
}
//=======================================================================
//function : Value2
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Value2(const Handle(TDataStd_Real)& value)
{
// OCC2932 correction
if(!myValue2.IsNull())
if(myValue2->Get() == value->Get())
return;
Backup();
myValue2 = value;
}
//=======================================================================
//function : NbInstances1
//purpose :
//=======================================================================
void TDataXtd_PatternStd::NbInstances1(const Handle(TDataStd_Integer)& NbInstances1)
{
// OCC2932 correction
if(!myNb1.IsNull())
if(myNb1->Get() == NbInstances1->Get())
return;
Backup();
myNb1 = NbInstances1;
}
//=======================================================================
//function : NbInstances2
//purpose :
//=======================================================================
void TDataXtd_PatternStd::NbInstances2(const Handle(TDataStd_Integer)& NbInstances2)
{
// OCC2932 correction
if(!myNb1.IsNull())
if(myNb1->Get() == NbInstances2->Get())
return;
Backup();
myNb2 = NbInstances2;
}
//=======================================================================
//function : Mirror
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Mirror(const Handle(TNaming_NamedShape)& plane)
{
// OCC2932 correction
if(!myMirror.IsNull()) {
if(myMirror->Get() == plane->Get())
return;
}
Backup();
myMirror = plane;
}
//=======================================================================
//function : NbTrsfs
//purpose :
//=======================================================================
Standard_Integer TDataXtd_PatternStd::NbTrsfs() const
{
Standard_Integer nb = 1;
if (mySignature < 5) {
if (!myNb1.IsNull()) nb = myNb1->Get();
if (!myNb2.IsNull()) nb = nb*myNb2->Get();
nb--;
}
return nb;
}
//=======================================================================
//function : ComputeTrsfs
//purpose :
//=======================================================================
void TDataXtd_PatternStd::ComputeTrsfs(TDataXtd_Array1OfTrsf& Trsfs) const
{
Standard_Integer nb = 0;
gp_Trsf trsf;
if (mySignature < 5) {
// recover direction and step
gp_Ax1 axis1;
TDataXtd_Geometry::Axis(myAxis1, axis1);
if (myAxis1Reversed) axis1.Reverse();
Standard_Real value1 = myValue1->Get();
for (Standard_Integer i=2; i<=myNb1->Get(); i++) {
if (mySignature != 2) {
gp_Vec vec(axis1.Direction());
vec *= (value1*(i-1));
trsf.SetTranslation(vec);
}
else {
trsf.SetRotation(axis1, value1*(i-1));
}
Trsfs(++nb) = trsf;
}
if (mySignature == 3 || mySignature == 4) {
// recover direction and step
gp_Ax1 axis2;
TDataXtd_Geometry::Axis(myAxis2, axis2);
if (myAxis2Reversed) axis2.Reverse();
Standard_Real value2 = myValue2->Get();
for (Standard_Integer j=2; j<=myNb2->Get(); j++) {
gp_Trsf trsf2;
if (mySignature ==3) {
gp_Vec vec(axis2.Direction());
vec *= (value2*(j-1));
trsf2.SetTranslation(vec);
}
else {
trsf2.SetRotation(axis2, value2*(j-1));
}
Trsfs(++nb) = trsf2;
for (Standard_Integer i=2; i<=myNb1->Get(); i++) {
trsf = trsf2;
trsf.Multiply(Trsfs(i-1));
Trsfs(++nb) = trsf;
}
}
}
}
else {
gp_Pln pln;
TDataXtd_Geometry::Plane(myMirror, pln);
trsf.SetMirror(pln.Position().Ax2());
Trsfs(++nb) = trsf;
}
}
//=======================================================================
//function : PatternID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_PatternStd::PatternID() const
{
return GetPatternID ();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Restore(const Handle(TDF_Attribute)& With)
{
Handle(TDataXtd_PatternStd) PatternStd = Handle(TDataXtd_PatternStd)::DownCast(With);
mySignature = PatternStd->Signature();
myAxis1Reversed = PatternStd->Axis1Reversed();
myAxis2Reversed = PatternStd->Axis2Reversed();
myAxis1 = PatternStd->Axis1();
myAxis2 = PatternStd->Axis2();
myValue1 = PatternStd->Value1();
myValue2 = PatternStd->Value2();
myNb1 = PatternStd->NbInstances1();
myNb2 = PatternStd->NbInstances2();
myMirror = PatternStd->Mirror();
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataXtd_PatternStd::NewEmpty() const
{
return new TDataXtd_PatternStd();
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataXtd_PatternStd::Paste(const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& RT) const
{
Handle(TDataXtd_PatternStd) intof = Handle(TDataXtd_PatternStd)::DownCast(Into);
intof->Signature(mySignature);
intof->Axis1Reversed(myAxis1Reversed);
intof->Axis2Reversed(myAxis2Reversed);
if (mySignature < 5) {
Handle(TNaming_NamedShape) axis;
Handle(TDataStd_Real) value;
Handle(TDataStd_Integer) nb;
RT->HasRelocation(myAxis1, axis);
intof->Axis1(axis);
RT->HasRelocation(myValue1, value);
intof->Value1(value);
RT->HasRelocation(myNb1, nb);
intof->NbInstances1(nb);
if (mySignature > 2) {
RT->HasRelocation(myAxis2, axis);
intof->Axis2(axis);
RT->HasRelocation(myValue2, value);
intof->Value2(value);
RT->HasRelocation(myNb2, nb);
intof->NbInstances2(nb);
}
}
else {
Handle(TNaming_NamedShape) plane;
RT->HasRelocation(myMirror, plane);
intof->Mirror(plane);
}
}
//=======================================================================
//function : References
//purpose :
//=======================================================================
void TDataXtd_PatternStd::References(const Handle(TDF_DataSet)& aDataSet) const
{
if (mySignature < 5) {
aDataSet->AddAttribute(myAxis1);
aDataSet->AddAttribute(myValue1);
aDataSet->AddAttribute(myNb1);
if (mySignature > 2) {
aDataSet->AddAttribute(myAxis2);
aDataSet->AddAttribute(myValue2);
aDataSet->AddAttribute(myNb2);
}
}
else {
aDataSet->AddAttribute(myMirror);
}
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
Standard_OStream& TDataXtd_PatternStd::Dump(Standard_OStream& anOS) const
{
anOS << "TDataXtd_PatternStd";
return anOS;
}

View File

@@ -0,0 +1,105 @@
// File: TDataXtd_PatternStd.lxx
// Created: Mon Apr 6 18:10:37 2009
// Author: Sergey ZARITCHNY
// <szy@covox>
//=======================================================================
//function : Signature
//purpose :
//=======================================================================
inline Standard_Integer TDataXtd_PatternStd::Signature() const
{
return mySignature;
}
//=======================================================================
//function : Axis1
//purpose :
//=======================================================================
inline Handle(TNaming_NamedShape) TDataXtd_PatternStd::Axis1() const
{
return myAxis1;
}
//=======================================================================
//function : Axis2
//purpose :
//=======================================================================
inline Handle(TNaming_NamedShape) TDataXtd_PatternStd::Axis2() const
{
return myAxis2;
}
//=======================================================================
//function : Axis1Reversed
//purpose :
//=======================================================================
inline Standard_Boolean TDataXtd_PatternStd::Axis1Reversed() const
{
return myAxis1Reversed;
}
//=======================================================================
//function : Axis2Reversed
//purpose :
//=======================================================================
inline Standard_Boolean TDataXtd_PatternStd::Axis2Reversed() const
{
return myAxis2Reversed;
}
//=======================================================================
//function : Value1
//purpose :
//=======================================================================
inline Handle(TDataStd_Real) TDataXtd_PatternStd::Value1() const
{
return myValue1;
}
//=======================================================================
//function : Value2
//purpose :
//=======================================================================
inline Handle(TDataStd_Real) TDataXtd_PatternStd::Value2() const
{
return myValue2;
}
//=======================================================================
//function : NbInstances1
//purpose :
//=======================================================================
inline Handle(TDataStd_Integer) TDataXtd_PatternStd::NbInstances1() const
{
return myNb1;
}
//=======================================================================
//function : NbInstances2
//purpose :
//=======================================================================
inline Handle(TDataStd_Integer) TDataXtd_PatternStd::NbInstances2() const
{
return myNb2;
}
//=======================================================================
//function : Mirror
//purpose :
//=======================================================================
inline Handle(TNaming_NamedShape) TDataXtd_PatternStd::Mirror() const
{
return myMirror;
}

View File

@@ -0,0 +1,64 @@
-- File: TDataXtd_Placement.cdl
-- Created: Mon Apr 6 18:12:47 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2009
class Placement from TDataXtd inherits Attribute from TDF
---Purpose:
uses Attribute from TDF,
Label from TDF,
GUID from Standard,
Integer from Standard,
DataSet from TDF,
RelocationTable from TDF,
Constraint from TDataXtd
is
---Purpose: class methods
-- =============
GetID (myclass)
---C++: return const &
returns GUID from Standard;
Set (myclass; label : Label from TDF)
---Purpose: Find, or create, an Placement attribute. the
-- Placement attribute is returned.
returns Placement from TDataXtd;
---Purpose: Placement methods
-- =================
Create
returns mutable Placement from TDataXtd;
---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);
Dump (me; anOS : in out OStream from Standard)
returns OStream from Standard
is redefined;
---C++: return &
end Placement;

View File

@@ -0,0 +1,96 @@
// File: TDataXtd_Placement.cxx
// Created: Mon Apr 6 18:14:13 2009
// Author: Sergey ZARITCHNY
// <szy@covox>
#include <TDataXtd_Placement.ixx>
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Placement::GetID ()
{
static Standard_GUID TDataXtd_PlacementID ("2a96b60b-ec8b-11d0-bee7-080009dc3333");
return TDataXtd_PlacementID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Placement) TDataXtd_Placement::Set (const TDF_Label& L)
{
Handle (TDataXtd_Placement) A;
if (!L.FindAttribute (TDataXtd_Placement::GetID (), A)) {
A = new TDataXtd_Placement ();
L.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : TDataXtd_Placement
//purpose :
//=======================================================================
TDataXtd_Placement::TDataXtd_Placement () { }
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Placement::ID () const { return GetID(); }
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataXtd_Placement::NewEmpty() const
{
return new TDataXtd_Placement();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataXtd_Placement::Restore (const Handle(TDF_Attribute)& other)
{
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataXtd_Placement::Paste(const Handle(TDF_Attribute)& Into,
const Handle(TDF_RelocationTable)& RT) const
{
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
Standard_OStream& TDataXtd_Placement::Dump (Standard_OStream& anOS) const
{
anOS << "Placement";
return anOS;
}

76
src/TDataXtd/TDataXtd_Plane.cdl Executable file
View File

@@ -0,0 +1,76 @@
-- File: TDataXtd_Plane.cdl
-- Created: Mon Apr 6 18:22:10 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2009
class Plane from TDataXtd inherits Attribute from TDF
---Purpose: The basis to define a plane attribute.
-- Warning: Use TDataXtd_Geometry attribute to retrieve the
-- gp_Pln of the Plane attribute
uses Attribute from TDF,
Label from TDF,
GUID from Standard,
Label from TDF,
Plane from Geom,
Pln from gp,
DataSet from TDF,
RelocationTable from TDF
is
---Purpose: class methods
-- =============
GetID (myclass)
---C++: return const &
returns GUID from Standard;
---Purpose:
-- Returns the GUID for plane attributes.
Set (myclass ; label : Label from TDF)
---Purpose: Finds or creates the plane attribute defined by
-- the label label.
-- Warning
-- If you are creating the attribute with this syntax, a
-- planar face should already be associated with label.
returns Plane from TDataXtd;
Set (myclass ; label : Label from TDF; P : Pln from gp)
---Purpose: Finds, or creates, a Plane attribute and sets <P> as
-- generated the associated NamedShape.
returns Plane from TDataXtd;
---Purpose: Plane methods
-- =============
Create
returns mutable Plane from TDataXtd;
---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);
Dump (me; anOS : in out OStream from Standard)
returns OStream from Standard
is redefined;
---C++: return &
end Plane;

144
src/TDataXtd/TDataXtd_Plane.cxx Executable file
View File

@@ -0,0 +1,144 @@
// File: TDataXtd_Plane.cxx
// Created: Mon Apr 6 18:24:00 2009
// Author: Sergey ZARITCHNY
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2009
#include <TDataXtd_Plane.ixx>
#include <TDataStd.hxx>
#include <TDataXtd.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <TNaming_Builder.hxx>
#include <TDF_Label.hxx>
#include <gp_Pln.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Face.hxx>
#include <TopAbs.hxx>
#include <BRep_Tool.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <Geom_RectangularTrimmedSurface.hxx>
#include <Geom_Plane.hxx>
#include <GeomLib_IsPlanarSurface.hxx>
#define OCC2932
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Plane::GetID ()
{
static Standard_GUID TDataXtd_PlaneID("2a96b60c-ec8b-11d0-bee7-080009dc3333");
return TDataXtd_PlaneID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Plane) TDataXtd_Plane::Set (const TDF_Label& L)
{
Handle(TDataXtd_Plane) A;
if (!L.FindAttribute(TDataXtd_Plane::GetID(),A)) {
A = new TDataXtd_Plane ();
L.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Plane) TDataXtd_Plane::Set (const TDF_Label& L, const gp_Pln& P)
{
Handle(TDataXtd_Plane) A = Set (L);
#ifdef OCC2932
Handle(TNaming_NamedShape) aNS;
if(L.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
if(!aNS->Get().IsNull())
if(aNS->Get().ShapeType() == TopAbs_FACE) {
TopoDS_Face aFace = TopoDS::Face(aNS->Get());
Handle(Geom_Surface) aSurface = BRep_Tool::Surface(aFace);
GeomLib_IsPlanarSurface aChecker(aSurface);
if(aChecker.IsPlanar()) {
gp_Pln aPlane = aChecker.Plan();
if(aPlane.Location().X() == P.Location().X() &&
aPlane.Location().Y() == P.Location().Y() &&
aPlane.Location().Z() == P.Location().Z() &&
aPlane.Axis().Location().X() == P.Axis().Location().X() &&
aPlane.Axis().Location().Y() == P.Axis().Location().Y() &&
aPlane.Axis().Location().Z() == P.Axis().Location().Z() &&
aPlane.Axis().Direction().X() == P.Axis().Direction().X() &&
aPlane.Axis().Direction().Y() == P.Axis().Direction().Y() &&
aPlane.Axis().Direction().Z() == P.Axis().Direction().Z()
)
return A;
}
}
}
#endif
TNaming_Builder B(L);
B.Generated(BRepBuilderAPI_MakeFace(P));
return A;
}
//=======================================================================
//function : TDataXtd_Plane
//purpose :
//=======================================================================
TDataXtd_Plane::TDataXtd_Plane () { }
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Plane::ID() const { return GetID(); }
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataXtd_Plane::NewEmpty () const
{
return new TDataXtd_Plane();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataXtd_Plane::Restore(const Handle(TDF_Attribute)& With) {}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataXtd_Plane::Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const { }
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
Standard_OStream& TDataXtd_Plane::Dump (Standard_OStream& anOS) const
{
anOS << "Plane";
return anOS;
}

76
src/TDataXtd/TDataXtd_Point.cdl Executable file
View File

@@ -0,0 +1,76 @@
-- File: TDataXtd_Point.cdl
-- Created: Mon Apr 6 18:26:21 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2008
class Point from TDataXtd inherits Attribute from TDF
---Purpose:
-- The basis to define a point attribute.
-- The topological attribute must contain a vertex.
-- You use this class to create reference points in a design.
--
-- Warning: Use TDataXtd_Geometry attribute to retrieve the
-- gp_Pnt of the Point attribute
uses Attribute from TDF,
Label from TDF,
GUID from Standard,
Pnt from gp,
DataSet from TDF,
RelocationTable from TDF
is
---Purpose: class methods
-- =============
GetID(myclass)
---C++: return const &
returns GUID from Standard;
---Purpose:
-- Returns the GUID for point attributes.
Set (myclass ; label : Label from TDF)
---Purpose:
-- Sets the label Label as a point attribute.
-- If no object is found, a point attribute is created.
returns Point from TDataXtd;
Set (myclass ; label : Label from TDF; P : Pnt from gp)
---Purpose:
-- Sets the label Label as a point attribute containing the point P.
-- If no object is found, a point attribute is created.
returns Point from TDataXtd;
---Purpose: Point methods
-- =============
Create
returns mutable Point from TDataXtd;
---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);
Dump (me; anOS : in out OStream from Standard)
returns OStream from Standard
is redefined;
---C++: return &
end Point;

135
src/TDataXtd/TDataXtd_Point.cxx Executable file
View File

@@ -0,0 +1,135 @@
// File: TDataXtd_Point.cxx
// Created: Mon Apr 6 18:27:28 2009
// Author: Sergey ZARITCHNY
// <szy@covox>
#include <TDataXtd_Point.ixx>
#include <TDataStd.hxx>
#include <TDataXtd.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <TNaming_Builder.hxx>
#include <BRep_Tool.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopAbs.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <Geom_CartesianPoint.hxx>
#include <BRep_Tool.hxx>
#define OCC2932
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Point::GetID()
{
static Standard_GUID TDataXtd_PointID("2a96b60d-ec8b-11d0-bee7-080009dc3333");
return TDataXtd_PointID;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Point) TDataXtd_Point::Set (const TDF_Label& L)
{
Handle(TDataXtd_Point) A;
if (!L.FindAttribute(TDataXtd_Point::GetID(),A)) {
A = new TDataXtd_Point ();
L.AddAttribute(A);
}
return A;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Point) TDataXtd_Point::Set (const TDF_Label& L, const gp_Pnt& P)
{
Handle(TDataXtd_Point) A = Set (L);
#ifdef OCC2932
Handle(TNaming_NamedShape) aNS;
if(L.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
if(!aNS->Get().IsNull())
if(aNS->Get().ShapeType() == TopAbs_VERTEX) {
gp_Pnt anOldPnt = BRep_Tool::Pnt(TopoDS::Vertex(aNS->Get()));
if(anOldPnt.X() == P.X() &&
anOldPnt.Y() == P.Y() &&
anOldPnt.Z() == P.Z()
)
return A;
}
}
#endif
TNaming_Builder B(L);
B.Generated(BRepBuilderAPI_MakeVertex(P));
return A;
}
//=======================================================================
//function : TDataXtd_Point
//purpose :
//=======================================================================
TDataXtd_Point::TDataXtd_Point () {}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Point::ID() const { return GetID ();}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataXtd_Point::NewEmpty () const
{
return new TDataXtd_Point();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataXtd_Point::Restore(const Handle(TDF_Attribute)& With) { }
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataXtd_Point::Paste (const Handle(TDF_Attribute)& Into, const Handle(TDF_RelocationTable)& RT) const { }
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
Standard_OStream& TDataXtd_Point::Dump (Standard_OStream& anOS) const
{
anOS << "Point";
return anOS;
}

View File

@@ -0,0 +1,88 @@
-- File: TDataXtd_Position.cdl
-- Created: Mon Apr 6 18:29:34 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2009
class Position from TDataXtd inherits Attribute from TDF
---Purpose: Position of a Label
uses
RelocationTable from TDF,
GUID from Standard,
Attribute from TDF,
Pnt from gp,
Label from TDF
is
Set(myclass; aLabel: Label from TDF; aPos : Pnt from gp);
---Purpose: Create if not found the TDataXtd_Position attribute set its position to <aPos>
Set (myclass; aLabel : Label from TDF)
---Purpose: Find an existing, or create an empty, Position.
-- the Position attribute is returned.
returns Position from TDataXtd;
Get(myclass; aLabel: Label from TDF; aPos : in out Pnt from gp)
---Purpose: Search label <aLabel) for the TDataXtd_Position attribute and get its position
-- if found returns True
returns Boolean from Standard;
Create
returns mutable Position from TDataXtd;
ID(me) returns GUID from Standard
is redefined static;
---Purpose: Returns the ID of the attribute.
---C++: return const &
GetID(myclass) returns GUID from Standard;
---Purpose: Returns the ID of the attribute.
---C++: return const &
Restore(me: mutable; anAttribute : Attribute from TDF)
is redefined;
---Purpose: Restores the contents from <anAttribute> into this
-- one. It is used when aborting a transaction.
--
-- Copy use methods
-- ----------------
NewEmpty(me)
returns mutable Attribute from TDF
is redefined;
---Purpose: Returns an new empty attribute from the good end
-- type. It is used by the copy algorithm.
Paste(me; intoAttribute : mutable Attribute from TDF;
aRelocTationable : mutable RelocationTable from TDF)
is redefined;
---Purpose: This method is different from the "Copy" one,
-- because it is used when copying an attribute from
-- a source structure into a target structure. This
-- method pastes the current attribute to the label
-- corresponding to the insertor. The pasted
-- attribute may be a brand new one or a new version
-- of the previous one.
GetPosition (me)
---C++: return const &
returns Pnt from gp;
SetPosition (me: mutable ; aPos : Pnt from gp);
fields
myPosition : Pnt from gp;
end Position;

View File

@@ -0,0 +1,134 @@
// File: TDataXtd_Position.cxx
// Created: Mon Apr 6 18:31:09 2009
// Author: Sergey ZARITCHNY
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2009
#include <TDataXtd_Position.ixx>
#include <TDF_Label.hxx>
//=======================================================================
//function : Set (class method)
//purpose :
//=======================================================================
void TDataXtd_Position::Set(const TDF_Label& aLabel, const gp_Pnt& aPos)
{
Handle(TDataXtd_Position) pos;
if (!aLabel.FindAttribute(TDataXtd_Position::GetID(), pos)) {
pos = new TDataXtd_Position();
aLabel.AddAttribute(pos);
}
pos->SetPosition( aPos );
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Position) TDataXtd_Position::Set (const TDF_Label& L)
{
Handle(TDataXtd_Position) POS;
if (!L.FindAttribute (TDataXtd_Position::GetID (), POS)) {
POS = new TDataXtd_Position;
L.AddAttribute(POS);
}
return POS;
}
//=======================================================================
//function : Get (class method)
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Position::Get(const TDF_Label& aLabel, gp_Pnt& aPos)
{
Handle(TDataXtd_Position) pos;
if( aLabel.FindAttribute( TDataXtd_Position::GetID(), pos) ) {
aPos = pos->GetPosition();
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Position::GetID()
{
static Standard_GUID TDataXtd_Position_guid("55553252-ce0c-11d1-b5d8-00a0c9064368");
return TDataXtd_Position_guid;
}
//=======================================================================
//function : TDataXtd_Position
//purpose :
//=======================================================================
TDataXtd_Position::TDataXtd_Position()
:myPosition(gp_Pnt(0.,0.,0.))
{
}
//=======================================================================
//function : GetPosition
//purpose :
//=======================================================================
const gp_Pnt& TDataXtd_Position::GetPosition() const
{
return myPosition;
}
//=======================================================================
//function : Position
//purpose :
//=======================================================================
void TDataXtd_Position::SetPosition(const gp_Pnt& aPos)
{
// OCC2932 correction
if(myPosition.X() == aPos.X() &&
myPosition.Y() == aPos.Y() &&
myPosition.Z() == aPos.Z())
return;
Backup();
myPosition = aPos;
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Position::ID() const
{
return GetID();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataXtd_Position::Restore(const Handle(TDF_Attribute)& anAttribute)
{
myPosition = Handle(TDataXtd_Position)::DownCast(anAttribute)->GetPosition();
}
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataXtd_Position::NewEmpty() const
{
return new TDataXtd_Position;
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataXtd_Position::Paste(const Handle(TDF_Attribute)& intoAttribute,
const Handle(TDF_RelocationTable)&) const
{
Handle(TDataXtd_Position)::DownCast(intoAttribute)->SetPosition(myPosition);
}

82
src/TDataXtd/TDataXtd_Shape.cdl Executable file
View File

@@ -0,0 +1,82 @@
-- File: TDataXtd_Shape.cdl
-- Created: Mon Apr 6 18:16:04 2009
-- Author: Sergey ZARITCHNY
-- <sergey.zaritchny@opencascade.com>
---Copyright: Open CasCade SA 2009
class Shape from TDataXtd inherits Attribute from TDF
---Purpose: A Shape is associated in the framework with :
-- a NamedShape attribute
uses Attribute from TDF,
Label from TDF,
NamedShape from TNaming,
GUID from Standard,
DataSet from TDF,
RelocationTable from TDF,
Shape from TopoDS
is
---Purpose: class methods
-- =============
Find (myclass; current : Label from TDF; S : in out Shape from TDataXtd)
---Purpose: try to retrieve a Shape attribute at <current> label
-- or in fathers label of <current>. Returns True if
-- found and set <S>.
returns Boolean from Standard;
New (myclass; label : Label from TDF)
---Purpose: Find, or create, a Shape attribute. the Shape attribute
-- is returned. Raises if <label> has attribute.
returns Shape from TDataXtd;
Set (myclass; label : Label from TDF; shape : Shape from TopoDS)
---Purpose: Create or update associated NamedShape attribute. the
-- Shape attribute is returned.
returns Shape from TDataXtd;
Get (myclass; label : Label from TDF)
---Purpose: the Shape from associated NamedShape attribute
-- is returned.
returns Shape from TopoDS;
GetID (myclass)
---C++: return const &
returns GUID from Standard;
---Purpose: Shape methods
-- ============
Create
returns mutable Shape from TDataXtd;
---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);
References (me; DS : DataSet from TDF) is redefined;
Dump(me; anOS : in out OStream from Standard)
returns OStream from Standard
is redefined;
---C++: return &
end Shape;

182
src/TDataXtd/TDataXtd_Shape.cxx Executable file
View File

@@ -0,0 +1,182 @@
// File: TDataXtd_Shape.cxx
// Created: Mon Apr 6 18:17:29 2009
// Author: Sergey ZARITCHNY
// <sergey.zaritchny@opencascade.com>
//Copyright: Open CasCade SA 2009
#include <TDataXtd_Shape.ixx>
#include <TDataStd.hxx>
#include <TDataXtd.hxx>
#include <TDF_Label.hxx>
#include <BRep_Builder.hxx>
#include <TopoDS_Solid.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TNaming_Tool.hxx>
#include <TNaming.hxx>
#define OCC2932
//=======================================================================
//function : Find
//purpose :
//=======================================================================
Standard_Boolean TDataXtd_Shape::Find (const TDF_Label& current,
Handle(TDataXtd_Shape)& S)
{
TDF_Label L = current;
Handle(TDataXtd_Shape) SA;
if (L.IsNull()) return Standard_False;
while (1) {
if(L.FindAttribute(TDataXtd_Shape::GetID(), SA)) break;
L = L.Father();
if (L.IsNull()) break;
}
if (!SA.IsNull()) {
S = SA;
return Standard_True;
}
return Standard_False;
}
//=======================================================================
//function : New
//purpose :
//=======================================================================
Handle(TDataXtd_Shape) TDataXtd_Shape::New (const TDF_Label& label)
{
if (label.HasAttribute()) {
Standard_DomainError::Raise("TDataXtd_Shape::New : not an empty label");
}
Handle(TDataXtd_Shape) A = new TDataXtd_Shape ();
label.AddAttribute(A);
return A;
}
//=======================================================================
//function : Set
//purpose :
//=======================================================================
Handle(TDataXtd_Shape) TDataXtd_Shape::Set (const TDF_Label& label, const TopoDS_Shape& shape)
{
Handle(TDataXtd_Shape) A;
if (!label.FindAttribute(TDataXtd_Shape::GetID(),A)) {
A = TDataXtd_Shape::New (label);
}
#ifdef OCC2932
Handle(TNaming_NamedShape) aNS;
if(label.FindAttribute(TNaming_NamedShape::GetID(), aNS)) {
if(!aNS->Get().IsNull())
if(aNS->Get() == shape)
return A;
}
#endif
TNaming_Builder B(label);
B.Generated(shape);
return A;
}
//=======================================================================
//function : Get
//purpose :
//=======================================================================
TopoDS_Shape TDataXtd_Shape::Get (const TDF_Label& label)
{
TopoDS_Shape shape;
Handle(TNaming_NamedShape) NS;
if( label.FindAttribute(TNaming_NamedShape::GetID(), NS)) {
shape = TNaming_Tool::GetShape(NS);
return shape;
}
shape.Nullify();
return shape;
}
//=======================================================================
//function : GetID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Shape::GetID()
{
static Standard_GUID TDataXtd_ShapeID("2a96b620-ec8b-11d0-bee7-080009dc3333");
return TDataXtd_ShapeID;
}
//=======================================================================
//function : TDataXtd_Shape
//purpose :
//=======================================================================
TDataXtd_Shape::TDataXtd_Shape()
{
}
//=======================================================================
//function : ID
//purpose :
//=======================================================================
const Standard_GUID& TDataXtd_Shape::ID() const
{ return GetID(); }
//=======================================================================
//function : NewEmpty
//purpose :
//=======================================================================
Handle(TDF_Attribute) TDataXtd_Shape::NewEmpty () const
{
return new TDataXtd_Shape();
}
//=======================================================================
//function : Restore
//purpose :
//=======================================================================
void TDataXtd_Shape::Restore(const Handle(TDF_Attribute)& with)
{
}
//=======================================================================
//function : Paste
//purpose :
//=======================================================================
void TDataXtd_Shape::Paste (const Handle(TDF_Attribute)& into,
const Handle(TDF_RelocationTable)& RT) const
{
}
//=======================================================================
//function : References
//purpose :
//=======================================================================
void TDataXtd_Shape::References (const Handle(TDF_DataSet)& DS) const
{
}
//=======================================================================
//function : Dump
//purpose :
//=======================================================================
Standard_OStream& TDataXtd_Shape::Dump (Standard_OStream& anOS) const
{
anOS << "Shape";
return anOS;
}